aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/tutorials
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/tutorials')
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview1/PetsModel.qml102
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview1/dynamicview.qml90
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview2/PetsModel.qml98
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview2/dynamicview.qml121
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview3/PetsModel.qml98
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml143
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview4/ListSelector.qml120
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview4/PetsModel.qml98
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml219
-rw-r--r--examples/quick/tutorials/extending/chapter1-basics/app.qml60
-rw-r--r--examples/quick/tutorials/extending/chapter1-basics/chapter1-basics.pro5
-rw-r--r--examples/quick/tutorials/extending/chapter1-basics/main.cpp57
-rw-r--r--examples/quick/tutorials/extending/chapter1-basics/piechart.cpp79
-rw-r--r--examples/quick/tutorials/extending/chapter1-basics/piechart.h71
-rw-r--r--examples/quick/tutorials/extending/chapter2-methods/app.qml66
-rw-r--r--examples/quick/tutorials/extending/chapter2-methods/chapter2-methods.pro5
-rw-r--r--examples/quick/tutorials/extending/chapter2-methods/main.cpp57
-rw-r--r--examples/quick/tutorials/extending/chapter2-methods/piechart.cpp84
-rw-r--r--examples/quick/tutorials/extending/chapter2-methods/piechart.h84
-rw-r--r--examples/quick/tutorials/extending/chapter3-bindings/app.qml74
-rw-r--r--examples/quick/tutorials/extending/chapter3-bindings/chapter3-bindings.pro5
-rw-r--r--examples/quick/tutorials/extending/chapter3-bindings/main.cpp57
-rw-r--r--examples/quick/tutorials/extending/chapter3-bindings/piechart.cpp86
-rw-r--r--examples/quick/tutorials/extending/chapter3-bindings/piechart.h84
-rw-r--r--examples/quick/tutorials/extending/chapter4-customPropertyTypes/app.qml60
-rw-r--r--examples/quick/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro7
-rw-r--r--examples/quick/tutorials/extending/chapter4-customPropertyTypes/main.cpp66
-rw-r--r--examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp70
-rw-r--r--examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.h78
-rw-r--r--examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp66
-rw-r--r--examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.h66
-rw-r--r--examples/quick/tutorials/extending/chapter5-listproperties/app.qml70
-rw-r--r--examples/quick/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro7
-rw-r--r--examples/quick/tutorials/extending/chapter5-listproperties/main.cpp58
-rw-r--r--examples/quick/tutorials/extending/chapter5-listproperties/piechart.cpp72
-rw-r--r--examples/quick/tutorials/extending/chapter5-listproperties/piechart.h75
-rw-r--r--examples/quick/tutorials/extending/chapter5-listproperties/pieslice.cpp86
-rw-r--r--examples/quick/tutorials/extending/chapter5-listproperties/pieslice.h76
-rw-r--r--examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir2
-rw-r--r--examples/quick/tutorials/extending/chapter6-plugins/app.qml69
-rw-r--r--examples/quick/tutorials/extending/chapter6-plugins/chapter6-plugins.pro18
-rw-r--r--examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.cpp53
-rw-r--r--examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.h57
-rw-r--r--examples/quick/tutorials/extending/chapter6-plugins/piechart.cpp71
-rw-r--r--examples/quick/tutorials/extending/chapter6-plugins/piechart.h69
-rw-r--r--examples/quick/tutorials/extending/chapter6-plugins/pieslice.cpp86
-rw-r--r--examples/quick/tutorials/extending/chapter6-plugins/pieslice.h74
-rw-r--r--examples/quick/tutorials/extending/extending.pro10
-rw-r--r--examples/quick/tutorials/gettingStartedQml/core/Button.qml108
-rw-r--r--examples/quick/tutorials/gettingStartedQml/core/EditMenu.qml105
-rw-r--r--examples/quick/tutorials/gettingStartedQml/core/FileDialog.qml164
-rw-r--r--examples/quick/tutorials/gettingStartedQml/core/FileMenu.qml233
-rw-r--r--examples/quick/tutorials/gettingStartedQml/core/MenuBar.qml144
-rw-r--r--examples/quick/tutorials/gettingStartedQml/core/TextArea.qml87
-rw-r--r--examples/quick/tutorials/gettingStartedQml/core/qmldir7
-rw-r--r--examples/quick/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp51
-rw-r--r--examples/quick/tutorials/gettingStartedQml/filedialog/dialogPlugin.h57
-rw-r--r--examples/quick/tutorials/gettingStartedQml/filedialog/directory.cpp218
-rw-r--r--examples/quick/tutorials/gettingStartedQml/filedialog/directory.h107
-rw-r--r--examples/quick/tutorials/gettingStartedQml/filedialog/file.cpp60
-rw-r--r--examples/quick/tutorials/gettingStartedQml/filedialog/file.h66
-rw-r--r--examples/quick/tutorials/gettingStartedQml/filedialog/filedialog.pro22
-rw-r--r--examples/quick/tutorials/gettingStartedQml/filedialog/qmldir1
-rw-r--r--examples/quick/tutorials/gettingStartedQml/gettingStartedQml.pro10
-rw-r--r--examples/quick/tutorials/gettingStartedQml/images/arrow.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part0/Button.qml55
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part1/Button.qml97
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part1/EditMenu.qml76
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part1/FileMenu.qml91
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml73
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_button.pngbin0 -> 1670 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_editmenu.pngbin0 -> 6177 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_filemenu.pngbin0 -> 6062 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_simplebutton.pngbin0 -> 1055 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part1/qml-texteditor.qmlproject14
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part2/Button.qml99
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part2/EditMenu.qml77
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part2/FileMenu.qml92
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part2/MenuBar.qml140
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part2/pics/qml-texteditor2_menubar.pngbin0 -> 6079 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part2/qml-texteditor2.qmlproject14
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part3/Button.qml99
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part3/EditMenu.qml77
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part3/FileMenu.qml92
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part3/MenuBar.qml140
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part3/TextArea.qml80
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part3/TextEditor.qml68
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part3/images/arrow.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part3/pics/qml-texteditor3_texteditor.pngbin0 -> 59345 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part3/qml-texteditor3.qmlproject14
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/Button.qml109
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/EditMenu.qml81
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/FileMenu.qml96
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/MenuBar.qml146
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml59
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/TextArea.qml80
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/TextEditor.qml146
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/images/arrow.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/pics/qml-texteditor4_texteditor.pngbin0 -> 63629 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part4/qml-texteditor4.qmlproject14
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/TextEditor.qml127
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/core/Button.qml109
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml110
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml171
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml233
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml145
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml86
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/core/qmldir11
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp57
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h57
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp219
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h108
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp56
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/file.h67
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro17
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/qmldir1
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/images/arrow.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_editmenu.pngbin0 -> 65123 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_filemenu.pngbin0 -> 21367 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_newfile.pngbin0 -> 76693 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/parts/part5/qml-texteditor5.qmlproject14
-rw-r--r--examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_editmenu.pngbin0 -> 65123 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_filemenu.pngbin0 -> 21367 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_newfile.pngbin0 -> 76693 bytes
-rw-r--r--examples/quick/tutorials/gettingStartedQml/texteditor.qml132
-rw-r--r--examples/quick/tutorials/helloworld/Cell.qml72
-rw-r--r--examples/quick/tutorials/helloworld/tutorial1.qml63
-rw-r--r--examples/quick/tutorials/helloworld/tutorial2.qml72
-rw-r--r--examples/quick/tutorials/helloworld/tutorial3.qml91
-rw-r--r--examples/quick/tutorials/samegame/samegame1/Block.qml53
-rw-r--r--examples/quick/tutorials/samegame/samegame1/Button.qml83
-rw-r--r--examples/quick/tutorials/samegame/samegame1/samegame.qml82
-rw-r--r--examples/quick/tutorials/samegame/samegame1/samegame1.qmlproject16
-rw-r--r--examples/quick/tutorials/samegame/samegame2/Block.qml51
-rw-r--r--examples/quick/tutorials/samegame/samegame2/Button.qml81
-rw-r--r--examples/quick/tutorials/samegame/samegame2/samegame.js63
-rw-r--r--examples/quick/tutorials/samegame/samegame2/samegame.qml85
-rw-r--r--examples/quick/tutorials/samegame/samegame2/samegame2.qmlproject16
-rw-r--r--examples/quick/tutorials/samegame/samegame3/Block.qml63
-rw-r--r--examples/quick/tutorials/samegame/samegame3/Button.qml81
-rw-r--r--examples/quick/tutorials/samegame/samegame3/Dialog.qml71
-rw-r--r--examples/quick/tutorials/samegame/samegame3/samegame.js174
-rw-r--r--examples/quick/tutorials/samegame/samegame3/samegame.qml109
-rw-r--r--examples/quick/tutorials/samegame/samegame3/samegame3.qmlproject16
-rw-r--r--examples/quick/tutorials/samegame/samegame4/content/BoomBlock.qml122
-rw-r--r--examples/quick/tutorials/samegame/samegame4/content/Button.qml81
-rw-r--r--examples/quick/tutorials/samegame/samegame4/content/Dialog.qml107
-rwxr-xr-xexamples/quick/tutorials/samegame/samegame4/content/samegame.js226
-rw-r--r--examples/quick/tutorials/samegame/samegame4/highscores/README1
-rwxr-xr-xexamples/quick/tutorials/samegame/samegame4/highscores/score_data.xml2
-rwxr-xr-xexamples/quick/tutorials/samegame/samegame4/highscores/score_style.xsl28
-rwxr-xr-xexamples/quick/tutorials/samegame/samegame4/highscores/scores.php31
-rw-r--r--examples/quick/tutorials/samegame/samegame4/samegame.qml115
-rw-r--r--examples/quick/tutorials/samegame/samegame4/samegame4.qmlproject16
-rw-r--r--examples/quick/tutorials/samegame/shared/pics/background.jpgbin0 -> 36473 bytes
-rw-r--r--examples/quick/tutorials/samegame/shared/pics/blueStar.pngbin0 -> 278 bytes
-rw-r--r--examples/quick/tutorials/samegame/shared/pics/blueStone.pngbin0 -> 3054 bytes
-rw-r--r--examples/quick/tutorials/samegame/shared/pics/greenStar.pngbin0 -> 273 bytes
-rw-r--r--examples/quick/tutorials/samegame/shared/pics/greenStone.pngbin0 -> 2932 bytes
-rw-r--r--examples/quick/tutorials/samegame/shared/pics/redStar.pngbin0 -> 274 bytes
-rw-r--r--examples/quick/tutorials/samegame/shared/pics/redStone.pngbin0 -> 2902 bytes
-rw-r--r--examples/quick/tutorials/samegame/shared/pics/star.pngbin0 -> 262 bytes
-rw-r--r--examples/quick/tutorials/samegame/shared/pics/yellowStone.pngbin0 -> 3056 bytes
-rw-r--r--examples/quick/tutorials/tutorials.pro8
164 files changed, 10697 insertions, 0 deletions
diff --git a/examples/quick/tutorials/dynamicview/dynamicview1/PetsModel.qml b/examples/quick/tutorials/dynamicview/dynamicview1/PetsModel.qml
new file mode 100644
index 0000000000..d0f52e16f2
--- /dev/null
+++ b/examples/quick/tutorials/dynamicview/dynamicview1/PetsModel.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+//![0]
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+//![1]
+}
+//![1]
diff --git a/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview.qml
new file mode 100644
index 0000000000..a3d4af5533
--- /dev/null
+++ b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+//![1]
+ Component {
+ id: dragDelegate
+
+ Rectangle {
+ id: content
+
+ anchors { left: parent.left; right: parent.right }
+ height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+
+ radius: 2
+
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+ }
+ }
+//![1]
+//![2]
+ ListView {
+ id: view
+
+ anchors { fill: parent; margins: 2 }
+
+ model: PetsModel {}
+ delegate: dragDelegate
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+//![2]
+}
+//![0]
diff --git a/examples/quick/tutorials/dynamicview/dynamicview2/PetsModel.qml b/examples/quick/tutorials/dynamicview/dynamicview2/PetsModel.qml
new file mode 100644
index 0000000000..22c7487fe1
--- /dev/null
+++ b/examples/quick/tutorials/dynamicview/dynamicview2/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview.qml
new file mode 100644
index 0000000000..942505265c
--- /dev/null
+++ b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+//![0]
+ Component {
+ id: dragDelegate
+
+//![1]
+ MouseArea {
+ id: dragArea
+
+ property bool held: false
+
+ anchors { left: parent.left; right: parent.right }
+ height: content.height
+
+ drag.target: held ? content : undefined
+ drag.axis: Drag.YAxis
+
+ onPressAndHold: held = true
+ onReleased: held = false
+
+ Rectangle {
+ id: content
+//![1]
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ width: dragArea.width; height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+//![3]
+ color: dragArea.held ? "lightsteelblue" : "white"
+ Behavior on color { ColorAnimation { duration: 100 } }
+//![3]
+ radius: 2
+//![4]
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+//![4]
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+//![2]
+ }
+ }
+//![2]
+ }
+//![0]
+
+ ListView {
+ id: view
+
+ anchors { fill: parent; margins: 2 }
+
+ model: PetsModel {}
+ delegate: dragDelegate
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+}
diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/PetsModel.qml b/examples/quick/tutorials/dynamicview/dynamicview3/PetsModel.qml
new file mode 100644
index 0000000000..22c7487fe1
--- /dev/null
+++ b/examples/quick/tutorials/dynamicview/dynamicview3/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml
new file mode 100644
index 0000000000..5c3da9499c
--- /dev/null
+++ b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//![0]
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+ Component {
+ id: dragDelegate
+
+ MouseArea {
+ id: dragArea
+
+ property bool held: false
+
+ anchors { left: parent.left; right: parent.right }
+ height: content.height
+
+ drag.target: held ? content : undefined
+ drag.axis: Drag.YAxis
+
+ onPressAndHold: held = true
+ onReleased: held = false
+
+ Rectangle {
+ id: content
+//![0]
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ width: dragArea.width; height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+
+ color: dragArea.held ? "lightsteelblue" : "white"
+ Behavior on color { ColorAnimation { duration: 100 } }
+
+ radius: 2
+//![1]
+ Drag.active: dragArea.held
+ Drag.source: dragArea
+ Drag.hotSpot.x: width / 2
+ Drag.hotSpot.y: height / 2
+//![1]
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+//![2]
+ }
+//![3]
+ DropArea {
+ anchors { fill: parent; margins: 10 }
+
+ onEntered: {
+ visualModel.items.move(
+ drag.source.VisualDataModel.itemsIndex,
+ dragArea.VisualDataModel.itemsIndex)
+ }
+ }
+//![3]
+ }
+ }
+//![2]
+//![4]
+ VisualDataModel {
+ id: visualModel
+
+ model: PetsModel {}
+ delegate: dragDelegate
+ }
+
+ ListView {
+ id: view
+
+ anchors { fill: parent; margins: 2 }
+
+ model: visualModel
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+//![4]
+//![5]
+}
+//![5]
diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/ListSelector.qml b/examples/quick/tutorials/dynamicview/dynamicview4/ListSelector.qml
new file mode 100644
index 0000000000..cfc8af216c
--- /dev/null
+++ b/examples/quick/tutorials/dynamicview/dynamicview4/ListSelector.qml
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: selector
+
+ property alias list: view.model
+ property alias selectedIndex: view.currentIndex
+ property alias label: labelText.text
+ property bool expanded
+
+ width: 100; height: labelText.implicitHeight + 26
+
+ Rectangle {
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom; }
+
+ height: labelText.implicitHeight + 4 + (expanded ? 20 * view.count : 20)
+ Behavior on height { NumberAnimation { duration: 300 } }
+
+ radius: 2
+ border.width: 1
+ border.color: "yellow"
+ color: "yellow"
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: selector.expanded = !selector.expanded
+
+ Text {
+ id: labelText
+ anchors { left: parent.left; top: parent.top; margins: 2 }
+ }
+
+ Rectangle {
+ anchors {
+ left: parent.left; top: labelText.bottom;
+ right: parent.right; bottom: parent.bottom;
+ margins: 2
+ leftMargin: 10
+ }
+
+ radius: 2
+ color: "white"
+
+ ListView {
+ id: view
+
+ anchors.fill: parent
+
+ clip: true
+
+ delegate: Text {
+ anchors { left: parent.left; right: parent.right }
+ height: 20
+
+ verticalAlignment: Text.AlignVCenter
+
+ text: modelData
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ view.currentIndex = index
+ selector.expanded = !selector.expanded
+ }
+ }
+ }
+ highlight: Rectangle {
+ anchors { left: parent.left; right: parent.right }
+ height: 20
+ radius: 2
+
+ color: "yellow"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/PetsModel.qml b/examples/quick/tutorials/dynamicview/dynamicview4/PetsModel.qml
new file mode 100644
index 0000000000..22c7487fe1
--- /dev/null
+++ b/examples/quick/tutorials/dynamicview/dynamicview4/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml
new file mode 100644
index 0000000000..83f61a6e2f
--- /dev/null
+++ b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+ Component {
+ id: dragDelegate
+
+ MouseArea {
+ id: dragArea
+
+ property bool held: false
+
+ anchors { left: parent.left; right: parent.right }
+ height: content.height
+
+ enabled: visualModel.sortOrder == visualModel.lessThan.length
+
+ drag.target: held ? content : undefined
+ drag.axis: Drag.YAxis
+
+ onPressAndHold: held = true
+ onReleased: held = false
+
+ Rectangle {
+ id: content
+
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ width: dragArea.width; height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+
+ color: dragArea.held ? "lightsteelblue" : "white"
+ Behavior on color { ColorAnimation { duration: 100 } }
+
+ radius: 2
+
+ Drag.active: dragArea.held
+ Drag.source: dragArea
+ Drag.hotSpot.x: width / 2
+ Drag.hotSpot.y: height / 2
+
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+ }
+
+ DropArea {
+ anchors { fill: parent; margins: 10 }
+
+ onEntered: {
+ visualModel.items.move(
+ drag.source.VisualDataModel.itemsIndex,
+ dragArea.VisualDataModel.itemsIndex)
+ }
+ }
+ }
+ }
+//![0]
+ VisualDataModel {
+ id: visualModel
+//![4]
+ property var lessThan: [
+ function(left, right) { return left.name < right.name },
+ function(left, right) { return left.type < right.type },
+ function(left, right) { return left.age < right.age },
+ function(left, right) {
+ if (left.size == "Small")
+ return true
+ else if (right.size == "Small")
+ return false
+ else if (left.size == "Medium")
+ return true
+ else
+ return false
+ }
+ ]
+//![4]
+//![6]
+
+ property int sortOrder: orderSelector.selectedIndex
+ onSortOrderChanged: items.setGroups(0, items.count, "unsorted")
+
+//![6]
+//![3]
+ function insertPosition(lessThan, item) {
+ var lower = 0
+ var upper = items.count
+ while (lower < upper) {
+ var middle = Math.floor(lower + (upper - lower) / 2)
+ var result = lessThan(item.model, items.get(middle).model);
+ if (result) {
+ upper = middle
+ } else {
+ lower = middle + 1
+ }
+ }
+ return lower
+ }
+
+ function sort(lessThan) {
+ while (unsortedItems.count > 0) {
+ var item = unsortedItems.get(0)
+ var index = insertPosition(lessThan, item)
+
+ item.groups = "items"
+ items.move(item.itemsIndex, index)
+ }
+ }
+//![3]
+
+//![1]
+ items.includeByDefault: false
+//![5]
+ groups: VisualDataGroup {
+ id: unsortedItems
+ name: "unsorted"
+
+ includeByDefault: true
+//![1]
+ onChanged: {
+ if (visualModel.sortOrder == visualModel.lessThan.length)
+ setGroups(0, count, "items")
+ else
+ visualModel.sort(visualModel.lessThan[visualModel.sortOrder])
+ }
+//![2]
+ }
+//![2]
+//![5]
+ model: PetsModel {}
+ delegate: dragDelegate
+ }
+//![0]
+ ListView {
+ id: view
+
+ anchors {
+ left: parent.left; top: parent.top; right: parent.right; bottom: orderSelector.top;
+ margins: 2
+ }
+
+ model: visualModel
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+
+ ListSelector {
+ id: orderSelector
+
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 }
+
+ label: "Sort By"
+ list: [ "Name", "Type", "Age", "Size", "Custom" ]
+ }
+}
diff --git a/examples/quick/tutorials/extending/chapter1-basics/app.qml b/examples/quick/tutorials/extending/chapter1-basics/app.qml
new file mode 100644
index 0000000000..b5aabc9367
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter1-basics/app.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ name: "A simple pie chart"
+ color: "red"
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: aPieChart.name
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/quick/tutorials/extending/chapter1-basics/chapter1-basics.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter1-basics/chapter1-basics.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/quick/tutorials/extending/chapter1-basics/main.cpp b/examples/quick/tutorials/extending/chapter1-basics/main.cpp
new file mode 100644
index 0000000000..89c681185b
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter1-basics/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter1-basics/piechart.cpp b/examples/quick/tutorials/extending/chapter1-basics/piechart.cpp
new file mode 100644
index 0000000000..eabc0a3ffc
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter1-basics/piechart.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include <QPainter>
+
+//![0]
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+//![0]
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+void PieChart::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+//![1]
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+//![1]
+
diff --git a/examples/quick/tutorials/extending/chapter1-basics/piechart.h b/examples/quick/tutorials/extending/chapter1-basics/piechart.h
new file mode 100644
index 0000000000..c86554942f
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter1-basics/piechart.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+//![0]
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+class PieChart : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+public:
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+private:
+ QString m_name;
+ QColor m_color;
+};
+//![0]
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/chapter2-methods/app.qml b/examples/quick/tutorials/extending/chapter2-methods/app.qml
new file mode 100644
index 0000000000..dee65676ab
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter2-methods/app.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ color: "red"
+
+ onChartCleared: console.log("The chart has been cleared")
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: aPieChart.clearChart()
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: "Click anywhere to clear the chart"
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/quick/tutorials/extending/chapter2-methods/chapter2-methods.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter2-methods/chapter2-methods.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/quick/tutorials/extending/chapter2-methods/main.cpp b/examples/quick/tutorials/extending/chapter2-methods/main.cpp
new file mode 100644
index 0000000000..89c681185b
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter2-methods/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter2-methods/piechart.cpp b/examples/quick/tutorials/extending/chapter2-methods/piechart.cpp
new file mode 100644
index 0000000000..27b39d0df2
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter2-methods/piechart.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include <QPainter>
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+void PieChart::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+
+//![0]
+void PieChart::clearChart()
+{
+ setColor(QColor(Qt::transparent));
+ update();
+
+ emit chartCleared();
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter2-methods/piechart.h b/examples/quick/tutorials/extending/chapter2-methods/piechart.h
new file mode 100644
index 0000000000..2655299f1a
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter2-methods/piechart.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieChart : public QQuickPaintedItem
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+//![1]
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+//![2]
+ Q_INVOKABLE void clearChart();
+
+signals:
+ void chartCleared();
+//![2]
+
+private:
+ QString m_name;
+ QColor m_color;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/chapter3-bindings/app.qml b/examples/quick/tutorials/extending/chapter3-bindings/app.qml
new file mode 100644
index 0000000000..1267697ee7
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter3-bindings/app.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 20
+
+ PieChart {
+ id: chartA
+ width: 100; height: 100
+ color: "red"
+ }
+
+ PieChart {
+ id: chartB
+ width: 100; height: 100
+ color: chartA.color
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { chartA.color = "blue" }
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: "Click anywhere to change the chart color"
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/quick/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/quick/tutorials/extending/chapter3-bindings/main.cpp b/examples/quick/tutorials/extending/chapter3-bindings/main.cpp
new file mode 100644
index 0000000000..89c681185b
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter3-bindings/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/quick/tutorials/extending/chapter3-bindings/piechart.cpp
new file mode 100644
index 0000000000..ca7f0d701f
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter3-bindings/piechart.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include <QPainter>
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+//![0]
+void PieChart::setColor(const QColor &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ update(); // repaint with the new color
+ emit colorChanged();
+ }
+}
+//![0]
+
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+
+void PieChart::clearChart()
+{
+ setColor(QColor(Qt::transparent));
+ update();
+}
diff --git a/examples/quick/tutorials/extending/chapter3-bindings/piechart.h b/examples/quick/tutorials/extending/chapter3-bindings/piechart.h
new file mode 100644
index 0000000000..216a6012e9
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter3-bindings/piechart.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QColor>
+#include <QtQuick/QQuickPaintedItem>
+
+//![0]
+class PieChart : public QQuickPaintedItem
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+ Q_INVOKABLE void clearChart();
+
+//![2]
+signals:
+ void colorChanged();
+//![2]
+
+private:
+ QString m_name;
+ QColor m_color;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/app.qml
new file mode 100644
index 0000000000..b96cb554ac
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/app.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: chart
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ pieSlice: PieSlice {
+ anchors.fill: parent
+ color: "red"
+ }
+ }
+
+ Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color)
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
new file mode 100644
index 0000000000..23eb222ea3
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
@@ -0,0 +1,7 @@
+QT += qml quick
+
+HEADERS += piechart.h \
+ pieslice.h
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ main.cpp
diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/main.cpp
new file mode 100644
index 0000000000..367a252bf9
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+//![0]
+int main(int argc, char *argv[])
+{
+//![0]
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+//![1]
+ qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+//![1]
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+
+//![2]
+}
+//![2]
diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
new file mode 100644
index 0000000000..9c907593f7
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+PieSlice *PieChart::pieSlice() const
+{
+ return m_pieSlice;
+}
+
+//![0]
+void PieChart::setPieSlice(PieSlice *pieSlice)
+{
+ m_pieSlice = pieSlice;
+ pieSlice->setParentItem(this);
+}
+//![0]
+
diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.h
new file mode 100644
index 0000000000..0259720091
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+//![0]
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ PieSlice *pieSlice() const;
+ void setPieSlice(PieSlice *pieSlice);
+//![2]
+
+private:
+ QString m_name;
+ PieSlice *m_pieSlice;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
new file mode 100644
index 0000000000..b104e31c65
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+
diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
new file mode 100644
index 0000000000..5dbe3e53cf
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+};
+//![0]
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/app.qml b/examples/quick/tutorials/extending/chapter5-listproperties/app.qml
new file mode 100644
index 0000000000..4acd456131
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter5-listproperties/app.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ slices: [
+ PieSlice {
+ anchors.fill: parent
+ color: "red"
+ fromAngle: 0; angleSpan: 110
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "black"
+ fromAngle: 110; angleSpan: 50
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "blue"
+ fromAngle: 160; angleSpan: 100
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/quick/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
new file mode 100644
index 0000000000..23eb222ea3
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
@@ -0,0 +1,7 @@
+QT += qml quick
+
+HEADERS += piechart.h \
+ pieslice.h
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ main.cpp
diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/main.cpp b/examples/quick/tutorials/extending/chapter5-listproperties/main.cpp
new file mode 100644
index 0000000000..7af7dc8037
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter5-listproperties/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+ qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/quick/tutorials/extending/chapter5-listproperties/piechart.cpp
new file mode 100644
index 0000000000..91e056a0cb
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter5-listproperties/piechart.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+//![0]
+QQmlListProperty<PieSlice> PieChart::slices()
+{
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice);
+}
+
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
+{
+ PieChart *chart = qobject_cast<PieChart *>(list->object);
+ if (chart) {
+ slice->setParentItem(chart);
+ chart->m_slices.append(slice);
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/piechart.h b/examples/quick/tutorials/extending/chapter5-listproperties/piechart.h
new file mode 100644
index 0000000000..1234d07e6a
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter5-listproperties/piechart.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+//![0]
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ QQmlListProperty<PieSlice> slices();
+
+private:
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
+
+ QString m_name;
+ QList<PieSlice *> m_slices;
+};
+//![2]
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.cpp
new file mode 100644
index 0000000000..d2a927c01a
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+int PieSlice::fromAngle() const
+{
+ return m_fromAngle;
+}
+
+void PieSlice::setFromAngle(int angle)
+{
+ m_fromAngle = angle;
+}
+
+int PieSlice::angleSpan() const
+{
+ return m_angleSpan;
+}
+
+void PieSlice::setAngleSpan(int angle)
+{
+ m_angleSpan = angle;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16);
+}
+
diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.h
new file mode 100644
index 0000000000..e1fc76d445
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+//![0]
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ int fromAngle() const;
+ void setFromAngle(int angle);
+
+ int angleSpan() const;
+ void setAngleSpan(int span);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+ int m_fromAngle;
+ int m_angleSpan;
+};
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir b/examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir
new file mode 100644
index 0000000000..d9e8471b3c
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir
@@ -0,0 +1,2 @@
+module Charts
+plugin chartsplugin
diff --git a/examples/quick/tutorials/extending/chapter6-plugins/app.qml b/examples/quick/tutorials/extending/chapter6-plugins/app.qml
new file mode 100644
index 0000000000..19c39c9d2b
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter6-plugins/app.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 Charts 1.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ slices: [
+ PieSlice {
+ anchors.fill: parent
+ color: "red"
+ fromAngle: 0; angleSpan: 110
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "black"
+ fromAngle: 110; angleSpan: 50
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "blue"
+ fromAngle: 160; angleSpan: 100
+ }
+ ]
+ }
+}
+
diff --git a/examples/quick/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/quick/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
new file mode 100644
index 0000000000..c84b6fe7ff
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
@@ -0,0 +1,18 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml quick
+
+DESTDIR = Charts
+TARGET = chartsplugin
+
+OBJECTS_DIR = tmp
+MOC_DIR = tmp
+
+HEADERS += piechart.h \
+ pieslice.h \
+ chartsplugin.h
+
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ chartsplugin.cpp
+
diff --git a/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.cpp
new file mode 100644
index 0000000000..df079f767c
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "chartsplugin.h"
+//![0]
+#include "piechart.h"
+#include "pieslice.h"
+#include <qqml.h>
+
+void ChartsPlugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<PieChart>(uri, 1, 0, "PieChart");
+ qmlRegisterType<PieSlice>(uri, 1, 0, "PieSlice");
+}
+
+//![0]
+
diff --git a/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.h
new file mode 100644
index 0000000000..09a120666b
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef CHARTSPLUGIN_H
+#define CHARTSPLUGIN_H
+
+//![0]
+#include <QQmlExtensionPlugin>
+
+class ChartsPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+ void registerTypes(const char *uri);
+};
+//![0]
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/quick/tutorials/extending/chapter6-plugins/piechart.cpp
new file mode 100644
index 0000000000..5110153acc
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter6-plugins/piechart.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QQmlListProperty<PieSlice> PieChart::slices()
+{
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice);
+}
+
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
+{
+ PieChart *chart = qobject_cast<PieChart *>(list->object);
+ if (chart) {
+ slice->setParentItem(chart);
+ chart->m_slices.append(slice);
+ }
+}
+
diff --git a/examples/quick/tutorials/extending/chapter6-plugins/piechart.h b/examples/quick/tutorials/extending/chapter6-plugins/piechart.h
new file mode 100644
index 0000000000..e292cdbc7a
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter6-plugins/piechart.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+public:
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QQmlListProperty<PieSlice> slices();
+
+private:
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
+
+ QString m_name;
+ QList<PieSlice *> m_slices;
+};
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/quick/tutorials/extending/chapter6-plugins/pieslice.cpp
new file mode 100644
index 0000000000..d2a927c01a
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter6-plugins/pieslice.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+int PieSlice::fromAngle() const
+{
+ return m_fromAngle;
+}
+
+void PieSlice::setFromAngle(int angle)
+{
+ m_fromAngle = angle;
+}
+
+int PieSlice::angleSpan() const
+{
+ return m_angleSpan;
+}
+
+void PieSlice::setAngleSpan(int angle)
+{
+ m_angleSpan = angle;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16);
+}
+
diff --git a/examples/quick/tutorials/extending/chapter6-plugins/pieslice.h b/examples/quick/tutorials/extending/chapter6-plugins/pieslice.h
new file mode 100644
index 0000000000..2ea15302fb
--- /dev/null
+++ b/examples/quick/tutorials/extending/chapter6-plugins/pieslice.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ int fromAngle() const;
+ void setFromAngle(int angle);
+
+ int angleSpan() const;
+ void setAngleSpan(int span);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+ int m_fromAngle;
+ int m_angleSpan;
+};
+
+#endif
+
diff --git a/examples/quick/tutorials/extending/extending.pro b/examples/quick/tutorials/extending/extending.pro
new file mode 100644
index 0000000000..967473fda0
--- /dev/null
+++ b/examples/quick/tutorials/extending/extending.pro
@@ -0,0 +1,10 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ chapter1-basics \
+ chapter2-methods \
+ chapter3-bindings \
+ chapter4-customPropertyTypes \
+ chapter5-listproperties \
+ chapter6-plugins
+
diff --git a/examples/quick/tutorials/gettingStartedQml/core/Button.qml b/examples/quick/tutorials/gettingStartedQml/core/Button.qml
new file mode 100644
index 0000000000..a5afcc0297
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/core/Button.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 {
+ //identifier of the item
+ id: button
+
+ //these properties act as constants, useable outside this QML file
+ property int buttonHeight: 75
+ property int buttonWidth: 150
+
+ //attaches to the Text element's text content
+ property string label
+ property color textColor: buttonLabel.color
+
+ //the color highlight when the mouse hovers on the rectangle
+ property color onHoverColor: "lightsteelblue"
+ property color borderColor: "transparent"
+
+ //buttonColor is set to the button's main color
+ property color buttonColor: "lightblue"
+
+ property real labelSize: 14
+
+ //set appearance properties
+ radius: 6
+ antialiasing: true
+ border { width: 2; color: borderColor }
+ width: buttonWidth; height: buttonHeight
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: parent
+ text: label //bind the text to the parent's text
+ color: "#DCDCCC"
+ font.pointSize: labelSize
+ }
+
+ //buttonClick() is callable and a signal handler, onButtonClick is automatically created
+ signal buttonClick()
+
+ //define the clickable area to be the whole rectangle
+ MouseArea {
+ id: buttonMouseArea
+ anchors.fill: parent //stretch the area to the parent's dimension
+ onClicked: buttonClick()
+
+ //if true, then onEntered and onExited called if mouse hovers in the mouse area
+ //if false, a button must be clicked to detect the mouse hover
+ hoverEnabled: true
+
+ //display a border if the mouse hovers on the button mouse area
+ onEntered: parent.border.color = onHoverColor
+ //remove the border if the mouse exits the button mouse area
+ onExited: parent.border.color = borderColor
+ }
+
+ //change the color of the button when pressed
+ color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
+ //animate the color whenever the color property changes
+ Behavior on color { ColorAnimation{ duration: 55 } }
+
+ //scale the button when pressed
+ scale: buttonMouseArea.pressed ? 1.1 : 1.00
+ //Animate the scale property change
+ Behavior on scale { NumberAnimation{ duration: 55 } }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/core/EditMenu.qml b/examples/quick/tutorials/gettingStartedQml/core/EditMenu.qml
new file mode 100644
index 0000000000..2665442685
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/core/EditMenu.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: editMenu
+ height: 480; width:1000
+ color: "powderblue"
+ property color buttonBorderColor: "#7A8182"
+ property color buttonFillColor: "#61BDCACD"
+ property string menuName:"Edit"
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#6A7570" }
+ GradientStop { position: 1.0; color: Qt.darker("#6A7570") }
+ }
+
+ Rectangle {
+ id:actionContainer
+ color:"transparent"
+ anchors.centerIn: parent
+ width: parent.width; height: parent.height / 5
+ Row {
+ anchors.centerIn: parent
+ spacing: parent.width/9
+ Button {
+ id: loadButton
+ buttonColor: buttonFillColor
+ label: "Copy"
+ labelSize: 16
+ borderColor: buttonBorderColor
+ height: actionContainer.height; width: actionContainer.width/6
+ onButtonClick: textArea.copy()
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ Button {
+ id: saveButton
+ height: actionContainer.height; width: actionContainer.width/6
+ buttonColor: buttonFillColor
+ label: "Paste"
+ borderColor: buttonBorderColor
+ labelSize: 16
+ onButtonClick: textArea.paste()
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ Button {
+ id: exitButton
+ label: "Select All"
+ height: actionContainer.height; width: actionContainer.width/6
+ labelSize: 16
+ buttonColor: buttonFillColor
+ borderColor:buttonBorderColor
+ onButtonClick: textArea.selectAll()
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/core/FileDialog.qml b/examples/quick/tutorials/gettingStartedQml/core/FileDialog.qml
new file mode 100644
index 0000000000..24501efd89
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/core/FileDialog.qml
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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:dialog
+ height: 200 * partition; width: 200
+ color: "transparent"
+
+ signal selectChanged()
+ signal notifyRefresh()
+ onNotifyRefresh:dirView.model = directory.files
+
+ property string selectedFile
+ property int selectedIndex: 0
+
+ Rectangle {
+ id: dirBox
+ radius: 10
+ antialiasing: true
+ anchors.centerIn:parent
+ height: parent.height -15; width: parent.width -30
+
+ Rectangle {
+ id:header
+ height: parent.height*0.1; width: parent.width
+ radius:3
+ antialiasing: true
+ z:1
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#8C8F8C" }
+ GradientStop { position: 0.17; color: "#6A6D6A" }
+ GradientStop { position: 0.98;color: "#3F3F3F" }
+ GradientStop { position: 1.0; color: "#0e1B20" }
+ }
+ Text {
+ height: header.height; anchors.centerIn: header
+ text: "files:"
+ color: "lightblue"
+ font.weight: Font.Light
+ font.italic: true
+ }
+ }
+ GridView {
+ id:dirView
+ width:parent.width; height:parent.height*.9
+ anchors.top: header.bottom
+ cellWidth: 100; cellHeight: 75
+ model: directory.files
+ delegate: dirDelegate
+ clip: true
+ highlightMoveDuration: 40
+ }
+ Component {
+ id: dirDelegate
+ Rectangle {
+ id:file
+ color: "transparent"
+ width: GridView.view.cellWidth; height: GridView.view.cellHeight
+
+ Text {
+ id:fileName
+ width: parent.width
+ anchors.centerIn: parent
+ text: name
+ color: "#BDCACD"
+ font.weight: GridView.view.currentIndex == index ? Font.DemiBold : Font.Normal
+ font.pointSize: GridView.view.currentIndex == index ? 12 : 10
+ elide: Text.ElideMiddle
+ horizontalAlignment: Text.AlignHCenter
+ }
+ Rectangle {
+ id: selection
+ width: parent.width; height: parent.height
+ anchors.centerIn: parent
+ radius: 10
+ antialiasing: true
+ scale: GridView.view.currentIndex == index ? 1 : 0.5
+ opacity: GridView.view.currentIndex == index ? 1 : 0
+ Text {
+ id: overlay
+ width: parent.width
+ anchors.centerIn: parent
+ text: name
+ color: "#696167"
+ font.weight: Font.DemiBold
+ font.pointSize: 12
+ elide: Text.ElideMiddle
+ horizontalAlignment: Text.AlignHCenter
+ }
+ Behavior on opacity { NumberAnimation{ duration: 45 } }
+ Behavior on scale { NumberAnimation{ duration: 45 } }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter("lightsteelblue",1.25) }
+ GradientStop { position: 0.67; color: Qt.darker("lightsteelblue",1.3) }
+ }
+ border.color: "lightsteelblue"
+ border.width: 1
+ }
+ MouseArea {
+ id:fileMouseArea
+ anchors.fill:parent
+ hoverEnabled: true
+
+ onClicked: {
+ GridView.view.currentIndex = index
+ selectedFile = directory.files[index].name
+ selectChanged()
+ }
+ onEntered: {
+ fileName.color = "lightsteelblue"
+ fileName.font.weight = Font.DemiBold
+ }
+ onExited: {
+ fileName.font.weight = Font.Normal
+ fileName.color = "#BDCACD"
+ }
+ }
+ }
+ }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#A5333333" }
+ GradientStop { position: 1.0; color: "#03333333" }
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/core/FileMenu.qml b/examples/quick/tutorials/gettingStartedQml/core/FileMenu.qml
new file mode 100644
index 0000000000..37afca62b9
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/core/FileMenu.qml
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 "../filedialog" 1.0
+
+Rectangle {
+ id: fileMenu
+ height: 480; width:1000
+ property color buttonBorderColor: "#7F8487"
+ property color buttonFillColor: "#8FBDCACD"
+ property string fileContent:directory.fileContent
+
+ //the menuName is accessible from outside this QML file
+ property string menuName: "File"
+
+ //used to divide the screen into parts.
+ property real partition: 1/3
+
+ color: "#6C646A"
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#6C646A" }
+ GradientStop { position: 1.0; color: Qt.darker("#6A6D6A") }
+ }
+
+ Directory {
+ id:directory
+ filename: textInput.text
+ onDirectoryChanged:fileDialog.notifyRefresh()
+ }
+
+ Rectangle {
+ id:actionContainer
+
+ //make this rectangle invisible
+ color:"transparent"
+ anchors.left: parent.left
+
+ //the height is a good proportion that creates more space at the top of
+ //the column of buttons
+ width: fileMenu.width * partition; height: fileMenu.height
+
+ Column {
+ anchors.centerIn: parent
+ spacing: parent.height/32
+ Button {
+ id: saveButton
+ label: "Save"
+ borderColor: buttonBorderColor
+ buttonColor: buttonFillColor
+ width: actionContainer.width/ 1.3
+ height:actionContainer.height / 8
+ labelSize:24
+ onButtonClick: {
+ directory.fileContent = textArea.textContent
+ directory.filename = textInput.text
+ directory.saveFile()
+ }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ Button {
+ id: loadButton
+ width: actionContainer.width/ 1.3
+ height:actionContainer.height/ 8
+ buttonColor: buttonFillColor
+ borderColor: buttonBorderColor
+ label: "Load"
+ labelSize:24
+ onButtonClick:{
+ directory.filename = textInput.text
+ directory.loadFile()
+ textArea.textContent = directory.fileContent
+ }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ Button {
+ id: newButton
+ width: actionContainer.width/ 1.3
+ height: actionContainer.height/ 8
+ buttonColor: buttonFillColor
+ borderColor: buttonBorderColor
+ label: "New"
+ labelSize: 24
+ onButtonClick:{
+ textArea.textContent = ""
+ textInput.text = ""
+ }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+
+ }
+ Rectangle {
+ id: space
+ width: actionContainer.width/ 1.3
+ height: actionContainer.height / 16
+ color: "transparent"
+ }
+ Button {
+ id: exitButton
+ width: actionContainer.width/ 1.3
+ height: actionContainer.height/ 8
+ label: "Exit"
+ labelSize: 24
+ buttonColor: buttonFillColor
+ borderColor: buttonBorderColor
+ onButtonClick: Qt.quit()
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ }
+ }
+ Rectangle {
+ id:dialogContainer
+
+ width: 2*fileMenu.width * partition; height: fileMenu.height
+ anchors.right:parent.right
+ color: "transparent"
+
+ Column {
+ anchors.centerIn: parent
+ spacing: parent.height /640
+ FileDialog {
+ id:fileDialog
+ height: 2*dialogContainer.height * partition
+ width: dialogContainer.width
+ onSelectChanged: textInput.text = selectedFile
+ }
+
+ Rectangle {
+ id:lowerPartition
+ height: dialogContainer.height * partition; width: dialogContainer.width
+ color: "transparent"
+
+ Rectangle {
+ id: nameField
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#806F6F6F" }
+ GradientStop { position: 1.0; color: "#136F6F6F" }
+ }
+ radius: 10
+ anchors { centerIn:parent; leftMargin: 15; rightMargin: 15; topMargin: 15 }
+ height: parent.height-15
+ width: parent.width -20
+ border { color: "#4A4A4A"; width:1 }
+
+ TextInput {
+ id: textInput
+ z:2
+ anchors { bottom: parent.bottom; topMargin: 10; horizontalCenter: parent.horizontalCenter }
+ width: parent.width - 10
+ height: parent.height -10
+ font.pointSize: 40
+ color: "lightsteelblue"
+ focus: true
+ }
+ Text {
+ id: textInstruction
+ anchors.centerIn: parent
+ text: "Select file name and press save or load"
+ font {pointSize: 11; weight: Font.Light; italic: true}
+ color: "lightblue"
+ z: 2
+ opacity: (textInput.text == "") ? 1 : 0
+ }
+ Text {
+ id:fieldLabel
+ anchors { top: parent.top; left: parent.left }
+ text: " file name: "
+ font { pointSize: 11; weight: Font.Light; italic: true }
+ color: "lightblue"
+ z:2
+ }
+ MouseArea {
+ anchors.centerIn:parent
+ width: nameField.width; height: nameField.height
+ onClicked: {
+ textInput.text = ""
+ textInput.focus = true
+ textInput.forceFocus()
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/core/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/core/MenuBar.qml
new file mode 100644
index 0000000000..045e00e6c0
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/core/MenuBar.qml
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: menuBar
+ width: 1000; height:300
+ color:"transparent"
+ property color fileColor: "plum"
+ property color editColor: "powderblue"
+
+ property real partition: 1/10
+
+ Column {
+ anchors.fill: parent
+ //container for the header and the buttons
+ z: 1
+ Rectangle {
+ id: labelList
+ height:menuBar.height*partition
+ width: menuBar.width
+ color: "beige"
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#8C8F8C" }
+ GradientStop { position: 0.17; color: "#6A6D6A" }
+ GradientStop { position: 0.98;color: "#3F3F3F" }
+ GradientStop { position: 1.0; color: "#0e1B20" }
+ }
+ Text {
+ height: parent.height
+ anchors { right: labelRow.left ; verticalCenter: parent.bottom }
+ text: "menu: "
+ color: "lightblue"
+ font { weight: Font.Light; italic: true }
+ }
+ //row displays its children in a vertical row
+ Row {
+ id: labelRow
+ anchors.centerIn: parent
+ spacing:40
+ Button {
+ id: fileButton
+ height: 20; width: 50
+ label: "File"
+ buttonColor : menuListView.currentIndex == 0? fileColor : Qt.darker(fileColor, 1.5)
+ scale: menuListView.currentIndex == 0? 1.25: 1
+ labelSize: menuListView.currentIndex == 0? 16:12
+ radius: 1
+ //on a button click, change the list's currently selected item to FileMenu
+ onButtonClick: menuListView.currentIndex = 0
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: fileColor }
+ GradientStop { position: 1.0; color: "#136F6F6F" }
+ }
+ }
+ Button {
+ id: editButton
+ height: 20; width: 50
+ buttonColor : menuListView.currentIndex == 1? Qt.darker(editColor, 1.5) : Qt.darker(editColor, 1.9)
+ scale: menuListView.currentIndex == 1? 1.25: 1
+ label: "Edit"
+ radius: 1
+ labelSize: menuListView.currentIndex == 1? 16:12
+ //on a button click, change the list's currently selected item to EditMenu
+ onButtonClick: menuListView.currentIndex = 1
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: editColor }
+ GradientStop { position: 1.0; color: "#136F6F6F" }
+ }
+ }
+ }
+ }
+
+ //list view will display a model according to a delegate
+ ListView {
+ id: menuListView
+ width:menuBar.width; height: 9*menuBar.height*partition
+
+ //the model contains the data
+ model: menuListModel
+
+ //control the movement of the menu switching
+ snapMode: ListView.SnapOneItem
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ flickDeceleration: 5000
+ highlightFollowsCurrentItem: true
+ highlightMoveDuration:240
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ }
+ }
+ //a list of visual items already have delegates handling their display
+ VisualItemModel {
+ id: menuListModel
+
+ FileMenu {
+ id:fileMenu
+ width: menuListView.width; height: menuListView.height
+ color: fileColor
+ }
+ EditMenu {
+ color: editColor
+ width: menuListView.width; height: menuListView.height
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/core/TextArea.qml b/examples/quick/tutorials/gettingStartedQml/core/TextArea.qml
new file mode 100644
index 0000000000..5165533f65
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/core/TextArea.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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:textArea
+
+ function paste() { textEdit.paste() }
+ function copy() { textEdit.copy() }
+ function selectAll() { textEdit.selectAll() }
+
+ width :400; height:400
+
+ property color fontColor: "white"
+ property alias textContent: textEdit.text
+ Flickable {
+ id: flickArea
+ width: parent.width; height: parent.height
+ anchors.fill:parent
+
+ boundsBehavior: Flickable.StopAtBounds
+ flickableDirection: Flickable.HorizontalFlick
+ interactive: true
+ //Will move the text Edit area to make the area visible when
+ //scrolled with keyboard strokes
+ function ensureVisible(r) {
+ if (contentX >= r.x)
+ contentX = r.x;
+ else if (contentX+width <= r.x+r.width)
+ contentX = r.x+r.width-width;
+ if (contentY >= r.y)
+ contentY = r.y;
+ else if (contentY+height <= r.y+r.height)
+ contentY = r.y+r.height-height;
+ }
+
+ TextEdit {
+ id: textEdit
+ anchors.fill:parent
+ width:parent.width; height:parent.height
+ color:fontColor
+ focus: true
+ wrapMode: TextEdit.Wrap
+ font.pointSize:10
+ onCursorRectangleChanged: flickArea.ensureVisible(cursorRectangle)
+ selectByMouse: true
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/core/qmldir b/examples/quick/tutorials/gettingStartedQml/core/qmldir
new file mode 100644
index 0000000000..da1f373433
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/core/qmldir
@@ -0,0 +1,7 @@
+Button ./Button.qml
+FileDialog ./FileDialog.qml
+TextArea ./TextArea.qml
+TextEditor ./TextEditor.qml
+EditMenu ./EditMenu.qml
+MenuBar ./MenuBar.qml
+FileMenu ./FileMenu.qml
diff --git a/examples/quick/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp b/examples/quick/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp
new file mode 100644
index 0000000000..a77b93ae33
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 "dialogPlugin.h"
+#include "directory.h"
+#include "file.h"
+#include <QtQml/qqml.h>
+
+void DialogPlugin::registerTypes(const char *uri)
+{
+ //register the class Directory into QML as a "Directory" element version 1.0
+ qmlRegisterType<Directory>(uri, 1, 0, "Directory");
+ qmlRegisterType<File>(uri,1,0,"File");
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/filedialog/dialogPlugin.h b/examples/quick/tutorials/gettingStartedQml/filedialog/dialogPlugin.h
new file mode 100644
index 0000000000..05e076839a
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/filedialog/dialogPlugin.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 DIALOGPLUGIN_H
+#define DIALOGPLUGIN_H
+
+#include <QtQml/QQmlExtensionPlugin>
+
+class DialogPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+ // registerTypes is inherited from QQmlExtensionPlugin
+ void registerTypes(const char *uri);
+};
+
+#endif
+
diff --git a/examples/quick/tutorials/gettingStartedQml/filedialog/directory.cpp b/examples/quick/tutorials/gettingStartedQml/filedialog/directory.cpp
new file mode 100644
index 0000000000..38a47f0431
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/filedialog/directory.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 "directory.h"
+#include <QDebug>
+
+/*
+Directory constructor
+
+Initialize the saves directory and creates the file list
+*/
+Directory::Directory(QObject *parent) : QObject(parent)
+{
+ m_dir.cd(QDir::currentPath());
+
+ // go to the saved directory. if not found, create save directory
+ m_saveDir = "saves";
+ if (m_dir.cd(m_saveDir) == 0) {
+ m_dir.mkdir(m_saveDir);
+ m_dir.cd(m_saveDir);
+ }
+ m_filterList << "*.txt";
+ refresh();
+}
+
+/*
+Directory::filesNumber
+Return the number of Files
+*/
+int Directory::filesCount() const
+{
+ return m_fileList.size();
+}
+
+/*
+Function called to append data onto list property
+*/
+void appendFiles(QQmlListProperty<File> *property, File *file)
+{
+ Q_UNUSED(property);
+ Q_UNUSED(file);
+ //Do nothing. can't add to a directory using this method
+}
+
+/*
+Function called to retrieve file in the list using an index
+*/
+File *fileAt(QQmlListProperty<File> *property, int index)
+{
+ return static_cast< QList<File *> *>(property->data)->at(index);
+}
+
+/*
+Returns the number of files in the list
+*/
+int filesSize(QQmlListProperty<File> *property)
+{
+ return static_cast< QList<File *> *>(property->data)->size();
+}
+
+/*
+Function called to empty the list property contents
+*/
+void clearFilesPtr(QQmlListProperty<File> *property)
+{
+ return static_cast< QList<File *> *>(property->data)->clear();
+}
+
+/*
+Returns the list of files as a QQmlListProperty.
+*/
+QQmlListProperty<File> Directory::files()
+{
+ refresh();
+ return QQmlListProperty<File>(this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr);
+}
+
+/*
+Return the name of the currently selected file
+*/
+QString Directory::filename() const
+{
+ return currentFile.name();
+}
+
+/*
+Return the file's content as a string.
+*/
+QString Directory::fileContent() const
+{
+ return m_fileContent;
+}
+
+/*
+Set the file name of the current file
+*/
+void Directory::setFilename(const QString &str)
+{
+ if (str != currentFile.name()) {
+ currentFile.setName(str);
+ emit filenameChanged();
+ }
+}
+
+/*
+Set the content of the file as a string
+*/
+void Directory::setFileContent(const QString &str)
+{
+ if (str != m_fileContent) {
+ m_fileContent = str;
+ emit fileContentChanged();
+ }
+}
+
+/*
+Called from QML to save the file using the filename and file content.
+Saving makes sure that the file has a .txt extension.
+*/
+void Directory::saveFile()
+{
+ if (currentFile.name().isEmpty()) {
+ qWarning()<< "Empty filename. no save";
+ return;
+ }
+ QString extendedName = currentFile.name();
+ if (!currentFile.name().endsWith(".txt")) {
+ extendedName.append(".txt");
+ }
+ QFile file(m_dir.filePath(extendedName));
+ if (file.open(QFile::WriteOnly | QFile::Truncate)) {
+ QTextStream outStream(&file);
+ outStream << m_fileContent;
+ }
+ file.close();
+ refresh();
+ emit directoryChanged();
+}
+
+/*
+Load the contents of a file.
+Only loads files with a .txt extension
+*/
+void Directory::loadFile()
+{
+ m_fileContent.clear();
+ QString extendedName = currentFile.name();
+ if (!currentFile.name().endsWith(".txt")) {
+ extendedName.append(".txt");
+ }
+
+ QFile file(m_dir.filePath(extendedName));
+ if (file.open(QFile::ReadOnly)) {
+ QTextStream inStream(&file);
+ m_fileContent = inStream.readAll();
+ }
+ file.close();
+}
+
+/*
+Reloads the content of the files list. This is to ensure that the newly
+created files are added onto the list.
+*/
+void Directory::refresh()
+{
+ m_dirFiles = m_dir.entryList(m_filterList,QDir::Files,QDir::Name);
+ m_fileList.clear();
+
+ File *file;
+ for (int i = 0; i < m_dirFiles.size(); ++i) {
+ file = new File();
+
+ if (m_dirFiles.at(i).endsWith(".txt")) {
+ QString name = m_dirFiles.at(i);
+ file->setName(name.remove(".txt",Qt::CaseSensitive));
+ } else {
+ file->setName(m_dirFiles.at(i));
+ }
+ m_fileList.append(file);
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/filedialog/directory.h b/examples/quick/tutorials/gettingStartedQml/filedialog/directory.h
new file mode 100644
index 0000000000..90c427c1c5
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/filedialog/directory.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 DIRECTORY_H
+#define DIRECTORY_H
+
+#include "file.h"
+
+#include <QDir>
+#include <QObject>
+#include <QQmlListProperty>
+#include <QStringList>
+#include <QTextStream>
+
+class Directory : public QObject
+{
+ Q_OBJECT
+
+ // number of files in the directory
+ Q_PROPERTY(int filesCount READ filesCount)
+
+ // list property containing file names as QString
+ Q_PROPERTY(QQmlListProperty<File> files READ files CONSTANT)
+
+ // file name of the text file to read/write
+ Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
+
+ // text content of the file
+ Q_PROPERTY(QString fileContent READ fileContent WRITE setFileContent NOTIFY fileContentChanged)
+
+public:
+ Directory(QObject *parent = 0);
+
+ // properties' read functions
+ int filesCount() const;
+ QString filename() const;
+ QString fileContent() const;
+ QQmlListProperty<File> files();
+
+ // properties' write functions
+ void setFilename(const QString &str);
+ void setFileContent(const QString &str);
+
+ // accessible from QML
+ Q_INVOKABLE void saveFile();
+ Q_INVOKABLE void loadFile();
+
+signals:
+ void directoryChanged();
+ void filenameChanged();
+ void fileContentChanged();
+
+private:
+ QDir m_dir;
+ QStringList m_dirFiles;
+ File currentFile;
+ QString m_saveDir;
+ QStringList m_filterList;
+
+ //contains the file data in QString format
+ QString m_fileContent;
+
+ //Registered to QML in a plugin. Accessible from QML as a property of Directory
+ QList<File *> m_fileList;
+
+ //refresh content of the directory
+ void refresh();
+};
+
+#endif
diff --git a/examples/quick/tutorials/gettingStartedQml/filedialog/file.cpp b/examples/quick/tutorials/gettingStartedQml/filedialog/file.cpp
new file mode 100644
index 0000000000..b53c569d56
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/filedialog/file.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 "file.h"
+
+File::File(QObject *parent) : QObject(parent)
+{
+}
+
+QString File::name() const
+{
+ return m_name;
+}
+
+void File::setName(const QString &str)
+{
+ if (str != m_name) {
+ m_name = str;
+ emit nameChanged();
+ }
+}
+
diff --git a/examples/quick/tutorials/gettingStartedQml/filedialog/file.h b/examples/quick/tutorials/gettingStartedQml/filedialog/file.h
new file mode 100644
index 0000000000..7a0da05b70
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/filedialog/file.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 FILE_H
+#define FILE_H
+
+#include <QObject>
+#include <QString>
+
+class File : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+
+public:
+ File(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &str);
+
+signals:
+ void nameChanged();
+
+private:
+ QString m_name;
+};
+
+#endif
diff --git a/examples/quick/tutorials/gettingStartedQml/filedialog/filedialog.pro b/examples/quick/tutorials/gettingStartedQml/filedialog/filedialog.pro
new file mode 100644
index 0000000000..36d88588e4
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/filedialog/filedialog.pro
@@ -0,0 +1,22 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml
+
+DESTDIR += ../plugins
+OBJECTS_DIR = tmp
+MOC_DIR = tmp
+
+TARGET = FileDialog
+
+HEADERS += directory.h \
+ file.h \
+ dialogPlugin.h
+
+SOURCES += directory.cpp \
+ file.cpp \
+ dialogPlugin.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/gettingStartedQml/filedialog
+qml.files = qmldir
+qml.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/gettingStartedQml/filedialog
+INSTALLS += target qml
diff --git a/examples/quick/tutorials/gettingStartedQml/filedialog/qmldir b/examples/quick/tutorials/gettingStartedQml/filedialog/qmldir
new file mode 100644
index 0000000000..4a8d13d026
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/filedialog/qmldir
@@ -0,0 +1 @@
+plugin FileDialog ../plugins
diff --git a/examples/quick/tutorials/gettingStartedQml/gettingStartedQml.pro b/examples/quick/tutorials/gettingStartedQml/gettingStartedQml.pro
new file mode 100644
index 0000000000..1fc74b69f3
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/gettingStartedQml.pro
@@ -0,0 +1,10 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ filedialog\
+
+EXAMPLE_FILES = \
+ core \
+ images \
+ parts \
+ pics \
+ texteditor.qml
diff --git a/examples/quick/tutorials/gettingStartedQml/images/arrow.png b/examples/quick/tutorials/gettingStartedQml/images/arrow.png
new file mode 100644
index 0000000000..14978c2e56
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/images/arrow.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part0/Button.qml b/examples/quick/tutorials/gettingStartedQml/parts/part0/Button.qml
new file mode 100644
index 0000000000..f49ca9359f
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part0/Button.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [document]
+import QtQuick 2.0
+
+Rectangle {
+ id: simplebutton
+ color: "grey"
+ width: 150; height: 75
+
+ Text{
+ id: buttonLabel
+ anchors.centerIn: parent
+ text: "button label"
+ }
+}
+//! [document]
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part1/Button.qml b/examples/quick/tutorials/gettingStartedQml/parts/part1/Button.qml
new file mode 100644
index 0000000000..ab85963593
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part1/Button.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 {
+
+ //identifier of the item
+ id: button
+
+ property string label: "button label"
+
+ //these properties act as constants, useable outside this QML file
+ property int buttonHeight: 75
+ property int buttonWidth: 150
+
+ //the color highlight when the mouse hovers on the rectangle
+ property color onHoverColor: "gold"
+ property color borderColor: "white"
+
+ //buttonColor is set to the button's main color
+ property color buttonColor: "lightblue"
+
+ //set appearance properties
+ radius: 10
+ antialiasing: true
+ border{color: "white"; width: 3}
+ width: buttonWidth; height: buttonHeight
+
+ Text{
+ id: buttonLabel
+ anchors.centerIn: parent
+ text: label
+ }
+
+ //buttonClick() is callable and a signal handler, onButtonClick is automatically created
+ signal buttonClick()
+ onButtonClick: {
+ console.log(buttonLabel.text + " clicked" )
+ }
+
+ //define the clickable area to be the whole rectangle
+ MouseArea{
+ id: buttonMouseArea
+ anchors.fill: parent //stretch the area to the parent's dimension
+ onClicked: buttonClick()
+
+ //if true, then onEntered and onExited called if mouse hovers in the mouse area
+ //if false, a button must be clicked to detect the mouse hover
+ hoverEnabled: true
+
+ //display a border if the mouse hovers on the button mouse area
+ onEntered: parent.border.color = onHoverColor
+ //remove the border if the mouse exits the button mouse area
+ onExited: parent.border.color = borderColor
+ }
+
+ //change the color of the button when pressed
+ color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part1/EditMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part1/EditMenu.qml
new file mode 100644
index 0000000000..1940aebac3
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part1/EditMenu.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: editMenu
+ height: 480; width:1000
+ color: "powderblue"
+ property string menuName:"Edit"
+
+ Rectangle{
+ id:actionContainer
+ color:"transparent"
+ anchors.centerIn: parent
+
+ width: parent.width; height: parent.height / 5
+ Row{
+ anchors.centerIn: parent
+ spacing: parent.width/6
+ Button{
+ id: loadButton
+ buttonColor: "lightgrey"
+ label: "Cut"
+ }
+
+ Button{
+ buttonColor: "grey"
+ id: saveButton
+ label: "Paste"
+ }
+ Button{
+ id: exitButton
+ label: "Select All"
+ buttonColor: "darkgrey"
+ }
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part1/FileMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part1/FileMenu.qml
new file mode 100644
index 0000000000..abb7fba41b
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part1/FileMenu.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: fileMenu
+
+ //the menuName is accessible from outside this QML file
+ property string menuName: "File"
+
+ //generous amount of screen space that will allow the buttons to fit
+ height: 480; width:1000
+
+ color: "#6C646A"
+
+ //a sub-rectangle allows the flexibility of setting the row area
+ Rectangle{
+ id:actionContainer
+
+ //make this rectangle invisible
+ color:"transparent"
+ anchors.centerIn: parent
+
+ //the height is a good proportion that creates more space at the top of the row of buttons
+ width: parent.width; height: parent.height / 5
+
+ Row{
+ anchors.centerIn: parent
+ spacing: parent.width/6
+ Button{
+ id: loadButton
+ buttonColor: "lightgrey"
+ label: "Load"
+ }
+
+ Button{
+ buttonColor: "grey"
+ id: saveButton
+ label: "Save"
+ }
+ Button{
+ id: exitButton
+ label: "Exit"
+ buttonColor: "darkgrey"
+
+ //exit the application if the exitButton is clicked
+ onButtonClick:{
+ Qt.quit()
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml b/examples/quick/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml
new file mode 100644
index 0000000000..7559d4a917
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 {
+
+ //identifier of the item
+ id: simplebutton
+
+ //the rectangle's fill color
+ color: "grey"
+
+ //dimensions of the button
+ width: 150; height: 75
+
+ //A text element contains functionalities for creating texts
+ Text {
+ id: buttonLabel
+
+ //center the text inside the parent
+ anchors.centerIn: parent
+
+ //text property binds to the label displayed on the button
+ text: "button label"
+ }
+
+ //define the clickable area to be the whole rectangle
+ MouseArea {
+ id: buttonMouseArea
+ anchors.fill: parent //anchor all sides of the mouse area to the rectangle's anchors
+
+ //onClicked handles valid mouse button clicks
+ onClicked: console.log(buttonLabel.text + " clicked" )
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_button.png b/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_button.png
new file mode 100644
index 0000000000..aab64bcf39
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_button.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_editmenu.png b/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_editmenu.png
new file mode 100644
index 0000000000..d3ff66f2fd
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_editmenu.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_filemenu.png b/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_filemenu.png
new file mode 100644
index 0000000000..f2e2b0d990
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_filemenu.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_simplebutton.png b/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_simplebutton.png
new file mode 100644
index 0000000000..21ce50929b
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part1/pics/qml-texteditor1_simplebutton.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part1/qml-texteditor.qmlproject b/examples/quick/tutorials/gettingStartedQml/parts/part1/qml-texteditor.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part1/qml-texteditor.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part2/Button.qml b/examples/quick/tutorials/gettingStartedQml/parts/part2/Button.qml
new file mode 100644
index 0000000000..7119feeb08
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part2/Button.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 {
+
+ //identifier of the item
+ id: button
+
+ property string label: "button label"
+
+ //these properties act as constants, useable outside this QML file
+ property int buttonHeight: 75
+ property int buttonWidth: 150
+
+ //the color highlight when the mouse hovers on the rectangle
+ property color onHoverColor: "gold"
+ property color borderColor: "white"
+
+ //buttonColor is set to the button's main color
+ property color buttonColor: "lightblue"
+
+ //set appearance properties
+ radius:10
+ antialiasing: true
+ border{color: "white"; width: 3}
+ width: buttonWidth; height: buttonHeight
+
+ Text{
+ id: buttonLabel
+ anchors.centerIn: parent
+ text: label
+ }
+
+ //buttonClick() is callable and a signal handler, onButtonClick is automatically created
+ signal buttonClick()
+ onButtonClick: {
+ console.log(buttonLabel.text + " clicked" )
+ }
+
+ //define the clickable area to be the whole rectangle
+ MouseArea{
+ id: buttonMouseArea
+ anchors.fill: parent //stretch the area to the parent's dimension
+ onClicked: buttonClick()
+
+ //if true, then onEntered and onExited called if mouse hovers in the mouse area
+ //if false, a button must be clicked to detect the mouse hover
+ hoverEnabled: true
+
+ //display a border if the mouse hovers on the button mouse area
+ onEntered: parent.border.color = onHoverColor
+ //remove the border if the mouse exits the button mouse area
+ onExited: parent.border.color = borderColor
+
+ }
+
+ //change the color of the button when pressed
+ color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part2/EditMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part2/EditMenu.qml
new file mode 100644
index 0000000000..47a37059b0
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part2/EditMenu.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: editMenu
+ height: 480; width:1000
+ color: "powderblue"
+ property string menuName:"Edit"
+
+ Rectangle{
+ id:actionContainer
+ color:"transparent"
+ anchors.centerIn: parent
+
+ width: parent.width; height: parent.height / 5
+ Row{
+ anchors.centerIn: parent
+ spacing: parent.width/6
+ Button{
+ id: loadButton
+ buttonColor: "lightgrey"
+ label: "Cut"
+ }
+
+ Button{
+ buttonColor: "grey"
+ id: saveButton
+ label: "Paste"
+ }
+ Button{
+ id: exitButton
+ label: "Select All"
+ buttonColor: "darkgrey"
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part2/FileMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part2/FileMenu.qml
new file mode 100644
index 0000000000..41c7369fc0
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part2/FileMenu.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: fileMenu
+
+ //the menuName is accessible from outside this QML file
+ property string menuName: "File"
+
+ //generous amount of screen space that will allow the buttons to fit
+ height: 480; width:1000
+
+ color: "#6C646A"
+
+ //a sub-rectangle allows the flexibility of setting the row area
+ Rectangle{
+ id:actionContainer
+
+ //make this rectangle invisible
+ color:"transparent"
+ anchors.centerIn: parent
+
+ //the height is a good proportion that creates more space at the top of the row of buttons
+ width: parent.width; height: parent.height / 5
+
+ Row{
+ anchors.centerIn: parent
+ spacing: parent.width/6
+ Button{
+ id: loadButton
+ buttonColor: "lightgrey"
+ label: "Load"
+ }
+
+ Button{
+ buttonColor: "grey"
+ id: saveButton
+ label: "Save"
+ }
+ Button{
+ id: exitButton
+ label: "Exit"
+ buttonColor: "darkgrey"
+
+ //exit the application if the exitButton is clicked
+ onButtonClick:{
+ Qt.quit()
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part2/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/parts/part2/MenuBar.qml
new file mode 100644
index 0000000000..f9a293361e
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part2/MenuBar.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: menuBar
+ width: 1000
+ height:300
+
+ property color fileColor: "thistle"
+ property color editColor: "powderblue"
+
+ //container for the header and the buttons
+ Rectangle{
+
+ id: labelList
+ height:parent.height/10
+ width: parent.width
+ color: "steelblue"
+
+ //default z is 0, items with higher z values are shown on top of items with lower z values
+ z: 1
+
+ //row displays its children in a vertical row
+ Row{
+ anchors.centerIn: parent
+ spacing:40
+ Button{
+ height: 20
+ width: 50
+ label: "File"
+ id: fileButton
+ buttonColor : menuListView.currentIndex == 0? fileColor : Qt.darker(fileColor, 1.5)
+ scale: menuListView.currentIndex == 0? 1.25: 1
+ radius: 1
+
+ //on a button click, change the list's currently selected item to FileMenu
+ onButtonClick: {
+ menuListView.currentIndex = 0
+ }
+ }
+ Button{
+ height: 20
+ width: 50
+ id: editButton
+ buttonColor : menuListView.currentIndex == 1? editColor : Qt.darker(editColor, 1.5)
+ scale: menuListView.currentIndex == 1? 1.25: 1
+ label: "Edit"
+ radius: 1
+
+ //on a button click, change the list's currently selected item to EditMenu
+ onButtonClick: {
+ menuListView.currentIndex = 1
+ }
+
+
+ }
+
+
+ }
+ }
+
+ //a list of visual items already have delegates handling their display
+ VisualItemModel{
+ id: menuListModel
+
+ FileMenu{
+ width: menuListView.width
+ height: menuBar.height
+ color: fileColor
+ }
+ EditMenu{
+ color: editColor
+ width: menuListView.width
+ height: menuBar.height
+
+ }
+ }
+
+ //list view will display a model according to a delegate
+ ListView{
+ id: menuListView
+ anchors.fill:parent
+ anchors.bottom: parent.bottom
+ width:parent.width
+ height: parent.height
+
+ //the model contains the data
+ model: menuListModel
+
+ //control the movement of the menu switching
+ snapMode: ListView.SnapOneItem
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ flickDeceleration: 5000
+ highlightFollowsCurrentItem: true
+ highlightMoveDuration:240
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ }
+
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part2/pics/qml-texteditor2_menubar.png b/examples/quick/tutorials/gettingStartedQml/parts/part2/pics/qml-texteditor2_menubar.png
new file mode 100644
index 0000000000..da959a3468
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part2/pics/qml-texteditor2_menubar.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part2/qml-texteditor2.qmlproject b/examples/quick/tutorials/gettingStartedQml/parts/part2/qml-texteditor2.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part2/qml-texteditor2.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/Button.qml b/examples/quick/tutorials/gettingStartedQml/parts/part3/Button.qml
new file mode 100644
index 0000000000..7119feeb08
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/Button.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 {
+
+ //identifier of the item
+ id: button
+
+ property string label: "button label"
+
+ //these properties act as constants, useable outside this QML file
+ property int buttonHeight: 75
+ property int buttonWidth: 150
+
+ //the color highlight when the mouse hovers on the rectangle
+ property color onHoverColor: "gold"
+ property color borderColor: "white"
+
+ //buttonColor is set to the button's main color
+ property color buttonColor: "lightblue"
+
+ //set appearance properties
+ radius:10
+ antialiasing: true
+ border{color: "white"; width: 3}
+ width: buttonWidth; height: buttonHeight
+
+ Text{
+ id: buttonLabel
+ anchors.centerIn: parent
+ text: label
+ }
+
+ //buttonClick() is callable and a signal handler, onButtonClick is automatically created
+ signal buttonClick()
+ onButtonClick: {
+ console.log(buttonLabel.text + " clicked" )
+ }
+
+ //define the clickable area to be the whole rectangle
+ MouseArea{
+ id: buttonMouseArea
+ anchors.fill: parent //stretch the area to the parent's dimension
+ onClicked: buttonClick()
+
+ //if true, then onEntered and onExited called if mouse hovers in the mouse area
+ //if false, a button must be clicked to detect the mouse hover
+ hoverEnabled: true
+
+ //display a border if the mouse hovers on the button mouse area
+ onEntered: parent.border.color = onHoverColor
+ //remove the border if the mouse exits the button mouse area
+ onExited: parent.border.color = borderColor
+
+ }
+
+ //change the color of the button when pressed
+ color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/EditMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part3/EditMenu.qml
new file mode 100644
index 0000000000..47a37059b0
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/EditMenu.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: editMenu
+ height: 480; width:1000
+ color: "powderblue"
+ property string menuName:"Edit"
+
+ Rectangle{
+ id:actionContainer
+ color:"transparent"
+ anchors.centerIn: parent
+
+ width: parent.width; height: parent.height / 5
+ Row{
+ anchors.centerIn: parent
+ spacing: parent.width/6
+ Button{
+ id: loadButton
+ buttonColor: "lightgrey"
+ label: "Cut"
+ }
+
+ Button{
+ buttonColor: "grey"
+ id: saveButton
+ label: "Paste"
+ }
+ Button{
+ id: exitButton
+ label: "Select All"
+ buttonColor: "darkgrey"
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/FileMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part3/FileMenu.qml
new file mode 100644
index 0000000000..41c7369fc0
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/FileMenu.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: fileMenu
+
+ //the menuName is accessible from outside this QML file
+ property string menuName: "File"
+
+ //generous amount of screen space that will allow the buttons to fit
+ height: 480; width:1000
+
+ color: "#6C646A"
+
+ //a sub-rectangle allows the flexibility of setting the row area
+ Rectangle{
+ id:actionContainer
+
+ //make this rectangle invisible
+ color:"transparent"
+ anchors.centerIn: parent
+
+ //the height is a good proportion that creates more space at the top of the row of buttons
+ width: parent.width; height: parent.height / 5
+
+ Row{
+ anchors.centerIn: parent
+ spacing: parent.width/6
+ Button{
+ id: loadButton
+ buttonColor: "lightgrey"
+ label: "Load"
+ }
+
+ Button{
+ buttonColor: "grey"
+ id: saveButton
+ label: "Save"
+ }
+ Button{
+ id: exitButton
+ label: "Exit"
+ buttonColor: "darkgrey"
+
+ //exit the application if the exitButton is clicked
+ onButtonClick:{
+ Qt.quit()
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/parts/part3/MenuBar.qml
new file mode 100644
index 0000000000..f9a293361e
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/MenuBar.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: menuBar
+ width: 1000
+ height:300
+
+ property color fileColor: "thistle"
+ property color editColor: "powderblue"
+
+ //container for the header and the buttons
+ Rectangle{
+
+ id: labelList
+ height:parent.height/10
+ width: parent.width
+ color: "steelblue"
+
+ //default z is 0, items with higher z values are shown on top of items with lower z values
+ z: 1
+
+ //row displays its children in a vertical row
+ Row{
+ anchors.centerIn: parent
+ spacing:40
+ Button{
+ height: 20
+ width: 50
+ label: "File"
+ id: fileButton
+ buttonColor : menuListView.currentIndex == 0? fileColor : Qt.darker(fileColor, 1.5)
+ scale: menuListView.currentIndex == 0? 1.25: 1
+ radius: 1
+
+ //on a button click, change the list's currently selected item to FileMenu
+ onButtonClick: {
+ menuListView.currentIndex = 0
+ }
+ }
+ Button{
+ height: 20
+ width: 50
+ id: editButton
+ buttonColor : menuListView.currentIndex == 1? editColor : Qt.darker(editColor, 1.5)
+ scale: menuListView.currentIndex == 1? 1.25: 1
+ label: "Edit"
+ radius: 1
+
+ //on a button click, change the list's currently selected item to EditMenu
+ onButtonClick: {
+ menuListView.currentIndex = 1
+ }
+
+
+ }
+
+
+ }
+ }
+
+ //a list of visual items already have delegates handling their display
+ VisualItemModel{
+ id: menuListModel
+
+ FileMenu{
+ width: menuListView.width
+ height: menuBar.height
+ color: fileColor
+ }
+ EditMenu{
+ color: editColor
+ width: menuListView.width
+ height: menuBar.height
+
+ }
+ }
+
+ //list view will display a model according to a delegate
+ ListView{
+ id: menuListView
+ anchors.fill:parent
+ anchors.bottom: parent.bottom
+ width:parent.width
+ height: parent.height
+
+ //the model contains the data
+ model: menuListModel
+
+ //control the movement of the menu switching
+ snapMode: ListView.SnapOneItem
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ flickDeceleration: 5000
+ highlightFollowsCurrentItem: true
+ highlightMoveDuration:240
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ }
+
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/TextArea.qml b/examples/quick/tutorials/gettingStartedQml/parts/part3/TextArea.qml
new file mode 100644
index 0000000000..fa79c71fd9
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/TextArea.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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:textArea
+
+ width :400
+ height:400
+ color: "white"
+
+ Flickable{
+ id: flickArea
+
+ width: parent.width
+ height: parent.height
+ anchors.fill:parent
+
+ function ensureVisible(r){
+ if (contentX >= r.x)
+ contentX = r.x;
+ else if (contentX+width <= r.x+r.width)
+ contentX = r.x+r.width-width;
+ if (contentY >= r.y)
+ contentY = r.y;
+ else if (contentY+height <= r.y+r.height)
+ contentY = r.y+r.height-height;
+ }
+
+ TextEdit{
+ id: textEditor
+ anchors.fill:parent
+ width:parent.width; height:parent.height
+ color:"midnightblue"
+ focus: true
+
+ wrapMode: TextEdit.Wrap
+
+ onCursorRectangleChanged: flickArea.ensureVisible(cursorRectangle)
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/TextEditor.qml b/examples/quick/tutorials/gettingStartedQml/parts/part3/TextEditor.qml
new file mode 100644
index 0000000000..49be5e84cd
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/TextEditor.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+
+ id: screen
+ width: 1000; height: 1000
+ border.color:"black"
+ //the screen is partitioned into the MenuBar and TextArea. 1/3 of the screen is assigned to the MenuBar
+ property int partition: height/3
+
+ MenuBar{
+ id:menuBar
+ height: partition
+ width:parent.width
+ z: 1
+ }
+
+
+ TextArea{
+ id:textArea
+ anchors.bottom:parent.bottom
+ y: partition
+ color: "azure"
+ height: partition*2
+ width:parent.width
+ }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/images/arrow.png b/examples/quick/tutorials/gettingStartedQml/parts/part3/images/arrow.png
new file mode 100644
index 0000000000..14978c2e56
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/images/arrow.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/pics/qml-texteditor3_texteditor.png b/examples/quick/tutorials/gettingStartedQml/parts/part3/pics/qml-texteditor3_texteditor.png
new file mode 100644
index 0000000000..d0623b5a79
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/pics/qml-texteditor3_texteditor.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/qml-texteditor3.qmlproject b/examples/quick/tutorials/gettingStartedQml/parts/part3/qml-texteditor3.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/qml-texteditor3.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/Button.qml b/examples/quick/tutorials/gettingStartedQml/parts/part4/Button.qml
new file mode 100644
index 0000000000..50d4c9059f
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/Button.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 {
+
+ //identifier of the item
+ id: button
+
+ //these properties act as constants, useable outside this QML file
+ property int buttonHeight: 75
+ property int buttonWidth: 150
+
+ //attaches to the Text element's text content
+ property string label
+ property color textColor: buttonLabel.color
+
+ //the color highlight when the mouse hovers on the rectangle
+ property color onHoverColor: "gold"
+ property color borderColor: "white"
+
+ //buttonColor is set to the button's main color
+ property color buttonColor: "lightblue"
+
+ //set appearance properties
+ radius:10
+ antialiasing: true
+ border.color: "white"
+ border.width: 3
+ width: buttonWidth; height: buttonHeight
+
+ Text{
+ id: buttonLabel
+ anchors.centerIn: parent
+ text: label //"button label" //bind the text to the parent's text
+ }
+
+ //buttonClick() is callable and a signal handler, onButtonClick is automatically created
+ signal buttonClick()
+ onButtonClick: {
+ console.log(buttonLabel.text + " clicked" )
+ }
+
+ //define the clickable area to be the whole rectangle
+ MouseArea{
+ id: buttonMouseArea
+ anchors.fill: parent //stretch the area to the parent's dimension
+ onClicked: buttonClick()
+
+ //if true, then onEntered and onExited called if mouse hovers in the mouse area
+ //if false, a button must be clicked to detect the mouse hover
+ hoverEnabled: true
+
+ //display a border if the mouse hovers on the button mouse area
+ onEntered: parent.border.color = onHoverColor
+ //remove the border if the mouse exits the button mouse area
+ onExited: parent.border.color = borderColor
+
+ }
+
+ //change the color of the button when pressed
+ color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
+ //animate the color whenever the color property changes
+ Behavior on color { ColorAnimation{ duration: 55} }
+
+ //scale the button when pressed
+ scale: buttonMouseArea.pressed ? 1.1 : 1.00
+ //Animate the scale property change
+ Behavior on scale { NumberAnimation{ duration: 55} }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/EditMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part4/EditMenu.qml
new file mode 100644
index 0000000000..9613e3aaf5
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/EditMenu.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: editMenu
+ height: 480; width:1000
+ color: "powderblue"
+ property string menuName:"Edit"
+ gradient: Gradient{
+ GradientStop { position: 0.0; color: "#6A6F70" }
+ GradientStop { position: 1.0; color: Qt.darker("#6A6D67") }
+ }
+
+ Rectangle{
+ id:actionContainer
+ color:"transparent"
+ anchors.centerIn: parent
+
+ width: parent.width; height: parent.height / 5
+ Row{
+ anchors.centerIn: parent
+ spacing: parent.width/6
+ Button{
+ id: loadButton
+ buttonColor: "lightgrey"
+ label: "Cut"
+ }
+
+ Button{
+ buttonColor: "grey"
+ id: saveButton
+ label: "Paste"
+ }
+ Button{
+ id: exitButton
+ label: "Select All"
+ buttonColor: "darkgrey"
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/FileMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part4/FileMenu.qml
new file mode 100644
index 0000000000..fd3ccbd710
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/FileMenu.qml
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: fileMenu
+
+ //the menuName is accessible from outside this QML file
+ property string menuName: "File"
+
+ //generous amount of screen space that will allow the buttons to fit
+ height: 480; width:1000
+
+ color: "#6C646A"
+ gradient: Gradient{
+ GradientStop { position: 0.0; color: "#6C646A" }
+ GradientStop { position: 1.0; color: Qt.darker("#6A6D6A") }
+ }
+
+ //a sub-rectangle allows the flexibility of setting the row area
+ Rectangle{
+ id:actionContainer
+
+ //make this rectangle invisible
+ color:"transparent"
+ anchors.centerIn: parent
+
+ //the height is a good proportion that creates more space at the top of the row of buttons
+ width: parent.width; height: parent.height / 5
+
+ Row{
+ anchors.centerIn: parent
+ spacing: parent.width/6
+ Button{
+ id: loadButton
+ buttonColor: "lightgrey"
+ label: "Load"
+ }
+
+ Button{
+ buttonColor: "grey"
+ id: saveButton
+ label: "Save"
+ }
+ Button{
+ id: exitButton
+ label: "Exit"
+ buttonColor: "darkgrey"
+
+ //exit the application if the exitButton is clicked
+ onButtonClick:{
+ Qt.quit()
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/parts/part4/MenuBar.qml
new file mode 100644
index 0000000000..abd8a313cf
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/MenuBar.qml
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: menuBar
+ width: 1000
+ height:300
+
+ property color fileColor: "plum"
+ property color editColor: "powderblue"
+
+ //container for the header and the buttons
+ Rectangle{
+
+ id: labelList
+ height:parent.height/10
+ width: parent.width
+ color: "beige"
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#8C8F8C" }
+ GradientStop { position: 0.17; color: "#6A6D6A" }
+ GradientStop { position: 0.98;color: "#3F3F3F" }
+ GradientStop { position: 1.0; color: "#0e1B20" }
+ }
+
+ //default z is 0, items with higher z values are shown on top of items with lower z values
+ z: 1
+
+ //row displays its children in a vertical row
+ Row{
+ anchors.centerIn: parent
+ spacing:40
+ Button{
+ height: 20
+ width: 50
+ label: "File"
+ id: fileButton
+ buttonColor : menuListView.currentIndex == 0? fileColor : Qt.darker(fileColor, 1.5)
+ scale: menuListView.currentIndex == 0? 1.25: 1
+ radius: 1
+
+ //on a button click, change the list's currently selected item to FileMenu
+ onButtonClick: {
+ menuListView.currentIndex = 0
+ }
+ }
+ Button{
+ height: 20
+ width: 50
+ id: editButton
+ buttonColor : menuListView.currentIndex == 1? editColor : Qt.darker(editColor, 1.5)
+ scale: menuListView.currentIndex == 1? 1.25: 1
+ label: "Edit"
+ radius: 1
+
+ //on a button click, change the list's currently selected item to EditMenu
+ onButtonClick: {
+ menuListView.currentIndex = 1
+ }
+
+
+ }
+
+
+ }
+ }
+
+ //a list of visual items already have delegates handling their display
+ VisualItemModel{
+ id: menuListModel
+
+ FileMenu{
+ width: menuListView.width
+ height: menuBar.height
+ color: fileColor
+ }
+ EditMenu{
+ color: editColor
+ width: menuListView.width
+ height: menuBar.height
+
+ }
+ }
+
+ //list view will display a model according to a delegate
+ ListView{
+ id: menuListView
+ anchors.fill:parent
+ anchors.bottom: parent.bottom
+ width:parent.width
+ height: parent.height
+
+ //the model contains the data
+ model: menuListModel
+
+ //control the movement of the menu switching
+ snapMode: ListView.SnapOneItem
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ flickDeceleration: 5000
+ highlightFollowsCurrentItem: true
+ highlightMoveDuration:240
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ }
+
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml b/examples/quick/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml
new file mode 100644
index 0000000000..27f6923c1d
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: simplebutton
+ color: "grey"
+ width: 150; height: 75
+
+ Text{
+ id: buttonLabel
+ anchors.centerIn: parent
+ text: "button label"
+ }
+
+ MouseArea{
+ id: buttonMouseArea
+ anchors.fill: parent
+ onClicked: console.log(buttonLabel.text + " clicked" )
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/TextArea.qml b/examples/quick/tutorials/gettingStartedQml/parts/part4/TextArea.qml
new file mode 100644
index 0000000000..88a60d049c
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/TextArea.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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:textArea
+
+ width :400
+ height:400
+ property color fontColor: "white"
+
+ Flickable{
+ id: flickArea
+
+ width: parent.width
+ height: parent.height
+ anchors.fill:parent
+
+ function ensureVisible(r){
+ if (contentX >= r.x)
+ contentX = r.x;
+ else if (contentX+width <= r.x+r.width)
+ contentX = r.x+r.width-width;
+ if (contentY >= r.y)
+ contentY = r.y;
+ else if (contentY+height <= r.y+r.height)
+ contentY = r.y+r.height-height;
+ }
+
+ TextEdit{
+ id: textEditor
+ anchors.fill:parent
+ width:parent.width; height:parent.height
+ color:fontColor
+ focus: true
+
+ wrapMode: TextEdit.Wrap
+
+ onCursorRectangleChanged: flickArea.ensureVisible(cursorRectangle)
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/TextEditor.qml b/examples/quick/tutorials/gettingStartedQml/parts/part4/TextEditor.qml
new file mode 100644
index 0000000000..09bcb37cb2
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/TextEditor.qml
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: screen
+ width: 1000; height: 1000
+ property int partition: height/3
+ state: "DRAWER_CLOSED"
+
+
+ //Item 1: MenuBar on the top portion of the screen
+ MenuBar{
+ id:menuBar
+ height: partition
+ //anchors.top:parent.top
+ width:parent.width
+ z:1
+ }
+
+
+ //Item 2: The editable text area
+ TextArea{
+ id:textArea
+ y:drawer.height
+ border.color: Qt.darker(color, 1.4)
+ border.width: 2
+ color: "#3F3F3F"
+ fontColor: "#DCDCCC"
+ height: partition*2
+ width:parent.width
+ }
+
+ //Item 3: The drawer handle
+ Rectangle{
+ id:drawer
+ height:15
+ width: parent.width
+ border.color : "#6A6D6A"
+ border.width: 1
+
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#8C8F8C" }
+ GradientStop { position: 0.17; color: "#6A6D6A" }
+ GradientStop { position: 0.77; color: "#3F3F3F" }
+ GradientStop { position: 1.0; color: "#6A6D6A" }
+ }
+
+ Image{
+ id: arrowIcon
+ source: "images/arrow.png"
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ Behavior{NumberAnimation{property: "rotation";easing.type: Easing.OutExpo }}
+ }
+
+ MouseArea{
+ id: drawerMouseArea
+ anchors.fill:parent
+ onClicked:{
+ if (screen.state == "DRAWER_CLOSED"){
+ screen.state = "DRAWER_OPEN"
+ console.log("drawer OPEN")
+ }
+ else if (screen.state == "DRAWER_OPEN"){
+ screen.state = "DRAWER_CLOSED"
+ console.log("drawer closed")
+ }
+ }
+
+ //if true, then onEntered and onExited called if mouse hovers in the mouse area
+ //if false, a button must be clicked to detect the mouse hover
+ hoverEnabled: true
+
+ //display a border if the mouse hovers on the button mouse area
+ onEntered: parent.border.color = Qt.lighter("#6A6D6A")
+ //remove the border if the mouse exits the button mouse area
+ onExited: parent.border.color = "#6A6D6A"
+ }
+
+ }
+ states:[
+ State{
+ name: "DRAWER_OPEN"
+ PropertyChanges { target: menuBar; y:0}
+ PropertyChanges { target: textArea; y: partition + drawer.height}
+ PropertyChanges { target: drawer; y: partition}
+ PropertyChanges { target: arrowIcon; rotation: 180}
+ },
+ State{
+ name: "DRAWER_CLOSED"
+ PropertyChanges { target: menuBar; y:-partition}
+ PropertyChanges { target: textArea; y: drawer.height; height: screen.height - drawer.height}
+ PropertyChanges { target: drawer; y: 0}
+ PropertyChanges { target: arrowIcon; rotation: 0}
+ }
+
+ ]
+ transitions: [
+ Transition{
+ to: "*"
+ NumberAnimation { target: textArea; properties: "y, height"; duration: 100; easing.type:Easing.OutExpo }
+ NumberAnimation { target: menuBar; properties: "y"; duration: 100;easing.type: Easing.OutExpo }
+ NumberAnimation { target: drawer; properties: "y"; duration: 100;easing.type: Easing.OutExpo }
+ }
+
+ ]
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/images/arrow.png b/examples/quick/tutorials/gettingStartedQml/parts/part4/images/arrow.png
new file mode 100644
index 0000000000..14978c2e56
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/images/arrow.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/pics/qml-texteditor4_texteditor.png b/examples/quick/tutorials/gettingStartedQml/parts/part4/pics/qml-texteditor4_texteditor.png
new file mode 100644
index 0000000000..a195fb87c3
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/pics/qml-texteditor4_texteditor.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/qml-texteditor4.qmlproject b/examples/quick/tutorials/gettingStartedQml/parts/part4/qml-texteditor4.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/qml-texteditor4.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/TextEditor.qml b/examples/quick/tutorials/gettingStartedQml/parts/part5/TextEditor.qml
new file mode 100644
index 0000000000..5ce5a89ceb
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/TextEditor.qml
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "core"
+
+Rectangle {
+ id: screen
+ width: 1000; height: 1000
+ property int partition: height/3
+ state: "DRAWER_CLOSED"
+
+ //Item 1: MenuBar on the top portion of the screen
+ MenuBar{
+ id:menuBar
+ height: screen.partition; width: screen.width
+ z:1
+ }
+ //Item 2: The editable text area
+ TextArea{
+ id:textArea
+ y:drawer.height
+ color: "#3F3F3F"
+ fontColor: "#DCDCCC"
+ height: partition*2; width:parent.width
+ }
+ //Item 3: The drawer handle
+ Rectangle{
+ id:drawer
+ height:15; width: parent.width
+ border.color : "#6A6D6A"
+ border.width: 1
+ z:1
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#8C8F8C" }
+ GradientStop { position: 0.17; color: "#6A6D6A" }
+ GradientStop { position: 0.77; color: "#3F3F3F" }
+ GradientStop { position: 1.0; color: "#6A6D6A" }
+ }
+ Image{
+ id: arrowIcon
+ source: "images/arrow.png"
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ Behavior{NumberAnimation{property: "rotation";easing.type: Easing.OutExpo }}
+ }
+
+ MouseArea{
+ id: drawerMouseArea
+ anchors.fill:parent
+ hoverEnabled: true
+ onEntered: parent.border.color = Qt.lighter("#6A6D6A")
+ onExited: parent.border.color = "#6A6D6A"
+ onClicked:{
+ if (screen.state == "DRAWER_CLOSED"){
+ screen.state = "DRAWER_OPEN"
+ }
+ else if (screen.state == "DRAWER_OPEN"){
+ screen.state = "DRAWER_CLOSED"
+ }
+ }
+ }
+ }
+
+ states:[
+ State{
+ name: "DRAWER_OPEN"
+ PropertyChanges { target: menuBar; y: 0}
+ PropertyChanges { target: textArea; y: partition + drawer.height}
+ PropertyChanges { target: drawer; y: partition}
+ PropertyChanges { target: arrowIcon; rotation: 180}
+ },
+ State{
+ name: "DRAWER_CLOSED"
+ PropertyChanges { target: menuBar; y:-height; }
+ PropertyChanges { target: textArea; y: drawer.height; height: screen.height - drawer.height}
+ PropertyChanges { target: drawer; y: 0}
+ PropertyChanges { target: arrowIcon; rotation: 0}
+ }
+ ]
+
+ transitions: [
+ Transition{
+ to: "*"
+ NumberAnimation { target: textArea; properties: "y, height"; duration: 100; easing.type:Easing.OutExpo }
+ NumberAnimation { target: menuBar; properties: "y"; duration: 100;easing.type: Easing.OutExpo }
+ NumberAnimation { target: drawer; properties: "y"; duration: 100;easing.type: Easing.OutExpo }
+ }
+ ]
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/core/Button.qml b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/Button.qml
new file mode 100644
index 0000000000..eca367e859
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/Button.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 {
+
+ //identifier of the item
+ id: button
+
+ //these properties act as constants, useable outside this QML file
+ property int buttonHeight: 75
+ property int buttonWidth: 150
+
+ //attaches to the Text element's text content
+ property string label
+ property color textColor: buttonLabel.color
+
+ //the color highlight when the mouse hovers on the rectangle
+ property color onHoverColor: "lightsteelblue"
+ property color borderColor: "transparent"
+
+ //buttonColor is set to the button's main color
+ property color buttonColor: "lightblue"
+
+ property real labelSize: 14
+ //set appearance properties
+ radius:6
+ antialiasing: true
+ border.width: 2
+ border.color: borderColor
+ width: buttonWidth; height: buttonHeight
+
+ Text{
+ id: buttonLabel
+ anchors.centerIn: parent
+ text: label //bind the text to the parent's text
+ color: "#DCDCCC"
+ font.pointSize: labelSize
+ }
+
+ //buttonClick() is callable and a signal handler, onButtonClick is automatically created
+ signal buttonClick()
+
+ //define the clickable area to be the whole rectangle
+ MouseArea{
+ id: buttonMouseArea
+ anchors.fill: parent //stretch the area to the parent's dimension
+ onClicked: buttonClick()
+
+ //if true, then onEntered and onExited called if mouse hovers in the mouse area
+ //if false, a button must be clicked to detect the mouse hover
+ hoverEnabled: true
+
+ //display a border if the mouse hovers on the button mouse area
+ onEntered: parent.border.color = onHoverColor
+ //remove the border if the mouse exits the button mouse area
+ onExited: parent.border.color = borderColor
+
+ }
+
+ //change the color of the button when pressed
+ color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
+ //animate the color whenever the color property changes
+ Behavior on color { ColorAnimation{ duration: 55} }
+
+ //scale the button when pressed
+ scale: buttonMouseArea.pressed ? 1.1 : 1.00
+ //Animate the scale property change
+ Behavior on scale { NumberAnimation{ duration: 55} }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml
new file mode 100644
index 0000000000..57e297c509
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: editMenu
+ height: 480; width:1000
+ color: "powderblue"
+ property color buttonBorderColor: "#7A8182"
+ property color buttonFillColor: "#61BDCACD"
+ property string menuName:"Edit"
+
+ gradient: Gradient{
+ GradientStop { position: 0.0; color: "#6A7570" }
+ GradientStop { position: 1.0; color: Qt.darker("#6A7570") }
+ }
+
+ Rectangle{
+ id:actionContainer
+ color:"transparent"
+ anchors.centerIn: parent
+ width: parent.width; height: parent.height / 5
+ Row{
+ anchors.centerIn: parent
+ spacing: parent.width/9
+ Button{
+ id: loadButton
+ buttonColor: buttonFillColor
+ label: "Copy"
+ labelSize:16
+ borderColor:buttonBorderColor
+ height: actionContainer.height
+ width: actionContainer.width/6
+ onButtonClick:textArea.copy()
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+
+ Button{
+ id: saveButton
+ height: actionContainer.height
+ width: actionContainer.width/6
+ buttonColor: buttonFillColor
+ label: "Paste"
+ borderColor:buttonBorderColor
+ labelSize:16
+ onButtonClick:textArea.paste()
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ Button{
+ id: exitButton
+ label: "Select All"
+ height: actionContainer.height
+ width: actionContainer.width/6
+ labelSize:16
+ buttonColor: buttonFillColor
+ borderColor:buttonBorderColor
+ onButtonClick:textArea.selectAll()
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml
new file mode 100644
index 0000000000..b73e908464
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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:dialog
+ height: 200 * partition; width: 200
+ color: "transparent"
+
+ signal selectChanged()
+ signal notifyRefresh()
+ onNotifyRefresh:dirView.model = directory.files
+
+ property string selectedFile
+ property int selectedIndex: 0
+
+ Rectangle{
+ id: dirBox
+ radius: 10
+ antialiasing: true
+ anchors.centerIn:parent
+ height: parent.height -15; width: parent.width -30
+
+ Rectangle{
+ id:header
+ height:parent.height*0.1
+ width: parent.width
+ radius:3
+ antialiasing: true
+ z:1
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#8C8F8C" }
+ GradientStop { position: 0.17; color: "#6A6D6A" }
+ GradientStop { position: 0.98;color: "#3F3F3F" }
+ GradientStop { position: 1.0; color: "#0e1B20" }
+ }
+ Text{
+ height: header.height
+ anchors.centerIn: header
+ text: "files:"
+ color: "lightblue"
+ font.weight: Font.Light
+ font.italic: true
+ }
+ }
+ GridView{
+ id:dirView
+ width:parent.width
+ height:parent.height*.9
+ anchors.top: header.bottom
+ cellWidth: 100
+ cellHeight: 75
+// highlight: Rectangle { width:cellWidth; height: cellHeight; color: "lightsteelblue" ;radius: 13}
+ model: directory.files
+ delegate: dirDelegate
+ clip: true
+ highlightMoveDuration:40
+ }
+
+ Component{
+ id:dirDelegate
+
+ Rectangle{
+ id:file
+ color: "transparent"
+ width: GridView.view.cellWidth; height: GridView.view.cellHeight
+
+ Text{
+ id:fileName
+ width: parent.width
+ anchors.centerIn:parent
+ text: name
+ color: "#BDCACD"
+ font.weight: GridView.view.currentIndex == index ? Font.DemiBold : Font.Normal
+ font.pointSize: GridView.view.currentIndex == index ? 12 : 10
+ elide: Text.ElideMiddle
+ horizontalAlignment: Text.AlignHCenter
+ }
+ Rectangle{
+ id:selection
+ width:parent.width; height:parent.height
+ anchors.centerIn: parent
+ radius: 10
+ antialiasing: true
+ scale: GridView.view.currentIndex == index ? 1 : 0.5
+ opacity: GridView.view.currentIndex == index ? 1 : 0
+ Text{
+ id:overlay
+ width: parent.width
+ anchors.centerIn:parent
+ text: name
+ color: "#696167"
+ font.weight: Font.DemiBold
+ font.pointSize: 12
+ elide: Text.ElideMiddle
+ horizontalAlignment: Text.AlignHCenter
+ }
+ Behavior on opacity{ NumberAnimation{ duration: 45} }
+ Behavior on scale { NumberAnimation{ duration: 45} }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter("lightsteelblue",1.25) }
+ GradientStop { position: 0.67; color: Qt.darker("lightsteelblue",1.3) }
+ }
+ border.color:"lightsteelblue"
+ border.width:1
+ }
+ MouseArea{
+ id:fileMouseArea
+ anchors.fill:parent
+ hoverEnabled: true
+
+ onClicked:{
+ GridView.view.currentIndex = index
+ selectedFile = directory.files[index].name
+ selectChanged()
+ }
+ onEntered:{
+ fileName.color = "lightsteelblue"
+ fileName.font.weight = Font.DemiBold
+ }
+ onExited: {
+ fileName.font.weight = Font.Normal
+ fileName.color = "#BDCACD"
+ }
+ }
+ }
+ }
+ gradient: Gradient{
+ GradientStop { position: 0.0; color: "#A5333333" }
+ GradientStop { position: 1.0; color: "#03333333" }
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml
new file mode 100644
index 0000000000..c13e753f06
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 "../filedialog" 1.0
+
+Rectangle {
+ id: fileMenu
+ height: 480; width:1000
+ property color buttonBorderColor: "#7F8487"
+ property color buttonFillColor: "#8FBDCACD"
+ property string fileContent:directory.fileContent
+
+ //the menuName is accessible from outside this QML file
+ property string menuName: "File"
+
+ //used to divide the screen into parts.
+ property real partition: 1/3
+
+ color: "#6C646A"
+ gradient: Gradient{
+ GradientStop { position: 0.0; color: "#6C646A" }
+ GradientStop { position: 1.0; color: Qt.darker("#6A6D6A") }
+ }
+
+ Directory{
+ id:directory
+ filename: textInput.text
+ onDirectoryChanged:fileDialog.notifyRefresh()
+ }
+
+ Rectangle{
+ id:actionContainer
+
+ //make this rectangle invisible
+ color:"transparent"
+ anchors.left: parent.left
+
+ //the height is a good proportion that creates more space at the top of the column of buttons
+ width: fileMenu.width * partition; height: fileMenu.height
+
+ Column{
+ anchors.centerIn: parent
+ spacing: parent.height/32
+ Button{
+ id: saveButton
+ label: "Save"
+ borderColor: buttonBorderColor
+ buttonColor: buttonFillColor
+ width: actionContainer.width/ 1.3
+ height:actionContainer.height / 8
+ labelSize:24
+ onButtonClick:{
+ directory.fileContent = textArea.textContent
+ directory.filename = textInput.text
+ directory.saveFile()
+ }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+
+ }
+ Button{
+ id: loadButton
+ width: actionContainer.width/ 1.3
+ height:actionContainer.height/ 8
+ buttonColor: buttonFillColor
+ borderColor: buttonBorderColor
+ label: "Load"
+ labelSize:24
+ onButtonClick:{
+ directory.filename = textInput.text
+ directory.loadFile()
+ textArea.textContent = directory.fileContent
+ }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ Button{
+ id: newButton
+ width: actionContainer.width/ 1.3
+ height:actionContainer.height/ 8
+ buttonColor: buttonFillColor
+ borderColor: buttonBorderColor
+ label: "New"
+ labelSize:24
+ onButtonClick:{
+ textArea.textContent = ""
+ textInput.text = ""
+ }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+
+ }
+ Rectangle{
+ id: space
+ width: actionContainer.width/ 1.3
+ height:actionContainer.height / 16
+ color:"transparent"
+ }
+ Button{
+ id: exitButton
+ width: actionContainer.width/ 1.3
+ height:actionContainer.height/ 8
+ label: "Exit"
+ labelSize:24
+ buttonColor: buttonFillColor
+ borderColor: buttonBorderColor
+ onButtonClick:Qt.quit()
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Qt.lighter(buttonFillColor,1.25) }
+ GradientStop { position: 0.67; color: Qt.darker(buttonFillColor,1.3) }
+ }
+ }
+ }
+ }
+
+ Rectangle{
+ id:dialogContainer
+
+ width: 2*fileMenu.width * partition; height: fileMenu.height
+ anchors.right:parent.right
+ color:"transparent"
+
+ Column {
+ anchors.centerIn: parent
+ spacing: parent.height /640
+ FileDialog{
+ id:fileDialog
+ height: 2*dialogContainer.height * partition; width: dialogContainer.width
+ onSelectChanged: textInput.text = selectedFile
+ }
+
+ Rectangle{
+ id:lowerPartition
+ height: dialogContainer.height * partition; width: dialogContainer.width
+ color: "transparent"
+
+ Rectangle{
+ id: nameField
+ gradient: Gradient{
+ GradientStop { position: 0.0; color: "#806F6F6F" }
+ GradientStop { position: 1.0; color: "#136F6F6F" }
+ }
+
+ radius: 10
+ anchors {centerIn:parent; leftMargin: 15; rightMargin: 15; topMargin: 15}
+ height: parent.height-15; width: parent.width -20
+ border {color:"#4A4A4A"; width:1}
+
+ TextInput{
+ id: textInput
+ z:2
+ anchors {bottom: parent.bottom; topMargin: 10; horizontalCenter:parent.horizontalCenter}
+ width: parent.width - 10
+ height: parent.height -10
+ font.pointSize: 40
+ color:"lightsteelblue"
+ focus:true
+ }
+ Text{
+ id: textInstruction
+ anchors.centerIn:parent
+ text: "Select file name and press save or load"
+ font {pointSize: 11; weight:Font.Light; italic: true}
+ color: "lightblue"
+ z:2
+ opacity: (textInput.text == "") ? 1: 0
+ }
+ Text{
+ id:fieldLabel
+ anchors {top: parent.top; left: parent.left}
+ text: " file name: "
+ font {pointSize: 11; weight: Font.Light; italic: true}
+ color: "lightblue"
+ z:2
+ }
+ MouseArea{
+ anchors.centerIn:parent
+ width: nameField.width; height: nameField.height
+ onClicked:{
+ textInput.text = ""
+ textInput.focus = true
+ textInput.forceFocus()
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml
new file mode 100644
index 0000000000..89f21c021d
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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: menuBar
+ width: 1000; height:300
+ color:"transparent"
+ property color fileColor: "plum"
+ property color editColor: "powderblue"
+
+ property real partition: 1/10
+
+ Column{
+ anchors.fill: parent
+ //container for the header and the buttons
+ z: 1
+ Rectangle{
+ id: labelList
+ height:menuBar.height*partition
+ width: menuBar.width
+ color: "beige"
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#8C8F8C" }
+ GradientStop { position: 0.17; color: "#6A6D6A" }
+ GradientStop { position: 0.98;color: "#3F3F3F" }
+ GradientStop { position: 1.0; color: "#0e1B20" }
+ }
+ Text{
+ height: parent.height
+ anchors {right: labelRow.left ; verticalCenter: parent.bottom}
+ text: "menu: "
+ color: "lightblue"
+ font {weight: Font.Light; italic: true}
+ }
+
+ //row displays its children in a vertical row
+ Row{
+ id: labelRow
+ anchors.centerIn: parent
+ spacing:40
+ Button{
+ id: fileButton
+ height: 20; width: 50
+ label: "File"
+ buttonColor : menuListView.currentIndex == 0? fileColor : Qt.darker(fileColor, 1.5)
+ scale: menuListView.currentIndex == 0? 1.25: 1
+ labelSize: menuListView.currentIndex == 0? 16:12
+ radius: 1
+ //on a button click, change the list's currently selected item to FileMenu
+ onButtonClick: menuListView.currentIndex = 0
+ gradient: Gradient{
+ GradientStop { position: 0.0; color: fileColor }
+ GradientStop { position: 1.0; color: "#136F6F6F" }
+ }
+ }
+ Button{
+ id: editButton
+ height: 20; width: 50
+ buttonColor : menuListView.currentIndex == 1? Qt.darker(editColor, 1.5) : Qt.darker(editColor, 1.9)
+ scale: menuListView.currentIndex == 1? 1.25: 1
+ label: "Edit"
+ radius: 1
+ labelSize: menuListView.currentIndex == 1? 16:12
+ //on a button click, change the list's currently selected item to EditMenu
+ onButtonClick: menuListView.currentIndex = 1
+ gradient: Gradient{
+ GradientStop { position: 0.0; color: editColor }
+ GradientStop { position: 1.0; color: "#136F6F6F" }
+ }
+ }
+ }
+ }
+
+ //list view will display a model according to a delegate
+ ListView{
+ id: menuListView
+ width:menuBar.width; height: 9*menuBar.height*partition
+
+ //the model contains the data
+ model: menuListModel
+
+ //control the movement of the menu switching
+ snapMode: ListView.SnapOneItem
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ flickDeceleration: 5000
+ highlightFollowsCurrentItem: true
+ highlightMoveDuration:240
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ }
+ }
+ //a list of visual items already have delegates handling their display
+ VisualItemModel{
+ id: menuListModel
+
+ FileMenu{
+ id:fileMenu
+ width: menuListView.width; height: menuListView.height
+ color: fileColor
+ }
+ EditMenu{
+ color: editColor
+ width: menuListView.width; height: menuListView.height
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml
new file mode 100644
index 0000000000..a19e53264d
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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:textArea
+
+ function paste(){ textEdit.paste()}
+ function copy() { textEdit.copy() }
+ function selectAll() { textEdit.selectAll() }
+
+ width :400; height:400
+
+ property color fontColor: "white"
+ property alias textContent: textEdit.text
+ Flickable{
+ id: flickArea
+ width: parent.width; height: parent.height
+ anchors.fill:parent
+
+ boundsBehavior: Flickable.StopAtBounds
+ flickableDirection: Flickable.HorizontalFlick
+ interactive: true
+ //Will move the text Edit area to make the area visible when scrolled with keyboard strokes
+ function ensureVisible(r){
+ if (contentX >= r.x)
+ contentX = r.x;
+ else if (contentX+width <= r.x+r.width)
+ contentX = r.x+r.width-width;
+ if (contentY >= r.y)
+ contentY = r.y;
+ else if (contentY+height <= r.y+r.height)
+ contentY = r.y+r.height-height;
+ }
+
+ TextEdit{
+ id: textEdit
+ anchors.fill:parent
+ width:parent.width; height:parent.height
+ color:fontColor
+ focus: true
+ wrapMode: TextEdit.Wrap
+ font.pointSize:10
+ onCursorRectangleChanged: flickArea.ensureVisible(cursorRectangle)
+ selectByMouse: true
+ }
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/core/qmldir b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/qmldir
new file mode 100644
index 0000000000..b8b0c7c431
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/qmldir
@@ -0,0 +1,11 @@
+
+Button ./Button.qml
+FileDialog ./FileDialog.qml
+TextArea ./TextArea.qml
+TextEditor ./TextEditor.qml
+EditMenu ./EditMenu.qml
+MenuBar ./MenuBar.qml
+
+
+
+
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp
new file mode 100644
index 0000000000..d71e622b33
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 "dialogPlugin.h"
+#include "directory.h"
+#include "file.h"
+#include <QtQml/qqml.h>
+
+void DialogPlugin::registerTypes(const char *uri){
+
+ //register the class Directory into QML as a "Directory" element version 1.0
+ qmlRegisterType<Directory>(uri, 1, 0, "Directory");
+ qmlRegisterType<File>(uri,1,0,"File");
+
+ //qRegisterMetaType<QQmlListProperty<QString> > ("QQmlListProperty<QString>");
+
+}
+
+//FileDialog is the plugin name (same as the TARGET in the project file) and DialogPlugin is the plugin classs
+Q_EXPORT_PLUGIN2(FileDialog, DialogPlugin);
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h
new file mode 100644
index 0000000000..82035193c8
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 DIALOGPLUGIN_H
+#define DIALOGPLUGIN_H
+
+#include <QtQml/QQmlExtensionPlugin>
+
+class DialogPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+
+ public:
+ //registerTypes is inherited from QQmlExtensionPlugin
+ void registerTypes(const char *uri);
+
+};
+
+#endif
+
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp
new file mode 100644
index 0000000000..4cd9d2da85
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 "directory.h"
+#include <QDebug>
+
+/*
+Directory constructor
+
+Initialize the saves directory and creates the file list
+*/
+Directory::Directory(QObject *parent) : QObject(parent)
+{
+
+
+ m_dir.cd( QDir::currentPath());
+
+ //go to the saved directory. if not found, create save directory
+ m_saveDir = "saves";
+ if (m_dir.cd(m_saveDir) == 0){
+ m_dir.mkdir(m_saveDir);
+ m_dir.cd(m_saveDir);
+ }
+ m_filterList << "*.txt";
+
+ refresh();
+}
+
+/*
+Directory::filesNumber
+Return the number of Files
+*/
+int Directory:: filesCount() const{
+ return m_fileList.size();
+}
+
+/*
+Function called to append data onto list property
+*/
+void appendFiles(QQmlListProperty<File> * property, File * file){
+ //Do nothing. can't add to a directory using this method
+}
+
+/*
+Function called to retrieve file in the list using an index
+*/
+File* fileAt(QQmlListProperty<File> * property, int index){
+ return static_cast< QList<File *> *>(property->data)->at(index);
+}
+
+/*
+Returns the number of files in the list
+*/
+int filesSize(QQmlListProperty<File> * property){
+ return static_cast< QList<File *> *>(property->data)->size();
+}
+
+/*
+Function called to empty the list property contents
+*/
+void clearFilesPtr(QQmlListProperty<File> *property){
+ return static_cast< QList<File *> *>(property->data)->clear();
+}
+
+/*
+Returns the list of files as a QQmlListProperty.
+*/
+QQmlListProperty<File> Directory::files(){
+
+ refresh();
+// return QQmlListProperty<QString>(this,m_filePtrList); //not recommended in the docs
+ return QQmlListProperty<File>( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr );
+}
+
+/*
+Return te name of the currently selected file
+*/
+QString Directory::filename() const{
+ return currentFile.name();
+}
+
+/*
+Return the file's content as a string.
+*/
+QString Directory::fileContent() const{
+ return m_fileContent;
+}
+
+/*
+Set the file name of the current file
+*/
+void Directory::setFilename(const QString &str){
+ if(str != currentFile.name()){
+ currentFile.setName(str);
+ emit filenameChanged();
+ }
+}
+
+/*
+Set the content of the file as a string
+*/
+void Directory::setFileContent(const QString &str){
+ if(str != m_fileContent){
+ m_fileContent = str;
+ emit fileContentChanged();
+ }
+}
+
+/*
+Called from QML to save the file using the filename and file content.
+Saving makes sure that the file has a .txt extension.
+*/
+void Directory::saveFile(){
+
+ if(currentFile.name().size() == 0){
+ qWarning()<< "Empty filename. no save";
+ return;
+ }
+
+ QString extendedName = currentFile.name();
+ if(!currentFile.name().endsWith(".txt")){
+ extendedName.append(".txt");
+ }
+
+ QFile file( m_dir.filePath(extendedName) );
+ if (file.open(QFile::WriteOnly | QFile::Truncate)){
+ QTextStream outStream(&file);
+ outStream << m_fileContent;
+ }
+ file.close();
+ refresh();
+ emit directoryChanged();
+}
+
+/*
+Load the contents of a file.
+Only loads files with a .txt extension
+*/
+void Directory::loadFile(){
+
+ m_fileContent.clear();
+ QString extendedName = currentFile.name();
+ if(!currentFile.name().endsWith(".txt")){
+ extendedName.append(".txt");
+ }
+
+ QFile file( m_dir.filePath(extendedName) );
+ if (file.open(QFile::ReadOnly )){
+ QTextStream inStream(&file);
+
+ QString line;
+ do{
+ line = inStream.read(75);
+ m_fileContent.append(line);
+ }while (!line .isNull());
+ }
+ file.close();
+}
+
+/*
+Reloads the content of the files list. This is to ensure that the newly
+created files are added onto the list.
+*/
+void Directory::refresh(){
+ m_dirFiles = m_dir.entryList(m_filterList,QDir::Files,QDir::Name);
+ m_fileList.clear();
+
+ File * file;
+ for(int i = 0; i < m_dirFiles.size() ; i ++){
+
+ file = new File();
+
+ if(m_dirFiles.at(i).endsWith(".txt")){
+ QString name = m_dirFiles.at(i);
+ file->setName( name.remove(".txt",Qt::CaseSensitive));
+ }
+ else{
+ file->setName(m_dirFiles.at(i));
+ }
+ m_fileList.append(file);
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h
new file mode 100644
index 0000000000..25b121d5b3
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 DIRECTORY_H
+#define DIRECTORY_H
+
+#include "file.h"
+
+#include <QDir>
+#include <QStringList>
+#include <QTextStream>
+#include <QQmlListProperty>
+#include <QObject>
+
+class Directory : public QObject{
+
+ Q_OBJECT
+
+ //number of files in the directory
+ Q_PROPERTY(int filesCount READ filesCount)
+
+ //list property containing file names as QString
+ Q_PROPERTY(QQmlListProperty<File> files READ files CONSTANT )
+
+ //file name of the text file to read/write
+ Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
+
+ //text content of the file
+ Q_PROPERTY(QString fileContent READ fileContent WRITE setFileContent NOTIFY fileContentChanged)
+
+ public:
+ Directory(QObject *parent = 0);
+
+ //properties' read functions
+ int filesCount() const;
+ QString filename() const;
+ QString fileContent() const;
+ QQmlListProperty<File> files();
+
+ //properties' write functions
+ void setFilename(const QString &str);
+ void setFileContent(const QString &str);
+
+ //accessible from QML
+ Q_INVOKABLE void saveFile();
+ Q_INVOKABLE void loadFile();
+
+ signals:
+ void directoryChanged();
+ void filenameChanged();
+ void fileContentChanged();
+
+ private:
+ QDir m_dir;
+ QStringList m_dirFiles;
+ File currentFile;
+ QString m_saveDir;
+ QStringList m_filterList;
+
+ //contains the file data in QString format
+ QString m_fileContent;
+
+ //Registered to QML in a plugin. Accessible from QML as a property of Directory
+ QList<File *> m_fileList;
+
+ //refresh content of the directory
+ void refresh();
+};
+
+
+#endif
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp
new file mode 100644
index 0000000000..162350eb0f
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 "file.h"
+
+File::File(QObject *parent) : QObject(parent)
+{
+ m_name = "";
+}
+
+QString File::name() const{
+ return m_name;
+}
+void File::setName(const QString &str){
+ if(str != m_name){
+ m_name = str;
+ emit nameChanged();
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/file.h b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/file.h
new file mode 100644
index 0000000000..7125a9aae5
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/file.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR 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 FILE_H
+#define FILE_H
+
+
+#include <QString>
+#include <QObject>
+
+class File : public QObject{
+
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+
+ public:
+ File(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &str);
+
+ signals:
+ void nameChanged();
+
+ private:
+ QString m_name;
+};
+
+#endif
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro
new file mode 100644
index 0000000000..71abddc7e3
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro
@@ -0,0 +1,17 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml
+
+DESTDIR += ../plugins
+OBJECTS_DIR = tmp
+MOC_DIR = tmp
+
+TARGET = FileDialog
+
+HEADERS += directory.h \
+ file.h \
+ dialogPlugin.h
+
+SOURCES += directory.cpp \
+ file.cpp \
+ dialogPlugin.cpp
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/qmldir b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/qmldir
new file mode 100644
index 0000000000..4a8d13d026
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/filedialog/qmldir
@@ -0,0 +1 @@
+plugin FileDialog ../plugins
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/images/arrow.png b/examples/quick/tutorials/gettingStartedQml/parts/part5/images/arrow.png
new file mode 100644
index 0000000000..14978c2e56
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/images/arrow.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_editmenu.png b/examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_editmenu.png
new file mode 100644
index 0000000000..27feed5e82
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_editmenu.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_filemenu.png b/examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_filemenu.png
new file mode 100644
index 0000000000..4d8f9f22b2
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_filemenu.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_newfile.png b/examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_newfile.png
new file mode 100644
index 0000000000..680acfe839
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/pics/qml-texteditor5_newfile.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/qml-texteditor5.qmlproject b/examples/quick/tutorials/gettingStartedQml/parts/part5/qml-texteditor5.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/qml-texteditor5.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_editmenu.png b/examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_editmenu.png
new file mode 100644
index 0000000000..27feed5e82
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_editmenu.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_filemenu.png b/examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_filemenu.png
new file mode 100644
index 0000000000..4d8f9f22b2
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_filemenu.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_newfile.png b/examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_newfile.png
new file mode 100644
index 0000000000..680acfe839
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/pics/qml-texteditor5_newfile.png
Binary files differ
diff --git a/examples/quick/tutorials/gettingStartedQml/texteditor.qml b/examples/quick/tutorials/gettingStartedQml/texteditor.qml
new file mode 100644
index 0000000000..8e09b7fcf9
--- /dev/null
+++ b/examples/quick/tutorials/gettingStartedQml/texteditor.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "core"
+
+Rectangle {
+ id: screen
+ width: 1000; height: 1000
+ property int partition: height/3
+ border { width: 1; color: "#DCDCCC"}
+ state: "DRAWER_CLOSED"
+
+ //Item 1: MenuBar on the top portion of the screen
+ MenuBar {
+ id:menuBar
+ height: screen.partition; width: screen.width
+ z: 1
+ }
+
+ //Item 2: The editable text area
+ TextArea {
+ id: textArea
+ y: drawer.height
+ color: "#3F3F3F"
+ fontColor: "#DCDCCC"
+ height: partition*2; width:parent.width
+ }
+
+ //Item 3: The drawer handle
+ Rectangle {
+ id: drawer
+ height: 15; width: parent.width
+ border { color : "#6A6D6A"; width: 1 }
+ z: 1
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#8C8F8C" }
+ GradientStop { position: 0.17; color: "#6A6D6A" }
+ GradientStop { position: 0.77; color: "#3F3F3F" }
+ GradientStop { position: 1.0; color: "#6A6D6A" }
+ }
+ Image {
+ id: arrowIcon
+ source: "images/arrow.png"
+ anchors.horizontalCenter: parent.horizontalCenter
+ Behavior{ NumberAnimation { property: "rotation"; easing.type: Easing.OutExpo } }
+ }
+
+ MouseArea {
+ id: drawerMouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ onEntered: parent.border.color = Qt.lighter("#6A6D6A")
+ onExited: parent.border.color = "#6A6D6A"
+ onClicked: {
+ if (screen.state == "DRAWER_CLOSED") {
+ screen.state = "DRAWER_OPEN"
+ }
+ else if (screen.state == "DRAWER_OPEN"){
+ screen.state = "DRAWER_CLOSED"
+ }
+ }
+ }
+ }
+
+//! [states]
+ states:[
+ State {
+ name: "DRAWER_OPEN"
+ PropertyChanges { target: menuBar; y: 0}
+ PropertyChanges { target: textArea; y: partition + drawer.height}
+ PropertyChanges { target: drawer; y: partition}
+ PropertyChanges { target: arrowIcon; rotation: 180}
+ },
+ State {
+ name: "DRAWER_CLOSED"
+ PropertyChanges { target: menuBar; y:-height; }
+ PropertyChanges { target: textArea; y: drawer.height; height: screen.height - drawer.height }
+ PropertyChanges { target: drawer; y: 0 }
+ PropertyChanges { target: arrowIcon; rotation: 0 }
+ }
+ ]
+//! [states]
+
+//! [transitions]
+ transitions: [
+ Transition {
+ to: "*"
+ NumberAnimation { target: textArea; properties: "y, height"; duration: 100; easing.type:Easing.OutExpo }
+ NumberAnimation { target: menuBar; properties: "y"; duration: 100; easing.type: Easing.OutExpo }
+ NumberAnimation { target: drawer; properties: "y"; duration: 100; easing.type: Easing.OutExpo }
+ }
+ ]
+//! [transitions]
+}
diff --git a/examples/quick/tutorials/helloworld/Cell.qml b/examples/quick/tutorials/helloworld/Cell.qml
new file mode 100644
index 0000000000..760c468eaa
--- /dev/null
+++ b/examples/quick/tutorials/helloworld/Cell.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+//![1]
+Item {
+ id: container
+//![4]
+ property alias cellColor: rectangle.color
+//![4]
+//![5]
+ signal clicked(color cellColor)
+//![5]
+
+ width: 40; height: 25
+//![1]
+
+//![2]
+ Rectangle {
+ id: rectangle
+ border.color: "white"
+ anchors.fill: parent
+ }
+//![2]
+
+//![3]
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.clicked(container.cellColor)
+ }
+//![3]
+}
+//![0]
diff --git a/examples/quick/tutorials/helloworld/tutorial1.qml b/examples/quick/tutorials/helloworld/tutorial1.qml
new file mode 100644
index 0000000000..f55a5d50cd
--- /dev/null
+++ b/examples/quick/tutorials/helloworld/tutorial1.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+//![3]
+import QtQuick 2.0
+//![3]
+
+//![1]
+Rectangle {
+ id: page
+ width: 320; height: 480
+ color: "lightgray"
+//![1]
+
+//![2]
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+//![2]
+}
+//![0]
diff --git a/examples/quick/tutorials/helloworld/tutorial2.qml b/examples/quick/tutorials/helloworld/tutorial2.qml
new file mode 100644
index 0000000000..fbcae467c3
--- /dev/null
+++ b/examples/quick/tutorials/helloworld/tutorial2.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 320; height: 480
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+
+ Grid {
+ id: colorPicker
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
+ rows: 2; columns: 3; spacing: 3
+
+//![1]
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
+//![1]
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/helloworld/tutorial3.qml b/examples/quick/tutorials/helloworld/tutorial3.qml
new file mode 100644
index 0000000000..9b95e012a9
--- /dev/null
+++ b/examples/quick/tutorials/helloworld/tutorial3.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 320; height: 480
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+
+//![1]
+ MouseArea { id: mouseArea; anchors.fill: parent }
+//![1]
+
+//![2]
+ states: State {
+ name: "down"; when: mouseArea.pressed == true
+ PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" }
+ }
+//![2]
+
+//![3]
+ transitions: Transition {
+ from: ""; to: "down"; reversible: true
+ ParallelAnimation {
+ NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad }
+ ColorAnimation { duration: 500 }
+ }
+ }
+//![3]
+ }
+
+ Grid {
+ id: colorPicker
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
+ rows: 2; columns: 3; spacing: 3
+
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/samegame/samegame1/Block.qml b/examples/quick/tutorials/samegame/samegame1/Block.qml
new file mode 100644
index 0000000000..65cff95dbe
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame1/Block.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Item {
+ id: block
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "../shared/pics/redStone.png"
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/samegame/samegame1/Button.qml b/examples/quick/tutorials/samegame/samegame1/Button.qml
new file mode 100644
index 0000000000..6fdc6c707f
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame1/Button.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ antialiasing: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/samegame/samegame1/samegame.qml b/examples/quick/tutorials/samegame/samegame1/samegame.qml
new file mode 100644
index 0000000000..ab3aca19a2
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame1/samegame.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: console.log("This doesn't do anything yet...")
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/quick/tutorials/samegame/samegame1/samegame1.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame1/samegame1.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/tutorials/samegame/samegame2/Block.qml b/examples/quick/tutorials/samegame/samegame2/Block.qml
new file mode 100644
index 0000000000..f4065565b6
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame2/Block.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: block
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "../shared/pics/redStone.png"
+ }
+}
diff --git a/examples/quick/tutorials/samegame/samegame2/Button.qml b/examples/quick/tutorials/samegame/samegame2/Button.qml
new file mode 100644
index 0000000000..db1b52e2cd
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame2/Button.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ antialiasing: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/examples/quick/tutorials/samegame/samegame2/samegame.js b/examples/quick/tutorials/samegame/samegame2/samegame.js
new file mode 100644
index 0000000000..c749dc17b1
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame2/samegame.js
@@ -0,0 +1,63 @@
+//![0]
+var blockSize = 40;
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxColumn = Math.floor(background.width / blockSize);
+ maxRow = Math.floor(background.height / blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("Block.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(background);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.x = column * blockSize;
+ dynamicObject.y = row * blockSize;
+ dynamicObject.width = blockSize;
+ dynamicObject.height = blockSize;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+//![0]
+
diff --git a/examples/quick/tutorials/samegame/samegame2/samegame.qml b/examples/quick/tutorials/samegame/samegame2/samegame.qml
new file mode 100644
index 0000000000..85f5f39b0c
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame2/samegame.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//![2]
+import "samegame.js" as SameGame
+//![2]
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 32
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+//![1]
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+//![1]
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
diff --git a/examples/quick/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/quick/tutorials/samegame/samegame2/samegame2.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame2/samegame2.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/tutorials/samegame/samegame3/Block.qml b/examples/quick/tutorials/samegame/samegame3/Block.qml
new file mode 100644
index 0000000000..55fe7f876a
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame3/Block.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Item {
+ id: block
+
+ property int type: 0
+
+ Image {
+ id: img
+
+ anchors.fill: parent
+ source: {
+ if (type == 0)
+ return "../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../shared/pics/blueStone.png";
+ else
+ return "../shared/pics/greenStone.png";
+ }
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/samegame/samegame3/Button.qml b/examples/quick/tutorials/samegame/samegame3/Button.qml
new file mode 100644
index 0000000000..db1b52e2cd
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame3/Button.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ antialiasing: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/examples/quick/tutorials/samegame/samegame3/Dialog.qml b/examples/quick/tutorials/samegame/samegame3/Dialog.qml
new file mode 100644
index 0000000000..f89ad16ba1
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame3/Dialog.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ function show(text) {
+ dialogText.text = text;
+ container.opacity = 1;
+ }
+
+ function hide() {
+ container.opacity = 0;
+ }
+
+ width: dialogText.width + 20
+ height: dialogText.height + 20
+ opacity: 0
+
+ Text {
+ id: dialogText
+ anchors.centerIn: parent
+ text: ""
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: hide();
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/samegame/samegame3/samegame.js b/examples/quick/tutorials/samegame/samegame3/samegame.js
new file mode 100644
index 0000000000..df5bdfb049
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame3/samegame.js
@@ -0,0 +1,174 @@
+/* This script file handles the game logic */
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Calculate board size
+ maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Close dialogs
+ dialog.hide();
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("Block.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(gameCanvas);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.x = column * gameCanvas.blockSize;
+ dynamicObject.y = row * gameCanvas.blockSize;
+ dynamicObject.width = gameCanvas.blockSize;
+ dynamicObject.height = gameCanvas.blockSize;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+var fillFound; //Set after a floodFill call to the number of blocks found
+var floodBoard; //Set to 1 if the floodFill reaches off that node
+
+//![1]
+function handleClick(xPos, yPos) {
+ var column = Math.floor(xPos / gameCanvas.blockSize);
+ var row = Math.floor(yPos / gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ //If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column, row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+//![1]
+
+function floodFill(column, row, type) {
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column, row)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; //Can't remove single blocks
+ board[index(column, row)].opacity = 0;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown() {
+ //Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column, row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y += fallDist * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ var fallDist = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (var row = 0; row < maxRow; row++) {
+ var obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x -= fallDist * gameCanvas.blockSize;
+ board[index(column - fallDist, row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+//![2]
+function victoryCheck() {
+ //Award bonus points if no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+
+ //Check whether game has finished
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1)))
+ dialog.show("Game Over. Your score is " + gameCanvas.score);
+}
+//![2]
+
+//only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type) {
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
diff --git a/examples/quick/tutorials/samegame/samegame3/samegame.qml b/examples/quick/tutorials/samegame/samegame3/samegame.qml
new file mode 100644
index 0000000000..26d0212250
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame3/samegame.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+import "samegame.js" as SameGame
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+//![1]
+ Item {
+ id: gameCanvas
+
+ property int score: 0
+ property int blockSize: 40
+
+ width: parent.width - (parent.width % blockSize)
+ height: parent.height - (parent.height % blockSize)
+ anchors.centerIn: parent
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: SameGame.handleClick(mouse.x, mouse.y)
+ }
+ }
+//![1]
+ }
+
+//![2]
+ Dialog {
+ id: dialog
+ anchors.centerIn: parent
+ z: 100
+ }
+//![2]
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
+//![0]
diff --git a/examples/quick/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/quick/tutorials/samegame/samegame3/samegame3.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame3/samegame3.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/quick/tutorials/samegame/samegame4/content/BoomBlock.qml
new file mode 100644
index 0000000000..335f4aecf6
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/content/BoomBlock.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Qt.labs.particles 1.0
+
+Item {
+ id: block
+
+ property int type: 0
+ property bool dying: false
+
+ //![1]
+ property bool spawned: false
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ //![1]
+
+ //![2]
+ Image {
+ id: img
+
+ anchors.fill: parent
+ source: {
+ if (type == 0)
+ return "../../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStone.png";
+ else
+ return "../../shared/pics/greenStone.png";
+ }
+ opacity: 0
+
+ Behavior on opacity {
+ NumberAnimation { properties:"opacity"; duration: 200 }
+ }
+ }
+ //![2]
+
+ //![3]
+ Particles {
+ id: particles
+
+ width: 1; height: 1
+ anchors.centerIn: parent
+
+ emissionRate: 0
+ lifeSpan: 700; lifeSpanDeviation: 600
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation: 30
+ source: {
+ if (type == 0)
+ return "../../shared/pics/redStar.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStar.png";
+ else
+ return "../../shared/pics/greenStar.png";
+ }
+ }
+ //![3]
+
+ //![4]
+ states: [
+ State {
+ name: "AliveState"
+ when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"
+ when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+ //![4]
+}
diff --git a/examples/quick/tutorials/samegame/samegame4/content/Button.qml b/examples/quick/tutorials/samegame/samegame4/content/Button.qml
new file mode 100644
index 0000000000..db1b52e2cd
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/content/Button.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ antialiasing: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/examples/quick/tutorials/samegame/samegame4/content/Dialog.qml b/examples/quick/tutorials/samegame/samegame4/content/Dialog.qml
new file mode 100644
index 0000000000..ca4d573543
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/content/Dialog.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![0]
+Rectangle {
+ id: container
+//![0]
+
+//![1]
+ property string inputText: textInput.text
+ signal closed
+
+ function show(text) {
+ dialogText.text = text;
+ container.opacity = 1;
+ textInput.opacity = 0;
+ }
+
+ function showWithInput(text) {
+ show(text);
+ textInput.opacity = 1;
+ textInput.focus = true;
+ textInput.text = ""
+ }
+
+ function hide() {
+ textInput.focus = false;
+ container.opacity = 0;
+ container.closed();
+ }
+//![1]
+
+ width: dialogText.width + textInput.width + 20
+ height: dialogText.height + 20
+ opacity: 0
+ visible: opacity > 0
+
+ Text {
+ id: dialogText
+ anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 }
+ text: ""
+ }
+
+//![2]
+ TextInput {
+ id: textInput
+ anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
+ width: 80
+ text: ""
+
+ onAccepted: container.hide() // close dialog when Enter is pressed
+ }
+//![2]
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ if (textInput.text == "" && textInput.opacity > 0)
+ Qt.inputMethod.show();
+ else
+ hide();
+ }
+ }
+
+//![3]
+}
+//![3]
diff --git a/examples/quick/tutorials/samegame/samegame4/content/samegame.js b/examples/quick/tutorials/samegame/samegame4/content/samegame.js
new file mode 100755
index 0000000000..ad4d39d7b1
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/content/samegame.js
@@ -0,0 +1,226 @@
+/* This script file handles the game logic */
+.import QtQuick.LocalStorage 2.0 as Sql
+
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+var scoresURL = "";
+var gameDuration;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Close dialogs
+ nameInputDialog.hide();
+ dialog.hide();
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+
+ gameDuration = new Date();
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("content/BoomBlock.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(gameCanvas);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.x = column * gameCanvas.blockSize;
+ dynamicObject.y = row * gameCanvas.blockSize;
+ dynamicObject.width = gameCanvas.blockSize;
+ dynamicObject.height = gameCanvas.blockSize;
+ dynamicObject.spawned = true;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+var fillFound; //Set after a floodFill call to the number of blocks found
+var floodBoard; //Set to 1 if the floodFill reaches off that node
+
+function handleClick(xPos, yPos) {
+ var column = Math.floor(xPos / gameCanvas.blockSize);
+ var row = Math.floor(yPos / gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ //If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column, row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+
+function floodFill(column, row, type) {
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column, row)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; //Can't remove single blocks
+ board[index(column, row)].dying = true;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown() {
+ //Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column, row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row + fallDist) * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * gameCanvas.blockSize;
+ board[index(column - fallDist, row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+//![3]
+function victoryCheck() {
+//![3]
+ //Award bonus points if no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+
+//![4]
+ //Check whether game has finished
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) {
+ gameDuration = new Date() - gameDuration;
+ nameInputDialog.showWithInput("You won! Please enter your name: ");
+ }
+}
+//![4]
+
+//only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type) {
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
+//![2]
+function saveHighScore(name) {
+ if (scoresURL != "")
+ sendHighScore(name);
+
+ var db = Sql.LocalStorage.openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100);
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)];
+ db.transaction(function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for a standard sized grid\n\n"
+ for (var i = 0; i < rs.rows.length; i++) {
+ r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n';
+ }
+ dialog.show(r);
+ });
+}
+//![2]
+
+//![1]
+function sendHighScore(name) {
+ var postman = new XMLHttpRequest()
+ var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000);
+ postman.open("POST", scoresURL, true);
+ postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ postman.onreadystatechange = function() {
+ if (postman.readyState == postman.DONE) {
+ dialog.show("Your score has been uploaded.");
+ }
+ }
+ postman.send(postData);
+}
+//![1]
diff --git a/examples/quick/tutorials/samegame/samegame4/highscores/README b/examples/quick/tutorials/samegame/samegame4/highscores/README
new file mode 100644
index 0000000000..eaa00fae37
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/highscores/README
@@ -0,0 +1 @@
+The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it.
diff --git a/examples/quick/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/quick/tutorials/samegame/samegame4/highscores/score_data.xml
new file mode 100755
index 0000000000..c3fd90d9cf
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/highscores/score_data.xml
@@ -0,0 +1,2 @@
+<record><score>1000000</score><name>Alan the Tester</name><gridSize>0x0</gridSize><seconds>0</seconds></record>
+<record><score>6213</score><name>Alan</name><gridSize>12x17</gridSize><seconds>51</seconds></record>
diff --git a/examples/quick/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/quick/tutorials/samegame/samegame4/highscores/score_style.xsl
new file mode 100755
index 0000000000..670354c965
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/highscores/score_style.xsl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+ <html>
+ <head><title>SameGame High Scores</title></head>
+ <body>
+ <h2>SameGame High Scores</h2>
+ <table border="1">
+ <tr bgcolor="lightsteelblue">
+ <th>Name</th>
+ <th>Score</th>
+ <th>Grid Size</th>
+ <th>Time, s</th>
+ </tr>
+ <xsl:for-each select="records/record">
+ <xsl:sort select="score" data-type="number" order="descending"/>
+ <tr>
+ <td><xsl:value-of select="name"/></td>
+ <td><xsl:value-of select="score"/></td>
+ <td><xsl:value-of select="gridSize"/></td>
+ <td><xsl:value-of select="seconds"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/examples/quick/tutorials/samegame/samegame4/highscores/scores.php b/examples/quick/tutorials/samegame/samegame4/highscores/scores.php
new file mode 100755
index 0000000000..daf480e21b
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/highscores/scores.php
@@ -0,0 +1,31 @@
+<?php
+ $score = $_POST["score"];
+ echo "<html>";
+ echo "<head><title>SameGame High Scores</title></head><body>";
+ if($score > 0){#Sending in a new high score
+ $name = $_POST["name"];
+ $grid = $_POST["gridSize"];
+ $time = $_POST["time"];
+ if($name == "")
+ $name = "Anonymous";
+ $file = fopen("score_data.xml", "a");
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
+ . $time . "</seconds></record>\n");
+ echo "Your score has been recorded. Thanks for playing!";
+ if($ret == False)
+ echo "<br/> There was an error though, so don't expect to see that score again.";
+ }else{#Read high score list
+ #Now uses XSLT to display. So just print the file. With XML cruft added.
+ #Note that firefox at least won't apply the XSLT on a php file. So redirecting
+ $file = fopen("scores.xml", "w");
+ $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
+ . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
+ . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
+ if($ret == False)
+ echo "There was an internal error. Sorry.";
+ else
+ echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
+ }
+ echo "</body></html>";
+?>
diff --git a/examples/quick/tutorials/samegame/samegame4/samegame.qml b/examples/quick/tutorials/samegame/samegame4/samegame.qml
new file mode 100644
index 0000000000..e6edcc35b8
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/samegame.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+import "content/samegame.js" as SameGame
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ Item {
+ id: gameCanvas
+ property int score: 0
+ property int blockSize: 40
+
+ anchors.centerIn: parent
+ width: parent.width - (parent.width % blockSize);
+ height: parent.height - (parent.height % blockSize);
+
+ MouseArea {
+ anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y);
+ }
+ }
+ }
+
+ Dialog {
+ id: dialog
+ anchors.centerIn: parent
+ z: 100
+ }
+
+ //![0]
+ Dialog {
+ id: nameInputDialog
+ anchors.centerIn: parent
+ z: 100
+
+ onClosed: {
+ if (nameInputDialog.inputText != "")
+ SameGame.saveHighScore(nameInputDialog.inputText);
+ }
+ }
+ //![0]
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: " + gameCanvas.score
+ }
+ }
+}
diff --git a/examples/quick/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/quick/tutorials/samegame/samegame4/samegame4.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/quick/tutorials/samegame/samegame4/samegame4.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/tutorials/samegame/shared/pics/background.jpg b/examples/quick/tutorials/samegame/shared/pics/background.jpg
new file mode 100644
index 0000000000..903d395c8d
--- /dev/null
+++ b/examples/quick/tutorials/samegame/shared/pics/background.jpg
Binary files differ
diff --git a/examples/quick/tutorials/samegame/shared/pics/blueStar.png b/examples/quick/tutorials/samegame/shared/pics/blueStar.png
new file mode 100644
index 0000000000..ff9588f80a
--- /dev/null
+++ b/examples/quick/tutorials/samegame/shared/pics/blueStar.png
Binary files differ
diff --git a/examples/quick/tutorials/samegame/shared/pics/blueStone.png b/examples/quick/tutorials/samegame/shared/pics/blueStone.png
new file mode 100644
index 0000000000..20e43c75b6
--- /dev/null
+++ b/examples/quick/tutorials/samegame/shared/pics/blueStone.png
Binary files differ
diff --git a/examples/quick/tutorials/samegame/shared/pics/greenStar.png b/examples/quick/tutorials/samegame/shared/pics/greenStar.png
new file mode 100644
index 0000000000..cd06854719
--- /dev/null
+++ b/examples/quick/tutorials/samegame/shared/pics/greenStar.png
Binary files differ
diff --git a/examples/quick/tutorials/samegame/shared/pics/greenStone.png b/examples/quick/tutorials/samegame/shared/pics/greenStone.png
new file mode 100644
index 0000000000..b568a1900c
--- /dev/null
+++ b/examples/quick/tutorials/samegame/shared/pics/greenStone.png
Binary files differ
diff --git a/examples/quick/tutorials/samegame/shared/pics/redStar.png b/examples/quick/tutorials/samegame/shared/pics/redStar.png
new file mode 100644
index 0000000000..0a4dffe583
--- /dev/null
+++ b/examples/quick/tutorials/samegame/shared/pics/redStar.png
Binary files differ
diff --git a/examples/quick/tutorials/samegame/shared/pics/redStone.png b/examples/quick/tutorials/samegame/shared/pics/redStone.png
new file mode 100644
index 0000000000..36b09a2686
--- /dev/null
+++ b/examples/quick/tutorials/samegame/shared/pics/redStone.png
Binary files differ
diff --git a/examples/quick/tutorials/samegame/shared/pics/star.png b/examples/quick/tutorials/samegame/shared/pics/star.png
new file mode 100644
index 0000000000..defbde53ca
--- /dev/null
+++ b/examples/quick/tutorials/samegame/shared/pics/star.png
Binary files differ
diff --git a/examples/quick/tutorials/samegame/shared/pics/yellowStone.png b/examples/quick/tutorials/samegame/shared/pics/yellowStone.png
new file mode 100644
index 0000000000..b1ce76212c
--- /dev/null
+++ b/examples/quick/tutorials/samegame/shared/pics/yellowStone.png
Binary files differ
diff --git a/examples/quick/tutorials/tutorials.pro b/examples/quick/tutorials/tutorials.pro
new file mode 100644
index 0000000000..fd6117b2d0
--- /dev/null
+++ b/examples/quick/tutorials/tutorials.pro
@@ -0,0 +1,8 @@
+TEMPLATE = subdirs
+SUBDIRS += gettingStartedQml
+
+EXAMPLE_FILES = \
+ dynamicview \
+ extending \
+ helloworld \
+ samegame