diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-12 03:31:47 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-12 03:31:47 (GMT) |
commit | 381ea9c22eb8f6b3701376a650202f094e17746d (patch) | |
tree | 5c0014189bf8c14ae11ad9d246134c839c13c343 /examples | |
parent | 27f8facfea87d7c4669852e7aa0fe5d9ca828eb3 (diff) | |
parent | b6a50a14189da153e93aef581c30863608399714 (diff) | |
download | Qt-381ea9c22eb8f6b3701376a650202f094e17746d.zip Qt-381ea9c22eb8f6b3701376a650202f094e17746d.tar.gz Qt-381ea9c22eb8f6b3701376a650202f094e17746d.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (130 commits)
Warning
Read Maemo orientation at startup
Exclude gestures from examples autotest
Exclude proxywidgets from examples autotest
Fix crash on QScriptProgram destruction
doc fixes
Start documenting coding conventions
Adds missing qml file to qdeclarativeflipable autotest
Revert "Better reporting of extension plugin loading errors."
Doc
Fix graphicswidget auto-test.
Add Mac OS X bundle description for qml runtime
Cleanup
Disallow writes to read-only value type properties
Allow undefined to be assigned to QVariant properties
Add a Qt.isQtObject() method
Fix crash in QML library imports
Remove QT_VERSION checks in QML
List properties aren't read-only
Small doc fix.
...
Diffstat (limited to 'examples')
126 files changed, 714 insertions, 645 deletions
diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml index d8361ba..3616a31 100644 --- a/examples/declarative/animations/color-animation.qml +++ b/examples/declarative/animations/color-animation.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import Qt.labs.particles 1.0 Item { diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml index 8f2655e..bed4b5f9 100644 --- a/examples/declarative/animations/easing.qml +++ b/examples/declarative/animations/easing.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: window diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml index fd5eb3c..5afe8ef 100644 --- a/examples/declarative/animations/property-animation.qml +++ b/examples/declarative/animations/property-animation.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: window diff --git a/examples/declarative/aspectratio/face_fit.qml b/examples/declarative/aspectratio/face_fit.qml index 6a031a4..52cd4c2 100644 --- a/examples/declarative/aspectratio/face_fit.qml +++ b/examples/declarative/aspectratio/face_fit.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 // Here, we implement a hybrid of the "scale to fit" and "scale and crop" // behaviours which will crop up to 25% from *one* dimension if necessary diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml index 79e99e9..63fc9c6 100644 --- a/examples/declarative/aspectratio/face_fit_animated.qml +++ b/examples/declarative/aspectratio/face_fit_animated.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 // Here, we extend the "face_fit" example with animation to show how truly // diverse and usage-specific behaviours are made possible by NOT putting a @@ -19,8 +19,8 @@ Rectangle { x: (parent.width-width*scale)/2 y: (parent.height-height*scale)/2 SpringFollow on scale { - source: Math.max(Math.min(face.parent.width/face.width*1.333,face.parent.height/face.height), - Math.min(face.parent.width/face.width,face.parent.height/face.height*1.333)) + to: Math.max(Math.min(face.parent.width/face.width*1.333,face.parent.height/face.height), + Math.min(face.parent.width/face.width,face.parent.height/face.height*1.333)) spring: 1 damping: 0.05 } diff --git a/examples/declarative/aspectratio/scale_and_crop.qml b/examples/declarative/aspectratio/scale_and_crop.qml index 2e2b6ed..a438104 100644 --- a/examples/declarative/aspectratio/scale_and_crop.qml +++ b/examples/declarative/aspectratio/scale_and_crop.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 // Here, we implement "Scale and Crop" behaviour. // diff --git a/examples/declarative/aspectratio/scale_and_crop_simple.qml b/examples/declarative/aspectratio/scale_and_crop_simple.qml index e720ce7..1160ec5 100644 --- a/examples/declarative/aspectratio/scale_and_crop_simple.qml +++ b/examples/declarative/aspectratio/scale_and_crop_simple.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 // Here, we implement "Scale to Fit" behaviour, using the // fillMode property. diff --git a/examples/declarative/aspectratio/scale_and_sidecrop.qml b/examples/declarative/aspectratio/scale_and_sidecrop.qml index 8230e49..5593ab8 100644 --- a/examples/declarative/aspectratio/scale_and_sidecrop.qml +++ b/examples/declarative/aspectratio/scale_and_sidecrop.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 // Here, we implement a variant of "Scale and Crop" behaviour, where we // crop the sides if necessary to fully fit vertically, but not the reverse. diff --git a/examples/declarative/aspectratio/scale_to_fit.qml b/examples/declarative/aspectratio/scale_to_fit.qml index eae4d16..724a36e 100644 --- a/examples/declarative/aspectratio/scale_to_fit.qml +++ b/examples/declarative/aspectratio/scale_to_fit.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 // Here, we implement "Scale to Fit" behaviour "manually", rather // than using the preserveAspect property. diff --git a/examples/declarative/aspectratio/scale_to_fit_simple.qml b/examples/declarative/aspectratio/scale_to_fit_simple.qml index 7389581..0e960b4 100644 --- a/examples/declarative/aspectratio/scale_to_fit_simple.qml +++ b/examples/declarative/aspectratio/scale_to_fit_simple.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 // Here, we implement "Scale to Fit" behaviour, using the // fillMode property. diff --git a/examples/declarative/behaviors/SideRect.qml b/examples/declarative/behaviors/SideRect.qml index 7caac45..d06f73c 100644 --- a/examples/declarative/behaviors/SideRect.qml +++ b/examples/declarative/behaviors/SideRect.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: myRect diff --git a/examples/declarative/behaviors/behavior-example.qml b/examples/declarative/behaviors/behavior-example.qml index 8da1ada..b21f4f0 100644 --- a/examples/declarative/behaviors/behavior-example.qml +++ b/examples/declarative/behaviors/behavior-example.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { color: "#343434" diff --git a/examples/declarative/border-image/animated.qml b/examples/declarative/border-image/animated.qml index 29c02b3..730aeca 100644 --- a/examples/declarative/border-image/animated.qml +++ b/examples/declarative/border-image/animated.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" Rectangle { diff --git a/examples/declarative/border-image/borders.qml b/examples/declarative/border-image/borders.qml index 9879416..8956128 100644 --- a/examples/declarative/border-image/borders.qml +++ b/examples/declarative/border-image/borders.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: page diff --git a/examples/declarative/border-image/content/MyBorderImage.qml b/examples/declarative/border-image/content/MyBorderImage.qml index f0c3cfc..f65f093 100644 --- a/examples/declarative/border-image/content/MyBorderImage.qml +++ b/examples/declarative/border-image/content/MyBorderImage.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { property alias horizontalMode: image.horizontalTileMode diff --git a/examples/declarative/clocks/clocks.qml b/examples/declarative/clocks/clocks.qml index c5aa1dc..22cf820 100644 --- a/examples/declarative/clocks/clocks.qml +++ b/examples/declarative/clocks/clocks.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" Rectangle { diff --git a/examples/declarative/clocks/content/Clock.qml b/examples/declarative/clocks/content/Clock.qml index 90c6be8..036df46 100644 --- a/examples/declarative/clocks/content/Clock.qml +++ b/examples/declarative/clocks/content/Clock.qml @@ -1,14 +1,14 @@ -import Qt 4.6 +import Qt 4.7 Item { id: clock width: 200; height: 230 property alias city: cityLabel.text - property var hours - property var minutes - property var seconds - property var shift : 0 + property variant hours + property variant minutes + property variant seconds + property variant shift : 0 property bool night: false function timeChanged() { @@ -36,7 +36,7 @@ Item { origin.x: 7.5; origin.y: 73; angle: 0 SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 - source: (clock.hours * 30) + (clock.minutes * 0.5) + to: (clock.hours * 30) + (clock.minutes * 0.5) } } } @@ -50,7 +50,7 @@ Item { origin.x: 6.5; origin.y: 83; angle: 0 SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 - source: clock.minutes * 6 + to: clock.minutes * 6 } } } @@ -64,7 +64,7 @@ Item { origin.x: 2.5; origin.y: 80; angle: 0 SpringFollow on angle { spring: 5; damping: 0.25; modulus: 360 - source: clock.seconds * 6 + to: clock.seconds * 6 } } } diff --git a/examples/declarative/connections/connections-example.qml b/examples/declarative/connections/connections-example.qml index c35bda5..0b4ca45 100644 --- a/examples/declarative/connections/connections-example.qml +++ b/examples/declarative/connections/connections-example.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" Rectangle { diff --git a/examples/declarative/connections/content/Button.qml b/examples/declarative/connections/content/Button.qml index 0e33c78..f95afbb 100644 --- a/examples/declarative/connections/content/Button.qml +++ b/examples/declarative/connections/content/Button.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: button diff --git a/examples/declarative/dial/content/Dial.qml b/examples/declarative/dial/content/Dial.qml index ad4717a..f9ab3e3 100644 --- a/examples/declarative/dial/content/Dial.qml +++ b/examples/declarative/dial/content/Dial.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: root @@ -29,7 +29,7 @@ Item { SpringFollow on angle { spring: 1.4 damping: .15 - source: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + to: Math.min(Math.max(-130, root.value*2.6 - 130), 133) } } } diff --git a/examples/declarative/dial/dial-example.qml b/examples/declarative/dial/dial-example.qml index 3aed70e..1ca958a 100644 --- a/examples/declarative/dial/dial-example.qml +++ b/examples/declarative/dial/dial-example.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" Rectangle { diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index 7de4d38..7331b3f 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import Qt.labs.particles 1.0 import "qml" @@ -110,7 +110,7 @@ Item { focusOnPress: true font.pixelSize: 14 - text: "import Qt 4.6\nImage {\n id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n NumberAnimation on opacity { \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}" + text: "import Qt 4.7\nImage {\n id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n NumberAnimation on opacity { \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}" } Button { text: "Create" diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml index 757e295..53588bb 100644 --- a/examples/declarative/dynamic/qml/Button.qml +++ b/examples/declarative/dynamic/qml/Button.qml @@ -1,9 +1,9 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: container - property var text + property variant text signal clicked SystemPalette { id: activePalette } diff --git a/examples/declarative/dynamic/qml/GenericItem.qml b/examples/declarative/dynamic/qml/GenericItem.qml index 10e3dba..faac06d 100644 --- a/examples/declarative/dynamic/qml/GenericItem.qml +++ b/examples/declarative/dynamic/qml/GenericItem.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item{ property bool created: false diff --git a/examples/declarative/dynamic/qml/PaletteItem.qml b/examples/declarative/dynamic/qml/PaletteItem.qml index 08bdc40..e8f2ed4 100644 --- a/examples/declarative/dynamic/qml/PaletteItem.qml +++ b/examples/declarative/dynamic/qml/PaletteItem.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "itemCreation.js" as Code GenericItem { diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml index a0dfad3..3cbe64a 100644 --- a/examples/declarative/dynamic/qml/PerspectiveItem.qml +++ b/examples/declarative/dynamic/qml/PerspectiveItem.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Image { id: tree diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml index 81b6e9b..3627964 100644 --- a/examples/declarative/dynamic/qml/Sun.qml +++ b/examples/declarative/dynamic/qml/Sun.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Image { id: sun diff --git a/examples/declarative/effects/effects.qml b/examples/declarative/effects/effects.qml index 2280a2a..d325e11 100644 --- a/examples/declarative/effects/effects.qml +++ b/examples/declarative/effects/effects.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { color: "white" diff --git a/examples/declarative/fillmode/fillmode.qml b/examples/declarative/fillmode/fillmode.qml index 3f2020c..249674b 100644 --- a/examples/declarative/fillmode/fillmode.qml +++ b/examples/declarative/fillmode/fillmode.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Image { width: 400 diff --git a/examples/declarative/flipable/content/Card.qml b/examples/declarative/flipable/content/Card.qml index 6b8fa69..2577d89 100644 --- a/examples/declarative/flipable/content/Card.qml +++ b/examples/declarative/flipable/content/Card.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Flipable { id: container diff --git a/examples/declarative/flipable/flipable-example.qml b/examples/declarative/flipable/flipable-example.qml index eebc721..171353f 100644 --- a/examples/declarative/flipable/flipable-example.qml +++ b/examples/declarative/flipable/flipable-example.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" Rectangle { diff --git a/examples/declarative/focus/Core/ContextMenu.qml b/examples/declarative/focus/Core/ContextMenu.qml index bd6d8a2..56a1b3e 100644 --- a/examples/declarative/focus/Core/ContextMenu.qml +++ b/examples/declarative/focus/Core/ContextMenu.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 FocusScope { id: container diff --git a/examples/declarative/focus/Core/GridMenu.qml b/examples/declarative/focus/Core/GridMenu.qml index 03d837a..75f6be0 100644 --- a/examples/declarative/focus/Core/GridMenu.qml +++ b/examples/declarative/focus/Core/GridMenu.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 FocusScope { property alias interactive: gridView.interactive diff --git a/examples/declarative/focus/Core/ListViewDelegate.qml b/examples/declarative/focus/Core/ListViewDelegate.qml index b7e067a..35c04cf 100644 --- a/examples/declarative/focus/Core/ListViewDelegate.qml +++ b/examples/declarative/focus/Core/ListViewDelegate.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Component { Item { diff --git a/examples/declarative/focus/Core/ListViews.qml b/examples/declarative/focus/Core/ListViews.qml index 3cc4836..b28cc1c 100644 --- a/examples/declarative/focus/Core/ListViews.qml +++ b/examples/declarative/focus/Core/ListViews.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 FocusScope { clip: true diff --git a/examples/declarative/focus/Core/qmldir b/examples/declarative/focus/Core/qmldir index 0460d9c..e25d63c 100644 --- a/examples/declarative/focus/Core/qmldir +++ b/examples/declarative/focus/Core/qmldir @@ -1,4 +1,4 @@ ContextMenu ContextMenu.qml GridMenu GridMenu.qml -ListViews Listviews.qml +ListViews ListViews.qml ListViewDelegate ListViewDelegate.qml diff --git a/examples/declarative/focus/focus.qml b/examples/declarative/focus/focus.qml index a8dc3c8..d9b6549 100644 --- a/examples/declarative/focus/focus.qml +++ b/examples/declarative/focus/focus.qml @@ -1,5 +1,5 @@ -import Qt 4.6 -import "Core" 1.0 +import Qt 4.7 +import "Core" Rectangle { id: window; width: 800; height: 480; color: "#3E606F" diff --git a/examples/declarative/fonts/banner.qml b/examples/declarative/fonts/banner.qml index 957246f..b7f5344 100644 --- a/examples/declarative/fonts/banner.qml +++ b/examples/declarative/fonts/banner.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: screen diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index e928df4..49c3d0a 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { property string myText: "The quick brown fox jumps over the lazy dog." diff --git a/examples/declarative/fonts/hello.qml b/examples/declarative/fonts/hello.qml index e15a0f0..9d926fb 100644 --- a/examples/declarative/fonts/hello.qml +++ b/examples/declarative/fonts/hello.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: screen; width: 800; height: 480; color: "black" diff --git a/examples/declarative/gestures/experimental-gestures.qml b/examples/declarative/gestures/experimental-gestures.qml index 914d403..cb190ea 100644 --- a/examples/declarative/gestures/experimental-gestures.qml +++ b/examples/declarative/gestures/experimental-gestures.qml @@ -5,9 +5,18 @@ import Qt.labs.gestures 1.0 Rectangle { id: rect + width: 320 + height: 180 + + Text { + anchors.centerIn: parent + text: "Tap / TapAndHold / Pan / Pinch / Swipe\nOnly works on platforms with Touch support." + horizontalAlignment: Text.Center + } GestureArea { anchors.fill: parent + focus: true // Only some of the many gesture properties are shown. See Gesture documentation. diff --git a/examples/declarative/gridview/gridview-example.qml b/examples/declarative/gridview/gridview-example.qml index 93931c7..fd5f430 100644 --- a/examples/declarative/gridview/gridview-example.qml +++ b/examples/declarative/gridview/gridview-example.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { width: 300; height: 400; color: "white" diff --git a/examples/declarative/imageprovider/imageprovider-example.qml b/examples/declarative/imageprovider/imageprovider-example.qml index a895821..9d22576 100644 --- a/examples/declarative/imageprovider/imageprovider-example.qml +++ b/examples/declarative/imageprovider/imageprovider-example.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "ImageProviderCore" //![0] ListView { diff --git a/examples/declarative/images/images.qml b/examples/declarative/images/images.qml index 35ce1ab..7980088 100644 --- a/examples/declarative/images/images.qml +++ b/examples/declarative/images/images.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { color: "white" diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml index 7cbf68a..0f08893 100644 --- a/examples/declarative/layouts/Button.qml +++ b/examples/declarative/layouts/Button.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { border.color: "black"; color: "steelblue"; radius: 5; width: pix.width + textelement.width + 13; height: pix.height + 10; id: page property string text diff --git a/examples/declarative/layouts/layouts.qml b/examples/declarative/layouts/layouts.qml index 4b2a3f8..1d34afd 100644 --- a/examples/declarative/layouts/layouts.qml +++ b/examples/declarative/layouts/layouts.qml @@ -1,30 +1,25 @@ -import Qt 4.6 +import Qt 4.7 import Qt.widgets 4.6 Item { id: resizable width:400 height:400 + QGraphicsWidget { + size.width:parent.width + size.height:parent.height - GraphicsObjectContainer { - anchors.fill:parent - - QGraphicsWidget { - size.width:parent.width - size.height:parent.height - - layout: QGraphicsLinearLayout { - LayoutItem { - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { color: "yellow"; anchors.fill: parent } - } - LayoutItem { - minimumSize: "100x100" - maximumSize: "400x400" - preferredSize: "200x200" - Rectangle { color: "green"; anchors.fill: parent } - } + layout: QGraphicsLinearLayout { + LayoutItem { + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rectangle { color: "yellow"; anchors.fill: parent } + } + LayoutItem { + minimumSize: "100x100" + maximumSize: "400x400" + preferredSize: "200x200" + Rectangle { color: "green"; anchors.fill: parent } } } } diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml index bce53bd..ef225d0 100644 --- a/examples/declarative/layouts/positioners.qml +++ b/examples/declarative/layouts/positioners.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: page diff --git a/examples/declarative/listmodel-threaded/timedisplay.qml b/examples/declarative/listmodel-threaded/timedisplay.qml index e8d8fe2..848192e 100644 --- a/examples/declarative/listmodel-threaded/timedisplay.qml +++ b/examples/declarative/listmodel-threaded/timedisplay.qml @@ -1,5 +1,5 @@ // ![0] -import Qt 4.6 +import Qt 4.7 ListView { width: 200 diff --git a/examples/declarative/listview/content/ClickAutoRepeating.qml b/examples/declarative/listview/content/ClickAutoRepeating.qml index cbf1f3b..f65c2b3 100644 --- a/examples/declarative/listview/content/ClickAutoRepeating.qml +++ b/examples/declarative/listview/content/ClickAutoRepeating.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: page diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml index e9065c1..a625b4c 100644 --- a/examples/declarative/listview/content/MediaButton.qml +++ b/examples/declarative/listview/content/MediaButton.qml @@ -1,7 +1,7 @@ -import Qt 4.6 +import Qt 4.7 Item { - property var text + property variant text signal clicked id: container diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml index 1ac37bb..f15dda3 100644 --- a/examples/declarative/listview/dummydata/MyPetsModel.qml +++ b/examples/declarative/listview/dummydata/MyPetsModel.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 // ListModel allows free form list models to be defined and populated. diff --git a/examples/declarative/listview/dummydata/Recipes.qml b/examples/declarative/listview/dummydata/Recipes.qml index 68e94ac..f707c82 100644 --- a/examples/declarative/listview/dummydata/Recipes.qml +++ b/examples/declarative/listview/dummydata/Recipes.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 ListModel { id: recipesModel diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml index 81550d7..32483fa 100644 --- a/examples/declarative/listview/dynamic.qml +++ b/examples/declarative/listview/dynamic.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" import "../scrollbar" diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml index 5e4911d..2b54dd8 100644 --- a/examples/declarative/listview/highlight.qml +++ b/examples/declarative/listview/highlight.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { width: 400; height: 300; color: "white" @@ -44,7 +44,7 @@ Rectangle { id: petHighlight Rectangle { width: 200; height: 50; color: "#FFFF88" - SpringFollow on y { source: list1.currentItem.y; spring: 3; damping: 0.1 } + SpringFollow on y { to: list1.currentItem.y; spring: 3; damping: 0.1 } } } ListView { diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml index 41aa860..2f4aa31 100644 --- a/examples/declarative/listview/itemlist.qml +++ b/examples/declarative/listview/itemlist.qml @@ -1,7 +1,7 @@ // This example demonstrates placing items in a view using // a VisualItemModel -import Qt 4.6 +import Qt 4.7 Rectangle { color: "lightgray" diff --git a/examples/declarative/listview/listview-example.qml b/examples/declarative/listview/listview-example.qml index 92acce1..d648b60 100644 --- a/examples/declarative/listview/listview-example.qml +++ b/examples/declarative/listview/listview-example.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { width: 600; height: 300; color: "white" diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index b76a9ab..66c4109 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" // This example illustrates expanding a list item to show a more detailed view @@ -60,7 +60,9 @@ Rectangle { opacity: wrapper.detailsOpacity } Text { - text: ingredients; wrap: true; width: parent.width + text: ingredients + wrapMode: Text.WordWrap + width: parent.width opacity: wrapper.detailsOpacity } } @@ -82,7 +84,7 @@ Rectangle { id: flick anchors.top: methodTitle.bottom; anchors.bottom: parent.bottom width: parent.width; contentHeight: methodText.height; clip: true - Text { id: methodText; text: method; wrap: true; width: details.width } + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } } Image { anchors.right: flick.right; anchors.top: flick.top diff --git a/examples/declarative/listview/sections.qml b/examples/declarative/listview/sections.qml index 877026b..7c132a4 100644 --- a/examples/declarative/listview/sections.qml +++ b/examples/declarative/listview/sections.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 //! [0] Rectangle { diff --git a/examples/declarative/mousearea/mouse.qml b/examples/declarative/mousearea/mouse.qml index 9191f8a..efbfb53 100644 --- a/examples/declarative/mousearea/mouse.qml +++ b/examples/declarative/mousearea/mouse.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { color: "white" diff --git a/examples/declarative/objectlistmodel/view.qml b/examples/declarative/objectlistmodel/view.qml index 5f5e415..908e388 100644 --- a/examples/declarative/objectlistmodel/view.qml +++ b/examples/declarative/objectlistmodel/view.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 ListView { width: 100 diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml index f35314f..785fde6 100644 --- a/examples/declarative/package/Delegate.qml +++ b/examples/declarative/package/Delegate.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 //![0] Package { diff --git a/examples/declarative/package/view.qml b/examples/declarative/package/view.qml index 07bba0c..67f896b 100644 --- a/examples/declarative/package/view.qml +++ b/examples/declarative/package/view.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { width: 400 diff --git a/examples/declarative/parallax/parallax.qml b/examples/declarative/parallax/parallax.qml index 6193f27..cb0437d 100644 --- a/examples/declarative/parallax/parallax.qml +++ b/examples/declarative/parallax/parallax.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "../clocks/content" import "qml" diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml index 08193ae..8f5f290 100644 --- a/examples/declarative/parallax/qml/ParallaxView.qml +++ b/examples/declarative/parallax/qml/ParallaxView.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: root diff --git a/examples/declarative/parallax/qml/Smiley.qml b/examples/declarative/parallax/qml/Smiley.qml index c13b879..b1e1ae8 100644 --- a/examples/declarative/parallax/qml/Smiley.qml +++ b/examples/declarative/parallax/qml/Smiley.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: window diff --git a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml index 622fcf9..0048372 100644 --- a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml +++ b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml @@ -1,13 +1,13 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: clock width: 200; height: 200; color: "gray" property alias city: cityLabel.text - property var hours - property var minutes - property var shift : 0 + property variant hours + property variant minutes + property variant shift : 0 Image { id: background; source: "clock.png" } @@ -20,7 +20,7 @@ Rectangle { origin.x: 7.5; origin.y: 73; angle: 0 SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 - source: (clock.hours * 30) + (clock.minutes * 0.5) + to: (clock.hours * 30) + (clock.minutes * 0.5) } } } @@ -34,7 +34,7 @@ Rectangle { origin.x: 6.5; origin.y: 83; angle: 0 SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 - source: clock.minutes * 6 + to: clock.minutes * 6 } } } diff --git a/examples/declarative/progressbar/content/ProgressBar.qml b/examples/declarative/progressbar/content/ProgressBar.qml index aafb12e..d82d89d 100644 --- a/examples/declarative/progressbar/content/ProgressBar.qml +++ b/examples/declarative/progressbar/content/ProgressBar.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: progressbar diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml index c8022b0..e10c9f0 100644 --- a/examples/declarative/progressbar/progressbars.qml +++ b/examples/declarative/progressbar/progressbars.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" Rectangle { diff --git a/examples/declarative/proxywidgets/proxywidgets.qml b/examples/declarative/proxywidgets/proxywidgets.qml index 023de71..6fa0c40 100644 --- a/examples/declarative/proxywidgets/proxywidgets.qml +++ b/examples/declarative/proxywidgets/proxywidgets.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "ProxyWidgets" 1.0 Rectangle { diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml index 802b537..2186b35 100644 --- a/examples/declarative/scrollbar/ScrollBar.qml +++ b/examples/declarative/scrollbar/ScrollBar.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: scrollBar @@ -9,7 +9,7 @@ Item { // orientation can be either 'Vertical' or 'Horizontal' property real position property real pageSize - property var orientation : "Vertical" + property variant orientation : "Vertical" // A light, semi-transparent background Rectangle { diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml index 84763d2..421cb7f 100644 --- a/examples/declarative/scrollbar/display.qml +++ b/examples/declarative/scrollbar/display.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { width: 640 diff --git a/examples/declarative/searchbox/SearchBox.qml b/examples/declarative/searchbox/SearchBox.qml index 524b652..be85023 100644 --- a/examples/declarative/searchbox/SearchBox.qml +++ b/examples/declarative/searchbox/SearchBox.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 FocusScope { id: focusScope diff --git a/examples/declarative/searchbox/main.qml b/examples/declarative/searchbox/main.qml index 9b33be3..eb95a23 100644 --- a/examples/declarative/searchbox/main.qml +++ b/examples/declarative/searchbox/main.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { width: 500; height: 250; color: "#edecec" diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml index 758aee6..e16198d 100644 --- a/examples/declarative/slideswitch/content/Switch.qml +++ b/examples/declarative/slideswitch/content/Switch.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 Item { id: toggleswitch diff --git a/examples/declarative/slideswitch/slideswitch.qml b/examples/declarative/slideswitch/slideswitch.qml index 396749f..51c3c77 100644 --- a/examples/declarative/slideswitch/slideswitch.qml +++ b/examples/declarative/slideswitch/slideswitch.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" Rectangle { diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml index 29e084c..a9f77ca 100644 --- a/examples/declarative/sql/hello.qml +++ b/examples/declarative/sql/hello.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Text { function findGreetings() { diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml index 89f2421..c35cd63 100644 --- a/examples/declarative/states/states.qml +++ b/examples/declarative/states/states.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: page diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml index 8ad61ad..3cb5543 100644 --- a/examples/declarative/states/transitions.qml +++ b/examples/declarative/states/transitions.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: page diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml index f0f7164..e6b40fd 100644 --- a/examples/declarative/tabwidget/TabWidget.qml +++ b/examples/declarative/tabwidget/TabWidget.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: tabWidget diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml index 1d11b03..e1bbdef 100644 --- a/examples/declarative/tabwidget/tabs.qml +++ b/examples/declarative/tabwidget/tabs.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 TabWidget { id: tabs @@ -13,7 +13,7 @@ TabWidget { Text { anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter text: "Roses are red"; font.pixelSize: 20 - wrap: true; width: parent.width - 20 + wrapMode: Text.WordWrap; width: parent.width - 20 } } } @@ -27,7 +27,7 @@ TabWidget { Text { anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter text: "Flower stems are green"; font.pixelSize: 20 - wrap: true; width: parent.width - 20 + wrapMode: Text.WordWrap; width: parent.width - 20 } } } @@ -41,7 +41,7 @@ TabWidget { Text { anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter text: "Violets are blue"; font.pixelSize: 20 - wrap: true; width: parent.width - 20 + wrapMode: Text.WordWrap; width: parent.width - 20 } } } diff --git a/examples/declarative/tic-tac-toe/content/Button.qml b/examples/declarative/tic-tac-toe/content/Button.qml index cfc2f04..05d3f8d 100644 --- a/examples/declarative/tic-tac-toe/content/Button.qml +++ b/examples/declarative/tic-tac-toe/content/Button.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: container diff --git a/examples/declarative/tic-tac-toe/content/TicTac.qml b/examples/declarative/tic-tac-toe/content/TicTac.qml index ccb7b78..d247943 100644 --- a/examples/declarative/tic-tac-toe/content/TicTac.qml +++ b/examples/declarative/tic-tac-toe/content/TicTac.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { signal clicked diff --git a/examples/declarative/tic-tac-toe/content/pics/board.png b/examples/declarative/tic-tac-toe/content/pics/board.png Binary files differindex e7a7324..29118a9 100644 --- a/examples/declarative/tic-tac-toe/content/pics/board.png +++ b/examples/declarative/tic-tac-toe/content/pics/board.png diff --git a/examples/declarative/tic-tac-toe/content/tic-tac-toe.js b/examples/declarative/tic-tac-toe/content/tic-tac-toe.js new file mode 100644 index 0000000..f8d6d9f --- /dev/null +++ b/examples/declarative/tic-tac-toe/content/tic-tac-toe.js @@ -0,0 +1,145 @@ +function winner(board) +{ + for (var i=0; i<3; ++i) { + if (board.children[i].state!="" + && board.children[i].state==board.children[i+3].state + && board.children[i].state==board.children[i+6].state) + return true + + if (board.children[i*3].state!="" + && board.children[i*3].state==board.children[i*3+1].state + && board.children[i*3].state==board.children[i*3+2].state) + return true + } + + if (board.children[0].state!="" + && board.children[0].state==board.children[4].state!="" + && board.children[0].state==board.children[8].state!="") + return true + + if (board.children[2].state!="" + && board.children[2].state==board.children[4].state!="" + && board.children[2].state==board.children[6].state!="") + return true + + return false +} + +function restart() +{ + // No moves left - start again + for (var i=0; i<9; ++i) + board.children[i].state = "" +} + +function makeMove(pos,player) +{ + board.children[pos].state = player + if (winner(board)) { + win(player + " wins") + return true + } else { + return false + } +} + +function computerTurn() +{ + var r = Math.random(); + if(r < game.difficulty){ + smartAI(); + }else{ + randAI(); + } +} + +function smartAI() +{ + function boardCopy(a){ + var ret = new Object; + ret.children = new Array(9); + for(var i = 0; i<9; i++){ + ret.children[i] = new Object; + ret.children[i].state = a.children[i].state; + } + return ret; + } + for(var i=0; i<9; i++){ + var simpleBoard = boardCopy(board); + if (board.children[i].state == "") { + simpleBoard.children[i].state = "O"; + if(winner(simpleBoard)){ + makeMove(i,"O") + return + } + } + } + for(var i=0; i<9; i++){ + var simpleBoard = boardCopy(board); + if (board.children[i].state == "") { + simpleBoard.children[i].state = "X"; + if(winner(simpleBoard)){ + makeMove(i,"O") + return + } + } + } + function thwart(a,b,c){//If they are at a, try b or c + if (board.children[a].state == "X") { + if (board.children[b].state == "") { + makeMove(b,"O") + return true + }else if (board.children[c].state == "") { + makeMove(c,"O") + return true + } + } + return false; + } + if(thwart(4,0,2)) return; + if(thwart(0,4,3)) return; + if(thwart(2,4,1)) return; + if(thwart(6,4,7)) return; + if(thwart(8,4,5)) return; + if(thwart(1,4,2)) return; + if(thwart(3,4,0)) return; + if(thwart(5,4,8)) return; + if(thwart(7,4,6)) return; + for(var i =0; i<9; i++){//Backup + if (board.children[i].state == "") { + makeMove(i,"O") + return + } + } + restart(); +} + +function randAI() +{ + var open = 0; + for (var i=0; i<9; ++i) + if (board.children[i].state == "") { + open += 1; + } + if(open == 0){ + restart(); + return; + } + var openA = new Array(open);//JS doesn't have lists I can append to (i think) + var acc = 0; + for (var i=0; i<9; ++i) + if (board.children[i].state == "") { + openA[acc] = i; + acc += 1; + } + var choice = openA[Math.floor(Math.random() * open)]; + makeMove(choice, "O"); +} + +function win(s) +{ + msg.text = s + msg.opacity = 1 + endtimer.running = true +} + diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/tic-tac-toe/tic-tac-toe.qml index 4bb1e3f..ca66a46 100644 --- a/examples/declarative/tic-tac-toe/tic-tac-toe.qml +++ b/examples/declarative/tic-tac-toe/tic-tac-toe.qml @@ -1,6 +1,6 @@ -import Qt 4.6 +import Qt 4.7 import "content" -import "tic-tac-toe.js" as Logic +import "content/tic-tac-toe.js" as Logic Item { id: game diff --git a/examples/declarative/tutorials/helloworld/Cell.qml b/examples/declarative/tutorials/helloworld/Cell.qml index 9249ffe..1e52a67 100644 --- a/examples/declarative/tutorials/helloworld/Cell.qml +++ b/examples/declarative/tutorials/helloworld/Cell.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 //![1] Item { diff --git a/examples/declarative/tutorials/helloworld/tutorial1.qml b/examples/declarative/tutorials/helloworld/tutorial1.qml index 93d3c34..5e27b45 100644 --- a/examples/declarative/tutorials/helloworld/tutorial1.qml +++ b/examples/declarative/tutorials/helloworld/tutorial1.qml @@ -1,6 +1,6 @@ //![0] //![3] -import Qt 4.6 +import Qt 4.7 //![3] //![1] diff --git a/examples/declarative/tutorials/helloworld/tutorial2.qml b/examples/declarative/tutorials/helloworld/tutorial2.qml index 38447e2..085efa4 100644 --- a/examples/declarative/tutorials/helloworld/tutorial2.qml +++ b/examples/declarative/tutorials/helloworld/tutorial2.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 Rectangle { id: page diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml index d851c49..4bf4970 100644 --- a/examples/declarative/tutorials/helloworld/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/tutorial3.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 Rectangle { id: page diff --git a/examples/declarative/tutorials/samegame/samegame1/Block.qml b/examples/declarative/tutorials/samegame/samegame1/Block.qml index f133b17..7cf819b 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Block.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 Item { id:block diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml index 5e28da7..8ad7c0f 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 Rectangle { id: container @@ -8,20 +8,21 @@ Rectangle { property string text: "Button" color: activePalette.button; smooth: true - width: txtItem.width + 20; height: txtItem.height + 6 + width: buttonLabel.width + 20; height: buttonLabel.height + 6 border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; gradient: Gradient { GradientStop { - id: topGrad; position: 0.0 - color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } } + position: 0.0 + color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } + } GradientStop { position: 1.0; color: activePalette.button } } MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } Text { - id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText + id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } } //![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml index 006b926..ae881ba 100644 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 Rectangle { id: screen @@ -24,7 +24,7 @@ Rectangle { anchors.bottom: screen.bottom Button { - id: btnA; text: "New Game"; onClicked: console.log("Starting a new game..."); + text: "New Game"; onClicked: console.log("Starting a new game..."); anchors.left: parent.left; anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter } diff --git a/examples/declarative/tutorials/samegame/samegame2/Block.qml b/examples/declarative/tutorials/samegame/samegame2/Block.qml index e4b3354..44ff5d7 100644 --- a/examples/declarative/tutorials/samegame/samegame2/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame2/Block.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id:block diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml index a7853d4..cf4c61b 100644 --- a/examples/declarative/tutorials/samegame/samegame2/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: container @@ -7,19 +7,20 @@ Rectangle { property string text: "Button" color: activePalette.button; smooth: true - width: txtItem.width + 20; height: txtItem.height + 6 + width: buttonLabel.width + 20; height: buttonLabel.height + 6 border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; gradient: Gradient { GradientStop { - id: topGrad; position: 0.0 - color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } } + position: 0.0 + color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } + } GradientStop { position: 1.0; color: activePalette.button } } MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } Text { - id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText + id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } } diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js index 0ec3a8b..9809c1d 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.js @@ -1,63 +1,59 @@ //![0] -//Note that X/Y referred to here are in game coordinates -var maxX = 10;//Nums are for tileSize 40 -var maxY = 15; -var tileSize = 40; -var maxIndex = maxX*maxY; +var blockSize = 40; +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; var board = new Array(maxIndex); -var tileSrc = "Block.qml"; var component; //Index function used instead of a 2D array -function index(xIdx,yIdx) { - return xIdx + (yIdx * maxX); +function index(column, row) { + return column + (row * maxColumn); } -function initBoard() -{ - //Delete old blocks - for(var i = 0; i<maxIndex; i++){ - if(board[i] != null) +function startNewGame() { + //Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) board[i].destroy(); } //Calculate board size - maxX = Math.floor(background.width/tileSize); - maxY = Math.floor(background.height/tileSize); - maxIndex = maxY*maxX; + maxColumn = Math.floor(background.width / blockSize); + maxRow = Math.floor(background.height / blockSize); + maxIndex = maxRow * maxColumn; //Initialize Board board = new Array(maxIndex); - for(var xIdx=0; xIdx<maxX; xIdx++){ - for(var yIdx=0; yIdx<maxY; yIdx++){ - board[index(xIdx,yIdx)] = null; - createBlock(xIdx,yIdx); + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); } } } -function createBlock(xIdx,yIdx){ - if(component==null) - component = createComponent(tileSrc); +function createBlock(column, row) { + if (component == null) + component = createComponent("Block.qml"); - // Note that we don't wait for the component to become ready. This will - // only work if the block QML is a local file. Otherwise the component will - // not be ready immediately. There is a statusChanged signal on the - // component you could use if you want to wait to load remote files. - if(component.isReady){ + // Note that if Block.qml was not a local file, component.isReady would be + // false and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and fully loaded before calling createObject(). + if (component.isReady) { var dynamicObject = component.createObject(); - if(dynamicObject == null){ + if (dynamicObject == null) { print("error creating block"); print(component.errorsString()); return false; } dynamicObject.parent = background; - dynamicObject.x = xIdx*tileSize; - dynamicObject.y = yIdx*tileSize; - dynamicObject.width = tileSize; - dynamicObject.height = tileSize; - board[index(xIdx,yIdx)] = dynamicObject; - }else{//isError or isLoading + dynamicObject.x = column * blockSize; + dynamicObject.y = row * blockSize; + dynamicObject.width = blockSize; + dynamicObject.height = blockSize; + board[index(column, row)] = dynamicObject; + } else { print("error loading block component"); print(component.errorsString()); return false; @@ -65,3 +61,4 @@ function createBlock(xIdx,yIdx){ return true; } //![0] + diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml index 89d8035..e0706c2 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 //![2] import "samegame.js" as SameGame //![2] @@ -27,7 +27,7 @@ Rectangle { //![1] Button { - id: btnA; text: "New Game"; onClicked: SameGame.initBoard(); + text: "New Game"; onClicked: SameGame.startNewGame(); anchors.left: parent.left; anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter } diff --git a/examples/declarative/tutorials/samegame/samegame3/Block.qml b/examples/declarative/tutorials/samegame/samegame3/Block.qml index 7620104..bb48ac8 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Block.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 Item { id:block diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml index a7853d4..cf4c61b 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: container @@ -7,19 +7,20 @@ Rectangle { property string text: "Button" color: activePalette.button; smooth: true - width: txtItem.width + 20; height: txtItem.height + 6 + width: buttonLabel.width + 20; height: buttonLabel.height + 6 border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; gradient: Gradient { GradientStop { - id: topGrad; position: 0.0 - color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } } + position: 0.0 + color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } + } GradientStop { position: 1.0; color: activePalette.button } } MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } Text { - id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText + id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } } diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml index 966f85a..a76b517 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 Rectangle { id: page @@ -8,16 +8,16 @@ Rectangle { page.opacity = 0; } function show(txt) { - myText.text = txt; + dialogText.text = txt; page.opacity = 1; } signal closed(); - color: "white"; border.width: 1; width: myText.width + 20; height: 60; + color: "white"; border.width: 1; width: dialogText.width + 20; height: dialogText.height + 20; opacity: 0 Behavior on opacity { NumberAnimation { duration: 1000 } } - Text { id: myText; anchors.centerIn: parent; text: "Hello World!" } - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: forceClose(); } + Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" } + MouseArea { anchors.fill: parent; onClicked: forceClose(); } } //![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js index 33449fa..c12def7 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js @@ -1,23 +1,20 @@ /* This script file handles the game logic */ -//Note that X/Y referred to here are in game coordinates -var maxX = 10;//Nums are for tileSize 40 -var maxY = 15; -var maxIndex = maxX*maxY; +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; var board = new Array(maxIndex); -var tileSrc = "Block.qml"; var component; //Index function used instead of a 2D array -function index(xIdx,yIdx) { - return xIdx + (yIdx * maxX); +function index(column, row) { + return column + (row * maxColumn); } -function initBoard() -{ +function startNewGame() { //Calculate board size - maxX = Math.floor(gameCanvas.width/gameCanvas.tileSize); - maxY = Math.floor(gameCanvas.height/gameCanvas.tileSize); - maxIndex = maxY*maxX; + maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; //Close dialogs dialog.forceClose(); @@ -25,37 +22,36 @@ function initBoard() //Initialize Board board = new Array(maxIndex); gameCanvas.score = 0; - for(var xIdx=0; xIdx<maxX; xIdx++){ - for(var yIdx=0; yIdx<maxY; yIdx++){ - board[index(xIdx,yIdx)] = null; - createBlock(xIdx,yIdx); + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); } } } -function createBlock(xIdx,yIdx){ - if(component==null) - component = createComponent(tileSrc); +function createBlock(column, row) { + if (component == null) + component = createComponent("Block.qml"); - // Note that we don't wait for the component to become ready. This will - // only work if the block QML is a local file. Otherwise the component will - // not be ready immediately. There is a statusChanged signal on the - // component you could use if you want to wait to load remote files. - if(component.isReady){ + // Note that if Block.qml was not a local file, component.isReady would be + // false and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and fully loaded before calling createObject(). + if (component.isReady) { var dynamicObject = component.createObject(); - if(dynamicObject == null){ + if (dynamicObject == null) { print("error creating block"); print(component.errorsString()); return false; } dynamicObject.type = Math.floor(Math.random() * 3); dynamicObject.parent = gameCanvas; - dynamicObject.x = xIdx*gameCanvas.tileSize; - dynamicObject.y = yIdx*gameCanvas.tileSize; - dynamicObject.width = gameCanvas.tileSize; - dynamicObject.height = gameCanvas.tileSize; - board[index(xIdx,yIdx)] = dynamicObject; - }else{//isError or isLoading + dynamicObject.x = column * gameCanvas.blockSize; + dynamicObject.y = row * gameCanvas.blockSize; + dynamicObject.width = gameCanvas.blockSize; + dynamicObject.height = gameCanvas.blockSize; + board[index(column, row)] = dynamicObject; + } else { print("error loading block component"); print(component.errorsString()); return false; @@ -63,21 +59,21 @@ function createBlock(xIdx,yIdx){ return true; } -var fillFound;//Set after a floodFill call to the number of tiles found -var floodBoard;//Set to 1 if the floodFill reaches off that node -//NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope +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(x,y) -{ - var xIdx = Math.floor(x/gameCanvas.tileSize); - var yIdx = Math.floor(y/gameCanvas.tileSize); - if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) +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(xIdx, yIdx)] == null) + if (board[index(column, row)] == null) return; - //If it's a valid tile, remove it and all connected (does nothing if it's not connected) - floodFill(xIdx,yIdx, -1); - if(fillFound <= 0) + //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(); @@ -85,67 +81,65 @@ function handleClick(x,y) } //![1] -function floodFill(xIdx,yIdx,type) -{ - if(board[index(xIdx, yIdx)] == null) +function floodFill(column, row, type) { + if (board[index(column, row)] == null) return; var first = false; - if(type == -1){ + if (type == -1) { first = true; - type = board[index(xIdx,yIdx)].type; - + type = board[index(column, row)].type; + //Flood fill initialization fillFound = 0; floodBoard = new Array(maxIndex); } - if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) return; - if(floodBoard[index(xIdx, yIdx)] == 1 || (!first && type != board[index(xIdx,yIdx)].type)) + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) return; - floodBoard[index(xIdx, yIdx)] = 1; - floodFill(xIdx+1,yIdx,type); - floodFill(xIdx-1,yIdx,type); - floodFill(xIdx,yIdx+1,type); - floodFill(xIdx,yIdx-1,type); - if(first==true && fillFound == 0) - return;//Can't remove single tiles - board[index(xIdx,yIdx)].opacity = 0; - board[index(xIdx,yIdx)] = null; + 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() -{ +function shuffleDown() { //Fall down - for(var xIdx=0; xIdx<maxX; xIdx++){ + for (var column = 0; column < maxColumn; column++) { var fallDist = 0; - for(var yIdx=maxY-1; yIdx>=0; yIdx--){ - if(board[index(xIdx,yIdx)] == null){ + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column, row)] == null) { fallDist += 1; - }else{ - if(fallDist > 0){ - var obj = board[index(xIdx,yIdx)]; - obj.y += fallDist * gameCanvas.tileSize; - board[index(xIdx,yIdx+fallDist)] = obj; - board[index(xIdx,yIdx)] = null; + } 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 xIdx=0; xIdx<maxX; xIdx++){ - if(board[index(xIdx, maxY - 1)] == null){ + for (var column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { fallDist += 1; - }else{ - if(fallDist > 0){ - for(var yIdx=0; yIdx<maxY; yIdx++){ - var obj = board[index(xIdx,yIdx)]; - if(obj == null) + } 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.tileSize; - board[index(xIdx-fallDist,yIdx)] = obj; - board[index(xIdx,yIdx)] = null; + obj.x -= fallDist * gameCanvas.blockSize; + board[index(column - fallDist, row)] = obj; + board[index(column, row)] = null; } } } @@ -153,31 +147,30 @@ function shuffleDown() } //![2] -function victoryCheck() -{ - //awards bonuses for no tiles left +function victoryCheck() { + //Award bonus points if no blocks left var deservesBonus = true; - for(var xIdx=maxX-1; xIdx>=0; xIdx--) - if(board[index(xIdx, maxY - 1)] != null) - deservesBonus = false; - if(deservesBonus) + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) gameCanvas.score += 500; - //Checks for game over - if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))) + + //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 tiles -function floodMoveCheck(xIdx, yIdx, type) -{ - if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) +//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(xIdx, yIdx)] == null) + if (board[index(column, row)] == null) return false; - var myType = board[index(xIdx, yIdx)].type; - if(type == myType) + var myType = board[index(column, row)].type; + if (type == myType) return true; - return floodMoveCheck(xIdx + 1, yIdx, myType) || - floodMoveCheck(xIdx, yIdx - 1, board[index(xIdx,yIdx)].type); + return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); } + diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml index db25e24..cdf99d7 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml @@ -1,5 +1,5 @@ //![0] -import Qt 4.6 +import Qt 4.7 import "samegame.js" as SameGame Rectangle { @@ -21,11 +21,11 @@ Rectangle { Item { id: gameCanvas property int score: 0 - property int tileSize: 40 + property int blockSize: 40 z: 20; anchors.centerIn: parent - width: parent.width - (parent.width % tileSize); - height: parent.height - (parent.height % tileSize); + width: parent.width - (parent.width % blockSize); + height: parent.height - (parent.height % blockSize); MouseArea { anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y); @@ -45,7 +45,7 @@ Rectangle { anchors.bottom: screen.bottom Button { - id: btnA; text: "New Game"; onClicked: SameGame.initBoard(); + text: "New Game"; onClicked: SameGame.startNewGame(); anchors.left: parent.left; anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml index e50aae0..243df75 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import Qt.labs.particles 1.0 Item { id:block @@ -9,8 +9,8 @@ Item { id:block property int targetX: 0 property int targetY: 0 - SpringFollow on x { source: targetX; spring: 2; damping: 0.2; enabled: spawned } - SpringFollow on y { source: targetY; spring: 2; damping: 0.2 } + SpringFollow on x { to: targetX; spring: 2; damping: 0.2; enabled: spawned } + SpringFollow on y { to: targetY; spring: 2; damping: 0.2 } //![1] //![2] diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml index a7853d4..cf4c61b 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: container @@ -7,19 +7,20 @@ Rectangle { property string text: "Button" color: activePalette.button; smooth: true - width: txtItem.width + 20; height: txtItem.height + 6 + width: buttonLabel.width + 20; height: buttonLabel.height + 6 border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; gradient: Gradient { GradientStop { - id: topGrad; position: 0.0 - color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } } + position: 0.0 + color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } + } GradientStop { position: 1.0; color: activePalette.button } } MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } Text { - id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText + id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml index fc83e39..15f5b19 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: page @@ -7,15 +7,15 @@ Rectangle { page.opacity = 0; } function show(txt) { - myText.text = txt; + dialogText.text = txt; page.opacity = 1; } signal closed(); - color: "white"; border.width: 1; width: myText.width + 20; height: 60; + color: "white"; border.width: 1; width: dialogText.width + 20; height: dialogText.height + 20; opacity: 0 Behavior on opacity { NumberAnimation { duration: 1000 } } - Text { id: myText; anchors.centerIn: parent; text: "Hello World!" } - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: forceClose(); } + Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" } + MouseArea { anchors.fill: parent; onClicked: forceClose(); } } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js index 2a0d718..47985de 100755 --- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js @@ -1,245 +1,219 @@ /* This script file handles the game logic */ -//Note that X/Y referred to here are in game coordinates -var maxX = 10;//Nums are for gameCanvas.tileSize 40 -var maxY = 15; -var maxIndex = maxX*maxY; +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; var board = new Array(maxIndex); -var tileSrc = "content/BoomBlock.qml"; -//var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php"; +var component; var scoresURL = ""; -var timer; -var component = createComponent(tileSrc); +var gameDuration; //Index function used instead of a 2D array -function index(xIdx,yIdx) { - return xIdx + (yIdx * maxX); +function index(column, row) { + return column + (row * maxColumn); } -function timeStr(msecs) { - var secs = Math.floor(msecs/1000); - var m = Math.floor(secs/60); - var ret = "" + m + "m " + (secs%60) + "s"; - return ret; -} - -function getTileSize() -{ - return tileSize; -} - -function initBoard() -{ - for(var i = 0; i<maxIndex; i++){ - //Delete old blocks - if(board[i] != null) +function startNewGame() { + for (var i = 0; i < maxIndex; i++) { + //Delete blocks from previous game + if (board[i] != null) board[i].destroy(); } //Calculate board size - maxX = Math.floor(gameCanvas.width/gameCanvas.tileSize); - maxY = Math.floor(gameCanvas.height/gameCanvas.tileSize); - maxIndex = maxY*maxX; + maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; //Close dialogs - scoreName.forceClose(); + nameInputDialog.forceClose(); dialog.forceClose(); - var a = new Date(); //Initialize Board board = new Array(maxIndex); gameCanvas.score = 0; - for(var xIdx=0; xIdx<maxX; xIdx++){ - for(var yIdx=0; yIdx<maxY; yIdx++){ - board[index(xIdx,yIdx)] = null; - createBlock(xIdx,yIdx); + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); } } - timer = new Date(); - print(timer.valueOf() - a.valueOf()); + gameDuration = new Date(); +} + +function createBlock(column, row) { + if (component == null) + component = createComponent("content/BoomBlock.qml"); + + // Note that if Block.qml was not a local file, component.isReady would be + // false and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and fully loaded before calling createObject(). + if (component.isReady) { + var dynamicObject = component.createObject(); + if (dynamicObject == null) { + print("error creating block"); + print(component.errorsString()); + return false; + } + dynamicObject.type = Math.floor(Math.random() * 3); + dynamicObject.parent = gameCanvas; + dynamicObject.x = column * gameCanvas.blockSize; + dynamicObject.targetX = column * gameCanvas.blockSize; + dynamicObject.targetY = row * gameCanvas.blockSize; + dynamicObject.width = gameCanvas.blockSize; + dynamicObject.height = gameCanvas.blockSize; + dynamicObject.spawned = true; + board[index(column, row)] = dynamicObject; + } else { + print("error loading block component"); + print(component.errorsString()); + return false; + } + return true; } -var fillFound;//Set after a floodFill call to the number of tiles found -var floodBoard;//Set to 1 if the floodFill reaches off that node -//NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope -function handleClick(x,y) -{ - var xIdx = Math.floor(x/gameCanvas.tileSize); - var yIdx = Math.floor(y/gameCanvas.tileSize); - if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) +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(xIdx, yIdx)] == null) + if (board[index(column, row)] == null) return; - //If it's a valid tile, remove it and all connected (does nothing if it's not connected) - floodFill(xIdx,yIdx, -1); - if(fillFound <= 0) + //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(xIdx,yIdx,type) -{ - if(board[index(xIdx, yIdx)] == null) +function floodFill(column, row, type) { + if (board[index(column, row)] == null) return; var first = false; - if(type == -1){ + if (type == -1) { first = true; - type = board[index(xIdx,yIdx)].type; - + type = board[index(column, row)].type; + //Flood fill initialization fillFound = 0; floodBoard = new Array(maxIndex); } - if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) return; - if(floodBoard[index(xIdx, yIdx)] == 1 || (!first && type != board[index(xIdx,yIdx)].type)) + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) return; - floodBoard[index(xIdx, yIdx)] = 1; - floodFill(xIdx+1,yIdx,type); - floodFill(xIdx-1,yIdx,type); - floodFill(xIdx,yIdx+1,type); - floodFill(xIdx,yIdx-1,type); - if(first==true && fillFound == 0) - return;//Can't remove single tiles - board[index(xIdx,yIdx)].dying = true; - board[index(xIdx,yIdx)] = null; + 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() -{ +function shuffleDown() { //Fall down - for(var xIdx=0; xIdx<maxX; xIdx++){ + for (var column = 0; column < maxColumn; column++) { var fallDist = 0; - for(var yIdx=maxY-1; yIdx>=0; yIdx--){ - if(board[index(xIdx,yIdx)] == null){ + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column, row)] == null) { fallDist += 1; - }else{ - if(fallDist > 0){ - var obj = board[index(xIdx,yIdx)]; - obj.targetY += fallDist * gameCanvas.tileSize; - board[index(xIdx,yIdx+fallDist)] = obj; - board[index(xIdx,yIdx)] = null; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.targetY += fallDist * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; } } } } //Fall to the left fallDist = 0; - for(xIdx=0; xIdx<maxX; xIdx++){ - if(board[index(xIdx, maxY - 1)] == null){ + for (column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { fallDist += 1; - }else{ - if(fallDist > 0){ - for(yIdx=0; yIdx<maxY; yIdx++){ - obj = board[index(xIdx,yIdx)]; - if(obj == null) + } else { + if (fallDist > 0) { + for (row = 0; row < maxRow; row++) { + obj = board[index(column, row)]; + if (obj == null) continue; - obj.targetX -= fallDist * gameCanvas.tileSize; - board[index(xIdx-fallDist,yIdx)] = obj; - board[index(xIdx,yIdx)] = null; + obj.targetX -= fallDist * gameCanvas.blockSize; + board[index(column - fallDist, row)] = obj; + board[index(column, row)] = null; } } } } } -function victoryCheck() -{ - //awards bonuses for no tiles left +function victoryCheck() { + //Award bonus points if no blocks left var deservesBonus = true; - for(var xIdx=maxX-1; xIdx>=0; xIdx--) - if(board[index(xIdx, maxY - 1)] != null) - deservesBonus = false; - if(deservesBonus) + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) gameCanvas.score += 500; - //Checks for game over - if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){ - timer = new Date() - timer; - scoreName.show("You won! Please enter your name: "); - //dialog.show("Game Over. Your score is " + gameCanvas.score); + + //Check whether game has finished + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { + gameDuration = new Date() - gameDuration; + nameInputDialog.show("You won! Please enter your name: "); } } -//only floods up and right, to see if it can find adjacent same-typed tiles -function floodMoveCheck(xIdx, yIdx, type) -{ - if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) +//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(xIdx, yIdx)] == null) + if (board[index(column, row)] == null) return false; - var myType = board[index(xIdx, yIdx)].type; - if(type == myType) + var myType = board[index(column, row)].type; + if (type == myType) return true; - return floodMoveCheck(xIdx + 1, yIdx, myType) || - floodMoveCheck(xIdx, yIdx - 1, board[index(xIdx,yIdx)].type); -} - -function createBlock(xIdx,yIdx){ - // Note that we don't wait for the component to become ready. This will - // only work if the block QML is a local file. Otherwise the component will - // not be ready immediately. There is a statusChanged signal on the - // component you could use if you want to wait to load remote files. - if(component.isReady){ - var dynamicObject = component.createObject(); - if(dynamicObject == null){ - print("error creating block"); - print(component.errorsString()); - return false; - } - dynamicObject.type = Math.floor(Math.random() * 3); - dynamicObject.parent = gameCanvas; - dynamicObject.x = xIdx*gameCanvas.tileSize; - dynamicObject.targetX = xIdx*gameCanvas.tileSize; - dynamicObject.targetY = yIdx*gameCanvas.tileSize; - dynamicObject.width = gameCanvas.tileSize; - dynamicObject.height = gameCanvas.tileSize; - dynamicObject.spawned = true; - board[index(xIdx,yIdx)] = dynamicObject; - }else{//isError or isLoading - print("error loading block component"); - print(component.errorsString()); - return false; - } - return true; + return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); } //![2] function saveHighScore(name) { - if(scoresURL!="") + if (scoresURL != "") sendHighScore(name); - //OfflineStorage - var db = openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores",100); + + var db = openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100); var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; - var data = [name, gameCanvas.score, maxX+"x"+maxY ,Math.floor(timer/1000)]; - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); - tx.executeSql(dataStr, data); - - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10'); - var r = "\nHIGH SCORES for a standard sized grid\n\n" - for(var i = 0; i < rs.rows.length; i++){ - r += (i+1)+". " + rs.rows.item(i).name +' got ' - + rs.rows.item(i).score + ' points in ' - + rs.rows.item(i).time + ' seconds.\n'; - } - dialog.show(r); + 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="+maxX+"x"+maxY +"&time="+Math.floor(timer/1000); + 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() { + postman.onreadystatechange = function() { if (postman.readyState == postman.DONE) { dialog.show("Your score has been uploaded."); } @@ -247,3 +221,4 @@ function sendHighScore(name) { postman.send(postData); } //![1] + diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php b/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php index 3cceb2d..daf480e 100755 --- a/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php +++ b/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php @@ -8,10 +8,7 @@ $time = $_POST["time"]; if($name == "") $name = "Anonymous"; - //if($grid != "10x10"){ - //Need a standard, so as to reject others? - //} - $file = fopen("score_data.xml", "a"); #It's XML. Happy? + $file = fopen("score_data.xml", "a"); $ret = fwrite($file, "<record><score>". $score . "</score><name>" . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>" . $time . "</seconds></record>\n"); diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml index 090496d..5d5c81f 100644 --- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame4/samegame.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import "content" import "content/samegame.js" as SameGame @@ -20,11 +20,11 @@ Rectangle { Item { id: gameCanvas property int score: 0 - property int tileSize: 40 + property int blockSize: 40 z: 20; anchors.centerIn: parent - width: parent.width - (parent.width % getTileSize()); - height: parent.height - (parent.height % getTileSize()); + width: parent.width - (parent.width % blockSize); + height: parent.height - (parent.height % blockSize); MouseArea { anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y); @@ -36,7 +36,7 @@ Rectangle { //![0] Dialog { - id: scoreName; anchors.centerIn: parent; z: 22; + id: nameInputDialog; anchors.centerIn: parent; z: 22; Text { id: spacer opacity: 0 @@ -45,9 +45,9 @@ Rectangle { TextInput { id: editor onAccepted: { - if(scoreName.opacity==1&&editor.text!="") - saveHighScore(editor.text); - scoreName.forceClose(); + if(nameInputDialog.opacity==1&&editor.text!="") + SameGame.saveHighScore(editor.text); + nameInputDialog.forceClose(); } anchors.verticalCenter: parent.verticalCenter width: 72; focus: true @@ -63,7 +63,7 @@ Rectangle { anchors.bottom: screen.bottom Button { - id: btnA; text: "New Game"; onClicked: {SameGame.initBoard();} + text: "New Game"; onClicked: SameGame.startNewGame(); anchors.left: parent.left; anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter } diff --git a/examples/declarative/tvtennis/tvtennis.qml b/examples/declarative/tvtennis/tvtennis.qml index fcb285d..9d107ad 100644 --- a/examples/declarative/tvtennis/tvtennis.qml +++ b/examples/declarative/tvtennis/tvtennis.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import Qt.multimedia 4.7 Rectangle { @@ -10,7 +10,7 @@ Rectangle { Rectangle { // Add a property for the target y coordinate property int targetY : page.height - 10 - property var direction : "right" + property variant direction : "right" id: ball color: "Lime" @@ -31,7 +31,7 @@ Rectangle { } // Make y follow the target y coordinate, with a velocity of 200 - SpringFollow on y { source: ball.targetY; velocity: 200 } + SpringFollow on y { to: ball.targetY; velocity: 200 } // Detect the ball hitting the top or bottom of the view and bounce it onYChanged: { @@ -52,7 +52,7 @@ Rectangle { color: "Lime" x: 2; width: 20; height: 90 SpringFollow on y { - source: ball.y - 45; velocity: 300 + to: ball.y - 45; velocity: 300 enabled: ball.direction == 'left' } } @@ -61,7 +61,7 @@ Rectangle { color: "Lime" x: page.width - 22; width: 20; height: 90 SpringFollow on y { - source: ball.y-45; velocity: 300 + to: ball.y-45; velocity: 300 enabled: ball.direction == 'right' } } diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index f4c24a5..a39ec94 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -1,78 +1,92 @@ -import Qt 4.6 +import Qt 4.7 -Rectangle { - property alias day: dayText.text - property var stickies +Component { + Item { + property variant stickies - id: page - width: 400; height: 500; radius: 7 - border.color: "black" + id: page + width: 840; height: 480 - Image { x: 10; y: 10; source: "cork.jpg" } + Image { source: "cork.jpg" } - Text { - id: dayText; x: 20; y: 20 - height: 40; width: 370 - font.pointSize: 14; font.bold: true - style: Text.Outline; styleColor: "#dedede" - } - - Repeater { - model: page.stickies - - Item { - id: stickyPage - x: Math.random() * 200 + 100 - y: Math.random() * 300 + 50 - SpringFollow on rotation { - source: -flickable.horizontalVelocity / 100 - spring: 2.0; damping: 0.1 - } + Text { + text: name; x: 15; y: 8; height: 40; width: 370 + font.pixelSize: 18; font.bold: true; color: "white" + style: Text.Outline; styleColor: "black" + } + Repeater { + model: notes Item { - id: sticky - scale: 0.5 - Image { - id: stickyImage; source: "sticky.png"; transformOrigin: Item.TopLeft - smooth: true; y: -20; x: 8 + -width * 0.6 / 2; scale: 0.6 - } + property int randomX: Math.random() * 500 + 100 + property int randomY: Math.random() * 200 + 50 - TextEdit { - id: myText; smooth: true; font.pointSize: 28 - readOnly: false; x: -104; y: 36; wrap: true - rotation: -8; text: noteText; width: 195; height: 172 + id: stickyPage + x: randomX; y: randomY + + SpringFollow on rotation { + to: -flickable.horizontalVelocity / 100 + spring: 2.0; damping: 0.15 } Item { - y: -20 - x: stickyImage.x - width: stickyImage.width * stickyImage.scale - height: stickyImage.height * stickyImage.scale - MouseArea { - id: mouse - onClicked: { myText.focus = true } - anchors.fill: parent - drag.target: stickyPage; drag.axis: MouseArea.XandYAxis; drag.minimumY: 0; drag.maximumY: 500 - drag.minimumX: 0; drag.maximumX: 400 + id: sticky + scale: 0.7 + Image { + id: stickyImage + source: "note-yellow.png"; transformOrigin: Item.TopLeft + smooth: true; y: -20; x: 8 + -width * 0.6 / 2; scale: 0.6 + } + + TextEdit { + id: myText; smooth: true; font.pixelSize: 24 + readOnly: false; x: -104; y: 36 + rotation: -8; text: noteText; width: 215; height: 200 + } + + Item { + y: -20 + x: stickyImage.x + width: stickyImage.width * stickyImage.scale + height: stickyImage.height * stickyImage.scale + MouseArea { + id: mouse + onClicked: { myText.focus = true } + anchors.fill: parent + drag.target: stickyPage + drag.axis: "XandYAxis" + drag.minimumY: 0 + drag.maximumY: page.height - 80 + drag.minimumX: 100 + drag.maximumX: page.width - 140 + } } } - } - Image { - source: "tack.png"; transformOrigin: Item.TopLeft - x: -width / 2; y: -height * 0.7 / 2; scale: 0.7 - } + Image { + source: "tack.png"; transformOrigin: Item.TopLeft + x: -width / 2; y: -height * 0.5 / 2; scale: 0.7 + } - states: State { - name: "pressed" - when: mouse.pressed - PropertyChanges { target: sticky; rotation: 8; scale: 1 } - PropertyChanges { target: page; z: 8 } - } + states: State { + name: "pressed" + when: mouse.pressed + PropertyChanges { target: sticky; rotation: 8; scale: 1 } + PropertyChanges { target: page; z: 8 } + } - transitions: Transition { - NumberAnimation { properties: "rotation,scale"; duration: 200 } + transitions: Transition { + NumberAnimation { properties: "rotation,scale"; duration: 200 } + } } } } } + + + + + + + + diff --git a/examples/declarative/velocity/cork.jpg b/examples/declarative/velocity/cork.jpg Binary files differindex d4d706c..160bc00 100644 --- a/examples/declarative/velocity/cork.jpg +++ b/examples/declarative/velocity/cork.jpg diff --git a/examples/declarative/velocity/note-yellow.png b/examples/declarative/velocity/note-yellow.png Binary files differnew file mode 100644 index 0000000..8ddecc8 --- /dev/null +++ b/examples/declarative/velocity/note-yellow.png diff --git a/examples/declarative/velocity/sticky.png b/examples/declarative/velocity/sticky.png Binary files differdeleted file mode 100644 index 73df3cd..0000000 --- a/examples/declarative/velocity/sticky.png +++ /dev/null diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml index 0d1881e..20821d6 100644 --- a/examples/declarative/velocity/velocity.qml +++ b/examples/declarative/velocity/velocity.qml @@ -1,108 +1,46 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { - color: "lightSteelBlue" - width: 800; height: 600 + width: 800; height: 480; color: "#464646" ListModel { id: list ListElement { name: "Sunday" - dayColor: "#808080" - notes: [ - ListElement { - noteText: "Lunch" - }, - ListElement { - noteText: "Party" - } - ] + notes: [ ListElement { noteText: "Lunch" }, ListElement { noteText: "Birthday Party" } ] } ListElement { name: "Monday" - dayColor: "blue" - notes: [ - ListElement { - noteText: "Pickup kids" - }, - ListElement { - noteText: "Checkout kinetic" - }, - ListElement { - noteText: "Read email" - } - ] + notes: [ ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, + ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } ] } ListElement { name: "Tuesday" - dayColor: "yellow" - notes: [ - ListElement { - noteText: "Walk dog" - }, - ListElement { - noteText: "Buy newspaper" - } - ] + notes: [ ListElement { noteText: "Walk dog" }, ListElement { noteText: "Buy newspaper" } ] } ListElement { - name: "Wednesday" - dayColor: "purple" - notes: [ - ListElement { - noteText: "Cook dinner" - }, - ListElement { - noteText: "Eat dinner" - } - ] + name: "Wednesday"; notes: [ ListElement { noteText: "Cook dinner" } ] } ListElement { name: "Thursday" - dayColor: "blue" - notes: [ - ListElement { - noteText: "5:30pm Meeting" - }, - ListElement { - noteText: "Weed garden" - } - ] + notes: [ ListElement { noteText: "Meeting\n5.30pm" }, ListElement { noteText: "Weed garden" } ] } ListElement { name: "Friday" - dayColor: "green" - notes: [ - ListElement { - noteText: "Still work" - }, - ListElement { - noteText: "Drink" - } - ] + notes: [ ListElement { noteText: "More work" }, ListElement { noteText: "Grocery shopping" } ] } ListElement { name: "Saturday" - dayColor: "orange" - notes: [ - ListElement { - noteText: "Drink" - }, - ListElement { - noteText: "Drink" - } - ] + notes: [ ListElement { noteText: "Drink" }, ListElement { noteText: "Download Qt\nPlay with QML" } ] } } - Flickable { + + ListView { id: flickable - anchors.fill: parent; contentWidth: lay.width - Row { - id: lay - Repeater { - model: list - Component { Day { day: name; color: dayColor; stickies: notes } } - } - } + anchors.fill: parent; focus: true + model: list; delegate: Day { } + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem } } diff --git a/examples/declarative/webview/alerts.qml b/examples/declarative/webview/alerts.qml index ab2e860..2ba4300 100644 --- a/examples/declarative/webview/alerts.qml +++ b/examples/declarative/webview/alerts.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import org.webkit 1.0 WebView { @@ -51,7 +51,7 @@ WebView { color: "white" font.pixelSize: 20 width: webView.width*0.75 - wrap: true + wrapMode: Text.WordWrap horizontalAlignment: "AlignHCenter" } } diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml index 3c00ee6..c4a502e 100644 --- a/examples/declarative/webview/autosize.qml +++ b/examples/declarative/webview/autosize.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import org.webkit 1.0 // The WebView size is determined by the width, height, diff --git a/examples/declarative/webview/content/FieldText.qml b/examples/declarative/webview/content/FieldText.qml index 1da9219..d1d003f 100644 --- a/examples/declarative/webview/content/FieldText.qml +++ b/examples/declarative/webview/content/FieldText.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { id: fieldText diff --git a/examples/declarative/webview/content/Mapping/Map.qml b/examples/declarative/webview/content/Mapping/Map.qml index 38c42dd..5d3ba81 100644 --- a/examples/declarative/webview/content/Mapping/Map.qml +++ b/examples/declarative/webview/content/Mapping/Map.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import org.webkit 1.0 Item { diff --git a/examples/declarative/webview/content/SpinSquare.qml b/examples/declarative/webview/content/SpinSquare.qml index 62c0ce2..dba48d4 100644 --- a/examples/declarative/webview/content/SpinSquare.qml +++ b/examples/declarative/webview/content/SpinSquare.qml @@ -1,8 +1,8 @@ -import Qt 4.6 +import Qt 4.7 Item { - property var period : 250 - property var color : "black" + property variant period : 250 + property variant color : "black" id: root Item { diff --git a/examples/declarative/webview/googleMaps.qml b/examples/declarative/webview/googleMaps.qml index a0926f5..4702dea 100644 --- a/examples/declarative/webview/googleMaps.qml +++ b/examples/declarative/webview/googleMaps.qml @@ -5,7 +5,7 @@ // API, but users from QML don't need to understand the implementation in // order to create a Map. -import Qt 4.6 +import Qt 4.7 import org.webkit 1.0 import "content/Mapping" diff --git a/examples/declarative/webview/inline-html.qml b/examples/declarative/webview/inline-html.qml index 41dfec3..eec7fc6 100644 --- a/examples/declarative/webview/inline-html.qml +++ b/examples/declarative/webview/inline-html.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import org.webkit 1.0 // Inline HTML with loose formatting can be diff --git a/examples/declarative/webview/newwindows.qml b/examples/declarative/webview/newwindows.qml index c62aba6..2e4a72e 100644 --- a/examples/declarative/webview/newwindows.qml +++ b/examples/declarative/webview/newwindows.qml @@ -3,7 +3,7 @@ // Note that to open windows from JavaScript, you will need to // allow it on WebView with settings.javascriptCanOpenWindows: true -import Qt 4.6 +import Qt 4.7 import org.webkit 1.0 Grid { diff --git a/examples/declarative/webview/transparent.qml b/examples/declarative/webview/transparent.qml index 5530819..a0676f4 100644 --- a/examples/declarative/webview/transparent.qml +++ b/examples/declarative/webview/transparent.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 import org.webkit 1.0 // The WebView background is transparent diff --git a/examples/declarative/workerscript/workerscript.qml b/examples/declarative/workerscript/workerscript.qml index 0566f1f..1c7a920 100644 --- a/examples/declarative/workerscript/workerscript.qml +++ b/examples/declarative/workerscript/workerscript.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { width: 480; height: 320; diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml index 456f309..c5732c0 100644 --- a/examples/declarative/xmldata/daringfireball.qml +++ b/examples/declarative/xmldata/daringfireball.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { color: "white" @@ -32,7 +32,7 @@ Rectangle { x: 10 text: content anchors.top: titleText.bottom - width: 580; wrap: true + width: 580; wrapMode: Text.WordWrap onLinkActivated: { console.log('link clicked: ' + link) } } } diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index f7c269c..e6cb373 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { gradient: Gradient { @@ -45,7 +45,7 @@ Rectangle { id: descriptionText text: description width: 560 - wrap: true + wrapMode: Text.WordWrap font.family: "Helvetica" anchors.top: titleText.bottom anchors.topMargin: 5 diff --git a/examples/declarative/xmlhttprequest/test.qml b/examples/declarative/xmlhttprequest/test.qml index 15ac54b..ef9d5f3 100644 --- a/examples/declarative/xmlhttprequest/test.qml +++ b/examples/declarative/xmlhttprequest/test.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { width: 800; height: 600 |