From 0f04787ffb587a979386bcce432dd181ac3a06db Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 9 Aug 2012 11:24:20 +1000 Subject: More consistent examples directory structure Under examples the next directory level distinguishes imports/modules and the next directory level distinguishes examples. Change-Id: Icabadaac6ccb9c1c424efa9c9e64a7d94bc7c0da Reviewed-by: Alan Alpert --- examples/localstorage/hello.qml | 78 -- examples/localstorage/localstorage.pro | 11 +- examples/localstorage/localstorage.qml | 66 -- examples/localstorage/localstorage.qmlproject | 16 - examples/localstorage/localstorage/hello.qml | 78 ++ .../localstorage/localstorage/localstorage.pro | 9 + .../localstorage/localstorage/localstorage.qml | 66 ++ .../localstorage/localstorage.qmlproject | 16 + examples/localstorage/localstorage/main.cpp | 41 + examples/localstorage/main.cpp | 41 - examples/qml/cppextensions/cppextensions.pro | 8 - .../qml/cppextensions/cppextensions.qmlproject | 16 - .../imageprovider/ImageProviderCore/qmldir | 2 - .../imageprovider/imageprovider-example.qml | 49 -- .../cppextensions/imageprovider/imageprovider.cpp | 109 --- .../cppextensions/imageprovider/imageprovider.pro | 22 - .../imageprovider/imageprovider.qmlproject | 14 - .../networkaccessmanagerfactory/main.cpp | 108 --- .../networkaccessmanagerfactory.pro | 4 - .../networkaccessmanagerfactory.qmlproject | 14 - .../networkaccessmanagerfactory.qrc | 5 - .../networkaccessmanagerfactory/view.qml | 47 -- examples/qml/cppextensions/plugins/README | 9 - .../plugins/com/nokia/TimeExample/Clock.qml | 90 --- .../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/qml/cppextensions/plugins/plugin.cpp | 155 ---- examples/qml/cppextensions/plugins/plugins.pro | 25 - examples/qml/cppextensions/plugins/plugins.qml | 53 -- .../qml/cppextensions/plugins/plugins.qmlproject | 16 - .../referenceexamples/adding/adding.pro | 11 - .../referenceexamples/adding/adding.qrc | 5 - .../referenceexamples/adding/example.qml | 48 -- .../referenceexamples/adding/main.cpp | 64 -- .../referenceexamples/adding/person.cpp | 68 -- .../referenceexamples/adding/person.h | 65 -- .../referenceexamples/attached/attached.pro | 13 - .../referenceexamples/attached/attached.qrc | 5 - .../referenceexamples/attached/birthdayparty.cpp | 91 --- .../referenceexamples/attached/birthdayparty.h | 89 --- .../referenceexamples/attached/example.qml | 69 -- .../referenceexamples/attached/main.cpp | 91 --- .../referenceexamples/attached/person.cpp | 118 --- .../referenceexamples/attached/person.h | 105 --- .../referenceexamples/binding/binding.pro | 15 - .../referenceexamples/binding/binding.qrc | 5 - .../referenceexamples/binding/birthdayparty.cpp | 113 --- .../referenceexamples/binding/birthdayparty.h | 102 --- .../referenceexamples/binding/example.qml | 78 -- .../binding/happybirthdaysong.cpp | 85 -- .../referenceexamples/binding/happybirthdaysong.h | 74 -- .../referenceexamples/binding/main.cpp | 92 --- .../referenceexamples/binding/person.cpp | 138 ---- .../referenceexamples/binding/person.h | 113 --- .../referenceexamples/coercion/birthdayparty.cpp | 71 -- .../referenceexamples/coercion/birthdayparty.h | 69 -- .../referenceexamples/coercion/coercion.pro | 13 - .../referenceexamples/coercion/coercion.qrc | 5 - .../referenceexamples/coercion/example.qml | 55 -- .../referenceexamples/coercion/main.cpp | 80 -- .../referenceexamples/coercion/person.cpp | 79 -- .../referenceexamples/coercion/person.h | 83 -- .../referenceexamples/default/birthdayparty.cpp | 71 -- .../referenceexamples/default/birthdayparty.h | 70 -- .../referenceexamples/default/default.pro | 13 - .../referenceexamples/default/default.qrc | 5 - .../referenceexamples/default/example.qml | 54 -- .../referenceexamples/default/main.cpp | 75 -- .../referenceexamples/default/person.cpp | 78 -- .../referenceexamples/default/person.h | 77 -- .../referenceexamples/extended/example.qml | 47 -- .../referenceexamples/extended/extended.pro | 11 - .../referenceexamples/extended/extended.qrc | 5 - .../referenceexamples/extended/lineedit.cpp | 104 --- .../referenceexamples/extended/lineedit.h | 73 -- .../referenceexamples/extended/main.cpp | 64 -- .../referenceexamples/grouped/birthdayparty.cpp | 71 -- .../referenceexamples/grouped/birthdayparty.h | 69 -- .../referenceexamples/grouped/example.qml | 78 -- .../referenceexamples/grouped/grouped.pro | 13 - .../referenceexamples/grouped/grouped.qrc | 5 - .../referenceexamples/grouped/main.cpp | 85 -- .../referenceexamples/grouped/person.cpp | 118 --- .../referenceexamples/grouped/person.h | 107 --- .../referenceexamples/methods/birthdayparty.cpp | 80 -- .../referenceexamples/methods/birthdayparty.h | 71 -- .../referenceexamples/methods/example.qml | 58 -- .../referenceexamples/methods/main.cpp | 68 -- .../referenceexamples/methods/methods.pro | 13 - .../referenceexamples/methods/methods.qrc | 5 - .../referenceexamples/methods/person.cpp | 66 -- .../referenceexamples/methods/person.h | 63 -- .../referenceexamples/properties/birthdayparty.cpp | 73 -- .../referenceexamples/properties/birthdayparty.h | 75 -- .../referenceexamples/properties/example.qml | 55 -- .../referenceexamples/properties/main.cpp | 70 -- .../referenceexamples/properties/person.cpp | 66 -- .../referenceexamples/properties/person.h | 63 -- .../referenceexamples/properties/properties.pro | 13 - .../referenceexamples/properties/properties.qrc | 5 - .../referenceexamples/referenceexamples.pro | 15 - .../referenceexamples/referenceexamples.qmlproject | 14 - .../referenceexamples/signal/birthdayparty.cpp | 98 --- .../referenceexamples/signal/birthdayparty.h | 92 --- .../referenceexamples/signal/example.qml | 73 -- .../referenceexamples/signal/main.cpp | 91 --- .../referenceexamples/signal/person.cpp | 118 --- .../referenceexamples/signal/person.h | 105 --- .../referenceexamples/signal/signal.pro | 13 - .../referenceexamples/signal/signal.qrc | 5 - .../valuesource/birthdayparty.cpp | 108 --- .../referenceexamples/valuesource/birthdayparty.h | 97 --- .../referenceexamples/valuesource/example.qml | 77 -- .../valuesource/happybirthdaysong.cpp | 80 -- .../valuesource/happybirthdaysong.h | 79 -- .../referenceexamples/valuesource/main.cpp | 93 --- .../referenceexamples/valuesource/person.cpp | 118 --- .../referenceexamples/valuesource/person.h | 105 --- .../referenceexamples/valuesource/valuesource.pro | 15 - .../referenceexamples/valuesource/valuesource.qrc | 5 - .../qml/imageprovider/ImageProviderCore/qmldir | 2 + .../qml/imageprovider/imageprovider-example.qml | 49 ++ examples/qml/imageprovider/imageprovider.cpp | 109 +++ examples/qml/imageprovider/imageprovider.pro | 22 + .../qml/imageprovider/imageprovider.qmlproject | 14 + examples/qml/networkaccessmanagerfactory/main.cpp | 108 +++ .../networkaccessmanagerfactory.pro | 4 + .../networkaccessmanagerfactory.qmlproject | 14 + .../networkaccessmanagerfactory.qrc | 5 + examples/qml/networkaccessmanagerfactory/view.qml | 47 ++ examples/qml/plugins/README | 9 + .../qml/plugins/com/nokia/TimeExample/Clock.qml | 90 +++ .../qml/plugins/com/nokia/TimeExample/center.png | Bin 0 -> 765 bytes .../qml/plugins/com/nokia/TimeExample/clock.png | Bin 0 -> 20653 bytes .../qml/plugins/com/nokia/TimeExample/hour.png | Bin 0 -> 625 bytes .../qml/plugins/com/nokia/TimeExample/minute.png | Bin 0 -> 625 bytes examples/qml/plugins/com/nokia/TimeExample/qmldir | 2 + examples/qml/plugins/plugin.cpp | 155 ++++ examples/qml/plugins/plugins.pro | 25 + examples/qml/plugins/plugins.qml | 53 ++ examples/qml/plugins/plugins.qmlproject | 16 + examples/qml/qml.pro | 6 + examples/qml/referenceexamples/adding/adding.pro | 11 + examples/qml/referenceexamples/adding/adding.qrc | 5 + examples/qml/referenceexamples/adding/example.qml | 48 ++ examples/qml/referenceexamples/adding/main.cpp | 64 ++ examples/qml/referenceexamples/adding/person.cpp | 68 ++ examples/qml/referenceexamples/adding/person.h | 65 ++ .../qml/referenceexamples/attached/attached.pro | 13 + .../qml/referenceexamples/attached/attached.qrc | 5 + .../referenceexamples/attached/birthdayparty.cpp | 91 +++ .../qml/referenceexamples/attached/birthdayparty.h | 89 +++ .../qml/referenceexamples/attached/example.qml | 69 ++ examples/qml/referenceexamples/attached/main.cpp | 91 +++ examples/qml/referenceexamples/attached/person.cpp | 118 +++ examples/qml/referenceexamples/attached/person.h | 105 +++ examples/qml/referenceexamples/binding/binding.pro | 15 + examples/qml/referenceexamples/binding/binding.qrc | 5 + .../referenceexamples/binding/birthdayparty.cpp | 113 +++ .../qml/referenceexamples/binding/birthdayparty.h | 102 +++ examples/qml/referenceexamples/binding/example.qml | 78 ++ .../binding/happybirthdaysong.cpp | 85 ++ .../referenceexamples/binding/happybirthdaysong.h | 74 ++ examples/qml/referenceexamples/binding/main.cpp | 92 +++ examples/qml/referenceexamples/binding/person.cpp | 138 ++++ examples/qml/referenceexamples/binding/person.h | 113 +++ .../referenceexamples/coercion/birthdayparty.cpp | 71 ++ .../qml/referenceexamples/coercion/birthdayparty.h | 69 ++ .../qml/referenceexamples/coercion/coercion.pro | 13 + .../qml/referenceexamples/coercion/coercion.qrc | 5 + .../qml/referenceexamples/coercion/example.qml | 55 ++ examples/qml/referenceexamples/coercion/main.cpp | 80 ++ examples/qml/referenceexamples/coercion/person.cpp | 79 ++ examples/qml/referenceexamples/coercion/person.h | 83 ++ .../referenceexamples/default/birthdayparty.cpp | 71 ++ .../qml/referenceexamples/default/birthdayparty.h | 70 ++ examples/qml/referenceexamples/default/default.pro | 13 + examples/qml/referenceexamples/default/default.qrc | 5 + examples/qml/referenceexamples/default/example.qml | 54 ++ examples/qml/referenceexamples/default/main.cpp | 75 ++ examples/qml/referenceexamples/default/person.cpp | 78 ++ examples/qml/referenceexamples/default/person.h | 77 ++ .../qml/referenceexamples/extended/example.qml | 47 ++ .../qml/referenceexamples/extended/extended.pro | 11 + .../qml/referenceexamples/extended/extended.qrc | 5 + .../qml/referenceexamples/extended/lineedit.cpp | 104 +++ examples/qml/referenceexamples/extended/lineedit.h | 73 ++ examples/qml/referenceexamples/extended/main.cpp | 64 ++ .../referenceexamples/grouped/birthdayparty.cpp | 71 ++ .../qml/referenceexamples/grouped/birthdayparty.h | 69 ++ examples/qml/referenceexamples/grouped/example.qml | 78 ++ examples/qml/referenceexamples/grouped/grouped.pro | 13 + examples/qml/referenceexamples/grouped/grouped.qrc | 5 + examples/qml/referenceexamples/grouped/main.cpp | 85 ++ examples/qml/referenceexamples/grouped/person.cpp | 118 +++ examples/qml/referenceexamples/grouped/person.h | 107 +++ .../referenceexamples/methods/birthdayparty.cpp | 80 ++ .../qml/referenceexamples/methods/birthdayparty.h | 71 ++ examples/qml/referenceexamples/methods/example.qml | 58 ++ examples/qml/referenceexamples/methods/main.cpp | 68 ++ examples/qml/referenceexamples/methods/methods.pro | 13 + examples/qml/referenceexamples/methods/methods.qrc | 5 + examples/qml/referenceexamples/methods/person.cpp | 66 ++ examples/qml/referenceexamples/methods/person.h | 63 ++ .../referenceexamples/properties/birthdayparty.cpp | 73 ++ .../referenceexamples/properties/birthdayparty.h | 75 ++ .../qml/referenceexamples/properties/example.qml | 55 ++ examples/qml/referenceexamples/properties/main.cpp | 70 ++ .../qml/referenceexamples/properties/person.cpp | 66 ++ examples/qml/referenceexamples/properties/person.h | 63 ++ .../referenceexamples/properties/properties.pro | 13 + .../referenceexamples/properties/properties.qrc | 5 + .../qml/referenceexamples/referenceexamples.pro | 15 + .../referenceexamples/referenceexamples.qmlproject | 14 + .../qml/referenceexamples/signal/birthdayparty.cpp | 98 +++ .../qml/referenceexamples/signal/birthdayparty.h | 92 +++ examples/qml/referenceexamples/signal/example.qml | 73 ++ examples/qml/referenceexamples/signal/main.cpp | 91 +++ examples/qml/referenceexamples/signal/person.cpp | 118 +++ examples/qml/referenceexamples/signal/person.h | 105 +++ examples/qml/referenceexamples/signal/signal.pro | 13 + examples/qml/referenceexamples/signal/signal.qrc | 5 + .../valuesource/birthdayparty.cpp | 108 +++ .../referenceexamples/valuesource/birthdayparty.h | 97 +++ .../qml/referenceexamples/valuesource/example.qml | 77 ++ .../valuesource/happybirthdaysong.cpp | 80 ++ .../valuesource/happybirthdaysong.h | 79 ++ .../qml/referenceexamples/valuesource/main.cpp | 93 +++ .../qml/referenceexamples/valuesource/person.cpp | 118 +++ .../qml/referenceexamples/valuesource/person.h | 105 +++ .../referenceexamples/valuesource/valuesource.pro | 15 + .../referenceexamples/valuesource/valuesource.qrc | 5 + examples/qml/script/script.pro | 4 - examples/qml/script/shell/main.cpp | 153 ---- examples/qml/script/shell/shell.pro | 7 - examples/qml/shell/main.cpp | 153 ++++ examples/qml/shell/shell.pro | 7 + examples/qmltest/qmltest.pro | 6 +- examples/qmltest/qmltest/qmltest.pro | 4 + examples/qmltest/qmltest/tst_basic.qml | 79 ++ examples/qmltest/qmltest/tst_item.qml | 58 ++ examples/qmltest/qmltest/tst_qmltest.cpp | 43 + examples/qmltest/tst_basic.qml | 79 -- examples/qmltest/tst_item.qml | 58 -- examples/qmltest/tst_qmltest.cpp | 43 - examples/quick/customitems/customitems.pro | 13 + .../quick/customitems/dialcontrol/content/Dial.qml | 86 ++ .../customitems/dialcontrol/content/QuitButton.qml | 52 ++ .../customitems/dialcontrol/content/background.png | Bin 0 -> 35876 bytes .../customitems/dialcontrol/content/needle.png | Bin 0 -> 342 bytes .../dialcontrol/content/needle_shadow.png | Bin 0 -> 632 bytes .../customitems/dialcontrol/content/overlay.png | Bin 0 -> 3564 bytes .../quick/customitems/dialcontrol/content/quit.png | Bin 0 -> 583 bytes .../quick/customitems/dialcontrol/dialcontrol.qml | 100 +++ .../quick/customitems/flipable/content/5_heart.png | Bin 0 -> 3872 bytes .../quick/customitems/flipable/content/9_club.png | Bin 0 -> 6135 bytes .../quick/customitems/flipable/content/Card.qml | 80 ++ .../quick/customitems/flipable/content/back.png | Bin 0 -> 1418 bytes examples/quick/customitems/flipable/flipable.qml | 55 ++ examples/quick/customitems/glitem/glitem.pro | 6 + examples/quick/customitems/glitem/main.cpp | 60 ++ examples/quick/customitems/glitem/main.qml | 81 ++ examples/quick/customitems/glitem/squircle.cpp | 123 +++ examples/quick/customitems/glitem/squircle.h | 76 ++ .../customitems/maskedmousearea/images/cloud_1.png | Bin 0 -> 49524 bytes .../customitems/maskedmousearea/images/cloud_2.png | Bin 0 -> 32288 bytes .../customitems/maskedmousearea/images/moon.png | Bin 0 -> 13263 bytes .../quick/customitems/maskedmousearea/main.cpp | 57 ++ .../maskedmousearea/maskedmousearea.cpp | 141 ++++ .../customitems/maskedmousearea/maskedmousearea.h | 98 +++ .../maskedmousearea/maskedmousearea.pro | 14 + .../maskedmousearea/maskedmousearea.qml | 135 ++++ .../maskedmousearea/maskedmousearea.qmlproject | 16 + .../painteditem/TextBalloonPlugin/plugin.h | 55 ++ .../painteditem/TextBalloonPlugin/qmldir | 1 + .../quick/customitems/painteditem/painteditem.pro | 25 + .../quick/customitems/painteditem/textballoon.cpp | 92 +++ .../quick/customitems/painteditem/textballoon.h | 68 ++ .../quick/customitems/painteditem/textballoons.qml | 115 +++ .../progressbar/content/ProgressBar.qml | 83 ++ .../customitems/progressbar/content/background.png | Bin 0 -> 426 bytes examples/quick/customitems/progressbar/main.qml | 73 ++ examples/quick/customitems/scrollbar/ScrollBar.qml | 74 ++ examples/quick/customitems/scrollbar/main.qml | 93 +++ .../customitems/scrollbar/pics/niagara_falls.jpg | Bin 0 -> 142510 bytes .../customitems/scrollbar/scrollbar.qmlproject | 16 + examples/quick/customitems/searchbox/SearchBox.qml | 109 +++ .../quick/customitems/searchbox/images/clear.png | Bin 0 -> 429 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 0 -> 526 bytes .../customitems/searchbox/images/lineedit-bg.png | Bin 0 -> 426 bytes examples/quick/customitems/searchbox/main.qml | 60 ++ .../customitems/searchbox/searchbox.qmlproject | 16 + .../customitems/slideswitch/content/Switch.qml | 117 +++ .../customitems/slideswitch/content/background.png | Bin 0 -> 3091 bytes .../customitems/slideswitch/content/background.svg | 23 + .../quick/customitems/slideswitch/content/knob.png | Bin 0 -> 3101 bytes .../quick/customitems/slideswitch/content/knob.svg | 867 +++++++++++++++++++++ .../quick/customitems/slideswitch/slideswitch.qml | 51 ++ .../quick/customitems/spinner/content/Spinner.qml | 70 ++ .../customitems/spinner/content/spinner-bg.png | Bin 0 -> 345 bytes .../customitems/spinner/content/spinner-select.png | Bin 0 -> 320 bytes examples/quick/customitems/spinner/main.qml | 61 ++ .../quick/customitems/spinner/spinner.qmlproject | 16 + examples/quick/customitems/tabwidget/TabWidget.qml | 102 +++ examples/quick/customitems/tabwidget/main.qml | 99 +++ examples/quick/customitems/tabwidget/tab.png | Bin 0 -> 507 bytes .../customitems/tabwidget/tabwidget.qmlproject | 16 + examples/quick/maskedmousearea/images/cloud_1.png | Bin 49524 -> 0 bytes examples/quick/maskedmousearea/images/cloud_2.png | Bin 32288 -> 0 bytes examples/quick/maskedmousearea/images/moon.png | Bin 13263 -> 0 bytes examples/quick/maskedmousearea/main.cpp | 57 -- examples/quick/maskedmousearea/maskedmousearea.cpp | 141 ---- examples/quick/maskedmousearea/maskedmousearea.h | 98 --- examples/quick/maskedmousearea/maskedmousearea.pro | 14 - examples/quick/maskedmousearea/maskedmousearea.qml | 135 ---- .../maskedmousearea/maskedmousearea.qmlproject | 16 - examples/quick/openglunderqml/main.cpp | 60 -- examples/quick/openglunderqml/main.qml | 81 -- examples/quick/openglunderqml/openglunderqml.pro | 6 - examples/quick/openglunderqml/squircle.cpp | 123 --- examples/quick/openglunderqml/squircle.h | 76 -- examples/quick/painteditem/painteditem.pro | 5 - examples/quick/painteditem/smile/main.cpp | 96 --- examples/quick/painteditem/smile/smile.pro | 11 - examples/quick/painteditem/smile/smile.qml | 80 -- .../textballoons/TextBalloonPlugin/plugin.h | 55 -- .../textballoons/TextBalloonPlugin/qmldir | 1 - .../quick/painteditem/textballoons/textballoon.cpp | 92 --- .../quick/painteditem/textballoons/textballoon.h | 68 -- .../painteditem/textballoons/textballoons.pro | 25 - .../painteditem/textballoons/textballoons.qml | 115 --- examples/quick/quick.pro | 5 +- .../ui-components/dialcontrol/content/Dial.qml | 86 -- .../dialcontrol/content/QuitButton.qml | 52 -- .../dialcontrol/content/background.png | Bin 35876 -> 0 bytes .../ui-components/dialcontrol/content/needle.png | Bin 342 -> 0 bytes .../dialcontrol/content/needle_shadow.png | Bin 632 -> 0 bytes .../ui-components/dialcontrol/content/overlay.png | Bin 3564 -> 0 bytes .../ui-components/dialcontrol/content/quit.png | Bin 583 -> 0 bytes .../ui-components/dialcontrol/dialcontrol.qml | 100 --- .../ui-components/flipable/content/5_heart.png | Bin 3872 -> 0 bytes .../ui-components/flipable/content/9_club.png | Bin 6135 -> 0 bytes .../ui-components/flipable/content/Card.qml | 80 -- .../ui-components/flipable/content/back.png | Bin 1418 -> 0 bytes .../tutorials/ui-components/flipable/flipable.qml | 55 -- .../progressbar/content/ProgressBar.qml | 83 -- .../progressbar/content/background.png | Bin 426 -> 0 bytes .../tutorials/ui-components/progressbar/main.qml | 73 -- .../ui-components/scrollbar/ScrollBar.qml | 74 -- .../tutorials/ui-components/scrollbar/main.qml | 93 --- .../ui-components/scrollbar/pics/niagara_falls.jpg | Bin 142510 -> 0 bytes .../ui-components/scrollbar/scrollbar.qmlproject | 16 - .../ui-components/searchbox/SearchBox.qml | 109 --- .../ui-components/searchbox/images/clear.png | Bin 429 -> 0 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 526 -> 0 bytes .../ui-components/searchbox/images/lineedit-bg.png | Bin 426 -> 0 bytes .../tutorials/ui-components/searchbox/main.qml | 60 -- .../ui-components/searchbox/searchbox.qmlproject | 16 - .../ui-components/slideswitch/content/Switch.qml | 117 --- .../slideswitch/content/background.png | Bin 3091 -> 0 bytes .../slideswitch/content/background.svg | 23 - .../ui-components/slideswitch/content/knob.png | Bin 3101 -> 0 bytes .../ui-components/slideswitch/content/knob.svg | 867 --------------------- .../ui-components/slideswitch/slideswitch.qml | 51 -- .../ui-components/spinner/content/Spinner.qml | 70 -- .../ui-components/spinner/content/spinner-bg.png | Bin 345 -> 0 bytes .../spinner/content/spinner-select.png | Bin 320 -> 0 bytes examples/tutorials/ui-components/spinner/main.qml | 61 -- .../ui-components/spinner/spinner.qmlproject | 16 - .../ui-components/tabwidget/TabWidget.qml | 102 --- .../tutorials/ui-components/tabwidget/main.qml | 99 --- examples/tutorials/ui-components/tabwidget/tab.png | Bin 507 -> 0 bytes .../ui-components/tabwidget/tabwidget.qmlproject | 16 - examples/window/Window.qml | 58 -- examples/window/standalone.qml | 71 -- examples/window/window.cpp | 58 -- examples/window/window.pro | 9 +- examples/window/window/Window.qml | 58 ++ examples/window/window/standalone.qml | 71 ++ examples/window/window/window.cpp | 58 ++ examples/window/window/window.pro | 5 + 384 files changed, 10631 insertions(+), 10825 deletions(-) delete mode 100644 examples/localstorage/hello.qml delete mode 100644 examples/localstorage/localstorage.qml delete mode 100644 examples/localstorage/localstorage.qmlproject create mode 100644 examples/localstorage/localstorage/hello.qml create mode 100644 examples/localstorage/localstorage/localstorage.pro create mode 100644 examples/localstorage/localstorage/localstorage.qml create mode 100644 examples/localstorage/localstorage/localstorage.qmlproject create mode 100644 examples/localstorage/localstorage/main.cpp delete mode 100644 examples/localstorage/main.cpp delete mode 100644 examples/qml/cppextensions/cppextensions.pro delete mode 100644 examples/qml/cppextensions/cppextensions.qmlproject delete mode 100644 examples/qml/cppextensions/imageprovider/ImageProviderCore/qmldir delete mode 100644 examples/qml/cppextensions/imageprovider/imageprovider-example.qml delete mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.cpp delete mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.pro delete mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.qmlproject delete mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp delete mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro delete mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject delete mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc delete mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/view.qml delete mode 100644 examples/qml/cppextensions/plugins/README delete mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml delete mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png delete mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png delete mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png delete mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png delete mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir delete mode 100644 examples/qml/cppextensions/plugins/plugin.cpp delete mode 100644 examples/qml/cppextensions/plugins/plugins.pro delete mode 100644 examples/qml/cppextensions/plugins/plugins.qml delete mode 100644 examples/qml/cppextensions/plugins/plugins.qmlproject delete mode 100644 examples/qml/cppextensions/referenceexamples/adding/adding.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/adding/adding.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/adding/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/adding/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/adding/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/adding/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/attached/attached.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/attached/attached.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h delete mode 100644 examples/qml/cppextensions/referenceexamples/attached/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/attached/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/attached/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/attached/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/binding.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/binding.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/binding/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h delete mode 100644 examples/qml/cppextensions/referenceexamples/coercion/coercion.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/coercion/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/coercion/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/coercion/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/coercion/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/default/birthdayparty.h delete mode 100644 examples/qml/cppextensions/referenceexamples/default/default.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/default/default.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/default/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/default/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/default/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/default/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/extended/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/extended/extended.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/extended/extended.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/extended/lineedit.h delete mode 100644 examples/qml/cppextensions/referenceexamples/extended/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h delete mode 100644 examples/qml/cppextensions/referenceexamples/grouped/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/grouped/grouped.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/grouped/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/grouped/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/grouped/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h delete mode 100644 examples/qml/cppextensions/referenceexamples/methods/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/methods/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/methods/methods.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/methods/methods.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/methods/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/methods/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h delete mode 100644 examples/qml/cppextensions/referenceexamples/properties/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/properties/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/properties/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/properties/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/properties/properties.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/properties/properties.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/referenceexamples.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject delete mode 100644 examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h delete mode 100644 examples/qml/cppextensions/referenceexamples/signal/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/signal/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/signal/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/signal/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/signal/signal.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/signal/signal.qrc delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/example.qml delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/main.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/person.cpp delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/person.h delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro delete mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc create mode 100644 examples/qml/imageprovider/ImageProviderCore/qmldir create mode 100644 examples/qml/imageprovider/imageprovider-example.qml create mode 100644 examples/qml/imageprovider/imageprovider.cpp create mode 100644 examples/qml/imageprovider/imageprovider.pro create mode 100644 examples/qml/imageprovider/imageprovider.qmlproject create mode 100644 examples/qml/networkaccessmanagerfactory/main.cpp create mode 100644 examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.pro create mode 100644 examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject create mode 100644 examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc create mode 100644 examples/qml/networkaccessmanagerfactory/view.qml create mode 100644 examples/qml/plugins/README create mode 100644 examples/qml/plugins/com/nokia/TimeExample/Clock.qml create mode 100644 examples/qml/plugins/com/nokia/TimeExample/center.png create mode 100644 examples/qml/plugins/com/nokia/TimeExample/clock.png create mode 100644 examples/qml/plugins/com/nokia/TimeExample/hour.png create mode 100644 examples/qml/plugins/com/nokia/TimeExample/minute.png create mode 100644 examples/qml/plugins/com/nokia/TimeExample/qmldir create mode 100644 examples/qml/plugins/plugin.cpp create mode 100644 examples/qml/plugins/plugins.pro create mode 100644 examples/qml/plugins/plugins.qml create mode 100644 examples/qml/plugins/plugins.qmlproject create mode 100644 examples/qml/referenceexamples/adding/adding.pro create mode 100644 examples/qml/referenceexamples/adding/adding.qrc create mode 100644 examples/qml/referenceexamples/adding/example.qml create mode 100644 examples/qml/referenceexamples/adding/main.cpp create mode 100644 examples/qml/referenceexamples/adding/person.cpp create mode 100644 examples/qml/referenceexamples/adding/person.h create mode 100644 examples/qml/referenceexamples/attached/attached.pro create mode 100644 examples/qml/referenceexamples/attached/attached.qrc create mode 100644 examples/qml/referenceexamples/attached/birthdayparty.cpp create mode 100644 examples/qml/referenceexamples/attached/birthdayparty.h create mode 100644 examples/qml/referenceexamples/attached/example.qml create mode 100644 examples/qml/referenceexamples/attached/main.cpp create mode 100644 examples/qml/referenceexamples/attached/person.cpp create mode 100644 examples/qml/referenceexamples/attached/person.h create mode 100644 examples/qml/referenceexamples/binding/binding.pro create mode 100644 examples/qml/referenceexamples/binding/binding.qrc create mode 100644 examples/qml/referenceexamples/binding/birthdayparty.cpp create mode 100644 examples/qml/referenceexamples/binding/birthdayparty.h create mode 100644 examples/qml/referenceexamples/binding/example.qml create mode 100644 examples/qml/referenceexamples/binding/happybirthdaysong.cpp create mode 100644 examples/qml/referenceexamples/binding/happybirthdaysong.h create mode 100644 examples/qml/referenceexamples/binding/main.cpp create mode 100644 examples/qml/referenceexamples/binding/person.cpp create mode 100644 examples/qml/referenceexamples/binding/person.h create mode 100644 examples/qml/referenceexamples/coercion/birthdayparty.cpp create mode 100644 examples/qml/referenceexamples/coercion/birthdayparty.h create mode 100644 examples/qml/referenceexamples/coercion/coercion.pro create mode 100644 examples/qml/referenceexamples/coercion/coercion.qrc create mode 100644 examples/qml/referenceexamples/coercion/example.qml create mode 100644 examples/qml/referenceexamples/coercion/main.cpp create mode 100644 examples/qml/referenceexamples/coercion/person.cpp create mode 100644 examples/qml/referenceexamples/coercion/person.h create mode 100644 examples/qml/referenceexamples/default/birthdayparty.cpp create mode 100644 examples/qml/referenceexamples/default/birthdayparty.h create mode 100644 examples/qml/referenceexamples/default/default.pro create mode 100644 examples/qml/referenceexamples/default/default.qrc create mode 100644 examples/qml/referenceexamples/default/example.qml create mode 100644 examples/qml/referenceexamples/default/main.cpp create mode 100644 examples/qml/referenceexamples/default/person.cpp create mode 100644 examples/qml/referenceexamples/default/person.h create mode 100644 examples/qml/referenceexamples/extended/example.qml create mode 100644 examples/qml/referenceexamples/extended/extended.pro create mode 100644 examples/qml/referenceexamples/extended/extended.qrc create mode 100644 examples/qml/referenceexamples/extended/lineedit.cpp create mode 100644 examples/qml/referenceexamples/extended/lineedit.h create mode 100644 examples/qml/referenceexamples/extended/main.cpp create mode 100644 examples/qml/referenceexamples/grouped/birthdayparty.cpp create mode 100644 examples/qml/referenceexamples/grouped/birthdayparty.h create mode 100644 examples/qml/referenceexamples/grouped/example.qml create mode 100644 examples/qml/referenceexamples/grouped/grouped.pro create mode 100644 examples/qml/referenceexamples/grouped/grouped.qrc create mode 100644 examples/qml/referenceexamples/grouped/main.cpp create mode 100644 examples/qml/referenceexamples/grouped/person.cpp create mode 100644 examples/qml/referenceexamples/grouped/person.h create mode 100644 examples/qml/referenceexamples/methods/birthdayparty.cpp create mode 100644 examples/qml/referenceexamples/methods/birthdayparty.h create mode 100644 examples/qml/referenceexamples/methods/example.qml create mode 100644 examples/qml/referenceexamples/methods/main.cpp create mode 100644 examples/qml/referenceexamples/methods/methods.pro create mode 100644 examples/qml/referenceexamples/methods/methods.qrc create mode 100644 examples/qml/referenceexamples/methods/person.cpp create mode 100644 examples/qml/referenceexamples/methods/person.h create mode 100644 examples/qml/referenceexamples/properties/birthdayparty.cpp create mode 100644 examples/qml/referenceexamples/properties/birthdayparty.h create mode 100644 examples/qml/referenceexamples/properties/example.qml create mode 100644 examples/qml/referenceexamples/properties/main.cpp create mode 100644 examples/qml/referenceexamples/properties/person.cpp create mode 100644 examples/qml/referenceexamples/properties/person.h create mode 100644 examples/qml/referenceexamples/properties/properties.pro create mode 100644 examples/qml/referenceexamples/properties/properties.qrc create mode 100644 examples/qml/referenceexamples/referenceexamples.pro create mode 100644 examples/qml/referenceexamples/referenceexamples.qmlproject create mode 100644 examples/qml/referenceexamples/signal/birthdayparty.cpp create mode 100644 examples/qml/referenceexamples/signal/birthdayparty.h create mode 100644 examples/qml/referenceexamples/signal/example.qml create mode 100644 examples/qml/referenceexamples/signal/main.cpp create mode 100644 examples/qml/referenceexamples/signal/person.cpp create mode 100644 examples/qml/referenceexamples/signal/person.h create mode 100644 examples/qml/referenceexamples/signal/signal.pro create mode 100644 examples/qml/referenceexamples/signal/signal.qrc create mode 100644 examples/qml/referenceexamples/valuesource/birthdayparty.cpp create mode 100644 examples/qml/referenceexamples/valuesource/birthdayparty.h create mode 100644 examples/qml/referenceexamples/valuesource/example.qml create mode 100644 examples/qml/referenceexamples/valuesource/happybirthdaysong.cpp create mode 100644 examples/qml/referenceexamples/valuesource/happybirthdaysong.h create mode 100644 examples/qml/referenceexamples/valuesource/main.cpp create mode 100644 examples/qml/referenceexamples/valuesource/person.cpp create mode 100644 examples/qml/referenceexamples/valuesource/person.h create mode 100644 examples/qml/referenceexamples/valuesource/valuesource.pro create mode 100644 examples/qml/referenceexamples/valuesource/valuesource.qrc delete mode 100644 examples/qml/script/script.pro delete mode 100644 examples/qml/script/shell/main.cpp delete mode 100644 examples/qml/script/shell/shell.pro create mode 100644 examples/qml/shell/main.cpp create mode 100644 examples/qml/shell/shell.pro create mode 100644 examples/qmltest/qmltest/qmltest.pro create mode 100644 examples/qmltest/qmltest/tst_basic.qml create mode 100644 examples/qmltest/qmltest/tst_item.qml create mode 100644 examples/qmltest/qmltest/tst_qmltest.cpp delete mode 100644 examples/qmltest/tst_basic.qml delete mode 100644 examples/qmltest/tst_item.qml delete mode 100644 examples/qmltest/tst_qmltest.cpp create mode 100644 examples/quick/customitems/customitems.pro create mode 100644 examples/quick/customitems/dialcontrol/content/Dial.qml create mode 100644 examples/quick/customitems/dialcontrol/content/QuitButton.qml create mode 100644 examples/quick/customitems/dialcontrol/content/background.png create mode 100644 examples/quick/customitems/dialcontrol/content/needle.png create mode 100644 examples/quick/customitems/dialcontrol/content/needle_shadow.png create mode 100644 examples/quick/customitems/dialcontrol/content/overlay.png create mode 100644 examples/quick/customitems/dialcontrol/content/quit.png create mode 100644 examples/quick/customitems/dialcontrol/dialcontrol.qml create mode 100644 examples/quick/customitems/flipable/content/5_heart.png create mode 100644 examples/quick/customitems/flipable/content/9_club.png create mode 100644 examples/quick/customitems/flipable/content/Card.qml create mode 100644 examples/quick/customitems/flipable/content/back.png create mode 100644 examples/quick/customitems/flipable/flipable.qml create mode 100644 examples/quick/customitems/glitem/glitem.pro create mode 100644 examples/quick/customitems/glitem/main.cpp create mode 100644 examples/quick/customitems/glitem/main.qml create mode 100644 examples/quick/customitems/glitem/squircle.cpp create mode 100644 examples/quick/customitems/glitem/squircle.h create mode 100644 examples/quick/customitems/maskedmousearea/images/cloud_1.png create mode 100644 examples/quick/customitems/maskedmousearea/images/cloud_2.png create mode 100644 examples/quick/customitems/maskedmousearea/images/moon.png create mode 100644 examples/quick/customitems/maskedmousearea/main.cpp create mode 100644 examples/quick/customitems/maskedmousearea/maskedmousearea.cpp create mode 100644 examples/quick/customitems/maskedmousearea/maskedmousearea.h create mode 100644 examples/quick/customitems/maskedmousearea/maskedmousearea.pro create mode 100644 examples/quick/customitems/maskedmousearea/maskedmousearea.qml create mode 100644 examples/quick/customitems/maskedmousearea/maskedmousearea.qmlproject create mode 100644 examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h create mode 100644 examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir create mode 100644 examples/quick/customitems/painteditem/painteditem.pro create mode 100644 examples/quick/customitems/painteditem/textballoon.cpp create mode 100644 examples/quick/customitems/painteditem/textballoon.h create mode 100644 examples/quick/customitems/painteditem/textballoons.qml create mode 100644 examples/quick/customitems/progressbar/content/ProgressBar.qml create mode 100644 examples/quick/customitems/progressbar/content/background.png create mode 100644 examples/quick/customitems/progressbar/main.qml create mode 100644 examples/quick/customitems/scrollbar/ScrollBar.qml create mode 100644 examples/quick/customitems/scrollbar/main.qml create mode 100644 examples/quick/customitems/scrollbar/pics/niagara_falls.jpg create mode 100644 examples/quick/customitems/scrollbar/scrollbar.qmlproject create mode 100644 examples/quick/customitems/searchbox/SearchBox.qml create mode 100644 examples/quick/customitems/searchbox/images/clear.png create mode 100644 examples/quick/customitems/searchbox/images/lineedit-bg-focus.png create mode 100644 examples/quick/customitems/searchbox/images/lineedit-bg.png create mode 100644 examples/quick/customitems/searchbox/main.qml create mode 100644 examples/quick/customitems/searchbox/searchbox.qmlproject create mode 100644 examples/quick/customitems/slideswitch/content/Switch.qml create mode 100644 examples/quick/customitems/slideswitch/content/background.png create mode 100644 examples/quick/customitems/slideswitch/content/background.svg create mode 100644 examples/quick/customitems/slideswitch/content/knob.png create mode 100644 examples/quick/customitems/slideswitch/content/knob.svg create mode 100644 examples/quick/customitems/slideswitch/slideswitch.qml create mode 100644 examples/quick/customitems/spinner/content/Spinner.qml create mode 100644 examples/quick/customitems/spinner/content/spinner-bg.png create mode 100644 examples/quick/customitems/spinner/content/spinner-select.png create mode 100644 examples/quick/customitems/spinner/main.qml create mode 100644 examples/quick/customitems/spinner/spinner.qmlproject create mode 100644 examples/quick/customitems/tabwidget/TabWidget.qml create mode 100644 examples/quick/customitems/tabwidget/main.qml create mode 100644 examples/quick/customitems/tabwidget/tab.png create mode 100644 examples/quick/customitems/tabwidget/tabwidget.qmlproject delete mode 100644 examples/quick/maskedmousearea/images/cloud_1.png delete mode 100644 examples/quick/maskedmousearea/images/cloud_2.png delete mode 100644 examples/quick/maskedmousearea/images/moon.png delete mode 100644 examples/quick/maskedmousearea/main.cpp delete mode 100644 examples/quick/maskedmousearea/maskedmousearea.cpp delete mode 100644 examples/quick/maskedmousearea/maskedmousearea.h delete mode 100644 examples/quick/maskedmousearea/maskedmousearea.pro delete mode 100644 examples/quick/maskedmousearea/maskedmousearea.qml delete mode 100644 examples/quick/maskedmousearea/maskedmousearea.qmlproject delete mode 100644 examples/quick/openglunderqml/main.cpp delete mode 100644 examples/quick/openglunderqml/main.qml delete mode 100644 examples/quick/openglunderqml/openglunderqml.pro delete mode 100644 examples/quick/openglunderqml/squircle.cpp delete mode 100644 examples/quick/openglunderqml/squircle.h delete mode 100644 examples/quick/painteditem/painteditem.pro delete mode 100644 examples/quick/painteditem/smile/main.cpp delete mode 100644 examples/quick/painteditem/smile/smile.pro delete mode 100644 examples/quick/painteditem/smile/smile.qml delete mode 100644 examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h delete mode 100644 examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir delete mode 100644 examples/quick/painteditem/textballoons/textballoon.cpp delete mode 100644 examples/quick/painteditem/textballoons/textballoon.h delete mode 100644 examples/quick/painteditem/textballoons/textballoons.pro delete mode 100644 examples/quick/painteditem/textballoons/textballoons.qml delete mode 100644 examples/tutorials/ui-components/dialcontrol/content/Dial.qml delete mode 100644 examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml delete mode 100644 examples/tutorials/ui-components/dialcontrol/content/background.png delete mode 100644 examples/tutorials/ui-components/dialcontrol/content/needle.png delete mode 100644 examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png delete mode 100644 examples/tutorials/ui-components/dialcontrol/content/overlay.png delete mode 100644 examples/tutorials/ui-components/dialcontrol/content/quit.png delete mode 100644 examples/tutorials/ui-components/dialcontrol/dialcontrol.qml delete mode 100644 examples/tutorials/ui-components/flipable/content/5_heart.png delete mode 100644 examples/tutorials/ui-components/flipable/content/9_club.png delete mode 100644 examples/tutorials/ui-components/flipable/content/Card.qml delete mode 100644 examples/tutorials/ui-components/flipable/content/back.png delete mode 100644 examples/tutorials/ui-components/flipable/flipable.qml delete mode 100644 examples/tutorials/ui-components/progressbar/content/ProgressBar.qml delete mode 100644 examples/tutorials/ui-components/progressbar/content/background.png delete mode 100644 examples/tutorials/ui-components/progressbar/main.qml delete mode 100644 examples/tutorials/ui-components/scrollbar/ScrollBar.qml delete mode 100644 examples/tutorials/ui-components/scrollbar/main.qml delete mode 100644 examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg delete mode 100644 examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject delete mode 100644 examples/tutorials/ui-components/searchbox/SearchBox.qml delete mode 100644 examples/tutorials/ui-components/searchbox/images/clear.png delete mode 100644 examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png delete mode 100644 examples/tutorials/ui-components/searchbox/images/lineedit-bg.png delete mode 100644 examples/tutorials/ui-components/searchbox/main.qml delete mode 100644 examples/tutorials/ui-components/searchbox/searchbox.qmlproject delete mode 100644 examples/tutorials/ui-components/slideswitch/content/Switch.qml delete mode 100644 examples/tutorials/ui-components/slideswitch/content/background.png delete mode 100644 examples/tutorials/ui-components/slideswitch/content/background.svg delete mode 100644 examples/tutorials/ui-components/slideswitch/content/knob.png delete mode 100644 examples/tutorials/ui-components/slideswitch/content/knob.svg delete mode 100644 examples/tutorials/ui-components/slideswitch/slideswitch.qml delete mode 100644 examples/tutorials/ui-components/spinner/content/Spinner.qml delete mode 100644 examples/tutorials/ui-components/spinner/content/spinner-bg.png delete mode 100644 examples/tutorials/ui-components/spinner/content/spinner-select.png delete mode 100644 examples/tutorials/ui-components/spinner/main.qml delete mode 100644 examples/tutorials/ui-components/spinner/spinner.qmlproject delete mode 100644 examples/tutorials/ui-components/tabwidget/TabWidget.qml delete mode 100644 examples/tutorials/ui-components/tabwidget/main.qml delete mode 100644 examples/tutorials/ui-components/tabwidget/tab.png delete mode 100644 examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject delete mode 100644 examples/window/Window.qml delete mode 100644 examples/window/standalone.qml delete mode 100644 examples/window/window.cpp create mode 100644 examples/window/window/Window.qml create mode 100644 examples/window/window/standalone.qml create mode 100644 examples/window/window/window.cpp create mode 100644 examples/window/window/window.pro diff --git a/examples/localstorage/hello.qml b/examples/localstorage/hello.qml deleted file mode 100644 index 3496b86bd9..0000000000 --- a/examples/localstorage/hello.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQuick.LocalStorage 2.0 as LS - -Rectangle { - color: "white" - width: 200 - height: 100 - - Text { - text: "?" - anchors.horizontalCenter: parent.horizontalCenter - function findGreetings() { - var db = LS.openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); - - db.transaction( - function(tx) { - // Create the database if it doesn't already exist - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - - // Add (another) greeting row - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - - // Show all added greetings - var rs = tx.executeSql('SELECT * FROM Greeting'); - - var r = "" - for(var i = 0; i < rs.rows.length; i++) { - r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" - } - text = r - } - ) - } - - Component.onCompleted: findGreetings() - } -} -//![0] diff --git a/examples/localstorage/localstorage.pro b/examples/localstorage/localstorage.pro index 311dc4ac8b..dd2eb80250 100644 --- a/examples/localstorage/localstorage.pro +++ b/examples/localstorage/localstorage.pro @@ -1,9 +1,2 @@ -TEMPLATE = app - -QT += quick qml -SOURCES += main.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/localstorage -qml.files = localstorage.qml hello.qml -qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/localstorage -INSTALLS += target qml +TEMPLATE = subdirs +SUBDIRS += localstorage diff --git a/examples/localstorage/localstorage.qml b/examples/localstorage/localstorage.qml deleted file mode 100644 index 714774c78e..0000000000 --- a/examples/localstorage/localstorage.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../shared" as Examples - -/*! - \title QtQuick Examples - Local Storage - \example localstorage - \brief This is a collection of QML local storage examples - \image qml-localstorage-example.png - - This is a collection of small QML examples relating to local storage functionality. - - Hello World demos creating a simple SQL table and how to do inserting/selecting operations. - -*/ - -Item { - height: 480 - width: 320 - Examples.LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("Hello World", "Simple SQL operations with local storage API", Qt.resolvedUrl("hello.qml")); - } - } -} diff --git a/examples/localstorage/localstorage.qmlproject b/examples/localstorage/localstorage.qmlproject deleted file mode 100644 index 6835d23503..0000000000 --- a/examples/localstorage/localstorage.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - mainFile: "localstorage.qml" - /* Include .qml, .js, and image files from current directory and subdirectories */ - - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} \ No newline at end of file diff --git a/examples/localstorage/localstorage/hello.qml b/examples/localstorage/localstorage/hello.qml new file mode 100644 index 0000000000..3496b86bd9 --- /dev/null +++ b/examples/localstorage/localstorage/hello.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import QtQuick.LocalStorage 2.0 as LS + +Rectangle { + color: "white" + width: 200 + height: 100 + + Text { + text: "?" + anchors.horizontalCenter: parent.horizontalCenter + function findGreetings() { + var db = LS.openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); + + db.transaction( + function(tx) { + // Create the database if it doesn't already exist + tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); + + // Add (another) greeting row + tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); + + // Show all added greetings + var rs = tx.executeSql('SELECT * FROM Greeting'); + + var r = "" + for(var i = 0; i < rs.rows.length; i++) { + r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" + } + text = r + } + ) + } + + Component.onCompleted: findGreetings() + } +} +//![0] diff --git a/examples/localstorage/localstorage/localstorage.pro b/examples/localstorage/localstorage/localstorage.pro new file mode 100644 index 0000000000..311dc4ac8b --- /dev/null +++ b/examples/localstorage/localstorage/localstorage.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/localstorage +qml.files = localstorage.qml hello.qml +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/localstorage +INSTALLS += target qml diff --git a/examples/localstorage/localstorage/localstorage.qml b/examples/localstorage/localstorage/localstorage.qml new file mode 100644 index 0000000000..714774c78e --- /dev/null +++ b/examples/localstorage/localstorage/localstorage.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" as Examples + +/*! + \title QtQuick Examples - Local Storage + \example localstorage + \brief This is a collection of QML local storage examples + \image qml-localstorage-example.png + + This is a collection of small QML examples relating to local storage functionality. + + Hello World demos creating a simple SQL table and how to do inserting/selecting operations. + +*/ + +Item { + height: 480 + width: 320 + Examples.LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Hello World", "Simple SQL operations with local storage API", Qt.resolvedUrl("hello.qml")); + } + } +} diff --git a/examples/localstorage/localstorage/localstorage.qmlproject b/examples/localstorage/localstorage/localstorage.qmlproject new file mode 100644 index 0000000000..6835d23503 --- /dev/null +++ b/examples/localstorage/localstorage/localstorage.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + mainFile: "localstorage.qml" + /* Include .qml, .js, and image files from current directory and subdirectories */ + + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} \ No newline at end of file diff --git a/examples/localstorage/localstorage/main.cpp b/examples/localstorage/localstorage/main.cpp new file mode 100644 index 0000000000..005ed2008b --- /dev/null +++ b/examples/localstorage/localstorage/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(localstorage) diff --git a/examples/localstorage/main.cpp b/examples/localstorage/main.cpp deleted file mode 100644 index 484fcdbefc..0000000000 --- a/examples/localstorage/main.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(localstorage) \ No newline at end of file diff --git a/examples/qml/cppextensions/cppextensions.pro b/examples/qml/cppextensions/cppextensions.pro deleted file mode 100644 index cde19b5c90..0000000000 --- a/examples/qml/cppextensions/cppextensions.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - imageprovider \ - plugins \ - networkaccessmanagerfactory \ - referenceexamples - diff --git a/examples/qml/cppextensions/cppextensions.qmlproject b/examples/qml/cppextensions/cppextensions.qmlproject deleted file mode 100644 index 6b362842cb..0000000000 --- a/examples/qml/cppextensions/cppextensions.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: [ "plugins" ] -} diff --git a/examples/qml/cppextensions/imageprovider/ImageProviderCore/qmldir b/examples/qml/cppextensions/imageprovider/ImageProviderCore/qmldir deleted file mode 100644 index 6be88bccec..0000000000 --- a/examples/qml/cppextensions/imageprovider/ImageProviderCore/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -plugin qmlimageproviderplugin - diff --git a/examples/qml/cppextensions/imageprovider/imageprovider-example.qml b/examples/qml/cppextensions/imageprovider/imageprovider-example.qml deleted file mode 100644 index fe2f1b130b..0000000000 --- a/examples/qml/cppextensions/imageprovider/imageprovider-example.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import "ImageProviderCore" // import the plugin that registers the color image provider - -//![0] -Column { - Image { source: "image://colors/yellow" } - Image { source: "image://colors/red" } -} -//![0] - diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.cpp b/examples/qml/cppextensions/imageprovider/imageprovider.cpp deleted file mode 100644 index a203ad8053..0000000000 --- a/examples/qml/cppextensions/imageprovider/imageprovider.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - -#include -#include -#include -#include - -//![0] -class ColorImageProvider : public QQuickImageProvider -{ -public: - ColorImageProvider() - : QQuickImageProvider(QQuickImageProvider::Pixmap) - { - } - - QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) - { - int width = 100; - int height = 50; - - if (size) - *size = QSize(width, height); - QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, - requestedSize.height() > 0 ? requestedSize.height() : height); - pixmap.fill(QColor(id).rgba()); -//![0] - - // write the color name - QPainter painter(&pixmap); - QFont f = painter.font(); - f.setPixelSize(20); - painter.setFont(f); - painter.setPen(Qt::black); - if (requestedSize.isValid()) - painter.scale(requestedSize.width() / width, requestedSize.height() / height); - painter.drawText(QRectF(0, 0, width, height), Qt::AlignCenter, id); - -//![1] - return pixmap; - } -}; -//![1] - - -class ImageProviderExtensionPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") -public: - void registerTypes(const char *uri) - { - Q_UNUSED(uri); - } - - void initializeEngine(QQmlEngine *engine, const char *uri) - { - Q_UNUSED(uri); - engine->addImageProvider("colors", new ColorImageProvider); - } - -}; - - -#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface" - - -#include "imageprovider.moc" diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.pro b/examples/qml/cppextensions/imageprovider/imageprovider.pro deleted file mode 100644 index e85bad9866..0000000000 --- a/examples/qml/cppextensions/imageprovider/imageprovider.pro +++ /dev/null @@ -1,22 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += qml quick - -DESTDIR = ImageProviderCore -TARGET = qmlimageproviderplugin - -SOURCES += imageprovider.cpp - -OTHER_FILES += imageprovider.json - -sources.files = $$SOURCES imageprovider.qml imageprovider.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore - -ImageProviderCore_sources.files = \ - ImageProviderCore/qmldir -ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore - -INSTALLS = sources ImageProviderCore_sources target - diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.qmlproject b/examples/qml/cppextensions/imageprovider/imageprovider.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/qml/cppextensions/imageprovider/imageprovider.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp b/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp deleted file mode 100644 index 6ebded0512..0000000000 --- a/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -#include -#include -#include - - -/* - This example illustrates using a QQmlNetworkAccessManagerFactory to - create a QNetworkAccessManager with a proxy. - - Usage: - networkaccessmanagerfactory [-host -port ] [file] -*/ - -static QString proxyHost; -static int proxyPort = 0; - -class MyNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory -{ -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"); - - QGuiApplication 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: networkaccessmanagerfactory [-host -port ] [file]"; - exit(1); - } - } - - QQuickView view; - view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); - - view.setSource(source); - view.show(); - - return app.exec(); -} - diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro deleted file mode 100644 index 6cbc24a7b8..0000000000 --- a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro +++ /dev/null @@ -1,4 +0,0 @@ -QT += qml quick network - -SOURCES += main.cpp -RESOURCES += networkaccessmanagerfactory.qrc diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/view.qml b/examples/qml/cppextensions/networkaccessmanagerfactory/view.qml deleted file mode 100644 index b2d46a991f..0000000000 --- a/examples/qml/cppextensions/networkaccessmanagerfactory/view.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - width: 100 - height: 100 - source: "http://qt.nokia.com/logo.png" -} diff --git a/examples/qml/cppextensions/plugins/README b/examples/qml/cppextensions/plugins/README deleted file mode 100644 index f4f9074059..0000000000 --- a/examples/qml/cppextensions/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_IMPORT_PATH=$PWD qmlscene plugins.qml - diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml deleted file mode 100644 index eac9226a00..0000000000 --- a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: 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: (clock.hours * 30) + (clock.minutes * 0.5) - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - smooth: true - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; - angle: clock.minutes * 6 - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - 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/qml/cppextensions/plugins/com/nokia/TimeExample/center.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png deleted file mode 100644 index 7fbd802a44..0000000000 Binary files a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png and /dev/null differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png deleted file mode 100644 index 462edacc0e..0000000000 Binary files a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png and /dev/null differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png deleted file mode 100644 index f8061a1235..0000000000 Binary files a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png and /dev/null differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png deleted file mode 100644 index 1297ec7c2b..0000000000 Binary files a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png and /dev/null differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir deleted file mode 100644 index e1288cfac0..0000000000 --- a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Clock 1.0 Clock.qml -plugin qmlqtimeexampleplugin diff --git a/examples/qml/cppextensions/plugins/plugin.cpp b/examples/qml/cppextensions/plugins/plugin.cpp deleted file mode 100644 index f20e6935be..0000000000 --- a/examples/qml/cppextensions/plugins/plugin.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#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; -}; - -//![0] -class TimeModel : public QObject -{ - Q_OBJECT - Q_PROPERTY(int hour READ hour NOTIFY timeChanged) - Q_PROPERTY(int minute READ minute NOTIFY timeChanged) -//![0] - -public: - TimeModel(QObject *parent=0) : QObject(parent) - { - if (++instances == 1) { - if (!timer) - timer = new MinuteTimer(QCoreApplication::instance()); - 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; - -//![plugin] -class QExampleQmlPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); - qmlRegisterType(uri, 1, 0, "Time"); - } -}; -//![plugin] - -#include "plugin.moc" diff --git a/examples/qml/cppextensions/plugins/plugins.pro b/examples/qml/cppextensions/plugins/plugins.pro deleted file mode 100644 index e127509c0d..0000000000 --- a/examples/qml/cppextensions/plugins/plugins.pro +++ /dev/null @@ -1,25 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += qml - -DESTDIR = com/nokia/TimeExample -TARGET = qmlqtimeexampleplugin - -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]/qtdeclarative/qml/plugins/com/nokia/TimeExample - -sources.files += plugins.pro plugin.cpp plugins.qml README -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample - -INSTALLS += qdeclarativesources sources target - diff --git a/examples/qml/cppextensions/plugins/plugins.qml b/examples/qml/cppextensions/plugins/plugins.qml deleted file mode 100644 index f1048ddd36..0000000000 --- a/examples/qml/cppextensions/plugins/plugins.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import 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 - -} -//![0] diff --git a/examples/qml/cppextensions/plugins/plugins.qmlproject b/examples/qml/cppextensions/plugins/plugins.qmlproject deleted file mode 100644 index 771ab45b66..0000000000 --- a/examples/qml/cppextensions/plugins/plugins.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "plugins.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/qml/cppextensions/referenceexamples/adding/adding.pro b/examples/qml/cppextensions/referenceexamples/adding/adding.pro deleted file mode 100644 index 706322e9ff..0000000000 --- a/examples/qml/cppextensions/referenceexamples/adding/adding.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp -HEADERS += person.h -RESOURCES += adding.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/adding/adding.qrc b/examples/qml/cppextensions/referenceexamples/adding/adding.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/adding/adding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/adding/example.qml b/examples/qml/cppextensions/referenceexamples/adding/example.qml deleted file mode 100644 index 3b2ca34d10..0000000000 --- a/examples/qml/cppextensions/referenceexamples/adding/example.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -import People 1.0 - -Person { - name: "Bob Jones" - shoeSize: 12 -} -// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/adding/main.cpp b/examples/qml/cppextensions/referenceexamples/adding/main.cpp deleted file mode 100644 index c3a0ab6812..0000000000 --- a/examples/qml/cppextensions/referenceexamples/adding/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); -//![0] - qmlRegisterType("People", 1,0, "Person"); -//![0] - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); - } - - return 0; -} diff --git a/examples/qml/cppextensions/referenceexamples/adding/person.cpp b/examples/qml/cppextensions/referenceexamples/adding/person.cpp deleted file mode 100644 index 0e78b0b77b..0000000000 --- a/examples/qml/cppextensions/referenceexamples/adding/person.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/adding/person.h b/examples/qml/cppextensions/referenceexamples/adding/person.h deleted file mode 100644 index 45fb2f3297..0000000000 --- a/examples/qml/cppextensions/referenceexamples/adding/person.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/attached/attached.pro b/examples/qml/cppextensions/referenceexamples/attached/attached.pro deleted file mode 100644 index f4385e1a30..0000000000 --- a/examples/qml/cppextensions/referenceexamples/attached/attached.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += attached.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/attached/attached.qrc b/examples/qml/cppextensions/referenceexamples/attached/attached.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/attached/attached.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp deleted file mode 100644 index c4f906119a..0000000000 --- a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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; -} - -QQmlListProperty BirthdayParty::guests() -{ - return QQmlListProperty(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/qml/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h deleted file mode 100644 index 1da6c34026..0000000000 --- a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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(QQmlListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QQmlListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - //! [static attached] - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - //! [static attached] -private: - Person *m_host; - QList m_guests; -}; - -//! [declare attached] -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) -//! [declare attached] -#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/attached/example.qml b/examples/qml/cppextensions/referenceexamples/attached/example.qml deleted file mode 100644 index aaf998d386..0000000000 --- a/examples/qml/cppextensions/referenceexamples/attached/example.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 -import QtQuick 2.0 // For QColor - -//! [begin] -BirthdayParty { -//! [begin] - -//! [rsvp] - Boy { - name: "Robert Campbell" - BirthdayParty.rsvp: "2009-07-01" - } -//! [rsvp] - // ![1] - Boy { - name: "Leo Hodges" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - - BirthdayParty.rsvp: "2009-07-06" - } - // ![1] - host: Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } -//! [end] -} -//! [end] - diff --git a/examples/qml/cppextensions/referenceexamples/attached/main.cpp b/examples/qml/cppextensions/referenceexamples/attached/main.cpp deleted file mode 100644 index ce067bbbf7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/attached/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#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"); - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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); - - //! [query rsvp] - QDate rsvpDate; - QObject *attached = qmlAttachedPropertiesObject(guest, false); - - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - //! [query rsvp] - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/qml/cppextensions/referenceexamples/attached/person.cpp b/examples/qml/cppextensions/referenceexamples/attached/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/qml/cppextensions/referenceexamples/attached/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/attached/person.h b/examples/qml/cppextensions/referenceexamples/attached/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/qml/cppextensions/referenceexamples/attached/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/binding/binding.pro b/examples/qml/cppextensions/referenceexamples/binding/binding.pro deleted file mode 100644 index 0379f93ea7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/binding.pro +++ /dev/null @@ -1,15 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h - -RESOURCES += binding.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/binding/binding.qrc b/examples/qml/cppextensions/referenceexamples/binding/binding.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/binding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp deleted file mode 100644 index 62499862f0..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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(); -} - -QQmlListProperty BirthdayParty::guests() -{ - return QQmlListProperty(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/qml/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h deleted file mode 100644 index 195e9cd9cf..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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(QQmlListProperty 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 *); - - QQmlListProperty 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/qml/cppextensions/referenceexamples/binding/example.qml b/examples/qml/cppextensions/referenceexamples/binding/example.qml deleted file mode 100644 index 9d46adc5fc..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/example.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 -import QtQuick 2.0 // For QColor - -// ![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/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp deleted file mode 100644 index 90220e15ae..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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 QQmlProperty &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/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h deleted file mode 100644 index ace48b2af0..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include - -#include - -class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_INTERFACES(QQmlPropertyValueSource) -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QQmlProperty &); - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -signals: - void nameChanged(); -private: - int m_line; - QStringList m_lyrics; - QQmlProperty m_target; - QString m_name; -}; - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/qml/cppextensions/referenceexamples/binding/main.cpp b/examples/qml/cppextensions/referenceexamples/binding/main.cpp deleted file mode 100644 index 389cb7609b..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/main.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#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"); - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); - } - - return app.exec(); -} diff --git a/examples/qml/cppextensions/referenceexamples/binding/person.cpp b/examples/qml/cppextensions/referenceexamples/binding/person.cpp deleted file mode 100644 index 89e7127caf..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/person.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/binding/person.h b/examples/qml/cppextensions/referenceexamples/binding/person.h deleted file mode 100644 index d0f196b95c..0000000000 --- a/examples/qml/cppextensions/referenceexamples/binding/person.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp deleted file mode 100644 index e15ffe1604..0000000000 --- a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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; -} - -QQmlListProperty BirthdayParty::guests() -{ - return QQmlListProperty(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/qml/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h deleted file mode 100644 index 43611693d9..0000000000 --- a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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(QQmlListProperty guests READ guests) -// ![0] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QQmlListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro b/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro deleted file mode 100644 index 60e8532bab..0000000000 --- a/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += coercion.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc b/examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/coercion/example.qml b/examples/qml/cppextensions/referenceexamples/coercion/example.qml deleted file mode 100644 index 25791f38f8..0000000000 --- a/examples/qml/cppextensions/referenceexamples/coercion/example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import 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/qml/cppextensions/referenceexamples/coercion/main.cpp b/examples/qml/cppextensions/referenceexamples/coercion/main.cpp deleted file mode 100644 index 15e41ca597..0000000000 --- a/examples/qml/cppextensions/referenceexamples/coercion/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#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] - - //![register boy girl] - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - //![register boy girl] - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); - } - - return 0; -} diff --git a/examples/qml/cppextensions/referenceexamples/coercion/person.cpp b/examples/qml/cppextensions/referenceexamples/coercion/person.cpp deleted file mode 100644 index b28d63216e..0000000000 --- a/examples/qml/cppextensions/referenceexamples/coercion/person.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/coercion/person.h b/examples/qml/cppextensions/referenceexamples/coercion/person.h deleted file mode 100644 index dc4ae43dd6..0000000000 --- a/examples/qml/cppextensions/referenceexamples/coercion/person.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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); -}; - -//! [girl class] -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; -//! [girl class] - -// ![0] - -#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp deleted file mode 100644 index e15ffe1604..0000000000 --- a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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; -} - -QQmlListProperty BirthdayParty::guests() -{ - return QQmlListProperty(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/qml/cppextensions/referenceexamples/default/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h deleted file mode 100644 index 3ee635039d..0000000000 --- a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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(QQmlListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QQmlListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![0] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/default/default.pro b/examples/qml/cppextensions/referenceexamples/default/default.pro deleted file mode 100644 index 36ef39fc55..0000000000 --- a/examples/qml/cppextensions/referenceexamples/default/default.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += default.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/default/default.qrc b/examples/qml/cppextensions/referenceexamples/default/default.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/default/default.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/default/example.qml b/examples/qml/cppextensions/referenceexamples/default/example.qml deleted file mode 100644 index 9ef24b59b7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/default/example.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import 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/qml/cppextensions/referenceexamples/default/main.cpp b/examples/qml/cppextensions/referenceexamples/default/main.cpp deleted file mode 100644 index 175945fc5d..0000000000 --- a/examples/qml/cppextensions/referenceexamples/default/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#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"); - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); - } - - return 0; -} diff --git a/examples/qml/cppextensions/referenceexamples/default/person.cpp b/examples/qml/cppextensions/referenceexamples/default/person.cpp deleted file mode 100644 index 5a615a1ecd..0000000000 --- a/examples/qml/cppextensions/referenceexamples/default/person.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/default/person.h b/examples/qml/cppextensions/referenceexamples/default/person.h deleted file mode 100644 index d85672798c..0000000000 --- a/examples/qml/cppextensions/referenceexamples/default/person.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/extended/example.qml b/examples/qml/cppextensions/referenceexamples/extended/example.qml deleted file mode 100644 index 642a95d443..0000000000 --- a/examples/qml/cppextensions/referenceexamples/extended/example.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -QLineEdit { - leftMargin: 20 -} -// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/extended/extended.pro b/examples/qml/cppextensions/referenceexamples/extended/extended.pro deleted file mode 100644 index 206ea19c61..0000000000 --- a/examples/qml/cppextensions/referenceexamples/extended/extended.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += qml widgets - -SOURCES += main.cpp \ - lineedit.cpp -HEADERS += lineedit.h -RESOURCES += extended.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/extended/extended.qrc b/examples/qml/cppextensions/referenceexamples/extended/extended.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/extended/extended.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp deleted file mode 100644 index a3b1d0d54e..0000000000 --- a/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/extended/lineedit.h b/examples/qml/cppextensions/referenceexamples/extended/lineedit.h deleted file mode 100644 index fa8c75df78..0000000000 --- a/examples/qml/cppextensions/referenceexamples/extended/lineedit.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/extended/main.cpp b/examples/qml/cppextensions/referenceexamples/extended/main.cpp deleted file mode 100644 index de7c450169..0000000000 --- a/examples/qml/cppextensions/referenceexamples/extended/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include "lineedit.h" - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - qmlRegisterExtendedType("People", 1,0, "QLineEdit"); - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc:example.qml")); - QLineEdit *edit = qobject_cast(component.create()); - - if (edit) { - edit->show(); - return app.exec(); - } else { - qWarning() << component.errors(); - return 0; - } -} diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp deleted file mode 100644 index e15ffe1604..0000000000 --- a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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; -} - -QQmlListProperty BirthdayParty::guests() -{ - return QQmlListProperty(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/qml/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h deleted file mode 100644 index 5ca0e9b982..0000000000 --- a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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(QQmlListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QQmlListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - - -#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/grouped/example.qml b/examples/qml/cppextensions/referenceexamples/grouped/example.qml deleted file mode 100644 index 22923ca395..0000000000 --- a/examples/qml/cppextensions/referenceexamples/grouped/example.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 -import QtQuick 2.0 // For QColor - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Bikey"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" -//![grouped] - shoe { size: 10; color: "black"; brand: "Thebok"; price: 59.95 } -//![grouped] - } - // ![1] - Boy { - name: "Jack Smith" - shoe { - size: 8 - color: "blue" - brand: "Luma" - price: 19.95 - } - } - // ![1] - Girl { - name: "Anne Brown" -//![ungrouped] - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Job Macobs" - shoe.price: 699.99 -//![ungrouped] - } -} -// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro b/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro deleted file mode 100644 index d32a98f79b..0000000000 --- a/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += grouped.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc b/examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/grouped/main.cpp b/examples/qml/cppextensions/referenceexamples/grouped/main.cpp deleted file mode 100644 index 55be3b715b..0000000000 --- a/examples/qml/cppextensions/referenceexamples/grouped/main.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#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"); - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); - } - - return 0; -} diff --git a/examples/qml/cppextensions/referenceexamples/grouped/person.cpp b/examples/qml/cppextensions/referenceexamples/grouped/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/qml/cppextensions/referenceexamples/grouped/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/grouped/person.h b/examples/qml/cppextensions/referenceexamples/grouped/person.h deleted file mode 100644 index dea715bacb..0000000000 --- a/examples/qml/cppextensions/referenceexamples/grouped/person.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp deleted file mode 100644 index c96f41d944..0000000000 --- a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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; -} - -QQmlListProperty BirthdayParty::guests() -{ - return QQmlListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::invite(const QString &name) -{ - Person *person = new Person(this); - person->setName(name); - m_guests.append(person); -} -// ![0] - diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h deleted file mode 100644 index df8a859972..0000000000 --- a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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(QQmlListProperty guests READ guests) -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QQmlListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -// ![0] - Q_INVOKABLE void invite(const QString &name); -// ![0] - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/methods/example.qml b/examples/qml/cppextensions/referenceexamples/methods/example.qml deleted file mode 100644 index 9119835e04..0000000000 --- a/examples/qml/cppextensions/referenceexamples/methods/example.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import People 1.0 - -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo Hodges" }, - Person { name: "Jack Smith" }, - Person { name: "Anne Brown" } - ] - -// ![0] - Component.onCompleted: invite("William Green") -// ![0] -} diff --git a/examples/qml/cppextensions/referenceexamples/methods/main.cpp b/examples/qml/cppextensions/referenceexamples/methods/main.cpp deleted file mode 100644 index 1e502c3943..0000000000 --- a/examples/qml/cppextensions/referenceexamples/methods/main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#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"); - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); - } - - return 0; -} diff --git a/examples/qml/cppextensions/referenceexamples/methods/methods.pro b/examples/qml/cppextensions/referenceexamples/methods/methods.pro deleted file mode 100644 index f4c63bfa29..0000000000 --- a/examples/qml/cppextensions/referenceexamples/methods/methods.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += methods.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/methods/methods.qrc b/examples/qml/cppextensions/referenceexamples/methods/methods.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/methods/methods.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/methods/person.cpp b/examples/qml/cppextensions/referenceexamples/methods/person.cpp deleted file mode 100644 index 30d1e46e5a..0000000000 --- a/examples/qml/cppextensions/referenceexamples/methods/person.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/methods/person.h b/examples/qml/cppextensions/referenceexamples/methods/person.h deleted file mode 100644 index dd3ad4d188..0000000000 --- a/examples/qml/cppextensions/referenceexamples/methods/person.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp deleted file mode 100644 index 8e79d07748..0000000000 --- a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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; -} - -QQmlListProperty BirthdayParty::guests() -{ - return QQmlListProperty(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/qml/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h deleted file mode 100644 index 84eefa52ae..0000000000 --- a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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(QQmlListProperty guests READ guests) -// ![2] -// ![3] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QQmlListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![3] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/properties/example.qml b/examples/qml/cppextensions/referenceexamples/properties/example.qml deleted file mode 100644 index 36ee952243..0000000000 --- a/examples/qml/cppextensions/referenceexamples/properties/example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import 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/qml/cppextensions/referenceexamples/properties/main.cpp b/examples/qml/cppextensions/referenceexamples/properties/main.cpp deleted file mode 100644 index cc0de89221..0000000000 --- a/examples/qml/cppextensions/referenceexamples/properties/main.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - -//![register list] - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); -//![register list] - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); - } - - return 0; -} diff --git a/examples/qml/cppextensions/referenceexamples/properties/person.cpp b/examples/qml/cppextensions/referenceexamples/properties/person.cpp deleted file mode 100644 index 30d1e46e5a..0000000000 --- a/examples/qml/cppextensions/referenceexamples/properties/person.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/properties/person.h b/examples/qml/cppextensions/referenceexamples/properties/person.h deleted file mode 100644 index dd3ad4d188..0000000000 --- a/examples/qml/cppextensions/referenceexamples/properties/person.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/properties/properties.pro b/examples/qml/cppextensions/referenceexamples/properties/properties.pro deleted file mode 100644 index e079b1f79e..0000000000 --- a/examples/qml/cppextensions/referenceexamples/properties/properties.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += properties.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/properties/properties.qrc b/examples/qml/cppextensions/referenceexamples/properties/properties.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/properties/properties.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/referenceexamples.pro b/examples/qml/cppextensions/referenceexamples/referenceexamples.pro deleted file mode 100644 index 4bfbd488ea..0000000000 --- a/examples/qml/cppextensions/referenceexamples/referenceexamples.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - adding \ - attached \ - binding \ - coercion \ - default \ - grouped \ - properties \ - signal \ - valuesource \ - methods - -!contains(QT_CONFIG, no-widgets): SUBDIRS += extended diff --git a/examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject b/examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp deleted file mode 100644 index b9f7e15907..0000000000 --- a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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; -} - -QQmlListProperty BirthdayParty::guests() -{ - return QQmlListProperty(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/qml/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h deleted file mode 100644 index 3f1b020b5a..0000000000 --- a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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(QQmlListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QQmlListProperty 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/qml/cppextensions/referenceexamples/signal/example.qml b/examples/qml/cppextensions/referenceexamples/signal/example.qml deleted file mode 100644 index db959ffd86..0000000000 --- a/examples/qml/cppextensions/referenceexamples/signal/example.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 -import QtQuick 2.0 // For QColor - -BirthdayParty { -// ![0] - 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/qml/cppextensions/referenceexamples/signal/main.cpp b/examples/qml/cppextensions/referenceexamples/signal/main.cpp deleted file mode 100644 index 21a26d9b67..0000000000 --- a/examples/qml/cppextensions/referenceexamples/signal/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#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"); - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); - } - - return 0; -} diff --git a/examples/qml/cppextensions/referenceexamples/signal/person.cpp b/examples/qml/cppextensions/referenceexamples/signal/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/qml/cppextensions/referenceexamples/signal/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/signal/person.h b/examples/qml/cppextensions/referenceexamples/signal/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/qml/cppextensions/referenceexamples/signal/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/signal/signal.pro b/examples/qml/cppextensions/referenceexamples/signal/signal.pro deleted file mode 100644 index d426e398a5..0000000000 --- a/examples/qml/cppextensions/referenceexamples/signal/signal.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += signal.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/signal/signal.qrc b/examples/qml/cppextensions/referenceexamples/signal/signal.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/signal/signal.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp deleted file mode 100644 index aa8bc77116..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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; -} - -QQmlListProperty BirthdayParty::guests() -{ - return QQmlListProperty(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/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h deleted file mode 100644 index f3635e899b..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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(QQmlListProperty 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 *); - - QQmlListProperty 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/qml/cppextensions/referenceexamples/valuesource/example.qml b/examples/qml/cppextensions/referenceexamples/valuesource/example.qml deleted file mode 100644 index 4c25cebae3..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/example.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 -import QtQuick 2.0 // For QColor - -// ![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/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp deleted file mode 100644 index d69154b57a..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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 QQmlProperty &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/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h deleted file mode 100644 index 19e47c28ac..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include -#include - -#include - -// ![0] -class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource -{ - Q_OBJECT - Q_INTERFACES(QQmlPropertyValueSource) -// ![0] - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QQmlProperty &); -// ![1] - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -private: - int m_line; - QStringList m_lyrics; - QQmlProperty m_target; - QString m_name; -// ![2] -}; -// ![2] - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp deleted file mode 100644 index e119e719af..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#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"); - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); - } - - return app.exec(); -} diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/person.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "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/qml/cppextensions/referenceexamples/valuesource/person.h b/examples/qml/cppextensions/referenceexamples/valuesource/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef 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/qml/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro deleted file mode 100644 index afc1784d71..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro +++ /dev/null @@ -1,15 +0,0 @@ -QT += qml - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h -RESOURCES += valuesource.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource -INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/qml/imageprovider/ImageProviderCore/qmldir b/examples/qml/imageprovider/ImageProviderCore/qmldir new file mode 100644 index 0000000000..6be88bccec --- /dev/null +++ b/examples/qml/imageprovider/ImageProviderCore/qmldir @@ -0,0 +1,2 @@ +plugin qmlimageproviderplugin + diff --git a/examples/qml/imageprovider/imageprovider-example.qml b/examples/qml/imageprovider/imageprovider-example.qml new file mode 100644 index 0000000000..fe2f1b130b --- /dev/null +++ b/examples/qml/imageprovider/imageprovider-example.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import "ImageProviderCore" // import the plugin that registers the color image provider + +//![0] +Column { + Image { source: "image://colors/yellow" } + Image { source: "image://colors/red" } +} +//![0] + diff --git a/examples/qml/imageprovider/imageprovider.cpp b/examples/qml/imageprovider/imageprovider.cpp new file mode 100644 index 0000000000..a203ad8053 --- /dev/null +++ b/examples/qml/imageprovider/imageprovider.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include +#include +#include +#include + +//![0] +class ColorImageProvider : public QQuickImageProvider +{ +public: + ColorImageProvider() + : QQuickImageProvider(QQuickImageProvider::Pixmap) + { + } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) + { + int width = 100; + int height = 50; + + if (size) + *size = QSize(width, height); + QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, + requestedSize.height() > 0 ? requestedSize.height() : height); + pixmap.fill(QColor(id).rgba()); +//![0] + + // write the color name + QPainter painter(&pixmap); + QFont f = painter.font(); + f.setPixelSize(20); + painter.setFont(f); + painter.setPen(Qt::black); + if (requestedSize.isValid()) + painter.scale(requestedSize.width() / width, requestedSize.height() / height); + painter.drawText(QRectF(0, 0, width, height), Qt::AlignCenter, id); + +//![1] + return pixmap; + } +}; +//![1] + + +class ImageProviderExtensionPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") +public: + void registerTypes(const char *uri) + { + Q_UNUSED(uri); + } + + void initializeEngine(QQmlEngine *engine, const char *uri) + { + Q_UNUSED(uri); + engine->addImageProvider("colors", new ColorImageProvider); + } + +}; + + +#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface" + + +#include "imageprovider.moc" diff --git a/examples/qml/imageprovider/imageprovider.pro b/examples/qml/imageprovider/imageprovider.pro new file mode 100644 index 0000000000..e85bad9866 --- /dev/null +++ b/examples/qml/imageprovider/imageprovider.pro @@ -0,0 +1,22 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml quick + +DESTDIR = ImageProviderCore +TARGET = qmlimageproviderplugin + +SOURCES += imageprovider.cpp + +OTHER_FILES += imageprovider.json + +sources.files = $$SOURCES imageprovider.qml imageprovider.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore + +ImageProviderCore_sources.files = \ + ImageProviderCore/qmldir +ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore + +INSTALLS = sources ImageProviderCore_sources target + diff --git a/examples/qml/imageprovider/imageprovider.qmlproject b/examples/qml/imageprovider/imageprovider.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/imageprovider/imageprovider.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/networkaccessmanagerfactory/main.cpp b/examples/qml/networkaccessmanagerfactory/main.cpp new file mode 100644 index 0000000000..6ebded0512 --- /dev/null +++ b/examples/qml/networkaccessmanagerfactory/main.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include +#include +#include + + +/* + This example illustrates using a QQmlNetworkAccessManagerFactory to + create a QNetworkAccessManager with a proxy. + + Usage: + networkaccessmanagerfactory [-host -port ] [file] +*/ + +static QString proxyHost; +static int proxyPort = 0; + +class MyNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory +{ +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"); + + QGuiApplication 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: networkaccessmanagerfactory [-host -port ] [file]"; + exit(1); + } + } + + QQuickView view; + view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); + + view.setSource(source); + view.show(); + + return app.exec(); +} + diff --git a/examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.pro new file mode 100644 index 0000000000..6cbc24a7b8 --- /dev/null +++ b/examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.pro @@ -0,0 +1,4 @@ +QT += qml quick network + +SOURCES += main.cpp +RESOURCES += networkaccessmanagerfactory.qrc diff --git a/examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject b/examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc b/examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc new file mode 100644 index 0000000000..17e9301471 --- /dev/null +++ b/examples/qml/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/qml/networkaccessmanagerfactory/view.qml b/examples/qml/networkaccessmanagerfactory/view.qml new file mode 100644 index 0000000000..b2d46a991f --- /dev/null +++ b/examples/qml/networkaccessmanagerfactory/view.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + width: 100 + height: 100 + source: "http://qt.nokia.com/logo.png" +} diff --git a/examples/qml/plugins/README b/examples/qml/plugins/README new file mode 100644 index 0000000000..f4f9074059 --- /dev/null +++ b/examples/qml/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_IMPORT_PATH=$PWD qmlscene plugins.qml + diff --git a/examples/qml/plugins/com/nokia/TimeExample/Clock.qml b/examples/qml/plugins/com/nokia/TimeExample/Clock.qml new file mode 100644 index 0000000000..eac9226a00 --- /dev/null +++ b/examples/qml/plugins/com/nokia/TimeExample/Clock.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +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: (clock.hours * 30) + (clock.minutes * 0.5) + Behavior on angle { + SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 93.5; y: 17 + source: "minute.png" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 6.5; origin.y: 83; + angle: clock.minutes * 6 + Behavior on angle { + SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + 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/qml/plugins/com/nokia/TimeExample/center.png b/examples/qml/plugins/com/nokia/TimeExample/center.png new file mode 100644 index 0000000000..7fbd802a44 Binary files /dev/null and b/examples/qml/plugins/com/nokia/TimeExample/center.png differ diff --git a/examples/qml/plugins/com/nokia/TimeExample/clock.png b/examples/qml/plugins/com/nokia/TimeExample/clock.png new file mode 100644 index 0000000000..462edacc0e Binary files /dev/null and b/examples/qml/plugins/com/nokia/TimeExample/clock.png differ diff --git a/examples/qml/plugins/com/nokia/TimeExample/hour.png b/examples/qml/plugins/com/nokia/TimeExample/hour.png new file mode 100644 index 0000000000..f8061a1235 Binary files /dev/null and b/examples/qml/plugins/com/nokia/TimeExample/hour.png differ diff --git a/examples/qml/plugins/com/nokia/TimeExample/minute.png b/examples/qml/plugins/com/nokia/TimeExample/minute.png new file mode 100644 index 0000000000..1297ec7c2b Binary files /dev/null and b/examples/qml/plugins/com/nokia/TimeExample/minute.png differ diff --git a/examples/qml/plugins/com/nokia/TimeExample/qmldir b/examples/qml/plugins/com/nokia/TimeExample/qmldir new file mode 100644 index 0000000000..e1288cfac0 --- /dev/null +++ b/examples/qml/plugins/com/nokia/TimeExample/qmldir @@ -0,0 +1,2 @@ +Clock 1.0 Clock.qml +plugin qmlqtimeexampleplugin diff --git a/examples/qml/plugins/plugin.cpp b/examples/qml/plugins/plugin.cpp new file mode 100644 index 0000000000..f20e6935be --- /dev/null +++ b/examples/qml/plugins/plugin.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#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; +}; + +//![0] +class TimeModel : public QObject +{ + Q_OBJECT + Q_PROPERTY(int hour READ hour NOTIFY timeChanged) + Q_PROPERTY(int minute READ minute NOTIFY timeChanged) +//![0] + +public: + TimeModel(QObject *parent=0) : QObject(parent) + { + if (++instances == 1) { + if (!timer) + timer = new MinuteTimer(QCoreApplication::instance()); + 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; + +//![plugin] +class QExampleQmlPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); + qmlRegisterType(uri, 1, 0, "Time"); + } +}; +//![plugin] + +#include "plugin.moc" diff --git a/examples/qml/plugins/plugins.pro b/examples/qml/plugins/plugins.pro new file mode 100644 index 0000000000..e127509c0d --- /dev/null +++ b/examples/qml/plugins/plugins.pro @@ -0,0 +1,25 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml + +DESTDIR = com/nokia/TimeExample +TARGET = qmlqtimeexampleplugin + +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]/qtdeclarative/qml/plugins/com/nokia/TimeExample + +sources.files += plugins.pro plugin.cpp plugins.qml README +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample + +INSTALLS += qdeclarativesources sources target + diff --git a/examples/qml/plugins/plugins.qml b/examples/qml/plugins/plugins.qml new file mode 100644 index 0000000000..f1048ddd36 --- /dev/null +++ b/examples/qml/plugins/plugins.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import 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 + +} +//![0] diff --git a/examples/qml/plugins/plugins.qmlproject b/examples/qml/plugins/plugins.qmlproject new file mode 100644 index 0000000000..771ab45b66 --- /dev/null +++ b/examples/qml/plugins/plugins.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "plugins.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/qml.pro b/examples/qml/qml.pro index 967108504e..ce5efbb823 100644 --- a/examples/qml/qml.pro +++ b/examples/qml/qml.pro @@ -1 +1,7 @@ TEMPLATE = subdirs + +SUBDIRS +=imageprovider \ + plugins \ + networkaccessmanagerfactory \ + referenceexamples \ + shell diff --git a/examples/qml/referenceexamples/adding/adding.pro b/examples/qml/referenceexamples/adding/adding.pro new file mode 100644 index 0000000000..706322e9ff --- /dev/null +++ b/examples/qml/referenceexamples/adding/adding.pro @@ -0,0 +1,11 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp +HEADERS += person.h +RESOURCES += adding.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/adding/adding.qrc b/examples/qml/referenceexamples/adding/adding.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/adding/adding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/adding/example.qml b/examples/qml/referenceexamples/adding/example.qml new file mode 100644 index 0000000000..3b2ca34d10 --- /dev/null +++ b/examples/qml/referenceexamples/adding/example.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +import People 1.0 + +Person { + name: "Bob Jones" + shoeSize: 12 +} +// ![0] diff --git a/examples/qml/referenceexamples/adding/main.cpp b/examples/qml/referenceexamples/adding/main.cpp new file mode 100644 index 0000000000..c3a0ab6812 --- /dev/null +++ b/examples/qml/referenceexamples/adding/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); +//![0] + qmlRegisterType("People", 1,0, "Person"); +//![0] + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/referenceexamples/adding/person.cpp b/examples/qml/referenceexamples/adding/person.cpp new file mode 100644 index 0000000000..0e78b0b77b --- /dev/null +++ b/examples/qml/referenceexamples/adding/person.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/adding/person.h b/examples/qml/referenceexamples/adding/person.h new file mode 100644 index 0000000000..45fb2f3297 --- /dev/null +++ b/examples/qml/referenceexamples/adding/person.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/attached/attached.pro b/examples/qml/referenceexamples/attached/attached.pro new file mode 100644 index 0000000000..f4385e1a30 --- /dev/null +++ b/examples/qml/referenceexamples/attached/attached.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += attached.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/attached/attached.qrc b/examples/qml/referenceexamples/attached/attached.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/attached/attached.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/attached/birthdayparty.cpp b/examples/qml/referenceexamples/attached/birthdayparty.cpp new file mode 100644 index 0000000000..c4f906119a --- /dev/null +++ b/examples/qml/referenceexamples/attached/birthdayparty.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(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/qml/referenceexamples/attached/birthdayparty.h b/examples/qml/referenceexamples/attached/birthdayparty.h new file mode 100644 index 0000000000..1da6c34026 --- /dev/null +++ b/examples/qml/referenceexamples/attached/birthdayparty.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef 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(QQmlListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + //! [static attached] + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + //! [static attached] +private: + Person *m_host; + QList m_guests; +}; + +//! [declare attached] +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) +//! [declare attached] +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/attached/example.qml b/examples/qml/referenceexamples/attached/example.qml new file mode 100644 index 0000000000..aaf998d386 --- /dev/null +++ b/examples/qml/referenceexamples/attached/example.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 +import QtQuick 2.0 // For QColor + +//! [begin] +BirthdayParty { +//! [begin] + +//! [rsvp] + Boy { + name: "Robert Campbell" + BirthdayParty.rsvp: "2009-07-01" + } +//! [rsvp] + // ![1] + Boy { + name: "Leo Hodges" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + + BirthdayParty.rsvp: "2009-07-06" + } + // ![1] + host: Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } +//! [end] +} +//! [end] + diff --git a/examples/qml/referenceexamples/attached/main.cpp b/examples/qml/referenceexamples/attached/main.cpp new file mode 100644 index 0000000000..ce067bbbf7 --- /dev/null +++ b/examples/qml/referenceexamples/attached/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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); + + //! [query rsvp] + QDate rsvpDate; + QObject *attached = qmlAttachedPropertiesObject(guest, false); + + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + //! [query rsvp] + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/referenceexamples/attached/person.cpp b/examples/qml/referenceexamples/attached/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/referenceexamples/attached/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/attached/person.h b/examples/qml/referenceexamples/attached/person.h new file mode 100644 index 0000000000..032eca3c17 --- /dev/null +++ b/examples/qml/referenceexamples/attached/person.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/binding/binding.pro b/examples/qml/referenceexamples/binding/binding.pro new file mode 100644 index 0000000000..0379f93ea7 --- /dev/null +++ b/examples/qml/referenceexamples/binding/binding.pro @@ -0,0 +1,15 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.h + +RESOURCES += binding.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/binding/binding.qrc b/examples/qml/referenceexamples/binding/binding.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/binding/binding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/binding/birthdayparty.cpp b/examples/qml/referenceexamples/binding/birthdayparty.cpp new file mode 100644 index 0000000000..62499862f0 --- /dev/null +++ b/examples/qml/referenceexamples/binding/birthdayparty.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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(); +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(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/qml/referenceexamples/binding/birthdayparty.h b/examples/qml/referenceexamples/binding/birthdayparty.h new file mode 100644 index 0000000000..195e9cd9cf --- /dev/null +++ b/examples/qml/referenceexamples/binding/birthdayparty.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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(QQmlListProperty 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 *); + + QQmlListProperty 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/qml/referenceexamples/binding/example.qml b/examples/qml/referenceexamples/binding/example.qml new file mode 100644 index 0000000000..9d46adc5fc --- /dev/null +++ b/examples/qml/referenceexamples/binding/example.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 +import QtQuick 2.0 // For QColor + +// ![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/qml/referenceexamples/binding/happybirthdaysong.cpp b/examples/qml/referenceexamples/binding/happybirthdaysong.cpp new file mode 100644 index 0000000000..90220e15ae --- /dev/null +++ b/examples/qml/referenceexamples/binding/happybirthdaysong.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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 QQmlProperty &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/qml/referenceexamples/binding/happybirthdaysong.h b/examples/qml/referenceexamples/binding/happybirthdaysong.h new file mode 100644 index 0000000000..ace48b2af0 --- /dev/null +++ b/examples/qml/referenceexamples/binding/happybirthdaysong.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include + +#include + +class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_INTERFACES(QQmlPropertyValueSource) +public: + HappyBirthdaySong(QObject *parent = 0); + + virtual void setTarget(const QQmlProperty &); + + QString name() const; + void setName(const QString &); + +private slots: + void advance(); + +signals: + void nameChanged(); +private: + int m_line; + QStringList m_lyrics; + QQmlProperty m_target; + QString m_name; +}; + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/qml/referenceexamples/binding/main.cpp b/examples/qml/referenceexamples/binding/main.cpp new file mode 100644 index 0000000000..389cb7609b --- /dev/null +++ b/examples/qml/referenceexamples/binding/main.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#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"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); + } + + return app.exec(); +} diff --git a/examples/qml/referenceexamples/binding/person.cpp b/examples/qml/referenceexamples/binding/person.cpp new file mode 100644 index 0000000000..89e7127caf --- /dev/null +++ b/examples/qml/referenceexamples/binding/person.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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/qml/referenceexamples/binding/person.h b/examples/qml/referenceexamples/binding/person.h new file mode 100644 index 0000000000..d0f196b95c --- /dev/null +++ b/examples/qml/referenceexamples/binding/person.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef 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/qml/referenceexamples/coercion/birthdayparty.cpp b/examples/qml/referenceexamples/coercion/birthdayparty.cpp new file mode 100644 index 0000000000..e15ffe1604 --- /dev/null +++ b/examples/qml/referenceexamples/coercion/birthdayparty.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(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/qml/referenceexamples/coercion/birthdayparty.h b/examples/qml/referenceexamples/coercion/birthdayparty.h new file mode 100644 index 0000000000..43611693d9 --- /dev/null +++ b/examples/qml/referenceexamples/coercion/birthdayparty.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef 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(QQmlListProperty guests READ guests) +// ![0] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/coercion/coercion.pro b/examples/qml/referenceexamples/coercion/coercion.pro new file mode 100644 index 0000000000..60e8532bab --- /dev/null +++ b/examples/qml/referenceexamples/coercion/coercion.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += coercion.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/coercion/coercion.qrc b/examples/qml/referenceexamples/coercion/coercion.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/coercion/coercion.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/coercion/example.qml b/examples/qml/referenceexamples/coercion/example.qml new file mode 100644 index 0000000000..25791f38f8 --- /dev/null +++ b/examples/qml/referenceexamples/coercion/example.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import 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/qml/referenceexamples/coercion/main.cpp b/examples/qml/referenceexamples/coercion/main.cpp new file mode 100644 index 0000000000..15e41ca597 --- /dev/null +++ b/examples/qml/referenceexamples/coercion/main.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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] + + //![register boy girl] + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + //![register boy girl] + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/referenceexamples/coercion/person.cpp b/examples/qml/referenceexamples/coercion/person.cpp new file mode 100644 index 0000000000..b28d63216e --- /dev/null +++ b/examples/qml/referenceexamples/coercion/person.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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/qml/referenceexamples/coercion/person.h b/examples/qml/referenceexamples/coercion/person.h new file mode 100644 index 0000000000..dc4ae43dd6 --- /dev/null +++ b/examples/qml/referenceexamples/coercion/person.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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); +}; + +//! [girl class] +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; +//! [girl class] + +// ![0] + +#endif // PERSON_H diff --git a/examples/qml/referenceexamples/default/birthdayparty.cpp b/examples/qml/referenceexamples/default/birthdayparty.cpp new file mode 100644 index 0000000000..e15ffe1604 --- /dev/null +++ b/examples/qml/referenceexamples/default/birthdayparty.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(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/qml/referenceexamples/default/birthdayparty.h b/examples/qml/referenceexamples/default/birthdayparty.h new file mode 100644 index 0000000000..3ee635039d --- /dev/null +++ b/examples/qml/referenceexamples/default/birthdayparty.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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(QQmlListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![0] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/default/default.pro b/examples/qml/referenceexamples/default/default.pro new file mode 100644 index 0000000000..36ef39fc55 --- /dev/null +++ b/examples/qml/referenceexamples/default/default.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += default.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/default/default.qrc b/examples/qml/referenceexamples/default/default.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/default/default.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/default/example.qml b/examples/qml/referenceexamples/default/example.qml new file mode 100644 index 0000000000..9ef24b59b7 --- /dev/null +++ b/examples/qml/referenceexamples/default/example.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import 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/qml/referenceexamples/default/main.cpp b/examples/qml/referenceexamples/default/main.cpp new file mode 100644 index 0000000000..175945fc5d --- /dev/null +++ b/examples/qml/referenceexamples/default/main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#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"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/referenceexamples/default/person.cpp b/examples/qml/referenceexamples/default/person.cpp new file mode 100644 index 0000000000..5a615a1ecd --- /dev/null +++ b/examples/qml/referenceexamples/default/person.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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/qml/referenceexamples/default/person.h b/examples/qml/referenceexamples/default/person.h new file mode 100644 index 0000000000..d85672798c --- /dev/null +++ b/examples/qml/referenceexamples/default/person.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/extended/example.qml b/examples/qml/referenceexamples/extended/example.qml new file mode 100644 index 0000000000..642a95d443 --- /dev/null +++ b/examples/qml/referenceexamples/extended/example.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +QLineEdit { + leftMargin: 20 +} +// ![0] diff --git a/examples/qml/referenceexamples/extended/extended.pro b/examples/qml/referenceexamples/extended/extended.pro new file mode 100644 index 0000000000..206ea19c61 --- /dev/null +++ b/examples/qml/referenceexamples/extended/extended.pro @@ -0,0 +1,11 @@ +QT += qml widgets + +SOURCES += main.cpp \ + lineedit.cpp +HEADERS += lineedit.h +RESOURCES += extended.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/extended/extended.qrc b/examples/qml/referenceexamples/extended/extended.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/extended/extended.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/extended/lineedit.cpp b/examples/qml/referenceexamples/extended/lineedit.cpp new file mode 100644 index 0000000000..a3b1d0d54e --- /dev/null +++ b/examples/qml/referenceexamples/extended/lineedit.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/extended/lineedit.h b/examples/qml/referenceexamples/extended/lineedit.h new file mode 100644 index 0000000000..fa8c75df78 --- /dev/null +++ b/examples/qml/referenceexamples/extended/lineedit.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/extended/main.cpp b/examples/qml/referenceexamples/extended/main.cpp new file mode 100644 index 0000000000..de7c450169 --- /dev/null +++ b/examples/qml/referenceexamples/extended/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "lineedit.h" + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + qmlRegisterExtendedType("People", 1,0, "QLineEdit"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + QLineEdit *edit = qobject_cast(component.create()); + + if (edit) { + edit->show(); + return app.exec(); + } else { + qWarning() << component.errors(); + return 0; + } +} diff --git a/examples/qml/referenceexamples/grouped/birthdayparty.cpp b/examples/qml/referenceexamples/grouped/birthdayparty.cpp new file mode 100644 index 0000000000..e15ffe1604 --- /dev/null +++ b/examples/qml/referenceexamples/grouped/birthdayparty.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(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/qml/referenceexamples/grouped/birthdayparty.h b/examples/qml/referenceexamples/grouped/birthdayparty.h new file mode 100644 index 0000000000..5ca0e9b982 --- /dev/null +++ b/examples/qml/referenceexamples/grouped/birthdayparty.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef 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(QQmlListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/grouped/example.qml b/examples/qml/referenceexamples/grouped/example.qml new file mode 100644 index 0000000000..22923ca395 --- /dev/null +++ b/examples/qml/referenceexamples/grouped/example.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 +import QtQuick 2.0 // For QColor + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Bikey"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" +//![grouped] + shoe { size: 10; color: "black"; brand: "Thebok"; price: 59.95 } +//![grouped] + } + // ![1] + Boy { + name: "Jack Smith" + shoe { + size: 8 + color: "blue" + brand: "Luma" + price: 19.95 + } + } + // ![1] + Girl { + name: "Anne Brown" +//![ungrouped] + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Job Macobs" + shoe.price: 699.99 +//![ungrouped] + } +} +// ![0] diff --git a/examples/qml/referenceexamples/grouped/grouped.pro b/examples/qml/referenceexamples/grouped/grouped.pro new file mode 100644 index 0000000000..d32a98f79b --- /dev/null +++ b/examples/qml/referenceexamples/grouped/grouped.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += grouped.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/grouped/grouped.qrc b/examples/qml/referenceexamples/grouped/grouped.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/grouped/grouped.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/grouped/main.cpp b/examples/qml/referenceexamples/grouped/main.cpp new file mode 100644 index 0000000000..55be3b715b --- /dev/null +++ b/examples/qml/referenceexamples/grouped/main.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/referenceexamples/grouped/person.cpp b/examples/qml/referenceexamples/grouped/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/referenceexamples/grouped/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/grouped/person.h b/examples/qml/referenceexamples/grouped/person.h new file mode 100644 index 0000000000..dea715bacb --- /dev/null +++ b/examples/qml/referenceexamples/grouped/person.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef 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/qml/referenceexamples/methods/birthdayparty.cpp b/examples/qml/referenceexamples/methods/birthdayparty.cpp new file mode 100644 index 0000000000..c96f41d944 --- /dev/null +++ b/examples/qml/referenceexamples/methods/birthdayparty.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::invite(const QString &name) +{ + Person *person = new Person(this); + person->setName(name); + m_guests.append(person); +} +// ![0] + diff --git a/examples/qml/referenceexamples/methods/birthdayparty.h b/examples/qml/referenceexamples/methods/birthdayparty.h new file mode 100644 index 0000000000..df8a859972 --- /dev/null +++ b/examples/qml/referenceexamples/methods/birthdayparty.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef 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(QQmlListProperty guests READ guests) +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +// ![0] + Q_INVOKABLE void invite(const QString &name); +// ![0] + +private: + Person *m_host; + QList m_guests; +}; + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/methods/example.qml b/examples/qml/referenceexamples/methods/example.qml new file mode 100644 index 0000000000..9119835e04 --- /dev/null +++ b/examples/qml/referenceexamples/methods/example.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import People 1.0 + +BirthdayParty { + host: Person { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Person { name: "Leo Hodges" }, + Person { name: "Jack Smith" }, + Person { name: "Anne Brown" } + ] + +// ![0] + Component.onCompleted: invite("William Green") +// ![0] +} diff --git a/examples/qml/referenceexamples/methods/main.cpp b/examples/qml/referenceexamples/methods/main.cpp new file mode 100644 index 0000000000..1e502c3943 --- /dev/null +++ b/examples/qml/referenceexamples/methods/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/referenceexamples/methods/methods.pro b/examples/qml/referenceexamples/methods/methods.pro new file mode 100644 index 0000000000..f4c63bfa29 --- /dev/null +++ b/examples/qml/referenceexamples/methods/methods.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += methods.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/methods/methods.qrc b/examples/qml/referenceexamples/methods/methods.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/methods/methods.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/methods/person.cpp b/examples/qml/referenceexamples/methods/person.cpp new file mode 100644 index 0000000000..30d1e46e5a --- /dev/null +++ b/examples/qml/referenceexamples/methods/person.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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/qml/referenceexamples/methods/person.h b/examples/qml/referenceexamples/methods/person.h new file mode 100644 index 0000000000..dd3ad4d188 --- /dev/null +++ b/examples/qml/referenceexamples/methods/person.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/properties/birthdayparty.cpp b/examples/qml/referenceexamples/properties/birthdayparty.cpp new file mode 100644 index 0000000000..8e79d07748 --- /dev/null +++ b/examples/qml/referenceexamples/properties/birthdayparty.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(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/qml/referenceexamples/properties/birthdayparty.h b/examples/qml/referenceexamples/properties/birthdayparty.h new file mode 100644 index 0000000000..84eefa52ae --- /dev/null +++ b/examples/qml/referenceexamples/properties/birthdayparty.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef 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(QQmlListProperty guests READ guests) +// ![2] +// ![3] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![3] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/properties/example.qml b/examples/qml/referenceexamples/properties/example.qml new file mode 100644 index 0000000000..36ee952243 --- /dev/null +++ b/examples/qml/referenceexamples/properties/example.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import 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/qml/referenceexamples/properties/main.cpp b/examples/qml/referenceexamples/properties/main.cpp new file mode 100644 index 0000000000..cc0de89221 --- /dev/null +++ b/examples/qml/referenceexamples/properties/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + +//![register list] + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "Person"); +//![register list] + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/referenceexamples/properties/person.cpp b/examples/qml/referenceexamples/properties/person.cpp new file mode 100644 index 0000000000..30d1e46e5a --- /dev/null +++ b/examples/qml/referenceexamples/properties/person.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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/qml/referenceexamples/properties/person.h b/examples/qml/referenceexamples/properties/person.h new file mode 100644 index 0000000000..dd3ad4d188 --- /dev/null +++ b/examples/qml/referenceexamples/properties/person.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/properties/properties.pro b/examples/qml/referenceexamples/properties/properties.pro new file mode 100644 index 0000000000..e079b1f79e --- /dev/null +++ b/examples/qml/referenceexamples/properties/properties.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += properties.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/properties/properties.qrc b/examples/qml/referenceexamples/properties/properties.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/properties/properties.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/referenceexamples.pro b/examples/qml/referenceexamples/referenceexamples.pro new file mode 100644 index 0000000000..4bfbd488ea --- /dev/null +++ b/examples/qml/referenceexamples/referenceexamples.pro @@ -0,0 +1,15 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + adding \ + attached \ + binding \ + coercion \ + default \ + grouped \ + properties \ + signal \ + valuesource \ + methods + +!contains(QT_CONFIG, no-widgets): SUBDIRS += extended diff --git a/examples/qml/referenceexamples/referenceexamples.qmlproject b/examples/qml/referenceexamples/referenceexamples.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/referenceexamples/referenceexamples.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/referenceexamples/signal/birthdayparty.cpp b/examples/qml/referenceexamples/signal/birthdayparty.cpp new file mode 100644 index 0000000000..b9f7e15907 --- /dev/null +++ b/examples/qml/referenceexamples/signal/birthdayparty.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "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; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(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/qml/referenceexamples/signal/birthdayparty.h b/examples/qml/referenceexamples/signal/birthdayparty.h new file mode 100644 index 0000000000..3f1b020b5a --- /dev/null +++ b/examples/qml/referenceexamples/signal/birthdayparty.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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(QQmlListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty 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/qml/referenceexamples/signal/example.qml b/examples/qml/referenceexamples/signal/example.qml new file mode 100644 index 0000000000..db959ffd86 --- /dev/null +++ b/examples/qml/referenceexamples/signal/example.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 +import QtQuick 2.0 // For QColor + +BirthdayParty { +// ![0] + 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/qml/referenceexamples/signal/main.cpp b/examples/qml/referenceexamples/signal/main.cpp new file mode 100644 index 0000000000..21a26d9b67 --- /dev/null +++ b/examples/qml/referenceexamples/signal/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/referenceexamples/signal/person.cpp b/examples/qml/referenceexamples/signal/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/referenceexamples/signal/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/signal/person.h b/examples/qml/referenceexamples/signal/person.h new file mode 100644 index 0000000000..032eca3c17 --- /dev/null +++ b/examples/qml/referenceexamples/signal/person.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/signal/signal.pro b/examples/qml/referenceexamples/signal/signal.pro new file mode 100644 index 0000000000..d426e398a5 --- /dev/null +++ b/examples/qml/referenceexamples/signal/signal.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += signal.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/signal/signal.qrc b/examples/qml/referenceexamples/signal/signal.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/signal/signal.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/referenceexamples/valuesource/birthdayparty.cpp b/examples/qml/referenceexamples/valuesource/birthdayparty.cpp new file mode 100644 index 0000000000..aa8bc77116 --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/birthdayparty.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(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/qml/referenceexamples/valuesource/birthdayparty.h b/examples/qml/referenceexamples/valuesource/birthdayparty.h new file mode 100644 index 0000000000..f3635e899b --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/birthdayparty.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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(QQmlListProperty 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 *); + + QQmlListProperty 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/qml/referenceexamples/valuesource/example.qml b/examples/qml/referenceexamples/valuesource/example.qml new file mode 100644 index 0000000000..4c25cebae3 --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/example.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 +import QtQuick 2.0 // For QColor + +// ![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/qml/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/qml/referenceexamples/valuesource/happybirthdaysong.cpp new file mode 100644 index 0000000000..d69154b57a --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/happybirthdaysong.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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 QQmlProperty &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/qml/referenceexamples/valuesource/happybirthdaysong.h b/examples/qml/referenceexamples/valuesource/happybirthdaysong.h new file mode 100644 index 0000000000..19e47c28ac --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/happybirthdaysong.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include +#include + +#include + +// ![0] +class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource +{ + Q_OBJECT + Q_INTERFACES(QQmlPropertyValueSource) +// ![0] + Q_PROPERTY(QString name READ name WRITE setName) +// ![1] +public: + HappyBirthdaySong(QObject *parent = 0); + + virtual void setTarget(const QQmlProperty &); +// ![1] + + QString name() const; + void setName(const QString &); + +private slots: + void advance(); + +private: + int m_line; + QStringList m_lyrics; + QQmlProperty m_target; + QString m_name; +// ![2] +}; +// ![2] + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/qml/referenceexamples/valuesource/main.cpp b/examples/qml/referenceexamples/valuesource/main.cpp new file mode 100644 index 0000000000..e119e719af --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc: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() << component.errors(); + } + + return app.exec(); +} diff --git a/examples/qml/referenceexamples/valuesource/person.cpp b/examples/qml/referenceexamples/valuesource/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/valuesource/person.h b/examples/qml/referenceexamples/valuesource/person.h new file mode 100644 index 0000000000..032eca3c17 --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/person.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#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/qml/referenceexamples/valuesource/valuesource.pro b/examples/qml/referenceexamples/valuesource/valuesource.pro new file mode 100644 index 0000000000..afc1784d71 --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/valuesource.pro @@ -0,0 +1,15 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.h +RESOURCES += valuesource.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource +INSTALLS += target sources diff --git a/examples/qml/referenceexamples/valuesource/valuesource.qrc b/examples/qml/referenceexamples/valuesource/valuesource.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/referenceexamples/valuesource/valuesource.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/script/script.pro b/examples/qml/script/script.pro deleted file mode 100644 index 98c1bbc5ee..0000000000 --- a/examples/qml/script/script.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = \ - shell diff --git a/examples/qml/script/shell/main.cpp b/examples/qml/script/shell/main.cpp deleted file mode 100644 index 4ea36f7e77..0000000000 --- a/examples/qml/script/shell/main.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include -#include -#include - -#include - -#include - -#include - - -class CommandInterface : public QObject -{ - Q_OBJECT -public: - Q_INVOKABLE void quit() { m_wantsToQuit = true; } - static bool wantsToQuit() { return m_wantsToQuit; } -private: - static bool m_wantsToQuit; -}; - -bool CommandInterface::m_wantsToQuit = false; - - -static void interactive(QJSEngine *eng) -{ - QTextStream qin(stdin, QFile::ReadOnly); - const char *prompt = "qs> "; - - forever { - QString line; - - printf("%s", prompt); - fflush(stdout); - - line = qin.readLine(); - if (line.isNull()) - break; - - if (line.trimmed().isEmpty()) - continue; - - line += QLatin1Char('\n'); - - QJSValue result = eng->evaluate(line, QLatin1String("typein")); - - fprintf(stderr, "%s\n", qPrintable(result.toString())); - - if (CommandInterface::wantsToQuit()) - break; - } -} - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - QScopedPointer eng(new QJSEngine()); - { - QJSValue globalObject = eng->globalObject(); - QJSValue interface = eng->newQObject(new CommandInterface); - globalObject.setProperty("qt", interface); - } - - if (! *++argv) { - interactive(eng.data()); - return EXIT_SUCCESS; - } - - while (const char *arg = *argv++) { - QString fileName = QString::fromLocal8Bit(arg); - - if (fileName == QLatin1String("-i")) { - interactive(eng.data()); - break; - } - - QString contents; - int lineNumber = 1; - - if (fileName == QLatin1String("-")) { - QTextStream stream(stdin, QFile::ReadOnly); - contents = stream.readAll(); - } else { - QFile file(fileName); - if (file.open(QFile::ReadOnly)) { - QTextStream stream(&file); - contents = stream.readAll(); - file.close(); - - // strip off #!/usr/bin/env qjs line - if (contents.startsWith("#!")) { - contents.remove(0, contents.indexOf("\n")); - ++lineNumber; - } - } - } - - if (contents.isEmpty()) - continue; - - QJSValue result = eng->evaluate(contents, fileName, lineNumber); - if (result.isError()) { - fprintf (stderr, " %s\n\n", qPrintable(result.toString())); - return EXIT_FAILURE; - } - } - - return EXIT_SUCCESS; -} - -#include diff --git a/examples/qml/script/shell/shell.pro b/examples/qml/script/shell/shell.pro deleted file mode 100644 index 5f6b23862b..0000000000 --- a/examples/qml/script/shell/shell.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += qml - -win32: CONFIG += console -mac:CONFIG -= app_bundle - -SOURCES += main.cpp - diff --git a/examples/qml/shell/main.cpp b/examples/qml/shell/main.cpp new file mode 100644 index 0000000000..4ea36f7e77 --- /dev/null +++ b/examples/qml/shell/main.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include + +#include + +#include + +#include + + +class CommandInterface : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE void quit() { m_wantsToQuit = true; } + static bool wantsToQuit() { return m_wantsToQuit; } +private: + static bool m_wantsToQuit; +}; + +bool CommandInterface::m_wantsToQuit = false; + + +static void interactive(QJSEngine *eng) +{ + QTextStream qin(stdin, QFile::ReadOnly); + const char *prompt = "qs> "; + + forever { + QString line; + + printf("%s", prompt); + fflush(stdout); + + line = qin.readLine(); + if (line.isNull()) + break; + + if (line.trimmed().isEmpty()) + continue; + + line += QLatin1Char('\n'); + + QJSValue result = eng->evaluate(line, QLatin1String("typein")); + + fprintf(stderr, "%s\n", qPrintable(result.toString())); + + if (CommandInterface::wantsToQuit()) + break; + } +} + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QScopedPointer eng(new QJSEngine()); + { + QJSValue globalObject = eng->globalObject(); + QJSValue interface = eng->newQObject(new CommandInterface); + globalObject.setProperty("qt", interface); + } + + if (! *++argv) { + interactive(eng.data()); + return EXIT_SUCCESS; + } + + while (const char *arg = *argv++) { + QString fileName = QString::fromLocal8Bit(arg); + + if (fileName == QLatin1String("-i")) { + interactive(eng.data()); + break; + } + + QString contents; + int lineNumber = 1; + + if (fileName == QLatin1String("-")) { + QTextStream stream(stdin, QFile::ReadOnly); + contents = stream.readAll(); + } else { + QFile file(fileName); + if (file.open(QFile::ReadOnly)) { + QTextStream stream(&file); + contents = stream.readAll(); + file.close(); + + // strip off #!/usr/bin/env qjs line + if (contents.startsWith("#!")) { + contents.remove(0, contents.indexOf("\n")); + ++lineNumber; + } + } + } + + if (contents.isEmpty()) + continue; + + QJSValue result = eng->evaluate(contents, fileName, lineNumber); + if (result.isError()) { + fprintf (stderr, " %s\n\n", qPrintable(result.toString())); + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; +} + +#include diff --git a/examples/qml/shell/shell.pro b/examples/qml/shell/shell.pro new file mode 100644 index 0000000000..5f6b23862b --- /dev/null +++ b/examples/qml/shell/shell.pro @@ -0,0 +1,7 @@ +QT += qml + +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += main.cpp + diff --git a/examples/qmltest/qmltest.pro b/examples/qmltest/qmltest.pro index 40d964c20a..b98cc03c65 100644 --- a/examples/qmltest/qmltest.pro +++ b/examples/qmltest/qmltest.pro @@ -1,4 +1,2 @@ -TEMPLATE=app -TARGET=tst_qmltestexample -CONFIG += qmltestcase -SOURCES += tst_qmltest.cpp +TEMPLATE = subdirs +SUBDIRS += qmltest diff --git a/examples/qmltest/qmltest/qmltest.pro b/examples/qmltest/qmltest/qmltest.pro new file mode 100644 index 0000000000..40d964c20a --- /dev/null +++ b/examples/qmltest/qmltest/qmltest.pro @@ -0,0 +1,4 @@ +TEMPLATE=app +TARGET=tst_qmltestexample +CONFIG += qmltestcase +SOURCES += tst_qmltest.cpp diff --git a/examples/qmltest/qmltest/tst_basic.qml b/examples/qmltest/qmltest/tst_basic.qml new file mode 100644 index 0000000000..2ff6880922 --- /dev/null +++ b/examples/qmltest/qmltest/tst_basic.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + name: "BasicTests" + + function test_pass() { + compare(2 + 2, 4, "2 + 2") + } + + function test_fail() { + expectFail("", "this is the fail we wanted") + compare(2 + 2, 5, "2 + 2") + } + + function test_skip() { + skip("skipping") + } + + function test_expecting() { + expectFail("", "this is the fail we wanted") + verify(false) + } + + function test_table_data() { + return [ + {tag: "2 + 2 = 4", a: 2, b: 2, answer: 4 }, + {tag: "2 + 6 = 8", a: 2, b: 6, answer: 8 }, + {tag: "2 + 2 = 5", a: 2, b: 2, answer: 5 }, // fail + ] + } + + function test_table(data) { + if (data.answer === 5) + expectFail("", "this is the fail we wanted") + compare(data.a + data.b, data.answer) + } +} diff --git a/examples/qmltest/qmltest/tst_item.qml b/examples/qmltest/qmltest/tst_item.qml new file mode 100644 index 0000000000..44934c2c72 --- /dev/null +++ b/examples/qmltest/qmltest/tst_item.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 + +Rectangle { + id: foo + width: 640; height: 480 + color: "cyan" + + TestCase { + name: "ItemTests" + id: test1 + + function test_color() { + compare(foo.color, "#00ffff") + } + } +} diff --git a/examples/qmltest/qmltest/tst_qmltest.cpp b/examples/qmltest/qmltest/tst_qmltest.cpp new file mode 100644 index 0000000000..02e2e3b5e6 --- /dev/null +++ b/examples/qmltest/qmltest/tst_qmltest.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +QUICK_TEST_MAIN(qmltestexample) diff --git a/examples/qmltest/tst_basic.qml b/examples/qmltest/tst_basic.qml deleted file mode 100644 index 2ff6880922..0000000000 --- a/examples/qmltest/tst_basic.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtTest 1.0 - -TestCase { - name: "BasicTests" - - function test_pass() { - compare(2 + 2, 4, "2 + 2") - } - - function test_fail() { - expectFail("", "this is the fail we wanted") - compare(2 + 2, 5, "2 + 2") - } - - function test_skip() { - skip("skipping") - } - - function test_expecting() { - expectFail("", "this is the fail we wanted") - verify(false) - } - - function test_table_data() { - return [ - {tag: "2 + 2 = 4", a: 2, b: 2, answer: 4 }, - {tag: "2 + 6 = 8", a: 2, b: 6, answer: 8 }, - {tag: "2 + 2 = 5", a: 2, b: 2, answer: 5 }, // fail - ] - } - - function test_table(data) { - if (data.answer === 5) - expectFail("", "this is the fail we wanted") - compare(data.a + data.b, data.answer) - } -} diff --git a/examples/qmltest/tst_item.qml b/examples/qmltest/tst_item.qml deleted file mode 100644 index 44934c2c72..0000000000 --- a/examples/qmltest/tst_item.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtTest 1.0 - -Rectangle { - id: foo - width: 640; height: 480 - color: "cyan" - - TestCase { - name: "ItemTests" - id: test1 - - function test_color() { - compare(foo.color, "#00ffff") - } - } -} diff --git a/examples/qmltest/tst_qmltest.cpp b/examples/qmltest/tst_qmltest.cpp deleted file mode 100644 index 02e2e3b5e6..0000000000 --- a/examples/qmltest/tst_qmltest.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -QUICK_TEST_MAIN(qmltestexample) diff --git a/examples/quick/customitems/customitems.pro b/examples/quick/customitems/customitems.pro new file mode 100644 index 0000000000..2349fce1e0 --- /dev/null +++ b/examples/quick/customitems/customitems.pro @@ -0,0 +1,13 @@ +TEMPLATE = subdirs +SUBDIRS = \ + #dialcontrol \ + #flipable \ + glitem \ + painteditem \ + #progressbar \ + #scrollbar \ + #searchbox \ + #slideswitch \ + #spinner \ + #tabwidget \ + maskedmousearea diff --git a/examples/quick/customitems/dialcontrol/content/Dial.qml b/examples/quick/customitems/dialcontrol/content/Dial.qml new file mode 100644 index 0000000000..c61adee364 --- /dev/null +++ b/examples/quick/customitems/dialcontrol/content/Dial.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property real value : 0 + + width: 210; height: 210 + + Image { source: "background.png" } + +//! [needle_shadow] + Image { + x: 96 + y: 35 + source: "needle_shadow.png" + transform: Rotation { + origin.x: 9; origin.y: 67 + angle: needleRotation.angle + } + } +//! [needle_shadow] +//! [needle] + Image { + id: needle + x: 98; y: 33 + smooth: true + source: "needle.png" + transform: Rotation { + id: needleRotation + origin.x: 5; origin.y: 65 + //! [needle angle] + angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + Behavior on angle { + SpringAnimation { + spring: 1.4 + damping: .15 + } + } + //! [needle angle] + } + } +//! [needle] +//! [overlay] + Image { x: 21; y: 18; source: "overlay.png" } +//! [overlay] +} diff --git a/examples/quick/customitems/dialcontrol/content/QuitButton.qml b/examples/quick/customitems/dialcontrol/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/quick/customitems/dialcontrol/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/quick/customitems/dialcontrol/content/background.png b/examples/quick/customitems/dialcontrol/content/background.png new file mode 100644 index 0000000000..75d555d7ab Binary files /dev/null and b/examples/quick/customitems/dialcontrol/content/background.png differ diff --git a/examples/quick/customitems/dialcontrol/content/needle.png b/examples/quick/customitems/dialcontrol/content/needle.png new file mode 100644 index 0000000000..2d19f75039 Binary files /dev/null and b/examples/quick/customitems/dialcontrol/content/needle.png differ diff --git a/examples/quick/customitems/dialcontrol/content/needle_shadow.png b/examples/quick/customitems/dialcontrol/content/needle_shadow.png new file mode 100644 index 0000000000..8d8a928cc5 Binary files /dev/null and b/examples/quick/customitems/dialcontrol/content/needle_shadow.png differ diff --git a/examples/quick/customitems/dialcontrol/content/overlay.png b/examples/quick/customitems/dialcontrol/content/overlay.png new file mode 100644 index 0000000000..3860a7b590 Binary files /dev/null and b/examples/quick/customitems/dialcontrol/content/overlay.png differ diff --git a/examples/quick/customitems/dialcontrol/content/quit.png b/examples/quick/customitems/dialcontrol/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/quick/customitems/dialcontrol/content/quit.png differ diff --git a/examples/quick/customitems/dialcontrol/dialcontrol.qml b/examples/quick/customitems/dialcontrol/dialcontrol.qml new file mode 100644 index 0000000000..467a558696 --- /dev/null +++ b/examples/quick/customitems/dialcontrol/dialcontrol.qml @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [imports] +import QtQuick 2.0 +import "content" +//! [imports] + +//! [0] +Rectangle { + color: "#545454" + width: 300; height: 300 + + //! [the dial in use] + // Dial with a slider to adjust it + Dial { + id: dial + anchors.centerIn: parent + value: slider.x * 100 / (container.width - 34) + } + //! [the dial in use] + + Rectangle { + id: container + anchors { bottom: parent.bottom; left: parent.left + right: parent.right; leftMargin: 20; rightMargin: 20 + bottomMargin: 10 + } + height: 16 + + radius: 8 + opacity: 0.7 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "gray" } + GradientStop { position: 1.0; color: "white" } + } + + Rectangle { + id: slider + x: 1; y: 1; width: 30; height: 14 + radius: 6 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#424242" } + GradientStop { position: 1.0; color: "black" } + } + + MouseArea { + anchors.fill: parent + anchors.margins: -16 // Increase mouse area a lot outside the slider + drag.target: parent; drag.axis: Drag.XAxis + drag.minimumX: 2; drag.maximumX: container.width - 32 + } + } + } + QuitButton { + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 10 + } +} +//! [0] diff --git a/examples/quick/customitems/flipable/content/5_heart.png b/examples/quick/customitems/flipable/content/5_heart.png new file mode 100644 index 0000000000..fb59d81453 Binary files /dev/null and b/examples/quick/customitems/flipable/content/5_heart.png differ diff --git a/examples/quick/customitems/flipable/content/9_club.png b/examples/quick/customitems/flipable/content/9_club.png new file mode 100644 index 0000000000..2545001904 Binary files /dev/null and b/examples/quick/customitems/flipable/content/9_club.png differ diff --git a/examples/quick/customitems/flipable/content/Card.qml b/examples/quick/customitems/flipable/content/Card.qml new file mode 100644 index 0000000000..6006ea14fc --- /dev/null +++ b/examples/quick/customitems/flipable/content/Card.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: container + + property alias source: frontImage.source + property bool flipped: true + property int xAxis: 0 + property int yAxis: 0 + property int angle: 0 + + width: front.width; height: front.height + + front: Image { id: frontImage; smooth: true } + back: Image { source: "back.png"; smooth: true } + + state: "back" + + MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } + + transform: Rotation { + id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 + axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 + } + + states: State { + name: "back"; when: container.flipped + PropertyChanges { target: rotation; angle: container.angle } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { target: rotation; properties: "angle"; duration: 600 } + SequentialAnimation { + NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } + NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } + } + } + } +} diff --git a/examples/quick/customitems/flipable/content/back.png b/examples/quick/customitems/flipable/content/back.png new file mode 100644 index 0000000000..f715d7487e Binary files /dev/null and b/examples/quick/customitems/flipable/content/back.png differ diff --git a/examples/quick/customitems/flipable/flipable.qml b/examples/quick/customitems/flipable/flipable.qml new file mode 100644 index 0000000000..4af64afc53 --- /dev/null +++ b/examples/quick/customitems/flipable/flipable.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "darkgreen" + + Row { + anchors.centerIn: parent; spacing: 30 + Card { source: "content/9_club.png"; angle: 180; yAxis: 1 } + Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 } + } +} diff --git a/examples/quick/customitems/glitem/glitem.pro b/examples/quick/customitems/glitem/glitem.pro new file mode 100644 index 0000000000..64a58b3729 --- /dev/null +++ b/examples/quick/customitems/glitem/glitem.pro @@ -0,0 +1,6 @@ +QT += qml quick + +HEADERS += squircle.h +SOURCES += squircle.cpp main.cpp + +OTHER_FILES += main.qml diff --git a/examples/quick/customitems/glitem/main.cpp b/examples/quick/customitems/glitem/main.cpp new file mode 100644 index 0000000000..8d1a91bdb2 --- /dev/null +++ b/examples/quick/customitems/glitem/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +#include "squircle.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("OpenGLUnderQML", 2, 0, "Squircle"); + + QQuickView view; + view.setSource(QUrl("main.qml")); + view.show(); + + return app.exec(); + +} diff --git a/examples/quick/customitems/glitem/main.qml b/examples/quick/customitems/glitem/main.qml new file mode 100644 index 0000000000..66bc08bf03 --- /dev/null +++ b/examples/quick/customitems/glitem/main.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import OpenGLUnderQML 2.0 + +Item { + + width: 320 + height: 480 + + Squircle { + width: 320 + height: 320 + SequentialAnimation on t { + NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } + NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } + loops: Animation.Infinite + running: true + } + } + + Rectangle { + color: Qt.rgba(1, 1, 1, 0.8); + radius: 10 + border.width: 1 + border.color: "white" + anchors.fill: label + anchors.margins: -10 + } + + Text { + id: label + color: "black" + wrapMode: Text.WordWrap + text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickWindow. This text label and its border is rendered using QML" + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 20 + } + +} diff --git a/examples/quick/customitems/glitem/squircle.cpp b/examples/quick/customitems/glitem/squircle.cpp new file mode 100644 index 0000000000..b1340687f9 --- /dev/null +++ b/examples/quick/customitems/glitem/squircle.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "squircle.h" + +#include +#include + +Squircle::Squircle() + : m_program(0) +{ + setFlag(ItemHasContents); +} + +void Squircle::itemChange(ItemChange change, const ItemChangeData &) +{ + // The ItemSceneChange event is sent when we are first attached to a window. + if (change == ItemSceneChange) { + QQuickWindow *c = window(); + + // Connect our the beforeRendering signal to our paint function. + // Since this call is executed on the rendering thread it must be + // a Qt::DirectConnection + connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); + + // If we allow QML to do the clearing, they would clear what we paint + // and nothing would show. + c->setClearBeforeRendering(false); + } +} + +void Squircle::paint() +{ + if (!m_program) { + m_program = new QOpenGLShaderProgram(); + m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, + "attribute highp vec4 vertices;" + "varying highp vec2 coords;" + "void main() {" + " gl_Position = vertices;" + " coords = vertices.xy;" + "}"); + m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, + "uniform lowp float t;" + "varying highp vec2 coords;" + "void main() {" + " lowp float i = 1. - (pow(coords.x, 4.) + pow(coords.y, 4.));" + " i = smoothstep(t - 0.3, t + 0.3, i);" + " gl_FragColor = vec4(coords / 2. + .5, i, i);" + "}"); + + m_program->bindAttributeLocation("vertices", 0); + m_program->link(); + } + + m_program->bind(); + + m_program->enableAttributeArray(0); + + float values[] = { + -1, -1, + 1, -1, + -1, 1, + 1, 1 + }; + m_program->setAttributeArray(0, GL_FLOAT, values, 2); + m_program->setUniformValue("t", (float) m_t); + + glViewport(0, 0, window()->width(), window()->height()); + + glDisable(GL_DEPTH_TEST); + + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + m_program->disableAttributeArray(0); + m_program->release(); +} + + diff --git a/examples/quick/customitems/glitem/squircle.h b/examples/quick/customitems/glitem/squircle.h new file mode 100644 index 0000000000..9e7a03b75b --- /dev/null +++ b/examples/quick/customitems/glitem/squircle.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SQUIRCLE_H +#define SQUIRCLE_H + +#include +#include + +class Squircle : public QQuickItem +{ + Q_OBJECT + + Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) + +public: + Squircle(); + + qreal t() const { return m_t; } + void setT(qreal t) { m_t = t; emit tChanged(); update(); } + + void itemChange(ItemChange change, const ItemChangeData &); + +signals: + void tChanged(); + +public slots: + void paint(); + +private: + QOpenGLShaderProgram *m_program; + + qreal m_t; + bool m_render_under; + bool m_render_over; +}; + +#endif // SQUIRCLE_H diff --git a/examples/quick/customitems/maskedmousearea/images/cloud_1.png b/examples/quick/customitems/maskedmousearea/images/cloud_1.png new file mode 100644 index 0000000000..87c54af253 Binary files /dev/null and b/examples/quick/customitems/maskedmousearea/images/cloud_1.png differ diff --git a/examples/quick/customitems/maskedmousearea/images/cloud_2.png b/examples/quick/customitems/maskedmousearea/images/cloud_2.png new file mode 100644 index 0000000000..981bbd2630 Binary files /dev/null and b/examples/quick/customitems/maskedmousearea/images/cloud_2.png differ diff --git a/examples/quick/customitems/maskedmousearea/images/moon.png b/examples/quick/customitems/maskedmousearea/images/moon.png new file mode 100644 index 0000000000..0a8037dd85 Binary files /dev/null and b/examples/quick/customitems/maskedmousearea/images/moon.png differ diff --git a/examples/quick/customitems/maskedmousearea/main.cpp b/examples/quick/customitems/maskedmousearea/main.cpp new file mode 100644 index 0000000000..407497e640 --- /dev/null +++ b/examples/quick/customitems/maskedmousearea/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "maskedmousearea.h" + + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc,argv); + QQuickView view; + + qmlRegisterType("Example", 1, 0, "MaskedMouseArea"); + + view.setSource(QUrl::fromLocalFile("maskedmousearea.qml")); + view.show(); + return app.exec(); +} diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp b/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp new file mode 100644 index 0000000000..3f872a66f6 --- /dev/null +++ b/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "maskedmousearea.h" + +#include +#include + + +MaskedMouseArea::MaskedMouseArea(QQuickItem *parent) + : QQuickItem(parent), + m_pressed(false), + m_alphaThreshold(0.0), + m_containsMouse(false) +{ + setAcceptHoverEvents(true); + setAcceptedMouseButtons(Qt::LeftButton); +} + +void MaskedMouseArea::setPressed(bool pressed) +{ + if (m_pressed != pressed) { + m_pressed = pressed; + emit pressedChanged(); + } +} + +void MaskedMouseArea::setContainsMouse(bool containsMouse) +{ + if (m_containsMouse != containsMouse) { + m_containsMouse = containsMouse; + emit containsMouseChanged(); + } +} + +void MaskedMouseArea::setMaskSource(const QUrl &source) +{ + if (m_maskSource != source) { + m_maskSource = source; + m_maskImage = QImage(source.toLocalFile()); + emit maskSourceChanged(); + } +} + +void MaskedMouseArea::setAlphaThreshold(qreal threshold) +{ + if (m_alphaThreshold != threshold) { + m_alphaThreshold = threshold; + emit alphaThresholdChanged(); + } +} + +bool MaskedMouseArea::contains(const QPointF &point) const +{ + if (!QQuickItem::contains(point) || m_maskImage.isNull()) + return false; + + QPoint p = point.toPoint(); + + if (p.x() < 0 || p.x() >= m_maskImage.width() || + p.y() < 0 || p.y() >= m_maskImage.height()) + return false; + + qreal r = qBound(0, m_alphaThreshold * 255, 255); + return qAlpha(m_maskImage.pixel(p)) > r; +} + +void MaskedMouseArea::mousePressEvent(QMouseEvent *event) +{ + setPressed(true); + m_pressPoint = event->pos(); + emit pressed(); +} + +void MaskedMouseArea::mouseReleaseEvent(QMouseEvent *event) +{ + setPressed(false); + emit released(); + + const int threshold = qApp->styleHints()->startDragDistance(); + const bool isClick = (threshold >= qAbs(event->x() - m_pressPoint.x()) && + threshold >= qAbs(event->y() - m_pressPoint.y())); + + if (isClick) + emit clicked(); +} + +void MaskedMouseArea::mouseUngrabEvent() +{ + setPressed(false); + emit canceled(); +} + +void MaskedMouseArea::hoverEnterEvent(QHoverEvent *event) +{ + Q_UNUSED(event); + setContainsMouse(true); +} + +void MaskedMouseArea::hoverLeaveEvent(QHoverEvent *event) +{ + Q_UNUSED(event); + setContainsMouse(false); +} diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.h b/examples/quick/customitems/maskedmousearea/maskedmousearea.h new file mode 100644 index 0000000000..045d02d6f0 --- /dev/null +++ b/examples/quick/customitems/maskedmousearea/maskedmousearea.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MASKEDMOUSEAREA_H +#define MASKEDMOUSEAREA_H + +#include +#include + + +class MaskedMouseArea : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged) + Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) + Q_PROPERTY(QUrl maskSource READ maskSource WRITE setMaskSource NOTIFY maskSourceChanged) + Q_PROPERTY(qreal alphaThreshold READ alphaThreshold WRITE setAlphaThreshold NOTIFY alphaThresholdChanged) + +public: + MaskedMouseArea(QQuickItem *parent = 0); + + bool contains(const QPointF &point) const; + + bool isPressed() const { return m_pressed; } + bool containsMouse() const { return m_containsMouse; } + + QUrl maskSource() const { return m_maskSource; } + void setMaskSource(const QUrl &source); + + qreal alphaThreshold() const { return m_alphaThreshold; } + void setAlphaThreshold(qreal threshold); + +signals: + void pressed(); + void released(); + void clicked(); + void canceled(); + void pressedChanged(); + void maskSourceChanged(); + void containsMouseChanged(); + void alphaThresholdChanged(); + +protected: + void setPressed(bool pressed); + void setContainsMouse(bool containsMouse); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void hoverEnterEvent(QHoverEvent *event); + void hoverLeaveEvent(QHoverEvent *event); + void mouseUngrabEvent(); + +private: + bool m_pressed; + QUrl m_maskSource; + QImage m_maskImage; + QPointF m_pressPoint; + qreal m_alphaThreshold; + bool m_containsMouse; +}; + +#endif diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.pro b/examples/quick/customitems/maskedmousearea/maskedmousearea.pro new file mode 100644 index 0000000000..1623f7919b --- /dev/null +++ b/examples/quick/customitems/maskedmousearea/maskedmousearea.pro @@ -0,0 +1,14 @@ +TEMPLATE = app + +QT += quick qml + +HEADERS += maskedmousearea.h + +SOURCES += main.cpp \ + maskedmousearea.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/maskedmousearea +qml.files = maskedmousearea.qml images +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/maskedmousearea +INSTALLS += target qml + diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.qml b/examples/quick/customitems/maskedmousearea/maskedmousearea.qml new file mode 100644 index 0000000000..82d351b04f --- /dev/null +++ b/examples/quick/customitems/maskedmousearea/maskedmousearea.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Example 1.0 + +Rectangle { + height: 480 + width: 320 + color: "black" + + Text { + text: qsTr("CLICK AND HOVER") + opacity: 0.6 + color: "white" + font.pixelSize: 20 + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + anchors.topMargin: 50 + } + + Image { + id: moon + smooth: true + anchors.centerIn: parent + scale: moonArea.pressed ? 1.1 : 1.0 + opacity: moonArea.containsMouse ? 1.0 : 0.7 + source: Qt.resolvedUrl("images/moon.png") + + MaskedMouseArea { + id: moonArea + anchors.fill: parent + alphaThreshold: 0.4 + maskSource: moon.source + } + + Behavior on opacity { + NumberAnimation { duration: 200 } + } + Behavior on scale { + NumberAnimation { duration: 100 } + } + } + + Image { + id: rightCloud + anchors { + centerIn: moon + verticalCenterOffset: 30 + horizontalCenterOffset: 80 + } + smooth: true + scale: rightCloudArea.pressed ? 1.1 : 1.0 + opacity: rightCloudArea.containsMouse ? 1.0 : 0.7 + source: Qt.resolvedUrl("images/cloud_2.png") + + MaskedMouseArea { + id: rightCloudArea + anchors.fill: parent + alphaThreshold: 0.4 + maskSource: rightCloud.source + } + + Behavior on opacity { + NumberAnimation { duration: 200 } + } + Behavior on scale { + NumberAnimation { duration: 100 } + } + } + + Image { + id: leftCloud + anchors { + centerIn: moon + verticalCenterOffset: 40 + horizontalCenterOffset: -80 + } + smooth: true + scale: leftCloudArea.pressed ? 1.1 : 1.0 + opacity: leftCloudArea.containsMouse ? 1.0 : 0.7 + source: Qt.resolvedUrl("images/cloud_1.png") + + MaskedMouseArea { + id: leftCloudArea + anchors.fill: parent + alphaThreshold: 0.4 + maskSource: leftCloud.source + } + + Behavior on opacity { + NumberAnimation { duration: 200 } + } + Behavior on scale { + NumberAnimation { duration: 100 } + } + } +} diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.qmlproject b/examples/quick/customitems/maskedmousearea/maskedmousearea.qmlproject new file mode 100644 index 0000000000..709c19866f --- /dev/null +++ b/examples/quick/customitems/maskedmousearea/maskedmousearea.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "maskedmousearea.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h b/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h new file mode 100644 index 0000000000..a039339ba4 --- /dev/null +++ b/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "../textballoon.h" + +class TextBalloonPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") +public: + void registerTypes(const char *uri) + { + qmlRegisterType(uri, 1, 0, "TextBalloon"); + } +}; diff --git a/examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir b/examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir new file mode 100644 index 0000000000..e8a08ae9d3 --- /dev/null +++ b/examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir @@ -0,0 +1 @@ +plugin qmltextballoonplugin diff --git a/examples/quick/customitems/painteditem/painteditem.pro b/examples/quick/customitems/painteditem/painteditem.pro new file mode 100644 index 0000000000..9526817146 --- /dev/null +++ b/examples/quick/customitems/painteditem/painteditem.pro @@ -0,0 +1,25 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml quick + +TARGET = qmltextballoonplugin + +HEADERS += TextBalloonPlugin/plugin.h \ + textballoon.h + +SOURCES += textballoon.cpp + +OTHER_FILES += textballoon.json + +DESTDIR = TextBalloonPlugin + +qdeclarativesources.files += \ + TextBalloonPlugin/qmldir + +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/TextBalloonPlugin + +sources.files = textballoons.qml +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/TextBalloonPlugin + +INSTALLS = qdeclarativesources sources target diff --git a/examples/quick/customitems/painteditem/textballoon.cpp b/examples/quick/customitems/painteditem/textballoon.cpp new file mode 100644 index 0000000000..d097adfe1b --- /dev/null +++ b/examples/quick/customitems/painteditem/textballoon.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "textballoon.h" + +//! [0] +TextBalloon::TextBalloon(QQuickItem *parent) + : QQuickPaintedItem(parent) + , rightAligned(false) +{ +} +//! [0] + +//! [1] +void TextBalloon::paint(QPainter *painter) +{ + QBrush brush(QColor("#007430")); + + painter->setBrush(brush); + painter->setPen(Qt::NoPen); + painter->setRenderHint(QPainter::Antialiasing); + + painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10); + + if (rightAligned) + { + const QPointF points[3] = { + QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0), + QPointF(boundingRect().width() - 20.0, boundingRect().height()), + QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } + else + { + const QPointF points[3] = { + QPointF(10.0, boundingRect().height() - 10.0), + QPointF(20.0, boundingRect().height()), + QPointF(30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } +} +//! [1] + +bool TextBalloon::isRightAligned() +{ + return this->rightAligned; +} + +void TextBalloon::setRightAligned(bool rightAligned) +{ + this->rightAligned = rightAligned; +} diff --git a/examples/quick/customitems/painteditem/textballoon.h b/examples/quick/customitems/painteditem/textballoon.h new file mode 100644 index 0000000000..93ed0a7105 --- /dev/null +++ b/examples/quick/customitems/painteditem/textballoon.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTBALLOON_H +#define TEXTBALLOON_H + +#include + +//! [0] +class TextBalloon : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) + + public: + TextBalloon(QQuickItem *parent = 0); + void paint(QPainter *painter); + + bool isRightAligned(); + void setRightAligned(bool rightAligned); + + private: + bool rightAligned; + + signals: + void rightAlignedChanged(); +}; +//! [0] + +#endif diff --git a/examples/quick/customitems/painteditem/textballoons.qml b/examples/quick/customitems/painteditem/textballoons.qml new file mode 100644 index 0000000000..d5151c9553 --- /dev/null +++ b/examples/quick/customitems/painteditem/textballoons.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import TextBalloonPlugin 1.0 + +/*! + \title QtQuick Examples - Painted Text Balloons + \example quick/painteditem/textballoons + \brief This is a simple example that draws text balloons using QPainter +*/ +Item { + height: 480 + width: 320 + + //! [0] + ListModel { + id: balloonModel + ListElement { + balloonWidth: 200 + } + ListElement { + balloonWidth: 120 + } + } + + ListView { + anchors.bottom: controls.top + anchors.bottomMargin: 2 + anchors.top: parent.top + id: balloonView + delegate: TextBalloon { + anchors.right: index % 2 == 0 ? undefined : parent.right + height: 60 + rightAligned: index % 2 == 0 ? false : true + width: balloonWidth + } + model: balloonModel + spacing: 5 + width: parent.width + } + //! [0] + + //! [1] + Rectangle { + id: controls + + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.margins: 1 + anchors.right: parent.right + border.width: 2 + color: "white" + height: parent.height * 0.15 + + Text { + anchors.centerIn: parent + text: "Add another balloon" + } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onClicked: { + balloonModel.append({"balloonWidth": Math.floor(Math.random() * 200 + 100)}) + balloonView.positionViewAtIndex(balloonView.count -1, ListView.End) + } + onEntered: { + parent.color = "#8ac953" + } + onExited: { + parent.color = "white" + } + } + } + //! [1] +} diff --git a/examples/quick/customitems/progressbar/content/ProgressBar.qml b/examples/quick/customitems/progressbar/content/ProgressBar.qml new file mode 100644 index 0000000000..c9be8d7336 --- /dev/null +++ b/examples/quick/customitems/progressbar/content/ProgressBar.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: progressbar + + property int minimum: 0 + property int maximum: 100 + property int value: 0 + property alias color: gradient1.color + property alias secondColor: gradient2.color + + width: 250; height: 23 + clip: true + + BorderImage { + source: "background.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + Rectangle { + id: highlight + + property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) + + width: highlight.widthDest + Behavior on width { SmoothedAnimation { velocity: 1200 } } + + anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 } + radius: 1 + gradient: Gradient { + GradientStop { id: gradient1; position: 0.0 } + GradientStop { id: gradient2; position: 1.0 } + } + + } + Text { + anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } + color: "white" + font.bold: true + text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' + } +} diff --git a/examples/quick/customitems/progressbar/content/background.png b/examples/quick/customitems/progressbar/content/background.png new file mode 100644 index 0000000000..9044226f85 Binary files /dev/null and b/examples/quick/customitems/progressbar/content/background.png differ diff --git a/examples/quick/customitems/progressbar/main.qml b/examples/quick/customitems/progressbar/main.qml new file mode 100644 index 0000000000..367e4c1265 --- /dev/null +++ b/examples/quick/customitems/progressbar/main.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: main + + width: 600; height: 405 + color: "#edecec" + + Flickable { + anchors.fill: parent + contentHeight: column.height + 20 + + Column { + id: column + x: 10; y: 10 + spacing: 10 + + Repeater { + model: 25 + + ProgressBar { + property int r: Math.floor(Math.random() * 5000 + 1000) + width: main.width - 20 + + NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } + ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } + ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } + } + } + } + } +} diff --git a/examples/quick/customitems/scrollbar/ScrollBar.qml b/examples/quick/customitems/scrollbar/ScrollBar.qml new file mode 100644 index 0000000000..a3d0d3841c --- /dev/null +++ b/examples/quick/customitems/scrollbar/ScrollBar.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: scrollBar + + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + // orientation can be either Qt.Vertical or Qt.Horizontal + property real position + property real pageSize + property variant orientation : Qt.Vertical + + // A light, semi-transparent background + Rectangle { + id: background + anchors.fill: parent + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "white" + opacity: 0.3 + } + + // Size the bar to the required size, depending upon the orientation. + Rectangle { + x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "black" + opacity: 0.7 + } +} diff --git a/examples/quick/customitems/scrollbar/main.qml b/examples/quick/customitems/scrollbar/main.qml new file mode 100644 index 0000000000..a7d602b437 --- /dev/null +++ b/examples/quick/customitems/scrollbar/main.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 640 + height: 480 + + // Create a flickable to view a large image. + Flickable { + id: view + anchors.fill: parent + contentWidth: picture.width + contentHeight: picture.height + + Image { + id: picture + source: "pics/niagara_falls.jpg" + asynchronous: true + } + + // Only show the scrollbars when the view is moving. + states: State { + name: "ShowBars" + when: view.movingVertically || view.movingHorizontally + PropertyChanges { target: verticalScrollBar; opacity: 1 } + PropertyChanges { target: horizontalScrollBar; opacity: 1 } + } + + transitions: Transition { + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + // Attach scrollbars to the right and bottom edges of the view. + ScrollBar { + id: verticalScrollBar + width: 12; height: view.height-12 + anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + } + + ScrollBar { + id: horizontalScrollBar + width: view.width-12; height: 12 + anchors.bottom: view.bottom + opacity: 0 + orientation: Qt.Horizontal + position: view.visibleArea.xPosition + pageSize: view.visibleArea.widthRatio + } +} diff --git a/examples/quick/customitems/scrollbar/pics/niagara_falls.jpg b/examples/quick/customitems/scrollbar/pics/niagara_falls.jpg new file mode 100644 index 0000000000..e625c0d3e6 Binary files /dev/null and b/examples/quick/customitems/scrollbar/pics/niagara_falls.jpg differ diff --git a/examples/quick/customitems/scrollbar/scrollbar.qmlproject b/examples/quick/customitems/scrollbar/scrollbar.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/quick/customitems/scrollbar/scrollbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/customitems/searchbox/SearchBox.qml b/examples/quick/customitems/searchbox/SearchBox.qml new file mode 100644 index 0000000000..6f6f486412 --- /dev/null +++ b/examples/quick/customitems/searchbox/SearchBox.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id: focusScope + width: 250; height: 28 + + BorderImage { + source: "images/lineedit-bg.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + BorderImage { + source: "images/lineedit-bg-focus.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + visible: parent.activeFocus ? true : false + } + + Text { + id: typeSomething + anchors.fill: parent; anchors.leftMargin: 8 + verticalAlignment: Text.AlignVCenter + text: "Type something..." + color: "gray" + font.italic: true + } + + MouseArea { + anchors.fill: parent + onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } + } + + TextInput { + id: textInput + anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } + focus: true + selectByMouse: true + } + + Image { + id: clear + anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } + source: "images/clear.png" + opacity: 0 + + MouseArea { + anchors.fill: parent + onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } + } + } + + states: State { + name: "hasText"; when: textInput.text != '' + PropertyChanges { target: typeSomething; opacity: 0 } + PropertyChanges { target: clear; opacity: 1 } + } + + transitions: [ + Transition { + from: ""; to: "hasText" + NumberAnimation { exclude: typeSomething; properties: "opacity" } + }, + Transition { + from: "hasText"; to: "" + NumberAnimation { properties: "opacity" } + } + ] +} diff --git a/examples/quick/customitems/searchbox/images/clear.png b/examples/quick/customitems/searchbox/images/clear.png new file mode 100644 index 0000000000..91eb270695 Binary files /dev/null and b/examples/quick/customitems/searchbox/images/clear.png differ diff --git a/examples/quick/customitems/searchbox/images/lineedit-bg-focus.png b/examples/quick/customitems/searchbox/images/lineedit-bg-focus.png new file mode 100644 index 0000000000..bbfac38d2d Binary files /dev/null and b/examples/quick/customitems/searchbox/images/lineedit-bg-focus.png differ diff --git a/examples/quick/customitems/searchbox/images/lineedit-bg.png b/examples/quick/customitems/searchbox/images/lineedit-bg.png new file mode 100644 index 0000000000..9044226f85 Binary files /dev/null and b/examples/quick/customitems/searchbox/images/lineedit-bg.png differ diff --git a/examples/quick/customitems/searchbox/main.qml b/examples/quick/customitems/searchbox/main.qml new file mode 100644 index 0000000000..6e9731cf9c --- /dev/null +++ b/examples/quick/customitems/searchbox/main.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 250 + color: "#edecec" + + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + Column { + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + spacing: 10 + + SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } + SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } + SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } + } +} diff --git a/examples/quick/customitems/searchbox/searchbox.qmlproject b/examples/quick/customitems/searchbox/searchbox.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/quick/customitems/searchbox/searchbox.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/customitems/slideswitch/content/Switch.qml b/examples/quick/customitems/slideswitch/content/Switch.qml new file mode 100644 index 0000000000..981fc16673 --- /dev/null +++ b/examples/quick/customitems/slideswitch/content/Switch.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: toggleswitch + width: background.width; height: background.height + +//![1] + property bool on: false +//![1] + +//![2] + function toggle() { + if (toggleswitch.state == "on") + toggleswitch.state = "off"; + else + toggleswitch.state = "on"; + } +//![2] + +//![3] + function releaseSwitch() { + if (knob.x == 1) { + if (toggleswitch.state == "off") return; + } + if (knob.x == 78) { + if (toggleswitch.state == "on") return; + } + toggle(); + } +//![3] + +//![4] + Image { + id: background + source: "background.png" + MouseArea { anchors.fill: parent; onClicked: toggle() } + } +//![4] + +//![5] + Image { + id: knob + x: 1; y: 2 + source: "knob.png" + + MouseArea { + anchors.fill: parent + drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 + onClicked: toggle() + onReleased: releaseSwitch() + } + } +//![5] + +//![6] + states: [ + State { + name: "on" + PropertyChanges { target: knob; x: 78 } + PropertyChanges { target: toggleswitch; on: true } + }, + State { + name: "off" + PropertyChanges { target: knob; x: 1 } + PropertyChanges { target: toggleswitch; on: false } + } + ] +//![6] + +//![7] + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } + } +//![7] +} +//![0] diff --git a/examples/quick/customitems/slideswitch/content/background.png b/examples/quick/customitems/slideswitch/content/background.png new file mode 100644 index 0000000000..d736815870 Binary files /dev/null and b/examples/quick/customitems/slideswitch/content/background.png differ diff --git a/examples/quick/customitems/slideswitch/content/background.svg b/examples/quick/customitems/slideswitch/content/background.svg new file mode 100644 index 0000000000..f920d3e47a --- /dev/null +++ b/examples/quick/customitems/slideswitch/content/background.svg @@ -0,0 +1,23 @@ + + + +]> + + + + + + + + + + + + + + diff --git a/examples/quick/customitems/slideswitch/content/knob.png b/examples/quick/customitems/slideswitch/content/knob.png new file mode 100644 index 0000000000..ee0a436f84 Binary files /dev/null and b/examples/quick/customitems/slideswitch/content/knob.png differ diff --git a/examples/quick/customitems/slideswitch/content/knob.svg b/examples/quick/customitems/slideswitch/content/knob.svg new file mode 100644 index 0000000000..fb6933718e --- /dev/null +++ b/examples/quick/customitems/slideswitch/content/knob.svg @@ -0,0 +1,867 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/quick/customitems/slideswitch/slideswitch.qml b/examples/quick/customitems/slideswitch/slideswitch.qml new file mode 100644 index 0000000000..60a331407c --- /dev/null +++ b/examples/quick/customitems/slideswitch/slideswitch.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + color: "white" + width: 400; height: 250 + +//![0] + Switch { anchors.centerIn: parent; on: false } +//![0] +} diff --git a/examples/quick/customitems/spinner/content/Spinner.qml b/examples/quick/customitems/spinner/content/Spinner.qml new file mode 100644 index 0000000000..d7bbeb33ee --- /dev/null +++ b/examples/quick/customitems/spinner/content/Spinner.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property alias model: view.model + property alias delegate: view.delegate + property alias currentIndex: view.currentIndex + property real itemHeight: 30 + + source: "spinner-bg.png" + clip: true + + PathView { + id: view + anchors.fill: parent + + pathItemCount: height/itemHeight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } + dragMargin: view.width/2 + + path: Path { + startX: view.width/2; startY: -itemHeight/2 + PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } + } + } + + Keys.onDownPressed: view.incrementCurrentIndex() + Keys.onUpPressed: view.decrementCurrentIndex() +} diff --git a/examples/quick/customitems/spinner/content/spinner-bg.png b/examples/quick/customitems/spinner/content/spinner-bg.png new file mode 100644 index 0000000000..b3556f1f9f Binary files /dev/null and b/examples/quick/customitems/spinner/content/spinner-bg.png differ diff --git a/examples/quick/customitems/spinner/content/spinner-select.png b/examples/quick/customitems/spinner/content/spinner-select.png new file mode 100644 index 0000000000..95a17a1fe2 Binary files /dev/null and b/examples/quick/customitems/spinner/content/spinner-select.png differ diff --git a/examples/quick/customitems/spinner/main.qml b/examples/quick/customitems/spinner/main.qml new file mode 100644 index 0000000000..7584c98396 --- /dev/null +++ b/examples/quick/customitems/spinner/main.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 240; height: 320 + + Column { + y: 20; x: 20; spacing: 20 + + Spinner { + id: spinner + width: 200; height: 240 + focus: true + model: 20 + itemHeight: 30 + delegate: Text { font.pixelSize: 25; text: index; height: 30 } + } + + Text { text: "Current item index: " + spinner.currentIndex } + } +} diff --git a/examples/quick/customitems/spinner/spinner.qmlproject b/examples/quick/customitems/spinner/spinner.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/quick/customitems/spinner/spinner.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/customitems/tabwidget/TabWidget.qml b/examples/quick/customitems/tabwidget/TabWidget.qml new file mode 100644 index 0000000000..560ed1f58a --- /dev/null +++ b/examples/quick/customitems/tabwidget/TabWidget.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: tabWidget + + // Setting the default property to stack.children means any child items + // of the TabWidget are actually added to the 'stack' item's children. + // See the "Property Binding" + // documentation for details on default properties. + default property alias content: stack.children + + property int current: 0 + + onCurrentChanged: setOpacities() + Component.onCompleted: setOpacities() + + function setOpacities() { + for (var i = 0; i < stack.children.length; ++i) { + stack.children[i].opacity = (i == current ? 1 : 0) + } + } + + Row { + id: header + + Repeater { + model: stack.children.length + delegate: Rectangle { + width: tabWidget.width / stack.children.length; height: 36 + + Rectangle { + width: parent.width; height: 1 + anchors { bottom: parent.bottom; bottomMargin: 1 } + color: "#acb2c2" + } + BorderImage { + anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } + border { left: 7; right: 7 } + source: "tab.png" + visible: tabWidget.current == index + } + Text { + horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter + anchors.fill: parent + text: stack.children[index].title + elide: Text.ElideRight + font.bold: tabWidget.current == index + } + MouseArea { + anchors.fill: parent + onClicked: tabWidget.current = index + } + } + } + } + + Item { + id: stack + width: tabWidget.width + anchors.top: header.bottom; anchors.bottom: tabWidget.bottom + } +} diff --git a/examples/quick/customitems/tabwidget/main.qml b/examples/quick/customitems/tabwidget/main.qml new file mode 100644 index 0000000000..df99c11b7d --- /dev/null +++ b/examples/quick/customitems/tabwidget/main.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TabWidget { + id: tabs + width: 640; height: 480 + + Rectangle { + property string title: "Red" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#ff7f7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Roses are red" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Green" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#7fff7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Flower stems are green" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Blue" + anchors.fill: parent; color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#7f7fff" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Violets are blue" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } +} diff --git a/examples/quick/customitems/tabwidget/tab.png b/examples/quick/customitems/tabwidget/tab.png new file mode 100644 index 0000000000..ad8021605f Binary files /dev/null and b/examples/quick/customitems/tabwidget/tab.png differ diff --git a/examples/quick/customitems/tabwidget/tabwidget.qmlproject b/examples/quick/customitems/tabwidget/tabwidget.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/quick/customitems/tabwidget/tabwidget.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/maskedmousearea/images/cloud_1.png b/examples/quick/maskedmousearea/images/cloud_1.png deleted file mode 100644 index 87c54af253..0000000000 Binary files a/examples/quick/maskedmousearea/images/cloud_1.png and /dev/null differ diff --git a/examples/quick/maskedmousearea/images/cloud_2.png b/examples/quick/maskedmousearea/images/cloud_2.png deleted file mode 100644 index 981bbd2630..0000000000 Binary files a/examples/quick/maskedmousearea/images/cloud_2.png and /dev/null differ diff --git a/examples/quick/maskedmousearea/images/moon.png b/examples/quick/maskedmousearea/images/moon.png deleted file mode 100644 index 0a8037dd85..0000000000 Binary files a/examples/quick/maskedmousearea/images/moon.png and /dev/null differ diff --git a/examples/quick/maskedmousearea/main.cpp b/examples/quick/maskedmousearea/main.cpp deleted file mode 100644 index 407497e640..0000000000 --- a/examples/quick/maskedmousearea/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "maskedmousearea.h" - - -int main(int argc, char* argv[]) -{ - QGuiApplication app(argc,argv); - QQuickView view; - - qmlRegisterType("Example", 1, 0, "MaskedMouseArea"); - - view.setSource(QUrl::fromLocalFile("maskedmousearea.qml")); - view.show(); - return app.exec(); -} diff --git a/examples/quick/maskedmousearea/maskedmousearea.cpp b/examples/quick/maskedmousearea/maskedmousearea.cpp deleted file mode 100644 index 3f872a66f6..0000000000 --- a/examples/quick/maskedmousearea/maskedmousearea.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "maskedmousearea.h" - -#include -#include - - -MaskedMouseArea::MaskedMouseArea(QQuickItem *parent) - : QQuickItem(parent), - m_pressed(false), - m_alphaThreshold(0.0), - m_containsMouse(false) -{ - setAcceptHoverEvents(true); - setAcceptedMouseButtons(Qt::LeftButton); -} - -void MaskedMouseArea::setPressed(bool pressed) -{ - if (m_pressed != pressed) { - m_pressed = pressed; - emit pressedChanged(); - } -} - -void MaskedMouseArea::setContainsMouse(bool containsMouse) -{ - if (m_containsMouse != containsMouse) { - m_containsMouse = containsMouse; - emit containsMouseChanged(); - } -} - -void MaskedMouseArea::setMaskSource(const QUrl &source) -{ - if (m_maskSource != source) { - m_maskSource = source; - m_maskImage = QImage(source.toLocalFile()); - emit maskSourceChanged(); - } -} - -void MaskedMouseArea::setAlphaThreshold(qreal threshold) -{ - if (m_alphaThreshold != threshold) { - m_alphaThreshold = threshold; - emit alphaThresholdChanged(); - } -} - -bool MaskedMouseArea::contains(const QPointF &point) const -{ - if (!QQuickItem::contains(point) || m_maskImage.isNull()) - return false; - - QPoint p = point.toPoint(); - - if (p.x() < 0 || p.x() >= m_maskImage.width() || - p.y() < 0 || p.y() >= m_maskImage.height()) - return false; - - qreal r = qBound(0, m_alphaThreshold * 255, 255); - return qAlpha(m_maskImage.pixel(p)) > r; -} - -void MaskedMouseArea::mousePressEvent(QMouseEvent *event) -{ - setPressed(true); - m_pressPoint = event->pos(); - emit pressed(); -} - -void MaskedMouseArea::mouseReleaseEvent(QMouseEvent *event) -{ - setPressed(false); - emit released(); - - const int threshold = qApp->styleHints()->startDragDistance(); - const bool isClick = (threshold >= qAbs(event->x() - m_pressPoint.x()) && - threshold >= qAbs(event->y() - m_pressPoint.y())); - - if (isClick) - emit clicked(); -} - -void MaskedMouseArea::mouseUngrabEvent() -{ - setPressed(false); - emit canceled(); -} - -void MaskedMouseArea::hoverEnterEvent(QHoverEvent *event) -{ - Q_UNUSED(event); - setContainsMouse(true); -} - -void MaskedMouseArea::hoverLeaveEvent(QHoverEvent *event) -{ - Q_UNUSED(event); - setContainsMouse(false); -} diff --git a/examples/quick/maskedmousearea/maskedmousearea.h b/examples/quick/maskedmousearea/maskedmousearea.h deleted file mode 100644 index 045d02d6f0..0000000000 --- a/examples/quick/maskedmousearea/maskedmousearea.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MASKEDMOUSEAREA_H -#define MASKEDMOUSEAREA_H - -#include -#include - - -class MaskedMouseArea : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged) - Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) - Q_PROPERTY(QUrl maskSource READ maskSource WRITE setMaskSource NOTIFY maskSourceChanged) - Q_PROPERTY(qreal alphaThreshold READ alphaThreshold WRITE setAlphaThreshold NOTIFY alphaThresholdChanged) - -public: - MaskedMouseArea(QQuickItem *parent = 0); - - bool contains(const QPointF &point) const; - - bool isPressed() const { return m_pressed; } - bool containsMouse() const { return m_containsMouse; } - - QUrl maskSource() const { return m_maskSource; } - void setMaskSource(const QUrl &source); - - qreal alphaThreshold() const { return m_alphaThreshold; } - void setAlphaThreshold(qreal threshold); - -signals: - void pressed(); - void released(); - void clicked(); - void canceled(); - void pressedChanged(); - void maskSourceChanged(); - void containsMouseChanged(); - void alphaThresholdChanged(); - -protected: - void setPressed(bool pressed); - void setContainsMouse(bool containsMouse); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void hoverEnterEvent(QHoverEvent *event); - void hoverLeaveEvent(QHoverEvent *event); - void mouseUngrabEvent(); - -private: - bool m_pressed; - QUrl m_maskSource; - QImage m_maskImage; - QPointF m_pressPoint; - qreal m_alphaThreshold; - bool m_containsMouse; -}; - -#endif diff --git a/examples/quick/maskedmousearea/maskedmousearea.pro b/examples/quick/maskedmousearea/maskedmousearea.pro deleted file mode 100644 index 1623f7919b..0000000000 --- a/examples/quick/maskedmousearea/maskedmousearea.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = app - -QT += quick qml - -HEADERS += maskedmousearea.h - -SOURCES += main.cpp \ - maskedmousearea.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/maskedmousearea -qml.files = maskedmousearea.qml images -qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/maskedmousearea -INSTALLS += target qml - diff --git a/examples/quick/maskedmousearea/maskedmousearea.qml b/examples/quick/maskedmousearea/maskedmousearea.qml deleted file mode 100644 index 82d351b04f..0000000000 --- a/examples/quick/maskedmousearea/maskedmousearea.qml +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Example 1.0 - -Rectangle { - height: 480 - width: 320 - color: "black" - - Text { - text: qsTr("CLICK AND HOVER") - opacity: 0.6 - color: "white" - font.pixelSize: 20 - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 50 - } - - Image { - id: moon - smooth: true - anchors.centerIn: parent - scale: moonArea.pressed ? 1.1 : 1.0 - opacity: moonArea.containsMouse ? 1.0 : 0.7 - source: Qt.resolvedUrl("images/moon.png") - - MaskedMouseArea { - id: moonArea - anchors.fill: parent - alphaThreshold: 0.4 - maskSource: moon.source - } - - Behavior on opacity { - NumberAnimation { duration: 200 } - } - Behavior on scale { - NumberAnimation { duration: 100 } - } - } - - Image { - id: rightCloud - anchors { - centerIn: moon - verticalCenterOffset: 30 - horizontalCenterOffset: 80 - } - smooth: true - scale: rightCloudArea.pressed ? 1.1 : 1.0 - opacity: rightCloudArea.containsMouse ? 1.0 : 0.7 - source: Qt.resolvedUrl("images/cloud_2.png") - - MaskedMouseArea { - id: rightCloudArea - anchors.fill: parent - alphaThreshold: 0.4 - maskSource: rightCloud.source - } - - Behavior on opacity { - NumberAnimation { duration: 200 } - } - Behavior on scale { - NumberAnimation { duration: 100 } - } - } - - Image { - id: leftCloud - anchors { - centerIn: moon - verticalCenterOffset: 40 - horizontalCenterOffset: -80 - } - smooth: true - scale: leftCloudArea.pressed ? 1.1 : 1.0 - opacity: leftCloudArea.containsMouse ? 1.0 : 0.7 - source: Qt.resolvedUrl("images/cloud_1.png") - - MaskedMouseArea { - id: leftCloudArea - anchors.fill: parent - alphaThreshold: 0.4 - maskSource: leftCloud.source - } - - Behavior on opacity { - NumberAnimation { duration: 200 } - } - Behavior on scale { - NumberAnimation { duration: 100 } - } - } -} diff --git a/examples/quick/maskedmousearea/maskedmousearea.qmlproject b/examples/quick/maskedmousearea/maskedmousearea.qmlproject deleted file mode 100644 index 709c19866f..0000000000 --- a/examples/quick/maskedmousearea/maskedmousearea.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "maskedmousearea.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/quick/openglunderqml/main.cpp b/examples/quick/openglunderqml/main.cpp deleted file mode 100644 index 8d1a91bdb2..0000000000 --- a/examples/quick/openglunderqml/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include - -#include "squircle.h" - -int main(int argc, char **argv) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("OpenGLUnderQML", 2, 0, "Squircle"); - - QQuickView view; - view.setSource(QUrl("main.qml")); - view.show(); - - return app.exec(); - -} diff --git a/examples/quick/openglunderqml/main.qml b/examples/quick/openglunderqml/main.qml deleted file mode 100644 index 66bc08bf03..0000000000 --- a/examples/quick/openglunderqml/main.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import OpenGLUnderQML 2.0 - -Item { - - width: 320 - height: 480 - - Squircle { - width: 320 - height: 320 - SequentialAnimation on t { - NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } - NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } - loops: Animation.Infinite - running: true - } - } - - Rectangle { - color: Qt.rgba(1, 1, 1, 0.8); - radius: 10 - border.width: 1 - border.color: "white" - anchors.fill: label - anchors.margins: -10 - } - - Text { - id: label - color: "black" - wrapMode: Text.WordWrap - text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickWindow. This text label and its border is rendered using QML" - anchors.right: parent.right - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.margins: 20 - } - -} diff --git a/examples/quick/openglunderqml/openglunderqml.pro b/examples/quick/openglunderqml/openglunderqml.pro deleted file mode 100644 index 64a58b3729..0000000000 --- a/examples/quick/openglunderqml/openglunderqml.pro +++ /dev/null @@ -1,6 +0,0 @@ -QT += qml quick - -HEADERS += squircle.h -SOURCES += squircle.cpp main.cpp - -OTHER_FILES += main.qml diff --git a/examples/quick/openglunderqml/squircle.cpp b/examples/quick/openglunderqml/squircle.cpp deleted file mode 100644 index b1340687f9..0000000000 --- a/examples/quick/openglunderqml/squircle.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "squircle.h" - -#include -#include - -Squircle::Squircle() - : m_program(0) -{ - setFlag(ItemHasContents); -} - -void Squircle::itemChange(ItemChange change, const ItemChangeData &) -{ - // The ItemSceneChange event is sent when we are first attached to a window. - if (change == ItemSceneChange) { - QQuickWindow *c = window(); - - // Connect our the beforeRendering signal to our paint function. - // Since this call is executed on the rendering thread it must be - // a Qt::DirectConnection - connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); - - // If we allow QML to do the clearing, they would clear what we paint - // and nothing would show. - c->setClearBeforeRendering(false); - } -} - -void Squircle::paint() -{ - if (!m_program) { - m_program = new QOpenGLShaderProgram(); - m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, - "attribute highp vec4 vertices;" - "varying highp vec2 coords;" - "void main() {" - " gl_Position = vertices;" - " coords = vertices.xy;" - "}"); - m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, - "uniform lowp float t;" - "varying highp vec2 coords;" - "void main() {" - " lowp float i = 1. - (pow(coords.x, 4.) + pow(coords.y, 4.));" - " i = smoothstep(t - 0.3, t + 0.3, i);" - " gl_FragColor = vec4(coords / 2. + .5, i, i);" - "}"); - - m_program->bindAttributeLocation("vertices", 0); - m_program->link(); - } - - m_program->bind(); - - m_program->enableAttributeArray(0); - - float values[] = { - -1, -1, - 1, -1, - -1, 1, - 1, 1 - }; - m_program->setAttributeArray(0, GL_FLOAT, values, 2); - m_program->setUniformValue("t", (float) m_t); - - glViewport(0, 0, window()->width(), window()->height()); - - glDisable(GL_DEPTH_TEST); - - glClearColor(0, 0, 0, 1); - glClear(GL_COLOR_BUFFER_BIT); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - m_program->disableAttributeArray(0); - m_program->release(); -} - - diff --git a/examples/quick/openglunderqml/squircle.h b/examples/quick/openglunderqml/squircle.h deleted file mode 100644 index 9e7a03b75b..0000000000 --- a/examples/quick/openglunderqml/squircle.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SQUIRCLE_H -#define SQUIRCLE_H - -#include -#include - -class Squircle : public QQuickItem -{ - Q_OBJECT - - Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) - -public: - Squircle(); - - qreal t() const { return m_t; } - void setT(qreal t) { m_t = t; emit tChanged(); update(); } - - void itemChange(ItemChange change, const ItemChangeData &); - -signals: - void tChanged(); - -public slots: - void paint(); - -private: - QOpenGLShaderProgram *m_program; - - qreal m_t; - bool m_render_under; - bool m_render_over; -}; - -#endif // SQUIRCLE_H diff --git a/examples/quick/painteditem/painteditem.pro b/examples/quick/painteditem/painteditem.pro deleted file mode 100644 index e3afd6b0f0..0000000000 --- a/examples/quick/painteditem/painteditem.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = \ - smile \ - textballoons diff --git a/examples/quick/painteditem/smile/main.cpp b/examples/quick/painteditem/smile/main.cpp deleted file mode 100644 index 1c7888b10b..0000000000 --- a/examples/quick/painteditem/smile/main.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -class MyPaintItem : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged) -public: - MyPaintItem() - : QQuickPaintedItem() - , m_face(QLatin1String(":-)")) - { - setAntialiasing(true); - } - QString face() const {return m_face;} - void setFace(const QString &face) { - if (m_face != face) { - m_face = face; - emit faceChanged(); - } - } - virtual void paint(QPainter *p) - { - QRectF rect(0, 0, width(), height()); - rect.adjust(10, 10, -10, -10); - p->setPen(QPen(Qt::black, 20)); - p->setBrush(Qt::yellow); - p->drawEllipse(rect); - p->setPen(Qt::black); - p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2))); - p->drawText(rect, Qt::AlignCenter, m_face); - } -signals: - void faceChanged(); -private: - QString m_face; -}; - -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("MyModule", 1, 0, "MyPaintItem"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("smile.qml")); - view.show(); - view.raise(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/quick/painteditem/smile/smile.pro b/examples/quick/painteditem/smile/smile.pro deleted file mode 100644 index b1af4ee0ad..0000000000 --- a/examples/quick/painteditem/smile/smile.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = app -TARGET = painteditem - -QT += qml quick - -macx: CONFIG -= app_bundle - -SOURCES += main.cpp - -CONFIG += console - diff --git a/examples/quick/painteditem/smile/smile.qml b/examples/quick/painteditem/smile/smile.qml deleted file mode 100644 index c30da1b944..0000000000 --- a/examples/quick/painteditem/smile/smile.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import MyModule 1.0 -/*! - \title QtQuick Examples - Painted Smile - \example quick/painteditem/smile - \brief This is a simple example the draws a smile with QPainter -*/ - -Rectangle { - width: 320 - height: 480 - gradient: Gradient { - GradientStop { position: 0.0; color: "#00249a" } - GradientStop { position: 0.7; color: "#ffd94f" } - GradientStop { position: 1.0; color: "#ffa322" } - } - Grid { - columns: 2 - Repeater { - model: 6 - delegate: MyPaintItem { - renderTarget:PaintedItem.Image - clip:true - width:160 - height:160 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } - } - } -} diff --git a/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h deleted file mode 100644 index a039339ba4..0000000000 --- a/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "../textballoon.h" - -class TextBalloonPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") -public: - void registerTypes(const char *uri) - { - qmlRegisterType(uri, 1, 0, "TextBalloon"); - } -}; diff --git a/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir deleted file mode 100644 index e8a08ae9d3..0000000000 --- a/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmltextballoonplugin diff --git a/examples/quick/painteditem/textballoons/textballoon.cpp b/examples/quick/painteditem/textballoons/textballoon.cpp deleted file mode 100644 index d097adfe1b..0000000000 --- a/examples/quick/painteditem/textballoons/textballoon.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "textballoon.h" - -//! [0] -TextBalloon::TextBalloon(QQuickItem *parent) - : QQuickPaintedItem(parent) - , rightAligned(false) -{ -} -//! [0] - -//! [1] -void TextBalloon::paint(QPainter *painter) -{ - QBrush brush(QColor("#007430")); - - painter->setBrush(brush); - painter->setPen(Qt::NoPen); - painter->setRenderHint(QPainter::Antialiasing); - - painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10); - - if (rightAligned) - { - const QPointF points[3] = { - QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0), - QPointF(boundingRect().width() - 20.0, boundingRect().height()), - QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0), - }; - painter->drawConvexPolygon(points, 3); - } - else - { - const QPointF points[3] = { - QPointF(10.0, boundingRect().height() - 10.0), - QPointF(20.0, boundingRect().height()), - QPointF(30.0, boundingRect().height() - 10.0), - }; - painter->drawConvexPolygon(points, 3); - } -} -//! [1] - -bool TextBalloon::isRightAligned() -{ - return this->rightAligned; -} - -void TextBalloon::setRightAligned(bool rightAligned) -{ - this->rightAligned = rightAligned; -} diff --git a/examples/quick/painteditem/textballoons/textballoon.h b/examples/quick/painteditem/textballoons/textballoon.h deleted file mode 100644 index 93ed0a7105..0000000000 --- a/examples/quick/painteditem/textballoons/textballoon.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEXTBALLOON_H -#define TEXTBALLOON_H - -#include - -//! [0] -class TextBalloon : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) - - public: - TextBalloon(QQuickItem *parent = 0); - void paint(QPainter *painter); - - bool isRightAligned(); - void setRightAligned(bool rightAligned); - - private: - bool rightAligned; - - signals: - void rightAlignedChanged(); -}; -//! [0] - -#endif diff --git a/examples/quick/painteditem/textballoons/textballoons.pro b/examples/quick/painteditem/textballoons/textballoons.pro deleted file mode 100644 index d612048ee8..0000000000 --- a/examples/quick/painteditem/textballoons/textballoons.pro +++ /dev/null @@ -1,25 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += qml quick - -TARGET = qmltextballoonplugin - -HEADERS += TextBalloonPlugin/plugin.h \ - textballoon.h - -SOURCES += textballoon.cpp - -OTHER_FILES += textballoon.json - -DESTDIR = TextBalloonPlugin - -qdeclarativesources.files += \ - TextBalloonPlugin/qmldir - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin - -sources.files = textballoons.qml -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin - -INSTALLS = qdeclarativesources sources target diff --git a/examples/quick/painteditem/textballoons/textballoons.qml b/examples/quick/painteditem/textballoons/textballoons.qml deleted file mode 100644 index d5151c9553..0000000000 --- a/examples/quick/painteditem/textballoons/textballoons.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import TextBalloonPlugin 1.0 - -/*! - \title QtQuick Examples - Painted Text Balloons - \example quick/painteditem/textballoons - \brief This is a simple example that draws text balloons using QPainter -*/ -Item { - height: 480 - width: 320 - - //! [0] - ListModel { - id: balloonModel - ListElement { - balloonWidth: 200 - } - ListElement { - balloonWidth: 120 - } - } - - ListView { - anchors.bottom: controls.top - anchors.bottomMargin: 2 - anchors.top: parent.top - id: balloonView - delegate: TextBalloon { - anchors.right: index % 2 == 0 ? undefined : parent.right - height: 60 - rightAligned: index % 2 == 0 ? false : true - width: balloonWidth - } - model: balloonModel - spacing: 5 - width: parent.width - } - //! [0] - - //! [1] - Rectangle { - id: controls - - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.margins: 1 - anchors.right: parent.right - border.width: 2 - color: "white" - height: parent.height * 0.15 - - Text { - anchors.centerIn: parent - text: "Add another balloon" - } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onClicked: { - balloonModel.append({"balloonWidth": Math.floor(Math.random() * 200 + 100)}) - balloonView.positionViewAtIndex(balloonView.count -1, ListView.End) - } - onEntered: { - parent.color = "#8ac953" - } - onExited: { - parent.color = "white" - } - } - } - //! [1] -} diff --git a/examples/quick/quick.pro b/examples/quick/quick.pro index 8357e8e389..809ddea552 100644 --- a/examples/quick/quick.pro +++ b/examples/quick/quick.pro @@ -7,11 +7,10 @@ SUBDIRS = accessibility \ keyinteraction \ modelviews \ mousearea \ - openglunderqml \ - painteditem \ positioners \ righttoleft \ shadereffects \ text \ threading \ - touchinteraction + touchinteraction \ + customitems diff --git a/examples/tutorials/ui-components/dialcontrol/content/Dial.qml b/examples/tutorials/ui-components/dialcontrol/content/Dial.qml deleted file mode 100644 index c61adee364..0000000000 --- a/examples/tutorials/ui-components/dialcontrol/content/Dial.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property real value : 0 - - width: 210; height: 210 - - Image { source: "background.png" } - -//! [needle_shadow] - Image { - x: 96 - y: 35 - source: "needle_shadow.png" - transform: Rotation { - origin.x: 9; origin.y: 67 - angle: needleRotation.angle - } - } -//! [needle_shadow] -//! [needle] - Image { - id: needle - x: 98; y: 33 - smooth: true - source: "needle.png" - transform: Rotation { - id: needleRotation - origin.x: 5; origin.y: 65 - //! [needle angle] - angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) - Behavior on angle { - SpringAnimation { - spring: 1.4 - damping: .15 - } - } - //! [needle angle] - } - } -//! [needle] -//! [overlay] - Image { x: 21; y: 18; source: "overlay.png" } -//! [overlay] -} diff --git a/examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml b/examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml deleted file mode 100644 index 702b892d23..0000000000 --- a/examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/tutorials/ui-components/dialcontrol/content/background.png b/examples/tutorials/ui-components/dialcontrol/content/background.png deleted file mode 100644 index 75d555d7ab..0000000000 Binary files a/examples/tutorials/ui-components/dialcontrol/content/background.png and /dev/null differ diff --git a/examples/tutorials/ui-components/dialcontrol/content/needle.png b/examples/tutorials/ui-components/dialcontrol/content/needle.png deleted file mode 100644 index 2d19f75039..0000000000 Binary files a/examples/tutorials/ui-components/dialcontrol/content/needle.png and /dev/null differ diff --git a/examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png b/examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png deleted file mode 100644 index 8d8a928cc5..0000000000 Binary files a/examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png and /dev/null differ diff --git a/examples/tutorials/ui-components/dialcontrol/content/overlay.png b/examples/tutorials/ui-components/dialcontrol/content/overlay.png deleted file mode 100644 index 3860a7b590..0000000000 Binary files a/examples/tutorials/ui-components/dialcontrol/content/overlay.png and /dev/null differ diff --git a/examples/tutorials/ui-components/dialcontrol/content/quit.png b/examples/tutorials/ui-components/dialcontrol/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/tutorials/ui-components/dialcontrol/content/quit.png and /dev/null differ diff --git a/examples/tutorials/ui-components/dialcontrol/dialcontrol.qml b/examples/tutorials/ui-components/dialcontrol/dialcontrol.qml deleted file mode 100644 index 467a558696..0000000000 --- a/examples/tutorials/ui-components/dialcontrol/dialcontrol.qml +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 2.0 -import "content" -//! [imports] - -//! [0] -Rectangle { - color: "#545454" - width: 300; height: 300 - - //! [the dial in use] - // Dial with a slider to adjust it - Dial { - id: dial - anchors.centerIn: parent - value: slider.x * 100 / (container.width - 34) - } - //! [the dial in use] - - Rectangle { - id: container - anchors { bottom: parent.bottom; left: parent.left - right: parent.right; leftMargin: 20; rightMargin: 20 - bottomMargin: 10 - } - height: 16 - - radius: 8 - opacity: 0.7 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "gray" } - GradientStop { position: 1.0; color: "white" } - } - - Rectangle { - id: slider - x: 1; y: 1; width: 30; height: 14 - radius: 6 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#424242" } - GradientStop { position: 1.0; color: "black" } - } - - MouseArea { - anchors.fill: parent - anchors.margins: -16 // Increase mouse area a lot outside the slider - drag.target: parent; drag.axis: Drag.XAxis - drag.minimumX: 2; drag.maximumX: container.width - 32 - } - } - } - QuitButton { - anchors.right: parent.right - anchors.top: parent.top - anchors.margins: 10 - } -} -//! [0] diff --git a/examples/tutorials/ui-components/flipable/content/5_heart.png b/examples/tutorials/ui-components/flipable/content/5_heart.png deleted file mode 100644 index fb59d81453..0000000000 Binary files a/examples/tutorials/ui-components/flipable/content/5_heart.png and /dev/null differ diff --git a/examples/tutorials/ui-components/flipable/content/9_club.png b/examples/tutorials/ui-components/flipable/content/9_club.png deleted file mode 100644 index 2545001904..0000000000 Binary files a/examples/tutorials/ui-components/flipable/content/9_club.png and /dev/null differ diff --git a/examples/tutorials/ui-components/flipable/content/Card.qml b/examples/tutorials/ui-components/flipable/content/Card.qml deleted file mode 100644 index 6006ea14fc..0000000000 --- a/examples/tutorials/ui-components/flipable/content/Card.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Flipable { - id: container - - property alias source: frontImage.source - property bool flipped: true - property int xAxis: 0 - property int yAxis: 0 - property int angle: 0 - - width: front.width; height: front.height - - front: Image { id: frontImage; smooth: true } - back: Image { source: "back.png"; smooth: true } - - state: "back" - - MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } - - transform: Rotation { - id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 - axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 - } - - states: State { - name: "back"; when: container.flipped - PropertyChanges { target: rotation; angle: container.angle } - } - - transitions: Transition { - ParallelAnimation { - NumberAnimation { target: rotation; properties: "angle"; duration: 600 } - SequentialAnimation { - NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } - NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } - } - } - } -} diff --git a/examples/tutorials/ui-components/flipable/content/back.png b/examples/tutorials/ui-components/flipable/content/back.png deleted file mode 100644 index f715d7487e..0000000000 Binary files a/examples/tutorials/ui-components/flipable/content/back.png and /dev/null differ diff --git a/examples/tutorials/ui-components/flipable/flipable.qml b/examples/tutorials/ui-components/flipable/flipable.qml deleted file mode 100644 index 4af64afc53..0000000000 --- a/examples/tutorials/ui-components/flipable/flipable.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "darkgreen" - - Row { - anchors.centerIn: parent; spacing: 30 - Card { source: "content/9_club.png"; angle: 180; yAxis: 1 } - Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 } - } -} diff --git a/examples/tutorials/ui-components/progressbar/content/ProgressBar.qml b/examples/tutorials/ui-components/progressbar/content/ProgressBar.qml deleted file mode 100644 index c9be8d7336..0000000000 --- a/examples/tutorials/ui-components/progressbar/content/ProgressBar.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: progressbar - - property int minimum: 0 - property int maximum: 100 - property int value: 0 - property alias color: gradient1.color - property alias secondColor: gradient2.color - - width: 250; height: 23 - clip: true - - BorderImage { - source: "background.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - Rectangle { - id: highlight - - property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) - - width: highlight.widthDest - Behavior on width { SmoothedAnimation { velocity: 1200 } } - - anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 } - radius: 1 - gradient: Gradient { - GradientStop { id: gradient1; position: 0.0 } - GradientStop { id: gradient2; position: 1.0 } - } - - } - Text { - anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } - color: "white" - font.bold: true - text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' - } -} diff --git a/examples/tutorials/ui-components/progressbar/content/background.png b/examples/tutorials/ui-components/progressbar/content/background.png deleted file mode 100644 index 9044226f85..0000000000 Binary files a/examples/tutorials/ui-components/progressbar/content/background.png and /dev/null differ diff --git a/examples/tutorials/ui-components/progressbar/main.qml b/examples/tutorials/ui-components/progressbar/main.qml deleted file mode 100644 index 367e4c1265..0000000000 --- a/examples/tutorials/ui-components/progressbar/main.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: main - - width: 600; height: 405 - color: "#edecec" - - Flickable { - anchors.fill: parent - contentHeight: column.height + 20 - - Column { - id: column - x: 10; y: 10 - spacing: 10 - - Repeater { - model: 25 - - ProgressBar { - property int r: Math.floor(Math.random() * 5000 + 1000) - width: main.width - 20 - - NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } - ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } - ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } - } - } - } - } -} diff --git a/examples/tutorials/ui-components/scrollbar/ScrollBar.qml b/examples/tutorials/ui-components/scrollbar/ScrollBar.qml deleted file mode 100644 index a3d0d3841c..0000000000 --- a/examples/tutorials/ui-components/scrollbar/ScrollBar.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: scrollBar - - // The properties that define the scrollbar's state. - // position and pageSize are in the range 0.0 - 1.0. They are relative to the - // height of the page, i.e. a pageSize of 0.5 means that you can see 50% - // of the height of the view. - // orientation can be either Qt.Vertical or Qt.Horizontal - property real position - property real pageSize - property variant orientation : Qt.Vertical - - // A light, semi-transparent background - Rectangle { - id: background - anchors.fill: parent - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "white" - opacity: 0.3 - } - - // Size the bar to the required size, depending upon the orientation. - Rectangle { - x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "black" - opacity: 0.7 - } -} diff --git a/examples/tutorials/ui-components/scrollbar/main.qml b/examples/tutorials/ui-components/scrollbar/main.qml deleted file mode 100644 index a7d602b437..0000000000 --- a/examples/tutorials/ui-components/scrollbar/main.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 640 - height: 480 - - // Create a flickable to view a large image. - Flickable { - id: view - anchors.fill: parent - contentWidth: picture.width - contentHeight: picture.height - - Image { - id: picture - source: "pics/niagara_falls.jpg" - asynchronous: true - } - - // Only show the scrollbars when the view is moving. - states: State { - name: "ShowBars" - when: view.movingVertically || view.movingHorizontally - PropertyChanges { target: verticalScrollBar; opacity: 1 } - PropertyChanges { target: horizontalScrollBar; opacity: 1 } - } - - transitions: Transition { - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - // Attach scrollbars to the right and bottom edges of the view. - ScrollBar { - id: verticalScrollBar - width: 12; height: view.height-12 - anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - } - - ScrollBar { - id: horizontalScrollBar - width: view.width-12; height: 12 - anchors.bottom: view.bottom - opacity: 0 - orientation: Qt.Horizontal - position: view.visibleArea.xPosition - pageSize: view.visibleArea.widthRatio - } -} diff --git a/examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg deleted file mode 100644 index e625c0d3e6..0000000000 Binary files a/examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg and /dev/null differ diff --git a/examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject b/examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/tutorials/ui-components/searchbox/SearchBox.qml b/examples/tutorials/ui-components/searchbox/SearchBox.qml deleted file mode 100644 index 6f6f486412..0000000000 --- a/examples/tutorials/ui-components/searchbox/SearchBox.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id: focusScope - width: 250; height: 28 - - BorderImage { - source: "images/lineedit-bg.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - BorderImage { - source: "images/lineedit-bg-focus.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - visible: parent.activeFocus ? true : false - } - - Text { - id: typeSomething - anchors.fill: parent; anchors.leftMargin: 8 - verticalAlignment: Text.AlignVCenter - text: "Type something..." - color: "gray" - font.italic: true - } - - MouseArea { - anchors.fill: parent - onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } - } - - TextInput { - id: textInput - anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } - focus: true - selectByMouse: true - } - - Image { - id: clear - anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } - source: "images/clear.png" - opacity: 0 - - MouseArea { - anchors.fill: parent - onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } - } - } - - states: State { - name: "hasText"; when: textInput.text != '' - PropertyChanges { target: typeSomething; opacity: 0 } - PropertyChanges { target: clear; opacity: 1 } - } - - transitions: [ - Transition { - from: ""; to: "hasText" - NumberAnimation { exclude: typeSomething; properties: "opacity" } - }, - Transition { - from: "hasText"; to: "" - NumberAnimation { properties: "opacity" } - } - ] -} diff --git a/examples/tutorials/ui-components/searchbox/images/clear.png b/examples/tutorials/ui-components/searchbox/images/clear.png deleted file mode 100644 index 91eb270695..0000000000 Binary files a/examples/tutorials/ui-components/searchbox/images/clear.png and /dev/null differ diff --git a/examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png deleted file mode 100644 index bbfac38d2d..0000000000 Binary files a/examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png and /dev/null differ diff --git a/examples/tutorials/ui-components/searchbox/images/lineedit-bg.png b/examples/tutorials/ui-components/searchbox/images/lineedit-bg.png deleted file mode 100644 index 9044226f85..0000000000 Binary files a/examples/tutorials/ui-components/searchbox/images/lineedit-bg.png and /dev/null differ diff --git a/examples/tutorials/ui-components/searchbox/main.qml b/examples/tutorials/ui-components/searchbox/main.qml deleted file mode 100644 index 6e9731cf9c..0000000000 --- a/examples/tutorials/ui-components/searchbox/main.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - width: 500; height: 250 - color: "#edecec" - - MouseArea { - anchors.fill: parent - onClicked: page.focus = false; - } - Column { - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } - spacing: 10 - - SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } - SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } - SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } - } -} diff --git a/examples/tutorials/ui-components/searchbox/searchbox.qmlproject b/examples/tutorials/ui-components/searchbox/searchbox.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/tutorials/ui-components/searchbox/searchbox.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/tutorials/ui-components/slideswitch/content/Switch.qml b/examples/tutorials/ui-components/slideswitch/content/Switch.qml deleted file mode 100644 index 981fc16673..0000000000 --- a/examples/tutorials/ui-components/slideswitch/content/Switch.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - id: toggleswitch - width: background.width; height: background.height - -//![1] - property bool on: false -//![1] - -//![2] - function toggle() { - if (toggleswitch.state == "on") - toggleswitch.state = "off"; - else - toggleswitch.state = "on"; - } -//![2] - -//![3] - function releaseSwitch() { - if (knob.x == 1) { - if (toggleswitch.state == "off") return; - } - if (knob.x == 78) { - if (toggleswitch.state == "on") return; - } - toggle(); - } -//![3] - -//![4] - Image { - id: background - source: "background.png" - MouseArea { anchors.fill: parent; onClicked: toggle() } - } -//![4] - -//![5] - Image { - id: knob - x: 1; y: 2 - source: "knob.png" - - MouseArea { - anchors.fill: parent - drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 - onClicked: toggle() - onReleased: releaseSwitch() - } - } -//![5] - -//![6] - states: [ - State { - name: "on" - PropertyChanges { target: knob; x: 78 } - PropertyChanges { target: toggleswitch; on: true } - }, - State { - name: "off" - PropertyChanges { target: knob; x: 1 } - PropertyChanges { target: toggleswitch; on: false } - } - ] -//![6] - -//![7] - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } - } -//![7] -} -//![0] diff --git a/examples/tutorials/ui-components/slideswitch/content/background.png b/examples/tutorials/ui-components/slideswitch/content/background.png deleted file mode 100644 index d736815870..0000000000 Binary files a/examples/tutorials/ui-components/slideswitch/content/background.png and /dev/null differ diff --git a/examples/tutorials/ui-components/slideswitch/content/background.svg b/examples/tutorials/ui-components/slideswitch/content/background.svg deleted file mode 100644 index f920d3e47a..0000000000 --- a/examples/tutorials/ui-components/slideswitch/content/background.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - -]> - - - - - - - - - - - - - - diff --git a/examples/tutorials/ui-components/slideswitch/content/knob.png b/examples/tutorials/ui-components/slideswitch/content/knob.png deleted file mode 100644 index ee0a436f84..0000000000 Binary files a/examples/tutorials/ui-components/slideswitch/content/knob.png and /dev/null differ diff --git a/examples/tutorials/ui-components/slideswitch/content/knob.svg b/examples/tutorials/ui-components/slideswitch/content/knob.svg deleted file mode 100644 index fb6933718e..0000000000 --- a/examples/tutorials/ui-components/slideswitch/content/knob.svg +++ /dev/null @@ -1,867 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/tutorials/ui-components/slideswitch/slideswitch.qml b/examples/tutorials/ui-components/slideswitch/slideswitch.qml deleted file mode 100644 index 60a331407c..0000000000 --- a/examples/tutorials/ui-components/slideswitch/slideswitch.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - color: "white" - width: 400; height: 250 - -//![0] - Switch { anchors.centerIn: parent; on: false } -//![0] -} diff --git a/examples/tutorials/ui-components/spinner/content/Spinner.qml b/examples/tutorials/ui-components/spinner/content/Spinner.qml deleted file mode 100644 index d7bbeb33ee..0000000000 --- a/examples/tutorials/ui-components/spinner/content/Spinner.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - property alias model: view.model - property alias delegate: view.delegate - property alias currentIndex: view.currentIndex - property real itemHeight: 30 - - source: "spinner-bg.png" - clip: true - - PathView { - id: view - anchors.fill: parent - - pathItemCount: height/itemHeight - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } - dragMargin: view.width/2 - - path: Path { - startX: view.width/2; startY: -itemHeight/2 - PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } - } - } - - Keys.onDownPressed: view.incrementCurrentIndex() - Keys.onUpPressed: view.decrementCurrentIndex() -} diff --git a/examples/tutorials/ui-components/spinner/content/spinner-bg.png b/examples/tutorials/ui-components/spinner/content/spinner-bg.png deleted file mode 100644 index b3556f1f9f..0000000000 Binary files a/examples/tutorials/ui-components/spinner/content/spinner-bg.png and /dev/null differ diff --git a/examples/tutorials/ui-components/spinner/content/spinner-select.png b/examples/tutorials/ui-components/spinner/content/spinner-select.png deleted file mode 100644 index 95a17a1fe2..0000000000 Binary files a/examples/tutorials/ui-components/spinner/content/spinner-select.png and /dev/null differ diff --git a/examples/tutorials/ui-components/spinner/main.qml b/examples/tutorials/ui-components/spinner/main.qml deleted file mode 100644 index 7584c98396..0000000000 --- a/examples/tutorials/ui-components/spinner/main.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 240; height: 320 - - Column { - y: 20; x: 20; spacing: 20 - - Spinner { - id: spinner - width: 200; height: 240 - focus: true - model: 20 - itemHeight: 30 - delegate: Text { font.pixelSize: 25; text: index; height: 30 } - } - - Text { text: "Current item index: " + spinner.currentIndex } - } -} diff --git a/examples/tutorials/ui-components/spinner/spinner.qmlproject b/examples/tutorials/ui-components/spinner/spinner.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/tutorials/ui-components/spinner/spinner.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/tutorials/ui-components/tabwidget/TabWidget.qml b/examples/tutorials/ui-components/tabwidget/TabWidget.qml deleted file mode 100644 index 560ed1f58a..0000000000 --- a/examples/tutorials/ui-components/tabwidget/TabWidget.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: tabWidget - - // Setting the default property to stack.children means any child items - // of the TabWidget are actually added to the 'stack' item's children. - // See the "Property Binding" - // documentation for details on default properties. - default property alias content: stack.children - - property int current: 0 - - onCurrentChanged: setOpacities() - Component.onCompleted: setOpacities() - - function setOpacities() { - for (var i = 0; i < stack.children.length; ++i) { - stack.children[i].opacity = (i == current ? 1 : 0) - } - } - - Row { - id: header - - Repeater { - model: stack.children.length - delegate: Rectangle { - width: tabWidget.width / stack.children.length; height: 36 - - Rectangle { - width: parent.width; height: 1 - anchors { bottom: parent.bottom; bottomMargin: 1 } - color: "#acb2c2" - } - BorderImage { - anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } - border { left: 7; right: 7 } - source: "tab.png" - visible: tabWidget.current == index - } - Text { - horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter - anchors.fill: parent - text: stack.children[index].title - elide: Text.ElideRight - font.bold: tabWidget.current == index - } - MouseArea { - anchors.fill: parent - onClicked: tabWidget.current = index - } - } - } - } - - Item { - id: stack - width: tabWidget.width - anchors.top: header.bottom; anchors.bottom: tabWidget.bottom - } -} diff --git a/examples/tutorials/ui-components/tabwidget/main.qml b/examples/tutorials/ui-components/tabwidget/main.qml deleted file mode 100644 index df99c11b7d..0000000000 --- a/examples/tutorials/ui-components/tabwidget/main.qml +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -TabWidget { - id: tabs - width: 640; height: 480 - - Rectangle { - property string title: "Red" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#ff7f7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Roses are red" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Green" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#7fff7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Flower stems are green" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Blue" - anchors.fill: parent; color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#7f7fff" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Violets are blue" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } -} diff --git a/examples/tutorials/ui-components/tabwidget/tab.png b/examples/tutorials/ui-components/tabwidget/tab.png deleted file mode 100644 index ad8021605f..0000000000 Binary files a/examples/tutorials/ui-components/tabwidget/tab.png and /dev/null differ diff --git a/examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject b/examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/window/Window.qml b/examples/window/Window.qml deleted file mode 100644 index 48478458c6..0000000000 --- a/examples/window/Window.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Window.Window { - width: 640 - height: 480 - visible: true //It's false by default - property Component self - Component.onCompleted: self = Qt.createComponent("Window.qml") - Text{ - text: "Hello World!" - anchors.centerIn: parent - } - MouseArea{ - anchors.fill: parent - onClicked: self.createObject(); - } -} diff --git a/examples/window/standalone.qml b/examples/window/standalone.qml deleted file mode 100644 index 335cf7b635..0000000000 --- a/examples/window/standalone.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Item { - width: 640 - height: 480 - Text { - anchors.centerIn: parent - text: "First Window" - } - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - Window.Window { - width: 640 - height: 480 - x: 640 - y: 480 - visible: true - color: "green" - Text { - anchors.centerIn: parent - text: "Second Window" - } - MouseArea{ - anchors.fill: parent - onClicked: Qt.quit() - } - } -} diff --git a/examples/window/window.cpp b/examples/window/window.cpp deleted file mode 100644 index 2112ab8f45..0000000000 --- a/examples/window/window.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -int main(int argc, char* argv[]) -{ - QGuiApplication app(argc, argv); - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(QUrl::fromLocalFile("Window.qml")); - if ( component.isReady() ) - component.create(); - else - qWarning() << component.errorString(); - return app.exec(); -} diff --git a/examples/window/window.pro b/examples/window/window.pro index c4518418f6..b4e3886c87 100644 --- a/examples/window/window.pro +++ b/examples/window/window.pro @@ -1,5 +1,4 @@ -TEMPLATE = app -CONFIG += qt -QT += qml - -SOURCES += window.cpp +TEMPLATE = subdirs +SUBDIRS += \ + #screen \ + window diff --git a/examples/window/window/Window.qml b/examples/window/window/Window.qml new file mode 100644 index 0000000000..48478458c6 --- /dev/null +++ b/examples/window/window/Window.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Window.Window { + width: 640 + height: 480 + visible: true //It's false by default + property Component self + Component.onCompleted: self = Qt.createComponent("Window.qml") + Text{ + text: "Hello World!" + anchors.centerIn: parent + } + MouseArea{ + anchors.fill: parent + onClicked: self.createObject(); + } +} diff --git a/examples/window/window/standalone.qml b/examples/window/window/standalone.qml new file mode 100644 index 0000000000..335cf7b635 --- /dev/null +++ b/examples/window/window/standalone.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Item { + width: 640 + height: 480 + Text { + anchors.centerIn: parent + text: "First Window" + } + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + Window.Window { + width: 640 + height: 480 + x: 640 + y: 480 + visible: true + color: "green" + Text { + anchors.centerIn: parent + text: "Second Window" + } + MouseArea{ + anchors.fill: parent + onClicked: Qt.quit() + } + } +} diff --git a/examples/window/window/window.cpp b/examples/window/window/window.cpp new file mode 100644 index 0000000000..2112ab8f45 --- /dev/null +++ b/examples/window/window/window.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(QUrl::fromLocalFile("Window.qml")); + if ( component.isReady() ) + component.create(); + else + qWarning() << component.errorString(); + return app.exec(); +} diff --git a/examples/window/window/window.pro b/examples/window/window/window.pro new file mode 100644 index 0000000000..c4518418f6 --- /dev/null +++ b/examples/window/window/window.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +CONFIG += qt +QT += qml + +SOURCES += window.cpp -- cgit v1.2.3