diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-05-07 09:15:32 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-05-07 09:15:32 (GMT) |
commit | 695ddc4a13233c8e6f626fa205336f90f8c5a565 (patch) | |
tree | 88da8a1d80219e5788db3f4e138d1d281bb3d816 | |
parent | 1824eb63f6b2f8baa26b20c57fc50db84eefaa30 (diff) | |
parent | 67bf465253db71c0eddbc6ffcb811dd65c00b207 (diff) | |
download | Qt-695ddc4a13233c8e6f626fa205336f90f8c5a565.zip Qt-695ddc4a13233c8e6f626fa205336f90f8c5a565.tar.gz Qt-695ddc4a13233c8e6f626fa205336f90f8c5a565.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts:
examples/declarative/dynamic/qml/itemCreation.js
103 files changed, 955 insertions, 557 deletions
diff --git a/demos/declarative/flickr/common/Slider.qml b/demos/declarative/flickr/common/Slider.qml index 4da370e..76f6303 100644 --- a/demos/declarative/flickr/common/Slider.qml +++ b/demos/declarative/flickr/common/Slider.qml @@ -29,7 +29,7 @@ Item { MouseArea { anchors.fill: parent; drag.target: parent - drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: slider.xMax+2 + drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2 onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; } } } diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml index eccdc34..df608bc 100644 --- a/demos/declarative/flickr/mobile/GridDelegate.qml +++ b/demos/declarative/flickr/mobile/GridDelegate.qml @@ -38,7 +38,7 @@ states: [ State { - name: "Show"; when: thumb.status == 1 + name: "Show"; when: thumb.status == Image.Ready PropertyChanges { target: scaleMe; scale: 1 } }, State { diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml index 310c9df..caf1571 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -54,7 +54,11 @@ Flipable { Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 } - Common.Progress { anchors.centerIn: parent; width: 200; height: 18; progress: bigImage.progress; visible: bigImage.status!=1 } + Common.Progress { + anchors.centerIn: parent; width: 200; height: 18 + progress: bigImage.progress; visible: bigImage.status != Image.Ready + } + Flickable { id: flickable; anchors.fill: parent; clip: true contentWidth: imageContainer.width; contentHeight: imageContainer.height @@ -69,7 +73,7 @@ Flipable { anchors.centerIn: parent; smooth: !flickable.moving onStatusChanged : { // Default scale shows the entire image. - if (status == 1 && width != 0) { + if (status == Image.Ready && width != 0) { slider.minimum = Math.min(flickable.width / width, flickable.height / height); prevScale = Math.min(slider.minimum, 1); slider.value = prevScale; @@ -81,12 +85,12 @@ Flipable { Text { text: "Image Unavailable" - visible: bigImage.status == 'Error' + visible: bigImage.status == Image.Error anchors.centerIn: parent; color: "white"; font.bold: true } Common.Slider { - id: slider; visible: { bigImage.status == 1 && maximum > minimum } + id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum } anchors { bottom: parent.bottom; bottomMargin: 65 left: parent.left; leftMargin: 25 diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml index 47bced4..bc4a974 100644 --- a/demos/declarative/snake/snake.qml +++ b/demos/declarative/snake/snake.qml @@ -60,7 +60,7 @@ Rectangle { Image { id: title source: "content/pics/snake.jpg" - fillMode: "PreserveAspectCrop" + fillMode: Image.PreserveAspectCrop anchors.fill: parent anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter @@ -69,7 +69,7 @@ Rectangle { Text { color: "white" font.pointSize: 24 - horizontalAlignment: "AlignHCenter" + horizontalAlignment: Text.AlignHCenter text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore; anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom @@ -78,7 +78,7 @@ Rectangle { } source: "content/pics/background.png" - fillMode: "PreserveAspectCrop" + fillMode: Image.PreserveAspectCrop anchors.left: parent.left anchors.right: parent.right diff --git a/demos/declarative/twitter/TwitterCore/FatDelegate.qml b/demos/declarative/twitter/TwitterCore/FatDelegate.qml index 62ee11a..72e5ecc 100644 --- a/demos/declarative/twitter/TwitterCore/FatDelegate.qml +++ b/demos/declarative/twitter/TwitterCore/FatDelegate.qml @@ -27,7 +27,7 @@ Component { id: whiteRect; x: 6; width: 50; height: 50; color: "white"; smooth: true anchors.verticalCenter: parent.verticalCenter - Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != 1 } + Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready } Image { id: realImage; source: userImage; x: 1; y: 1; width:48; height:48 } } Text { id:txt; y:4; x: 56 diff --git a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml index 11aa74f..26ad1a9 100644 --- a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml @@ -37,7 +37,7 @@ Item { UserModel { user: rssModel.authName; id: userModel } Component { id: imgDelegate; Item { - Loading { width:48; height:48; visible: realImage.status != 1 } + Loading { width:48; height:48; visible: realImage.status != Image.Ready } Image { source: image; width:48; height:48; id: realImage } } } diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 46f45e0..50ea97d 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -105,14 +105,14 @@ Flickable { property: "scale" from: 1 to: 0 // set before calling - easing.type: "Linear" + easing.type: Easing.Linear duration: 200 } NumberAnimation { id: flickVX target: flickable property: "contentX" - easing.type: "Linear" + easing.type: Easing.Linear duration: 200 from: 0 // set before calling to: 0 // set before calling @@ -121,7 +121,7 @@ Flickable { id: flickVY target: flickable property: "contentY" - easing.type: "Linear" + easing.type: Easing.Linear duration: 200 from: 0 // set before calling to: 0 // set before calling diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index 88aca1b..6e98949 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -73,9 +73,9 @@ Rectangle { y: 0 SequentialAnimation on y { loops: Animation.Infinite - NumberAnimation { to: 200-img.height; easing.type: "OutBounce"; duration: 2000 } + NumberAnimation { to: 200-img.height; easing.type: Easing.OutBounce; duration: 2000 } PauseAnimation { duration: 1000 } - NumberAnimation { to: 0; easing.type: "OutQuad"; duration: 1000 } + NumberAnimation { to: 0; easing.type: Easing.OutQuad; duration: 1000 } } } } @@ -136,7 +136,7 @@ transitions: [ Transition { NumberAnimation { properties: "x,y" - easing.type: "OutBounce" + easing.type: Easing.OutBounce duration: 200 } } @@ -157,7 +157,7 @@ Transition { SequentialAnimation { NumberAnimation { duration: 1000 - easing.type: "OutBounce" + easing.type: Easing.OutBounce // animate myItem's x and y if they have changed in the state target: myItem properties: "x,y" @@ -199,7 +199,7 @@ Transition { ParallelAnimation { NumberAnimation { duration: 1000 - easing.type: "OutBounce" + easing.type: Easing.OutBounce targets: box1 properties: "x,y" } @@ -227,7 +227,7 @@ Rectangle { id: redRect color: "red" width: 100; height: 100 - Behavior on x { NumberAnimation { duration: 300; easing.type: "InOutQuad" } } + Behavior on x { NumberAnimation { duration: 300; easing.type: Easing.InOutQuad } } } \endqml diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 79fe909..574a187 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -120,11 +120,22 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \list \o \l Item \o \l Rectangle + \list + \o \l Gradient + \list + \o \l GradientStop + \endlist + \endlist \o \l Image \o \l BorderImage \o \l AnimatedImage \o \l Text \o \l TextInput + \list + \o \l IntValidator + \o \l DoubleValidator + \o \l RegExpValidator + \endlist \o \l TextEdit \endlist @@ -142,6 +153,7 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \o \l Loader \o \l Repeater \o \l SystemPalette +\o \l FontLoader \o \l LayoutItem \endlist diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/declarative/drag.qml index 9465efb..79469e3 100644 --- a/doc/src/snippets/declarative/drag.qml +++ b/doc/src/snippets/declarative/drag.qml @@ -9,7 +9,7 @@ Rectangle { MouseArea { anchors.fill: parent drag.target: pic - drag.axis: "XAxis" + drag.axis: Drag.XAxis drag.minimumX: 0 drag.maximumX: blurtest.width-pic.width } diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml index 3616a31..61737e9 100644 --- a/examples/declarative/animations/color-animation.qml +++ b/examples/declarative/animations/color-animation.qml @@ -31,15 +31,14 @@ Item { // the sun, moon, and stars Item { width: parent.width; height: 2 * parent.height - transformOrigin: Item.Center NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } Image { source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter - transformOrigin: Item.Center; rotation: -3 * parent.rotation + rotation: -3 * parent.rotation } Image { source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter - transformOrigin: Item.Center; rotation: -parent.rotation + rotation: -parent.rotation } Particles { x: 0; y: parent.height/2; width: parent.width; height: parent.height/2 diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml index 6360511..87ac8ec 100644 --- a/examples/declarative/animations/property-animation.qml +++ b/examples/declarative/animations/property-animation.qml @@ -26,7 +26,6 @@ Item { Image { anchors.horizontalCenter: parent.horizontalCenter source: "images/shadow.png"; y: smiley.minHeight + 58 - transformOrigin: Item.Center // The scale property depends on the y position of the smiley face. scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) diff --git a/examples/declarative/connections/connections-example.qml b/examples/declarative/connections/connections-example.qml index 1dd10ab..e65a280 100644 --- a/examples/declarative/connections/connections-example.qml +++ b/examples/declarative/connections/connections-example.qml @@ -13,7 +13,6 @@ Rectangle { id: image source: "content/bg1.jpg" anchors.centerIn: parent - transformOrigin: Item.Center rotation: window.angle Behavior on rotation { diff --git a/examples/declarative/dial/dial-example.qml b/examples/declarative/dial/dial-example.qml index fd899a5..2e102b0 100644 --- a/examples/declarative/dial/dial-example.qml +++ b/examples/declarative/dial/dial-example.qml @@ -37,7 +37,7 @@ Rectangle { MouseArea { anchors.fill: parent - drag.target: parent; drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: container.width - 32 + drag.target: parent; drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: container.width - 32 } } } diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index 0e6e197..52c7c1e 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -4,44 +4,49 @@ import "qml" Item { id: window + + property int activeSuns: 0 + //This is a desktop-sized example width: 1024; height: 512 - property int activeSuns: 0 - //This is the message that pops up when there's an error - Rectangle{ + //This is the message box that pops up when there's an error + Rectangle { id: dialog + opacity: 0 anchors.centerIn: parent - width: dialogText.width + 6 - height: dialogText.height + 6 + width: dialogText.width + 6; height: dialogText.height + 6 border.color: 'black' color: 'lightsteelblue' z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. + function show(str){ dialogText.text = str; dialogAnim.start(); } - Text{ + + Text { id: dialogText - x:3 - y:3 + x: 3; y: 3 font.pixelSize: 14 } - SequentialAnimation{ + + SequentialAnimation { id: dialogAnim - NumberAnimation{target: dialog; property:"opacity"; to: 1; duration: 1000} - PauseAnimation{duration: 5000} - NumberAnimation{target: dialog; property:"opacity"; to: 0; duration: 1000} + NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } + PauseAnimation { duration: 5000 } + NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } } } // sky - Rectangle { id: sky + Rectangle { + id: sky anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter } gradient: Gradient { - GradientStop { id: stopA; position: 0.0; color: "#0E1533" } - GradientStop { id: stopB; position: 1.0; color: "#437284" } + GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } + GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } } } @@ -49,109 +54,123 @@ Item { Particles { id: stars x: 0; y: 0; width: parent.width; height: parent.height / 2 - source: "images/star.png"; angleDeviation: 360; velocity: 0 - velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800 + source: "images/star.png" + angleDeviation: 360 + velocity: 0; velocityDeviation: 0 + count: parent.width / 10 + fadeInDuration: 2800 opacity: 1 } - // ground, which has a z such that the sun can set behind it + // ground Rectangle { id: ground - z: 2 - anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.right; bottom: parent.bottom } + z: 2 // just above the sun so that the sun can set behind it + anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.left; bottom: parent.bottom } gradient: Gradient { GradientStop { position: 0.0; color: "ForestGreen" } GradientStop { position: 1.0; color: "DarkGreen" } } } - //Day state, for when you place a sun - states: State { - name: "Day"; when: window.activeSuns > 0 - PropertyChanges { target: stopA; color: "DeepSkyBlue"} - PropertyChanges { target: stopB; color: "SkyBlue"} - PropertyChanges { target: stars; opacity: 0 } - } - - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - SystemPalette { id: activePalette } - // toolbox + // right-hand panel Rectangle { id: toolbox - z: 3 //Above ground - color: activePalette.window; + width: 480 - anchors { right: parent.right; top:parent.top; bottom: parent.bottom } - Rectangle { //Not a child of any positioner - border.color: "black"; - width: toolRow.width + 4 - height: toolRow.height + 4 - x: toolboxPositioner.x + toolRow.x - 2 - y: toolboxPositioner.y + toolRow.y - 2 - } + color: activePalette.window + anchors { right: parent.right; top: parent.top; bottom: parent.bottom } + Column { - id: toolboxPositioner anchors.centerIn: parent spacing: 8 + Text { text: "Drag an item into the scene." } - Row { - id: toolRow - spacing: 8; - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - file: "Sun.qml"; - image: "../images/sun.png" - } - PaletteItem { - file: "GenericItem.qml" - image: "../images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - file: "PerspectiveItem.qml" - image: "../images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - file: "PerspectiveItem.qml" - image: "../images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - file: "PerspectiveItem.qml" - image: "../images/rabbit_bw.png" + + Rectangle { + width: childrenRect.width + 10; height: childrenRect.height + 10 + border.color: "black" + + Row { + anchors.centerIn: parent + spacing: 8 + + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "Sun.qml" + image: "../images/sun.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "GenericSceneItem.qml" + image: "../images/moon.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + image: "../images/tree_s.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + image: "../images/rabbit_brown.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + image: "../images/rabbit_bw.png" + } } } + Text { text: "Active Suns: " + activeSuns } - Rectangle { width: 440; height: 1; color: "black" } - Text { text: "Arbitrary QML: " } - TextEdit { - id: qmlText - width: 460 - height: 220 - readOnly: false - focusOnPress: true - font.pixelSize: 14 - - text: "import Qt 4.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}" + + Rectangle { width: parent.width; height: 1; color: "black" } + + Text { text: "Arbitrary QML:" } + + Rectangle { + width: 460; height: 240 + + TextEdit { + id: qmlText + anchors.fill: parent; anchors.margins: 5 + readOnly: false + focusOnPress: true + font.pixelSize: 14 + + text: "import Qt 4.7\nImage {\n id: smile\n x: 500 * Math.random()\n y: 200 * Math.random() \n source: 'images/face-smile.png'\n\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n\n Component.onCompleted: smile.destroy(1500);\n}" + } } + Button { text: "Create" - function makeCustom() { - try{ + onClicked: { + try { Qt.createQmlObject(qmlText.text, window, 'CustomObject'); - }catch(err){ - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message ); + } catch(err) { + dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); } } - onClicked: makeCustom(); } } } + //Day state, for when a sun is added to the scene + states: State { + name: "Day" + when: window.activeSuns > 0 + + PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } + PropertyChanges { target: gradientStopB; color: "SkyBlue" } + PropertyChanges { target: stars; opacity: 0 } + } + + transitions: Transition { + PropertyAnimation { duration: 3000 } + ColorAnimation { duration: 3000 } + } + } diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml index 53588bb..963a850 100644 --- a/examples/declarative/dynamic/qml/Button.qml +++ b/examples/declarative/dynamic/qml/Button.qml @@ -6,19 +6,35 @@ Rectangle { property variant text signal clicked - SystemPalette { id: activePalette } - height: text.height + 10 - width: text.width + 20 + height: text.height + 10; width: text.width + 20 border.width: 1 - radius: 4; smooth: true + radius: 4 + smooth: true + gradient: Gradient { - GradientStop { position: 0.0; - color: if(!mr.pressed){activePalette.light;}else{activePalette.button;} + GradientStop { + position: 0.0 + color: !mouseArea.pressed ? activePalette.light : activePalette.button } - GradientStop { position: 1.0; - color: if(!mr.pressed){activePalette.button;}else{activePalette.dark;} + GradientStop { + position: 1.0 + color: !mouseArea.pressed ? activePalette.button : activePalette.dark } } - MouseArea { id:mr; anchors.fill: parent; onClicked: container.clicked() } - Text { id: text; anchors.centerIn:parent; font.pointSize: 10; text: parent.text; color: activePalette.buttonText } + + SystemPalette { id: activePalette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: text + anchors.centerIn:parent + font.pointSize: 10 + text: parent.text + color: activePalette.buttonText + } } diff --git a/examples/declarative/dynamic/qml/GenericItem.qml b/examples/declarative/dynamic/qml/GenericItem.qml deleted file mode 100644 index faac06d..0000000 --- a/examples/declarative/dynamic/qml/GenericItem.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.7 - -Item{ - property bool created: false - property string image - width: imageItem.width - height: imageItem.height - z: 2 - Image{ - id: imageItem - source: image; - } -} diff --git a/examples/declarative/dynamic/qml/PaletteItem.qml b/examples/declarative/dynamic/qml/PaletteItem.qml index e8f2ed4..dcb5cc3 100644 --- a/examples/declarative/dynamic/qml/PaletteItem.qml +++ b/examples/declarative/dynamic/qml/PaletteItem.qml @@ -1,13 +1,19 @@ import Qt 4.7 import "itemCreation.js" as Code -GenericItem { - id: itemButton - property string file +Image { + id: paletteItem + + property string componentFile + property string image + + source: image + MouseArea { - anchors.fill: parent; + anchors.fill: parent + onPressed: Code.startDrag(mouse); - onPositionChanged: Code.moveDrag(mouse); + onPositionChanged: Code.continueDrag(mouse); onReleased: Code.endDrag(mouse); } } diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml index 3cbe64a..c04d3dc 100644 --- a/examples/declarative/dynamic/qml/PerspectiveItem.qml +++ b/examples/declarative/dynamic/qml/PerspectiveItem.qml @@ -1,16 +1,25 @@ import Qt 4.7 Image { - id: tree + id: rootItem + property bool created: false - property double scaleFactor: Math.max((y+height-250)*0.01, 0.3) - property double scaledBottom: y + (height+height*scaleFactor)/2 - property bool onLand: scaledBottom > window.height/2 - property string image //Needed for compatibility with GenericItem + property string image + + property double scaledBottom: y + (height + height*scale) / 2 + property bool onLand: scaledBottom > window.height / 2 + + source: image opacity: onLand ? 1 : 0.25 - onCreatedChanged: if (created && !onLand) { tree.destroy() } else { z = scaledBottom } - scale: scaleFactor - transformOrigin: "Center" - source: image; smooth: true - onYChanged: z = scaledBottom + scale: Math.max((y + height - 250) * 0.01, 0.3) + smooth: true + + onCreatedChanged: { + if (created && !onLand) + rootItem.destroy(); + else + z = scaledBottom; + } + + onYChanged: z = scaledBottom; } diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml index 3627964..43dcb9a 100644 --- a/examples/declarative/dynamic/qml/Sun.qml +++ b/examples/declarative/dynamic/qml/Sun.qml @@ -2,23 +2,37 @@ import Qt 4.7 Image { id: sun + property bool created: false property string image: "../images/sun.png" - onCreatedChanged: if(created){window.activeSuns++;}else{window.activeSuns--;} - source: image; - z: 1 + source: image - //x and y get set when instantiated - //head offscreen + // once item is created, start moving offscreen NumberAnimation on y { - to: window.height / 2; + to: window.height / 2 running: created - onRunningChanged: if (running) duration = (window.height - sun.y) * 10; else state = "OffScreen"; + onRunningChanged: { + if (running) + duration = (window.height - sun.y) * 10; + else + state = "OffScreen" + } } states: State { - name: "OffScreen"; - StateChangeScript { script: { sun.created = false; sun.destroy() } } + name: "OffScreen" + StateChangeScript { + script: { sun.created = false; sun.destroy() } + } + } + + onCreatedChanged: { + if (created) { + sun.z = 1; // above the sky but below the ground layer + window.activeSuns++; + } else { + window.activeSuns--; + } } } diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js index 08f5320..59750f3 100644 --- a/examples/declarative/dynamic/qml/itemCreation.js +++ b/examples/declarative/dynamic/qml/itemCreation.js @@ -1,53 +1,38 @@ var itemComponent = null; var draggedItem = null; var startingMouse; -var startingZ; -//Until QT-2385 is resolved we need to convert to scene coordinates manually -var xOffset; -var yOffset; -function setSceneOffset() -{ - xOffset = 0; - yOffset = 0; - var p = itemButton; - while(p != window){ - xOffset += p.x; - yOffset += p.y; - p = p.parent; - } -} +var posnInWindow; function startDrag(mouse) { - setSceneOffset(); + posnInWindow = paletteItem.mapToItem(null, 0, 0); startingMouse = { x: mouse.x, y: mouse.y } loadComponent(); } -//Creation is split into two functions due to an asyncronous wait while +//Creation is split into two functions due to an asynchronous wait while //possible external files are loaded. function loadComponent() { - if (itemComponent != null) //Already loaded the component + if (itemComponent != null) { // component has been previously loaded createItem(); + return; + } - itemComponent = Qt.createComponent(itemButton.file); - //console.log(itemButton.file) - if(itemComponent.status == Component.Loading){ - component.statusChanged.connect(finishCreation); - }else{//Depending on the content, it can be ready or error immediately + itemComponent = Qt.createComponent(paletteItem.componentFile); + if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately + component.statusChanged.connect(createItem); + else createItem(); - } } function createItem() { if (itemComponent.status == Component.Ready && draggedItem == null) { draggedItem = itemComponent.createObject(window); - draggedItem.image = itemButton.image; - draggedItem.x = xOffset; - draggedItem.y = yOffset; - startingZ = draggedItem.z; - draggedItem.z = 4;//On top + draggedItem.image = paletteItem.image; + draggedItem.x = posnInWindow.x; + draggedItem.y = posnInWindow.y; + draggedItem.z = 3; // make sure created item is above the ground layer } else if (itemComponent.status == Component.Error) { draggedItem = null; console.log("error creating component"); @@ -55,25 +40,24 @@ function createItem() { } } -function moveDrag(mouse) +function continueDrag(mouse) { - if(draggedItem == null) + if (draggedItem == null) return; - draggedItem.x = mouse.x + xOffset - startingMouse.x; - draggedItem.y = mouse.y + yOffset - startingMouse.y; + draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; + draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; } function endDrag(mouse) { - if(draggedItem == null) + if (draggedItem == null) return; - if(draggedItem.x + draggedItem.width > toolbox.x){ //Don't drop it in the toolbox + if (draggedItem.x + draggedItem.width > toolbox.x) { //Don't drop it in the toolbox draggedItem.destroy(); draggedItem = null; - }else{ - draggedItem.z = startingZ; + } else { draggedItem.created = true; draggedItem = null; } diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index ae31b03..f3eac48 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -51,9 +51,9 @@ Rectangle { } Text { text: { - if (webFont.status == 1) myText - else if (webFont.status == 2) "Loading..." - else if (webFont.status == 3) "Error loading font" + if (webFont.status == FontLoader.Ready) myText + else if (webFont.status == FontLoader.Loading) "Loading..." + else if (webFont.status == FontLoader.Error) "Error loading font" } color: "lightsteelblue" width: parent.width diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml index 236a9c5..9b05ad5 100644 --- a/examples/declarative/listview/dynamic.qml +++ b/examples/declarative/listview/dynamic.qml @@ -56,7 +56,7 @@ Rectangle { Item { width: container.width; height: 55 - + Column { id: moveButtons x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter @@ -84,7 +84,7 @@ Rectangle { spacing: 5 Repeater { model: attributes - Component { + Component { Text { text: description; color: "White" } } } @@ -95,13 +95,12 @@ Rectangle { id: itemButtons anchors { right: removeButton.left; rightMargin: 35; verticalCenter: parent.verticalCenter } - width: childrenRect.width + width: childrenRect.width spacing: 10 Image { source: "content/pics/list-add.png" scale: clickUp.isPressed ? 0.9 : 1 - transformOrigin: Item.Center ClickAutoRepeating { id: clickUp @@ -115,9 +114,8 @@ Rectangle { Image { source: "content/pics/list-remove.png" scale: clickDown.isPressed ? 0.9 : 1 - transformOrigin: Item.Center - ClickAutoRepeating { + ClickAutoRepeating { id: clickDown anchors.fill: parent onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) @@ -147,7 +145,7 @@ Rectangle { width: 8; height: view.height; anchors.right: view.right opacity: 0 - orientation: "Vertical" + orientation: Qt.Vertical position: view.visibleArea.yPosition pageSize: view.visibleArea.heightRatio @@ -158,7 +156,7 @@ Rectangle { } transitions: Transition { NumberAnimation { properties: "opacity"; duration: 400 } - } + } } Row { @@ -198,10 +196,10 @@ Rectangle { } } - Image { + Image { source: "content/pics/archive-remove.png" - MouseArea { + MouseArea { anchors.fill: parent onClicked: fruitModel.clear() } diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml index e387f28..b73b3a3 100644 --- a/examples/declarative/listview/itemlist.qml +++ b/examples/declarative/listview/itemlist.qml @@ -33,7 +33,7 @@ Rectangle { anchors { fill: parent; bottomMargin: 30 } model: itemModel preferredHighlightBegin: 0; preferredHighlightEnd: 0 - highlightRangeMode: "StrictlyEnforceRange" + highlightRangeMode: ListView.StrictlyEnforceRange orientation: ListView.Horizontal snapMode: ListView.SnapOneItem; flickDeceleration: 2000 } @@ -55,7 +55,7 @@ Rectangle { radius: 3 color: view.currentIndex == index ? "blue" : "white" - MouseArea { + MouseArea { width: 20; height: 20 anchors.centerIn: parent onClicked: view.currentIndex = index diff --git a/examples/declarative/listview/listview-example.qml b/examples/declarative/listview/listview-example.qml index 6feedf6..2e8cdda 100644 --- a/examples/declarative/listview/listview-example.qml +++ b/examples/declarative/listview/listview-example.qml @@ -75,7 +75,7 @@ Rectangle { highlight: petHighlight currentIndex: list1.currentIndex preferredHighlightBegin: 80; preferredHighlightEnd: 220 - highlightRangeMode: "ApplyRange" + highlightRangeMode: ListView.ApplyRange } ListView { @@ -87,7 +87,7 @@ Rectangle { highlight: Rectangle { color: "lightsteelblue" } currentIndex: list1.currentIndex preferredHighlightBegin: 125; preferredHighlightEnd: 125 - highlightRangeMode: "StrictlyEnforceRange" + highlightRangeMode: ListView.StrictlyEnforceRange flickDeceleration: 1000 } } diff --git a/examples/declarative/listview/sections.qml b/examples/declarative/listview/sections.qml index 0a81f63..21f9f03 100644 --- a/examples/declarative/listview/sections.qml +++ b/examples/declarative/listview/sections.qml @@ -61,7 +61,7 @@ Rectangle { height: 20 Text { x: 2; height: parent.height - verticalAlignment: 'AlignVCenter' + verticalAlignment: Text.AlignVCenter text: section font.bold: true } diff --git a/examples/declarative/mousearea/mouse.qml b/examples/declarative/mousearea/mouse.qml index 67302a8..06134b7 100644 --- a/examples/declarative/mousearea/mouse.qml +++ b/examples/declarative/mousearea/mouse.qml @@ -33,7 +33,7 @@ Rectangle { MouseArea { anchors.fill: parent drag.target: parent - drag.axis: "XAxis" + drag.axis: Drag.XAxis drag.minimumX: 0 drag.maximumX: 150 diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml index 4b38d45..e869a21 100644 --- a/examples/declarative/parallax/qml/ParallaxView.qml +++ b/examples/declarative/parallax/qml/ParallaxView.qml @@ -18,9 +18,9 @@ Item { id: list currentIndex: root.currentIndex - onCurrentIndexChanged: root.currentIndex = currentIndex + onCurrentIndexChanged: root.currentIndex = currentIndex - orientation: "Horizontal" + orientation: Qt.Horizontal boundsBehavior: Flickable.DragOverBounds anchors.fill: parent model: VisualItemModel { id: visualModel } @@ -45,10 +45,10 @@ Item { anchors.horizontalCenter: parent.horizontalCenter width: Math.min(count * 50, parent.width - 20) interactive: width == parent.width - 20 - orientation: "Horizontal" + orientation: Qt.Horizontal - delegate: Item { - width: 50; height: 50 + delegate: Item { + width: 50; height: 50 id: delegateRoot Image { @@ -56,7 +56,6 @@ Item { source: modelData.icon smooth: true scale: 0.8 - transformOrigin: "Center" } MouseArea { @@ -64,10 +63,10 @@ Item { onClicked: { root.currentIndex = index } } - states: State { + states: State { name: "Selected" when: delegateRoot.ListView.isCurrentItem == true - PropertyChanges { + PropertyChanges { target: image scale: 1 y: -5 diff --git a/examples/declarative/parallax/qml/Smiley.qml b/examples/declarative/parallax/qml/Smiley.qml index cfa4fed..662addc 100644 --- a/examples/declarative/parallax/qml/Smiley.qml +++ b/examples/declarative/parallax/qml/Smiley.qml @@ -8,7 +8,6 @@ Item { Image { anchors.horizontalCenter: parent.horizontalCenter source: "../pics/shadow.png"; y: smiley.minHeight + 58 - transformOrigin: Item.Center // The scale property depends on the y position of the smiley face. scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) @@ -32,7 +31,7 @@ Item { from: smiley.minHeight; to: smiley.maxHeight easing.type: Easing.OutExpo; duration: 300 } - + // Then move back to minHeight in 1 second, using the OutBounce easing function NumberAnimation { from: smiley.maxHeight; to: smiley.minHeight diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml index 5433156..c628a20 100644 --- a/examples/declarative/scrollbar/ScrollBar.qml +++ b/examples/declarative/scrollbar/ScrollBar.qml @@ -7,26 +7,26 @@ Item { // position and pageSize are in the range 0.0 - 1.0. They are relative to the // height of the page, i.e. a pageSize of 0.5 means that you can see 50% // of the height of the view. - // orientation can be either 'Vertical' or 'Horizontal' + // orientation can be either Qt.Vertical or Qt.Horizontal property real position property real pageSize - property variant orientation : "Vertical" + property variant orientation : Qt.Vertical // A light, semi-transparent background Rectangle { id: background anchors.fill: parent - radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) color: "white" opacity: 0.3 } // Size the bar to the required size, depending upon the orientation. Rectangle { - x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) + x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) color: "black" opacity: 0.7 } diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml index cb1da16..b8a5e36 100644 --- a/examples/declarative/scrollbar/display.qml +++ b/examples/declarative/scrollbar/display.qml @@ -37,7 +37,7 @@ Rectangle { width: 12; height: view.height-12 anchors.right: view.right opacity: 0 - orientation: "Vertical" + orientation: Qt.Vertical position: view.visibleArea.yPosition pageSize: view.visibleArea.heightRatio } @@ -47,7 +47,7 @@ Rectangle { width: view.width-12; height: 12 anchors.bottom: view.bottom opacity: 0 - orientation: "Horizontal" + orientation: Qt.Horizontal position: view.visibleArea.xPosition pageSize: view.visibleArea.widthRatio } diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml index 1aa7696..526a171 100644 --- a/examples/declarative/slideswitch/content/Switch.qml +++ b/examples/declarative/slideswitch/content/Switch.qml @@ -45,7 +45,7 @@ Item { MouseArea { anchors.fill: parent - drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78 + drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 onClicked: toggle() onReleased: dorelease() } diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index 433295b..350c1c4 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -61,7 +61,7 @@ Component { id: mouse anchors.fill: parent drag.target: stickyPage - drag.axis: "XandYAxis" + drag.axis: Drag.XandYAxis drag.minimumY: 0 drag.maximumY: page.height - 80 drag.minimumX: 100 diff --git a/examples/declarative/webview/alerts.qml b/examples/declarative/webview/alerts.qml index 6a5a0d2..7684c3e 100644 --- a/examples/declarative/webview/alerts.qml +++ b/examples/declarative/webview/alerts.qml @@ -52,7 +52,7 @@ WebView { font.pixelSize: 20 width: webView.width*0.75 wrapMode: Text.WordWrap - horizontalAlignment: "AlignHCenter" + horizontalAlignment: Text.AlignHCenter } } } diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index ef6d3df..7b413fb 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -378,9 +378,11 @@ FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex) if (model->completePending()) { // complete listItem->item->setZValue(1); + listItem->item->setParentItem(q->viewport()); model->completeItem(); + } else { + listItem->item->setParentItem(q->viewport()); } - listItem->item->setParentItem(q->viewport()); unrequestedItems.remove(listItem->item); } requestedIndex = -1; @@ -1054,7 +1056,7 @@ void QDeclarativeGridView::setModel(const QVariant &model) } /*! - \qmlproperty component GridView::delegate + \qmlproperty Component GridView::delegate The delegate provides a template defining each item instantiated by the view. The index is exposed as an accessible \c index property. Properties of the @@ -1172,7 +1174,7 @@ int QDeclarativeGridView::count() const } /*! - \qmlproperty component GridView::highlight + \qmlproperty Component GridView::highlight This property holds the component to use as the highlight. An instance of the highlight component will be created for each view. @@ -1415,6 +1417,9 @@ void QDeclarativeGridView::setWrapEnabled(bool wrap) set to 40, then up to 2 delegates above and 2 delegates below the visible area may be retained. + Note that cacheBuffer is not a pixel buffer - it only maintains additional + instantiated delegates. + Setting this value can make scrolling the list smoother at the expense of additional memory usage. It is not a substitute for creating efficient delegates; the fewer elements in a delegate, the faster a view may be diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 0395766..9433ba0 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -720,7 +720,7 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) */ /*! - \qmlproperty List<Object> Keys::forwardTo + \qmlproperty list<Object> Keys::forwardTo This property provides a way to forward key presses, key releases, and keyboard input coming from input methods to other items. This can be useful when you want diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 8485071..416e0a8 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -573,9 +573,11 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex) if (model->completePending()) { // complete listItem->item->setZValue(1); + listItem->item->setParentItem(q->viewport()); model->completeItem(); + } else { + listItem->item->setParentItem(q->viewport()); } - listItem->item->setParentItem(q->viewport()); QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); if (sectionCriteria && sectionCriteria->delegate()) { @@ -648,7 +650,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) FxListItem *item = 0; int pos = itemEnd + 1; while (modelIndex < model->count() && pos <= fillTo) { - //qDebug() << "refill: append item" << modelIndex << "pos" << pos; +// qDebug() << "refill: append item" << modelIndex << "pos" << pos; if (!(item = createItem(modelIndex))) break; item->setPosition(pos); @@ -659,8 +661,8 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) if (doBuffer) // never buffer more than one item per frame break; } - while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos > fillFrom) { - //qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos; + while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos-1 >= fillFrom) { +// qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos; if (!(item = createItem(visibleIndex-1))) break; --visibleIndex; @@ -676,7 +678,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) while (visibleItems.count() > 1 && (item = visibleItems.first()) && item->endPosition() < bufferFrom) { if (item->attached->delayRemove()) break; - //qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition(); +// qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition(); if (item->index != -1) visibleIndex++; visibleItems.removeFirst(); @@ -686,7 +688,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) while (visibleItems.count() > 1 && (item = visibleItems.last()) && item->position() > bufferTo) { if (item->attached->delayRemove()) break; - //qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1; +// qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1 << item->position(); visibleItems.removeLast(); releaseItem(item); changed = true; @@ -1488,7 +1490,7 @@ void QDeclarativeListView::setModel(const QVariant &model) } /*! - \qmlproperty component ListView::delegate + \qmlproperty Component ListView::delegate The delegate provides a template defining each item instantiated by the view. The index is exposed as an accessible \c index property. Properties of the @@ -1608,7 +1610,7 @@ int QDeclarativeListView::count() const } /*! - \qmlproperty component ListView::highlight + \qmlproperty Component ListView::highlight This property holds the component to use as the highlight. An instance of the highlight component will be created for each list. @@ -1848,6 +1850,9 @@ void QDeclarativeListView::setWrapEnabled(bool wrap) set to 40, then up to 2 delegates above and 2 delegates below the visible area may be retained. + Note that cacheBuffer is not a pixel buffer - it only maintains additional + instantiated delegates. + Setting this value can make scrolling the list smoother at the expense of additional memory usage. It is not a substitute for creating efficient delegates; the fewer elements in a delegate, the faster a view may be diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index d178107..74f2338 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -288,6 +288,17 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() */ /*! + \qmlsignal MouseArea::onCanceled() + + This handler is called when the mouse events are canceled, either because the event was not accepted or + another element stole the mouse event handling. This signal is for advanced users, it's useful in case there + is more than one mouse areas handling input, or when there is a mouse area inside a flickable. In the latter + case, if you do some logic on pressed and then start dragging, the flickable will steal the mouse handling + from the mouse area. In these cases, to reset the logic when there is no mouse handling anymore, you should + use onCanceled, in addition to onReleased. +*/ + +/*! \internal \class QDeclarativeMouseArea \brief The QDeclarativeMouseArea class provides a simple mouse handling abstraction for use within Qml. @@ -562,10 +573,12 @@ bool QDeclarativeMouseArea::sceneEvent(QEvent *event) // state d->pressed = false; setKeepMouseGrab(false); - QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, false); - emit released(&me); + emit canceled(); emit pressedChanged(); - setHovered(false); + if (d->hovered) { + d->hovered = false; + emit hoveredChanged(); + } } } return rv; @@ -746,7 +759,7 @@ QDeclarativeDrag *QDeclarativeMouseArea::drag() /*! \qmlproperty Item MouseArea::drag.target \qmlproperty bool MouseArea::drag.active - \qmlproperty Axis MouseArea::drag.axis + \qmlproperty enumeration MouseArea::drag.axis \qmlproperty real MouseArea::drag.minimumX \qmlproperty real MouseArea::drag.maximumX \qmlproperty real MouseArea::drag.minimumY @@ -757,7 +770,7 @@ QDeclarativeDrag *QDeclarativeMouseArea::drag() \list \i \c target specifies the item to drag. \i \c active specifies if the target item is being currently dragged. - \i \c axis specifies whether dragging can be done horizontally (XAxis), vertically (YAxis), or both (XandYAxis) + \i \c axis specifies whether dragging can be done horizontally (Drag.XAxis), vertically (Drag.YAxis), or both (Drag.XandYAxis) \i the minimum and maximum properties limit how far the target can be dragged along the corresponding axes. \endlist diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h index e3f523b..df77ac6 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h @@ -163,6 +163,7 @@ Q_SIGNALS: void doubleClicked(QDeclarativeMouseEvent *mouse); void entered(); void exited(); + void canceled(); protected: void setHovered(bool); diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp index 6430fae..c4f0b86 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp +++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp @@ -210,6 +210,8 @@ void QDeclarativePaintedItem::geometryChanged(const QRectF &newGeometry, if (newGeometry.width() != oldGeometry.width() || newGeometry.height() != oldGeometry.height()) clearCache(); + + QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); } QVariant QDeclarativePaintedItem::itemChange(GraphicsItemChange change, diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 5c3a3c0..040fc98 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -561,7 +561,7 @@ void QDeclarativePathViewPrivate::setOffset(qreal o) } /*! - \qmlproperty component PathView::highlight + \qmlproperty Component PathView::highlight This property holds the component to use as the highlight. An instance of the highlight component will be created for each view. @@ -790,7 +790,7 @@ void QDeclarativePathView::setInteractive(bool interactive) } /*! - \qmlproperty component PathView::delegate + \qmlproperty Component PathView::delegate The delegate provides a template defining each item instantiated by the view. The index is exposed as an accessible \c index property. Properties of the diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index d0ee2ee..d095dbe 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -728,7 +728,7 @@ void QDeclarativeTextEdit::setPersistentSelection(bool on) } /* - \qmlproperty number TextEdit::textMargin + \qmlproperty real TextEdit::textMargin The margin, in pixels, around the text in the TextEdit. */ diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index a1fa8c6..9ae4e1a 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -706,14 +706,15 @@ bool QDeclarativeTextInput::hasAcceptableInput() const } /*! - \qmlproperty TextInput.EchoMode TextInput::echoMode + \qmlproperty enumeration TextInput::echoMode Specifies how the text should be displayed in the TextInput. - The default is Normal, which displays the text as it is. Other values - are Password, which displays asterixes instead of characters, NoEcho, - which displays nothing, and PasswordEchoOnEdit, which displays all but the - current character as asterixes. - + \list + \o TextInput.Normal - Displays the text as it is. (Default) + \o TextInput.Password - Displays asterixes instead of characters. + \o TextInput.NoEcho - Displays nothing. + \o TextInput.PasswordEchoOnEdit - Displays all but the current character as asterixes. + \endlist */ QDeclarativeTextInput::EchoMode QDeclarativeTextInput::echoMode() const { @@ -1084,7 +1085,7 @@ void QDeclarativeTextInput::setPasswordCharacter(const QString &str) \qmlproperty string TextInput::displayText This is the text displayed in the TextInput. - + If \l echoMode is set to TextInput::Normal, this holds the same value as the TextInput::text property. Otherwise, this property holds the text visible to the user, while diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index f01d4c2..1038c83 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -44,6 +44,7 @@ #include "qdeclarativeitem.h" #include <qdeclarativecontext.h> +#include <qdeclarativecontext_p.h> #include <qdeclarativeengine.h> #include <qdeclarativeexpression.h> #include <qdeclarativepackage_p.h> @@ -759,7 +760,7 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) } /*! - \qmlproperty component VisualDataModel::delegate + \qmlproperty Component VisualDataModel::delegate The delegate provides a template defining each item instantiated by a view. The index is exposed as an accessible \c index property. Properties of the @@ -963,6 +964,13 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q } if (d->m_cache.releaseItem(obj)) { + // Remove any bindings to avoid warnings due to parent change. + QObjectPrivate *p = QObjectPrivate::get(obj); + Q_ASSERT(p->declarativeData); + QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData); + if (d->ownContext && d->context) + d->context->clearExpressions(); + if (inPackage) { emit destroyingPackage(qobject_cast<QDeclarativePackage*>(obj)); } else { diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index ae4223e..b61b8cb 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -528,13 +528,8 @@ void QDeclarativeContextData::invalidate() parent = 0; } -void QDeclarativeContextData::destroy() +void QDeclarativeContextData::clearExpressions() { - if (linkedContext) - linkedContext->destroy(); - - if (engine) invalidate(); - QDeclarativeAbstractExpression *expression = expressions; while (expression) { QDeclarativeAbstractExpression *nextExpression = expression->m_nextExpression; @@ -546,6 +541,16 @@ void QDeclarativeContextData::destroy() expression = nextExpression; } expressions = 0; +} + +void QDeclarativeContextData::destroy() +{ + if (linkedContext) + linkedContext->destroy(); + + if (engine) invalidate(); + + clearExpressions(); while (contextObjects) { QDeclarativeData *co = contextObjects; diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h index c7fb099..6b6cd0a 100644 --- a/src/declarative/qml/qdeclarativecontext_p.h +++ b/src/declarative/qml/qdeclarativecontext_p.h @@ -113,6 +113,7 @@ class QDeclarativeContextData public: QDeclarativeContextData(); QDeclarativeContextData(QDeclarativeContext *); + void clearExpressions(); void destroy(); void invalidate(); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 6ddd01e..9f5cafe 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -329,8 +329,10 @@ void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o) QObjectPrivate *p = QObjectPrivate::get(o); Q_ASSERT(p->declarativeData); QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData); - if (d->ownContext) + if (d->ownContext && d->context) { d->context->destroy(); + d->context = 0; + } } void QDeclarativeData::destroyed(QAbstractDeclarativeData *d, QObject *o) @@ -962,7 +964,7 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS Q_ASSERT(context); if(ctxt->argumentCount() != 1) { - return ctxt->throwError("Qt.createComponent(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.createComponent(): Invalid arguments")); }else{ QString arg = ctxt->argument(0).toString(); if (arg.isEmpty()) @@ -982,7 +984,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS QDeclarativeEngine* activeEngine = activeEnginePriv->q_func(); if(ctxt->argumentCount() < 2 || ctxt->argumentCount() > 3) - return ctxt->throwError("Qt.createQmlObject(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.createQmlObject(): Invalid arguments")); QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt); Q_ASSERT(context); @@ -1002,7 +1004,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1)); if(!parentArg) - return ctxt->throwError("Qt.createQmlObject(): Missing parent object"); + return ctxt->throwError(QLatin1String("Qt.createQmlObject(): Missing parent object")); QDeclarativeComponent component(activeEngine); component.setData(qml.toUtf8(), url); @@ -1027,7 +1029,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS } if (!component.isReady()) - return ctxt->throwError("Qt.createQmlObject(): Component is not ready"); + return ctxt->throwError(QLatin1String("Qt.createQmlObject(): Component is not ready")); QObject *obj = component.beginCreate(context->asQDeclarativeContext()); if(obj) @@ -1076,7 +1078,7 @@ QScriptValue QDeclarativeEnginePrivate::isQtObject(QScriptContext *ctxt, QScript QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 3) - return ctxt->throwError("Qt.vector(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.vector(): Invalid arguments")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); qsreal z = ctxt->argument(2).toNumber(); @@ -1087,7 +1089,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE { int argCount = ctxt->argumentCount(); if(argCount == 0 || argCount > 2) - return ctxt->throwError("Qt.formatDate(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid arguments")); QDate date = ctxt->argument(0).toDateTime().date(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; @@ -1098,7 +1100,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else { - return ctxt->throwError("Qt.formatDate(): Invalid date format"); + return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid date format")); } } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); @@ -1108,7 +1110,7 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE { int argCount = ctxt->argumentCount(); if(argCount == 0 || argCount > 2) - return ctxt->throwError("Qt.formatTime(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.formatTime(): Invalid arguments")); QTime date = ctxt->argument(0).toDateTime().time(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; @@ -1119,7 +1121,7 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else { - return ctxt->throwError("Qt.formatTime(): Invalid time format"); + return ctxt->throwError(QLatin1String("Qt.formatTime(): Invalid time format")); } } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); @@ -1129,7 +1131,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr { int argCount = ctxt->argumentCount(); if(argCount == 0 || argCount > 2) - return ctxt->throwError("Qt.formatDateTime(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid arguments")); QDateTime date = ctxt->argument(0).toDateTime(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; @@ -1140,7 +1142,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else { - return ctxt->throwError("Qt.formatDateTime(): Invalid datetime format"); + return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid datetime format")); } } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); @@ -1150,7 +1152,7 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine { int argCount = ctxt->argumentCount(); if(argCount < 3 || argCount > 4) - return ctxt->throwError("Qt.rgba(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.rgba(): Invalid arguments")); qsreal r = ctxt->argument(0).toNumber(); qsreal g = ctxt->argument(1).toNumber(); qsreal b = ctxt->argument(2).toNumber(); @@ -1172,7 +1174,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine { int argCount = ctxt->argumentCount(); if(argCount < 3 || argCount > 4) - return ctxt->throwError("Qt.hsla(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.hsla(): Invalid arguments")); qsreal h = ctxt->argument(0).toNumber(); qsreal s = ctxt->argument(1).toNumber(); qsreal l = ctxt->argument(2).toNumber(); @@ -1193,7 +1195,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 4) - return ctxt->throwError("Qt.rect(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.rect(): Invalid arguments")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); @@ -1209,7 +1211,7 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) - return ctxt->throwError("Qt.point(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.point(): Invalid arguments")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QPointF(x, y))); @@ -1218,7 +1220,7 @@ QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngin QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) - return ctxt->throwError("Qt.size(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.size(): Invalid arguments")); qsreal w = ctxt->argument(0).toNumber(); qsreal h = ctxt->argument(1).toNumber(); return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QSizeF(w, h))); @@ -1227,7 +1229,7 @@ QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 1 && ctxt->argumentCount() != 2) - return ctxt->throwError("Qt.lighter(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.lighter(): Invalid arguments")); QVariant v = ctxt->argument(0).toVariant(); QColor color; if (v.userType() == QVariant::Color) @@ -1249,7 +1251,7 @@ QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEng QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 1 && ctxt->argumentCount() != 2) - return ctxt->throwError("Qt.darker(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.darker(): Invalid arguments")); QVariant v = ctxt->argument(0).toVariant(); QColor color; if (v.userType() == QVariant::Color) @@ -1282,7 +1284,7 @@ QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QSc QScriptValue QDeclarativeEnginePrivate::fontFamilies(QScriptContext *ctxt, QScriptEngine *e) { if(ctxt->argumentCount() != 0) - return ctxt->throwError("Qt.fontFamilies(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.fontFamilies(): Invalid arguments")); QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(e); QFontDatabase database; @@ -1292,7 +1294,7 @@ QScriptValue QDeclarativeEnginePrivate::fontFamilies(QScriptContext *ctxt, QScri QScriptValue QDeclarativeEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *) { if (ctxt->argumentCount() != 1) - return ctxt->throwError("Qt.md5(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.md5(): Invalid arguments")); QByteArray data = ctxt->argument(0).toString().toUtf8(); QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5); @@ -1303,7 +1305,7 @@ QScriptValue QDeclarativeEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::btoa(QScriptContext *ctxt, QScriptEngine *) { if (ctxt->argumentCount() != 1) - return ctxt->throwError("Qt.btoa(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.btoa(): Invalid arguments")); QByteArray data = ctxt->argument(0).toString().toUtf8(); @@ -1313,7 +1315,7 @@ QScriptValue QDeclarativeEnginePrivate::btoa(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::atob(QScriptContext *ctxt, QScriptEngine *) { if (ctxt->argumentCount() != 1) - return ctxt->throwError("Qt.atob(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.atob(): Invalid arguments")); QByteArray data = ctxt->argument(0).toString().toUtf8(); @@ -1414,7 +1416,7 @@ QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptE QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) - return ctxt->throwError("Qt.tint(): Invalid arguments"); + return ctxt->throwError(QLatin1String("Qt.tint(): Invalid arguments")); //get color QVariant v = ctxt->argument(0).toVariant(); QColor color; diff --git a/src/declarative/qml/qdeclarativeinfo.cpp b/src/declarative/qml/qdeclarativeinfo.cpp index ffed14e..c980a2a 100644 --- a/src/declarative/qml/qdeclarativeinfo.cpp +++ b/src/declarative/qml/qdeclarativeinfo.cpp @@ -78,8 +78,9 @@ QT_BEGIN_NAMESPACE \endcode */ -struct QDeclarativeInfoPrivate +class QDeclarativeInfoPrivate { +public: QDeclarativeInfoPrivate() : ref (1), object(0) {} int ref; diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp index b7e1832..94205fe 100644 --- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp +++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp @@ -46,6 +46,7 @@ #include "private/qdeclarativerefcount_p.h" #include "private/qdeclarativeengine_p.h" #include "private/qdeclarativeexpression_p.h" +#include "qdeclarativeglobal_p.h" #include <QtCore/qobject.h> #include <QtScript/qscriptvalue.h> @@ -94,6 +95,8 @@ QT_BEGIN_NAMESPACE +DEFINE_BOOL_CONFIG_OPTION(xhrDump, QML_XHR_DUMP); + class DocumentImpl; class NodeImpl { @@ -1131,6 +1134,14 @@ void QDeclarativeXMLHttpRequest::requestFromUrl(const QUrl &url) } } + if (xhrDump()) { + qWarning().nospace() << "XMLHttpRequest: " << qPrintable(m_method) << " " << qPrintable(url.toString()); + if (!m_data.isEmpty()) { + qWarning().nospace() << " " + << qPrintable(QString::fromUtf8(m_data)); + } + } + if (m_method == QLatin1String("GET")) m_network = networkAccessManager()->get(request); else if (m_method == QLatin1String("HEAD")) @@ -1264,6 +1275,16 @@ void QDeclarativeXMLHttpRequest::finished() if (cbv.isError()) printError(cbv); } m_responseEntityBody.append(m_network->readAll()); + + if (xhrDump()) { + qWarning().nospace() << "XMLHttpRequest: RESPONSE " << qPrintable(m_url.toString()); + if (!m_responseEntityBody.isEmpty()) { + qWarning().nospace() << " " + << qPrintable(QString::fromUtf8(m_responseEntityBody)); + } + } + + m_data.clear(); destroyNetwork(); if (m_state < Loading) { diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 206621b..0f7c946 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -755,7 +755,7 @@ void QDeclarativeScriptAction::setScript(const QDeclarativeScriptString &script) } /*! - \qmlproperty QString ScriptAction::scriptName + \qmlproperty string ScriptAction::scriptName This property holds the the name of the StateChangeScript to run. This property is only valid when ScriptAction is used as part of a transition. @@ -791,7 +791,7 @@ void QDeclarativeScriptActionPrivate::execute() if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.evaluate(); - if (expr.hasError()) + if (expr.hasError()) qmlInfo(q) << expr.error(); } } @@ -844,7 +844,7 @@ QAbstractAnimation *QDeclarativeScriptAction::qtAnimation() The PropertyAction is immediate - the target property is not animated to the selected value in any way. - + \sa QtDeclarative */ /*! @@ -2347,7 +2347,7 @@ QDeclarativeParentAnimation::~QDeclarativeParentAnimation() } /*! - \qmlproperty item ParentAnimation::target + \qmlproperty Item ParentAnimation::target The item to reparent. When used in a transition, if no target is specified all @@ -2370,7 +2370,7 @@ void QDeclarativeParentAnimation::setTarget(QDeclarativeItem *target) } /*! - \qmlproperty item ParentAnimation::newParent + \qmlproperty Item ParentAnimation::newParent The new parent to animate to. If not set, then the parent defined in the end state of the transition. @@ -2392,7 +2392,7 @@ void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent) } /*! - \qmlproperty item ParentAnimation::via + \qmlproperty Item ParentAnimation::via The item to reparent via. This provides a way to do an unclipped animation when both the old parent and new parent are clipped diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 3810256..0985a6b 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -591,7 +591,7 @@ void QDeclarativeListModel::set(int index, const QScriptValue& valuemap) Changes the \a property of the item at \a index in the list model to \a value. \code - fruitModel.set(3, "cost", 5.95) + fruitModel.setProperty(3, "cost", 5.95) \endcode The \a index must be an element in the list. diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 62d913c..833e284 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -484,10 +484,7 @@ QSize QDeclarativeViewPrivate::rootObjectSize() QSize rootObjectSize(0,0); int widthCandidate = -1; int heightCandidate = -1; - if (declarativeItemRoot) { - widthCandidate = declarativeItemRoot->width(); - heightCandidate = declarativeItemRoot->height(); - } else if (root) { + if (root) { QSizeF size = root->boundingRect().size(); widthCandidate = size.width(); heightCandidate = size.height(); @@ -614,16 +611,15 @@ bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e) /*! \internal - Preferred size follows the root object in - resize mode SizeViewToRootObject and - the view in resize mode SizeRootObjectToView. + Preferred size follows the root object geometry. */ QSize QDeclarativeView::sizeHint() const { - if (d->resizeMode == SizeRootObjectToView) { + QSize rootObjectSize = d->rootObjectSize(); + if (rootObjectSize.isEmpty()) { return size(); - } else { // d->resizeMode == SizeViewToRootObject - return d->rootObjectSize(); + } else { + return rootObjectSize; } } diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index bc5f1ef..8f8544f 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -60,16 +60,20 @@ QT_BEGIN_NAMESPACE template <typename Type> class QDataBuffer { public: - QDataBuffer(int res = 64) + QDataBuffer(int res) { capacity = res; - buffer = (Type*) qMalloc(capacity * sizeof(Type)); + if (res) + buffer = (Type*) qMalloc(capacity * sizeof(Type)); + else + buffer = 0; siz = 0; } ~QDataBuffer() { - qFree(buffer); + if (buffer) + qFree(buffer); } inline void reset() { siz = 0; } @@ -104,6 +108,8 @@ public: inline void reserve(int size) { if (size > capacity) { + if (capacity == 0) + capacity = 1; while (capacity < size) capacity *= 2; buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type)); @@ -112,7 +118,12 @@ public: inline void shrink(int size) { capacity = size; - buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type)); + if (size) + buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type)); + else { + qFree(buffer); + buffer = 0; + } } inline void swap(QDataBuffer<Type> &other) { diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index ad0c2eb..1b01960 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -154,7 +154,8 @@ QT_FT_Outline *QOutlineMapper::convertPath(const QVectorPath &path) // ### We can kill this copying and just use the buffer straight... m_elements.resize(count); - memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); + if (count) + memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); m_element_types.resize(0); } diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h index d0ce1a9..39b7593 100644 --- a/src/gui/painting/qoutlinemapper_p.h +++ b/src/gui/painting/qoutlinemapper_p.h @@ -87,8 +87,15 @@ const int QT_RASTER_COORD_LIMIT = 32767; class QOutlineMapper { public: - QOutlineMapper() - : m_round_coords(false) + QOutlineMapper() : + m_element_types(0), + m_elements(0), + m_elements_dev(0), + m_points(0), + m_tags(0), + m_contours(0), + m_polygon_dev(0), + m_round_coords(false) { } diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 9148ac2..483bc0c 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -336,17 +336,6 @@ void QRasterPaintEngine::init() d->hdc = 0; #endif - d->rasterPoolSize = 8192; - d->rasterPoolBase = -#if defined(Q_WS_WIN64) - // We make use of setjmp and longjmp in qgrayraster.c which requires - // 16-byte alignment, hence we hardcode this requirement here.. - (unsigned char *) _aligned_malloc(d->rasterPoolSize, sizeof(void*) * 2); -#else - (unsigned char *) malloc(d->rasterPoolSize); -#endif - Q_CHECK_PTR(d->rasterPoolBase); - // The antialiasing raster. d->grayRaster.reset(new QT_FT_Raster); Q_CHECK_PTR(d->grayRaster.data()); @@ -354,8 +343,6 @@ void QRasterPaintEngine::init() QT_THROW(std::bad_alloc()); // an error creating the raster is caused by a bad malloc - qt_ft_grays_raster.raster_reset(*d->grayRaster.data(), d->rasterPoolBase, d->rasterPoolSize); - d->rasterizer.reset(new QRasterizer); d->rasterBuffer.reset(new QRasterBuffer()); d->outlineMapper.reset(new QOutlineMapper); @@ -437,12 +424,6 @@ QRasterPaintEngine::~QRasterPaintEngine() { Q_D(QRasterPaintEngine); -#if defined(Q_WS_WIN64) - _aligned_free(d->rasterPoolBase); -#else - free(d->rasterPoolBase); -#endif - qt_ft_grays_raster.raster_done(*d->grayRaster.data()); } @@ -4090,6 +4071,22 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, return; } + const int rasterPoolInitialSize = 8192; + int rasterPoolSize = rasterPoolInitialSize; + unsigned char *rasterPoolBase; +#if defined(Q_WS_WIN64) + rasterPoolBase = + // We make use of setjmp and longjmp in qgrayraster.c which requires + // 16-byte alignment, hence we hardcode this requirement here.. + (unsigned char *) _aligned_malloc(rasterPoolSize, sizeof(void*) * 2); +#else + unsigned char rasterPoolOnStack[rasterPoolInitialSize]; + rasterPoolBase = rasterPoolOnStack; +#endif + Q_CHECK_PTR(rasterPoolBase); + + qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); + void *data = userData; QT_FT_BBox clip_box = { deviceRect.x(), @@ -4122,13 +4119,14 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, int new_size = rasterPoolSize * 2; if (new_size > 1024 * 1024) { qWarning("QPainter: Rasterization of primitive failed"); - return; + break; } #if defined(Q_WS_WIN64) _aligned_free(rasterPoolBase); #else - free(rasterPoolBase); + if (rasterPoolBase != rasterPoolOnStack) // initially on the stack + free(rasterPoolBase); #endif rasterPoolSize = new_size; @@ -4149,6 +4147,13 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, done = true; } } + +#if defined(Q_WS_WIN64) + _aligned_free(rasterPoolBase); +#else + if (rasterPoolBase != rasterPoolOnStack) // initially on the stack + free(rasterPoolBase); +#endif } void QRasterPaintEnginePrivate::recalculateFastImages() diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 55eb82e..0a0b0b2 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -300,6 +300,10 @@ QRasterPaintEnginePrivate : public QPaintEngineExPrivate { Q_DECLARE_PUBLIC(QRasterPaintEngine) public: + QRasterPaintEnginePrivate() : QPaintEngineExPrivate(), + cachedLines(0) + { + } void rasterizeLine_dashed(QLineF line, qreal width, int *dashIndex, qreal *dashOffset, bool *inDash); @@ -354,8 +358,6 @@ public: QScopedPointer<QDashStroker> dashStroker; QScopedPointer<QT_FT_Raster> grayRaster; - unsigned long rasterPoolSize; - unsigned char *rasterPoolBase; QDataBuffer<QLineF> cachedLines; QSpanData image_filler; diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index a78cafb..fda937e 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -149,6 +149,7 @@ QDebug Q_GUI_EXPORT &operator<<(QDebug &s, const QVectorPath &path) struct StrokeHandler { + StrokeHandler(int reserve) : pts(reserve), types(reserve) {} QDataBuffer<qreal> pts; QDataBuffer<QPainterPath::ElementType> types; }; @@ -394,7 +395,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) return; if (!d->strokeHandler) { - d->strokeHandler = new StrokeHandler; + d->strokeHandler = new StrokeHandler(path.elementCount()+4); d->stroker.setMoveToHook(qpaintengineex_moveTo); d->stroker.setLineToHook(qpaintengineex_lineTo); d->stroker.setCubicToHook(qpaintengineex_cubicTo); diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index c910024..78553c9 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -278,7 +278,8 @@ private: }; SegmentTree::SegmentTree(QPathSegments &segments) - : m_segments(segments) + : m_segments(segments), + m_intersections(0) { m_bounds.x1 = qt_inf(); m_bounds.y1 = qt_inf(); @@ -806,7 +807,7 @@ void QWingedEdge::intersectAndAdd() for (int i = 0; i < m_segments.points(); ++i) addVertex(m_segments.pointAt(i)); - QDataBuffer<QPathSegments::Intersection> intersections; + QDataBuffer<QPathSegments::Intersection> intersections(m_segments.segments()); for (int i = 0; i < m_segments.segments(); ++i) { intersections.reset(); @@ -857,11 +858,17 @@ void QWingedEdge::intersectAndAdd() } } -QWingedEdge::QWingedEdge() +QWingedEdge::QWingedEdge() : + m_edges(0), + m_vertices(0), + m_segments(0) { } -QWingedEdge::QWingedEdge(const QPainterPath &subject, const QPainterPath &clip) +QWingedEdge::QWingedEdge(const QPainterPath &subject, const QPainterPath &clip) : + m_edges(subject.length()), + m_vertices(subject.length()), + m_segments(subject.length()) { m_segments.setPath(subject); m_segments.addPath(clip); @@ -1414,9 +1421,9 @@ bool QPathClipper::intersect() else if (clipIsRect) return subjectPath.intersects(r2); - QPathSegments a; + QPathSegments a(subjectPath.length()); a.setPath(subjectPath); - QPathSegments b; + QPathSegments b(clipPath.length()); b.setPath(clipPath); QIntersectionFinder finder; @@ -1459,9 +1466,9 @@ bool QPathClipper::contains() if (clipIsRect) return subjectPath.contains(r2); - QPathSegments a; + QPathSegments a(subjectPath.length()); a.setPath(subjectPath); - QPathSegments b; + QPathSegments b(clipPath.length()); b.setPath(clipPath); QIntersectionFinder finder; diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h index 7962400..fab618d 100644 --- a/src/gui/painting/qpathclipper_p.h +++ b/src/gui/painting/qpathclipper_p.h @@ -199,7 +199,7 @@ public: }; - QPathSegments(); + QPathSegments(int reserve); void setPath(const QPainterPath &path); void addPath(const QPainterPath &path); @@ -345,7 +345,10 @@ inline QPathVertex::operator QPointF() const return QPointF(x, y); } -inline QPathSegments::QPathSegments() +inline QPathSegments::QPathSegments(int reserve) : + m_points(reserve), + m_segments(reserve), + m_intersections(reserve) { } diff --git a/src/gui/painting/qpolygonclipper_p.h b/src/gui/painting/qpolygonclipper_p.h index 1b4cbb3..cdaac1c 100644 --- a/src/gui/painting/qpolygonclipper_p.h +++ b/src/gui/painting/qpolygonclipper_p.h @@ -62,7 +62,8 @@ QT_BEGIN_NAMESPACE template <typename InType, typename OutType, typename CastType> class QPolygonClipper { public: - QPolygonClipper() + QPolygonClipper() : + buffer1(0), buffer2(0) { x1 = y1 = x2 = y2 = 0; } diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index 51d01c9..f8f8afb 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -198,9 +198,11 @@ public: }; QScanConverter::QScanConverter() - : m_alloc(0) + : m_lines(0) + , m_alloc(0) , m_size(0) , m_intersections(0) + , m_active(0) { } @@ -310,6 +312,10 @@ struct QBoolToType template <typename T> void qScanConvert(QScanConverter &d, T allVertical) { + if (!d.m_lines.size()) { + d.m_active.reset(); + return; + } qSort(d.m_lines.data(), d.m_lines.data() + d.m_lines.size(), QT_PREPEND_NAMESPACE(topOrder)); int line = 0; for (int y = d.m_lines.first().top; y <= d.m_bottom; ++y) { diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index e43544c..9b8e099 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -187,7 +187,7 @@ static inline qreal adapted_angle_on_x(const QLineF &line) } QStrokerOps::QStrokerOps() - : m_customData(0), m_moveTo(0), m_lineTo(0), m_cubicTo(0) + : m_elements(0), m_customData(0), m_moveTo(0), m_lineTo(0), m_cubicTo(0) { } diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 90b8be3..20297ae 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1546,18 +1546,35 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); const int tabOverlap = QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; - - if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| - skinElement==QS60StylePrivate::SE_TabBarTabWestInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabWestActive){ - optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); - } else { - if (directionMirrored) - optionTabAdj.rect.adjust(-tabOverlap, 0, 0, 0); + const bool usesScrollButtons = + (widget) ? (qobject_cast<const QTabBar*>(widget))->usesScrollButtons() : false; + const int roomForScrollButton = + usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; + + // adjust for overlapping tabs and scrollbuttons, if necessary + if (skinElement == QS60StylePrivate::SE_TabBarTabEastInactive || + skinElement == QS60StylePrivate::SE_TabBarTabEastActive || + skinElement == QS60StylePrivate::SE_TabBarTabWestInactive || + skinElement == QS60StylePrivate::SE_TabBarTabWestActive){ + if (optionTabAdj.position == QStyleOptionTabV3::Beginning) + optionTabAdj.rect.adjust(0, roomForScrollButton, 0, tabOverlap); + else if (optionTabAdj.position == QStyleOptionTabV3::End) + optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); else - optionTabAdj.rect.adjust(0, 0, tabOverlap, 0); + optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); + } else { + if (directionMirrored) { + if (optionTabAdj.position == QStyleOptionTabV3::Beginning) + optionTabAdj.rect.adjust(-tabOverlap, 0, -roomForScrollButton, 0); + else + optionTabAdj.rect.adjust(-tabOverlap, 0, 0, 0); + } else { + if (optionTabAdj.position == QStyleOptionTabV3::Beginning) + optionTabAdj.rect.adjust(roomForScrollButton, 0, tabOverlap, 0); + else + optionTabAdj.rect.adjust(0, 0, tabOverlap, 0); } + } } QS60StylePrivate::drawSkinElement(skinElement, painter, optionTabAdj.rect, flags); } @@ -1570,7 +1587,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const int borderThickness = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); const int tabOverlap = QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; - const QRect windowRect = painter->window(); + const bool usesScrollButtons = + (widget) ? (qobject_cast<const QTabBar*>(widget))->usesScrollButtons() : false; + const int roomForScrollButton = + usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; switch (tab->shape) { case QTabBar::TriangularWest: @@ -1605,6 +1625,17 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, || optionTab.shape == QTabBar::TriangularEast || optionTab.shape == QTabBar::TriangularWest; + //make room for scrollbuttons + if (!verticalTabs) { + if ((tab->position == QStyleOptionTabV3::Beginning && !directionMirrored)) + tr.adjust(roomForScrollButton, 0, 0, 0); + else if ((tab->position == QStyleOptionTabV3::Beginning && directionMirrored)) + tr.adjust(0, 0, -roomForScrollButton, 0); + } else { + if (tab->position == QStyleOptionTabV3::Beginning) + tr.adjust(0, roomForScrollButton, 0, 0); + } + if (verticalTabs) { painter->save(); int newX, newY, newRotation; @@ -1636,9 +1667,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, alignment |= Qt::TextHideMnemonic; if (!optionTab.icon.isNull()) { QSize iconSize = optionTab.iconSize; - int iconExtent = pixelMetric(PM_TabBarIconSize); - if (iconSize.height() > iconExtent || iconSize.width() > iconExtent) + if (!iconSize.isValid()) { + const int iconExtent = pixelMetric(PM_TabBarIconSize); iconSize = QSize(iconExtent, iconExtent); + } QPixmap tabIcon = optionTab.icon.pixmap(iconSize, (optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); if (tab->text.isEmpty()) @@ -2490,6 +2522,19 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); if (naviPaneSize.height() > sz.height()) sz.setHeight(naviPaneSize.height()); + // Adjust beginning tabbar item size, if scrollbuttons are used. This is to ensure that the + // tabbar item content fits, since scrollbuttons are making beginning tabbar item smaller. + int scrollButtonSize = 0; + if (const QTabBar *tabBar = qobject_cast<const QTabBar *>(widget)) + scrollButtonSize = tabBar->usesScrollButtons() ? pixelMetric(PM_TabBarScrollButtonWidth) : 0; + if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { + const bool verticalTabs = tab->shape == QTabBar::RoundedEast + || tab->shape == QTabBar::RoundedWest + || tab->shape == QTabBar::TriangularEast + || tab->shape == QTabBar::TriangularWest; + if (tab->position == QStyleOptionTab::Beginning) + sz += QSize(verticalTabs ? 0 : scrollButtonSize, !verticalTabs ? 0 : scrollButtonSize); + } } break; case CT_MenuItem: diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index 92d85cc..29a628c 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -200,7 +200,9 @@ protected: menuOpt.menuItemType = QStyleOptionMenuItem::Scroller; if (sliderAction == QAbstractSlider::SliderSingleStepAdd) menuOpt.state |= QStyle::State_DownArrow; +#ifndef Q_WS_S60 p.eraseRect(rect()); +#endif style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p); } diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 8aaaade..d692307 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -67,6 +67,10 @@ #include <private/qt_cocoa_helpers_mac_p.h> #endif +#ifndef QT_NO_STYLE_S60 +#include "qs60style.h" +#endif + QT_BEGIN_NAMESPACE @@ -490,6 +494,9 @@ void QTabBarPrivate::layoutTabs() if (useScrollButtons && tabList.count() && last > available) { int extra = extraWidth(); +#ifndef QT_NO_STYLE_S60 + QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()); +#endif if (!vertTabs) { Qt::LayoutDirection ld = q->layoutDirection(); QRect arrows = QStyle::visualRect(ld, q->rect(), @@ -497,25 +504,57 @@ void QTabBarPrivate::layoutTabs() int buttonOverlap = q->style()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, q); if (ld == Qt::LeftToRight) { +// In S60style, tab scroll buttons are layoutted separately, on the sides of the tabbar. +#ifndef QT_NO_STYLE_S60 + if (s60Style) { + rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height()); + leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height()); + } else { +#endif leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), extra/2, arrows.height()); +#ifndef QT_NO_STYLE_S60 + } +#endif leftB->setArrowType(Qt::LeftArrow); rightB->setArrowType(Qt::RightArrow); } else { +#ifndef QT_NO_STYLE_S60 + if (s60Style) { + rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height()); + leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height()); + } else { +#endif rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), extra/2, arrows.height()); +#ifndef QT_NO_STYLE_S60 + } +#endif rightB->setArrowType(Qt::LeftArrow); leftB->setArrowType(Qt::RightArrow); } } else { +#ifndef QT_NO_STYLE_S60 + if (s60Style) { + QRect arrows = QRect(0, 0, size.width(), available ); + leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra / 2); + leftB->setArrowType(Qt::UpArrow); + rightB->setGeometry(arrows.left(), arrows.bottom() - extra / 2 + 1, + arrows.width(), extra / 2); + rightB->setArrowType(Qt::DownArrow); + } else { +#endif QRect arrows = QRect(0, available - extra, size.width(), extra ); leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2); leftB->setArrowType(Qt::UpArrow); rightB->setGeometry(arrows.left(), arrows.bottom() - extra/2 + 1, arrows.width(), extra/2); rightB->setArrowType(Qt::DownArrow); +#ifndef QT_NO_STYLE_S60 + } +#endif } leftB->setEnabled(scrollOffset > 0); rightB->setEnabled(last - scrollOffset >= available - extra); diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 1754908..a9d600e 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -SUBDIRS += particles +SUBDIRS += particles gestures contains(QT_CONFIG, webkit): SUBDIRS += webkit contains(QT_CONFIG, mediaservices): SUBDIRS += multimedia diff --git a/src/imports/webkit/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp index 5db812c..9571470 100644 --- a/src/imports/webkit/qdeclarativewebview.cpp +++ b/src/imports/webkit/qdeclarativewebview.cpp @@ -437,24 +437,39 @@ void QDeclarativeWebView::paintPage(const QRect& r) /*! \qmlproperty list<object> WebView::javaScriptWindowObjects - This property is a list of object that are available from within - the webview's JavaScript context. + A list of QML objects to expose to the web page. - The \a object will be inserted as a child of the frame's window - object, under the name given by the attached property \c WebView.windowObjectName. + Each object will be added as a property of the web frame's window object. The + property name is controlled by the value of \c WebView.windowObjectName + attached property. + + Exposing QML objects to a web page allows JavaScript executing in the web + page itself to communicate with QML, by reading and writing properties and + by calling methods of the exposed QML objects. + + This example shows how to call into a QML method using a window object. \qml WebView { - javaScriptWindowObjects: Object { - WebView.windowObjectName: "coordinates" + javaScriptWindowObjects: QtObject { + WebView.windowObjectName: "qml" + + function qmlCall() { + console.log("This call is in QML!"); + } } + + html: "<script>console.log(\"This is in WebKit!\"); window.qml.qmlCall();</script>" } \endqml - Properties of the object will be exposed as JavaScript properties and slots as - JavaScript methods. + The output of the example will be: + \code + This is in WebKit! + This call is in QML! + \endcode - If Javascript is not enabled for this page, then this property does nothing. + If Javascript is not enabled for the page, then this property does nothing. */ QDeclarativeListProperty<QObject> QDeclarativeWebView::javaScriptWindowObjects() { diff --git a/src/multimedia/mediaservices/mediaservices.pro b/src/multimedia/mediaservices/mediaservices.pro index d5b0e4c..8a065f4 100644 --- a/src/multimedia/mediaservices/mediaservices.pro +++ b/src/multimedia/mediaservices/mediaservices.pro @@ -2,6 +2,8 @@ TARGET = QtMediaServices QPRO_PWD = $$PWD QT = core gui multimedia +contains(QT_CONFIG, opengl): QT += opengl + DEFINES += QT_BUILD_MEDIASERVICES_LIB QT_NO_USING_NAMESPACE unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtMultimedia diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp index 5d2be72..07baf1e 100644 --- a/src/network/socket/qlocalserver_win.cpp +++ b/src/network/socket/qlocalserver_win.cpp @@ -167,8 +167,8 @@ void QLocalServerPrivate::_q_onNewConnection() q->incomingConnection((quintptr)handle); } else { if (GetLastError() != ERROR_IO_INCOMPLETE) { + q->close(); setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection")); - closeServer(); return; } diff --git a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h b/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h index adc69ee..46029b9 100644 --- a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h +++ b/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h @@ -100,8 +100,10 @@ class QGL2PEXVertexArray { public: QGL2PEXVertexArray() : + vertexArray(0), vertexArrayStops(0), maxX(-2e10), maxY(-2e10), minX(2e10), minY(2e10), - boundingRectDirty(true) {} + boundingRectDirty(true) + { } inline void addRect(const QRectF &rect) { diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 6ba0c42..0a046dc 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -177,6 +177,7 @@ public: ctx(0), useSystemClip(true), elementIndicesVBOId(0), + opacityArray(0), snapToPixelGrid(false), addOffset(false), nativePaintingActive(false), diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index f677ce1..9bc099d 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -481,7 +481,8 @@ static void qdashprocessor_cubicTo(qreal, qreal, qreal, qreal, qreal, qreal, voi } QDashedStrokeProcessor::QDashedStrokeProcessor() - : m_dash_stroker(0), m_inv_scale(1) + : m_points(0), m_types(0), + m_dash_stroker(0), m_inv_scale(1) { m_dash_stroker.setMoveToHook(qdashprocessor_moveTo); m_dash_stroker.setLineToHook(qdashprocessor_lineTo); @@ -499,6 +500,8 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c m_points.reset(); m_types.reset(); + m_points.reserve(path.elementCount()); + m_types.reserve(path.elementCount()); qreal width = qpen_widthf(pen); if (width == 0) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index 956d7cc..ab27ed6 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE class QTriangulatingStroker { public: + QTriangulatingStroker() : m_vertices(0) {} void process(const QVectorPath &path, const QPen &pen, const QRectF &clip); inline int vertexCount() const { return m_vertices.size(); } diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp index ce917ff..df7cbc2 100644 --- a/src/opengl/gl2paintengineex/qtriangulator.cpp +++ b/src/opengl/gl2paintengineex/qtriangulator.cpp @@ -510,6 +510,7 @@ template <class T> class QMaxHeap { public: + QMaxHeap() : m_data(0) {} inline int size() const {return m_data.size();} inline bool empty() const {return m_data.isEmpty();} inline bool isEmpty() const {return m_data.isEmpty();} @@ -1299,7 +1300,8 @@ public: class ComplexToSimple { public: - inline ComplexToSimple(QTriangulator *parent) : m_parent(parent) { } + inline ComplexToSimple(QTriangulator *parent) : m_parent(parent), + m_edges(0), m_events(0), m_splits(0) { } void decompose(); private: struct Edge @@ -1412,7 +1414,7 @@ public: class SimpleToMonotone { public: - inline SimpleToMonotone(QTriangulator *parent) : m_parent(parent) { } + inline SimpleToMonotone(QTriangulator *parent) : m_parent(parent), m_edges(0), m_upperVertex(0) { } void decompose(); private: enum VertexType {MergeVertex, EndVertex, RegularVertex, StartVertex, SplitVertex}; @@ -1486,7 +1488,7 @@ public: int m_length; }; - inline QTriangulator() { } + inline QTriangulator() : m_vertices(0) { } // Call this only once. void initialize(const qreal *polygon, int count, uint hint, const QTransform &matrix); @@ -2709,7 +2711,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() return; Q_ASSERT(!m_edgeList.root); - QDataBuffer<QPair<int, int> > diagonals; + QDataBuffer<QPair<int, int> > diagonals(m_upperVertex.size()); int i = 0; for (int index = 1; index < m_edges.size(); ++index) { @@ -2853,7 +2855,7 @@ bool QTriangulator::SimpleToMonotone::CompareVertices::operator () (int i, int j void QTriangulator::MonotoneToTriangles::decompose() { QVector<quint32> result; - QDataBuffer<int> stack; + QDataBuffer<int> stack(m_parent->m_indices.size()); m_first = 0; // Require at least three more indices. while (m_first + 3 <= m_parent->m_indices.size()) { diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 306fd8b..d2b0d4f 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -668,6 +668,7 @@ public: , last_created_state(0) , shader_ctx(0) , grad_palette(0) + , tess_points(0) , drawable_texture(0) , ref_cleaner(this) {} @@ -1950,6 +1951,8 @@ void QOpenGLPaintEnginePrivate::pathToVertexArrays(const QPainterPath &path) void QOpenGLPaintEnginePrivate::drawVertexArrays() { + if (tess_points_stops.count() == 0) + return; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_DOUBLE, 0, tess_points.data()); int previous_stop = 0; diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp index 964fa53..9de2a34 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp @@ -259,7 +259,7 @@ int PvrEglScreen::transformation() const if (parent->classId() != QScreen::TransformedClass) return 0; return 90 * static_cast<const QTransformedScreen *>(parent) - ->transformation(); + ->transformOrientation(); } #else diff --git a/src/qt3support/widgets/q3spinwidget.cpp b/src/qt3support/widgets/q3spinwidget.cpp index 3dc36c5..3bfad06 100644 --- a/src/qt3support/widgets/q3spinwidget.cpp +++ b/src/qt3support/widgets/q3spinwidget.cpp @@ -340,11 +340,13 @@ void Q3SpinWidget::paintEvent(QPaintEvent *) QPainter p(this); QStyleOptionSpinBox opt = getStyleOption(this); - if (d->theButton & 1) + if (d->theButton & 1) { opt.activeSubControls = QStyle::SC_SpinBoxDown; - else if (d->theButton & 2) + opt.state |= QStyle::State_Sunken; + } else if (d->theButton & 2) { opt.activeSubControls = QStyle::SC_SpinBoxUp; - else + opt.state |= QStyle::State_Sunken; + } else opt.activeSubControls = QStyle::SC_None; opt.rect = style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxFrame, this); opt.subControls = QStyle::SC_All; diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 46431a8..1a0e737 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -182,6 +182,7 @@ namespace QTest { hbuffer->Des().Copy(ptr.Mid(i, size)); RDebug::Print(format, hbuffer); } + delete hbuffer; } else { // fast, no allocations, but truncates silently diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 9b3b3d0..a9b069c 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ examples \ - graphicswidgets \ # Cover parserstress \ # Cover qmetaobjectbuilder \ # Cover qdeclarativeanimations \ # Cover @@ -29,7 +28,6 @@ SUBDIRS += \ qdeclarativeitem \ # Cover qdeclarativelistview \ # Cover qdeclarativeloader \ # Cover - qdeclarativelayouts \ # Cover qdeclarativemousearea \ # Cover qdeclarativeparticles \ # Cover qdeclarativepathview \ # Cover @@ -65,6 +63,7 @@ SUBDIRS += \ qdeclarativestyledtext \ # Cover qdeclarativesqldatabase \ # Cover qdeclarativevisualdatamodel \ # Cover + qdeclarativeviewer \ # Cover qmlvisual # Cover contains(QT_CONFIG, webkit) { diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 058fda1..3759cb5 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -80,15 +80,6 @@ tst_examples::tst_examples() // Add directories you want excluded here - excludedDirs << "examples/declarative/extending"; - excludedDirs << "examples/declarative/tutorials/extending"; - excludedDirs << "examples/declarative/plugins"; - excludedDirs << "examples/declarative/proxywidgets"; - excludedDirs << "examples/declarative/gestures"; - - excludedDirs << "examples/declarative/imageprovider"; - excludedDirs << "demos/declarative/minehunt"; - excludedDirs << "doc/src/snippets/declarative/graphicswidgets"; #ifdef QT_NO_WEBKIT @@ -159,11 +150,14 @@ QStringList tst_examples::findQmlFiles(const QDir &d) QStringList rv; - QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), - QDir::Files); - foreach (const QString &file, files) { - if (file.at(0).isLower()) { - rv << d.absoluteFilePath(file); + QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files); + if (cppfiles.isEmpty()) { + QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), + QDir::Files); + foreach (const QString &file, files) { + if (file.at(0).isLower()) { + rv << d.absoluteFilePath(file); + } } } diff --git a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml b/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml deleted file mode 100644 index d6cf4de..0000000 --- a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml +++ /dev/null @@ -1,52 +0,0 @@ -import Qt 4.7 -import Qt.widgets 4.7 - -QGraphicsWidget { - geometry: "20,0,600x400" - layout: QGraphicsLinearLayout { - orientation: Qt.Horizontal - QGraphicsWidget { - layout: QGraphicsLinearLayout { - spacing: 10; orientation: Qt.Vertical - LayoutItem { - QGraphicsLinearLayout.stretchFactor: 1 - QGraphicsLinearLayout.spacing: 1 - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent } - } - LayoutItem { - QGraphicsLinearLayout.stretchFactor: 10 - QGraphicsLinearLayout.spacing: 10 - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "blue"; anchors.fill: parent } - } - } - } - QGraphicsWidget { - layout: QGraphicsLinearLayout { - spacing: 10; orientation: Qt.Horizontal; contentsMargin: 10 - LayoutItem { - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "red"; anchors.fill: parent } - } - LayoutItem { - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "green"; anchors.fill: parent } - } - } - } - } -} - diff --git a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp b/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp deleted file mode 100644 index f1a71d5..0000000 --- a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <qtest.h> -#include <QFile> -#include <QtDeclarative/qdeclarativeengine.h> -#include <QtDeclarative/qdeclarativecomponent.h> -#include <QtGui/qgraphicswidget.h> - -class tst_graphicswidgets : public QObject - -{ - Q_OBJECT -public: - tst_graphicswidgets(); - -private slots: - void widgets(); -}; - -tst_graphicswidgets::tst_graphicswidgets() -{ -} - -void tst_graphicswidgets::widgets() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/graphicswidgets.qml")); - QGraphicsWidget *obj = qobject_cast<QGraphicsWidget*>(c.create()); - - QVERIFY(obj != 0); - delete obj; -} - -QTEST_MAIN(tst_graphicswidgets) - -#include "tst_graphicswidgets.moc" diff --git a/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml b/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml index 91973a3..d430c2c 100644 --- a/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml +++ b/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml @@ -1,5 +1,4 @@ import Qt 4.7 -import Qt.widgets 4.7 Rectangle { color: "white" diff --git a/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml index 9bb0b37..3b851c1 100644 --- a/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml +++ b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml @@ -1,5 +1,4 @@ import Qt 4.7 -import Qt.widgets 4.6 QGraphicsWidget { size: "250x250" diff --git a/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml b/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml new file mode 100644 index 0000000..fecfadf --- /dev/null +++ b/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml @@ -0,0 +1,28 @@ +import Qt 4.7 + +Rectangle { + id: root + color: "#ffffff" + width: 320; height: 240 + property bool mr1_pressed: false + property bool mr1_released: false + property bool mr1_canceled: false + property bool mr2_pressed: false + property bool mr2_released: false + property bool mr2_canceled: false + + MouseArea { + id: mouseRegion1 + anchors.fill: parent + onPressed: {console.log("press111"); root.mr1_pressed = true} + onReleased: {console.log("release111"); root.mr1_released = true} + onCanceled: {console.log("ungrab1111"); root.mr1_canceled = true} + } + MouseArea { + id: mouseRegion2 + width: 120; height: 120 + onPressed: {console.log("press222"); root.mr2_pressed = true; mouse.accepted = false} + onReleased: {console.log("release2222"); root.mr2_released = true} + onCanceled: {console.log("ungrab2222"); root.mr2_canceled = true} + } +} diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index eb4aa12..ff3bf45 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -56,6 +56,8 @@ private slots: void updateMouseAreaPosOnClick(); void updateMouseAreaPosOnResize(); void noOnClickedWithPressAndHold(); + void onMousePressRejected(); + private: QDeclarativeView *createView(); }; @@ -320,7 +322,7 @@ void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold() QTest::qWait(1000); - QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMousePress); + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); releaseEvent.setScenePos(QPointF(100, 100)); releaseEvent.setButton(Qt::LeftButton); releaseEvent.setButtons(Qt::LeftButton); @@ -330,6 +332,48 @@ void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold() QVERIFY(canvas->rootObject()->property("held").toBool()); } +void tst_QDeclarativeMouseArea::onMousePressRejected() +{ + QDeclarativeView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/rejectEvent.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool()); + + QGraphicsScene *scene = canvas->scene(); + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setScenePos(QPointF(100, 100)); + pressEvent.setButton(Qt::LeftButton); + pressEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &pressEvent); + + QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); + QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); + QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool()); + + QTest::qWait(200); + + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); + releaseEvent.setScenePos(QPointF(100, 100)); + releaseEvent.setButton(Qt::LeftButton); + releaseEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &releaseEvent); + + QVERIFY(canvas->rootObject()->property("mr1_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); +} + QTEST_MAIN(tst_QDeclarativeMouseArea) #include "tst_qdeclarativemousearea.moc" diff --git a/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml b/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml new file mode 100644 index 0000000..b39ba5b --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml @@ -0,0 +1,12 @@ +import Qt 4.7 + +Item { + width: 400; height: 500; + property int bindingWidth: text.width + property int bindingHeight: text.height + + TextInput { + id: text + anchors.fill: parent + } +} diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 3307b7c..8cc0e3f 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -84,7 +84,7 @@ private slots: void navigation(); void readOnly(); void sendRequestSoftwareInputPanelEvent(); - + void geometrySignals(); private: void simulateKey(QDeclarativeView *, int key); QDeclarativeView *createView(const QString &filename); @@ -808,6 +808,17 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() QApplication::processEvents(); QCOMPARE(ic.softwareInputPanelEventReceived, true); } + +void tst_qdeclarativetextedit::geometrySignals() +{ + QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml"); + QObject *o = component.create(); + QVERIFY(o); + QCOMPARE(o->property("bindingWidth").toInt(), 400); + QCOMPARE(o->property("bindingHeight").toInt(), 500); + delete o; +} + QTEST_MAIN(tst_qdeclarativetextedit) #include "tst_qdeclarativetextedit.moc" diff --git a/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml b/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml new file mode 100644 index 0000000..a9b50fe --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml @@ -0,0 +1,12 @@ +import Qt 4.7 + +Item { + width: 400; height: 500; + property int bindingWidth: text.width + property int bindingHeight: text.height + + TextEdit { + id: text + anchors.fill: parent + } +} diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 83ebe6c..0065ccf 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -76,6 +76,7 @@ private slots: void focusOutClearSelection(); void echoMode(); + void geometrySignals(); private: void simulateKey(QDeclarativeView *, int key); QDeclarativeView *createView(const QString &filename); @@ -805,6 +806,16 @@ void tst_qdeclarativetextinput::focusOutClearSelection() QTRY_COMPARE(input.selectedText(), QLatin1String("")); } +void tst_qdeclarativetextinput::geometrySignals() +{ + QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml"); + QObject *o = component.create(); + QVERIFY(o); + QCOMPARE(o->property("bindingWidth").toInt(), 400); + QCOMPARE(o->property("bindingHeight").toInt(), 500); + delete o; +} + QTEST_MAIN(tst_qdeclarativetextinput) #include "tst_qdeclarativetextinput.moc" diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp index 1ed51c1..dd2f46e 100644 --- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp @@ -147,7 +147,7 @@ void tst_QDeclarativeView::resizemodedeclarativeitem() declarativeItem->setHeight(80); QCOMPARE(canvas->width(), 80); QCOMPARE(canvas->height(), 100); - QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(QSize(declarativeItem->width(), declarativeItem->height()), canvas->sizeHint()); QCOMPARE(sceneResizedSpy2.count(), 2); // size update from view @@ -230,7 +230,7 @@ void tst_QDeclarativeView::resizemodegraphicswidget() canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); graphicsWidget->resize(QSizeF(60,80)); QCOMPARE(canvas->size(), QSize(80,100)); - QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(QSize(graphicsWidget->size().width(), graphicsWidget->size().height()), canvas->sizeHint()); QCOMPARE(sceneResizedSpy2.count(), 2); // size update from view diff --git a/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml new file mode 100644 index 0000000..687fac6 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml @@ -0,0 +1,10 @@ +import Qt 4.7 +Rectangle { + color: "black" + width: (runtime.orientation == Orientation.Landscape) ? 300 : 200 + height: (runtime.orientation == Orientation.Landscape) ? 200 : 300 + Text { + text: runtime.orientation == Orientation.Landscape ? "Landscape" : "Portrait" + color: "white" + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro index b77b430..dc10f5b 100644 --- a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro +++ b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro @@ -2,9 +2,10 @@ load(qttest_p4) contains(QT_CONFIG,declarative): QT += declarative gui macx:CONFIG -= app_bundle -SOURCES += tst_graphicswidgets.cpp +include(../../../../tools/qml/qml.pri) + +SOURCES += tst_qdeclarativeviewer.cpp -# Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp new file mode 100644 index 0000000..9429dc9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativeview.h> +#include <QtDeclarative/qdeclarativeitem.h> +#include "qmlruntime.h" + +class tst_QDeclarativeViewer : public QObject + +{ + Q_OBJECT +public: + tst_QDeclarativeViewer(); + +private slots: + void orientation(); + +private: + QDeclarativeEngine engine; +}; + +tst_QDeclarativeViewer::tst_QDeclarativeViewer() +{ +} + +void tst_QDeclarativeViewer::orientation() +{ + QWidget window; + QDeclarativeViewer *viewer = new QDeclarativeViewer(&window); + QVERIFY(viewer); + viewer->open(SRCDIR "/data/orientation.qml"); + QVERIFY(viewer->view()); + QVERIFY(viewer->menuBar()); + QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject()); + QVERIFY(rootItem); + window.show(); + + QCOMPARE(rootItem->width(), 200.0); + QCOMPARE(rootItem->height(), 300.0); + QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); + QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + viewer->toggleOrientation(); + qApp->processEvents(); + + QCOMPARE(rootItem->width(), 300.0); + QCOMPARE(rootItem->height(), 200.0); + QCOMPARE(viewer->view()->size(), QSize(300, 200)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200)); + QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + viewer->toggleOrientation(); + qApp->processEvents(); + + QCOMPARE(rootItem->width(), 200.0); + QCOMPARE(rootItem->height(), 300.0); + QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); + QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); +} + +QTEST_MAIN(tst_QDeclarativeViewer) + +#include "tst_qdeclarativeviewer.moc" diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml new file mode 100644 index 0000000..f5198c9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + color: model.modelData.color + Text { objectName: "name"; text: name } + } + } +} diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml index a0b787f..e223f5e 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml @@ -25,7 +25,7 @@ Rectangle { MouseArea { anchors.fill: parent onPressed: blue.color = "lightsteelblue" - onReleased: blue.color = "steelblue" + onCanceled: blue.color = "steelblue" } } Rectangle { @@ -36,7 +36,7 @@ Rectangle { MouseArea { anchors.fill: parent onEntered: { red.color = "darkred"; tooltip.opacity = 1 } - onExited: { red.color = "red"; tooltip.opacity = 0 } + onCanceled: { red.color = "red"; tooltip.opacity = 0 } } Rectangle { id: tooltip diff --git a/tools/qml/loggerwidget.h b/tools/qml/loggerwidget.h index b68ecc5..fd20c41 100644 --- a/tools/qml/loggerwidget.h +++ b/tools/qml/loggerwidget.h @@ -86,8 +86,8 @@ private: Visibility m_visibility; }; -Q_DECLARE_METATYPE(LoggerWidget::Visibility); - QT_END_NAMESPACE +Q_DECLARE_METATYPE(LoggerWidget::Visibility) + #endif // LOGGERWIDGET_H diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 78f0c87..fb687ac 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -54,7 +54,7 @@ QT_USE_NAMESPACE -QtMsgHandler systemMsgOutput; +QtMsgHandler systemMsgOutput = 0; #if defined (Q_OS_SYMBIAN) #include <unistd.h> diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index fe0f67c..06fa004 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -535,6 +535,8 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) connect(&autoStartTimer, SIGNAL(triggered()), this, SLOT(autoStartRecording())); connect(&autoStopTimer, SIGNAL(triggered()), this, SLOT(autoStopRecording())); connect(&recordTimer, SIGNAL(triggered()), this, SLOT(recordFrame())); + connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()), + this, SLOT(orientationChanged()), Qt::QueuedConnection); autoStartTimer.setRunning(false); autoStopTimer.setRunning(false); recordTimer.setRunning(false); @@ -543,6 +545,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) QDeclarativeViewer::~QDeclarativeViewer() { + delete loggerWindow; canvas->engine()->setNetworkAccessManagerFactory(0); delete namFactory; } @@ -967,10 +970,8 @@ void QDeclarativeViewer::statusChanged() if (canvas->status() == QDeclarativeView::Ready) { initialSize = canvas->sizeHint(); if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { - QSize newWindowSize = initialSize; - newWindowSize.setHeight(newWindowSize.height()+menuBarHeight()); updateSizeHints(); - resize(newWindowSize); + resize(QSize(initialSize.width(), initialSize.height()+menuBarHeight())); } } } @@ -1424,6 +1425,19 @@ void QDeclarativeViewer::recordFrame() } } +void QDeclarativeViewer::orientationChanged() +{ + if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { + if (canvas->rootObject()) { + QSizeF rootObjectSize = canvas->rootObject()->boundingRect().size(); + QSize newSize(rootObjectSize.width(), rootObjectSize.height()+menuBarHeight()); + if (size() != newSize) { + resize(newSize); + } + } + } +} + void QDeclarativeViewer::setDeviceKeys(bool on) { devicemode = on; diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 655feea..9551090 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -125,6 +125,7 @@ public slots: void showProxySettings (); void proxySettingsChanged (); void setScaleView(); + void toggleOrientation(); void statusChanged(); void setSlowMode(bool); void launch(const QString &); @@ -132,7 +133,6 @@ public slots: protected: virtual void keyPressEvent(QKeyEvent *); virtual bool event(QEvent *); - void createMenu(QMenuBar *menu, QMenu *flatmenu); private slots: @@ -144,9 +144,9 @@ private slots: void setScaleSkin(); void setPortrait(); void setLandscape(); - void toggleOrientation(); void startNetwork(); void toggleFullScreen(); + void orientationChanged(); void showWarnings(bool show); void warningsWidgetOpened(); @@ -199,7 +199,6 @@ private: QNetworkReply *wgtreply; QString wgtdir; - NetworkAccessManagerFactory *namFactory; bool useQmlFileBrowser; diff --git a/translations/qt_iw.ts b/translations/qt_he.ts index 72a6df9..72a6df9 100644 --- a/translations/qt_iw.ts +++ b/translations/qt_he.ts diff --git a/translations/translations.pri b/translations/translations.pri index 34da6b1..3c4bdd1 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -17,7 +17,7 @@ LUPDATE += -locations relative -no-ui-lines ###### Qt Libraries -QT_TS = ar cs da de es fr hu iw ja_JP pl pt ru sk sl sv uk zh_CN zh_TW +QT_TS = ar cs da de es fr he hu ja_JP pl pt ru sk sl sv uk zh_CN zh_TW ts-qt.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ -I../include -I../include/Qt \ |