diff options
305 files changed, 5976 insertions, 5704 deletions
diff --git a/configure.exe b/configure.exe Binary files differindex 8913de1..980c190 100644 --- a/configure.exe +++ b/configure.exe diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index d9b73ed..54af7ad 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -118,7 +118,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { matchProperties: "x,y,width"; easing: "easeOutBounce"; duration: 500 } - NumberAnimation { matchProperties: "opacity"; easing: "easeInOutQuad"; duration: 500 } + NumberAnimation { properties: "x,y,width"; easing: "easeOutBounce"; duration: 500 } + NumberAnimation { properties: "opacity"; easing: "easeInOutQuad"; duration: 500 } } } diff --git a/demos/declarative/flickr/common/ImageDetails.qml b/demos/declarative/flickr/common/ImageDetails.qml index 95c32e8..19cad06 100644 --- a/demos/declarative/flickr/common/ImageDetails.qml +++ b/demos/declarative/flickr/common/ImageDetails.qml @@ -149,7 +149,7 @@ Flipable { property: "smooth" value: false } - NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 500 } + NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 } PropertyAction { target: bigImage property: "smooth" diff --git a/demos/declarative/flickr/common/Loading.qml b/demos/declarative/flickr/common/Loading.qml index 64a04c4..174cd21 100644 --- a/demos/declarative/flickr/common/Loading.qml +++ b/demos/declarative/flickr/common/Loading.qml @@ -3,6 +3,6 @@ import Qt 4.6 Image { id: loading; source: "pics/loading.png"; transformOrigin: "Center" rotation: NumberAnimation { - id: "RotationAnimation"; from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 + from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 } } diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml index abc8034..b24b296 100644 --- a/demos/declarative/flickr/common/MediaLineEdit.qml +++ b/demos/declarative/flickr/common/MediaLineEdit.qml @@ -42,7 +42,7 @@ Item { ] transitions: [ Transition { - NumberAnimation { matchProperties: "x,width"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,width"; duration: 500; easing: "easeInOutQuad" } } ] diff --git a/demos/declarative/flickr/common/ScrollBar.qml b/demos/declarative/flickr/common/ScrollBar.qml index 2c1ec8a..feebcb0 100644 --- a/demos/declarative/flickr/common/ScrollBar.qml +++ b/demos/declarative/flickr/common/ScrollBar.qml @@ -32,7 +32,7 @@ Item { to: "*" NumberAnimation { target: container - matchProperties: "opacity" + properties: "opacity" duration: 400 } } diff --git a/demos/declarative/flickr/common/Star.qml b/demos/declarative/flickr/common/Star.qml index c5abcca..173021b 100644 --- a/demos/declarative/flickr/common/Star.qml +++ b/demos/declarative/flickr/common/Star.qml @@ -37,7 +37,7 @@ Item { transitions: [ Transition { NumberAnimation { - matchProperties: "opacity,scale,x,y" + properties: "opacity,scale,x,y" easing: "easeOutBounce" } } diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml index 4e3b6cb..3848f12 100644 --- a/demos/declarative/flickr/flickr-desktop.qml +++ b/demos/declarative/flickr/flickr-desktop.qml @@ -86,15 +86,15 @@ Item { from: "*"; to: "Details" SequentialAnimation { ParentAction { } - NumberAnimation { matchProperties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } } }, Transition { from: "Details"; to: "*" SequentialAnimation { ParentAction { } - NumberAnimation { matchProperties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } - PropertyAction { matchTargets: wrapper; matchProperties: "z" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + PropertyAction { targets: wrapper; properties: "z" } } } ] @@ -180,7 +180,7 @@ Item { transitions: [ Transition { from: "*"; to: "*" - NumberAnimation { matchProperties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" } + NumberAnimation { properties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" } } ] } diff --git a/demos/declarative/flickr/flickr-mobile.qml b/demos/declarative/flickr/flickr-mobile.qml index 583f992..0a89c4f 100644 --- a/demos/declarative/flickr/flickr-mobile.qml +++ b/demos/declarative/flickr/flickr-mobile.qml @@ -38,7 +38,7 @@ Item { } transitions: Transition { - NumberAnimation { matchProperties: "x"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" } } } @@ -76,7 +76,7 @@ Item { } transitions: Transition { - NumberAnimation { matchProperties: "x"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" } } } } diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml index 3a42507..6c12896 100644 --- a/demos/declarative/flickr/mobile/GridDelegate.qml +++ b/demos/declarative/flickr/mobile/GridDelegate.qml @@ -55,14 +55,14 @@ Transition { from: "Show"; to: "Details" ParentAction { } - NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } }, Transition { from: "Details"; to: "Show" SequentialAnimation { ParentAction { } - NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } - PropertyAction { matchTargets: wrapper; matchProperties: "z" } + NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } + PropertyAction { targets: wrapper; properties: "z" } } } ] diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml index 9116428..1963bf5 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -117,7 +117,7 @@ Flipable { transitions: Transition { SequentialAnimation { PropertyAction { target: bigImage; property: "smooth"; value: false } - NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 500 } + NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 } PropertyAction { target: bigImage; property: "smooth"; value: !flickable.moving } } } diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml index 0341585..07b9762 100644 --- a/demos/declarative/flickr/mobile/TitleBar.qml +++ b/demos/declarative/flickr/mobile/TitleBar.qml @@ -71,6 +71,6 @@ Item { } transitions: Transition { - NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; easing: "easeInOutQuad" } } } diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp index 8ca37ff..0b862e3 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/main.cpp @@ -167,10 +167,7 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags canvas->setFixedSize(width, height); vbox->addWidget(canvas); - QFile file(fileName); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, fileName); + canvas->setSource(QUrl::fromLocalFile(fileName)); QmlContext *ctxt = canvas->rootContext(); ctxt->addDefaultObject(this); diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml index ff00d83..18e8195 100644 --- a/demos/declarative/minehunt/minehunt.qml +++ b/demos/declarative/minehunt/minehunt.qml @@ -31,7 +31,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter source: "pics/flag.png" - opacity: modelData.hasFlag + opacity: model.hasFlag opacity: Behavior { NumberAnimation { property: "opacity" @@ -47,16 +47,16 @@ Item { Text { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - text: modelData.hint + text: model.hint color: "white" font.bold: true - opacity: !modelData.hasMine && modelData.hint > 0 + opacity: !model.hasMine && model.hint > 0 } Image { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter source: "pics/bomb.png" - opacity: modelData.hasMine + opacity: model.hasMine } Explosion { id: expl @@ -65,7 +65,7 @@ Item { states: [ State { name: "back" - when: modelData.flipped + when: model.flipped PropertyChanges { target: flipable; angle: 180 } } ] @@ -81,7 +81,7 @@ Item { else ret = 0; if (ret > 0) { - if (modelData.hasMine && modelData.flipped) { + if (model.hasMine && model.flipped) { ret*3; } else { ret; @@ -93,10 +93,10 @@ Item { } NumberAnimation { easing: "easeInOutQuad" - matchProperties: "angle" + properties: "angle" } ScriptAction{ - script: if(modelData.hasMine && modelData.flipped){expl.explode = true;} + script: if(model.hasMine && model.flipped){expl.explode = true;} } } } diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml index f9a281a..5bd1123 100644 --- a/demos/declarative/samegame/content/Dialog.qml +++ b/demos/declarative/samegame/content/Dialog.qml @@ -11,6 +11,7 @@ Rectangle { page.opacity = 1; } signal closed(); + property Item text: myText color: "white"; border.width: 1; width: myText.width + 20; height: myText.height + 40; opacity: 0 opacity: Behavior { diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 0a42e88..c0f10bd 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -158,7 +158,11 @@ function victoryCheck() //Checks for game over if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){ timer = new Date() - timer; + //scoreName.show("You won! Please enter your name: "); scoreName.show("You won! Please enter your name: "); + scoreName.initialWidth = scoreName.text.width + 20; + scoreName.width = scoreName.initialWidth; + scoreName.text.opacity = 0;//Just a spacer //dialog.show("Game Over. Your score is " + gameCanvas.score); } } @@ -218,8 +222,9 @@ function saveHighScore(name) { tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); tx.executeSql(dataStr, data); - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10'); - var r = "\nHIGH SCORES for a standard sized grid\n\n" + //Only show results for the current grid size + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'+maxX+"x"+maxY+'" ORDER BY score desc LIMIT 10'); + var r = "\nHIGH SCORES for this grid size\n\n" for(var i = 0; i < rs.rows.length; i++){ r += (i+1)+". " + rs.rows.item(i).name +' got ' + rs.rows.item(i).score + ' points in ' diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 626c76b..f5c4fc5 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -38,20 +38,30 @@ Rectangle { Dialog { id: dialog; anchors.centerIn: parent; z: 21 } Dialog { id: scoreName; anchors.centerIn: parent; z: 22; + property int initialWidth: 0 + width: Behavior{NumberAnimation{} enabled: initialWidth!=0} Text { id: spacer - opacity: 0 - text: " You won! Please enter your name:" + anchors.left: scoreName.left + anchors.leftMargin: 20 + anchors.verticalCenter: parent.verticalCenter + text: "You won! Please enter your name: " } TextInput { id: editor + onTextChanged: { + var newWidth = editor.width + spacer.width + 40; + if((newWidth > scoreName.width && newWidth < screen.width) + || (scoreName.width > scoreName.initialWidth)) + scoreName.width = newWidth; + } onAccepted: { if(scoreName.opacity==1&&editor.text!="") saveHighScore(editor.text); scoreName.forceClose(); } anchors.verticalCenter: parent.verticalCenter - width: 72; focus: true + focus: true anchors.left: spacer.right } } @@ -79,7 +89,7 @@ Rectangle { text: "Score: " + gameCanvas.score; font.bold: true anchors.right: parent.right; anchors.rightMargin: 3 anchors.verticalCenter: parent.verticalCenter - color: activePalette.text + color: activePalette.windowText } } } diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml index c48befd..8054f2e 100644 --- a/demos/declarative/twitter/content/HomeTitleBar.qml +++ b/demos/declarative/twitter/content/HomeTitleBar.qml @@ -115,7 +115,7 @@ Item { transitions: [ Transition { from: "*"; to: "*" - NumberAnimation { matchProperties: "x,y,width,height"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,width,height"; easing: "easeInOutQuad" } } ] } diff --git a/demos/declarative/twitter/content/Loading.qml b/demos/declarative/twitter/content/Loading.qml index 8b22e70..3151415 100644 --- a/demos/declarative/twitter/content/Loading.qml +++ b/demos/declarative/twitter/content/Loading.qml @@ -3,6 +3,6 @@ import Qt 4.6 Image { id: loading; source: "images/loading.png"; transformOrigin: "Center" rotation: NumberAnimation { - id: "RotationAnimation"; from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 + from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 } } diff --git a/demos/declarative/twitter/content/MultiTitleBar.qml b/demos/declarative/twitter/content/MultiTitleBar.qml index ef8a450..ef7de65 100644 --- a/demos/declarative/twitter/content/MultiTitleBar.qml +++ b/demos/declarative/twitter/content/MultiTitleBar.qml @@ -18,7 +18,7 @@ Item { } ] transitions: [ - Transition { NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } } + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } } ] } diff --git a/demos/declarative/twitter/content/TitleBar.qml b/demos/declarative/twitter/content/TitleBar.qml index 28e7389..42a6115 100644 --- a/demos/declarative/twitter/content/TitleBar.qml +++ b/demos/declarative/twitter/content/TitleBar.qml @@ -72,6 +72,6 @@ Item { } transitions: Transition { - NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; easing: "easeInOutQuad" } } } diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml index bb7da9c..d2abf28 100644 --- a/demos/declarative/twitter/twitter.qml +++ b/demos/declarative/twitter/twitter.qml @@ -89,7 +89,7 @@ Item { } ] transitions: [ - Transition { NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } } + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } } ] } } diff --git a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml index a7e6a97..e58ab0a 100644 --- a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml +++ b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml @@ -96,8 +96,8 @@ Image { transitions: [ Transition { NumberAnimation { - matchTargets: header - matchProperties: "progressOff" + targets: header + properties: "progressOff" easing: "easeInOutQuad" duration: 300 } diff --git a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml index 6b1d271..b1c1938 100644 --- a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml +++ b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml @@ -149,7 +149,7 @@ Item { to: "*" reversible: true NumberAnimation { - matchProperties: "opacity,leftMargin,rightMargin" + properties: "opacity,leftMargin,rightMargin" duration: 200 } ColorAnimation { diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 3b3790c..8de13d5 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -97,7 +97,7 @@ Item { transitions: [ Transition { NumberAnimation { - matchProperties: "opacity" + properties: "opacity" easing: "easeInOutQuad" duration: 300 } @@ -153,7 +153,7 @@ Item { transitions: [ Transition { NumberAnimation { - matchProperties: "opacity" + properties: "opacity" easing: "easeInOutQuad" duration: 320 } diff --git a/doc/src/declarative/advtutorial1.qdoc b/doc/src/declarative/advtutorial1.qdoc index 598537a..90bac1b 100644 --- a/doc/src/declarative/advtutorial1.qdoc +++ b/doc/src/declarative/advtutorial1.qdoc @@ -55,8 +55,9 @@ This gives you a basic game window, with room for the game canvas. A new game button and room to display the score. The one thing you may not recognize here is the \l SystemPalette item. This item provides access to the Qt system palette and is used to make the button look more like a system button (for exact native -feel you would use a \l QPushButton). Since we want a fully QML button, and QML does -not include a button, we had to write our own. Below is the code which we wrote to do this: +feel you would use a \l QPushButton). Since we want a fully functional button, +we use the QML elements Text and MouseRegion inside a Rectangle to assemble a +button. Below is the code which we wrote to do this: \snippet declarative/tutorials/samegame/samegame1/Button.qml 0 diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index acf72e3..cfc100d 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -44,9 +44,9 @@ \title QML Animation Animation in QML is done by animating properties of objects. Properties of type -real, int, color, rect, point, and size can all be animated. +real, int, color, rect, point, size, and vector3d can all be animated. -QML supports three different forms of animation - basic property animation, +QML supports three main forms of animation - basic property animation, transitions, and property behaviors. \tableofcontents @@ -71,7 +71,6 @@ Rectangle { x: 60-img.width/2 y: 0 y: SequentialAnimation { - running: true repeat: true NumberAnimation { to: 200-img.height; easing: "easeOutBounce"; duration: 2000 } PauseAnimation { duration: 1000 } @@ -84,8 +83,8 @@ Rectangle { \image propanim.gif When you assign an animation as a value source, you do not need to specify \c property -or \c target; they are automatically selected for you. You do, however, need to specify \c to, and explicitly -start the animation (usually via the \c running property). +or \c target; they are automatically selected for you. You do, however, need to specify \c to. +An animation specified as a value source will be \c running by default. \qml Rectangle { @@ -94,7 +93,7 @@ Rectangle { Rectangle { color: "red" width: 50; height: 50 - x: NumberAnimation { to: 50; running: true } + x: NumberAnimation { to: 50; } } } \endqml @@ -135,7 +134,7 @@ For example, a transition could describe how an item moves from its initial posi transitions: [ Transition { NumberAnimation { - matchProperties: "x,y" + properties: "x,y" easing: "easeOutBounce" duration: 200 } @@ -143,13 +142,38 @@ transitions: [ ] \endcode -As you can see from the above example, transitions make use of the same basic animation classes introduced -above. However, you generally use a different set of properties when working with transitions. In the example, -no \c target or \c property has been specified. Instead, we have specified \c matchProperties, -which (along with \c matchTargets) acts as a selector to determine which property changes to animate; -in this case, we will animate any x,y properties that have changed on any objects. +As can be seen, transitions make use of the same basic animation classes introduced above. +In the above example we have specified that we want to animate the \c x and \c y properties, but have not +specified the objects to animate or the \c to values. By default these values are supplied by the framework -- +the animation will animate any \c targets whose \c x and \c y have changed, and the \c to values will be those +defined in the end state. You can always supply explicit values to override these implicit values when needed. -QML transitions also have selectors to determine which state changes a transition should apply to: +\code +Transition { + from: "*" + to: "MyState" + reversible: true + SequentialAnimation { + NumberAnimation { + duration: 1000 + easing: "easeOutBounce" + // animate myItem's x and y if they have changed in the state + target: myItem + properties: "x,y" + } + NumberAnimation { + duration: 1000 + // animate myItem2's y to 200, regardless of what happens in the state + target: myItem2 + property: "y" + to: 200 + } + } +} +\endcode + +QML transitions have selectors to determine which state changes a transition should apply to. +The following transition will only be triggered when we enter into the \c "details" state. \code Transition { @@ -175,50 +199,24 @@ Transition { NumberAnimation { duration: 1000 easing: "easeOutBounce" - matchTargets: box1 - matchProperties: "x,y" + targets: box1 + properties: "x,y" } NumberAnimation { duration: 1000 - matchTargets: box2 - matchProperties: "x,y" + targets: box2 + properties: "x,y" } } } } \endcode -To insert an explicit animation into your transition, you can use \c target and \c property as normal. - -\code -Transition { - from: "*" - to: "MyState" - reversible: true - SequentialAnimation { - NumberAnimation { - duration: 1000 - easing: "easeOutBounce" - // animate myItem's x and y if they have changed in the state - matchTargets: myItem - matchProperties: "x,y" - } - NumberAnimation { - duration: 1000 - // animate myItem2's y to 200, regardless of what happens in the state - target: myItem2 - property: "y" - to: 200 - } - } -} -\endcode - \section1 Property Behaviors A \l{Behavior}{property behavior} specifies a default animation to run whenever the property's value changes, regardless -of what caused the change. Unlike Transition, \l Behavior doesn't provide a way to indicate that a Behavior -should only apply under certain circumstances. +of what caused the change. The \c enabled property can be used to force a \l Behavior +to only apply under certain circumstances. In the following snippet, we specify that we want the x position of redRect to be animated whenever it changes. The animation will last 300 milliseconds and use an InOutQuad easing curve. diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 9bc44db..e3323c2 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -143,6 +143,7 @@ The following table lists the QML elements provided by the Qt Declarative module \o \l Repeater \o \l SystemPalette \o \l GraphicsObjectContainer +\o \l LayoutItem \endlist \header diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index 63df61c..bb9e1a4 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -326,7 +326,7 @@ which in turn gives \e {active focus} to the \c {Text} element that actually performs the work of handling the \e {Return} key. All of the QML view classes, such as \l PathView and \l GridView, behave -in a similar mannor to allow key handling in their respective delegates. +in a similar manner to allow key handling in their respective delegates. \section1 Focus Panels diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc index b7f8b17..43ec33a 100644 --- a/doc/src/declarative/integrating.qdoc +++ b/doc/src/declarative/integrating.qdoc @@ -86,6 +86,15 @@ QGraphicsObject *object = scene->addItem(object); \endcode +The following QGraphicsView options are recommended for optimal performance +of QML UIs: + +\list +\o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState); +\o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); +\o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex); +\endlist + \section1 Using existing QGraphicsWidgets in QML Another way of integrating with a QGraphicsView based UI is to expose your existing QGraphicsWidgets to QML, and constructing your scene in QML. Note that diff --git a/doc/src/declarative/qmlstates.qdoc b/doc/src/declarative/qmlstates.qdoc index b178e718..867c714 100644 --- a/doc/src/declarative/qmlstates.qdoc +++ b/doc/src/declarative/qmlstates.qdoc @@ -108,7 +108,7 @@ For example, adding this code to the above \c {Item {}} element animates the tra \qml transitions: [ Transition { - NumberAnimation { matchProperties: "x,y"; duration: 500 } + NumberAnimation { properties: "x,y"; duration: 500 } } ] \endqml diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index 4909355..8b9909e 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -153,7 +153,7 @@ class CustomPalette : public QObject { Q_OBJECT Q_PROPERTY(QColor background READ background WRITE setBackground NOTIFY backgroundChanged) -Q_PROPERTY(QColor text READ text WRITE setText NOTIFY text) +Q_PROPERTY(QColor text READ text WRITE setText NOTIFY textChanged) public: CustomPalette() : m_background(Qt::white), m_text(Qt::black) {} @@ -172,6 +172,10 @@ public: emit textChanged(); } } +signals: + void textChanged(); + void backgroundChanged(): + private: QColor m_background; QColor m_text; @@ -358,5 +362,41 @@ void MyApplication::continueLoading() } } \endcode + +\section1 Qt Resources + +QML content can be loaded from \l {The Qt Resource System} using the \e qrc: URL scheme. +For example: + +\code +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>main.qml</file> + <file>images/background.png</file> +</qresource> +</RCC> +\endcode +\code +// main.cpp +MyApplication::MyApplication() +{ + // ... + component = new QmlComponent(engine, QUrl("qrc:/main.qml")); + if (component->isError()) { + qWarning() << component->errors(); + } else { + QObject *myObject = component->create(); + } +} +\endcode +\code +// main.qml +import Qt 4.6 + +Image { + source: "images/background.png" +} +\endcode + */ diff --git a/doc/src/files-and-resources/resources.qdoc b/doc/src/files-and-resources/resources.qdoc index 639aaf4..00646ac 100644 --- a/doc/src/files-and-resources/resources.qdoc +++ b/doc/src/files-and-resources/resources.qdoc @@ -92,8 +92,11 @@ system. By default, resources are accessible in the application under the - same name as they have in the source tree, with a \c :/ prefix. - For example, the path \c :/images/cut.png would give access to the + same file name as they have in the source tree, with a \c :/ prefix, + or by a \link QUrl URL\endlink with a \c qrc scheme. + + For example, the file path \c :/images/cut.png or the URL + \c qrc:///images/cut.png would give access to the \c cut.png file, whose location in the application's source tree is \c images/cut.png. This can be changed using the \c file tag's \c alias attribute: diff --git a/doc/src/images/declarative-rotation.png b/doc/src/images/declarative-rotation.png Binary files differindex 994011b..b4031f5 100644 --- a/doc/src/images/declarative-rotation.png +++ b/doc/src/images/declarative-rotation.png diff --git a/examples/declarative/anchors/anchor-changes.qml b/examples/declarative/anchors/anchor-changes.qml index 2ebe1c0..f6fd35d 100644 --- a/examples/declarative/anchors/anchor-changes.qml +++ b/examples/declarative/anchors/anchor-changes.qml @@ -41,6 +41,6 @@ Item { } transitions : Transition { - NumberAnimation { matchProperties: "y,height" } + NumberAnimation { properties: "y,height" } } } diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml index a9ba05f..59e9b17 100644 --- a/examples/declarative/animations/easing.qml +++ b/examples/declarative/animations/easing.qml @@ -80,8 +80,8 @@ Rectangle { transitions: Transition { ParallelAnimation { - NumberAnimation { matchProperties: "x"; easing: type; duration: 1000 } - ColorAnimation { matchProperties: "color"; easing: type; duration: 1000 } + NumberAnimation { properties: "x"; easing: type; duration: 1000 } + ColorAnimation { properties: "color"; easing: type; duration: 1000 } } } } diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml index 728c3a5..a0dfad3 100644 --- a/examples/declarative/dynamic/qml/PerspectiveItem.qml +++ b/examples/declarative/dynamic/qml/PerspectiveItem.qml @@ -6,6 +6,7 @@ Image { 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 opacity: onLand ? 1 : 0.25 onCreatedChanged: if (created && !onLand) { tree.destroy() } else { z = scaledBottom } scale: scaleFactor diff --git a/examples/declarative/imageprovider/imageprovider.pro b/examples/declarative/imageprovider/imageprovider.pro new file mode 100644 index 0000000..60423ab --- /dev/null +++ b/examples/declarative/imageprovider/imageprovider.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = imageprovider +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp +RESOURCES += imageprovider.qrc diff --git a/examples/declarative/imageprovider/imageprovider.qrc b/examples/declarative/imageprovider/imageprovider.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/imageprovider/imageprovider.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>view.qml</file> +</qresource> +</RCC> diff --git a/tools/qmldebugger/standalone/objecttree.h b/examples/declarative/imageprovider/main.cpp index 31c257f..9526105 100644 --- a/tools/qmldebugger/standalone/objecttree.h +++ b/examples/declarative/imageprovider/main.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt QML Debugger of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,59 +38,62 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef OBJECTTREE_H -#define OBJECTTREE_H -#include <QtGui/qtreewidget.h> +#include <QApplication> -QT_BEGIN_NAMESPACE +#include <qmlengine.h> +#include <qmlcontext.h> +#include <qml.h> +#include <qmlgraphicsitem.h> +#include <qmlimageprovider.h> +#include <qmlview.h> +#include <QImage> +#include <QPainter> -class QTreeWidgetItem; +/* + This example illustrates using a QmlImageProvider to serve + images asynchronously. +*/ -class QmlEngineDebug; -class QmlDebugObjectReference; -class QmlDebugObjectQuery; -class QmlDebugContextReference; -class QmlDebugConnection; - - -class ObjectTree : public QTreeWidget +//![0] +class ColorImageProvider : public QmlImageProvider { - Q_OBJECT public: - ObjectTree(QmlEngineDebug *client = 0, QWidget *parent = 0); - - void setEngineDebug(QmlEngineDebug *client); - -signals: - void currentObjectChanged(const QmlDebugObjectReference &); - void activated(const QmlDebugObjectReference &); - void expressionWatchRequested(const QmlDebugObjectReference &, const QString &); - -public slots: - void reload(int objectDebugId); // set the root object - void setCurrentObject(int debugId); // select an object in the tree + // This is run in a low priority thread. + QImage request(const QString &id) { + QImage image(100, 50, QImage::Format_RGB32); + image.fill(QColor(id).rgba()); + QPainter p(&image); + p.setPen(Qt::black); + p.drawText(QRectF(0,0,100,50),Qt::AlignCenter,id); + return image; + } +}; -protected: - virtual void mousePressEvent(QMouseEvent *); +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); -private slots: - void objectFetched(); - void currentItemChanged(QTreeWidgetItem *); - void activated(QTreeWidgetItem *); + QmlView view; + view.setSource(QUrl("qrc:view.qml")); -private: - QTreeWidgetItem *findItemByObjectId(int debugId) const; - QTreeWidgetItem *findItem(QTreeWidgetItem *item, int debugId) const; - void dump(const QmlDebugContextReference &, int); - void dump(const QmlDebugObjectReference &, int); - void buildTree(const QmlDebugObjectReference &, QTreeWidgetItem *parent); + view.engine()->addImageProvider("colors", new ColorImageProvider); - QmlEngineDebug *m_client; - QmlDebugObjectQuery *m_query; -}; + QStringList dataList; + dataList.append("image://colors/red"); + dataList.append("image://colors/green"); + dataList.append("image://colors/blue"); + dataList.append("image://colors/brown"); + dataList.append("image://colors/orange"); + dataList.append("image://colors/purple"); + dataList.append("image://colors/yellow"); -QT_END_NAMESPACE + QmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + view.execute(); + view.show(); -#endif + return app.exec(); +} +//![0] diff --git a/examples/declarative/imageprovider/view.qml b/examples/declarative/imageprovider/view.qml new file mode 100644 index 0000000..2ab729d --- /dev/null +++ b/examples/declarative/imageprovider/view.qml @@ -0,0 +1,22 @@ +import Qt 4.6 +//![0] +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Item { + width: 100 + height: 50 + Text { + text: "Loading..." + anchors.centerIn: parent + } + Image { + source: modelData + } + } + } +} +//![0] diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml index 215b536..44d0c7b 100644 --- a/examples/declarative/layouts/Button.qml +++ b/examples/declarative/layouts/Button.qml @@ -17,6 +17,6 @@ Rectangle { border.color: "black"; color: "steelblue"; radius: 5; width: pix.wid transitions: Transition{ - NumberAnimation { matchProperties:"x,left"; easing:"easeInOutQuad"; duration:200 } + NumberAnimation { properties:"x,left"; easing:"easeInOutQuad"; duration:200 } } } diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml index 46762f7..fefd964 100644 --- a/examples/declarative/layouts/positioners.qml +++ b/examples/declarative/layouts/positioners.qml @@ -11,12 +11,12 @@ Rectangle { y: 0 move: Transition { NumberAnimation { - matchProperties: "y"; easing: "easeOutBounce" + properties: "y"; easing: "easeOutBounce" } } add: Transition { NumberAnimation { - matchProperties: "y"; easing: "easeOutQuad" + properties: "y"; easing: "easeOutQuad" } } Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } @@ -35,12 +35,12 @@ Rectangle { y: 300 move: Transition { NumberAnimation { - matchProperties: "x"; easing: "easeOutBounce" + properties: "x"; easing: "easeOutBounce" } } add: Transition { NumberAnimation { - matchProperties: "x"; easing: "easeOutQuad" + properties: "x"; easing: "easeOutQuad" } } Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } @@ -101,13 +101,13 @@ Rectangle { move: Transition { NumberAnimation { - matchProperties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing: "easeOutBounce" } } add: Transition { NumberAnimation { - matchProperties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing: "easeOutBounce" } } @@ -136,13 +136,13 @@ Rectangle { move: Transition { NumberAnimation { - matchProperties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing: "easeOutBounce" } } add: Transition { NumberAnimation { - matchProperties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing: "easeOutBounce" } } Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } diff --git a/examples/declarative/listview/content/ClickAutoRepeating.qml b/examples/declarative/listview/content/ClickAutoRepeating.qml index 796f9e3..be37b50 100644 --- a/examples/declarative/listview/content/ClickAutoRepeating.qml +++ b/examples/declarative/listview/content/ClickAutoRepeating.qml @@ -11,6 +11,7 @@ Item { signal clicked isPressed: SequentialAnimation { + running: false id: autoRepeat PropertyAction { target: page; property: "isPressed"; value: true } ScriptAction { script: page.pressed() } diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml index 101b708..dd898f9 100644 --- a/examples/declarative/listview/dynamic.qml +++ b/examples/declarative/listview/dynamic.qml @@ -24,7 +24,6 @@ Rectangle { } ListElement { name: "Cumquat"; cost: 3.25 - types: [ "Small", "Smaller" ] attributes: [ ListElement { description: "Citrus" } ] @@ -82,12 +81,12 @@ Rectangle { anchors.right: removeButton.left; anchors.rightMargin: 35; spacing: 10 width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter Image { source: "content/pics/list-add.png" - ClickAutoRepeating { id: clickUp; anchors.fill: parent; onClicked: fruitModel.set(index,"cost",Number(cost)+0.25) } + ClickAutoRepeating { id: clickUp; anchors.fill: parent; onClicked: fruitModel.setProperty(index,"cost",cost+0.25) } scale: clickUp.isPressed ? 0.9 : 1; transformOrigin: Item.Center } Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; } Image { source: "content/pics/list-remove.png" - ClickAutoRepeating { id: clickDown; anchors.fill: parent; onClicked: fruitModel.set(index,"cost",Math.max(0,Number(cost)-0.25)) } + ClickAutoRepeating { id: clickDown; anchors.fill: parent; onClicked: fruitModel.setProperty(index,"cost",Math.max(0,cost-0.25)) } scale: clickDown.isPressed ? 0.9 : 1; transformOrigin: Item.Center } } @@ -122,7 +121,7 @@ Rectangle { PropertyChanges { target: verticalScrollBar; opacity: 1 } } ] - transitions: [ Transition { NumberAnimation { matchProperties: "opacity"; duration: 400 } } ] + transitions: [ Transition { NumberAnimation { properties: "opacity"; duration: 400 } } ] } Row { diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml index 9665499..be1f62d 100644 --- a/examples/declarative/listview/highlight.qml +++ b/examples/declarative/listview/highlight.qml @@ -31,7 +31,7 @@ Rectangle { transitions: [ Transition { NumberAnimation { - matchProperties: "x"; duration: 200 + properties: "x"; duration: 200 } } ] diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index c133351..3410f56 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -124,7 +124,7 @@ Rectangle { ParallelAnimation { ColorAnimation { property: "color"; duration: 500 } NumberAnimation { - duration: 300; matchProperties: "detailsOpacity,x,viewportY,height,width" + duration: 300; properties: "detailsOpacity,x,viewportY,height,width" } } } diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp index 8231538..5eb6b7d 100644 --- a/examples/declarative/objectlistmodel/main.cpp +++ b/examples/declarative/objectlistmodel/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char ** argv) QApplication app(argc, argv); QmlView view; - view.setUrl(QUrl("qrc:view.qml")); + view.setSource(QUrl("qrc:view.qml")); QList<QObject*> dataList; dataList.append(new DataObject("Item 1", "red")); diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml index ff4a85a..f10d374 100644 --- a/examples/declarative/parallax/qml/ParallaxView.qml +++ b/examples/declarative/parallax/qml/ParallaxView.qml @@ -74,7 +74,7 @@ Item { } transitions: Transition { NumberAnimation { - matchProperties: "scale,y" + properties: "scale,y" } } } diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml index f68775c..802b537 100644 --- a/examples/declarative/scrollbar/ScrollBar.qml +++ b/examples/declarative/scrollbar/ScrollBar.qml @@ -2,7 +2,7 @@ import Qt 4.6 Item { id: scrollBar - // The matchProperties that define the scrollbar's state. + // The properties that define the scrollbar's state. // position and pageSize are in the range 0.0 - 1.0. They are relative to the // height of the page, i.e. a pageSize of 0.5 means that you can see 50% // of the height of the view. diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml index 0b9f95a..536a8b7 100644 --- a/examples/declarative/scrollbar/display.qml +++ b/examples/declarative/scrollbar/display.qml @@ -27,7 +27,7 @@ Rectangle { from: "*" to: "*" NumberAnimation { - matchProperties: "opacity" + properties: "opacity" duration: 400 } } diff --git a/examples/declarative/searchbox/SearchBox.qml b/examples/declarative/searchbox/SearchBox.qml index 42b5d67..7077a11 100644 --- a/examples/declarative/searchbox/SearchBox.qml +++ b/examples/declarative/searchbox/SearchBox.qml @@ -50,11 +50,11 @@ FocusScope { transitions: [ Transition { from: ""; to: "hasText" - NumberAnimation { exclude: typeSomething; matchProperties: "opacity" } + NumberAnimation { exclude: typeSomething; properties: "opacity" } }, Transition { from: "hasText"; to: "" - NumberAnimation { matchProperties: "opacity" } + NumberAnimation { properties: "opacity" } } ] } diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml index 29a62f7..c7f1c24 100644 --- a/examples/declarative/slideswitch/content/Switch.qml +++ b/examples/declarative/slideswitch/content/Switch.qml @@ -66,7 +66,7 @@ Item { //![7] transitions: Transition { - NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad"; duration: 200 } + NumberAnimation { properties: "x"; easing: "easeInOutQuad"; duration: 200 } } //![7] } diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml index 1d738b2..c2a2674 100644 --- a/examples/declarative/snow/ImageBatch.qml +++ b/examples/declarative/snow/ImageBatch.qml @@ -23,7 +23,7 @@ GridView { transitions: Transition { SequentialAnimation { PauseAnimation { duration: 150 } - PropertyAction { matchProperties: "z" } + PropertyAction { properties: "z" } } } model: XmlListModel { @@ -55,15 +55,15 @@ GridView { to: "selected" SequentialAnimation { PauseAnimation { duration: 150 } - PropertyAction { matchProperties: "z" } - NumberAnimation { matchProperties: "scale"; duration: 150; } + PropertyAction { properties: "z" } + NumberAnimation { properties: "scale"; duration: 150; } } }, Transition { from: "selected" SequentialAnimation { - NumberAnimation { matchProperties: "scale"; duration: 150 } - PropertyAction { matchProperties: "z" } + NumberAnimation { properties: "scale"; duration: 150 } + PropertyAction { properties: "z" } } } ] diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml index 925d90e..ba97d9be 100644 --- a/examples/declarative/states/transitions.qml +++ b/examples/declarative/states/transitions.qml @@ -48,23 +48,23 @@ Rectangle { } ] - // transitions define how the matchProperties change. + // transitions define how the properties change. transitions: [ // When transitioning to 'Position1' move x,y over a duration of 1 second, // with easeOutBounce easing function. Transition { from: "*"; to: "Position1" - NumberAnimation { matchProperties: "x,y"; easing: "easeOutBounce"; duration: 1000 } + NumberAnimation { properties: "x,y"; easing: "easeOutBounce"; duration: 1000 } }, // When transitioning to 'Position2' move x,y over a duration of 2 seconds, // with easeInOutQuad easing function. Transition { from: "*"; to: "Position2" - NumberAnimation { matchProperties: "x,y"; easing: "easeInOutQuad"; duration: 2000 } + NumberAnimation { properties: "x,y"; easing: "easeInOutQuad"; duration: 2000 } }, // For any other state changes move x,y linearly over duration of 200ms. Transition { - NumberAnimation { matchProperties: "x,y"; duration: 200 } + NumberAnimation { properties: "x,y"; duration: 200 } } ] } diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml index 0f27f86..107b066 100644 --- a/examples/declarative/tutorials/helloworld/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/tutorial3.qml @@ -28,7 +28,7 @@ Rectangle { transitions: Transition { from: ""; to: "down"; reversible: true ParallelAnimation { - NumberAnimation { matchProperties: "y,rotation"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "y,rotation"; duration: 500; easing: "easeInOutQuad" } ColorAnimation { duration: 500 } } } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml index 2eb2ceb..4c2ba43 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -24,7 +24,7 @@ Item { id:block } } opacity: 0 - opacity: Behavior { NumberAnimation { matchProperties:"opacity"; duration: 200 } } + opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } anchors.fill: parent } //![2] diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index 3a7ffa9..030fa13 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -71,7 +71,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { matchProperties: "rotation,scale"; duration: 200 } + NumberAnimation { properties: "rotation,scale"; duration: 200 } } } } diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml index 1614906..74c6844 100644 --- a/examples/declarative/webview/autosize.qml +++ b/examples/declarative/webview/autosize.qml @@ -1,7 +1,7 @@ import Qt 4.6 // The WebView size is determined by the width, height, -// preferredWidth, and preferredHeight matchProperties. +// preferredWidth, and preferredHeight properties. Rectangle { id: rect color: "white" diff --git a/examples/declarative/webview/content/FieldText.qml b/examples/declarative/webview/content/FieldText.qml index 6b1d271..b1c1938 100644 --- a/examples/declarative/webview/content/FieldText.qml +++ b/examples/declarative/webview/content/FieldText.qml @@ -149,7 +149,7 @@ Item { to: "*" reversible: true NumberAnimation { - matchProperties: "opacity,leftMargin,rightMargin" + properties: "opacity,leftMargin,rightMargin" duration: 200 } ColorAnimation { diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index bd14516..23463c2 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -61,8 +61,8 @@ Rectangle { transitions: Transition { from: "*"; to: "Details"; reversible: true SequentialAnimation { - NumberAnimation { duration: 200; matchProperties: "height"; easing: "easeOutQuad" } - NumberAnimation { duration: 200; matchProperties: "opacity" } + NumberAnimation { duration: 200; properties: "height"; easing: "easeOutQuad" } + NumberAnimation { duration: 200; properties: "opacity" } } } } diff --git a/mkspecs/linux-g++-x11egl/qmake.conf b/mkspecs/linux-g++-x11egl/qmake.conf deleted file mode 100644 index 593f120..0000000 --- a/mkspecs/linux-g++-x11egl/qmake.conf +++ /dev/null @@ -1,30 +0,0 @@ -# -# qmake configuration for linux-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublib - -include(../common/g++.conf) -include(../common/linux.conf) -load(qt_config) - -QMAKE_INCDIR_EGL = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/Include -QMAKE_LIBDIR_EGL = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/LinuxPC/Lib -QMAKE_LIBS_EGL = -lGLESv2 -lEGL - -QMAKE_INCDIR_OPENGL = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/Include -QMAKE_INCDIR_OPENGL_QT = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/Include - -QMAKE_LIBDIR_OPENGL = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/LinuxPC/Lib -QMAKE_LIBDIR_OPENGL_QT = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/LinuxPC/Lib - -QMAKE_LIBS_OPENGL = -lGLESv2 -lEGL -QMAKE_LIBS += -Wl,-rpath=$(HOME)/opengles2/SDKPackage/Builds/OGLES2/LinuxPC/Lib - -QMAKE_LIBS_OPENGL_QT = -lGLESv2 -lEGL - -QMAKE_RPATH = -Wl,-rpath, diff --git a/mkspecs/linux-g++-x11egl/qplatformdefs.h b/mkspecs/linux-g++-x11egl/qplatformdefs.h deleted file mode 100644 index dd3b9a1..0000000 --- a/mkspecs/linux-g++-x11egl/qplatformdefs.h +++ /dev/null @@ -1,164 +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 qmake spec of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H - -// Get Qt defines/settings - -#include "qglobal.h" - -// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs - -// 1) need to reset default environment if _BSD_SOURCE is defined -// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0 -// 3) it seems older glibc need this to include the X/Open stuff -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include <unistd.h> - - -// We are hot - unistd.h should have turned on the specific APIs we requested - -#include <features.h> -#include <pthread.h> -#include <dirent.h> -#include <fcntl.h> -#include <grp.h> -#include <pwd.h> -#include <signal.h> -#include <dlfcn.h> - -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/ipc.h> -#include <sys/time.h> -#include <sys/shm.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <netinet/in.h> -#ifndef QT_NO_IPV6IFNAME -#include <net/if.h> -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t -#else -#define QT_SOCKLEN_T int -#endif - -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf -#endif - - -#endif // QPLATFORMDEFS_H diff --git a/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp b/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp index 07f13d4..756ece3 100644 --- a/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp +++ b/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp @@ -20,6 +20,8 @@ #include "config.h" #include "AccessibilityObject.h" +QT_BEGIN_NAMESPACE + #if HAVE(ACCESSIBILITY) namespace WebCore { @@ -37,3 +39,5 @@ AccessibilityObjectPlatformInclusion AccessibilityObject::accessibilityPlatformI } // namespace WebCore #endif // HAVE(ACCESSIBILITY) + +QT_END_NAMESPACE diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 99bbe42..7e7d7d8 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -864,6 +864,9 @@ typedef quint64 qulonglong; # endif #endif +#define Q_INIT_RESOURCE_EXTERN(name) \ + extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); + #define Q_INIT_RESOURCE(name) \ do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \ QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (0) diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index 43e89e3..090998c 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -124,3 +124,4 @@ void qFreeAligned(void *ptr) } QT_END_NAMESPACE + diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index e54ec95..e3aab65 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,6 +1,30 @@ +============================================================================= +The changes below are pre Qt 4.7.0 alpha + +QmlView +------- +The API of QmlView has been narrowed and its role as a convenience class +reinforced. +- remove addItem() +- remove clearItems() - use 'delete root()' +- remove reset() +- resizeContent -> enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView } +- remove setQml(), qml() +- rename setUrl(), ur() to setSource(), source() +- root() -> rootObject(), returns QGraphicsObject rather than QmlGraphicsItem +- remove quit() signal -> use quit() signal of engine() +- initialSize() signal removed +- Added status() to determine status of the internal QmlComponent +sectionExpression has been replaced by section.property, section.criteria -Listview: sectionExpression has been replaced by section.property, section.criteria +ListModel +--------- +- types are strictly checked (previously, everything was a string) + - foo: "bar" continues to work as before + - foo: bar is now invalid, use foo: "bar" + - foo: true is now a bool (not string "true") + - foo: false is now a bool (not string "false" == true!) ============================================================================= diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp index 5e93d50..32d8bbb 100644 --- a/src/declarative/debugger/qmldebug.cpp +++ b/src/declarative/debugger/qmldebug.cpp @@ -47,6 +47,8 @@ #include <private/qobject_p.h> +QT_BEGIN_NAMESPACE + class QmlEngineDebugClient : public QmlDebugClient { public: @@ -142,8 +144,6 @@ void QmlEngineDebugPrivate::remove(QmlEngineDebug *c, QmlDebugExpressionQuery *q } } - -Q_DECLARE_METATYPE(QmlDebugObjectReference); void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o, bool simple) { @@ -932,3 +932,6 @@ bool QmlDebugPropertyReference::hasNotifySignal() const { return m_hasNotifySignal; } + +QT_END_NAMESPACE + diff --git a/src/declarative/debugger/qmldebug_p.h b/src/declarative/debugger/qmldebug_p.h index 4e9d065..a1371d5 100644 --- a/src/declarative/debugger/qmldebug_p.h +++ b/src/declarative/debugger/qmldebug_p.h @@ -361,6 +361,11 @@ private: QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlDebugEngineReference) +Q_DECLARE_METATYPE(QmlDebugObjectReference) +Q_DECLARE_METATYPE(QmlDebugContextReference) +Q_DECLARE_METATYPE(QmlDebugPropertyReference) + QT_END_HEADER #endif // QMLDEBUG_H diff --git a/src/declarative/debugger/qmldebugservice.cpp b/src/declarative/debugger/qmldebugservice.cpp index 7f28c0c..7b21869 100644 --- a/src/declarative/debugger/qmldebugservice.cpp +++ b/src/declarative/debugger/qmldebugservice.cpp @@ -61,9 +61,11 @@ class QmlDebugServer : public QObject public: static QmlDebugServer *instance(); void wait(); + void registerForStartNotification(QObject *object, const char *receiver); private Q_SLOTS: void readyRead(); + void registeredObjectDestroyed(QObject *object); private: friend class QmlDebugService; @@ -83,6 +85,7 @@ public: QPacketProtocol *protocol; QHash<QString, QmlDebugService *> plugins; QStringList enabledPlugins; + QList<QPair<QObject*, QByteArray> > notifyClients; }; class QmlDebugServicePrivate : public QObjectPrivate @@ -112,6 +115,14 @@ void QmlDebugServerPrivate::wait() qWarning("QmlDebugServer: Waiting for connection on port %d...", port); + for (int i=0; i<notifyClients.count(); i++) { + if (!QMetaObject::invokeMethod(notifyClients[i].first, notifyClients[i].second)) { + qWarning() << "QmlDebugServer: unable to call method" << notifyClients[i].second + << "on object" << notifyClients[i].first << "to notify of debug server start"; + } + } + notifyClients.clear(); + if (!server.waitForNewConnection(-1)) { qWarning("QmlDebugServer: Connection error"); return; @@ -165,6 +176,23 @@ void QmlDebugServer::wait() d->wait(); } +void QmlDebugServer::registerForStartNotification(QObject *object, const char *methodName) +{ + Q_D(QmlDebugServer); + connect(object, SIGNAL(destroyed(QObject*)), SLOT(registeredObjectDestroyed(QObject*))); + d->notifyClients.append(qMakePair(object, QByteArray(methodName))); +} + +void QmlDebugServer::registeredObjectDestroyed(QObject *object) +{ + Q_D(QmlDebugServer); + QMutableListIterator<QPair<QObject*, QByteArray> > i(d->notifyClients); + while (i.hasNext()) { + if (i.next().first == object) + i.remove(); + } +} + QmlDebugServer::QmlDebugServer(int port) : QObject(*(new QmlDebugServerPrivate)) { @@ -367,6 +395,11 @@ void QmlDebugService::waitForClients() QmlDebugServer::instance()->wait(); } +void QmlDebugService::notifyOnServerStart(QObject *object, const char *receiver) +{ + QmlDebugServer::instance()->registerForStartNotification(object, receiver); +} + void QmlDebugService::sendMessage(const QByteArray &message) { Q_D(QmlDebugService); diff --git a/src/declarative/debugger/qmldebugservice_p.h b/src/declarative/debugger/qmldebugservice_p.h index 55ecf1d..33ddda0 100644 --- a/src/declarative/debugger/qmldebugservice_p.h +++ b/src/declarative/debugger/qmldebugservice_p.h @@ -68,17 +68,19 @@ public: static int idForObject(QObject *); static QObject *objectForId(int); - static bool isDebuggingEnabled(); static QString objectToString(QObject *obj); static void waitForClients(); + static void notifyOnServerStart(QObject *object, const char *receiver); + protected: virtual void enabledChanged(bool); virtual void messageReceived(const QByteArray &); private: + void registerForStartNotification(QObject *object, const char *methodName); friend class QmlDebugServer; }; diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri index eb6e0ad..db9c29e 100644 --- a/src/declarative/graphicsitems/graphicsitems.pri +++ b/src/declarative/graphicsitems/graphicsitems.pri @@ -1,9 +1,11 @@ INCLUDEPATH += $$PWD HEADERS += \ + $$PWD/qmlgraphicsitemsmodule_p.h \ $$PWD/qmlgraphicsanchors_p.h \ $$PWD/qmlgraphicsanchors_p_p.h \ $$PWD/qmlgraphicsevents_p_p.h \ + $$PWD/qmlgraphicseffects_p.h \ $$PWD/qmlgraphicsflickable_p.h \ $$PWD/qmlgraphicsflickable_p_p.h \ $$PWD/qmlgraphicsflipable_p.h \ @@ -52,6 +54,7 @@ HEADERS += \ $$PWD/qmlgraphicseffects.cpp SOURCES += \ + $$PWD/qmlgraphicsitemsmodule.cpp \ $$PWD/qmlgraphicsanchors.cpp \ $$PWD/qmlgraphicsevents.cpp \ $$PWD/qmlgraphicsflickable.cpp \ diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp index 3a6ec48..cde9ec7 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp @@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsAnchors) - //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? //TODO: support non-parent, non-sibling (need to find lowest common ancestor) diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h index 12197f0..a2e41d3 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h @@ -87,9 +87,6 @@ public: return item == other.item && anchorLine == other.anchorLine; } }; -Q_DECLARE_METATYPE(QmlGraphicsAnchorLine) - - class QmlGraphicsAnchorsPrivate : public QObjectPrivate, public QmlGraphicsItemChangeListener { @@ -171,4 +168,7 @@ public: }; QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QmlGraphicsAnchorLine) + #endif diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp index eb60495..697be15 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp @@ -78,7 +78,6 @@ Item { \endqml \endtable */ -QML_DEFINE_TYPE(Qt,4,6,AnimatedImage,QmlGraphicsAnimatedImage) QmlGraphicsAnimatedImage::QmlGraphicsAnimatedImage(QmlGraphicsItem *parent) : QmlGraphicsImage(*(new QmlGraphicsAnimatedImagePrivate), parent) @@ -296,6 +295,7 @@ void QmlGraphicsAnimatedImage::playingStatusChanged() void QmlGraphicsAnimatedImage::componentComplete() { Q_D(QmlGraphicsAnimatedImage); + QmlGraphicsImage::componentComplete(); if (!d->reply) { setCurrentFrame(d->preset_currentframe); d->preset_currentframe = 0; diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp index 493b148..f739464 100644 --- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp @@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,BorderImage,QmlGraphicsBorderImage) - /*! \qmlclass BorderImage QmlGraphicsBorderImage \brief The BorderImage element provides an image that can be used as a border. diff --git a/src/declarative/graphicsitems/qmlgraphicseffects.cpp b/src/declarative/graphicsitems/qmlgraphicseffects.cpp index 0160971..6a93b12 100644 --- a/src/declarative/graphicsitems/qmlgraphicseffects.cpp +++ b/src/declarative/graphicsitems/qmlgraphicseffects.cpp @@ -43,12 +43,6 @@ #include <QtGui/qgraphicseffect.h> -QML_DECLARE_TYPE(QGraphicsEffect) -QML_DEFINE_NOCREATE_TYPE(QGraphicsEffect) - -QML_DECLARE_TYPE(QGraphicsBlurEffect) -QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect) - /*! \qmlclass Blur QGraphicsBlurEffect \brief The Blur object provides a blur effect. @@ -84,9 +78,6 @@ QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect) The default hint is Qt.PerformanceHint. */ -QML_DECLARE_TYPE(QGraphicsColorizeEffect) -QML_DEFINE_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect) - /*! \qmlclass Colorize QGraphicsColorizeEffect \brief The Colorize object provides a colorize effect. @@ -112,8 +103,6 @@ QML_DEFINE_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect) while 1.0 means full colorization. By default, the strength is 1.0. */ -QML_DECLARE_TYPE(QGraphicsDropShadowEffect) -QML_DEFINE_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect) /*! \qmlclass DropShadow QGraphicsDropShadowEffect @@ -155,8 +144,6 @@ QML_DEFINE_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect) By default, the drop color is a semi-transparent dark gray. */ -QML_DECLARE_TYPE(QGraphicsOpacityEffect) -QML_DEFINE_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect) /*! \qmlclass Opacity QGraphicsOpacityEffect diff --git a/tools/qmldebugger/standalone/engine.h b/src/declarative/graphicsitems/qmlgraphicseffects_p.h index ee706624..4b94a14 100644 --- a/tools/qmldebugger/standalone/engine.h +++ b/src/declarative/graphicsitems/qmlgraphicseffects_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt QML Debugger of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,64 +38,28 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef ENGINE_H -#define ENGINE_H - -#include <QWidget> -#include <QtCore/qpointer.h> -#include <QtDeclarative/qmlengine.h> -#include <QtDeclarative/qmlcontext.h> -#include <QtDeclarative/qmlview.h> -#include <private/qmldebug_p.h> - -QT_BEGIN_NAMESPACE - -class ObjectPropertiesView; -class QmlDebugConnection; -class QmlDebugPropertyReference; -class QmlDebugWatch; -class ObjectTree; -class WatchTableModel; -class WatchTableView; -class ExpressionQueryWidget; - -class QTabWidget; - -class EnginePane : public QWidget -{ -Q_OBJECT -public: - EnginePane(QmlDebugConnection *, QWidget *parent = 0); - -public slots: - void refreshEngines(); - -private slots: - void enginesChanged(); - - void queryContext(int); - void contextChanged(); - - void engineSelected(int); - -private: - QmlEngineDebug *m_client; - QmlDebugEnginesQuery *m_engines; - QmlDebugRootContextQuery *m_context; - - ObjectTree *m_objTree; - QTabWidget *m_tabs; - WatchTableView *m_watchTableView; - WatchTableModel *m_watchTableModel; - ExpressionQueryWidget *m_exprQueryWidget; - - QmlView *m_engineView; - QList<QObject *> m_engineItems; - - ObjectPropertiesView *m_propertiesView; -}; - -QT_END_NAMESPACE - -#endif // ENGINE_H +#ifndef QMLGRAPHICSEFFECTS_P_H +#define QMLGRAPHICSEFFECTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qml.h> +#include <QtGui/qgraphicseffect.h> + +QML_DECLARE_TYPE(QGraphicsEffect) +QML_DECLARE_TYPE(QGraphicsBlurEffect) +QML_DECLARE_TYPE(QGraphicsColorizeEffect) +QML_DECLARE_TYPE(QGraphicsDropShadowEffect) +QML_DECLARE_TYPE(QGraphicsOpacityEffect) + +#endif // QMLGRAPHICSEFFECTS_P_H diff --git a/src/declarative/graphicsitems/qmlgraphicsevents.cpp b/src/declarative/graphicsitems/qmlgraphicsevents.cpp index d42708c..1f63218 100644 --- a/src/declarative/graphicsitems/qmlgraphicsevents.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsevents.cpp @@ -189,7 +189,4 @@ MouseRegion { \endqml */ -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsKeyEvent) -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsMouseEvent) - QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index 2bf11a0..6825f89 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -56,36 +56,6 @@ static const int FlickThreshold = 20; // Really slow flicks can be annoying. static const int minimumFlickVelocity = 200; -class QmlGraphicsFlickableVisibleArea : public QObject -{ - Q_OBJECT - - Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged) - Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged) - Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged) - Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged) - -public: - QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent=0); - - qreal xPosition() const; - qreal widthRatio() const; - qreal yPosition() const; - qreal heightRatio() const; - - void updateVisible(); - -signals: - void pageChanged(); - -private: - QmlGraphicsFlickable *flickable; - qreal m_xPosition; - qreal m_widthRatio; - qreal m_yPosition; - qreal m_heightRatio; -}; - QmlGraphicsFlickableVisibleArea::QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent) : QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.) , m_yPosition(0.), m_heightRatio(0.) @@ -356,8 +326,6 @@ void QmlGraphicsFlickablePrivate::updateBeginningEnd() visibleArea->updateVisible(); } -QML_DEFINE_TYPE(Qt,4,6,Flickable,QmlGraphicsFlickable) - /*! \qmlclass Flickable QmlGraphicsFlickable \brief The Flickable item provides a surface that can be "flicked". @@ -1038,7 +1006,10 @@ bool QmlGraphicsFlickable::overShoot() const void QmlGraphicsFlickable::setOverShoot(bool o) { Q_D(QmlGraphicsFlickable); + if (d->overShoot == o) + return; d->overShoot = o; + emit overShootChanged(); } /*! @@ -1247,6 +1218,7 @@ void QmlGraphicsFlickable::setMaximumFlickVelocity(qreal v) if (v == d->maxVelocity) return; d->maxVelocity = v; + emit maximumFlickVelocityChanged(); } /*! @@ -1264,7 +1236,10 @@ qreal QmlGraphicsFlickable::flickDeceleration() const void QmlGraphicsFlickable::setFlickDeceleration(qreal deceleration) { Q_D(QmlGraphicsFlickable); + if (deceleration == d->deceleration) + return; d->deceleration = deceleration; + emit flickDecelerationChanged(); } /*! @@ -1302,6 +1277,7 @@ void QmlGraphicsFlickable::setPressDelay(int delay) if (d->pressDelay == delay) return; d->pressDelay = delay; + emit pressDelayChanged(); } qreal QmlGraphicsFlickable::reportedVelocitySmoothing() const @@ -1367,8 +1343,3 @@ void QmlGraphicsFlickablePrivate::updateVelocity() } QT_END_NAMESPACE - -QML_DECLARE_TYPE(QmlGraphicsFlickableVisibleArea) -QML_DEFINE_TYPE(Qt,4,6,VisibleArea,QmlGraphicsFlickableVisibleArea) - -#include <qmlgraphicsflickable.moc> diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h index 5ff8e6f..373815b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h @@ -65,15 +65,15 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsFlickable : public QmlGraphicsItem Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged) Q_PROPERTY(qreal reportedVelocitySmoothing READ reportedVelocitySmoothing WRITE setReportedVelocitySmoothing NOTIFY reportedVelocitySmoothingChanged) - Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot) - Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity) - Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration) + Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged) + Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged) + Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) Q_PROPERTY(FlickDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickDirectionChanged) Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) - Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay) + Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged) Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged) Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged) @@ -160,6 +160,10 @@ Q_SIGNALS: void pageChanged(); void flickDirectionChanged(); void interactiveChanged(); + void overShootChanged(); + void maximumFlickVelocityChanged(); + void flickDecelerationChanged(); + void pressDelayChanged(); protected: virtual bool sceneEventFilter(QGraphicsItem *, QEvent *); diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h index 5eda22c..0c98f7b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h @@ -159,6 +159,38 @@ public: QML_DECLARE_LIST_PROXY(QmlGraphicsFlickablePrivate, QObject *, data) }; +class QmlGraphicsFlickableVisibleArea : public QObject +{ + Q_OBJECT + + Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged) + Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged) + Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged) + Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged) + +public: + QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent=0); + + qreal xPosition() const; + qreal widthRatio() const; + qreal yPosition() const; + qreal heightRatio() const; + + void updateVisible(); + +signals: + void pageChanged(); + +private: + QmlGraphicsFlickable *flickable; + qreal m_xPosition; + qreal m_widthRatio; + qreal m_yPosition; + qreal m_heightRatio; +}; + QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlGraphicsFlickableVisibleArea) + #endif diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp index a30ba6c..be512fc 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp @@ -49,8 +49,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Flipable,QmlGraphicsFlipable) - class QmlGraphicsFlipablePrivate : public QmlGraphicsItemPrivate { Q_DECLARE_PUBLIC(QmlGraphicsFlipable) @@ -96,7 +94,7 @@ public: } transitions: Transition { - NumberAnimation { matchProperties: "angle"; duration: 2000 } + NumberAnimation { properties: "angle"; duration: 2000 } } MouseRegion { diff --git a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp b/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp index 093e9de..d564e86 100644 --- a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp @@ -46,8 +46,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,FocusPanel,QmlGraphicsFocusPanel) - /*! \qmlclass FocusPanel QmlGraphicsFocusPanel \brief The FocusPanel item explicitly creates a focus panel. diff --git a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp b/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp index 084e244..9930396 100644 --- a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp @@ -42,7 +42,6 @@ #include "qmlgraphicsfocusscope_p.h" QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,FocusScope,QmlGraphicsFocusScope) /*! \qmlclass FocusScope QmlGraphicsFocusScope diff --git a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp index e7206f1..497d950 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp @@ -131,9 +131,6 @@ public: \brief The QmlGraphicsGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications. */ -QML_DEFINE_NOCREATE_TYPE(QGraphicsObject) -QML_DEFINE_TYPE(Qt,4,6,GraphicsObjectContainer,QmlGraphicsGraphicsObjectContainer) - QmlGraphicsGraphicsObjectContainer::QmlGraphicsGraphicsObjectContainer(QmlGraphicsItem *parent) : QmlGraphicsItem(*new QmlGraphicsGraphicsObjectContainerPrivate, parent) { diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 24d9769..bf370ae 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -51,63 +51,6 @@ QT_BEGIN_NAMESPACE -class QmlGraphicsGridViewAttached : public QObject -{ - Q_OBJECT -public: - QmlGraphicsGridViewAttached(QObject *parent) - : QObject(parent), m_isCurrent(false), m_delayRemove(false) {} - ~QmlGraphicsGridViewAttached() { - attachedProperties.remove(parent()); - } - - Q_PROPERTY(QmlGraphicsGridView *view READ view CONSTANT) - QmlGraphicsGridView *view() { return m_view; } - - Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) - bool isCurrentItem() const { return m_isCurrent; } - void setIsCurrentItem(bool c) { - if (m_isCurrent != c) { - m_isCurrent = c; - emit currentItemChanged(); - } - } - - Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) - bool delayRemove() const { return m_delayRemove; } - void setDelayRemove(bool delay) { - if (m_delayRemove != delay) { - m_delayRemove = delay; - emit delayRemoveChanged(); - } - } - - static QmlGraphicsGridViewAttached *properties(QObject *obj) { - QmlGraphicsGridViewAttached *rv = attachedProperties.value(obj); - if (!rv) { - rv = new QmlGraphicsGridViewAttached(obj); - attachedProperties.insert(obj, rv); - } - return rv; - } - - void emitAdd() { emit add(); } - void emitRemove() { emit remove(); } - -Q_SIGNALS: - void currentItemChanged(); - void delayRemoveChanged(); - void add(); - void remove(); - -public: - QmlGraphicsGridView *m_view; - bool m_isCurrent; - bool m_delayRemove; - - static QHash<QObject*, QmlGraphicsGridViewAttached*> attachedProperties; -}; - QHash<QObject*, QmlGraphicsGridViewAttached*> QmlGraphicsGridViewAttached::attachedProperties; @@ -1713,9 +1656,32 @@ void QmlGraphicsGridView::itemsMoved(int from, int to, int count) ++endIndex; } + // update visibleIndex + for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { + if ((*it)->index != -1) { + d->visibleIndex = (*it)->index; + break; + } + } + + // Fix current index + if (d->currentIndex >= 0 && d->currentItem) { + int oldCurrent = d->currentIndex; + d->currentIndex = d->model->indexOf(d->currentItem->item, this); + if (oldCurrent != d->currentIndex) { + d->currentItem->index = d->currentIndex; + emit currentIndexChanged(); + } + } + // Whatever moved items remain are no longer visible items. - while (moved.count()) - d->releaseItem(moved.take(moved.begin().key())); + while (moved.count()) { + int idx = moved.begin().key(); + FxGridItem *item = moved.take(idx); + if (item->item == d->currentItem->item) + item->setPosition(d->colPosAt(idx), d->rowPosAt(idx)); + d->releaseItem(item); + } d->layout(removedBeforeVisible); } @@ -1754,8 +1720,4 @@ QmlGraphicsGridViewAttached *QmlGraphicsGridView::qmlAttachedProperties(QObject return QmlGraphicsGridViewAttached::properties(obj); } -QML_DEFINE_TYPE(Qt, 4,6, GridView, QmlGraphicsGridView) - QT_END_NAMESPACE - -#include <qmlgraphicsgridview.moc> diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h index 11dd3f2..bd18daf 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h @@ -154,6 +154,64 @@ private: void refill(); }; +class QmlGraphicsGridViewAttached : public QObject +{ + Q_OBJECT +public: + QmlGraphicsGridViewAttached(QObject *parent) + : QObject(parent), m_isCurrent(false), m_delayRemove(false) {} + ~QmlGraphicsGridViewAttached() { + attachedProperties.remove(parent()); + } + + Q_PROPERTY(QmlGraphicsGridView *view READ view CONSTANT) + QmlGraphicsGridView *view() { return m_view; } + + Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) + bool isCurrentItem() const { return m_isCurrent; } + void setIsCurrentItem(bool c) { + if (m_isCurrent != c) { + m_isCurrent = c; + emit currentItemChanged(); + } + } + + Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) + bool delayRemove() const { return m_delayRemove; } + void setDelayRemove(bool delay) { + if (m_delayRemove != delay) { + m_delayRemove = delay; + emit delayRemoveChanged(); + } + } + + static QmlGraphicsGridViewAttached *properties(QObject *obj) { + QmlGraphicsGridViewAttached *rv = attachedProperties.value(obj); + if (!rv) { + rv = new QmlGraphicsGridViewAttached(obj); + attachedProperties.insert(obj, rv); + } + return rv; + } + + void emitAdd() { emit add(); } + void emitRemove() { emit remove(); } + +Q_SIGNALS: + void currentItemChanged(); + void delayRemoveChanged(); + void add(); + void remove(); + +public: + QmlGraphicsGridView *m_view; + bool m_isCurrent; + bool m_delayRemove; + + static QHash<QObject*, QmlGraphicsGridViewAttached*> attachedProperties; +}; + + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsGridView) diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp index d4ad3c8..c586452 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp @@ -48,8 +48,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Image,QmlGraphicsImage) - /*! \qmlclass Image QmlGraphicsImage \brief The Image element allows you to add bitmaps to a scene. diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 17362d0..22beb12 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -69,12 +69,6 @@ QT_BEGIN_NAMESPACE #define FLT_MAX 1E+37 #endif -QML_DEFINE_TYPE(Qt,4,6,Item,QmlGraphicsItem) - -QML_DEFINE_NOCREATE_TYPE(QGraphicsTransform); -QML_DEFINE_TYPE(Qt,4,6,Scale,QGraphicsScale) -QML_DEFINE_TYPE(Qt,4,6,Rotation,QGraphicsRotation) - #include "qmlgraphicseffects.cpp" /*! @@ -325,28 +319,6 @@ void QmlGraphicsContents::setItem(QmlGraphicsItem *item) calcWidth(); } -/* - Key filters can be installed on a QmlGraphicsItem, but not removed. Currently they - are only used by attached objects (which are only destroyed on Item - destruction), so this isn't a problem. If in future this becomes any form - of public API, they will have to support removal too. -*/ -class QmlGraphicsItemKeyFilter -{ -public: - QmlGraphicsItemKeyFilter(QmlGraphicsItem * = 0); - virtual ~QmlGraphicsItemKeyFilter(); - - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *event); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - virtual void componentComplete(); - -private: - QmlGraphicsItemKeyFilter *m_next; -}; - QmlGraphicsItemKeyFilter::QmlGraphicsItemKeyFilter(QmlGraphicsItem *item) : m_next(0) { @@ -458,49 +430,6 @@ void QmlGraphicsItemKeyFilter::componentComplete() pressed. */ -class QmlGraphicsKeyNavigationAttachedPrivate : public QObjectPrivate -{ -public: - QmlGraphicsKeyNavigationAttachedPrivate() - : QObjectPrivate(), left(0), right(0), up(0), down(0) {} - - QmlGraphicsItem *left; - QmlGraphicsItem *right; - QmlGraphicsItem *up; - QmlGraphicsItem *down; -}; - -class QmlGraphicsKeyNavigationAttached : public QObject, public QmlGraphicsItemKeyFilter -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlGraphicsKeyNavigationAttached) - - Q_PROPERTY(QmlGraphicsItem *left READ left WRITE setLeft NOTIFY changed) - Q_PROPERTY(QmlGraphicsItem *right READ right WRITE setRight NOTIFY changed) - Q_PROPERTY(QmlGraphicsItem *up READ up WRITE setUp NOTIFY changed) - Q_PROPERTY(QmlGraphicsItem *down READ down WRITE setDown NOTIFY changed) -public: - QmlGraphicsKeyNavigationAttached(QObject * = 0); - - QmlGraphicsItem *left() const; - void setLeft(QmlGraphicsItem *); - QmlGraphicsItem *right() const; - void setRight(QmlGraphicsItem *); - QmlGraphicsItem *up() const; - void setUp(QmlGraphicsItem *); - QmlGraphicsItem *down() const; - void setDown(QmlGraphicsItem *); - - static QmlGraphicsKeyNavigationAttached *qmlAttachedProperties(QObject *); - -Q_SIGNALS: - void changed(); - -private: - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); -}; - QmlGraphicsKeyNavigationAttached::QmlGraphicsKeyNavigationAttached(QObject *parent) : QObject(*(new QmlGraphicsKeyNavigationAttachedPrivate), parent), QmlGraphicsItemKeyFilter(qobject_cast<QmlGraphicsItem*>(parent)) @@ -964,137 +893,6 @@ void QmlGraphicsKeyNavigationAttached::keyReleased(QKeyEvent *event) */ -class QmlGraphicsKeysAttachedPrivate : public QObjectPrivate -{ -public: - QmlGraphicsKeysAttachedPrivate() - : QObjectPrivate(), inPress(false), inRelease(false) - , inIM(false), enabled(true), imeItem(0), item(0) - {} - - bool isConnected(const char *signalName); - - QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const - { - QGraphicsItem *fp; - while ((fp = item->focusProxy())) - item = fp; - return item; - } - - //loop detection - bool inPress:1; - bool inRelease:1; - bool inIM:1; - - bool enabled : 1; - - QGraphicsItem *imeItem; - QList<QmlGraphicsItem *> targets; - QmlGraphicsItem *item; -}; - -class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached) - - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(QList<QmlGraphicsItem *> *forwardTo READ forwardTo) - -public: - QmlGraphicsKeysAttached(QObject *parent=0); - ~QmlGraphicsKeysAttached(); - - bool enabled() const { Q_D(const QmlGraphicsKeysAttached); return d->enabled; } - void setEnabled(bool enabled) { - Q_D(QmlGraphicsKeysAttached); - if (enabled != d->enabled) { - d->enabled = enabled; - emit enabledChanged(); - } - } - - QList<QmlGraphicsItem *> *forwardTo() { - Q_D(QmlGraphicsKeysAttached); - return &d->targets; - } - - virtual void componentComplete(); - - static QmlGraphicsKeysAttached *qmlAttachedProperties(QObject *); - -Q_SIGNALS: - void enabledChanged(); - void pressed(QmlGraphicsKeyEvent *event); - void released(QmlGraphicsKeyEvent *event); - void digit0Pressed(QmlGraphicsKeyEvent *event); - void digit1Pressed(QmlGraphicsKeyEvent *event); - void digit2Pressed(QmlGraphicsKeyEvent *event); - void digit3Pressed(QmlGraphicsKeyEvent *event); - void digit4Pressed(QmlGraphicsKeyEvent *event); - void digit5Pressed(QmlGraphicsKeyEvent *event); - void digit6Pressed(QmlGraphicsKeyEvent *event); - void digit7Pressed(QmlGraphicsKeyEvent *event); - void digit8Pressed(QmlGraphicsKeyEvent *event); - void digit9Pressed(QmlGraphicsKeyEvent *event); - - void leftPressed(QmlGraphicsKeyEvent *event); - void rightPressed(QmlGraphicsKeyEvent *event); - void upPressed(QmlGraphicsKeyEvent *event); - void downPressed(QmlGraphicsKeyEvent *event); - - void asteriskPressed(QmlGraphicsKeyEvent *event); - void numberSignPressed(QmlGraphicsKeyEvent *event); - void escapePressed(QmlGraphicsKeyEvent *event); - void returnPressed(QmlGraphicsKeyEvent *event); - void enterPressed(QmlGraphicsKeyEvent *event); - void deletePressed(QmlGraphicsKeyEvent *event); - void spacePressed(QmlGraphicsKeyEvent *event); - void backPressed(QmlGraphicsKeyEvent *event); - void cancelPressed(QmlGraphicsKeyEvent *event); - void selectPressed(QmlGraphicsKeyEvent *event); - void yesPressed(QmlGraphicsKeyEvent *event); - void noPressed(QmlGraphicsKeyEvent *event); - void context1Pressed(QmlGraphicsKeyEvent *event); - void context2Pressed(QmlGraphicsKeyEvent *event); - void context3Pressed(QmlGraphicsKeyEvent *event); - void context4Pressed(QmlGraphicsKeyEvent *event); - void callPressed(QmlGraphicsKeyEvent *event); - void hangupPressed(QmlGraphicsKeyEvent *event); - void flipPressed(QmlGraphicsKeyEvent *event); - void menuPressed(QmlGraphicsKeyEvent *event); - void volumeUpPressed(QmlGraphicsKeyEvent *event); - void volumeDownPressed(QmlGraphicsKeyEvent *event); - -private: - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - - const QByteArray keyToSignal(int key) { - QByteArray keySignal; - if (key >= Qt::Key_0 && key <= Qt::Key_9) { - keySignal = "digit0Pressed"; - keySignal[5] = '0' + (key - Qt::Key_0); - } else { - int i = 0; - while (sigMap[i].key && sigMap[i].key != key) - ++i; - keySignal = sigMap[i].sig; - } - return keySignal; - } - - struct SigMap { - int key; - const char *sig; - }; - - static const SigMap sigMap[]; -}; - const QmlGraphicsKeysAttached::SigMap QmlGraphicsKeysAttached::sigMap[] = { { Qt::Key_Left, "leftPressed" }, { Qt::Key_Right, "rightPressed" }, @@ -1538,12 +1336,8 @@ void QmlGraphicsItem::setParentItem(QmlGraphicsItem *parent) QmlGraphicsItem *oldParent = parentItem(); if (parent == oldParent || !parent) return; - Q_D(QmlGraphicsItem); QObject::setParent(parent); - d->setParentItemHelper(parent, /*newParentVariant=*/0, /*thisPointerVariant=*/0); - if (oldParent) - emit oldParent->childrenChanged(); - emit parentChanged(); + QGraphicsObject::setParentItem(parent); } /*! @@ -1846,7 +1640,10 @@ bool QmlGraphicsItem::clip() const void QmlGraphicsItem::setClip(bool c) { + if (clip() == c) + return; setFlag(ItemClipsChildrenToShape, c); + emit clipChanged(); } /*! @@ -2276,10 +2073,6 @@ void QmlGraphicsItem::setBaselineOffset(qreal offset) color: "blue" width: 100; height: 100 Rectangle { - color: "green" - width: 25; height: 25 - } - Rectangle { color: "red" x: 25; y: 25; width: 50; height: 50 rotation: 30 @@ -2838,6 +2631,7 @@ void QmlGraphicsItem::setSmooth(bool smooth) if (d->smooth == smooth) return; d->smooth = smooth; + emit smoothChanged(); update(); } @@ -3090,14 +2884,6 @@ int QmlGraphicsItemPrivate::restart(QTime &t) return n; } -#include <qmlgraphicsitem.moc> -#include <moc_qmlgraphicsitem.cpp> - QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlGraphicsKeysAttached) -QML_DECLARE_TYPEINFO(QmlGraphicsKeysAttached, QML_HAS_ATTACHED_PROPERTIES) -QML_DEFINE_TYPE(Qt,4,6,Keys,QmlGraphicsKeysAttached) -QML_DECLARE_TYPE(QmlGraphicsKeyNavigationAttached) -QML_DECLARE_TYPEINFO(QmlGraphicsKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES) -QML_DEFINE_TYPE(Qt,4,6,KeyNavigation,QmlGraphicsKeyNavigationAttached) +#include <moc_qmlgraphicsitem.cpp> diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h index 606cc56..e1cf035 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem.h @@ -50,6 +50,7 @@ #include <QtGui/qgraphicsitem.h> #include <QtGui/qgraphicstransform.h> #include <QtGui/qfont.h> +#include <QtGui/qaction.h> QT_BEGIN_HEADER @@ -87,12 +88,12 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlP Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline CONSTANT FINAL) Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) - Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY + Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged) Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL) Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged) - Q_PROPERTY(bool smooth READ smooth WRITE setSmooth) + Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect) Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") @@ -177,6 +178,8 @@ Q_SIGNALS: void wantsFocusChanged(); void parentChanged(); void transformOriginChanged(TransformOrigin); + void smoothChanged(); + void clipChanged(); protected: bool isComponentComplete() const; @@ -233,6 +236,7 @@ QML_DECLARE_TYPE(QmlGraphicsItem) QML_DECLARE_TYPE(QGraphicsTransform) QML_DECLARE_TYPE(QGraphicsScale) QML_DECLARE_TYPE(QGraphicsRotation) +QML_DECLARE_TYPE(QAction) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h index 5ef07e3..7662a3b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h @@ -280,8 +280,209 @@ public: static int restart(QTime &); }; +/* + Key filters can be installed on a QmlGraphicsItem, but not removed. Currently they + are only used by attached objects (which are only destroyed on Item + destruction), so this isn't a problem. If in future this becomes any form + of public API, they will have to support removal too. +*/ +class QmlGraphicsItemKeyFilter +{ +public: + QmlGraphicsItemKeyFilter(QmlGraphicsItem * = 0); + virtual ~QmlGraphicsItemKeyFilter(); + + virtual void keyPressed(QKeyEvent *event); + virtual void keyReleased(QKeyEvent *event); + virtual void inputMethodEvent(QInputMethodEvent *event); + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + virtual void componentComplete(); + +private: + QmlGraphicsItemKeyFilter *m_next; +}; + +class QmlGraphicsKeyNavigationAttachedPrivate : public QObjectPrivate +{ +public: + QmlGraphicsKeyNavigationAttachedPrivate() + : QObjectPrivate(), left(0), right(0), up(0), down(0) {} + + QmlGraphicsItem *left; + QmlGraphicsItem *right; + QmlGraphicsItem *up; + QmlGraphicsItem *down; +}; + +class QmlGraphicsKeyNavigationAttached : public QObject, public QmlGraphicsItemKeyFilter +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlGraphicsKeyNavigationAttached) + + Q_PROPERTY(QmlGraphicsItem *left READ left WRITE setLeft NOTIFY changed) + Q_PROPERTY(QmlGraphicsItem *right READ right WRITE setRight NOTIFY changed) + Q_PROPERTY(QmlGraphicsItem *up READ up WRITE setUp NOTIFY changed) + Q_PROPERTY(QmlGraphicsItem *down READ down WRITE setDown NOTIFY changed) +public: + QmlGraphicsKeyNavigationAttached(QObject * = 0); + + QmlGraphicsItem *left() const; + void setLeft(QmlGraphicsItem *); + QmlGraphicsItem *right() const; + void setRight(QmlGraphicsItem *); + QmlGraphicsItem *up() const; + void setUp(QmlGraphicsItem *); + QmlGraphicsItem *down() const; + void setDown(QmlGraphicsItem *); + + static QmlGraphicsKeyNavigationAttached *qmlAttachedProperties(QObject *); + +Q_SIGNALS: + void changed(); + +private: + virtual void keyPressed(QKeyEvent *event); + virtual void keyReleased(QKeyEvent *event); +}; + +class QmlGraphicsKeysAttachedPrivate : public QObjectPrivate +{ +public: + QmlGraphicsKeysAttachedPrivate() + : QObjectPrivate(), inPress(false), inRelease(false) + , inIM(false), enabled(true), imeItem(0), item(0) + {} + + bool isConnected(const char *signalName); + + QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const + { + QGraphicsItem *fp; + while ((fp = item->focusProxy())) + item = fp; + return item; + } + + //loop detection + bool inPress:1; + bool inRelease:1; + bool inIM:1; + + bool enabled : 1; + + QGraphicsItem *imeItem; + QList<QmlGraphicsItem *> targets; + QmlGraphicsItem *item; +}; + +class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached) + + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(QList<QmlGraphicsItem *> *forwardTo READ forwardTo) + +public: + QmlGraphicsKeysAttached(QObject *parent=0); + ~QmlGraphicsKeysAttached(); + + bool enabled() const { Q_D(const QmlGraphicsKeysAttached); return d->enabled; } + void setEnabled(bool enabled) { + Q_D(QmlGraphicsKeysAttached); + if (enabled != d->enabled) { + d->enabled = enabled; + emit enabledChanged(); + } + } + + QList<QmlGraphicsItem *> *forwardTo() { + Q_D(QmlGraphicsKeysAttached); + return &d->targets; + } + + virtual void componentComplete(); + + static QmlGraphicsKeysAttached *qmlAttachedProperties(QObject *); + +Q_SIGNALS: + void enabledChanged(); + void pressed(QmlGraphicsKeyEvent *event); + void released(QmlGraphicsKeyEvent *event); + void digit0Pressed(QmlGraphicsKeyEvent *event); + void digit1Pressed(QmlGraphicsKeyEvent *event); + void digit2Pressed(QmlGraphicsKeyEvent *event); + void digit3Pressed(QmlGraphicsKeyEvent *event); + void digit4Pressed(QmlGraphicsKeyEvent *event); + void digit5Pressed(QmlGraphicsKeyEvent *event); + void digit6Pressed(QmlGraphicsKeyEvent *event); + void digit7Pressed(QmlGraphicsKeyEvent *event); + void digit8Pressed(QmlGraphicsKeyEvent *event); + void digit9Pressed(QmlGraphicsKeyEvent *event); + + void leftPressed(QmlGraphicsKeyEvent *event); + void rightPressed(QmlGraphicsKeyEvent *event); + void upPressed(QmlGraphicsKeyEvent *event); + void downPressed(QmlGraphicsKeyEvent *event); + + void asteriskPressed(QmlGraphicsKeyEvent *event); + void numberSignPressed(QmlGraphicsKeyEvent *event); + void escapePressed(QmlGraphicsKeyEvent *event); + void returnPressed(QmlGraphicsKeyEvent *event); + void enterPressed(QmlGraphicsKeyEvent *event); + void deletePressed(QmlGraphicsKeyEvent *event); + void spacePressed(QmlGraphicsKeyEvent *event); + void backPressed(QmlGraphicsKeyEvent *event); + void cancelPressed(QmlGraphicsKeyEvent *event); + void selectPressed(QmlGraphicsKeyEvent *event); + void yesPressed(QmlGraphicsKeyEvent *event); + void noPressed(QmlGraphicsKeyEvent *event); + void context1Pressed(QmlGraphicsKeyEvent *event); + void context2Pressed(QmlGraphicsKeyEvent *event); + void context3Pressed(QmlGraphicsKeyEvent *event); + void context4Pressed(QmlGraphicsKeyEvent *event); + void callPressed(QmlGraphicsKeyEvent *event); + void hangupPressed(QmlGraphicsKeyEvent *event); + void flipPressed(QmlGraphicsKeyEvent *event); + void menuPressed(QmlGraphicsKeyEvent *event); + void volumeUpPressed(QmlGraphicsKeyEvent *event); + void volumeDownPressed(QmlGraphicsKeyEvent *event); + +private: + virtual void keyPressed(QKeyEvent *event); + virtual void keyReleased(QKeyEvent *event); + virtual void inputMethodEvent(QInputMethodEvent *); + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + + const QByteArray keyToSignal(int key) { + QByteArray keySignal; + if (key >= Qt::Key_0 && key <= Qt::Key_9) { + keySignal = "digit0Pressed"; + keySignal[5] = '0' + (key - Qt::Key_0); + } else { + int i = 0; + while (sigMap[i].key && sigMap[i].key != key) + ++i; + keySignal = sigMap[i].sig; + } + return keySignal; + } + + struct SigMap { + int key; + const char *sig; + }; + + static const SigMap sigMap[]; +}; + Q_DECLARE_OPERATORS_FOR_FLAGS(QmlGraphicsItemPrivate::ChangeTypes); QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlGraphicsKeysAttached) +QML_DECLARE_TYPEINFO(QmlGraphicsKeysAttached, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QmlGraphicsKeyNavigationAttached) +QML_DECLARE_TYPEINFO(QmlGraphicsKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES) + #endif // QMLGRAPHICSITEM_P_H diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp new file mode 100644 index 0000000..66d62f0 --- /dev/null +++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlgraphicsitemsmodule_p.h" + +#include <QtGui/qaction.h> +#include <QtGui/qvalidator.h> +#include <QtGui/qgraphicseffect.h> + +#include "qmlgraphicsevents_p_p.h" +#include "qmlgraphicseffects_p.h" +#include "qmlgraphicsscalegrid_p_p.h" +#include "qmlgraphicsanimatedimage_p.h" +#include "qmlgraphicsborderimage_p.h" +#include "qmlgraphicspositioners_p.h" +#include "qmlgraphicsmouseregion_p.h" +#include "qmlgraphicsflickable_p.h" +#include "qmlgraphicsflickable_p_p.h" +#include "qmlgraphicsflipable_p.h" +#include "qmlgraphicsfocuspanel_p.h" +#include "qmlgraphicsfocusscope_p.h" +#include "qmlgraphicsgraphicsobjectcontainer_p.h" +#include "qmlgraphicsgridview_p.h" +#include "qmlgraphicsimage_p.h" +#include "qmlgraphicsitem_p.h" +#include "qmlgraphicslayoutitem_p.h" +#include "qmlgraphicslistview_p.h" +#include "qmlgraphicsloader_p.h" +#include "qmlgraphicsmouseregion_p.h" +#include "qmlgraphicsparticles_p.h" +#include "qmlgraphicspath_p.h" +#include "qmlgraphicspathview_p.h" +#include "qmlgraphicsrectangle_p.h" +#include "qmlgraphicsrepeater_p.h" +#include "qmlgraphicstext_p.h" +#include "qmlgraphicstextedit_p.h" +#include "qmlgraphicstextinput_p.h" +#include "qmlgraphicsvisualitemmodel_p.h" +#ifdef QT_WEBKIT_LIB +#include "qmlgraphicswebview_p.h" +#include "qmlgraphicswebview_p_p.h" +#endif +#include "qmlgraphicsanchors_p.h" + +#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \ + qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #TYPE, #CLASS) + +#define QML_REGISTER_NOCREATE_TYPE(CLASS) \ + qmlRegisterType<CLASS>(#CLASS) + +void QmlGraphicsItemModule::defineModule() +{ + QML_REGISTER_TYPE(Qt,4,6,AnimatedImage,QmlGraphicsAnimatedImage); + QML_REGISTER_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect); + QML_REGISTER_TYPE(Qt,4,6,BorderImage,QmlGraphicsBorderImage); + QML_REGISTER_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect); + QML_REGISTER_TYPE(Qt,4,6,Column,QmlGraphicsColumn); + QML_REGISTER_TYPE(Qt,4,6,Drag,QmlGraphicsDrag); + QML_REGISTER_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect); + QML_REGISTER_TYPE(Qt,4,6,Flickable,QmlGraphicsFlickable); + QML_REGISTER_TYPE(Qt,4,6,Flipable,QmlGraphicsFlipable); + QML_REGISTER_TYPE(Qt,4,6,Flow,QmlGraphicsFlow); + QML_REGISTER_TYPE(Qt,4,6,FocusPanel,QmlGraphicsFocusPanel); + QML_REGISTER_TYPE(Qt,4,6,FocusScope,QmlGraphicsFocusScope); + QML_REGISTER_TYPE(Qt,4,6,Gradient,QmlGraphicsGradient); + QML_REGISTER_TYPE(Qt,4,6,GradientStop,QmlGraphicsGradientStop); + QML_REGISTER_TYPE(Qt,4,6,GraphicsObjectContainer,QmlGraphicsGraphicsObjectContainer); + QML_REGISTER_TYPE(Qt,4,6,Grid,QmlGraphicsGrid); + QML_REGISTER_TYPE(Qt,4,6,GridView,QmlGraphicsGridView); + QML_REGISTER_TYPE(Qt,4,6,Image,QmlGraphicsImage); + QML_REGISTER_TYPE(Qt,4,6,Item,QmlGraphicsItem); + QML_REGISTER_TYPE(Qt,4,6,KeyNavigation,QmlGraphicsKeyNavigationAttached); + QML_REGISTER_TYPE(Qt,4,6,Keys,QmlGraphicsKeysAttached); + QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QmlGraphicsLayoutItem); + QML_REGISTER_TYPE(Qt,4,6,ListView,QmlGraphicsListView); + QML_REGISTER_TYPE(Qt,4,6,Loader,QmlGraphicsLoader); + QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseRegion); + QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect); + QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QmlGraphicsParticleMotion); + QML_REGISTER_TYPE(Qt,4,6,ParticleMotionGravity,QmlGraphicsParticleMotionGravity); + QML_REGISTER_TYPE(Qt,4,6,ParticleMotionLinear,QmlGraphicsParticleMotionLinear); + QML_REGISTER_TYPE(Qt,4,6,ParticleMotionWander,QmlGraphicsParticleMotionWander); + QML_REGISTER_TYPE(Qt,4,6,Particles,QmlGraphicsParticles); + QML_REGISTER_TYPE(Qt,4,6,Path,QmlGraphicsPath); + QML_REGISTER_TYPE(Qt,4,6,PathAttribute,QmlGraphicsPathAttribute); + QML_REGISTER_TYPE(Qt,4,6,PathCubic,QmlGraphicsPathCubic); + QML_REGISTER_TYPE(Qt,4,6,PathLine,QmlGraphicsPathLine); + QML_REGISTER_TYPE(Qt,4,6,PathPercent,QmlGraphicsPathPercent); + QML_REGISTER_TYPE(Qt,4,6,PathQuad,QmlGraphicsPathQuad); + QML_REGISTER_TYPE(Qt,4,6,PathView,QmlGraphicsPathView); + QML_REGISTER_TYPE(Qt,4,6,Pen,QmlGraphicsPen); + QML_REGISTER_TYPE(Qt,4,6,QIntValidator,QIntValidator); +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) + QML_REGISTER_TYPE(Qt,4,7,QDoubleValidator,QDoubleValidator); + QML_REGISTER_TYPE(Qt,4,7,QRegExpValidator,QRegExpValidator); +#endif + QML_REGISTER_TYPE(Qt,4,6,Rectangle,QmlGraphicsRectangle); + QML_REGISTER_TYPE(Qt,4,6,Repeater,QmlGraphicsRepeater); + QML_REGISTER_TYPE(Qt,4,6,Rotation,QGraphicsRotation); + QML_REGISTER_TYPE(Qt,4,6,Row,QmlGraphicsRow); + QML_REGISTER_TYPE(Qt,4,6,Scale,QGraphicsScale); + QML_REGISTER_TYPE(Qt,4,6,Text,QmlGraphicsText); + QML_REGISTER_TYPE(Qt,4,6,TextEdit,QmlGraphicsTextEdit); + QML_REGISTER_TYPE(Qt,4,6,TextInput,QmlGraphicsTextInput); + QML_REGISTER_TYPE(Qt,4,6,ViewSection,QmlGraphicsViewSection); + QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QmlGraphicsFlickableVisibleArea); + QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QmlGraphicsVisualDataModel); + QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QmlGraphicsVisualItemModel); +#ifdef QT_WEBKIT_LIB + QML_REGISTER_TYPE(Qt,4,6,WebView,QmlGraphicsWebView); +#endif + + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsAnchors); + QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsKeyEvent); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsMouseEvent); + QML_REGISTER_NOCREATE_TYPE(QGraphicsObject); + QML_REGISTER_NOCREATE_TYPE(QGraphicsTransform); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsPathElement); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsCurve); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsScaleGrid); + QML_REGISTER_NOCREATE_TYPE(QValidator); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsVisualModel); + QML_REGISTER_NOCREATE_TYPE(QAction); +#ifdef QT_WEBKIT_LIB + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsWebSettings); +#endif +} diff --git a/tools/qmldebugger/standalone/canvasframerate.h b/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h index b31d607..76fea7e 100644 --- a/tools/qmldebugger/standalone/canvasframerate.h +++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt QML Debugger of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,54 +38,26 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef CANVASFRAMERATE_H -#define CANVASFRAMERATE_H -#include <QtCore/qpointer.h> -#include <QtGui/qwidget.h> +#ifndef QMLGRAPHICSITEMMODULE_H +#define QMLGRAPHICSITEMMODULE_H -#include <private/qmldebugclient_p.h> +#include <qml.h> -QT_BEGIN_NAMESPACE +QT_BEGIN_HEADER -class QTabWidget; -class QSlider; -class QGroupBox; -class QLabel; -class QSpinBox; -class QPushButton; +QT_BEGIN_NAMESPACE -class CanvasFrameRatePlugin; +QT_MODULE(Declarative) -class CanvasFrameRate : public QWidget +class QmlGraphicsItemModule { - Q_OBJECT public: - CanvasFrameRate(QWidget *parent = 0); - - void reset(QmlDebugConnection *conn); - - void setSizeHint(const QSize &); - virtual QSize sizeHint() const; - -private slots: - void clearGraph(); - void newTab(); - void enabledToggled(bool); - void connectionStateChanged(QAbstractSocket::SocketState state); - -private: - void handleConnected(QmlDebugConnection *conn); - - QGroupBox *m_group; - QTabWidget *m_tabs; - QSpinBox *m_res; - QPushButton *m_clearButton; - CanvasFrameRatePlugin *m_plugin; - QSize m_sizeHint; + static void defineModule(); }; QT_END_NAMESPACE -#endif // CANVASFRAMERATE_H +QT_END_HEADER +#endif // QMLGRAPHICSITEMMODULE_H diff --git a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp index b054ced..961065e 100644 --- a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp @@ -47,11 +47,16 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,LayoutItem,QmlGraphicsLayoutItem) - /*! \qmlclass LayoutItem QmlGraphicsLayoutItem \brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout. + + LayoutItem is a variant of Item with a couple of additional properties. These properties provide the size hints + needed for items to work in conjunction with Qt Layouts. The Qt Layout will resize the LayoutItem as appropriate, + taking its size hints into account, and you can propagate this to the other elements in your UI via anchors and bindings. + + This is a QGraphicsLayoutItem subclass, and the properties merely expose the QGraphicsLayoutItem functionality to QML. + See the QGraphicsLayoutItem documentation for further details. */ /*! diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index 1e2698c..c646d49 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -85,72 +85,6 @@ QString QmlGraphicsViewSection::sectionString(const QString &value) return value; } -class QmlGraphicsListViewAttached : public QObject -{ - Q_OBJECT -public: - QmlGraphicsListViewAttached(QObject *parent) - : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} - ~QmlGraphicsListViewAttached() {} - - Q_PROPERTY(QmlGraphicsListView *view READ view CONSTANT) - QmlGraphicsListView *view() { return m_view; } - - Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) - bool isCurrentItem() const { return m_isCurrent; } - void setIsCurrentItem(bool c) { - if (m_isCurrent != c) { - m_isCurrent = c; - emit currentItemChanged(); - } - } - - Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged) - QString prevSection() const { return m_prevSection; } - void setPrevSection(const QString §) { - if (m_prevSection != sect) { - m_prevSection = sect; - emit prevSectionChanged(); - } - } - - Q_PROPERTY(QString section READ section NOTIFY sectionChanged) - QString section() const { return m_section; } - void setSection(const QString §) { - if (m_section != sect) { - m_section = sect; - emit sectionChanged(); - } - } - - Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) - bool delayRemove() const { return m_delayRemove; } - void setDelayRemove(bool delay) { - if (m_delayRemove != delay) { - m_delayRemove = delay; - emit delayRemoveChanged(); - } - } - - void emitAdd() { emit add(); } - void emitRemove() { emit remove(); } - -Q_SIGNALS: - void currentItemChanged(); - void sectionChanged(); - void prevSectionChanged(); - void delayRemoveChanged(); - void add(); - void remove(); - -public: - QmlGraphicsListView *m_view; - bool m_isCurrent; - mutable QString m_section; - QString m_prevSection; - bool m_delayRemove; -}; - //---------------------------------------------------------------------------- class FxListItem @@ -1135,9 +1069,13 @@ void QmlGraphicsListViewPrivate::fixupY() fixupDuration = moveReason == Mouse ? fixupDuration : 0; if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) { - if (currentItem && highlight && currentItem->position() != highlight->position()) { + if (currentItem && currentItem->position() - position() != highlightRangeStart) { + qreal pos = currentItem->position() - highlightRangeStart; timeline.reset(_moveY); - timeline.move(_moveY, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + if (fixupDuration) + timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + else + _moveY.setValue(-pos); vTime = timeline.time(); } } else if (snapMode != QmlGraphicsListView::NoSnap) { @@ -1146,7 +1084,10 @@ void QmlGraphicsListViewPrivate::fixupY() qreal dist = qAbs(_moveY + pos); if (dist > 0) { timeline.reset(_moveY); - timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + if (fixupDuration) + timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + else + _moveY.setValue(-pos); vTime = timeline.time(); } } @@ -1168,9 +1109,13 @@ void QmlGraphicsListViewPrivate::fixupX() fixupDuration = moveReason == Mouse ? fixupDuration : 0; if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) { - if (currentItem && highlight && currentItem->position() != highlight->position()) { + if (currentItem && currentItem->position() - position() != highlightRangeStart) { + qreal pos = currentItem->position() - highlightRangeStart; timeline.reset(_moveX); - timeline.move(_moveX, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + if (fixupDuration) + timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + else + _moveX.setValue(-pos); vTime = timeline.time(); } } else if (snapMode != QmlGraphicsListView::NoSnap) { @@ -1179,7 +1124,10 @@ void QmlGraphicsListViewPrivate::fixupX() qreal dist = qAbs(_moveX + pos); if (dist > 0) { timeline.reset(_moveX); - timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + if (fixupDuration) + timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + else + _moveX.setValue(-pos); vTime = timeline.time(); } } @@ -2327,6 +2275,7 @@ void QmlGraphicsListView::positionViewAtIndex(int index) for (int i = 0; i < oldVisible.count(); ++i) d->releaseItem(oldVisible.at(i)); } + d->fixupPosition(); } @@ -2699,9 +2648,32 @@ void QmlGraphicsListView::itemsMoved(int from, int to, int count) ++endIndex; } + // update visibleIndex + for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { + if ((*it)->index != -1) { + d->visibleIndex = (*it)->index; + break; + } + } + + // Fix current index + if (d->currentIndex >= 0 && d->currentItem) { + int oldCurrent = d->currentIndex; + d->currentIndex = d->model->indexOf(d->currentItem->item, this); + if (oldCurrent != d->currentIndex) { + d->currentItem->index = d->currentIndex; + emit currentIndexChanged(); + } + } + // Whatever moved items remain are no longer visible items. - while (moved.count()) - d->releaseItem(moved.take(moved.begin().key())); + while (moved.count()) { + int idx = moved.begin().key(); + FxListItem *item = moved.take(idx); + if (item->item == d->currentItem->item) + item->setPosition(d->positionAt(idx)); + d->releaseItem(item); + } // Ensure we don't cause an ugly list scroll. d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy); @@ -2740,9 +2712,4 @@ QmlGraphicsListViewAttached *QmlGraphicsListView::qmlAttachedProperties(QObject return new QmlGraphicsListViewAttached(obj); } -QML_DEFINE_TYPE(Qt,4,6,ListView,QmlGraphicsListView) -QML_DEFINE_TYPE(Qt,4,6,ViewSection,QmlGraphicsViewSection) - QT_END_NAMESPACE - -#include <qmlgraphicslistview.moc> diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h index 5a8ac9c..c5b4aab 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicslistview_p.h @@ -227,6 +227,73 @@ private Q_SLOTS: void animStopped(); }; +class QmlGraphicsListViewAttached : public QObject +{ + Q_OBJECT +public: + QmlGraphicsListViewAttached(QObject *parent) + : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} + ~QmlGraphicsListViewAttached() {} + + Q_PROPERTY(QmlGraphicsListView *view READ view CONSTANT) + QmlGraphicsListView *view() { return m_view; } + + Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) + bool isCurrentItem() const { return m_isCurrent; } + void setIsCurrentItem(bool c) { + if (m_isCurrent != c) { + m_isCurrent = c; + emit currentItemChanged(); + } + } + + Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged) + QString prevSection() const { return m_prevSection; } + void setPrevSection(const QString §) { + if (m_prevSection != sect) { + m_prevSection = sect; + emit prevSectionChanged(); + } + } + + Q_PROPERTY(QString section READ section NOTIFY sectionChanged) + QString section() const { return m_section; } + void setSection(const QString §) { + if (m_section != sect) { + m_section = sect; + emit sectionChanged(); + } + } + + Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) + bool delayRemove() const { return m_delayRemove; } + void setDelayRemove(bool delay) { + if (m_delayRemove != delay) { + m_delayRemove = delay; + emit delayRemoveChanged(); + } + } + + void emitAdd() { emit add(); } + void emitRemove() { emit remove(); } + +Q_SIGNALS: + void currentItemChanged(); + void sectionChanged(); + void prevSectionChanged(); + void delayRemoveChanged(); + void add(); + void remove(); + +public: + QmlGraphicsListView *m_view; + bool m_isCurrent; + mutable QString m_section; + QString m_prevSection; + bool m_delayRemove; +}; + + QT_END_NAMESPACE QML_DECLARE_TYPEINFO(QmlGraphicsListView, QML_HAS_ATTACHED_PROPERTIES) diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp index 44932a2..159ddc3 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp @@ -108,8 +108,6 @@ void QmlGraphicsLoaderPrivate::initResize() _q_updateSize(); } -QML_DEFINE_TYPE(Qt,4,6,Loader,QmlGraphicsLoader) - /*! \qmlclass Loader QmlGraphicsLoader \inherits Item @@ -400,6 +398,7 @@ void QmlGraphicsLoader::setResizeMode(ResizeMode mode) } d->resizeMode = mode; + emit resizeModeChanged(); d->initResize(); } diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p.h index bfc011d..0ab67ac 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsloader_p.h @@ -59,7 +59,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsLoader : public QmlGraphicsItem Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(QmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent NOTIFY sourceChanged) - Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) + Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode NOTIFY resizeModeChanged) Q_PROPERTY(QGraphicsObject *item READ item NOTIFY itemChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) @@ -89,6 +89,8 @@ Q_SIGNALS: void sourceChanged(); void statusChanged(); void progressChanged(); + void resizeModeChanged(); + protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); QVariant itemChange(GraphicsItemChange change, const QVariant &value); diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp index 1f8435e..3470d37 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp @@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE static const int PressAndHoldDelay = 800; -QML_DEFINE_TYPE(Qt,4,6,Drag,QmlGraphicsDrag) QmlGraphicsDrag::QmlGraphicsDrag(QObject *parent) : QObject(parent), _target(0), _axis(XandYAxis), _xmin(0), _xmax(0), _ymin(0), _ymax(0) { @@ -66,7 +65,10 @@ QmlGraphicsItem *QmlGraphicsDrag::target() const void QmlGraphicsDrag::setTarget(QmlGraphicsItem *t) { + if (_target == t) + return; _target = t; + emit targetChanged(); } QmlGraphicsDrag::Axis QmlGraphicsDrag::axis() const @@ -76,7 +78,10 @@ QmlGraphicsDrag::Axis QmlGraphicsDrag::axis() const void QmlGraphicsDrag::setAxis(QmlGraphicsDrag::Axis a) { + if (_axis == a) + return; _axis = a; + emit axisChanged(); } qreal QmlGraphicsDrag::xmin() const @@ -86,7 +91,10 @@ qreal QmlGraphicsDrag::xmin() const void QmlGraphicsDrag::setXmin(qreal m) { + if (_xmin == m) + return; _xmin = m; + emit minimumXChanged(); } qreal QmlGraphicsDrag::xmax() const @@ -96,7 +104,10 @@ qreal QmlGraphicsDrag::xmax() const void QmlGraphicsDrag::setXmax(qreal m) { + if (_xmax == m) + return; _xmax = m; + emit maximumXChanged(); } qreal QmlGraphicsDrag::ymin() const @@ -106,7 +117,10 @@ qreal QmlGraphicsDrag::ymin() const void QmlGraphicsDrag::setYmin(qreal m) { + if (_ymin == m) + return; _ymin = m; + emit minimumYChanged(); } qreal QmlGraphicsDrag::ymax() const @@ -116,7 +130,10 @@ qreal QmlGraphicsDrag::ymax() const void QmlGraphicsDrag::setYmax(qreal m) { + if (_ymax == m) + return; _ymax = m; + emit maximumYChanged(); } QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() @@ -155,12 +172,24 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() \qmlsignal MouseRegion::onEntered() This handler is called when the mouse enters the mouse region. + + By default the onEntered handler is only called while a button is + pressed. Setting hoverEnabled to true enables handling of + onExited when no mouse button is pressed. + + \sa hoverEnabled */ /*! \qmlsignal MouseRegion::onExited() This handler is called when the mouse exists the mouse region. + + By default the onExited handler is only called while a button is + pressed. Setting hoverEnabled to true enables handling of + onExited when no mouse button is pressed. + + \sa hoverEnabled */ /*! @@ -172,6 +201,10 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() position, and any buttons currently pressed. The \e accepted property of the MouseEvent parameter is ignored in this handler. + + By default the onPositionChanged handler is only called while a button is + pressed. Setting hoverEnabled to true enables handling of + onPositionChanged when no mouse button is pressed. */ /*! @@ -231,8 +264,6 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() The \e accepted property of the MouseEvent parameter is ignored in this handler. */ -QML_DEFINE_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseRegion) - /*! \internal \class QmlGraphicsMouseRegion diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h b/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h index e01831e..cccf90c 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h @@ -55,12 +55,12 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsDrag : public QObject Q_OBJECT Q_ENUMS(Axis) - Q_PROPERTY(QmlGraphicsItem *target READ target WRITE setTarget) - Q_PROPERTY(Axis axis READ axis WRITE setAxis) - Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin) - Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax) - Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin) - Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax) + Q_PROPERTY(QmlGraphicsItem *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged) + Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged) + Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged) + Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged) + Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged) //### consider drag and drop public: @@ -83,6 +83,14 @@ public: qreal ymax() const; void setYmax(qreal); +Q_SIGNALS: + void targetChanged(); + void axisChanged(); + void minimumXChanged(); + void maximumXChanged(); + void minimumYChanged(); + void maximumYChanged(); + private: QmlGraphicsItem *_target; Axis _axis; @@ -107,7 +115,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsMouseRegion : public QmlGraphicsItem Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged) Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged) Q_PROPERTY(bool hoverEnabled READ acceptHoverEvents WRITE setAcceptHoverEvents) - Q_PROPERTY(QmlGraphicsDrag *drag READ drag) //### add flicking to QmlGraphicsDrag or add a QmlGraphicsFlick ??? + Q_PROPERTY(QmlGraphicsDrag *drag READ drag CONSTANT) //### add flicking to QmlGraphicsDrag or add a QmlGraphicsFlick ??? public: QmlGraphicsMouseRegion(QmlGraphicsItem *parent=0); diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp index 95d4844..08fce74 100644 --- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp @@ -108,8 +108,6 @@ public: //--------------------------------------------------------------------------- -QML_DEFINE_TYPE(Qt,4,6,ParticleMotion,QmlGraphicsParticleMotion) - /*! \class QmlGraphicsParticleMotion \ingroup group_effects @@ -169,8 +167,6 @@ void QmlGraphicsParticleMotion::destroy(QmlGraphicsParticle &particle) \brief The QmlGraphicsParticleMotionLinear class moves the particles linearly. */ -QML_DEFINE_TYPE(Qt,4,6,ParticleMotionLinear,QmlGraphicsParticleMotionLinear) - void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interval) { p.x += interval * p.x_velocity; @@ -191,8 +187,6 @@ void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interv \brief The QmlGraphicsParticleMotionGravity class moves the particles towards a point. */ -QML_DEFINE_TYPE(Qt,4,6,ParticleMotionGravity,QmlGraphicsParticleMotionGravity) - /*! \qmlproperty int ParticleMotionGravity::xattractor \qmlproperty int ParticleMotionGravity::yattractor @@ -293,8 +287,6 @@ Rectangle { This property holds how quickly the paricles will move from side to side. */ -QML_DEFINE_TYPE(Qt,4,6,ParticleMotionWander,QmlGraphicsParticleMotionWander) - void QmlGraphicsParticleMotionWander::advance(QmlGraphicsParticle &p, int interval) { if (!particles) @@ -561,8 +553,6 @@ void QmlGraphicsParticlesPrivate::updateOpacity(QmlGraphicsParticle &p, int age) } } -QML_DEFINE_TYPE(Qt,4,6,Particles,QmlGraphicsParticles) - /*! \qmlclass Particles \brief The Particles object generates and moves particles. @@ -645,7 +635,7 @@ QmlGraphicsParticles::~QmlGraphicsParticles() } /*! - \qmlproperty string Particles::src + \qmlproperty string Particles::source This property holds the URL of the particle image. */ diff --git a/src/declarative/graphicsitems/qmlgraphicspath.cpp b/src/declarative/graphicsitems/qmlgraphicspath.cpp index 6f04b75..7916bd3 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspath.cpp @@ -49,14 +49,6 @@ #include <private/qbezier_p.h> QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Path,QmlGraphicsPath) -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsPathElement) -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsCurve) -QML_DEFINE_TYPE(Qt,4,6,PathAttribute,QmlGraphicsPathAttribute) -QML_DEFINE_TYPE(Qt,4,6,PathPercent,QmlGraphicsPathPercent) -QML_DEFINE_TYPE(Qt,4,6,PathLine,QmlGraphicsPathLine) -QML_DEFINE_TYPE(Qt,4,6,PathQuad,QmlGraphicsPathQuad) -QML_DEFINE_TYPE(Qt,4,6,PathCubic,QmlGraphicsPathCubic) /*! \qmlclass PathElement QmlGraphicsPathElement diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index 4511820..f862555 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -54,9 +54,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,PathView,QmlGraphicsPathView) - - inline qreal qmlMod(qreal x, qreal y) { #ifdef QT_USE_MATH_H_FLOATS diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp index ba26f62..8adf239 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp @@ -288,7 +288,6 @@ void QmlGraphicsBasePositioner::finishApplyTransitions() d->moveActions.clear(); } -QML_DEFINE_TYPE(Qt,4,6,Column,QmlGraphicsColumn) /*! \qmlclass Column QmlGraphicsColumn \brief The Column item lines up its children vertically. @@ -362,7 +361,7 @@ Column { Column { move: Transition { NumberAnimation { - matchProperties: "y" + properties: "y" ease: "easeOutBounce" } } @@ -418,7 +417,6 @@ void QmlGraphicsColumn::doPositioning() } } -QML_DEFINE_TYPE(Qt,4,6,Row,QmlGraphicsRow) /*! \qmlclass Row QmlGraphicsRow \brief The Row item lines up its children horizontally. @@ -472,7 +470,7 @@ Row { id: positioner move: Transition { NumberAnimation { - matchProperties: "x" + properties: "x" ease: "easeOutBounce" } } @@ -523,7 +521,6 @@ void QmlGraphicsRow::doPositioning() } } -QML_DEFINE_TYPE(Qt,4,6,Grid,QmlGraphicsGrid) /*! \qmlclass Grid QmlGraphicsGrid @@ -595,7 +592,7 @@ Grid { Grid { move: Transition { NumberAnimation { - matchProperties: "x,y" + properties: "x,y" ease: "easeOutBounce" } } @@ -711,7 +708,6 @@ void QmlGraphicsGrid::doPositioning() } -QML_DEFINE_TYPE(Qt,4,6,Flow,QmlGraphicsFlow) /*! \qmlclass Flow QmlGraphicsFlow \brief The Flow item lines up its children side by side, wrapping as necessary. @@ -741,7 +737,7 @@ Flow { id: positioner move: Transition { NumberAnimation { - matchProperties: "x,y" + properties: "x,y" ease: "easeOutBounce" } } diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp b/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp index 1fa63e0..f357ed0 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp @@ -46,9 +46,6 @@ #include <QtCore/qmath.h> QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Pen,QmlGraphicsPen) -QML_DEFINE_TYPE(Qt,4,6,GradientStop,QmlGraphicsGradientStop) -QML_DEFINE_TYPE(Qt,4,6,Gradient,QmlGraphicsGradient) /*! \internal @@ -149,7 +146,6 @@ void QmlGraphicsGradient::doUpdate() emit updated(); } -QML_DEFINE_TYPE(Qt,4,6,Rectangle,QmlGraphicsRectangle) /*! \qmlclass Rectangle QmlGraphicsRectangle diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp index 0c27f4c..fc78ef8 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp @@ -60,8 +60,6 @@ QmlGraphicsRepeaterPrivate::~QmlGraphicsRepeaterPrivate() delete model; } -QML_DEFINE_TYPE(Qt,4,6,Repeater,QmlGraphicsRepeater) - /*! \qmlclass Repeater QmlGraphicsRepeater \inherits Item @@ -159,6 +157,9 @@ QVariant QmlGraphicsRepeater::model() const void QmlGraphicsRepeater::setModel(const QVariant &model) { Q_D(QmlGraphicsRepeater); + if (d->dataSource == model) + return; + clear(); if (d->model) { disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); @@ -170,6 +171,7 @@ void QmlGraphicsRepeater::setModel(const QVariant &model) */ } d->dataSource = model; + emit modelChanged(); QObject *object = qvariant_cast<QObject*>(model); QmlGraphicsVisualModel *vim = 0; if (object && (vim = qobject_cast<QmlGraphicsVisualModel *>(object))) { @@ -221,6 +223,10 @@ QmlComponent *QmlGraphicsRepeater::delegate() const void QmlGraphicsRepeater::setDelegate(QmlComponent *delegate) { Q_D(QmlGraphicsRepeater); + if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) + if (delegate == dataModel->delegate()) + return; + if (!d->ownModel) { d->model = new QmlGraphicsVisualDataModel(qmlContext(this)); d->ownModel = true; @@ -228,6 +234,7 @@ void QmlGraphicsRepeater::setDelegate(QmlComponent *delegate) if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) { dataModel->setDelegate(delegate); regenerate(); + emit delegateChanged(); } } diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h b/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h index f7a6b09..2324916 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h @@ -55,8 +55,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsRepeater : public QmlGraphicsItem { Q_OBJECT - Q_PROPERTY(QVariant model READ model WRITE setModel) - Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) + Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(int count READ count NOTIFY countChanged) Q_CLASSINFO("DefaultProperty", "delegate") @@ -73,8 +73,9 @@ public: int count() const; Q_SIGNALS: + void modelChanged(); + void delegateChanged(); void countChanged(); - private: void clear(); void regenerate(); diff --git a/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp b/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp index 58d6ab8..1956939 100644 --- a/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp @@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE \class QmlGraphicsScaleGrid \brief The QmlGraphicsScaleGrid class allows you to specify a 3x3 grid to use in scaling an image. */ -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsScaleGrid) QmlGraphicsScaleGrid::QmlGraphicsScaleGrid(QObject *parent) : QObject(parent), _left(0), _top(0), _right(0), _bottom(0) { diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp index e9e5924..ab2f9a3 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp @@ -55,7 +55,6 @@ #include <qmath.h> QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Text,QmlGraphicsText) /*! \qmlclass Text QmlGraphicsText diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp index e8cde10..3dadbe0 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp @@ -56,7 +56,6 @@ #include <private/qtextcontrol_p.h> QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,TextEdit,QmlGraphicsTextEdit) /*! \qmlclass TextEdit QmlGraphicsTextEdit diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp index a7b25c5..6b4407f 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp @@ -51,12 +51,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,TextInput,QmlGraphicsTextInput); -QML_DEFINE_NOCREATE_TYPE(QValidator); -QML_DEFINE_TYPE(Qt,4,6,QIntValidator,QIntValidator); -QML_DEFINE_TYPE(Qt,4,6,QDoubleValidator,QDoubleValidator); -QML_DEFINE_TYPE(Qt,4,6,QRegExpValidator,QRegExpValidator); - /*! \qmlclass TextInput QmlGraphicsTextInput The TextInput item allows you to add an editable line of text to a scene. @@ -652,10 +646,12 @@ void QmlGraphicsTextInput::focusChanged(bool hasFocus) void QmlGraphicsTextInput::keyPressEvent(QKeyEvent* ev) { Q_D(QmlGraphicsTextInput); - if((d->control->cursor() == 0 && ev->key() == Qt::Key_Left) + if(((d->control->cursor() == 0 && ev->key() == Qt::Key_Left) || (d->control->cursor() == d->control->text().length() - && ev->key() == Qt::Key_Right)){ + && ev->key() == Qt::Key_Right)) + && (d->lastSelectionStart == d->lastSelectionEnd)){ //ignore when moving off the end + //unless there is a selection, because then moving will do something (deselect) ev->ignore(); }else{ d->control->processKeyEvent(ev); diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h index 794661c..2b37b78 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h @@ -222,8 +222,10 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsTextInput) QML_DECLARE_TYPE(QValidator) QML_DECLARE_TYPE(QIntValidator) +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) QML_DECLARE_TYPE(QDoubleValidator) QML_DECLARE_TYPE(QRegExpValidator) +#endif QT_END_HEADER diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index f9ebef9..4ced2c3 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -62,48 +62,8 @@ #include <private/qobject_p.h> -QML_DECLARE_TYPE(QListModelInterface) - QT_BEGIN_NAMESPACE -class QmlGraphicsVisualItemModelAttached : public QObject -{ - Q_OBJECT - -public: - QmlGraphicsVisualItemModelAttached(QObject *parent) - : QObject(parent), m_index(0) {} - ~QmlGraphicsVisualItemModelAttached() { - attachedProperties.remove(parent()); - } - - Q_PROPERTY(int index READ index NOTIFY indexChanged) - int index() const { return m_index; } - void setIndex(int idx) { - if (m_index != idx) { - m_index = idx; - emit indexChanged(); - } - } - - static QmlGraphicsVisualItemModelAttached *properties(QObject *obj) { - QmlGraphicsVisualItemModelAttached *rv = attachedProperties.value(obj); - if (!rv) { - rv = new QmlGraphicsVisualItemModelAttached(obj); - attachedProperties.insert(obj, rv); - } - return rv; - } - -Q_SIGNALS: - void indexChanged(); - -public: - int m_index; - - static QHash<QObject*, QmlGraphicsVisualItemModelAttached*> attachedProperties; -}; - QHash<QObject*, QmlGraphicsVisualItemModelAttached*> QmlGraphicsVisualItemModelAttached::attachedProperties; @@ -1146,10 +1106,8 @@ void QmlGraphicsVisualDataModel::_q_destroyingPackage(QmlPackage *package) emit destroyingItem(qobject_cast<QmlGraphicsItem*>(package->part(d->m_part))); } -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsVisualModel); -QML_DEFINE_TYPE(Qt,4,6,VisualItemModel,QmlGraphicsVisualItemModel) -QML_DEFINE_TYPE(Qt,4,6,VisualDataModel,QmlGraphicsVisualDataModel) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QListModelInterface) + #include <qmlgraphicsvisualitemmodel.moc> diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h index 3321472..c0ea499 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h @@ -195,6 +195,45 @@ private: Q_DISABLE_COPY(QmlGraphicsVisualDataModel) }; +class QmlGraphicsVisualItemModelAttached : public QObject +{ + Q_OBJECT + +public: + QmlGraphicsVisualItemModelAttached(QObject *parent) + : QObject(parent), m_index(0) {} + ~QmlGraphicsVisualItemModelAttached() { + attachedProperties.remove(parent()); + } + + Q_PROPERTY(int index READ index NOTIFY indexChanged) + int index() const { return m_index; } + void setIndex(int idx) { + if (m_index != idx) { + m_index = idx; + emit indexChanged(); + } + } + + static QmlGraphicsVisualItemModelAttached *properties(QObject *obj) { + QmlGraphicsVisualItemModelAttached *rv = attachedProperties.value(obj); + if (!rv) { + rv = new QmlGraphicsVisualItemModelAttached(obj); + attachedProperties.insert(obj, rv); + } + return rv; + } + +Q_SIGNALS: + void indexChanged(); + +public: + int m_index; + + static QHash<QObject*, QmlGraphicsVisualItemModelAttached*> attachedProperties; +}; + + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsVisualModel) diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index a811506..515f896 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -64,13 +64,9 @@ #include <qlistmodelinterface_p.h> QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,WebView,QmlGraphicsWebView) -QML_DEFINE_NOCREATE_TYPE(QAction) static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsWebSettings) - class QmlGraphicsWebViewPrivate : public QmlGraphicsPaintedItemPrivate { Q_DECLARE_PUBLIC(QmlGraphicsWebView) @@ -461,30 +457,6 @@ QmlList<QObject *> *QmlGraphicsWebView::javaScriptWindowObjects() return &d->windowObjects; } -class QmlGraphicsWebViewAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName) -public: - QmlGraphicsWebViewAttached(QObject *parent) - : QObject(parent) - { - } - - QString windowObjectName() const - { - return m_windowObjectName; - } - - void setWindowObjectName(const QString &n) - { - m_windowObjectName = n; - } - -private: - QString m_windowObjectName; -}; - QmlGraphicsWebViewAttached *QmlGraphicsWebView::qmlAttachedProperties(QObject *o) { return new QmlGraphicsWebViewAttached(o); @@ -1111,7 +1083,8 @@ QmlGraphicsWebView *QmlGraphicsWebView::createWindow(QWebPage::WebWindowType typ if (!webview) { delete item; } else { - item->setParent(d->newWindowParent); + nobj->setParent(d->newWindowParent); + static_cast<QGraphicsObject*>(item)->setParentItem(d->newWindowParent); } } } else { diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index 2162716..1822ddb 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -246,11 +246,35 @@ private: friend class QmlGraphicsWebPage; }; +class QmlGraphicsWebViewAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName) +public: + QmlGraphicsWebViewAttached(QObject *parent) + : QObject(parent) + { + } + + QString windowObjectName() const + { + return m_windowObjectName; + } + + void setWindowObjectName(const QString &n) + { + m_windowObjectName = n; + } + +private: + QString m_windowObjectName; +}; + + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsWebView) QML_DECLARE_TYPEINFO(QmlGraphicsWebView, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QAction) QT_END_HEADER diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index 46eec67..e5e7c59 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -77,6 +77,7 @@ enum { /* TYPEINFO flags */ }; #define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \ +QT_BEGIN_NAMESPACE \ template <> \ class QmlTypeInfo<TYPE > \ { \ @@ -84,7 +85,8 @@ public: \ enum { \ hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \ }; \ -}; +}; \ +QT_END_NAMESPACE QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index cd2fbff..a8df61e 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -50,6 +50,7 @@ SOURCES += \ $$PWD/qmltypenamescriptclass.cpp \ $$PWD/qmllistscriptclass.cpp \ $$PWD/qmlworkerscript.cpp \ + $$PWD/qmlimageprovider.cpp \ $$PWD/qmlnetworkaccessmanagerfactory.cpp HEADERS += \ $$PWD/qmlparser_p.h \ @@ -75,8 +76,8 @@ HEADERS += \ $$PWD/qmlengine_p.h \ $$PWD/qmlexpression_p.h \ $$PWD/qmlprivate.h \ - $$PWD/qmldom.h \ $$PWD/qmldom_p.h \ + $$PWD/qmldom_p_p.h \ $$PWD/qmlrefcount_p.h \ $$PWD/qmlmetatype.h \ $$PWD/qmlengine.h \ @@ -117,6 +118,7 @@ HEADERS += \ $$PWD/qmlworkerscript_p.h \ $$PWD/qmlscriptclass_p.h \ $$PWD/qmlguard_p.h \ + $$PWD/qmlimageprovider.h \ $$PWD/qmlnetworkaccessmanagerfactory.h QT += sql include(parser/parser.pri) diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp index c4be39e..0dbe63b 100644 --- a/src/declarative/qml/qmlbinding.cpp +++ b/src/declarative/qml/qmlbinding.cpp @@ -291,6 +291,12 @@ void QmlAbstractBinding::removeFromObject() } } +void QmlAbstractBinding::clear() +{ + if (m_mePtr) + *m_mePtr = 0; +} + QString QmlAbstractBinding::expression() const { return QLatin1String("<Unknown>"); diff --git a/src/declarative/qml/qmlbinding.h b/src/declarative/qml/qmlbinding.h index 2b09414..151b71c 100644 --- a/src/declarative/qml/qmlbinding.h +++ b/src/declarative/qml/qmlbinding.h @@ -75,6 +75,9 @@ public: void addToObject(QObject *); void removeFromObject(); +protected: + void clear(); + private: friend class QmlDeclarativeData; friend class QmlMetaProperty; diff --git a/src/declarative/qml/qmlcleanup.cpp b/src/declarative/qml/qmlcleanup.cpp index fc01a90..581d4a3 100644 --- a/src/declarative/qml/qmlcleanup.cpp +++ b/src/declarative/qml/qmlcleanup.cpp @@ -43,6 +43,8 @@ #include "qmlengine_p.h" +QT_BEGIN_NAMESPACE + /*! \internal \class QmlCleanup @@ -82,4 +84,4 @@ QmlCleanup::~QmlCleanup() prev = 0; next = 0; } - +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcompiledbindings.cpp b/src/declarative/qml/qmlcompiledbindings.cpp index fbf714d..7a8cf0e 100644 --- a/src/declarative/qml/qmlcompiledbindings.cpp +++ b/src/declarative/qml/qmlcompiledbindings.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +// #define COMPILEDBINDINGS_DEBUG + #include "qmlcompiledbindings_p.h" #include <QtDeclarative/qmlinfo.h> @@ -275,6 +277,7 @@ void QmlCompiledBindingsPrivate::Binding::destroy() enabled = false; removeFromObject(); parent->q_func()->release(); + clear(); } int QmlCompiledBindings::qt_metacall(QMetaObject::Call c, int id, void **) @@ -975,6 +978,147 @@ static void throwException(int id, QmlDelayedError *error, qWarning() << error->error; } +static void dumpInstruction(const Instr *instr) +{ + switch (instr->common.type) { + case Instr::Noop: + qWarning().nospace() << "Noop"; + break; + case Instr::Subscribe: + qWarning().nospace() << "Subscribe" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index; + break; + case Instr::SubscribeId: + qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index; + break; + case Instr::LoadId: + qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg; + break; + case Instr::LoadScope: + qWarning().nospace() << "LoadScope" << "\t\t" << instr->load.index << "\t" << instr->load.reg; + break; + case Instr::LoadRoot: + qWarning().nospace() << "LoadRoot" << "\t\t" << instr->load.index << "\t" << instr->load.reg; + break; + case Instr::LoadAttached: + qWarning().nospace() << "LoadAttached" << "\t\t" << instr->attached.output << "\t" << instr->attached.reg << "\t" << instr->attached.index; + break; + case Instr::ConvertIntToReal: + qWarning().nospace() << "ConvertIntToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::ConvertRealToInt: + qWarning().nospace() << "ConvertRealToInt" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::Real: + qWarning().nospace() << "Real" << "\t\t\t" << instr->real_value.reg << "\t" << instr->real_value.value; + break; + case Instr::Int: + qWarning().nospace() << "Int" << "\t\t\t" << instr->int_value.reg << "\t" << instr->int_value.value; + break; + case Instr::Bool: + qWarning().nospace() << "Bool" << "\t\t\t" << instr->bool_value.reg << "\t" << instr->bool_value.value; + break; + case Instr::String: + qWarning().nospace() << "String" << "\t\t\t" << instr->string_value.reg << "\t" << instr->string_value.offset << "\t" << instr->string_value.length; + break; + case Instr::AddReal: + qWarning().nospace() << "AddReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::AddInt: + qWarning().nospace() << "AddInt" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::AddString: + qWarning().nospace() << "AddString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::MinusReal: + qWarning().nospace() << "MinusReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::MinusInt: + qWarning().nospace() << "MinusInt" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::CompareReal: + qWarning().nospace() << "CompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::CompareString: + qWarning().nospace() << "CompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::NotCompareReal: + qWarning().nospace() << "NotCompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::NotCompareString: + qWarning().nospace() << "NotCompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::GreaterThanReal: + qWarning().nospace() << "GreaterThanReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::MaxReal: + qWarning().nospace() << "MaxReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::MinReal: + qWarning().nospace() << "MinReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::NewString: + qWarning().nospace() << "NewString" << "\t\t" << instr->construct.reg; + break; + case Instr::NewUrl: + qWarning().nospace() << "NewUrl" << "\t\t\t" << instr->construct.reg; + break; + case Instr::CleanupString: + qWarning().nospace() << "CleanupString" << "\t\t" << instr->cleanup.reg; + break; + case Instr::CleanupUrl: + qWarning().nospace() << "CleanupUrl" << "\t\t" << instr->cleanup.reg; + break; + case Instr::Fetch: + qWarning().nospace() << "Fetch" << "\t\t\t" << instr->fetch.output << "\t" << instr->fetch.index << "\t" << instr->fetch.objectReg; + break; + case Instr::Store: + qWarning().nospace() << "Store" << "\t\t\t" << instr->store.output << "\t" << instr->store.index << "\t" << instr->store.reg; + break; + case Instr::Copy: + qWarning().nospace() << "Copy" << "\t\t\t" << instr->copy.reg << "\t" << instr->copy.src; + break; + case Instr::Skip: + qWarning().nospace() << "Skip" << "\t\t\t" << instr->skip.reg << "\t" << instr->skip.count; + break; + case Instr::Done: + qWarning().nospace() << "Done"; + break; + case Instr::InitString: + qWarning().nospace() << "InitString" << "\t\t" << instr->initstring.offset << "\t" << instr->initstring.dataIdx; + break; + case Instr::FindGeneric: + qWarning().nospace() << "FindGeneric" << "\t\t" << instr->find.reg << "\t" << instr->find.name; + break; + case Instr::FindGenericTerminal: + qWarning().nospace() << "FindGenericTerminal" << "\t" << instr->find.reg << "\t" << instr->find.name; + break; + case Instr::FindProperty: + qWarning().nospace() << "FindProperty" << "\t\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name; + break; + case Instr::FindPropertyTerminal: + qWarning().nospace() << "FindPropertyTerminal" << "\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name; + break; + case Instr::CleanupGeneric: + qWarning().nospace() << "CleanupGeneric" << "\t\t" << instr->cleanup.reg; + break; + case Instr::ConvertGenericToReal: + qWarning().nospace() << "ConvertGenericToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::ConvertGenericToBool: + qWarning().nospace() << "ConvertGenericToBool" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::ConvertGenericToString: + qWarning().nospace() << "ConvertGenericToString" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::ConvertGenericToUrl: + qWarning().nospace() << "ConvertGenericToUrl" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + default: + qWarning().nospace() << "Unknown"; + break; + } +} + void QmlCompiledBindingsPrivate::run(int instrIndex, QmlContextPrivate *context, QmlDelayedError *error, QObject *scope, QObject *output) @@ -990,7 +1134,14 @@ void QmlCompiledBindingsPrivate::run(int instrIndex, instr += instrIndex; const char *data = program->data(); +#ifdef COMPILEDBINDINGS_DEBUG + qWarning().nospace() << "Begin binding run"; +#endif + while (instr) { +#ifdef COMPILEDBINDINGS_DEBUG + dumpInstruction(instr); +#endif switch (instr->common.type) { case Instr::Noop: @@ -1403,144 +1554,7 @@ void QmlBindingCompiler::dump(const QByteArray &programData) while (count--) { - switch (instr->common.type) { - case Instr::Noop: - qWarning().nospace() << "Noop"; - break; - case Instr::Subscribe: - qWarning().nospace() << "Subscribe" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index; - break; - case Instr::SubscribeId: - qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index; - break; - case Instr::LoadId: - qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg; - break; - case Instr::LoadScope: - qWarning().nospace() << "LoadScope" << "\t\t" << instr->load.index << "\t" << instr->load.reg; - break; - case Instr::LoadRoot: - qWarning().nospace() << "LoadRoot" << "\t\t" << instr->load.index << "\t" << instr->load.reg; - break; - case Instr::LoadAttached: - qWarning().nospace() << "LoadAttached" << "\t\t" << instr->attached.output << "\t" << instr->attached.reg << "\t" << instr->attached.index; - break; - case Instr::ConvertIntToReal: - qWarning().nospace() << "ConvertIntToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::ConvertRealToInt: - qWarning().nospace() << "ConvertRealToInt" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::Real: - qWarning().nospace() << "Real" << "\t\t\t" << instr->real_value.reg << "\t" << instr->real_value.value; - break; - case Instr::Int: - qWarning().nospace() << "Int" << "\t\t\t" << instr->int_value.reg << "\t" << instr->int_value.value; - break; - case Instr::Bool: - qWarning().nospace() << "Bool" << "\t\t\t" << instr->bool_value.reg << "\t" << instr->bool_value.value; - break; - case Instr::String: - qWarning().nospace() << "String" << "\t\t\t" << instr->string_value.reg << "\t" << instr->string_value.offset << "\t" << instr->string_value.length; - break; - case Instr::AddReal: - qWarning().nospace() << "AddReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::AddInt: - qWarning().nospace() << "AddInt" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::AddString: - qWarning().nospace() << "AddString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::MinusReal: - qWarning().nospace() << "MinusReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::MinusInt: - qWarning().nospace() << "MinusInt" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::CompareReal: - qWarning().nospace() << "CompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::CompareString: - qWarning().nospace() << "CompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::NotCompareReal: - qWarning().nospace() << "NotCompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::NotCompareString: - qWarning().nospace() << "NotCompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::GreaterThanReal: - qWarning().nospace() << "GreaterThanReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::MaxReal: - qWarning().nospace() << "MaxReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::MinReal: - qWarning().nospace() << "MinReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::NewString: - qWarning().nospace() << "NewString" << "\t\t" << instr->construct.reg; - break; - case Instr::NewUrl: - qWarning().nospace() << "NewUrl" << "\t\t\t" << instr->construct.reg; - break; - case Instr::CleanupString: - qWarning().nospace() << "CleanupString" << "\t\t" << instr->cleanup.reg; - break; - case Instr::CleanupUrl: - qWarning().nospace() << "CleanupUrl" << "\t\t" << instr->cleanup.reg; - break; - case Instr::Fetch: - qWarning().nospace() << "Fetch" << "\t\t\t" << instr->fetch.output << "\t" << instr->fetch.index << "\t" << instr->fetch.objectReg; - break; - case Instr::Store: - qWarning().nospace() << "Store" << "\t\t\t" << instr->store.output << "\t" << instr->store.index << "\t" << instr->store.reg; - break; - case Instr::Copy: - qWarning().nospace() << "Copy" << "\t\t\t" << instr->copy.reg << "\t" << instr->copy.src; - break; - case Instr::Skip: - qWarning().nospace() << "Skip" << "\t\t\t" << instr->skip.reg << "\t" << instr->skip.count; - break; - case Instr::Done: - qWarning().nospace() << "Done"; - break; - case Instr::InitString: - qWarning().nospace() << "InitString" << "\t\t" << instr->initstring.offset << "\t" << instr->initstring.dataIdx; - break; - case Instr::FindGeneric: - qWarning().nospace() << "FindGeneric" << "\t\t" << instr->find.reg << "\t" << instr->find.name; - break; - case Instr::FindGenericTerminal: - qWarning().nospace() << "FindGenericTerminal" << "\t" << instr->find.reg << "\t" << instr->find.name; - break; - case Instr::FindProperty: - qWarning().nospace() << "FindProperty" << "\t\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name; - break; - case Instr::FindPropertyTerminal: - qWarning().nospace() << "FindPropertyTerminal" << "\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name; - break; - case Instr::CleanupGeneric: - qWarning().nospace() << "CleanupGeneric" << "\t\t" << instr->cleanup.reg; - break; - case Instr::ConvertGenericToReal: - qWarning().nospace() << "ConvertGenericToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::ConvertGenericToBool: - qWarning().nospace() << "ConvertGenericToBool" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::ConvertGenericToString: - qWarning().nospace() << "ConvertGenericToString" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::ConvertGenericToUrl: - qWarning().nospace() << "ConvertGenericToUrl" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - default: - qWarning().nospace() << "Unknown"; - break; - } - + dumpInstruction(instr); ++instr; } } @@ -1585,6 +1599,9 @@ bool QmlBindingCompilerPrivate::compile(QmlJS::AST::Node *node) { resetInstanceState(); + if (destination->type == -1) + return false; + Result type; if (!parseExpression(node, type)) @@ -1864,7 +1881,8 @@ bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type) subscribeName << contextName(); subscribeName << name; - fetch(type, context->metaObject(), reg, d0Idx, subscribeName, nameNodes.at(ii)); + if (!fetch(type, context->metaObject(), reg, d0Idx, subscribeName, nameNodes.at(ii))) + return false; } else if(d1Idx != -1) { Instr instr; instr.common.type = Instr::LoadRoot; @@ -1875,7 +1893,8 @@ bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type) subscribeName << QLatin1String("$$$ROOT"); subscribeName << name; - fetch(type, component->metaObject(), reg, d1Idx, subscribeName, nameNodes.at(ii)); + if (!fetch(type, component->metaObject(), reg, d1Idx, subscribeName, nameNodes.at(ii))) + return false; } else { Instr find; if (nameParts.count() == 1) @@ -1935,8 +1954,7 @@ bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type) if (absType || (wasAttachedObject && idx != -1) || (mo && mo->property(idx).isFinal())) { absType = 0; - fetch(type, mo, reg, idx, subscribeName, nameNodes.at(ii)); - if (type.type == -1) + if (!fetch(type, mo, reg, idx, subscribeName, nameNodes.at(ii))) return false; } else { diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index f15c364..87ecb8a 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -539,7 +539,6 @@ QObject *QmlComponent::create(QmlContext *context) QObject *QmlComponentPrivate::create(QmlContext *context, const QBitField &bindings) { - QObject *create(QmlContext *context, const QBitField &); if (!context) context = engine->rootContext(); diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h index e4e8007..342c88a 100644 --- a/src/declarative/qml/qmlcompositetypedata_p.h +++ b/src/declarative/qml/qmlcompositetypedata_p.h @@ -146,5 +146,7 @@ public: QByteArray data; }; +QT_END_NAMESPACE + #endif // QMLCOMPOSITETYPEDATA_P_H diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 4011d8d..303af42 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -300,8 +300,6 @@ QmlContext::~QmlContext() co->prevContextObject = 0; } - delete [] d->idValues; - if (d->propertyNames) d->propertyNames->release(); @@ -310,6 +308,8 @@ QmlContext::~QmlContext() if (d->optimizedBindings) d->optimizedBindings->release(); + + delete [] d->idValues; } void QmlContextPrivate::invalidateEngines() diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index c4eb062..01061ee 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qmldom.h" #include "qmldom_p.h" +#include "qmldom_p_p.h" #include "qmlcompositetypedata_p.h" #include "qmlcompiler_p.h" diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h deleted file mode 100644 index 98c5eb8..0000000 --- a/src/declarative/qml/qmldom.h +++ /dev/null @@ -1,349 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLDOM_H -#define QMLDOM_H - -#include "qmlerror.h" - -#include <QtCore/qlist.h> -#include <QtCore/qshareddata.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QString; -class QByteArray; -class QmlDomObject; -class QmlDomList; -class QmlDomValue; -class QmlEngine; -class QmlDomComponent; -class QmlDomImport; -class QIODevice; - -class QmlDomDocumentPrivate; - -class Q_DECLARATIVE_EXPORT QmlDomDocument -{ -public: - QmlDomDocument(); - QmlDomDocument(const QmlDomDocument &); - ~QmlDomDocument(); - QmlDomDocument &operator=(const QmlDomDocument &); - - QList<QmlDomImport> imports() const; - - QList<QmlError> errors() const; - bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl()); - - QmlDomObject rootObject() const; - -private: - QSharedDataPointer<QmlDomDocumentPrivate> d; -}; - -class QmlDomPropertyPrivate; -class Q_DECLARATIVE_EXPORT QmlDomProperty -{ -public: - QmlDomProperty(); - QmlDomProperty(const QmlDomProperty &); - ~QmlDomProperty(); - QmlDomProperty &operator=(const QmlDomProperty &); - - bool isValid() const; - - QByteArray propertyName() const; - QList<QByteArray> propertyNameParts() const; - - bool isDefaultProperty() const; - - QmlDomValue value() const; - - int position() const; - int length() const; - -private: - friend class QmlDomObject; - friend class QmlDomDynamicProperty; - QSharedDataPointer<QmlDomPropertyPrivate> d; -}; - -class QmlDomDynamicPropertyPrivate; -class Q_DECLARATIVE_EXPORT QmlDomDynamicProperty -{ -public: - QmlDomDynamicProperty(); - QmlDomDynamicProperty(const QmlDomDynamicProperty &); - ~QmlDomDynamicProperty(); - QmlDomDynamicProperty &operator=(const QmlDomDynamicProperty &); - - bool isValid() const; - - QByteArray propertyName() const; - int propertyType() const; - QByteArray propertyTypeName() const; - - bool isDefaultProperty() const; - QmlDomProperty defaultValue() const; - - bool isAlias() const; - - int position() const; - int length() const; - -private: - friend class QmlDomObject; - QSharedDataPointer<QmlDomDynamicPropertyPrivate> d; -}; - -class QmlDomObjectPrivate; -class Q_DECLARATIVE_EXPORT QmlDomObject -{ -public: - QmlDomObject(); - QmlDomObject(const QmlDomObject &); - ~QmlDomObject(); - QmlDomObject &operator=(const QmlDomObject &); - - bool isValid() const; - - QByteArray objectType() const; - QByteArray objectClassName() const; - - int objectTypeMajorVersion() const; - int objectTypeMinorVersion() const; - - QString objectId() const; - - QList<QmlDomProperty> properties() const; - QmlDomProperty property(const QByteArray &) const; - - QList<QmlDomDynamicProperty> dynamicProperties() const; - QmlDomDynamicProperty dynamicProperty(const QByteArray &) const; - - bool isCustomType() const; - QByteArray customTypeData() const; - - bool isComponent() const; - QmlDomComponent toComponent() const; - - int position() const; - int length() const; - - QUrl url() const; -private: - friend class QmlDomDocument; - friend class QmlDomComponent; - friend class QmlDomValue; - friend class QmlDomValueValueSource; - friend class QmlDomValueValueInterceptor; - QSharedDataPointer<QmlDomObjectPrivate> d; -}; - -class QmlDomValuePrivate; -class QmlDomBasicValuePrivate; -class Q_DECLARATIVE_EXPORT QmlDomValueLiteral -{ -public: - QmlDomValueLiteral(); - QmlDomValueLiteral(const QmlDomValueLiteral &); - ~QmlDomValueLiteral(); - QmlDomValueLiteral &operator=(const QmlDomValueLiteral &); - - QString literal() const; - -private: - friend class QmlDomValue; - QSharedDataPointer<QmlDomBasicValuePrivate> d; -}; - -class Q_DECLARATIVE_EXPORT QmlDomValueBinding -{ -public: - QmlDomValueBinding(); - QmlDomValueBinding(const QmlDomValueBinding &); - ~QmlDomValueBinding(); - QmlDomValueBinding &operator=(const QmlDomValueBinding &); - - QString binding() const; - -private: - friend class QmlDomValue; - QSharedDataPointer<QmlDomBasicValuePrivate> d; -}; - -class Q_DECLARATIVE_EXPORT QmlDomValueValueSource -{ -public: - QmlDomValueValueSource(); - QmlDomValueValueSource(const QmlDomValueValueSource &); - ~QmlDomValueValueSource(); - QmlDomValueValueSource &operator=(const QmlDomValueValueSource &); - - QmlDomObject object() const; - -private: - friend class QmlDomValue; - QSharedDataPointer<QmlDomBasicValuePrivate> d; -}; - -class Q_DECLARATIVE_EXPORT QmlDomValueValueInterceptor -{ -public: - QmlDomValueValueInterceptor(); - QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &); - ~QmlDomValueValueInterceptor(); - QmlDomValueValueInterceptor &operator=(const QmlDomValueValueInterceptor &); - - QmlDomObject object() const; - -private: - friend class QmlDomValue; - QSharedDataPointer<QmlDomBasicValuePrivate> d; -}; - - -class Q_DECLARATIVE_EXPORT QmlDomComponent : public QmlDomObject -{ -public: - QmlDomComponent(); - QmlDomComponent(const QmlDomComponent &); - ~QmlDomComponent(); - QmlDomComponent &operator=(const QmlDomComponent &); - - QmlDomObject componentRoot() const; -}; - -class Q_DECLARATIVE_EXPORT QmlDomValue -{ -public: - enum Type { - Invalid, - Literal, - PropertyBinding, - ValueSource, - ValueInterceptor, - Object, - List - }; - - QmlDomValue(); - QmlDomValue(const QmlDomValue &); - ~QmlDomValue(); - QmlDomValue &operator=(const QmlDomValue &); - - Type type() const; - - bool isInvalid() const; - bool isLiteral() const; - bool isBinding() const; - bool isValueSource() const; - bool isValueInterceptor() const; - bool isObject() const; - bool isList() const; - - QmlDomValueLiteral toLiteral() const; - QmlDomValueBinding toBinding() const; - QmlDomValueValueSource toValueSource() const; - QmlDomValueValueInterceptor toValueInterceptor() const; - QmlDomObject toObject() const; - QmlDomList toList() const; - - int position() const; - int length() const; - -private: - friend class QmlDomProperty; - friend class QmlDomList; - QSharedDataPointer<QmlDomValuePrivate> d; -}; - -class Q_DECLARATIVE_EXPORT QmlDomList -{ -public: - QmlDomList(); - QmlDomList(const QmlDomList &); - ~QmlDomList(); - QmlDomList &operator=(const QmlDomList &); - - QList<QmlDomValue> values() const; - - int position() const; - int length() const; - - QList<int> commaPositions() const; - -private: - friend class QmlDomValue; - QSharedDataPointer<QmlDomValuePrivate> d; -}; - -class QmlDomImportPrivate; -class Q_DECLARATIVE_EXPORT QmlDomImport -{ -public: - enum Type { Library, File }; - - QmlDomImport(); - QmlDomImport(const QmlDomImport &); - ~QmlDomImport(); - QmlDomImport &operator=(const QmlDomImport &); - - Type type() const; - QString uri() const; - QString version() const; - QString qualifier() const; - -private: - friend class QmlDomDocument; - QSharedDataPointer<QmlDomImportPrivate> d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMLDOM_H diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h index 4ddb9b0..8c7288e 100644 --- a/src/declarative/qml/qmldom_p.h +++ b/src/declarative/qml/qmldom_p.h @@ -53,105 +53,308 @@ // We mean it. // -#include "qmlparser_p.h" +#include "qmlerror.h" -#include <QtCore/QtGlobal> +#include <QtCore/qlist.h> +#include <QtCore/qshareddata.h> + +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QmlDomDocumentPrivate : public QSharedData +QT_MODULE(Declarative) + +class QString; +class QByteArray; +class QmlDomObject; +class QmlDomList; +class QmlDomValue; +class QmlEngine; +class QmlDomComponent; +class QmlDomImport; +class QIODevice; + +class QmlDomDocumentPrivate; + +class Q_DECLARATIVE_EXPORT QmlDomDocument { public: - QmlDomDocumentPrivate(); - QmlDomDocumentPrivate(const QmlDomDocumentPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomDocumentPrivate(); - - QList<QmlError> errors; - QList<QmlDomImport> imports; - QmlParser::Object *root; - QList<int> automaticSemicolonOffsets; + QmlDomDocument(); + QmlDomDocument(const QmlDomDocument &); + ~QmlDomDocument(); + QmlDomDocument &operator=(const QmlDomDocument &); + + QList<QmlDomImport> imports() const; + + QList<QmlError> errors() const; + bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl()); + + QmlDomObject rootObject() const; + +private: + QSharedDataPointer<QmlDomDocumentPrivate> d; +}; + +class QmlDomPropertyPrivate; +class Q_DECLARATIVE_EXPORT QmlDomProperty +{ +public: + QmlDomProperty(); + QmlDomProperty(const QmlDomProperty &); + ~QmlDomProperty(); + QmlDomProperty &operator=(const QmlDomProperty &); + + bool isValid() const; + + QByteArray propertyName() const; + QList<QByteArray> propertyNameParts() const; + + bool isDefaultProperty() const; + + QmlDomValue value() const; + + int position() const; + int length() const; + +private: + friend class QmlDomObject; + friend class QmlDomDynamicProperty; + QSharedDataPointer<QmlDomPropertyPrivate> d; }; -class QmlDomObjectPrivate : public QSharedData +class QmlDomDynamicPropertyPrivate; +class Q_DECLARATIVE_EXPORT QmlDomDynamicProperty { public: - QmlDomObjectPrivate(); - QmlDomObjectPrivate(const QmlDomObjectPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomObjectPrivate(); + QmlDomDynamicProperty(); + QmlDomDynamicProperty(const QmlDomDynamicProperty &); + ~QmlDomDynamicProperty(); + QmlDomDynamicProperty &operator=(const QmlDomDynamicProperty &); + + bool isValid() const; + + QByteArray propertyName() const; + int propertyType() const; + QByteArray propertyTypeName() const; + + bool isDefaultProperty() const; + QmlDomProperty defaultValue() const; + + bool isAlias() const; - typedef QList<QPair<QmlParser::Property *, QByteArray> > Properties; - Properties properties() const; - Properties properties(QmlParser::Property *) const; + int position() const; + int length() const; - QmlParser::Object *object; +private: + friend class QmlDomObject; + QSharedDataPointer<QmlDomDynamicPropertyPrivate> d; }; -class QmlDomPropertyPrivate : public QSharedData +class QmlDomObjectPrivate; +class Q_DECLARATIVE_EXPORT QmlDomObject { public: - QmlDomPropertyPrivate(); - QmlDomPropertyPrivate(const QmlDomPropertyPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomPropertyPrivate(); + QmlDomObject(); + QmlDomObject(const QmlDomObject &); + ~QmlDomObject(); + QmlDomObject &operator=(const QmlDomObject &); + + bool isValid() const; + + QByteArray objectType() const; + QByteArray objectClassName() const; + + int objectTypeMajorVersion() const; + int objectTypeMinorVersion() const; + + QString objectId() const; - QByteArray propertyName; - QmlParser::Property *property; + QList<QmlDomProperty> properties() const; + QmlDomProperty property(const QByteArray &) const; + + QList<QmlDomDynamicProperty> dynamicProperties() const; + QmlDomDynamicProperty dynamicProperty(const QByteArray &) const; + + bool isCustomType() const; + QByteArray customTypeData() const; + + bool isComponent() const; + QmlDomComponent toComponent() const; + + int position() const; + int length() const; + + QUrl url() const; +private: + friend class QmlDomDocument; + friend class QmlDomComponent; + friend class QmlDomValue; + friend class QmlDomValueValueSource; + friend class QmlDomValueValueInterceptor; + QSharedDataPointer<QmlDomObjectPrivate> d; }; -class QmlDomDynamicPropertyPrivate : public QSharedData +class QmlDomValuePrivate; +class QmlDomBasicValuePrivate; +class Q_DECLARATIVE_EXPORT QmlDomValueLiteral { public: - QmlDomDynamicPropertyPrivate(); - QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomDynamicPropertyPrivate(); + QmlDomValueLiteral(); + QmlDomValueLiteral(const QmlDomValueLiteral &); + ~QmlDomValueLiteral(); + QmlDomValueLiteral &operator=(const QmlDomValueLiteral &); + + QString literal() const; - bool valid; - QmlParser::Object::DynamicProperty property; +private: + friend class QmlDomValue; + QSharedDataPointer<QmlDomBasicValuePrivate> d; }; -class QmlDomValuePrivate : public QSharedData +class Q_DECLARATIVE_EXPORT QmlDomValueBinding { public: - QmlDomValuePrivate(); - QmlDomValuePrivate(const QmlDomValuePrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomValuePrivate(); + QmlDomValueBinding(); + QmlDomValueBinding(const QmlDomValueBinding &); + ~QmlDomValueBinding(); + QmlDomValueBinding &operator=(const QmlDomValueBinding &); - QmlParser::Property *property; - QmlParser::Value *value; + QString binding() const; + +private: + friend class QmlDomValue; + QSharedDataPointer<QmlDomBasicValuePrivate> d; }; -class QmlDomBasicValuePrivate : public QSharedData +class Q_DECLARATIVE_EXPORT QmlDomValueValueSource { public: - QmlDomBasicValuePrivate(); - QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomBasicValuePrivate(); + QmlDomValueValueSource(); + QmlDomValueValueSource(const QmlDomValueValueSource &); + ~QmlDomValueValueSource(); + QmlDomValueValueSource &operator=(const QmlDomValueValueSource &); + + QmlDomObject object() const; - QmlParser::Value *value; +private: + friend class QmlDomValue; + QSharedDataPointer<QmlDomBasicValuePrivate> d; }; -class QmlDomImportPrivate : public QSharedData +class Q_DECLARATIVE_EXPORT QmlDomValueValueInterceptor { public: - QmlDomImportPrivate(); - QmlDomImportPrivate(const QmlDomImportPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomImportPrivate(); + QmlDomValueValueInterceptor(); + QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &); + ~QmlDomValueValueInterceptor(); + QmlDomValueValueInterceptor &operator=(const QmlDomValueValueInterceptor &); + QmlDomObject object() const; + +private: + friend class QmlDomValue; + QSharedDataPointer<QmlDomBasicValuePrivate> d; +}; + + +class Q_DECLARATIVE_EXPORT QmlDomComponent : public QmlDomObject +{ +public: + QmlDomComponent(); + QmlDomComponent(const QmlDomComponent &); + ~QmlDomComponent(); + QmlDomComponent &operator=(const QmlDomComponent &); + + QmlDomObject componentRoot() const; +}; + +class Q_DECLARATIVE_EXPORT QmlDomValue +{ +public: + enum Type { + Invalid, + Literal, + PropertyBinding, + ValueSource, + ValueInterceptor, + Object, + List + }; + + QmlDomValue(); + QmlDomValue(const QmlDomValue &); + ~QmlDomValue(); + QmlDomValue &operator=(const QmlDomValue &); + + Type type() const; + + bool isInvalid() const; + bool isLiteral() const; + bool isBinding() const; + bool isValueSource() const; + bool isValueInterceptor() const; + bool isObject() const; + bool isList() const; + + QmlDomValueLiteral toLiteral() const; + QmlDomValueBinding toBinding() const; + QmlDomValueValueSource toValueSource() const; + QmlDomValueValueInterceptor toValueInterceptor() const; + QmlDomObject toObject() const; + QmlDomList toList() const; + + int position() const; + int length() const; + +private: + friend class QmlDomProperty; + friend class QmlDomList; + QSharedDataPointer<QmlDomValuePrivate> d; +}; + +class Q_DECLARATIVE_EXPORT QmlDomList +{ +public: + QmlDomList(); + QmlDomList(const QmlDomList &); + ~QmlDomList(); + QmlDomList &operator=(const QmlDomList &); + + QList<QmlDomValue> values() const; + + int position() const; + int length() const; + + QList<int> commaPositions() const; + +private: + friend class QmlDomValue; + QSharedDataPointer<QmlDomValuePrivate> d; +}; + +class QmlDomImportPrivate; +class Q_DECLARATIVE_EXPORT QmlDomImport +{ +public: enum Type { Library, File }; - Type type; - QString uri; - QString version; - QString qualifier; + QmlDomImport(); + QmlDomImport(const QmlDomImport &); + ~QmlDomImport(); + QmlDomImport &operator=(const QmlDomImport &); + + Type type() const; + QString uri() const; + QString version() const; + QString qualifier() const; + +private: + friend class QmlDomDocument; + QSharedDataPointer<QmlDomImportPrivate> d; }; QT_END_NAMESPACE -#endif // QMLDOM_P_H +QT_END_HEADER +#endif // QMLDOM_P_H diff --git a/src/declarative/qml/qmldom_p_p.h b/src/declarative/qml/qmldom_p_p.h new file mode 100644 index 0000000..9d955b0 --- /dev/null +++ b/src/declarative/qml/qmldom_p_p.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLDOM_P_P_H +#define QMLDOM_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlparser_p.h" + +#include <QtCore/QtGlobal> + +QT_BEGIN_NAMESPACE + +class QmlDomDocumentPrivate : public QSharedData +{ +public: + QmlDomDocumentPrivate(); + QmlDomDocumentPrivate(const QmlDomDocumentPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomDocumentPrivate(); + + QList<QmlError> errors; + QList<QmlDomImport> imports; + QmlParser::Object *root; + QList<int> automaticSemicolonOffsets; +}; + +class QmlDomObjectPrivate : public QSharedData +{ +public: + QmlDomObjectPrivate(); + QmlDomObjectPrivate(const QmlDomObjectPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomObjectPrivate(); + + typedef QList<QPair<QmlParser::Property *, QByteArray> > Properties; + Properties properties() const; + Properties properties(QmlParser::Property *) const; + + QmlParser::Object *object; +}; + +class QmlDomPropertyPrivate : public QSharedData +{ +public: + QmlDomPropertyPrivate(); + QmlDomPropertyPrivate(const QmlDomPropertyPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomPropertyPrivate(); + + QByteArray propertyName; + QmlParser::Property *property; +}; + +class QmlDomDynamicPropertyPrivate : public QSharedData +{ +public: + QmlDomDynamicPropertyPrivate(); + QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomDynamicPropertyPrivate(); + + bool valid; + QmlParser::Object::DynamicProperty property; +}; + +class QmlDomValuePrivate : public QSharedData +{ +public: + QmlDomValuePrivate(); + QmlDomValuePrivate(const QmlDomValuePrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomValuePrivate(); + + QmlParser::Property *property; + QmlParser::Value *value; +}; + +class QmlDomBasicValuePrivate : public QSharedData +{ +public: + QmlDomBasicValuePrivate(); + QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomBasicValuePrivate(); + + QmlParser::Value *value; +}; + +class QmlDomImportPrivate : public QSharedData +{ +public: + QmlDomImportPrivate(); + QmlDomImportPrivate(const QmlDomImportPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomImportPrivate(); + + enum Type { Library, File }; + + Type type; + QString uri; + QString version; + QString qualifier; +}; + +QT_END_NAMESPACE + +#endif // QMLDOM_P_P_H + diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index bb36035..cf26f58 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -65,6 +65,7 @@ #include "qmlcomponent_p.h" #include "qmlscriptclass_p.h" #include "qmlnetworkaccessmanagerfactory.h" +#include "qmlimageprovider.h" #include <qfxperf_p_p.h> @@ -85,6 +86,7 @@ #include <QtCore/qthread.h> #include <QtCore/qcoreapplication.h> #include <QtCore/qdir.h> +#include <QtCore/qmutex.h> #include <QtGui/qcolor.h> #include <QtGui/qvector3d.h> #include <QtGui/qsound.h> @@ -95,6 +97,8 @@ #include <private/qobject_p.h> #include <private/qscriptdeclarativeclass_p.h> +#include <private/qmlgraphicsitemsmodule_p.h> + #ifdef Q_OS_WIN // for %APPDATA% #include <qt_windows.h> #include <qlibrary.h> @@ -136,6 +140,8 @@ struct StaticQtMetaObject : public QObject { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; } }; +static bool qt_QmlQtModule_registered = false; + QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) : captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false), contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), @@ -144,6 +150,10 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) networkAccessManager(0), networkAccessManagerFactory(0), typeManager(e), uniqueId(1) { + if (!qt_QmlQtModule_registered) { + qt_QmlQtModule_registered = true; + QmlGraphicsItemModule::defineModule(); + } globalClass = new QmlGlobalScriptClass(&scriptEngine); fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml")); } @@ -428,6 +438,7 @@ QmlContext *QmlEngine::rootContext() void QmlEngine::setNetworkAccessManagerFactory(QmlNetworkAccessManagerFactory *factory) { Q_D(QmlEngine); + QMutexLocker locker(&d->mutex); d->networkAccessManagerFactory = factory; } @@ -442,17 +453,24 @@ QmlNetworkAccessManagerFactory *QmlEngine::networkAccessManagerFactory() const return d->networkAccessManagerFactory; } +QNetworkAccessManager *QmlEnginePrivate::createNetworkAccessManager(QObject *parent) const +{ + QMutexLocker locker(&mutex); + QNetworkAccessManager *nam; + if (networkAccessManagerFactory) { + nam = networkAccessManagerFactory->create(parent); + } else { + nam = new QNetworkAccessManager(parent); + } + + return nam; +} + QNetworkAccessManager *QmlEnginePrivate::getNetworkAccessManager() const { Q_Q(const QmlEngine); - - if (!networkAccessManager) { - if (networkAccessManagerFactory) { - networkAccessManager = networkAccessManagerFactory->create(const_cast<QmlEngine*>(q)); - } else { - networkAccessManager = new QNetworkAccessManager(const_cast<QmlEngine*>(q)); - } - } + if (!networkAccessManager) + networkAccessManager = createNetworkAccessManager(const_cast<QmlEngine*>(q)); return networkAccessManager; } @@ -474,6 +492,69 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const } /*! + Sets the \a provider to use for images requested via the \e image: url + scheme, with host \a providerId. + + QmlImageProvider allows images to be provided to QML asynchronously. + The image request will be run in a low priority thread. This allows + potentially costly image loading to be done in the background, without + affecting the performance of the UI. + + Note that images loaded from a QmlImageProvider are cached by + QPixmapCache, similar to any image loaded by QML. + + The QmlEngine assumes ownership of the provider. + + This example creates a provider with id \e colors: + + \snippet examples/declarative/imageprovider/main.cpp 0 + + \snippet examples/declarative/imageprovider/view.qml 0 + + \sa removeImageProvider() +*/ +void QmlEngine::addImageProvider(const QString &providerId, QmlImageProvider *provider) +{ + Q_D(QmlEngine); + QMutexLocker locker(&d->mutex); + d->imageProviders.insert(providerId, provider); +} + +/*! + Returns the QmlImageProvider set for \a providerId. +*/ +QmlImageProvider *QmlEngine::imageProvider(const QString &providerId) const +{ + Q_D(const QmlEngine); + QMutexLocker locker(&d->mutex); + return d->imageProviders.value(providerId); +} + +/*! + Removes the QmlImageProvider for \a providerId. + + Returns the provider if it was found; otherwise returns 0. + + \sa addImageProvider() +*/ +void QmlEngine::removeImageProvider(const QString &providerId) +{ + Q_D(QmlEngine); + QMutexLocker locker(&d->mutex); + delete d->imageProviders.take(providerId); +} + +QImage QmlEnginePrivate::getImageFromProvider(const QUrl &url) +{ + QMutexLocker locker(&mutex); + QImage image; + QmlImageProvider *provider = imageProviders.value(url.host()); + if (provider) + image = provider->request(url.path().mid(1)); + return image; +} + +/*! Return the base URL for this engine. The base URL is only used to resolve components when a relative URL is passed to the QmlComponent constructor. diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h index 8916013..64d0b9d 100644 --- a/src/declarative/qml/qmlengine.h +++ b/src/declarative/qml/qmlengine.h @@ -62,6 +62,7 @@ class QmlType; class QUrl; class QScriptEngine; class QScriptContext; +class QmlImageProvider; class QNetworkAccessManager; class QmlNetworkAccessManagerFactory; class Q_DECLARATIVE_EXPORT QmlEngine : public QObject @@ -83,6 +84,10 @@ public: QNetworkAccessManager *networkAccessManager() const; + void addImageProvider(const QString &id, QmlImageProvider *); + QmlImageProvider *imageProvider(const QString &id) const; + void removeImageProvider(const QString &id); + void setOfflineStoragePath(const QString& dir); QString offlineStoragePath() const; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index ce99e7c..7ec6dd6 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -75,6 +75,7 @@ #include <QtCore/qlist.h> #include <QtCore/qpair.h> #include <QtCore/qstack.h> +#include <QtCore/qmutex.h> #include <QtScript/qscriptengine.h> #include <private/qobject_p.h> @@ -211,10 +212,16 @@ public: bool inBeginCreate; + QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const; QNetworkAccessManager *getNetworkAccessManager() const; mutable QNetworkAccessManager *networkAccessManager; mutable QmlNetworkAccessManagerFactory *networkAccessManagerFactory; + QHash<QString,QmlImageProvider*> imageProviders; + QImage getImageFromProvider(const QUrl &url); + + mutable QMutex mutex; + QmlCompositeTypeManager typeManager; QStringList fileImportPath; QString offlineStoragePath; @@ -309,6 +316,7 @@ public: static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; } static QmlEngine *getEngine(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p->q_func(); } static QmlEnginePrivate *get(QmlEngine *e) { return e->d_func(); } + static QmlEnginePrivate *get(QmlContext *c) { return (c && c->engine()) ? QmlEnginePrivate::get(c->engine()) : 0; } static QmlEnginePrivate *get(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p; } static QmlEngine *get(QmlEnginePrivate *p) { return p->q_func(); } QmlContext *getContext(QScriptContext *); diff --git a/src/declarative/qml/qmlguard_p.h b/src/declarative/qml/qmlguard_p.h index dae7d05..0e90f79 100644 --- a/src/declarative/qml/qmlguard_p.h +++ b/src/declarative/qml/qmlguard_p.h @@ -94,10 +94,10 @@ private: inline void remGuard(); }; -Q_DECLARE_METATYPE(QmlGuard<QObject>); - QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlGuard<QObject>); + #include "qmldeclarativedata_p.h" QT_BEGIN_NAMESPACE diff --git a/tools/qmldebugger/standalone/main.cpp b/src/declarative/qml/qmlimageprovider.cpp index 9c075a1..7f15d08 100644 --- a/tools/qmldebugger/standalone/main.cpp +++ b/src/declarative/qml/qmlimageprovider.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt QML Debugger of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,40 +38,31 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <QtGui/qapplication.h> -#include "qmldebugger.h" +#include "qmlimageprovider.h" -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - app.setApplicationName("QtQmlDebugger"); - app.setOrganizationName("Nokia"); - app.setOrganizationDomain("nokia.com"); +QT_BEGIN_NAMESPACE + +/*! + \class QmlImageProvider + \brief The QmlImageProvider class provides an interface for threaded image requests. + + Note: the request() method may be called by multiple threads, so ensure the + implementation of this method is reentrant. - QStringList args = app.arguments(); + \sa QmlEngine::addImageProvider() +*/ +QmlImageProvider::~QmlImageProvider() +{ +} - QmlDebugger win; - if (args.contains("--engine")) - win.showEngineTab(); +/*! + \fn QImage QmlImageProvider::request(const QString &id) - for (int i=0; i<args.count(); i++) { - if (!args[i].contains(':')) - continue; - QStringList hostAndPort = args[i].split(':'); - bool ok = false; - quint16 port = hostAndPort.value(1).toInt(&ok); - if (ok) { - qWarning() << "qmldebugger connecting to" - << hostAndPort[0] << port << "..."; - win.setHost(hostAndPort[0]); - win.setPort(port); - win.connectToHost(); - break; - } - } + Implement this method to return the image with \a id. - win.show(); + Note: this method may be called by multiple threads, so ensure the + implementation of this method is reentrant. +*/ - return app.exec(); -} +QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/qmldebugger.h b/src/declarative/qml/qmlimageprovider.h index 894cf0f..52fe066 100644 --- a/tools/qmldebugger/standalone/qmldebugger.h +++ b/src/declarative/qml/qmlimageprovider.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt QML Debugger of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,53 +38,27 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef QMLDEBUGGER_H -#define QMLDEBUGGER_H -#include <private/qmldebugclient_p.h> -#include <QtNetwork/qtcpsocket.h> -#include <QtGui/qwidget.h> +#ifndef QMLIMAGEPROVIDER_H +#define QMLIMAGEPROVIDER_H -class QLabel; -class QLineEdit; -class QSpinBox; -class QPushButton; -class QTabWidget; +#include <QtGui/qimage.h> -class EnginePane; +QT_BEGIN_HEADER -class QmlDebugger : public QWidget -{ - Q_OBJECT -public: - QmlDebugger(QWidget * = 0); - - void setHost(const QString &host); - void setPort(quint16 port); - void showEngineTab(); - -public slots: - void connectToHost(); - void disconnectFromHost(); +QT_BEGIN_NAMESPACE -protected: - void closeEvent(QCloseEvent *); - -private slots: - void connectionStateChanged(); - void connectionError(QAbstractSocket::SocketError socketError); +QT_MODULE(Declarative) -private: - QmlDebugConnection client; +class Q_DECLARATIVE_EXPORT QmlImageProvider +{ +public: + virtual ~QmlImageProvider(); + virtual QImage request(const QString &id) = 0; +}; - QLabel *m_connectionState; - QLineEdit *m_host; - QSpinBox *m_port; - QPushButton *m_connectButton; - QPushButton *m_disconnectButton; +QT_END_NAMESPACE - EnginePane *m_enginePane; - QTabWidget *m_tabs; -}; +QT_END_HEADER -#endif +#endif // QMLIMAGEPROVIDER diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 5938384..d7d4a07 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -276,7 +276,7 @@ const char *QmlMetaProperty::propertyTypeName() const { if (type() & ValueTypeProperty) { - QmlEnginePrivate *ep = d->context?QmlEnginePrivate::get(d->context->engine()):0; + QmlEnginePrivate *ep = QmlEnginePrivate::get(d->context); QmlValueType *valueType = 0; if (ep) valueType = ep->valueTypes[d->core.propType]; else valueType = QmlValueTypeFactory::valueType(d->core.propType); @@ -689,7 +689,7 @@ QVariant QmlMetaPropertyPrivate::readValueProperty() } else if(type & QmlMetaProperty::ValueTypeProperty) { - QmlEnginePrivate *ep = context?QmlEnginePrivate::get(context->engine()):0; + QmlEnginePrivate *ep = QmlEnginePrivate::get(context); QmlValueType *valueType = 0; if (ep) valueType = ep->valueTypes[core.propType]; else valueType = QmlValueTypeFactory::valueType(core.propType); @@ -754,14 +754,15 @@ bool QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value, QmlMetaProperty::WriteFlags flags) { // Remove any existing bindings on this property - if (!(flags & QmlMetaProperty::DontRemoveBinding)) - delete q->setBinding(0); + if (!(flags & QmlMetaProperty::DontRemoveBinding)) { + QmlAbstractBinding *binding = q->setBinding(0); + if (binding) binding->destroy(); + } bool rv = false; uint type = q->type(); if (type & QmlMetaProperty::ValueTypeProperty) { - QmlEnginePrivate *ep = - context?static_cast<QmlEnginePrivate *>(QObjectPrivate::get(context->engine())):0; + QmlEnginePrivate *ep = QmlEnginePrivate::get(context); QmlValueType *writeBack = 0; if (ep) { diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 50a19e4..b94a815 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -840,6 +840,8 @@ QList<QmlType*> QmlMetaType::qmlTypes() return data->nameToType.values(); } +QT_END_NAMESPACE + #include <QtGui/qfont.h> #include <QtGui/qpixmap.h> #include <QtGui/qbrush.h> @@ -867,6 +869,7 @@ QList<QmlType*> QmlMetaType::qmlTypes() Q_DECLARE_METATYPE(QScriptValue); +QT_BEGIN_NAMESPACE /*! Copies \a copy into \a data, assuming they both are of type \a type. If \a copy is zero, a default type is copied. Returns true if the copy was diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp index 2c79ceb..e567fd2 100644 --- a/src/declarative/qml/qmlpropertycache.cpp +++ b/src/declarative/qml/qmlpropertycache.cpp @@ -45,10 +45,10 @@ #include "qmlbinding.h" #include "qdebug.h" -QT_BEGIN_NAMESPACE - Q_DECLARE_METATYPE(QScriptValue); +QT_BEGIN_NAMESPACE + void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine) { propType = p.userType(); diff --git a/src/declarative/qml/qmlscriptstring.h b/src/declarative/qml/qmlscriptstring.h index 3f61f5d..1789eb5 100644 --- a/src/declarative/qml/qmlscriptstring.h +++ b/src/declarative/qml/qmlscriptstring.h @@ -77,10 +77,10 @@ private: QSharedDataPointer<QmlScriptStringPrivate> d; }; -Q_DECLARE_METATYPE(QmlScriptString); - QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlScriptString); + QT_END_HEADER #endif // QMLSCRIPTSTRING_H diff --git a/src/declarative/qml/qmlsqldatabase.cpp b/src/declarative/qml/qmlsqldatabase.cpp index 4b132af..4e0e0fb 100644 --- a/src/declarative/qml/qmlsqldatabase.cpp +++ b/src/declarative/qml/qmlsqldatabase.cpp @@ -65,6 +65,8 @@ Q_DECLARE_METATYPE(QSqlDatabase) Q_DECLARE_METATYPE(QSqlQuery) +QT_BEGIN_NAMESPACE + class QmlSqlQueryScriptClass: public QScriptClass { public: QmlSqlQueryScriptClass(QScriptEngine *engine) : QScriptClass(engine) @@ -423,3 +425,4 @@ We add a "forwardOnly" property that stops Qt caching results (code promises to through the data. */ +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlsqldatabase_p.h b/src/declarative/qml/qmlsqldatabase_p.h index 95eb5ea..0fd275b 100644 --- a/src/declarative/qml/qmlsqldatabase_p.h +++ b/src/declarative/qml/qmlsqldatabase_p.h @@ -42,6 +42,7 @@ #ifndef QMLSQLDATABASE_P_H #define QMLSQLDATABASE_P_H +#include <QtScript/qscriptengine.h> // // W A R N I N G // ------------- @@ -53,8 +54,14 @@ // We mean it. // +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + class QScriptEngine; void qt_add_qmlsqldatabase(QScriptEngine *engine); +QT_END_NAMESPACE + #endif // QMLSQLDATABASE_P_H diff --git a/src/declarative/qml/qmlstringconverters_p.h b/src/declarative/qml/qmlstringconverters_p.h index 5156b7d..c83a1de 100644 --- a/src/declarative/qml/qmlstringconverters_p.h +++ b/src/declarative/qml/qmlstringconverters_p.h @@ -56,6 +56,8 @@ #include <QtCore/qglobal.h> #include <QtCore/qvariant.h> +QT_BEGIN_NAMESPACE + class QColor; class QPointF; class QSizeF; @@ -64,8 +66,6 @@ class QString; class QByteArray; class QVector3D; -QT_BEGIN_NAMESPACE - // XXX - Bauhaus currently uses these methods which is why they're exported namespace QmlStringConverters { diff --git a/src/declarative/qml/qmlworkerscript.cpp b/src/declarative/qml/qmlworkerscript.cpp index 4e6bd4f..a2e8c7a 100644 --- a/src/declarative/qml/qmlworkerscript.cpp +++ b/src/declarative/qml/qmlworkerscript.cpp @@ -55,6 +55,7 @@ #include <QtDeclarative/qmlinfo.h> #include "qmlnetworkaccessmanagerfactory.h" + QT_BEGIN_NAMESPACE class WorkerDataEvent : public QEvent @@ -238,8 +239,13 @@ private: QAtomicInt m_ref; QmlWorkerListModel *m_model; }; + +QT_END_NAMESPACE + Q_DECLARE_METATYPE(QmlWorkerListModelAgent::VariantRef); +QT_BEGIN_NAMESPACE + QmlWorkerScriptEnginePrivate::QmlWorkerScriptEnginePrivate(QmlEngine *engine) : workerEngine(0), qmlengine(engine), m_nextId(0) { @@ -1030,8 +1036,10 @@ QVariant QmlWorkerListModel::data(int index, int role) const return m_values.at(index).value(role); } +QT_END_NAMESPACE + QML_DEFINE_TYPE(Qt,4,6,WorkerListModel,QmlWorkerListModel) #include "qmlworkerscript.moc" -QT_END_NAMESPACE + diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp index 8bee751..eda2d9e 100644 --- a/src/declarative/qml/qmlxmlhttprequest.cpp +++ b/src/declarative/qml/qmlxmlhttprequest.cpp @@ -91,7 +91,7 @@ #define D(arg) (arg)->release() #define A(arg) (arg)->addref() -namespace { +QT_BEGIN_NAMESPACE class DocumentImpl; class NodeImpl @@ -315,12 +315,14 @@ public: static QScriptValue load(QScriptEngine *engine, const QString &data); }; -}; // namespace +QT_END_NAMESPACE Q_DECLARE_METATYPE(Node); Q_DECLARE_METATYPE(NodeList); Q_DECLARE_METATYPE(NamedNodeMap); +QT_BEGIN_NAMESPACE + void NodeImpl::addref() { A(document); @@ -1624,4 +1626,6 @@ void qt_add_qmlxmlhttprequest(QScriptEngine *engine) engine->globalObject().setProperty(QLatin1String("DOMException"), domExceptionPrototype); } +QT_END_NAMESPACE + #include <qmlxmlhttprequest.moc> diff --git a/src/declarative/qml/qmlxmlhttprequest_p.h b/src/declarative/qml/qmlxmlhttprequest_p.h index 733cc03..59cb211 100644 --- a/src/declarative/qml/qmlxmlhttprequest_p.h +++ b/src/declarative/qml/qmlxmlhttprequest_p.h @@ -42,6 +42,7 @@ #ifndef QMLXMLHTTPREQUEST_P_H #define QMLXMLHTTPREQUEST_P_H +#include <QtScript/qscriptengine.h> // // W A R N I N G // ------------- @@ -53,8 +54,14 @@ // We mean it. // +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + class QScriptEngine; void qt_add_qmlxmlhttprequest(QScriptEngine *engine); +QT_END_NAMESPACE + #endif // QMLXMLHTTPREQUEST_P_H diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 103a50f..82bd33e 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -210,11 +210,16 @@ bool QmlAbstractAnimation::isRunning() const return d->running; } +//commence is called to start an animation when it is used as a +//simple animation, and not as part of a transition void QmlAbstractAnimationPrivate::commence() { Q_Q(QmlAbstractAnimation); - q->prepare(userProperty.value); + QmlStateActions actions; + QmlMetaProperties properties; + q->transition(actions, properties, QmlAbstractAnimation::Forward); + q->qtAnimation()->start(); if (q->qtAnimation()->state() != QAbstractAnimation::Running) { running = false; @@ -238,14 +243,17 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const void QmlAbstractAnimation::setRunning(bool r) { Q_D(QmlAbstractAnimation); - - if (r == false) - d->avoidPropertyValueSourceStart = true; + if (!d->componentComplete) { + d->running = r; + if (r == false) + d->avoidPropertyValueSourceStart = true; + return; + } if (d->running == r) return; - if (d->group) { + if (d->group || d->disableUserControl) { qWarning("QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); return; } @@ -262,10 +270,7 @@ void QmlAbstractAnimation::setRunning(bool r) this, SLOT(timelineComplete())); d->connectedTimeLine = true; } - if (d->componentComplete) - d->commence(); - else - d->startOnCompletion = true; + d->commence(); emit started(); } else { if (d->alwaysRunToEnd) { @@ -304,7 +309,7 @@ void QmlAbstractAnimation::setPaused(bool p) if (d->paused == p) return; - if (d->group) { + if (d->group || d->disableUserControl) { qWarning("QmlAbstractAnimation: setPaused() cannot be used on non-root animation nodes"); return; } @@ -315,7 +320,7 @@ void QmlAbstractAnimation::setPaused(bool p) else qtAnimation()->resume(); - emit pausedChanged(d->running); + emit pausedChanged(d->paused); } void QmlAbstractAnimation::classBegin() @@ -327,9 +332,11 @@ void QmlAbstractAnimation::classBegin() void QmlAbstractAnimation::componentComplete() { Q_D(QmlAbstractAnimation); - if (d->startOnCompletion) - d->commence(); d->componentComplete = true; + if (d->running) { + d->running = false; + setRunning(true); + } } /*! @@ -534,17 +541,32 @@ void QmlAbstractAnimation::complete() void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p) { Q_D(QmlAbstractAnimation); - if (d->userProperty.isNull) - d->userProperty = p; + d->defaultProperty = p; if (!d->avoidPropertyValueSourceStart) setRunning(true); } -//prepare is called before an animation begins -//(when an animation is used as a simple animation, and not as part of a transition) -void QmlAbstractAnimation::prepare(QmlMetaProperty &) +/* + we rely on setTarget only being called when used as a value source + so this function allows us to do the same thing as setTarget without + that assumption +*/ +void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p) +{ + Q_D(QmlAbstractAnimation); + d->defaultProperty = p; +} + +/* + don't allow start/stop/pause/resume to be manually invoked, + because something else (like a Behavior) already has control + over the animation. +*/ +void QmlAbstractAnimation::setDisableUserControl() { + Q_D(QmlAbstractAnimation); + d->disableUserControl = true; } void QmlAbstractAnimation::transition(QmlStateActions &actions, @@ -685,7 +707,7 @@ void QmlColorAnimation::setFrom(const QColor &f) } /*! - \qmlproperty color ColorAnimation::from + \qmlproperty color ColorAnimation::to This property holds the ending color. */ QColor QmlColorAnimation::to() const @@ -819,7 +841,7 @@ QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction) Set \c thewebview.url to the value set for the destination state: \code - PropertyAction { matchTargets: thewebview; matchProperties: "url" } + PropertyAction { target: thewebview; property: "url" } \endcode The PropertyAction is immediate - @@ -866,25 +888,10 @@ void QmlPropertyAction::setTarget(QObject *o) Q_D(QmlPropertyAction); if (d->target == o) return; - d->target = o; - if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName, this); - } else { - d->userProperty.invalidate(); - } - emit targetChanged(d->target, d->propertyName); } -/*! - \qmlproperty string PropertyAction::property - This property holds an explicit property to animated. - - The exact effect of the \c property property depends on how the animation - is being used. Refer to the \l animation documentation for details. -*/ - QString QmlPropertyAction::property() const { Q_D(const QmlPropertyAction); @@ -896,29 +903,24 @@ void QmlPropertyAction::setProperty(const QString &n) Q_D(QmlPropertyAction); if (d->propertyName == n) return; - d->propertyName = n; - if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName, this); - } else { - d->userProperty.invalidate(); - } - emit targetChanged(d->target, d->propertyName); } /*! - \qmlproperty string PropertyAction::matchProperties - This property holds a comma-separated list of property names this action - will match against. These names are used in conjunction with matchTargets - to create a list of properties that the action will set, assuming those - properties have changed. + \qmlproperty string PropertyAction::property + \qmlproperty string PropertyAction::properties + \qmlproperty Object PropertyAction::target + \qmlproperty list<Object> PropertyAction::targets - This property is typically used for an action appearing as part of a Transition. + These properties are used as a set to determine which properties should be + affected by this action. - By default, no property names will be matched. + The details of how these properties are interpreted in different situations + is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation + documentation. - \sa matchTargets PropertyAnimation::matchProperties + \sa exclude */ QString QmlPropertyAction::properties() const { @@ -935,18 +937,6 @@ void QmlPropertyAction::setProperties(const QString &p) emit propertiesChanged(p); } -/*! - \qmlproperty list<Object> PropertyAction::matchTargets - This property holds a list of objects this action will match against. - These objects are used in conjunction with matchProperties to create a list of properties - that the action will set, assuming those properties have changed. - - This property is typically used for an action appearing as part of a Transition. - - By default, all changing targets will be matched. - - \sa exclude matchProperties PropertyAnimation::matchTargets -*/ QList<QObject *> *QmlPropertyAction::targets() { Q_D(QmlPropertyAction); @@ -956,7 +946,7 @@ QList<QObject *> *QmlPropertyAction::targets() /*! \qmlproperty list<Object> PropertyAction::exclude This property holds the objects not to be affected by this animation. - \sa matchTargets + \sa targets */ QList<QObject *> *QmlPropertyAction::exclude() { @@ -984,29 +974,12 @@ void QmlPropertyAction::setValue(const QVariant &v) } } -void QmlPropertyActionPrivate::doAction() -{ - property.write(value, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); -} - QAbstractAnimation *QmlPropertyAction::qtAnimation() { Q_D(QmlPropertyAction); return d->spa; } -void QmlPropertyAction::prepare(QmlMetaProperty &p) -{ - Q_D(QmlPropertyAction); - - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - - d->spa->setAnimAction(&d->proxy, QAbstractAnimation::KeepWhenStopped); -} - void QmlPropertyAction::transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction) @@ -1029,31 +1002,42 @@ void QmlPropertyAction::transition(QmlStateActions &actions, QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); for (int ii = 0; ii < props.count(); ++ii) props[ii] = props.at(ii).trimmed(); + if (!d->propertyName.isEmpty()) + props << d->propertyName; - bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty(); - bool hasTarget = !d->propertyName.isEmpty() || d->target; + QList<QObject*> targets = d->targets; + if (d->target) + targets.append(d->target); - if (hasSelectors && hasTarget) { - qmlInfo(this) << tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive."); - return; + bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); + + if (d->defaultProperty.isValid() && !hasSelectors) { + props << d->defaultProperty.name(); + targets << d->defaultProperty.object(); } QmlSetPropertyAnimationAction *data = new QmlSetPropertyAnimationAction; bool hasExplicit = false; - if (hasTarget && d->value.isValid()) { - QmlAction myAction; - myAction.property = d->createProperty(target(), d->propertyName, this); - if (myAction.property.isValid()) { - myAction.toValue = d->value; - data->actions << myAction; - hasExplicit = true; - for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; - if (action.property.object() == myAction.property.object() && - myAction.property.name() == action.property.name()) { - modified << action.property; - break; //### any chance there could be multiples? + //an explicit animation has been specified + if (d->value.isValid()) { + for (int i = 0; i < props.count(); ++i) { + for (int j = 0; j < targets.count(); ++j) { + QmlAction myAction; + myAction.property = d->createProperty(targets.at(j), props.at(i), this); + if (myAction.property.isValid()) { + myAction.toValue = d->value; + QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); + data->actions << myAction; + hasExplicit = true; + for (int ii = 0; ii < actions.count(); ++ii) { + QmlAction &action = actions[ii]; + if (action.property.object() == myAction.property.object() && + myAction.property.name() == action.property.name()) { + modified << action.property; + break; //### any chance there could be multiples? + } + } } } } @@ -1069,31 +1053,18 @@ void QmlPropertyAction::transition(QmlStateActions &actions, QString sPropertyName = action.specifiedProperty; bool same = (obj == sObj); - if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) && + if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) && (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) { QmlAction myAction = action; if (d->value.isValid()) myAction.toValue = d->value; + QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); modified << action.property; data->actions << myAction; action.fromValue = myAction.toValue; - } else if (d->userProperty.isValid() && - !hasSelectors && !hasTarget) { - if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) && - (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) { - //### same as above. merge - QmlAction myAction = action; - - if (d->value.isValid()) - myAction.toValue = d->value; - - modified << action.property; - data->actions << myAction; - action.fromValue = myAction.toValue; - } } } @@ -1161,24 +1132,7 @@ void QmlParentActionPrivate::init() /*! \qmlproperty Item ParentAction::target - This property holds an explicit target item to reparent. - */ -QmlGraphicsItem *QmlParentAction::object() const -{ - Q_D(const QmlParentAction); - return d->pcTarget; -} - -void QmlParentAction::setObject(QmlGraphicsItem *target) -{ - Q_D(QmlParentAction); - d->pcTarget = target; -} - -/*! - \qmlproperty Item ParentAction::matchTarget - This property holds the item this action will match against -- the item - that the action will reparent, assuming its parent has changed. + This property holds a target item to reparent. In the following example, \c myItem will be reparented by the ParentAction, while \c myOtherItem will not. @@ -1196,24 +1150,23 @@ void QmlParentAction::setObject(QmlGraphicsItem *target) Transition { SequentialAnimation { PropertyAnimation { ... } - ParentAction { matchTargets: myItem } + ParentAction { target: myItem } PropertyAnimation { ... } } } \endqml - This property is typically used for an action appearing as part of a Transition. */ -QmlGraphicsItem *QmlParentAction::matchTarget() const +QmlGraphicsItem *QmlParentAction::object() const { Q_D(const QmlParentAction); return d->pcTarget; } -void QmlParentAction::setMatchTarget(QmlGraphicsItem *target) +void QmlParentAction::setObject(QmlGraphicsItem *target) { Q_D(QmlParentAction); - d->pcMatchTarget = target; + d->pcTarget = target; } /*! @@ -1277,17 +1230,27 @@ void QmlParentAction::transition(QmlStateActions &actions, QmlParentActionData *data = new QmlParentActionData; - if (d->pcTarget && d->pcMatchTarget) { - qmlInfo(this) << tr("matchTarget and target are mutually exclusive."); - return; + //### need to correctly handle modified/done + + bool hasExplicit = false; + if (d->pcTarget && d->pcParent) { + data->reverse = false; + QmlAction myAction; + QmlParentChange *pc = new QmlParentChange; + pc->setObject(d->pcTarget); + pc->setParent(d->pcParent); + myAction.event = pc; + data->pc = pc; + data->actions << myAction; + hasExplicit = true; } + if (!hasExplicit) for (int ii = 0; ii < actions.count(); ++ii) { QmlAction &action = actions[ii]; if (action.event && action.event->typeName() == QLatin1String("ParentChange") - && !d->pcTarget - && (!d->pcMatchTarget || static_cast<QmlParentChange*>(action.event)->object() == d->pcMatchTarget)) { + && (!d->pcTarget || static_cast<QmlParentChange*>(action.event)->object() == d->pcTarget)) { QmlAction myAction = action; data->reverse = action.reverseEvent; //### this logic differs from PropertyAnimation @@ -1308,17 +1271,6 @@ void QmlParentAction::transition(QmlStateActions &actions, } } - if (d->pcTarget && d->pcParent) { - data->reverse = false; - QmlAction myAction; - QmlParentChange *pc = new QmlParentChange; - pc->setObject(d->pcTarget); - pc->setParent(d->pcParent); - myAction.event = pc; - data->pc = pc; - data->actions << myAction; - } - if (data->actions.count()) { d->cpa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped); } else { @@ -1336,7 +1288,7 @@ QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction) Animate a set of properties over 200ms, from their values in the start state to their values in the end state of the transition: \code - NumberAnimation { matchProperties: "x,y,scale"; duration: 200 } + NumberAnimation { properties: "x,y,scale"; duration: 200 } \endcode */ @@ -1376,7 +1328,7 @@ void QmlNumberAnimation::setFrom(qreal f) /*! \qmlproperty real NumberAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition. + If not set, then the value defined in the end state of the transition or Behavior. */ qreal QmlNumberAnimation::to() const { @@ -1434,7 +1386,7 @@ void QmlVector3dAnimation::setFrom(QVector3D f) /*! \qmlproperty real Vector3dAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition. + If not set, then the value defined in the end state of the transition or Behavior. */ QVector3D QmlVector3dAnimation::to() const { @@ -1449,6 +1401,177 @@ void QmlVector3dAnimation::setTo(QVector3D t) QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation) +/*! + \qmlclass RotationAnimation QmlRotationAnimation + \inherits PropertyAnimation + \brief The RotationAnimation element allows you to animate rotations. + + RotationAnimation is a specialized PropertyAnimation that gives control + over the direction of rotation. + + The RotationAnimation in the following example ensures that we always take + the shortest rotation path when switching between our states. + \qml + states: { + State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } } + State { name: "-180"; PropertyChanges { target: myItem; rotation: -180 } } + State { name: "180"; PropertyChanges { target: myItem; rotation: 270 } } + } + transition: Transition { + RotationAnimation { direction: RotationAnimation.Shortest } + } + \endqml + + By default, when used in a transition RotationAnimation will rotate all + properties named "rotation" or "angle". You can override this by providing + your own properties via \c properties or \c property. +*/ + +/*! + \internal + \class QmlRotationAnimation +*/ + +QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress) +{ + qreal newt = t; + qreal diff = t-f; + while(diff > 180.0){ + newt -= 360.0; + diff -= 360.0; + } + while(diff < -180.0){ + newt += 360.0; + diff += 360.0; + } + return QVariant(f + (newt - f) * progress); +} + +QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress) +{ + qreal newt = t; + qreal diff = t-f; + while(diff < 0.0){ + newt += 360.0; + diff += 360.0; + } + return QVariant(f + (newt - f) * progress); +} + +QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress) +{ + qreal newt = t; + qreal diff = t-f; + while(diff > 0.0){ + newt -= 360.0; + diff -= 360.0; + } + return QVariant(f + (newt - f) * progress); +} + +QmlRotationAnimation::QmlRotationAnimation(QObject *parent) +: QmlPropertyAnimation(*(new QmlRotationAnimationPrivate), parent) +{ + Q_D(QmlRotationAnimation); + d->interpolatorType = QMetaType::QReal; + d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation); + d->defaultProperties = QLatin1String("rotation,angle"); +} + +QmlRotationAnimation::~QmlRotationAnimation() +{ +} + +/*! + \qmlproperty real RotationAnimation::from + This property holds the starting value. + If not set, then the value defined in the start state of the transition. +*/ +qreal QmlRotationAnimation::from() const +{ + Q_D(const QmlRotationAnimation); + return d->from.toReal(); +} + +void QmlRotationAnimation::setFrom(qreal f) +{ + QmlPropertyAnimation::setFrom(f); +} + +/*! + \qmlproperty real RotationAnimation::to + This property holds the ending value. + If not set, then the value defined in the end state of the transition or Behavior. +*/ +qreal QmlRotationAnimation::to() const +{ + Q_D(const QmlRotationAnimation); + return d->to.toReal(); +} + +void QmlRotationAnimation::setTo(qreal t) +{ + QmlPropertyAnimation::setTo(t); +} + +/*! + \qmlproperty enum RotationAnimation::direction + The direction in which to rotate. + Possible values are Numerical, Clockwise, Counterclockwise, + or Shortest. + + \list + \row + \o Numerical + \o Rotate by linearly interpolating between the two numbers. + A rotation from 10 to 350 will rotate 340 degrees clockwise. + \row + \o Clockwise + \o Rotate clockwise between the two values + \row + \o Counterclockwise + \o Rotate counterclockwise between the two values + \row + \o Shortest + \o Rotate in the direction that produces the shortest animation path. + A rotation from 10 to 350 will rotate 20 degrees counterclockwise. + \list + + The default direction is Shortest. +*/ +QmlRotationAnimation::RotationDirection QmlRotationAnimation::direction() const +{ + Q_D(const QmlRotationAnimation); + return d->direction; +} + +void QmlRotationAnimation::setDirection(QmlRotationAnimation::RotationDirection direction) +{ + Q_D(QmlRotationAnimation); + if (d->direction == direction) + return; + + d->direction = direction; + switch(d->direction) { + case Clockwise: + d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateClockwiseRotation); + break; + case Counterclockwise: + d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateCounterclockwiseRotation); + break; + case Shortest: + d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation); + break; + default: + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); + break; + } + + emit directionChanged(); +} + +QML_DEFINE_TYPE(Qt,4,6,RotationAnimation,QmlRotationAnimation) + QmlAnimationGroup::QmlAnimationGroup(QObject *parent) : QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent) { @@ -1495,18 +1618,6 @@ QmlSequentialAnimation::~QmlSequentialAnimation() { } -void QmlSequentialAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlAnimationGroup); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - - for (int i = 0; i < d->animations.size(); ++i) - d->animations.at(i)->prepare(d->property); -} - QAbstractAnimation *QmlSequentialAnimation::qtAnimation() { Q_D(QmlAnimationGroup); @@ -1526,13 +1637,10 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions, from = d->animations.count() - 1; } - //needed for Behavior - if (d->userProperty.isValid()) { - for (int i = 0; i < d->animations.count(); ++i) - d->animations.at(i)->setTarget(d->userProperty); - } - + bool valid = d->defaultProperty.isValid(); for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) { + if (valid) + d->animations.at(ii)->setDefaultTarget(d->defaultProperty); d->animations.at(ii)->transition(actions, modified, direction); } } @@ -1574,18 +1682,6 @@ QmlParallelAnimation::~QmlParallelAnimation() { } -void QmlParallelAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlAnimationGroup); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - - for (int i = 0; i < d->animations.size(); ++i) - d->animations.at(i)->prepare(d->property); -} - QAbstractAnimation *QmlParallelAnimation::qtAnimation() { Q_D(QmlAnimationGroup); @@ -1597,14 +1693,10 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, TransitionDirection direction) { Q_D(QmlAnimationGroup); - - //needed for Behavior - if (d->userProperty.isValid()) { - for (int i = 0; i < d->animations.count(); ++i) - d->animations.at(i)->setTarget(d->userProperty); - } - + bool valid = d->defaultProperty.isValid(); for (int ii = 0; ii < d->animations.count(); ++ii) { + if (valid) + d->animations.at(ii)->setDefaultTarget(d->defaultProperty); d->animations.at(ii)->transition(actions, modified, direction); } } @@ -1668,12 +1760,56 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) \inherits Animation \brief The PropertyAnimation element allows you to animate property changes. - Animate theObject's size property over 200ms, from its current size to 20-by-20: - \code + PropertyAnimation provides a way to animate changes to a property's value. It can + be used in many different situations: + \list + \o In a Transition + + Animate any objects that have changed their x or y properties in the target state using + an InOutQuad easing curve: + \qml + Transition { PropertyAnimation { properties: "x,y"; easing: "InOutQuad" } } + \endqml + \o In a Behavior + + Animate all changes to a rectangle's x property. + \qml + Rectangle { + x: Behavior { PropertyAnimation {} } + } + \endqml + \o As a property value source + + Repeatedly animate the rectangle's x property. + \qml + Rectangle { + x: SequentialAnimation { + repeat: true + PropertyAnimation { to: 50 } + PropertyAnimation { to: 0 } + } + } + \endqml + \o In a signal handler + + Fade out \c theObject when clicked: + \qml + MouseRegion { + anchors.fill: theObject + onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 } + } + \endqml + \o Standalone + + Animate \c theObject's size property over 200ms, from its current size to 20-by-20: + \qml PropertyAnimation { target: theObject; property: "size"; to: "20x20"; duration: 200 } - \endcode + \endqml + \endlist - For an introduction to animation in QML, see \l{QML Animation}. + Depending on how the animation is used, the set of properties normally used will be + different. For more information see the individual property documentation, as well + as the \l{QML Animation} introduction. */ QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent) @@ -1683,6 +1819,13 @@ QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent) d->init(); } +QmlPropertyAnimation::QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent) +: QmlAbstractAnimation(dd, parent) +{ + Q_D(QmlPropertyAnimation); + d->init(); +} + QmlPropertyAnimation::~QmlPropertyAnimation() { } @@ -1744,7 +1887,7 @@ void QmlPropertyAnimation::setFrom(const QVariant &f) /*! \qmlproperty real PropertyAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition. + If not set, then the value defined in the end state of the transition or Behavior. */ QVariant QmlPropertyAnimation::to() const { @@ -1955,16 +2098,6 @@ void QmlPropertyAnimation::setEasing(const QString &e) emit easingChanged(e); } -/*! - \qmlproperty Object PropertyAnimation::target - This property holds an explicit target object to animate. - - target is used in conjunction with property to determine - what property should be animated. - - \sa property matchTargets -*/ - QObject *QmlPropertyAnimation::target() const { Q_D(const QmlPropertyAnimation); @@ -1976,27 +2109,10 @@ void QmlPropertyAnimation::setTarget(QObject *o) Q_D(QmlPropertyAnimation); if (d->target == o) return; - d->target = o; - if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName, this); - } else { - d->userProperty.invalidate(); - } - emit targetChanged(d->target, d->propertyName); } -/*! - \qmlproperty string PropertyAnimation::property - This property holds an explicit property name to animate. - - property is used in conjunction with target to determine - what property should be animated. - - \sa target matchProperties -*/ - QString QmlPropertyAnimation::property() const { Q_D(const QmlPropertyAnimation); @@ -2008,46 +2124,10 @@ void QmlPropertyAnimation::setProperty(const QString &n) Q_D(QmlPropertyAnimation); if (d->propertyName == n) return; - d->propertyName = n; - if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName, this); - } else { - d->userProperty.invalidate(); - } - emit targetChanged(d->target, d->propertyName); } -/*! - \qmlproperty string PropertyAnimation::matchProperties - This property holds a comma-separated list of property names this animation - will match against. These names are used in conjunction with matchTargets - to create a list of properties that the animation will animate, assuming those - properties have changed. - - In the following example, the change in 'x' will be animated by the transition, while - the change in 'y' will not. - \qml - State { - PropertyChanges { - target: myItem - x: 15; y: 15 - } - } - Transition { - PropertyAnimation { - matchProperties: "x" - } - } - \endqml - - This property is typically used for an animation appearing as part of a Transition. - - By default, no property names will be matched. - - \sa matchTargets PropertyAction::matchTargets -*/ QString QmlPropertyAnimation::properties() const { Q_D(const QmlPropertyAnimation); @@ -2065,37 +2145,86 @@ void QmlPropertyAnimation::setProperties(const QString &prop) } /*! - \qmlproperty list<Object> PropertyAnimation::matchTargets - This property holds a list of objects this animation will match against. - These objects are used in conjunction with matchProperties to create a list of properties - that the animation will animate, assuming those properties have changed. + \qmlproperty string PropertyAnimation::property + \qmlproperty string PropertyAnimation::properties + \qmlproperty Object PropertyAnimation::target + \qmlproperty list<Object> PropertyAnimation::targets - In the following example, the changes to \c myItem will be animated by the transition, while - the changes to \c myOtherItem will not. + These properties are used as a set to determine which properties should be animated. + The singular and plural forms are functionally identical, e.g. \qml - State { - PropertyChanges { - target: myItem - x: 15; y: 15 - } - PropertyChanges { - target: myOtherItem - x: 30; y: 30 - } - } - Transition { - PropertyAnimation { - matchTargets: myItem - matchProperties: "x,y" - } - } + NumberAnimation { target: theItem; property: "x"; to: 500 } + \endqml + has the same meaning as + \qml + NumberAnimation { targets: theItem; properties: "x"; to: 500 } \endqml + The singular forms are slightly optimized, so if you do have only a single target/property + to animate you should try to use them. - This property is typically used for an animation appearing as part of a Transition. + In many cases these properties do not need to be explicitly specified -- they can be + inferred from the animation framework. + \table 80% + \row + \o Value Source / Behavior + \o When an animation is used as a value source or in a Behavior, the default target and property + name to be animated can both be inferred. + \qml + Rectangle { + id: theRect + width: 100; height: 100 + color: Qt.rgba(0,0,1) + x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property + y: Behavior { NumberAnimation {} } //animate theRect's y property + } + \endqml + \row + \o Transition + \o When used in a transition, a property animation is assumed to match \e all targets + but \e no properties. In practice, that means you need to specify at least the properties + in order for the animation to do anything. + \qml + Rectangle { + id: theRect + width: 100; height: 100 + color: Qt.rgba(0,0,1) + Item { id: uselessItem } + states: State { + name: "state1" + PropertyChanges { target: theRect; x: 200; y: 200; z: 4 } + PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 } + } + transitions: Transition { + //animate both theRect's and uselessItem's x and y to their final values + NumberAnimation { properties: "x,y" } - By default, all changing targets will be matched. - - \sa exclude matchProperties + //animate theRect's z to its final value + NumberAnimation { target: theRect; property: "z" } + } + } + \endqml + \row + \o Standalone + \o When an animation is used standalone, both the target and property need to be + explicitly specified. + \qml + Rectangle { + id: theRect + width: 100; height: 100 + color: Qt.rgba(0,0,1) + //need to explicitly specify target and property + NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 } + MouseRegion { + anchors.fill: parent + onClicked: theAnim.start() + } + } + \endqml + \endtable + + As seen in the above example, properties is specified as a comma-separated string of property names to animate. + + \sa exclude */ QList<QObject *> *QmlPropertyAnimation::targets() { @@ -2106,7 +2235,7 @@ QList<QObject *> *QmlPropertyAnimation::targets() /*! \qmlproperty list<Object> PropertyAnimation::exclude This property holds the items not to be affected by this animation. - \sa matchTargets + \sa targets */ QList<QObject *> *QmlPropertyAnimation::exclude() { @@ -2114,152 +2243,119 @@ QList<QObject *> *QmlPropertyAnimation::exclude() return &d->exclude; } -void QmlPropertyAnimationPrivate::valueChanged(qreal r) -{ - if (!fromSourced) { - if (!fromIsDefined) { - from = property.read(); - convertVariant(from, interpolatorType ? interpolatorType : property.propertyType()); - //### check for invalid variant if using property type - } - fromSourced = true; - } - - if (r == 1.) { - property.write(to, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); - } else { - if (interpolator) - property.write(interpolator(from.constData(), to.constData(), r), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); - } -} - QAbstractAnimation *QmlPropertyAnimation::qtAnimation() { Q_D(QmlPropertyAnimation); return d->va; } -void QmlPropertyAnimation::prepare(QmlMetaProperty &p) +struct PropertyUpdater : public QmlTimeLineValue { - Q_D(QmlPropertyAnimation); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - - if (!d->rangeIsSet) { - d->va->setStartValue(qreal(0)); - d->va->setEndValue(qreal(1)); - d->rangeIsSet = true; - } - - int propType = d->property.propertyType(); - d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : propType); - if (d->fromIsDefined) - d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : propType); - - if (!d->interpolatorType) { - //### check for invalid variants - d->interpolator = QVariantAnimationPrivate::getInterpolator(propType); + QmlStateActions actions; + int interpolatorType; //for Number/ColorAnimation + int prevInterpolatorType; //for generic + QVariantAnimation::Interpolator interpolator; + bool reverse; + bool fromSourced; + bool fromDefined; + bool *wasDeleted; + PropertyUpdater() : wasDeleted(0) {} + ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; } + void setValue(qreal v) + { + bool deleted = false; + wasDeleted = &deleted; + if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 + v = 1 - v; + QmlTimeLineValue::setValue(v); + for (int ii = 0; ii < actions.count(); ++ii) { + QmlAction &action = actions[ii]; + + if (v == 1.) + action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + else { + if (!fromSourced && !fromDefined) { + action.fromValue = action.property.read(); + if (interpolatorType) + QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); + } + if (!interpolatorType) { + int propType = action.property.propertyType(); + if (!prevInterpolatorType || prevInterpolatorType != propType) { + prevInterpolatorType = propType; + interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); + } + } + if (interpolator) + action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + } + if (deleted) + return; + } + wasDeleted = 0; + fromSourced = true; } - - d->fromSourced = false; - d->value.QmlTimeLineValue::setValue(0.); - d->va->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); - d->va->setFromSourcedValue(&d->fromSourced); -} +}; void QmlPropertyAnimation::transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction) { Q_D(QmlPropertyAnimation); - Q_UNUSED(direction); - - struct PropertyUpdater : public QmlTimeLineValue - { - QmlStateActions actions; - int interpolatorType; //for Number/ColorAnimation - int prevInterpolatorType; //for generic - QVariantAnimation::Interpolator interpolator; - bool reverse; - bool *wasDeleted; - PropertyUpdater() : wasDeleted(0) {} - ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; } - void setValue(qreal v) - { - bool deleted = false; - wasDeleted = &deleted; - if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 - v = 1 - v; - QmlTimeLineValue::setValue(v); - for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; - - if (v == 1.) - action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); - else { - if (action.fromValue.isNull()) { - action.fromValue = action.property.read(); - if (interpolatorType) - QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); - } - if (!interpolatorType) { - int propType = action.property.propertyType(); - if (!prevInterpolatorType || prevInterpolatorType != propType) { - prevInterpolatorType = propType; - interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); - } - } - if (interpolator) - action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); - } - if (deleted) - return; - } - wasDeleted = 0; - } - }; QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); for (int ii = 0; ii < props.count(); ++ii) props[ii] = props.at(ii).trimmed(); + if (!d->propertyName.isEmpty()) + props << d->propertyName; - bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty(); - bool hasTarget = !d->propertyName.isEmpty() || d->target; + QList<QObject*> targets = d->targets; + if (d->target) + targets.append(d->target); - if (hasSelectors && hasTarget) { - qmlInfo(this) << tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive."); - return; + bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); + bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false; + + if (d->defaultProperty.isValid() && !hasSelectors) { + props << d->defaultProperty.name(); + targets << d->defaultProperty.object(); } - bool useType = (props.isEmpty() && d->propertyName.isEmpty() && d->defaultToInterpolatorType) ? true : false; + if (props.isEmpty() && !d->defaultProperties.isEmpty()) { + props << d->defaultProperties.split(QLatin1Char(',')); + } PropertyUpdater *data = new PropertyUpdater; data->interpolatorType = d->interpolatorType; data->interpolator = d->interpolator; data->reverse = direction == Backward ? true : false; + data->fromSourced = false; + data->fromDefined = d->fromIsDefined; bool hasExplicit = false; //an explicit animation has been specified - if (hasTarget && d->toIsDefined) { - QmlAction myAction; - myAction.property = d->createProperty(target(), d->propertyName, this); - if (myAction.property.isValid()) { - if (d->fromIsDefined) { - d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - myAction.fromValue = d->from; - } - d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - myAction.toValue = d->to; - data->actions << myAction; - hasExplicit = true; - for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; - if (action.property.object() == myAction.property.object() && - myAction.property.name() == action.property.name()) { - modified << action.property; - break; //### any chance there could be multiples? + if (d->toIsDefined) { + for (int i = 0; i < props.count(); ++i) { + for (int j = 0; j < targets.count(); ++j) { + QmlAction myAction; + myAction.property = d->createProperty(targets.at(j), props.at(i), this); + if (myAction.property.isValid()) { + if (d->fromIsDefined) { + myAction.fromValue = d->from; + d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); + } + myAction.toValue = d->to; + d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); + data->actions << myAction; + hasExplicit = true; + for (int ii = 0; ii < actions.count(); ++ii) { + QmlAction &action = actions[ii]; + if (action.property.object() == myAction.property.object() && + myAction.property.name() == action.property.name()) { + modified << action.property; + break; //### any chance there could be multiples? + } + } } } } @@ -2275,7 +2371,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, QString sPropertyName = action.specifiedProperty; bool same = (obj == sObj); - if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) && + if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) && (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && (props.contains(propertyName) || (!same && props.contains(sPropertyName)) || (useType && action.property.propertyType() == d->interpolatorType))) { @@ -2295,29 +2391,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, data->actions << myAction; action.fromValue = myAction.toValue; - } else if (d->userProperty.isValid() && - !hasSelectors && !hasTarget) { - if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) && - (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) { - //### same as above. merge - QmlAction myAction = action; - - if (d->fromIsDefined) - myAction.fromValue = d->from; - else - myAction.fromValue = QVariant(); - if (d->toIsDefined) - myAction.toValue = d->to; - - d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - - modified << action.property; - - data->actions << myAction; - action.fromValue = myAction.toValue; - } - } + } } if (data->actions.count()) { @@ -2327,6 +2401,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, d->rangeIsSet = true; } d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); + d->va->setFromSourcedValue(&data->fromSourced); } else { delete data; } diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index f9bbdf9..50eb577 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -94,7 +94,8 @@ public: QmlAnimationGroup *group() const; void setGroup(QmlAnimationGroup *); - virtual void setTarget(const QmlMetaProperty &); + void setDefaultTarget(const QmlMetaProperty &); + void setDisableUserControl(); void classBegin(); void componentComplete(); @@ -123,11 +124,13 @@ public: virtual void transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction); - virtual void prepare(QmlMetaProperty &); virtual QAbstractAnimation *qtAnimation() = 0; private Q_SLOTS: void timelineComplete(); + +private: + virtual void setTarget(const QmlMetaProperty &); }; class QmlPauseAnimationPrivate; @@ -186,8 +189,8 @@ class QmlPropertyAction : public QmlAbstractAnimation Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) - Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList<QObject *>* matchTargets READ targets) + Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) + Q_PROPERTY(QList<QObject *>* targets READ targets) Q_PROPERTY(QList<QObject *>* exclude READ exclude) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) @@ -220,7 +223,6 @@ protected: QmlMetaProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); }; class QmlGraphicsItem; @@ -231,8 +233,7 @@ class QmlParentAction : public QmlAbstractAnimation Q_DECLARE_PRIVATE(QmlParentAction) Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject) - Q_PROPERTY(QmlGraphicsItem *matchTarget READ matchTarget WRITE setMatchTarget) - Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent) + Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent) //### newParent public: QmlParentAction(QObject *parent=0); @@ -241,9 +242,6 @@ public: QmlGraphicsItem *object() const; void setObject(QmlGraphicsItem *); - QmlGraphicsItem *matchTarget() const; - void setMatchTarget(QmlGraphicsItem *); - QmlGraphicsItem *parent() const; void setParent(QmlGraphicsItem *); @@ -266,8 +264,8 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) - Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList<QObject *>* matchTargets READ targets) + Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) + Q_PROPERTY(QList<QObject *>* targets READ targets) Q_PROPERTY(QList<QObject *>* exclude READ exclude) public: @@ -299,11 +297,11 @@ public: QList<QObject *> *exclude(); protected: + QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent); virtual void transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); Q_SIGNALS: void durationChanged(int); @@ -370,6 +368,35 @@ public: void setTo(QVector3D); }; +class QmlRotationAnimationPrivate; +class Q_AUTOTEST_EXPORT QmlRotationAnimation : public QmlPropertyAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlRotationAnimation) + Q_ENUMS(RotationDirection) + + Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) + Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) + Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) + +public: + QmlRotationAnimation(QObject *parent=0); + virtual ~QmlRotationAnimation(); + + qreal from() const; + void setFrom(qreal); + + qreal to() const; + void setTo(qreal); + + enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise }; + RotationDirection direction() const; + void setDirection(RotationDirection direction); + +Q_SIGNALS: + void directionChanged(); +}; + class QmlAnimationGroupPrivate; class QmlAnimationGroup : public QmlAbstractAnimation { @@ -401,7 +428,6 @@ protected: QmlMetaProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); }; class QmlParallelAnimation : public QmlAnimationGroup @@ -418,7 +444,6 @@ protected: QmlMetaProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); }; QT_END_NAMESPACE @@ -434,6 +459,7 @@ QML_DECLARE_TYPE(QmlNumberAnimation) QML_DECLARE_TYPE(QmlSequentialAnimation) QML_DECLARE_TYPE(QmlParallelAnimation) QML_DECLARE_TYPE(QmlVector3dAnimation) +QML_DECLARE_TYPE(QmlRotationAnimation) QT_END_HEADER diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index 1fe0375..b2ce297 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -108,6 +108,8 @@ public: { if (state() == Running) stop(); + if (policy == DeleteWhenStopped) + delete animAction; animAction = action; policy = p; } @@ -126,12 +128,12 @@ protected: animAction = 0; } } - } else if (newState == Stopped && policy == DeleteWhenStopped) { + } /*else if (newState == Stopped && policy == DeleteWhenStopped) { if (!running) { delete animAction; animAction = 0; } - } + }*/ } private: @@ -151,6 +153,8 @@ public: { if (state() == Running) stop(); + if (policy == DeleteWhenStopped) + delete animValue; animValue = value; policy = p; } @@ -165,16 +169,17 @@ protected: animValue->setValue(value.toReal()); } virtual void updateState(State newState, State oldState) - { + { QVariantAnimation::updateState(newState, oldState); if (newState == Running) { //check for new from every loop if (fromSourced) *fromSourced = false; - } else if (newState == Stopped && policy == DeleteWhenStopped) { + } /*else if (newState == Stopped && policy == DeleteWhenStopped) { delete animValue; animValue = 0; - } + }*/ //### we get a stop each loop if we are in a group + //### top-level animation is the only reliable one for this } private: @@ -204,24 +209,22 @@ class QmlAbstractAnimationPrivate : public QObjectPrivate public: QmlAbstractAnimationPrivate() : running(false), paused(false), alwaysRunToEnd(false), repeat(false), - connectedTimeLine(false), componentComplete(true), startOnCompletion(false), - avoidPropertyValueSourceStart(false), group(0) {} + connectedTimeLine(false), componentComplete(true), + avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {} bool running:1; bool paused:1; bool alwaysRunToEnd:1; bool repeat:1; bool connectedTimeLine:1; - bool componentComplete:1; - bool startOnCompletion:1; bool avoidPropertyValueSourceStart:1; + bool disableUserControl:1; void commence(); - QmlNullableValue<QmlMetaProperty> userProperty; + QmlMetaProperty defaultProperty; - QmlMetaProperty property; QmlAnimationGroup *group; static QmlMetaProperty createProperty(QObject *obj, const QString &str, QObject *infoObj); @@ -265,7 +268,7 @@ class QmlPropertyActionPrivate : public QmlAbstractAnimationPrivate Q_DECLARE_PUBLIC(QmlPropertyAction) public: QmlPropertyActionPrivate() - : QmlAbstractAnimationPrivate(), target(0), proxy(this), spa(0) {} + : QmlAbstractAnimationPrivate(), target(0), spa(0) {} void init(); @@ -277,10 +280,6 @@ public: QmlNullableValue<QVariant> value; - void doAction(); - - QAnimationActionProxy<QmlPropertyActionPrivate, - &QmlPropertyActionPrivate::doAction> proxy; QActionAnimation *spa; }; @@ -289,12 +288,11 @@ class QmlParentActionPrivate : public QmlAbstractAnimationPrivate Q_DECLARE_PUBLIC(QmlParentAction) public: QmlParentActionPrivate() - : QmlAbstractAnimationPrivate(), pcTarget(0), pcMatchTarget(0), pcParent(0) {} + : QmlAbstractAnimationPrivate(), pcTarget(0), pcParent(0) {} void init(); QmlGraphicsItem *pcTarget; - QmlGraphicsItem *pcMatchTarget; QmlGraphicsItem *pcParent; void doAction(); @@ -346,8 +344,7 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate public: QmlPropertyAnimationPrivate() : QmlAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false), - rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0), - value(this, &QmlPropertyAnimationPrivate::valueChanged) {} + rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0) {} void init(); @@ -361,6 +358,7 @@ public: QString properties; QList<QObject *> targets; QList<QObject *> exclude; + QString defaultProperties; bool fromSourced; bool fromIsDefined:1; @@ -371,14 +369,20 @@ public: QVariantAnimation::Interpolator interpolator; QmlTimeLineValueAnimator *va; - virtual void valueChanged(qreal); - - QmlTimeLineValueProxy<QmlPropertyAnimationPrivate> value; static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress); static void convertVariant(QVariant &variant, int type); }; +class QmlRotationAnimationPrivate : public QmlPropertyAnimationPrivate +{ + Q_DECLARE_PUBLIC(QmlRotationAnimation) +public: + QmlRotationAnimationPrivate() : direction(QmlRotationAnimation::Shortest) {} + + QmlRotationAnimation::RotationDirection direction; +}; + QT_END_NAMESPACE #endif // QMLANIMATION_P_H diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp index 2367694..d65d8cd 100644 --- a/src/declarative/util/qmlbehavior.cpp +++ b/src/declarative/util/qmlbehavior.cpp @@ -124,8 +124,10 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation) } d->animation = animation; - if (d->animation) - d->animation->setTarget(d->property); + if (d->animation) { + d->animation->setDefaultTarget(d->property); + d->animation->setDisableUserControl(); + } } /*! @@ -183,7 +185,7 @@ void QmlBehavior::setTarget(const QmlMetaProperty &property) d->property = property; d->currentValue = property.read(); if (d->animation) - d->animation->setTarget(property); + d->animation->setDefaultTarget(property); } QT_END_NAMESPACE diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index ee35d2e..af41dfd 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -806,7 +806,23 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL qvariant_cast<QmlParser::Variant>(value); int ref = data.count(); - QByteArray d = variant.asScript().toUtf8(); + + QByteArray d; + d += char(variant.type()); // type tag + if (variant.isString()) { + d += variant.asString().toUtf8(); + } else if (variant.isNumber()) { + d += QByteArray::number(variant.asNumber(),'g',20); + } else if (variant.isBoolean()) { + d += char(variant.asBoolean()); + } else if (variant.isScript()) { + if (definesEmptyList(variant.asScript())) { + d[0] = 0; // QmlParser::Variant::Invalid - marks empty list + } else { + error(prop, QmlListModel::tr("ListElement: cannot use script for property value")); + return false; + } + } d.append('\0'); data.append(d); @@ -814,7 +830,6 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL li.type = ListInstruction::Value; li.dataIdx = ref; instr << li; - } } @@ -892,15 +907,22 @@ void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) case ListInstruction::Value: { ModelNode *n = nodes.top(); - QString s = QString::fromUtf8(QByteArray(data + instr.dataIdx)); - - bool isEmptyList = false; - if (!n->isArray) - isEmptyList = definesEmptyList(s); - if (isEmptyList) + switch (QmlParser::Variant::Type(data[instr.dataIdx])) { + case QmlParser::Variant::Invalid: n->isArray = true; - else - n->values.append(s); + break; + case QmlParser::Variant::Boolean: + n->values.append(bool(data[1 + instr.dataIdx])); + break; + case QmlParser::Variant::Number: + n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble()); + break; + case QmlParser::Variant::String: + n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx)); + break; + default: + Q_ASSERT("Format error in ListInstruction"); + } processingSet = false; } diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index f833501..56903ce 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -41,11 +41,13 @@ #include "qmlpixmapcache_p.h" #include "qmlnetworkaccessmanagerfactory.h" +#include "qmlimageprovider.h" #include "qfxperf_p_p.h" #include <qmlengine.h> #include <private/qmlglobal_p.h> +#include <private/qmlengine_p.h> #include <QCoreApplication> #include <QImageReader> @@ -82,7 +84,7 @@ class QmlImageReaderEvent : public QEvent public: enum ReadError { NoError, Loading, Decoding }; - QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, QImage &img) + QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, const QImage &img) : QEvent(QEvent::User), error(err), errorString(errStr), image(img) {} ReadError error; @@ -143,13 +145,8 @@ private slots: private: QNetworkAccessManager *networkAccessManager() { - if (!accessManager) { - if (engine && engine->networkAccessManagerFactory()) { - accessManager = engine->networkAccessManagerFactory()->create(this); - } else { - accessManager = new QNetworkAccessManager(this); - } - } + if (!accessManager) + accessManager = QmlEnginePrivate::get(engine)->createNetworkAccessManager(this); return accessManager; } @@ -197,21 +194,32 @@ bool QmlImageRequestHandler::event(QEvent *event) break; } - QmlPixmapReply *runningJob = reader->jobs.takeFirst(); + QmlPixmapReply *runningJob = reader->jobs.takeLast(); runningJob->addRef(); runningJob->setLoading(); QUrl url = runningJob->url(); reader->mutex.unlock(); // fetch - QNetworkRequest req(url); - req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - QNetworkReply *reply = networkAccessManager()->get(req); + if (url.scheme() == QLatin1String("image")) { + QImage image = QmlEnginePrivate::get(engine)->getImageFromProvider(url); + QmlImageReaderEvent::ReadError errorCode = QmlImageReaderEvent::NoError; + QString errorStr; + if (image.isNull()) { + errorCode = QmlImageReaderEvent::Loading; + errorStr = QLatin1String("Failed to get image from provider: ") + url.toString(); + } + QCoreApplication::postEvent(runningJob, new QmlImageReaderEvent(errorCode, errorStr, image)); + } else { + QNetworkRequest req(url); + req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); + QNetworkReply *reply = networkAccessManager()->get(req); - QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress); - QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone); + QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress); + QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone); - replies.insert(reply, runningJob); + replies.insert(reply, runningJob); + } } return true; } @@ -259,12 +267,12 @@ QmlImageReader::QmlImageReader(QmlEngine *eng) QmlImageReader::~QmlImageReader() { - quit(); - wait(); readerMutex.lock(); readers.remove(engine); readerMutex.unlock(); - delete handler; + + quit(); + wait(); } QmlImageReader *QmlImageReader::instance(QmlEngine *engine) @@ -327,6 +335,9 @@ void QmlImageReader::run() handler = new QmlImageRequestHandler(this, engine); exec(); + + delete handler; + handler = 0; } //=========================================================================== @@ -600,6 +611,6 @@ int QmlPixmapCache::pendingRequests() return qmlActivePixmapReplies()->count(); } -#include <qmlpixmapcache.moc> - QT_END_NAMESPACE + +#include <qmlpixmapcache.moc> diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index c53b0e5..d289e17 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -55,8 +55,6 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup) - class QmlStateGroupPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlStateGroup) @@ -421,3 +419,5 @@ void QmlStateGroup::removeState(QmlState *state) } QT_END_NAMESPACE + +QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup) diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index d1b2339..bd1f5f0 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -403,7 +403,7 @@ QString QmlStateChangeScript::typeName() const so you can animate them as you would normally changes to these properties: \qml //animate our anchor changes - NumberAnimation { matchTargets: content; matchProperties: "x,y,width,height" } + NumberAnimation { targets: content; properties: "x,y,width,height" } \endqml For more information on anchors see \l {anchor-layout}{Anchor Layouts}. diff --git a/src/declarative/util/qmlstyledtext.cpp b/src/declarative/util/qmlstyledtext.cpp index 1dc7bce..1f31214 100644 --- a/src/declarative/util/qmlstyledtext.cpp +++ b/src/declarative/util/qmlstyledtext.cpp @@ -58,6 +58,8 @@ The opening and closing tags must be correctly nested. */ +QT_BEGIN_NAMESPACE + class QmlStyledTextPrivate { public: @@ -341,3 +343,5 @@ QStringRef QmlStyledTextPrivate::parseValue(const QChar *&ch, const QString &tex return QStringRef(&textIn, valStart, valLength); } + +QT_END_NAMESPACE diff --git a/src/declarative/util/qmlstyledtext_p.h b/src/declarative/util/qmlstyledtext_p.h index a746594..4698279 100644 --- a/src/declarative/util/qmlstyledtext_p.h +++ b/src/declarative/util/qmlstyledtext_p.h @@ -44,10 +44,13 @@ #include <QSizeF> +QT_BEGIN_NAMESPACE + class QPainter; class QPointF; class QString; class QmlStyledTextPrivate; + class Q_DECLARATIVE_EXPORT QmlStyledText { public: @@ -60,4 +63,6 @@ private: QmlStyledTextPrivate *d; }; +QT_END_NAMESPACE + #endif diff --git a/src/declarative/util/qmltimeline_p_p.h b/src/declarative/util/qmltimeline_p_p.h index f335e7d..f271a3f 100644 --- a/src/declarative/util/qmltimeline_p_p.h +++ b/src/declarative/util/qmltimeline_p_p.h @@ -154,14 +154,6 @@ public: QmlTimeLineEvent(const QmlTimeLineEvent &o); template<class T, void (T::*method)()> - QmlTimeLineEvent(QmlTimeLineObject *b, T *c) - { - d0 = &callFunc<T, method>; - d1 = (void *)c; - d2 = b; - } - - template<class T, void (T::*method)()> static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c) { QmlTimeLineEvent rv; diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index 22826ce..e4e53d6 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -86,6 +86,7 @@ public: , reversed(false), reversible(false), endState(0) { animations.parent = this; + group.trans = this; } QString fromState; @@ -95,11 +96,6 @@ public: ParallelAnimationWrapper group; QmlTransitionManager *endState; - void init() - { - group.trans = this; - } - void complete() { endState->complete(); @@ -121,6 +117,7 @@ void QmlTransitionPrivate::AnimationList::append(QmlAbstractAnimation *a) { QmlConcreteList<QmlAbstractAnimation *>::append(a); parent->group.addAnimation(a->qtAnimation()); + a->setDisableUserControl(); } void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) @@ -139,8 +136,6 @@ QML_DEFINE_TYPE(Qt,4,6,Transition,QmlTransition) QmlTransition::QmlTransition(QObject *parent) : QObject(*(new QmlTransitionPrivate), parent) { - Q_D(QmlTransition); - d->init(); } QmlTransition::~QmlTransition() diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp index 702b054..4a6d697 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qmlview.cpp @@ -64,6 +64,7 @@ #include <qboxlayout.h> #include <qbasictimer.h> #include <QtCore/qabstractanimation.h> +#include <private/qgraphicsview_p.h> QT_BEGIN_NAMESPACE @@ -125,24 +126,24 @@ void FrameBreakAnimation::updateCurrentTime(int msecs) server->frameBreak(); } -class QmlViewPrivate +class QmlViewPrivate : public QGraphicsViewPrivate { + Q_DECLARE_PUBLIC(QmlView) public: - QmlViewPrivate(QmlView *w) - : q(w), root(0), component(0), resizable(false) {} + QmlViewPrivate() + : root(0), component(0), resizeMode(QmlView::SizeViewToRootObject) {} - QmlView *q; - QmlGraphicsItem *root; + QGuard<QGraphicsObject> root; + QGuard<QmlGraphicsItem> qmlRoot; QUrl source; - QString qml; QmlEngine engine; QmlComponent *component; QBasicTimer resizetimer; - QSize initialSize; - bool resizable; + mutable QSize initialSize; + QmlView::ResizeMode resizeMode; QTime frameTimer; void init(); @@ -154,9 +155,30 @@ public: \class QmlView \brief The QmlView class provides a widget for displaying a Qt Declarative user interface. - QmlView currently provides a minimal interface for displaying QML + Any QGraphicsObject or QmlGraphicsItem + created via QML can be placed on a standard QGraphicsScene and viewed with a standard + QGraphicsView. + + QmlView is a QGraphicsView subclass provided as a convenience for displaying QML files, and connecting between QML and C++ Qt objects. + QmlView performs the following functions: + + \list + \o Manages QmlComponent loading and object creation. + \o Initializes QGraphicsView for optimal performance with QML: + \list + \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState); + \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex); + \endlist + \o Initializes QGraphicsView for QML key handling: + \list + \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus); + \o QGraphicsScene::setStickyFocus(true); + \endlist + \endlist + Typical usage: \code ... @@ -164,7 +186,7 @@ public: vbox->addWidget(view); QUrl url(fileName); - view->setUrl(url); + view->setSource(url); ... view->execute(); ... @@ -172,7 +194,17 @@ public: \endcode To receive errors related to loading and executing QML with QmlView, - you can connect to the errors() signal. + you can connect to the statusChanged() signal and monitor for QmlView::Error. + The errors are available via QmlView::errors(). +*/ + + +/*! \fn void QmlView::sceneResized(QSize size) + This signal is emitted when the view is resized to \a size. +*/ + +/*! \fn void QmlView::statusChanged(QmlView::Status status) + This signal is emitted when the component's current \l{QmlView::Status} {status} changes. */ /*! @@ -181,14 +213,16 @@ public: Constructs a QmlView with the given \a parent. */ QmlView::QmlView(QWidget *parent) -: QGraphicsView(parent), d(new QmlViewPrivate(this)) +: QGraphicsView(*(new QmlViewPrivate), parent) { + Q_D(QmlView); setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); d->init(); } void QmlViewPrivate::init() { + Q_Q(QmlView); #ifdef Q_ENABLE_PERFORMANCE_LOG { QmlPerfTimer<QmlPerf::FontDatabase> perf; @@ -212,61 +246,46 @@ void QmlViewPrivate::init() } /*! - The destructor clears the view's \l {QmlGraphicsItem} {items} and + The destructor clears the view's \l {QGraphicsObject} {items} and deletes the internal representation. - - \sa clearItems() */ QmlView::~QmlView() { - clearItems(); - delete d; d = 0; + Q_D(QmlView); + delete d->root; } /*! - Sets the source to the \a url. The QML string is set to - empty. + Sets the source to the \a url. + + Call \l execute() to load the QML and instantiate the component. + + \sa execute() */ -void QmlView::setUrl(const QUrl& url) +void QmlView::setSource(const QUrl& url) { + Q_D(QmlView); d->source = url; - d->qml = QString(); } /*! Returns the source URL, if set. - \sa setUrl() + \sa setSource() */ -QUrl QmlView::url() const +QUrl QmlView::source() const { + Q_D(const QmlView); return d->source; } /*! - Sets the source to the URL from the \a filename, and sets - the QML string to \a qml. - */ -void QmlView::setQml(const QString &qml, const QString &filename) -{ - d->source = QUrl::fromLocalFile(filename); - d->qml = qml; -} - -/*! - Returns the QML string. - */ -QString QmlView::qml() const -{ - return d->qml; -} - -/*! Returns a pointer to the QmlEngine used for instantiating QML Components. */ QmlEngine* QmlView::engine() { + Q_D(QmlView); return &d->engine; } @@ -279,21 +298,21 @@ QmlEngine* QmlView::engine() */ QmlContext* QmlView::rootContext() { + Q_D(QmlView); return d->engine.rootContext(); } /*! - Displays the Qt Declarative user interface. + Loads and instantiates the QML component set by the \l setSource() method. + + \sa setSource() */ void QmlView::execute() { - if (d->qml.isEmpty()) { - d->component = new QmlComponent(&d->engine, d->source, this); - } else { - d->component = new QmlComponent(&d->engine, this); - d->component->setData(d->qml.toUtf8(), d->source); - } - connect (&d->engine, SIGNAL (quit ()), this, SIGNAL (quit ())); + Q_D(QmlView); + delete d->root; + delete d->component; + d->component = new QmlComponent(&d->engine, d->source, this); if (!d->component->isLoading()) { continueExecute(); @@ -302,26 +321,100 @@ void QmlView::execute() } } +/*! + \enum QmlView::Status + + Specifies the loading status of the QmlView. + + \value Null This QmlView has no source set. + \value Ready This QmlView has loaded and created the QML component. + \value Loading This QmlView is loading network data. + \value Error An error has occured. Calling errorDescription() to retrieve a description. +*/ + +/*! + \property QmlView::status + The component's current \l{QmlView::Status} {status}. +*/ + +QmlView::Status QmlView::status() const +{ + Q_D(const QmlView); + if (!d->component) + return QmlView::Null; + + return QmlView::Status(d->component->status()); +} + +/*! + Return the list of errors that occured during the last compile or create + operation. An empty list is returned if isError() is not set. +*/ +QList<QmlError> QmlView::errors() const +{ + Q_D(const QmlView); + if (d->component) + return d->component->errors(); + return QList<QmlError>(); +} + + +/*! + \property QmlView::resizeMode + \brief whether the view should resize the canvas contents + + If this property is set to SizeViewToRootObject (the default), the view + resizes with the root item in the QML. + + If this property is set to SizeRootObjectToView, the view will + automatically resize the root item. + + Regardless of this property, the sizeHint of the view + is the initial size of the root item. Note though that + since QML may load dynamically, that size may change. + + \sa initialSize() +*/ + +void QmlView::setResizeMode(ResizeMode mode) +{ + Q_D(QmlView); + if (d->resizeMode == mode) + return; + + d->resizeMode = mode; + if (d->qmlRoot) { + if (d->resizeMode == SizeRootObjectToView) { + d->qmlRoot->setWidth(width()); + d->qmlRoot->setHeight(height()); + } else { + d->qmlRoot->setWidth(d->initialSize.width()); + d->qmlRoot->setHeight(d->initialSize.height()); + } + } +} + +QmlView::ResizeMode QmlView::resizeMode() const +{ + Q_D(const QmlView); + return d->resizeMode; +} /*! \internal */ void QmlView::continueExecute() { - disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); + Q_D(QmlView); - if (!d->component) { - qWarning() << "Error in loading" << d->source; - return; - } + disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); - if(d->component->isError()) { + if (d->component->isError()) { QList<QmlError> errorList = d->component->errors(); foreach (const QmlError &error, errorList) { qWarning() << error; } - emit errors(errorList); - + emit statusChanged(status()); return; } @@ -332,8 +425,7 @@ void QmlView::continueExecute() foreach (const QmlError &error, errorList) { qWarning() << error; } - emit errors(errorList); - + emit statusChanged(status()); return; } @@ -345,24 +437,27 @@ void QmlView::continueExecute() QPerformanceLog::displayData(); QPerformanceLog::clear(); d->root = item; + d->qmlRoot = item; connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged())); connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged())); - if (d->initialSize.height() <= 0 && d->root->width() > 0) - d->initialSize.setWidth(d->root->width()); - if (d->initialSize.height() <= 0 && d->root->height() > 0) - d->initialSize.setHeight(d->root->height()); + if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0) + d->initialSize.setWidth(d->qmlRoot->width()); + if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0) + d->initialSize.setHeight(d->qmlRoot->height()); resize(d->initialSize); - if (d->resizable) { - d->root->setWidth(width()); - d->root->setHeight(height()); + if (d->resizeMode == SizeRootObjectToView) { + d->qmlRoot->setWidth(width()); + d->qmlRoot->setHeight(height()); } else { - QSize sz(d->root->width(),d->root->height()); + QSize sz(d->qmlRoot->width(),d->qmlRoot->height()); emit sceneResized(sz); resize(sz); } updateGeometry(); - emit initialSize(d->initialSize); + } else if (QGraphicsObject *item = qobject_cast<QGraphicsObject *>(obj)) { + d->scene.addItem(item); + qWarning() << "QmlView::resizeMode is not honored for components of type QGraphicsObject"; } else if (QWidget *wid = qobject_cast<QWidget *>(obj)) { window()->setAttribute(Qt::WA_OpaquePaintEvent, false); window()->setAttribute(Qt::WA_NoSystemBackground, false); @@ -377,45 +472,32 @@ void QmlView::continueExecute() } layout()->addWidget(wid); emit sceneResized(wid->size()); - emit initialSize(wid->size()); } } + emit statusChanged(status()); } -/*! \fn void QmlView::sceneResized(QSize size) - This signal is emitted when the view is resized to \a size. - */ - -/*! \fn void QmlView::initialSize(QSize size) - This signal is emitted when the initial \a size of the root item is known. - */ - -/*! \fn void QmlView::errors(const QList<QmlError> &errors) - This signal is emitted when the qml loaded contains \a errors. - */ - -/*! \fn void QmlView::quit() - \internal - */ - /*! \internal */ void QmlView::sizeChanged() { + Q_D(QmlView); // delay, so we catch both width and height changing. d->resizetimer.start(0,this); } /*! + \internal If the \l {QTimerEvent} {timer event} \a e is this view's resize timer, sceneResized() is emitted. */ void QmlView::timerEvent(QTimerEvent* e) { + Q_D(QmlView); if (!e || e->timerId() == d->resizetimer.timerId()) { - if (d->root) { - QSize sz(d->root->width(),d->root->height()); + if (d->qmlRoot) { + QSize sz(d->qmlRoot->width(),d->qmlRoot->height()); emit sceneResized(sz); //if (!d->resizable) //resize(sz); @@ -425,147 +507,47 @@ void QmlView::timerEvent(QTimerEvent* e) } } -// modelled on QScrollArea::widgetResizable -/*! - \property QmlView::contentResizable - \brief whether the view should resize the canvas contents - - If this property is set to false (the default), the view - resizes with the root item in the QML. - - If this property is set to true, the view will - automatically resize the root item. - - Regardless of this property, the sizeHint of the view - is the initial size of the root item. Note though that - since QML may load dynamically, that size may change. - - \sa initialSize() -*/ - -void QmlView::setContentResizable(bool on) -{ - if (d->resizable != on) { - d->resizable = on; - if (d->root) { - if (on) { - d->root->setWidth(width()); - d->root->setHeight(height()); - } else { - d->root->setWidth(d->initialSize.width()); - d->root->setHeight(d->initialSize.height()); - } - } - } -} - -bool QmlView::contentResizable() const -{ - return d->resizable; -} - - /*! + \internal The size hint is the size of the root item. */ QSize QmlView::sizeHint() const { - if (d->root) { + Q_D(const QmlView); + if (d->qmlRoot) { if (d->initialSize.width() <= 0) - d->initialSize.setWidth(d->root->width()); + d->initialSize.setWidth(d->qmlRoot->width()); if (d->initialSize.height() <= 0) - d->initialSize.setHeight(d->root->height()); + d->initialSize.setHeight(d->qmlRoot->height()); } return d->initialSize; } /*! - Creates a \l{QmlComponent} {component} from the \a qml - string, and returns it as an \l {QmlGraphicsItem} {item}. If the - \a parent item is provided, it becomes the new item's - parent. \a parent should be in this view's item hierarchy. + Returns the view's root \l {QGraphicsObject} {item}. */ -QmlGraphicsItem* QmlView::addItem(const QString &qml, QmlGraphicsItem* parent) -{ - if (!d->root) - return 0; - - QmlComponent component(&d->engine); - component.setData(qml.toUtf8(), QUrl()); - if(d->component->isError()) { - QList<QmlError> errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { - qWarning() << error; - } - emit errors(errorList); - - return 0; - } - - QObject *obj = component.create(); - if(d->component->isError()) { - QList<QmlError> errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { - qWarning() << error; - } - emit errors(errorList); - - return 0; - } - - if (obj){ - QmlGraphicsItem *item = static_cast<QmlGraphicsItem *>(obj); - if (!parent) - parent = d->root; - - item->setParentItem(parent); - return item; - } - return 0; -} - -/*! - Deletes the view's \l {QmlGraphicsItem} {items} and clears the \l {QmlEngine} - {QML engine's} Component cache. - */ -void QmlView::reset() -{ - clearItems(); - d->engine.clearComponentCache(); - d->initialSize = QSize(); -} - -/*! - Deletes the view's \l {QmlGraphicsItem} {items}. - */ -void QmlView::clearItems() -{ - if (!d->root) - return; - delete d->root; - d->root = 0; -} - -/*! - Returns the view's root \l {QmlGraphicsItem} {item}. - */ -QmlGraphicsItem *QmlView::root() const +QGraphicsObject *QmlView::rootObject() const { + Q_D(const QmlView); return d->root; } /*! + \internal This function handles the \l {QResizeEvent} {resize event} \a e. */ void QmlView::resizeEvent(QResizeEvent *e) { - if (d->resizable && d->root) { - d->root->setWidth(width()); - d->root->setHeight(height()); + Q_D(QmlView); + if (d->resizeMode == SizeRootObjectToView && d->qmlRoot) { + d->qmlRoot->setWidth(width()); + d->qmlRoot->setHeight(height()); } - if (d->root) { - setSceneRect(QRectF(0, 0, d->root->width(), d->root->height())); + if (d->qmlRoot) { + setSceneRect(QRectF(0, 0, d->qmlRoot->width(), d->qmlRoot->height())); + } else if (d->root) { + setSceneRect(d->root->boundingRect()); } else { setSceneRect(rect()); } @@ -573,10 +555,11 @@ void QmlView::resizeEvent(QResizeEvent *e) } /*! - \reimp + \internal */ void QmlView::paintEvent(QPaintEvent *event) { + Q_D(QmlView); int time = 0; if (frameRateDebug() || QmlViewDebugServer::isDebuggingEnabled()) time = d->frameTimer.restart(); diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h index 3fa9d37..1c6d865 100644 --- a/src/declarative/util/qmlview.h +++ b/src/declarative/util/qmlview.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QFXVIEW_H -#define QFXVIEW_H +#ifndef QMLVIEW_H +#define QMLVIEW_H #include <QtCore/qdatetime.h> #include <QtGui/qgraphicssceneevent.h> @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlGraphicsItem; +class QGraphicsObject; class QmlEngine; class QmlContext; class QmlError; @@ -62,35 +62,38 @@ class QmlViewPrivate; class Q_DECLARATIVE_EXPORT QmlView : public QGraphicsView { Q_OBJECT - Q_PROPERTY(bool contentResizable READ contentResizable WRITE setContentResizable) + Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + + Q_DECLARE_PRIVATE(QmlView) + public: explicit QmlView(QWidget *parent = 0); - virtual ~QmlView(); - void setUrl(const QUrl&); - QUrl url() const; - void setQml(const QString &qml, const QString &filename=QString()); - QString qml() const; + QUrl source() const; + void setSource(const QUrl&); + QmlEngine* engine(); QmlContext* rootContext(); - virtual void execute(); - virtual void reset(); + void execute(); - virtual QmlGraphicsItem* addItem(const QString &qml, QmlGraphicsItem* parent=0); - virtual void clearItems(); + QGraphicsObject *rootObject() const; - virtual QmlGraphicsItem *root() const; + enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView }; + ResizeMode resizeMode() const; + void setResizeMode(ResizeMode); + + enum Status { Null, Ready, Loading, Error }; + Status status() const; + + QList<QmlError> errors() const; - void setContentResizable(bool); - bool contentResizable() const; QSize sizeHint() const; Q_SIGNALS: - void initialSize(QSize size); - void sceneResized(QSize size); - void errors(const QList<QmlError> &error); - void quit(); + void sceneResized(QSize size); // ??? + void statusChanged(QmlView::Status); private Q_SLOTS: void continueExecute(); @@ -100,14 +103,10 @@ protected: virtual void resizeEvent(QResizeEvent *); virtual void paintEvent(QPaintEvent *event); void timerEvent(QTimerEvent*); - -private: - friend class QmlViewPrivate; - QmlViewPrivate *d; }; QT_END_NAMESPACE QT_END_HEADER -#endif // QFXVIEW_H +#endif // QMLVIEW_H diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp index 7975959..0e939bf 100644 --- a/src/declarative/util/qmlxmllistmodel.cpp +++ b/src/declarative/util/qmlxmllistmodel.cpp @@ -125,8 +125,10 @@ private: QString m_name; QString m_query; }; - +QT_END_NAMESPACE QML_DECLARE_TYPE(QmlXmlListModelRole) +QT_BEGIN_NAMESPACE + class QmlXmlListModelPrivate; struct QmlXmlRoleList : public QmlConcreteList<QmlXmlListModelRole *> diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 336be91..4ec2ae2 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -122,15 +122,19 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp static void initResources() { #if defined(Q_WS_WINCE) + Q_INIT_RESOURCE_EXTERN(qstyle_wince) Q_INIT_RESOURCE(qstyle_wince); #elif defined(Q_OS_SYMBIAN) + Q_INIT_RESOURCE_EXTERN(qstyle_s60) Q_INIT_RESOURCE(qstyle_s60); #else + Q_INIT_RESOURCE_EXTERN(qstyle) Q_INIT_RESOURCE(qstyle); #endif - + Q_INIT_RESOURCE_EXTERN(qmessagebox) Q_INIT_RESOURCE(qmessagebox); #if !defined(QT_NO_PRINTDIALOG) + Q_INIT_RESOURCE_EXTERN(qprintdialog) Q_INIT_RESOURCE(qprintdialog); #endif diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp index 319c4b0..0f5792f 100644 --- a/src/gui/util/qdesktopservices_s60.cpp +++ b/src/gui/util/qdesktopservices_s60.cpp @@ -413,11 +413,11 @@ QString QDesktopServices::storageLocation(StandardLocation type) //return QDir::homePath(); break; break; case DataLocation: - CEikonEnv::Static()->FsSession().PrivatePath(path); + qt_s60GetRFs().PrivatePath(path); path.Insert(0, writableExeDrive().Name()); break; case CacheLocation: - CEikonEnv::Static()->FsSession().PrivatePath(path); + qt_s60GetRFs().PrivatePath(path); path.Insert(0, writableExeDrive().Name()); path.Append(KCacheSubDir); break; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index d6ddbfe..c34cf89 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -91,6 +91,9 @@ QT_BEGIN_NAMESPACE //#define QT_GL_NO_SCISSOR_TEST +#ifdef Q_WS_WIN +extern Q_GUI_EXPORT bool qt_cleartype_enabled; +#endif extern QImage qt_imageForBrush(int brushStyle, bool invert); @@ -1822,7 +1825,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) #if !defined(QT_OPENGL_ES_2) #if defined(Q_WS_WIN) - extern Q_GUI_EXPORT bool qt_cleartype_enabled; if (qt_cleartype_enabled) #endif d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 4edb87a..032ff85 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -54,6 +54,9 @@ #include <QtCore/QFile> #include <QtCore/QBuffer> #include <qvariant.h> + +QT_BEGIN_NAMESPACE + // These next two structs represent how the icon information is stored // in an ICO file. typedef struct @@ -891,3 +894,4 @@ bool QtIcoHandler::jumpToNextImage() return jumpToImage(m_currentIconIndex + 1); } +QT_END_NAMESPACE diff --git a/src/plugins/imageformats/ico/qicohandler.h b/src/plugins/imageformats/ico/qicohandler.h index 394a5eb..4334ad9 100644 --- a/src/plugins/imageformats/ico/qicohandler.h +++ b/src/plugins/imageformats/ico/qicohandler.h @@ -43,6 +43,8 @@ #include <QtGui/QImageIOHandler> +QT_BEGIN_NAMESPACE + class ICOReader; class QtIcoHandler: public QImageIOHandler { @@ -71,5 +73,7 @@ private: }; +QT_END_NAMESPACE + #endif /* QTICOHANDLER_H */ diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 8773026..b4a0d0f 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -29,13 +29,13 @@ SUBDIRS += \ qmlgraphicsitem \ # Cover qmlgraphicslistview \ # Cover qmlgraphicsloader \ # Cover + qmlgraphicsmouseregion \ # Cover qmlgraphicsparticles \ # Cover qmlgraphicspathview \ # Cover qmlgraphicspositioners \ # Cover qmlgraphicstext \ # Cover qmlgraphicstextedit \ # Cover qmlgraphicstextinput \ # Cover - qmlgraphicswebview \ # Cover qmlinfo \ # Cover qmlinstruction \ # Cover qmllanguage \ # Cover @@ -57,8 +57,13 @@ SUBDIRS += \ qmlgraphicsrepeater \ # Cover qmlvaluetypes \ # Cover qmlxmlhttprequest \ # Cover + qmlimageprovider \ # Cover sql # Cover +contains(QT_CONFIG, webkit) { + SUBDIRS += \ + qmlgraphicswebview # Cover +} # Tests which should run in Pulse PULSE_TESTS = $$SUBDIRS diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp index 050df52..ee05574 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/layouts/tst_layouts.cpp @@ -69,10 +69,10 @@ void tst_QmlGraphicsLayouts::test_qml() canvas->execute(); qApp->processEvents(); - QmlGraphicsLayoutItem *left = static_cast<QmlGraphicsLayoutItem*>(canvas->root()->findChild<QmlGraphicsItem*>("left")); + QmlGraphicsLayoutItem *left = static_cast<QmlGraphicsLayoutItem*>(canvas->rootObject()->findChild<QmlGraphicsItem*>("left")); QVERIFY(left != 0); - QmlGraphicsLayoutItem *right = static_cast<QmlGraphicsLayoutItem*>(canvas->root()->findChild<QmlGraphicsItem*>("right")); + QmlGraphicsLayoutItem *right = static_cast<QmlGraphicsLayoutItem*>(canvas->rootObject()->findChild<QmlGraphicsItem*>("right")); QVERIFY(right != 0); qreal l = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin); @@ -81,9 +81,13 @@ void tst_QmlGraphicsLayouts::test_qml() qreal b = QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin); QVERIFY2(l == r && r == t && t == b, "Test assumes equal margins."); qreal gvMargin = l; + + QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(canvas->rootObject()); + QVERIFY(rootItem != 0); + //Preferred Size - canvas->root()->setWidth(300 + 2*gvMargin); - canvas->root()->setHeight(300 + 2*gvMargin); + rootItem->setWidth(300 + 2*gvMargin); + rootItem->setHeight(300 + 2*gvMargin); QCOMPARE(left->x(), gvMargin); QCOMPARE(left->y(), gvMargin); @@ -96,8 +100,8 @@ void tst_QmlGraphicsLayouts::test_qml() QCOMPARE(right->height(), 300.0); //Minimum Size - canvas->root()->setWidth(10+2*gvMargin); - canvas->root()->setHeight(10+2*gvMargin); + rootItem->setWidth(10+2*gvMargin); + rootItem->setHeight(10+2*gvMargin); QCOMPARE(left->x(), gvMargin); QCOMPARE(left->width(), 100.0); @@ -111,8 +115,8 @@ void tst_QmlGraphicsLayouts::test_qml() /*Note that if set to maximum size (or above) GraphicsLinearLayout behavior is to shrink them down to preferred size. So the exact maximum size can't be used*/ - canvas->root()->setWidth(670 + 2*gvMargin); - canvas->root()->setHeight(300 + 2*gvMargin); + rootItem->setWidth(670 + 2*gvMargin); + rootItem->setHeight(300 + 2*gvMargin); QCOMPARE(left->x(), gvMargin); QCOMPARE(left->width(), 270.0); @@ -133,11 +137,7 @@ void tst_QmlGraphicsLayouts::test_cpp() QmlView *tst_QmlGraphicsLayouts::createView(const QString &filename) { QmlView *canvas = new QmlView(0); - - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } diff --git a/tests/auto/declarative/qmlanimations/data/badtype4.qml b/tests/auto/declarative/qmlanimations/data/badtype4.qml index a4cf265..2ffed37 100644 --- a/tests/auto/declarative/qmlanimations/data/badtype4.qml +++ b/tests/auto/declarative/qmlanimations/data/badtype4.qml @@ -21,7 +21,7 @@ Rectangle { } transitions: Transition { //comment out each in turn to make sure each only animates the relevant property - ColorAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color - NumberAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color + ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color } } diff --git a/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml b/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml new file mode 100644 index 0000000..d9660b6 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + x: Behavior { + NumberAnimation { objectName: "MyAnim"; target: redRect; property: "y"; to: 300; repeat: true} + } + + } + +} diff --git a/tests/auto/declarative/qmlanimations/data/dontStart.qml b/tests/auto/declarative/qmlanimations/data/dontStart.qml new file mode 100644 index 0000000..36417db --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/dontStart.qml @@ -0,0 +1,19 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + x: SequentialAnimation { + running: false + NumberAnimation { objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/declarative/qmlanimations/data/dontStart2.qml b/tests/auto/declarative/qmlanimations/data/dontStart2.qml new file mode 100644 index 0000000..1a6540f --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/dontStart2.qml @@ -0,0 +1,19 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + + transitions: Transition { + SequentialAnimation { + NumberAnimation { id: myAnim; objectName: "MyAnim"; running: true } + } + } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/dotproperty.qml b/tests/auto/declarative/qmlanimations/data/dotproperty.qml index 369491f..08bb5d8 100644 --- a/tests/auto/declarative/qmlanimations/data/dotproperty.qml +++ b/tests/auto/declarative/qmlanimations/data/dotproperty.qml @@ -19,6 +19,6 @@ Rectangle { PropertyChanges { target: myRect; border.color: "blue" } } transitions: Transition { - ColorAnimation { matchProperties: "border.color"; duration: 1000 } + ColorAnimation { properties: "border.color"; duration: 1000 } } } diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml index 87f4f16..b46270c 100644 --- a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml +++ b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml @@ -20,6 +20,6 @@ Rectangle { PropertyChanges { target: myRect; x: 200; border.width: 10 } } transitions: Transition { - PropertyAnimation { matchProperties: "x,border.width"; duration: 1000 } //x is real, border.width is int + PropertyAnimation { properties: "x,border.width"; duration: 1000 } //x is real, border.width is int } } diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml index d555abd..15537f1 100644 --- a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml +++ b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml @@ -20,6 +20,6 @@ Rectangle { PropertyChanges { target: myRect; x: 200; color: "blue" } } transitions: Transition { - PropertyAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color + PropertyAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color } } diff --git a/tests/auto/declarative/qmlanimations/data/properties2.qml b/tests/auto/declarative/qmlanimations/data/properties2.qml index 86568ca..6c96155 100644 --- a/tests/auto/declarative/qmlanimations/data/properties2.qml +++ b/tests/auto/declarative/qmlanimations/data/properties2.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { matchTargets: theRect; matchProperties: "x"; to: 200; } + x: NumberAnimation { targets: theRect; properties: "x"; to: 200; } } } diff --git a/tests/auto/declarative/qmlanimations/data/properties5.qml b/tests/auto/declarative/qmlanimations/data/properties5.qml index 56e0be8..38396b1 100644 --- a/tests/auto/declarative/qmlanimations/data/properties5.qml +++ b/tests/auto/declarative/qmlanimations/data/properties5.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { matchTargets: theRect; matchProperties: "y"; to: 200; } + x: NumberAnimation { targets: theRect; properties: "y"; to: 200; } } } diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml index 75603b9..2f7fd4a 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { matchTargets: theRect; matchProperties: "x" } + NumberAnimation { targets: theRect; properties: "x" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml index eedba7b..5aaaab8 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { matchTargets: theRect; matchProperties: "y" } + NumberAnimation { targets: theRect; properties: "y" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml index 301f796..b7ebb1b 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { target: theRect; matchProperties: "x" } + NumberAnimation { target: theRect; properties: "x" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml index 565c519..9034fc5 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { matchTargets: theRect; property: "x" } + NumberAnimation { targets: theRect; property: "x" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml index b541dab..3d8be51 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { matchTargets: theItem; matchProperties: "x" } + NumberAnimation { targets: theItem; properties: "x" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index 34bb7e3..9eae308 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -46,13 +46,15 @@ #include <private/qmlanimation_p.h> #include <QVariantAnimation> -class tst_animations : public QObject +class tst_qmlanimations : public QObject { Q_OBJECT public: - tst_animations() {} + tst_qmlanimations() {} private slots: + void initTestCase() { QmlEngine engine; } // ensure types are registered + void simpleProperty(); void simpleNumber(); void simpleColor(); @@ -69,6 +71,7 @@ private slots: void invalidDuration(); void attached(); void propertyValueSourceDefaultStart(); + void dontStart(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -80,7 +83,7 @@ private slots: QCOMPARE(lhs, rhs); \ } while (false) -void tst_animations::simpleProperty() +void tst_qmlanimations::simpleProperty() { QmlGraphicsRectangle rect; QmlPropertyAnimation animation; @@ -105,7 +108,7 @@ void tst_animations::simpleProperty() QCOMPARE(rect.pos(), QPointF(100,100)); } -void tst_animations::simpleNumber() +void tst_qmlanimations::simpleNumber() { QmlGraphicsRectangle rect; QmlNumberAnimation animation; @@ -130,7 +133,7 @@ void tst_animations::simpleNumber() QCOMPARE(rect.x(), qreal(100)); } -void tst_animations::simpleColor() +void tst_qmlanimations::simpleColor() { QmlGraphicsRectangle rect; QmlColorAnimation animation; @@ -164,7 +167,7 @@ void tst_animations::simpleColor() QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); } -void tst_animations::alwaysRunToEnd() +void tst_qmlanimations::alwaysRunToEnd() { QmlGraphicsRectangle rect; QmlPropertyAnimation animation; @@ -184,7 +187,7 @@ void tst_animations::alwaysRunToEnd() QTIMED_COMPARE(rect.x(), qreal(200)); } -void tst_animations::complete() +void tst_qmlanimations::complete() { QmlGraphicsRectangle rect; QmlPropertyAnimation animation; @@ -205,7 +208,7 @@ void tst_animations::complete() QCOMPARE(rect.x(), qreal(200)); } -void tst_animations::resume() +void tst_qmlanimations::resume() { QmlGraphicsRectangle rect; QmlPropertyAnimation animation; @@ -217,7 +220,7 @@ void tst_animations::resume() QVERIFY(animation.from() == 10); animation.start(); - QTest::qWait(50); + QTest::qWait(100); animation.pause(); qreal x = rect.x(); QVERIFY(x != qreal(200)); @@ -227,12 +230,12 @@ void tst_animations::resume() animation.resume(); QVERIFY(animation.isRunning()); QVERIFY(!animation.isPaused()); - QTest::qWait(50); + QTest::qWait(100); animation.stop(); QVERIFY(rect.x() > x); } -void tst_animations::dotProperty() +void tst_qmlanimations::dotProperty() { QmlGraphicsRectangle rect; QmlNumberAnimation animation; @@ -251,12 +254,12 @@ void tst_animations::dotProperty() QCOMPARE(rect.border()->width(), 5); } -void tst_animations::badTypes() +void tst_qmlanimations::badTypes() { //don't crash { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml")); view->execute(); qApp->processEvents(); @@ -301,7 +304,7 @@ void tst_animations::badTypes() } } -void tst_animations::badProperties() +void tst_qmlanimations::badProperties() { //make sure we get a runtime error { @@ -310,14 +313,12 @@ void tst_animations::badProperties() QmlComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml")); QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\""; QTest::ignoreMessage(QtWarningMsg, message); - QTest::ignoreMessage(QtWarningMsg, message); // why twice? QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c1.create()); QVERIFY(rect); QmlComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml")); message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9) Cannot animate read-only property \"border\""; QTest::ignoreMessage(QtWarningMsg, message); - QTest::ignoreMessage(QtWarningMsg, message); // why twice? rect = qobject_cast<QmlGraphicsRectangle*>(c2.create()); QVERIFY(rect); @@ -328,9 +329,9 @@ void tst_animations::badProperties() //test animating mixed types with property animation in a transition //for example, int + real; color + real; etc -void tst_animations::mixedTypes() +void tst_qmlanimations::mixedTypes() { - //assumes border.width stats a real -- not real robust + //assumes border.width stays a real -- not real robust { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml")); @@ -364,7 +365,7 @@ void tst_animations::mixedTypes() } } -void tst_animations::properties() +void tst_qmlanimations::properties() { const int waitDuration = 300; { @@ -425,13 +426,12 @@ void tst_animations::properties() QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); - QEXPECT_FAIL("", "QTBUG-8072", Continue); QTIMED_COMPARE(myRect->x(),qreal(100)); - QTIMED_COMPARE(myRect->y(),qreal(100)); + QTIMED_COMPARE(myRect->y(),qreal(200)); } } -void tst_animations::propertiesTransition() +void tst_qmlanimations::propertiesTransition() { const int waitDuration = 300; { @@ -470,9 +470,9 @@ void tst_animations::propertiesTransition() QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); QVERIFY(myRect); - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); rect->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->y(),qreal(100)); } { @@ -483,9 +483,10 @@ void tst_animations::propertiesTransition() QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); QVERIFY(myRect); - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); rect->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); } { @@ -494,15 +495,30 @@ void tst_animations::propertiesTransition() QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); QVERIFY(rect); - //### should output warning at some point -- theItem doesn't exist QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); QVERIFY(myRect); rect->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); } + + /*{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + rect->setState("moved"); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(100)); + }*/ } -void tst_animations::easingStringConversion() +void tst_qmlanimations::easingStringConversion() { QmlNumberAnimation *animation = new QmlNumberAnimation; animation->setEasing("easeInOutQuad"); @@ -553,7 +569,7 @@ void tst_animations::easingStringConversion() delete animation; } -void tst_animations::invalidDuration() +void tst_qmlanimations::invalidDuration() { QmlPropertyAnimation *animation = new QmlPropertyAnimation; QTest::ignoreMessage(QtWarningMsg, "QML PropertyAnimation (unknown location) Cannot set a duration of < 0"); @@ -566,7 +582,7 @@ void tst_animations::invalidDuration() QCOMPARE(pauseAnimation->duration(), 250); } -void tst_animations::attached() +void tst_qmlanimations::attached() { QmlEngine engine; @@ -577,7 +593,7 @@ void tst_animations::attached() QVERIFY(rect); } -void tst_animations::propertyValueSourceDefaultStart() +void tst_qmlanimations::propertyValueSourceDefaultStart() { { QmlEngine engine; @@ -604,8 +620,53 @@ void tst_animations::propertyValueSourceDefaultStart() QVERIFY(myAnim); QVERIFY(myAnim->isRunning() == false); } + + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml")); + + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } +} + + +void tst_qmlanimations::dontStart() +{ + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); + + QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } + + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml")); + + QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } } -QTEST_MAIN(tst_animations) +QTEST_MAIN(tst_qmlanimations) #include "tst_qmlanimations.moc" diff --git a/tests/auto/declarative/qmlbehaviors/data/dontStart.qml b/tests/auto/declarative/qmlbehaviors/data/dontStart.qml new file mode 100644 index 0000000..ba7cc9c --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/dontStart.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + x: Behavior { + NumberAnimation { objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml b/tests/auto/declarative/qmlbehaviors/data/explicit.qml index ba36d93..ba36d93 100644 --- a/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml +++ b/tests/auto/declarative/qmlbehaviors/data/explicit.qml diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml index e9849eb..59cbd1a 100644 --- a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml +++ b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml @@ -8,7 +8,7 @@ Rectangle { width: 100; height: 100; color: "green" x: Behavior { objectName: "MyBehavior"; - NumberAnimation { matchTargets: rect; matchProperties: "y"; duration: 200; } + NumberAnimation { targets: rect; properties: "y"; duration: 200; } } } MouseRegion { diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp index 126c506..99ec728 100644 --- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp +++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp @@ -46,11 +46,11 @@ #include <private/qmlbehavior_p.h> #include <private/qmlanimation_p.h> -class tst_behaviors : public QObject +class tst_qmlbehaviors : public QObject { Q_OBJECT public: - tst_behaviors() {} + tst_qmlbehaviors() {} private slots: void simpleBehavior(); @@ -63,12 +63,14 @@ private slots: //void transitionOverrides(); void group(); void emptyBehavior(); + void explicitSelection(); void nonSelectingBehavior(); void reassignedAnimation(); void disabled(); + void dontStart(); }; -void tst_behaviors::simpleBehavior() +void tst_qmlbehaviors::simpleBehavior() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml")); @@ -82,7 +84,7 @@ void tst_behaviors::simpleBehavior() QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } -void tst_behaviors::scriptTriggered() +void tst_qmlbehaviors::scriptTriggered() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml")); @@ -95,7 +97,7 @@ void tst_behaviors::scriptTriggered() QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } -void tst_behaviors::cppTriggered() +void tst_qmlbehaviors::cppTriggered() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml")); @@ -111,7 +113,7 @@ void tst_behaviors::cppTriggered() QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } -void tst_behaviors::loop() +void tst_qmlbehaviors::loop() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml")); @@ -122,7 +124,7 @@ void tst_behaviors::loop() rect->setState("moved"); } -void tst_behaviors::colorBehavior() +void tst_qmlbehaviors::colorBehavior() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml")); @@ -135,7 +137,7 @@ void tst_behaviors::colorBehavior() QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered } -void tst_behaviors::parentBehavior() +void tst_qmlbehaviors::parentBehavior() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml")); @@ -152,7 +154,7 @@ void tst_behaviors::parentBehavior() QVERIFY(parent == newParent); } -void tst_behaviors::replaceBinding() +void tst_qmlbehaviors::replaceBinding() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml")); @@ -186,7 +188,7 @@ void tst_behaviors::replaceBinding() QCOMPARE(innerRect->x(), (qreal)20); } -void tst_behaviors::group() +void tst_qmlbehaviors::group() { { QmlEngine engine; @@ -213,7 +215,7 @@ void tst_behaviors::group() } } -void tst_behaviors::emptyBehavior() +void tst_qmlbehaviors::emptyBehavior() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml")); @@ -225,19 +227,23 @@ void tst_behaviors::emptyBehavior() QCOMPARE(x, qreal(200)); //should change immediately } -void tst_behaviors::nonSelectingBehavior() +void tst_qmlbehaviors::explicitSelection() { { QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting.qml")); + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml")); QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); QVERIFY(rect); rect->setState("moved"); + QTest::qWait(100); qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately + QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } +} +void tst_qmlbehaviors::nonSelectingBehavior() +{ { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml")); @@ -250,7 +256,7 @@ void tst_behaviors::nonSelectingBehavior() } } -void tst_behaviors::reassignedAnimation() +void tst_qmlbehaviors::reassignedAnimation() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); @@ -262,7 +268,7 @@ void tst_behaviors::reassignedAnimation() rect->findChild<QmlBehavior*>("MyBehavior"))->animation())->duration(), 200); } -void tst_behaviors::disabled() +void tst_qmlbehaviors::disabled() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); @@ -273,9 +279,23 @@ void tst_behaviors::disabled() rect->setState("moved"); qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately +} + +void tst_qmlbehaviors::dontStart() +{ + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); + + QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); } -QTEST_MAIN(tst_behaviors) +QTEST_MAIN(tst_qmlbehaviors) #include "tst_qmlbehaviors.moc" diff --git a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp b/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp index bb607ae..4b5dc1d 100644 --- a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp +++ b/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp @@ -44,11 +44,11 @@ #include <private/qmldatetimeformatter_p.h> #include <QDebug> -class tst_datetimeformatter : public QObject +class tst_qmldatetimeformatter : public QObject { Q_OBJECT public: - tst_datetimeformatter() {} + tst_qmldatetimeformatter() {} private slots: void date(); @@ -56,7 +56,7 @@ private slots: void dateTime(); }; -void tst_datetimeformatter::date() +void tst_qmldatetimeformatter::date() { QmlEngine engine; QmlComponent formatterComponent(&engine); @@ -86,7 +86,7 @@ void tst_datetimeformatter::date() delete formatter; } -void tst_datetimeformatter::time() +void tst_qmldatetimeformatter::time() { QmlEngine engine; QmlComponent formatterComponent(&engine); @@ -119,7 +119,7 @@ void tst_datetimeformatter::time() delete formatter; } -void tst_datetimeformatter::dateTime() +void tst_qmldatetimeformatter::dateTime() { QmlEngine engine; QmlComponent formatterComponent(&engine); @@ -145,6 +145,6 @@ void tst_datetimeformatter::dateTime() delete formatter; } -QTEST_MAIN(tst_datetimeformatter) +QTEST_MAIN(tst_qmldatetimeformatter) #include "tst_qmldatetimeformatter.moc" diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp index effc2c5..2e668ad 100644 --- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp +++ b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp @@ -288,10 +288,11 @@ void tst_QmlDebug::watch_property() QmlDebugPropertyWatch *watch; - QmlEngineDebug unconnected(0); - watch = unconnected.addWatch(prop, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + watch = unconnected->addWatch(prop, this); QCOMPARE(watch->state(), QmlDebugWatch::Dead); delete watch; + delete unconnected; watch = m_dbg->addWatch(QmlDebugPropertyReference(), this); QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State)))); @@ -346,10 +347,11 @@ void tst_QmlDebug::watch_object() QmlDebugWatch *watch; - QmlEngineDebug unconnected(0); - watch = unconnected.addWatch(obj, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + watch = unconnected->addWatch(obj, this); QCOMPARE(watch->state(), QmlDebugWatch::Dead); delete watch; + delete unconnected; watch = m_dbg->addWatch(QmlDebugObjectReference(), this); QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State)))); @@ -409,10 +411,11 @@ void tst_QmlDebug::watch_expression() QmlDebugObjectExpressionWatch *watch; - QmlEngineDebug unconnected(0); - watch = unconnected.addWatch(obj, expr, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + watch = unconnected->addWatch(obj, expr, this); QCOMPARE(watch->state(), QmlDebugWatch::Dead); delete watch; + delete unconnected; watch = m_dbg->addWatch(QmlDebugObjectReference(), expr, this); QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State)))); @@ -487,10 +490,11 @@ void tst_QmlDebug::queryAvailableEngines() { QmlDebugEnginesQuery *q_engines; - QmlEngineDebug unconnected(0); - q_engines = unconnected.queryAvailableEngines(0); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + q_engines = unconnected->queryAvailableEngines(0); QCOMPARE(q_engines->state(), QmlDebugQuery::Error); delete q_engines; + delete unconnected; q_engines = m_dbg->queryAvailableEngines(this); delete q_engines; @@ -519,10 +523,11 @@ void tst_QmlDebug::queryRootContexts() QmlDebugRootContextQuery *q_context; - QmlEngineDebug unconnected(0); - q_context = unconnected.queryRootContexts(engineId, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + q_context = unconnected->queryRootContexts(engineId, this); QCOMPARE(q_context->state(), QmlDebugQuery::Error); delete q_context; + delete unconnected; q_context = m_dbg->queryRootContexts(engineId, this); delete q_context; @@ -563,10 +568,11 @@ void tst_QmlDebug::queryObject() QmlDebugObjectQuery *q_obj = 0; - QmlEngineDebug unconnected(0); - q_obj = recursive ? unconnected.queryObjectRecursive(rootObject, this) : unconnected.queryObject(rootObject, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this); QCOMPARE(q_obj->state(), QmlDebugQuery::Error); delete q_obj; + delete unconnected; q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this); delete q_obj; @@ -637,10 +643,11 @@ void tst_QmlDebug::queryExpressionResult() QmlDebugExpressionQuery *q_expr; - QmlEngineDebug unconnected(0); - q_expr = unconnected.queryExpressionResult(objectId, expr, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + q_expr = unconnected->queryExpressionResult(objectId, expr, this); QCOMPARE(q_expr->state(), QmlDebugQuery::Error); delete q_expr; + delete unconnected; q_expr = m_dbg->queryExpressionResult(objectId, expr, this); delete q_expr; @@ -801,9 +808,10 @@ class tst_QmlDebug_Factory : public QmlTestFactory public: QObject *createTest(QmlDebugTestData *data) { - QmlContext *c = new QmlContext(data->engine->rootContext()); + tst_QmlDebug *test = new tst_QmlDebug(data); + QmlContext *c = new QmlContext(data->engine->rootContext(), test); c->setObjectName("tst_QmlDebug_childContext"); - return new tst_QmlDebug(data); + return test; } }; diff --git a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp index 45a06c4..e9e31ca 100644 --- a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp +++ b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp @@ -167,6 +167,7 @@ void tst_QmlDebugService::objectToString() obj->setObjectName("Hello"); QCOMPARE(QmlDebugService::objectToString(obj), QString("QObject: Hello")); + delete obj; } diff --git a/tests/auto/declarative/qmldom/tst_qmldom.cpp b/tests/auto/declarative/qmldom/tst_qmldom.cpp index 6dbcedd..16cdef0 100644 --- a/tests/auto/declarative/qmldom/tst_qmldom.cpp +++ b/tests/auto/declarative/qmldom/tst_qmldom.cpp @@ -41,7 +41,7 @@ #include <qtest.h> #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlcomponent.h> -#include <QtDeclarative/qmldom.h> +#include <QtDeclarative/private/qmldom_p.h> #include <QtCore/QDebug> #include <QtCore/QFile> diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index 4e66548..0ef836f 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -45,7 +45,7 @@ #include <QtDeclarative/qmlcontext.h> #include <QtCore/qfileinfo.h> #include <QtCore/qdebug.h> -#include <QtCore/private/qguard_p.h> +#include <QtDeclarative/private/qmlguard_p.h> #include <QtCore/qdir.h> #include <QtCore/qnumeric.h> #include <private/qmlengine_p.h> @@ -835,9 +835,9 @@ void tst_qmlecmascript::dynamicCreation() void tst_qmlecmascript::dynamicDestruction() { QmlComponent component(&engine, TEST_FILE("dynamicDeletion.qml")); - QGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create()); + QmlGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); - QGuard<QObject> createdQmlObject = 0; + QmlGuard<QObject> createdQmlObject = 0; QMetaObject::invokeMethod(object, "create"); createdQmlObject = object->objectProperty(); @@ -846,10 +846,9 @@ void tst_qmlecmascript::dynamicDestruction() QMetaObject::invokeMethod(object, "killOther"); QVERIFY(createdQmlObject); - QTest::qWait(0); QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion); QVERIFY(createdQmlObject); - for (int ii = 0; createdQmlObject && ii < 10; ++ii) { + for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up if (createdQmlObject) { QTest::qWait(100); QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion); diff --git a/tests/auto/declarative/qmlengine/qmlengine.pro b/tests/auto/declarative/qmlengine/qmlengine.pro index 21d55a4..1a0e5f4 100644 --- a/tests/auto/declarative/qmlengine/qmlengine.pro +++ b/tests/auto/declarative/qmlengine/qmlengine.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative webkit network +contains(QT_CONFIG,declarative): QT += declarative network macx:CONFIG -= app_bundle SOURCES += tst_qmlengine.cpp diff --git a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp index 24d6f44..aa6b56a 100644 --- a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp +++ b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp @@ -51,14 +51,14 @@ Q_DECLARE_METATYPE(QmlGraphicsAnchors::UsedAnchor) Q_DECLARE_METATYPE(QmlGraphicsAnchorLine::AnchorLine) -class tst_anchors : public QObject +class tst_qmlgraphicsanchors : public QObject { Q_OBJECT public: - tst_anchors() {} + tst_qmlgraphicsanchors() {} template<typename T> - T *findItem(QmlGraphicsItem *parent, const QString &id); + T *findItem(QGraphicsObject *parent, const QString &id); private slots: void basicAnchors(); @@ -80,7 +80,7 @@ private slots: Find an item with the specified id. */ template<typename T> -T *tst_anchors::findItem(QmlGraphicsItem *parent, const QString &objectName) +T *tst_qmlgraphicsanchors::findItem(QGraphicsObject *parent, const QString &objectName) { const QMetaObject &mo = T::staticMetaObject; QList<QGraphicsItem *> children = parent->childItems(); @@ -99,83 +99,83 @@ T *tst_anchors::findItem(QmlGraphicsItem *parent, const QString &objectName) return 0; } -void tst_anchors::basicAnchors() +void tst_qmlgraphicsanchors::basicAnchors() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); view->execute(); qApp->processEvents(); //sibling horizontal - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect1"))->x(), 26.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect2"))->x(), 122.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect3"))->x(), 74.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect4"))->x(), 16.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect5"))->x(), 112.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect6"))->x(), 64.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0); //parent horizontal - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect7"))->x(), 0.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect8"))->x(), 240.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect9"))->x(), 120.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect10"))->x(), -10.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect11"))->x(), 230.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect12"))->x(), 110.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0); //vertical - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect13"))->y(), 20.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect14"))->y(), 155.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0); //stretch - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect15"))->x(), 26.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect15"))->width(), 96.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect16"))->x(), 26.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect16"))->width(), 192.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect17"))->x(), -70.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect17"))->width(), 192.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0); //vertical stretch - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect18"))->y(), 20.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect18"))->height(), 40.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0); //more parent horizontal - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect19"))->x(), 115.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect20"))->x(), 235.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect21"))->x(), -5.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0); //centerIn - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect22"))->x(), 69.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect22"))->y(), 5.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0); //margins - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->x(), 31.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->y(), 5.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->width(), 86.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->height(), 10.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0); // offsets - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect24"))->x(), 26.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect25"))->y(), 60.0); - QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect26"))->y(), 5.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0); //baseline - QmlGraphicsText *text1 = findItem<QmlGraphicsText>(view->root(), QLatin1String("text1")); - QmlGraphicsText *text2 = findItem<QmlGraphicsText>(view->root(), QLatin1String("text2")); + QmlGraphicsText *text1 = findItem<QmlGraphicsText>(view->rootObject(), QLatin1String("text1")); + QmlGraphicsText *text2 = findItem<QmlGraphicsText>(view->rootObject(), QLatin1String("text2")); QCOMPARE(text1->y(), text2->y()); delete view; } // mostly testing that we don't crash -void tst_anchors::loops() +void tst_qmlgraphicsanchors::loops() { { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); - QString expect = "QML Text (" + view->url().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = "QML Text (" + view->source().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); @@ -188,9 +188,9 @@ void tst_anchors::loops() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); - QString expect = "QML Image (" + view->url().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = "QML Image (" + view->source().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); qApp->processEvents(); @@ -199,7 +199,7 @@ void tst_anchors::loops() } } -void tst_anchors::illegalSets() +void tst_qmlgraphicsanchors::illegalSets() { QFETCH(QString, qml); QFETCH(QString, warning); @@ -216,7 +216,7 @@ void tst_anchors::illegalSets() delete o; } -void tst_anchors::illegalSets_data() +void tst_qmlgraphicsanchors::illegalSets_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("warning"); @@ -274,7 +274,7 @@ void tst_anchors::illegalSets_data() << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; } -void tst_anchors::reset() +void tst_qmlgraphicsanchors::reset() { QFETCH(QString, side); QFETCH(QmlGraphicsAnchorLine::AnchorLine, anchorLine); @@ -301,7 +301,7 @@ void tst_anchors::reset() delete baseItem; } -void tst_anchors::reset_data() +void tst_qmlgraphicsanchors::reset_data() { QTest::addColumn<QString>("side"); QTest::addColumn<QmlGraphicsAnchorLine::AnchorLine>("anchorLine"); @@ -317,7 +317,7 @@ void tst_anchors::reset_data() QTest::newRow("baseline") << "baseline" << QmlGraphicsAnchorLine::Baseline << QmlGraphicsAnchors::HasBaselineAnchor; } -void tst_anchors::resetConvenience() +void tst_qmlgraphicsanchors::resetConvenience() { QmlGraphicsItem *baseItem = new QmlGraphicsItem; QmlGraphicsItem *item = new QmlGraphicsItem; @@ -338,7 +338,7 @@ void tst_anchors::resetConvenience() delete baseItem; } -void tst_anchors::nullItem() +void tst_qmlgraphicsanchors::nullItem() { QFETCH(QString, side); @@ -354,7 +354,7 @@ void tst_anchors::nullItem() delete item; } -void tst_anchors::nullItem_data() +void tst_qmlgraphicsanchors::nullItem_data() { QTest::addColumn<QString>("side"); @@ -368,13 +368,13 @@ void tst_anchors::nullItem_data() QTest::newRow("baseline") << "baseline"; } -void tst_anchors::crash1() +void tst_qmlgraphicsanchors::crash1() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); - QString expect = "QML Text (" + view->url().toString() + ":4:5" + ") Possible anchor loop detected on fill."; + QString expect = "QML Text (" + view->source().toString() + ":4:5" + ") Possible anchor loop detected on fill."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); // XXX ideally, should be one message view->execute(); @@ -383,15 +383,15 @@ void tst_anchors::crash1() delete view; } -void tst_anchors::fill() +void tst_qmlgraphicsanchors::fill() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); view->execute(); qApp->processEvents(); - QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("filler")); + QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler")); QCOMPARE(rect->x(), 0.0 + 10.0); QCOMPARE(rect->y(), 0.0 + 30.0); QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); @@ -409,15 +409,15 @@ void tst_anchors::fill() delete view; } -void tst_anchors::centerIn() +void tst_qmlgraphicsanchors::centerIn() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); view->execute(); qApp->processEvents(); - QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("centered")); + QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("centered")); QCOMPARE(rect->x(), 75.0 + 10); QCOMPARE(rect->y(), 75.0 + 30); //Alter Offsets (QTBUG-6631) @@ -429,15 +429,15 @@ void tst_anchors::centerIn() delete view; } -void tst_anchors::margins() +void tst_qmlgraphicsanchors::margins() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); view->execute(); qApp->processEvents(); - QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("filler")); + QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler")); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 6.0); QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); @@ -454,6 +454,6 @@ void tst_anchors::margins() delete view; } -QTEST_MAIN(tst_anchors) +QTEST_MAIN(tst_qmlgraphicsanchors) #include "tst_qmlgraphicsanchors.moc" diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp b/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp index 136e4cd..2342f25 100644 --- a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp +++ b/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp @@ -58,11 +58,11 @@ } while (false) -class tst_animatedimage : public QObject +class tst_qmlgraphicsanimatedimage : public QObject { Q_OBJECT public: - tst_animatedimage() {} + tst_qmlgraphicsanimatedimage() {} private slots: void play(); @@ -75,7 +75,7 @@ private slots: void invalidSource(); }; -void tst_animatedimage::play() +void tst_qmlgraphicsanimatedimage::play() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml")); @@ -86,7 +86,7 @@ void tst_animatedimage::play() delete anim; } -void tst_animatedimage::pause() +void tst_qmlgraphicsanimatedimage::pause() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); @@ -98,7 +98,7 @@ void tst_animatedimage::pause() delete anim; } -void tst_animatedimage::stopped() +void tst_qmlgraphicsanimatedimage::stopped() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml")); @@ -110,7 +110,7 @@ void tst_animatedimage::stopped() delete anim; } -void tst_animatedimage::setFrame() +void tst_qmlgraphicsanimatedimage::setFrame() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); @@ -122,7 +122,7 @@ void tst_animatedimage::setFrame() delete anim; } -void tst_animatedimage::frameCount() +void tst_qmlgraphicsanimatedimage::frameCount() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml")); @@ -134,7 +134,7 @@ void tst_animatedimage::frameCount() delete anim; } -void tst_animatedimage::remote() +void tst_qmlgraphicsanimatedimage::remote() { QFETCH(QString, fileName); QFETCH(bool, paused); @@ -159,7 +159,7 @@ void tst_animatedimage::remote() delete anim; } -void tst_animatedimage::remote_data() +void tst_qmlgraphicsanimatedimage::remote_data() { QTest::addColumn<QString>("fileName"); QTest::addColumn<bool>("paused"); @@ -168,7 +168,7 @@ void tst_animatedimage::remote_data() QTest::newRow("paused") << "stickmanpause.qml" << true; } -void tst_animatedimage::invalidSource() +void tst_qmlgraphicsanimatedimage::invalidSource() { QmlEngine engine; QmlComponent component(&engine); @@ -186,6 +186,6 @@ void tst_animatedimage::invalidSource() QCOMPARE(anim->frameCount(), 0); } -QTEST_MAIN(tst_animatedimage) +QTEST_MAIN(tst_qmlgraphicsanimatedimage) #include "tst_qmlgraphicsanimatedimage.moc" diff --git a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp b/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp index 7fdc4fb..b503571 100644 --- a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp +++ b/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include <qtest.h> +#include <QtTest/QSignalSpy> #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlcomponent.h> #include <private/qmlgraphicsflickable_p.h> @@ -56,6 +57,10 @@ private slots: void horizontalViewportSize(); void verticalViewportSize(); void properties(); + void overShoot(); + void maximumFlickVelocity(); + void flickDeceleration(); + void pressDelay(); private: QmlEngine engine; @@ -140,6 +145,80 @@ void tst_qmlgraphicsflickable::properties() delete obj; } +void tst_qmlgraphicsflickable::overShoot() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Flickable { overShoot: false; }", QUrl::fromLocalFile("")); + QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create()); + QSignalSpy spy(flickable, SIGNAL(overShootChanged())); + + QVERIFY(flickable); + QVERIFY(!flickable->overShoot()); + + flickable->setOverShoot(true); + QVERIFY(flickable->overShoot()); + QCOMPARE(spy.count(),1); + flickable->setOverShoot(true); + QCOMPARE(spy.count(),1); + + flickable->setOverShoot(false); + QVERIFY(!flickable->overShoot()); + QCOMPARE(spy.count(),2); + flickable->setOverShoot(false); + QCOMPARE(spy.count(),2); +} + +void tst_qmlgraphicsflickable::maximumFlickVelocity() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile("")); + QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create()); + QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->maximumFlickVelocity(), 1.0); + + flickable->setMaximumFlickVelocity(2.0); + QCOMPARE(flickable->maximumFlickVelocity(), 2.0); + QCOMPARE(spy.count(),1); + flickable->setMaximumFlickVelocity(2.0); + QCOMPARE(spy.count(),1); +} + +void tst_qmlgraphicsflickable::flickDeceleration() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile("")); + QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create()); + QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->flickDeceleration(), 1.0); + + flickable->setFlickDeceleration(2.0); + QCOMPARE(flickable->flickDeceleration(), 2.0); + QCOMPARE(spy.count(),1); + flickable->setFlickDeceleration(2.0); + QCOMPARE(spy.count(),1); +} + +void tst_qmlgraphicsflickable::pressDelay() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Flickable { pressDelay: 100; }", QUrl::fromLocalFile("")); + QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create()); + QSignalSpy spy(flickable, SIGNAL(pressDelayChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->pressDelay(), 100); + + flickable->setPressDelay(200); + QCOMPARE(flickable->pressDelay(), 200); + QCOMPARE(spy.count(),1); + flickable->setPressDelay(200); + QCOMPARE(spy.count(),1); +} + QTEST_MAIN(tst_qmlgraphicsflickable) #include "tst_qmlgraphicsflickable.moc" diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp index 40b54d2..00127e5 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -70,9 +70,9 @@ private slots: private: QmlView *createView(const QString &filename); template<typename T> - T *findItem(QmlGraphicsItem *parent, const QString &id, int index=-1); + T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); template<typename T> - QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName); + QList<T*> findItems(QGraphicsObject *parent, const QString &objectName); void dumpTree(QmlGraphicsItem *parent, int depth = 0); }; @@ -160,7 +160,7 @@ void tst_QmlGraphicsGridView::items() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -208,7 +208,7 @@ void tst_QmlGraphicsGridView::changed() canvas->execute(); qApp->processEvents(); - QmlGraphicsFlickable *gridview = findItem<QmlGraphicsFlickable>(canvas->root(), "grid"); + QmlGraphicsFlickable *gridview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -241,7 +241,7 @@ void tst_QmlGraphicsGridView::inserted() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -322,7 +322,7 @@ void tst_QmlGraphicsGridView::removed() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -482,7 +482,7 @@ void tst_QmlGraphicsGridView::moved() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -578,15 +578,12 @@ void tst_QmlGraphicsGridView::currentIndex() ctxt->setContextProperty("testModel", &model); QString filename(SRCDIR "/data/gridview-initCurrent.qml"); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -722,7 +719,7 @@ void tst_QmlGraphicsGridView::changeFlow() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -827,7 +824,7 @@ void tst_QmlGraphicsGridView::positionViewAtIndex() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -907,10 +904,7 @@ QmlView *tst_QmlGraphicsGridView::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } @@ -920,10 +914,10 @@ QmlView *tst_QmlGraphicsGridView::createView(const QString &filename) item must also evaluate the {index} expression equal to index */ template<typename T> -T *tst_QmlGraphicsGridView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index) +T *tst_QmlGraphicsGridView::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; + //qDebug() << parent->childItems().count() << "children"; for (int i = 0; i < parent->childItems().count(); ++i) { QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i)); if(!item) @@ -950,11 +944,11 @@ T *tst_QmlGraphicsGridView::findItem(QmlGraphicsItem *parent, const QString &obj } template<typename T> -QList<T*> tst_QmlGraphicsGridView::findItems(QmlGraphicsItem *parent, const QString &objectName) +QList<T*> tst_QmlGraphicsGridView::findItems(QGraphicsObject *parent, const QString &objectName) { QList<T*> items; const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; + //qDebug() << parent->childItems().count() << "children"; for (int i = 0; i < parent->childItems().count(); ++i) { QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i)); if(!item) diff --git a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp index 6673ced2..820a6de 100644 --- a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp +++ b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp @@ -39,11 +39,12 @@ ** ****************************************************************************/ #include <qtest.h> +#include <QtTest/QSignalSpy> #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlcomponent.h> #include <QtDeclarative/qmlcontext.h> #include <QtDeclarative/qmlview.h> -#include <qmlgraphicsitem.h> +#include <QtDeclarative/qmlgraphicsitem.h> class tst_QmlGraphicsItem : public QObject @@ -55,10 +56,13 @@ public: private slots: void keys(); void keyNavigation(); + void smooth(); + void clip(); private: template<typename T> - T *findItem(QmlGraphicsItem *parent, const QString &objectName); + T *findItem(QGraphicsObject *parent, const QString &objectName); + QmlEngine engine; }; class KeysTestObject : public QObject @@ -108,7 +112,7 @@ void tst_QmlGraphicsItem::keys() QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - canvas->setUrl(QUrl::fromLocalFile(SRCDIR "/data/keys.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml")); KeysTestObject *testObject = new KeysTestObject; canvas->rootContext()->setContextProperty("keysTestObject", testObject); @@ -190,7 +194,7 @@ void tst_QmlGraphicsItem::keyNavigation() QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - canvas->setUrl(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml")); canvas->execute(); canvas->show(); qApp->processEvents(); @@ -200,7 +204,7 @@ void tst_QmlGraphicsItem::keyNavigation() QFocusEvent fe(QEvent::FocusIn); QApplication::sendEvent(canvas, &fe); - QmlGraphicsItem *item = findItem<QmlGraphicsItem>(canvas->root(), "item1"); + QmlGraphicsItem *item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item1"); QVERIFY(item); QVERIFY(item->hasFocus()); @@ -209,7 +213,7 @@ void tst_QmlGraphicsItem::keyNavigation() QApplication::sendEvent(canvas, &key); QVERIFY(key.isAccepted()); - item = findItem<QmlGraphicsItem>(canvas->root(), "item2"); + item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item2"); QVERIFY(item); QVERIFY(item->hasFocus()); @@ -218,7 +222,7 @@ void tst_QmlGraphicsItem::keyNavigation() QApplication::sendEvent(canvas, &key); QVERIFY(key.isAccepted()); - item = findItem<QmlGraphicsItem>(canvas->root(), "item4"); + item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item4"); QVERIFY(item); QVERIFY(item->hasFocus()); @@ -227,7 +231,7 @@ void tst_QmlGraphicsItem::keyNavigation() QApplication::sendEvent(canvas, &key); QVERIFY(key.isAccepted()); - item = findItem<QmlGraphicsItem>(canvas->root(), "item3"); + item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item3"); QVERIFY(item); QVERIFY(item->hasFocus()); @@ -236,21 +240,67 @@ void tst_QmlGraphicsItem::keyNavigation() QApplication::sendEvent(canvas, &key); QVERIFY(key.isAccepted()); - item = findItem<QmlGraphicsItem>(canvas->root(), "item1"); + item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item1"); QVERIFY(item); QVERIFY(item->hasFocus()); } +void tst_QmlGraphicsItem::smooth() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile("")); + QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create()); + QSignalSpy spy(item, SIGNAL(smoothChanged())); + + QVERIFY(item); + QVERIFY(!item->smooth()); + + item->setSmooth(true); + QVERIFY(item->smooth()); + QCOMPARE(spy.count(),1); + item->setSmooth(true); + QCOMPARE(spy.count(),1); + + item->setSmooth(false); + QVERIFY(!item->smooth()); + QCOMPARE(spy.count(),2); + item->setSmooth(false); + QCOMPARE(spy.count(),2); +} + +void tst_QmlGraphicsItem::clip() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile("")); + QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create()); + QSignalSpy spy(item, SIGNAL(clipChanged())); + + QVERIFY(item); + QVERIFY(!item->clip()); + + item->setClip(true); + QVERIFY(item->clip()); + QCOMPARE(spy.count(),1); + item->setClip(true); + QCOMPARE(spy.count(),1); + + item->setClip(false); + QVERIFY(!item->clip()); + QCOMPARE(spy.count(),2); + item->setClip(false); + QCOMPARE(spy.count(),2); +} + template<typename T> -T *tst_QmlGraphicsItem::findItem(QmlGraphicsItem *parent, const QString &objectName) +T *tst_QmlGraphicsItem::findItem(QGraphicsObject *parent, const QString &objectName) { if (!parent) return 0; const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->QGraphicsObject::children().count() << "children"; - for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) { - QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->QGraphicsObject::children().at(i)); + for (int i = 0; i < parent->childItems().count(); ++i) { + QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i)); if(!item) continue; //qDebug() << "try" << item; diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp index 560e625..13ed41d 100644 --- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp +++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp @@ -90,9 +90,9 @@ private: template <class T> void clear(); QmlView *createView(const QString &filename); template<typename T> - T *findItem(QmlGraphicsItem *parent, const QString &id, int index=-1); + T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); template<typename T> - QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName); + QList<T*> findItems(QGraphicsObject *parent, const QString &objectName); void dumpTree(QmlGraphicsItem *parent, int depth = 0); }; @@ -316,13 +316,13 @@ void tst_QmlGraphicsListView::items() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QVERIFY(listview->highlightItem() != 0); @@ -343,20 +343,20 @@ void tst_QmlGraphicsListView::items() // switch to other delegate testObject->setAnimate(true); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QVERIFY(listview->currentItem()); // set invalid highlight testObject->setInvalidHighlight(true); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QVERIFY(listview->currentItem()); QVERIFY(listview->highlightItem() == 0); // back to normal highlight testObject->setInvalidHighlight(false); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QVERIFY(listview->currentItem()); QVERIFY(listview->highlightItem() != 0); @@ -396,7 +396,7 @@ void tst_QmlGraphicsListView::changed() canvas->execute(); qApp->processEvents(); - QmlGraphicsFlickable *listview = findItem<QmlGraphicsFlickable>(canvas->root(), "list"); + QmlGraphicsFlickable *listview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -432,7 +432,7 @@ void tst_QmlGraphicsListView::inserted() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -501,6 +501,8 @@ void tst_QmlGraphicsListView::inserted() QCOMPARE(item->y(), i*20.0 - 20.0); } +// QCOMPARE(listview->viewportHeight(), model.count() * 20.0); + delete canvas; } @@ -523,7 +525,7 @@ void tst_QmlGraphicsListView::removed(bool animated) canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -665,7 +667,7 @@ void tst_QmlGraphicsListView::clear() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -702,7 +704,7 @@ void tst_QmlGraphicsListView::moved() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -795,7 +797,7 @@ void tst_QmlGraphicsListView::enforceRange() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QCOMPARE(listview->preferredHighlightBegin(), 100.0); @@ -843,7 +845,7 @@ void tst_QmlGraphicsListView::spacing() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -898,7 +900,7 @@ void tst_QmlGraphicsListView::sections() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -971,15 +973,12 @@ void tst_QmlGraphicsListView::currentIndex() ctxt->setContextProperty("testWrap", QVariant(false)); QString filename(SRCDIR "/data/listview-initCurrent.qml"); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -1061,13 +1060,13 @@ void tst_QmlGraphicsListView::itemList() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "view"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "view"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); - QmlGraphicsVisualItemModel *model = canvas->root()->findChild<QmlGraphicsVisualItemModel*>("itemModel"); + QmlGraphicsVisualItemModel *model = canvas->rootObject()->findChild<QmlGraphicsVisualItemModel*>("itemModel"); QVERIFY(model != 0); QVERIFY(model->count() == 3); @@ -1112,7 +1111,7 @@ void tst_QmlGraphicsListView::cacheBuffer() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -1164,7 +1163,7 @@ void tst_QmlGraphicsListView::positionViewAtIndex() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -1301,10 +1300,7 @@ QmlView *tst_QmlGraphicsListView::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } @@ -1314,10 +1310,10 @@ QmlView *tst_QmlGraphicsListView::createView(const QString &filename) item must also evaluate the {index} expression equal to index */ template<typename T> -T *tst_QmlGraphicsListView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index) +T *tst_QmlGraphicsListView::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; + //qDebug() << parent->childItems().count() << "children"; for (int i = 0; i < parent->childItems().count(); ++i) { QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i)); if(!item) @@ -1342,11 +1338,11 @@ T *tst_QmlGraphicsListView::findItem(QmlGraphicsItem *parent, const QString &obj } template<typename T> -QList<T*> tst_QmlGraphicsListView::findItems(QmlGraphicsItem *parent, const QString &objectName) +QList<T*> tst_QmlGraphicsListView::findItems(QGraphicsObject *parent, const QString &objectName) { QList<T*> items; const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; + //qDebug() << parent->childItems().count() << "children"; for (int i = 0; i < parent->childItems().count(); ++i) { QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i)); if(!item) diff --git a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp index b38e8de..2d3d5ee 100644 --- a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp +++ b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp @@ -42,6 +42,7 @@ #include <QtGui/QGraphicsWidget> #include <QtGui/QGraphicsScene> +#include <QSignalSpy> #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlcomponent.h> #include <private/qmlgraphicsloader_p.h> @@ -259,6 +260,13 @@ void tst_QmlGraphicsLoader::sizeLoaderToItem() loader->setHeight(30); QCOMPARE(rect->width(), 180.0); QCOMPARE(rect->height(), 30.0); + + // notify + QSignalSpy spy(loader, SIGNAL(resizeModeChanged())); + loader->setResizeMode(QmlGraphicsLoader::NoResize); + QCOMPARE(spy.count(),1); + loader->setResizeMode(QmlGraphicsLoader::NoResize); + QCOMPARE(spy.count(),1); } void tst_QmlGraphicsLoader::sizeItemToLoader() @@ -381,7 +389,7 @@ void tst_QmlGraphicsLoader::networkRequestUrl() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory("data"); + server.serveDirectory(SRCDIR "/data"); QmlComponent component(&engine); component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), TEST_FILE("")); @@ -433,7 +441,7 @@ void tst_QmlGraphicsLoader::failNetworkRequest() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory("data"); + server.serveDirectory(SRCDIR "/data"); QTest::ignoreMessage(QtWarningMsg, "(:-1: Network error for URL http://127.0.0.1:14445/IDontExist.qml) "); diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml b/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml new file mode 100644 index 0000000..5acb3e4 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml @@ -0,0 +1,28 @@ +import Qt 4.6 +Rectangle { + id: whiteRect + width: 200 + height: 200 + color: "white" + Rectangle { + id: blackRect + objectName: "blackrect" + color: "black" + y: 50 + x: 50 + width: 100 + height: 100 + opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 + Text { text: blackRect.opacity} + MouseRegion { + objectName: "mouseregion" + anchors.fill: parent + drag.target: blackRect + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: whiteRect.width-blackRect.width + drag.minimumY: 0 + drag.maximumY: whiteRect.height-blackRect.height + } + } + }
\ No newline at end of file diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro b/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro new file mode 100644 index 0000000..7a7c8bd --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro @@ -0,0 +1,9 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui network +macx:CONFIG -= app_bundle + +HEADERS += ../shared/testhttpserver.h +SOURCES += tst_qmlgraphicsmouseregion.cpp ../shared/testhttpserver.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp b/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp new file mode 100644 index 0000000..82da9c8 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 <QtTest/QtTest> +#include <QtTest/QSignalSpy> +#include <private/qmlgraphicsmouseregion_p.h> +#include <QtDeclarative/qmlview.h> + +class tst_QmlGraphicsMouseRegion: public QObject +{ + Q_OBJECT +private slots: + void dragProperties(); +private: + QmlView *createView(const QString &filename); +}; + +void tst_QmlGraphicsMouseRegion::dragProperties() +{ + QmlView *canvas = createView(SRCDIR "/data/dragproperties.qml"); + canvas->execute(); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QmlGraphicsMouseRegion *mouseRegion = canvas->rootObject()->findChild<QmlGraphicsMouseRegion*>("mouseregion"); + QmlGraphicsDrag *drag = mouseRegion->drag(); + QVERIFY(mouseRegion != 0); + QVERIFY(drag != 0); + + // target + QmlGraphicsItem *blackRect = canvas->rootObject()->findChild<QmlGraphicsItem*>("blackrect"); + QVERIFY(blackRect != 0); + QVERIFY(blackRect == drag->target()); + QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(canvas->rootObject()); + QVERIFY(rootItem != 0); + QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); + drag->setTarget(rootItem); + QCOMPARE(targetSpy.count(),1); + drag->setTarget(rootItem); + QCOMPARE(targetSpy.count(),1); + + // axis + QCOMPARE(drag->axis(), QmlGraphicsDrag::XandYAxis); + QSignalSpy axisSpy(drag, SIGNAL(axisChanged())); + drag->setAxis(QmlGraphicsDrag::XAxis); + QCOMPARE(drag->axis(), QmlGraphicsDrag::XAxis); + QCOMPARE(axisSpy.count(),1); + drag->setAxis(QmlGraphicsDrag::XAxis); + QCOMPARE(axisSpy.count(),1); + + // minimum and maximum properties + QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged())); + QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged())); + QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged())); + QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged())); + + QCOMPARE(drag->xmin(), 0.0); + QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width()); + QCOMPARE(drag->ymin(), 0.0); + QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height()); + + drag->setXmin(10); + drag->setXmax(10); + drag->setYmin(10); + drag->setYmax(10); + + QCOMPARE(drag->xmin(), 10.0); + QCOMPARE(drag->xmax(), 10.0); + QCOMPARE(drag->ymin(), 10.0); + QCOMPARE(drag->ymax(), 10.0); + + QCOMPARE(xminSpy.count(),1); + QCOMPARE(xmaxSpy.count(),1); + QCOMPARE(yminSpy.count(),1); + QCOMPARE(ymaxSpy.count(),1); + + drag->setXmin(10); + drag->setXmax(10); + drag->setYmin(10); + drag->setYmax(10); + + QCOMPARE(xminSpy.count(),1); + QCOMPARE(xmaxSpy.count(),1); + QCOMPARE(yminSpy.count(),1); + QCOMPARE(ymaxSpy.count(),1); +} + +QmlView *tst_QmlGraphicsMouseRegion::createView(const QString &filename) +{ + QmlView *canvas = new QmlView(0); + canvas->setFixedSize(240,320); + + canvas->setSource(QUrl::fromLocalFile(filename)); + + return canvas; +} + +QTEST_MAIN(tst_QmlGraphicsMouseRegion) + +#include "tst_qmlgraphicsmouseregion.moc" diff --git a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp index d9ddf4b..a5c0b78 100644 --- a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp +++ b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp @@ -63,8 +63,8 @@ tst_QmlGraphicsParticles::tst_QmlGraphicsParticles() void tst_QmlGraphicsParticles::properties() { QmlView *canvas = createView(SRCDIR "/data/particles.qml"); - QVERIFY(canvas->root()); - QmlGraphicsParticles* particles = canvas->root()->findChild<QmlGraphicsParticles*>("particles"); + QVERIFY(canvas->rootObject()); + QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles"); QVERIFY(particles); particles->setSource(QUrl::fromLocalFile(SRCDIR "/data/particle.png")); @@ -101,8 +101,8 @@ void tst_QmlGraphicsParticles::properties() void tst_QmlGraphicsParticles::runs() { QmlView *canvas = createView(SRCDIR "/data/particles.qml"); - QVERIFY(canvas->root()); - QmlGraphicsParticles* particles = canvas->root()->findChild<QmlGraphicsParticles*>("particles"); + QVERIFY(canvas->rootObject()); + QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles"); QVERIFY(particles); QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash. } @@ -112,10 +112,7 @@ QmlView *tst_QmlGraphicsParticles::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); canvas->execute(); return canvas; diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp index 90e0de3..072f740 100644 --- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp +++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp @@ -71,9 +71,9 @@ private slots: private: QmlView *createView(const QString &filename); template<typename T> - T *findItem(QmlGraphicsItem *parent, const QString &objectName, int index=-1); + T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1); template<typename T> - QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName); + QList<T*> findItems(QGraphicsObject *parent, const QString &objectName); }; class TestObject : public QObject @@ -204,7 +204,7 @@ void tst_QmlGraphicsPathView::items() canvas->execute(); qApp->processEvents(); - QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->root(), "view"); + QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view"); QVERIFY(pathview != 0); QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible @@ -326,10 +326,10 @@ void tst_QmlGraphicsPathView::dataModel() canvas->execute(); qApp->processEvents(); - QmlGraphicsPathView *pathview = qobject_cast<QmlGraphicsPathView*>(canvas->root()); + QmlGraphicsPathView *pathview = qobject_cast<QmlGraphicsPathView*>(canvas->rootObject()); QVERIFY(pathview != 0); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QmlGraphicsItem *item = findItem<QmlGraphicsItem>(pathview, "wrapper", 0); @@ -352,7 +352,7 @@ void tst_QmlGraphicsPathView::dataModel() QCOMPARE(text->text(), model.name(2)); testObject->setPathItemCount(5); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count(); @@ -398,7 +398,7 @@ void tst_QmlGraphicsPathView::pathMoved() canvas->execute(); qApp->processEvents(); - QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->root(), "view"); + QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view"); QVERIFY(pathview != 0); QmlGraphicsRectangle *firstItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", 0); @@ -430,10 +430,7 @@ QmlView *tst_QmlGraphicsPathView::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } @@ -443,7 +440,7 @@ QmlView *tst_QmlGraphicsPathView::createView(const QString &filename) item must also evaluate the {index} expression equal to index */ template<typename T> -T *tst_QmlGraphicsPathView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index) +T *tst_QmlGraphicsPathView::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->childItems().count() << "children"; @@ -471,7 +468,7 @@ T *tst_QmlGraphicsPathView::findItem(QmlGraphicsItem *parent, const QString &obj } template<typename T> -QList<T*> tst_QmlGraphicsPathView::findItems(QmlGraphicsItem *parent, const QString &objectName) +QList<T*> tst_QmlGraphicsPathView::findItems(QGraphicsObject *parent, const QString &objectName) { QList<T*> items; const QMetaObject &mo = T::staticMetaObject; diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml index 022019c..f6376a1 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml +++ b/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml @@ -7,12 +7,12 @@ Item { columns: 3 add: Transition { NumberAnimation { - matchProperties: "x,y"; + properties: "x,y"; } } move: Transition { NumberAnimation { - matchProperties: "x,y"; + properties: "x,y"; } } Rectangle { diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml index eba165c..c113a36 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml +++ b/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml @@ -6,12 +6,12 @@ Item { Row { add: Transition { NumberAnimation { - matchProperties: "x"; + properties: "x"; } } move: Transition { NumberAnimation { - matchProperties: "x"; + properties: "x"; } } Rectangle { diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml index 8e3abbd..10f6cbb 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml +++ b/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml @@ -6,12 +6,12 @@ Item { Column { add: Transition { NumberAnimation { - matchProperties: "y"; + properties: "y"; } } move: Transition { NumberAnimation { - matchProperties: "y"; + properties: "y"; } } Rectangle { diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp index d6b4f87..b51266a 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp +++ b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp @@ -43,6 +43,7 @@ #include <qmlview.h> #include <private/qmlgraphicsrectangle_p.h> #include <qmlexpression.h> +#include "../../../shared/util.h" class tst_QmlGraphicsPositioners : public QObject { @@ -75,15 +76,14 @@ void tst_QmlGraphicsPositioners::test_horizontal() QmlView *canvas = createView(SRCDIR "/data/horizontal.qml"); canvas->execute(); - qApp->processEvents(); - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -99,15 +99,14 @@ void tst_QmlGraphicsPositioners::test_horizontal_spacing() QmlView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml"); canvas->execute(); - qApp->processEvents(); - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -123,30 +122,31 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated() QmlView *canvas = createView(SRCDIR "/data/horizontal-animated.qml"); canvas->execute(); - qApp->processEvents(); - //Note that they animate in - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); - QCOMPARE(one->x(), -100.0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); - QCOMPARE(two->x(), -100.0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); + + //Note that they animate in + QCOMPARE(one->x(), -100.0); + QCOMPARE(two->x(), -100.0); QCOMPARE(three->x(), -100.0); - QTest::qWait(300);//Let the animation complete + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->opacity(), 0.0); - QCOMPARE(two->x(), -100.0);//Not 'in' yet - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet + QTRY_COMPARE(two->y(), 0.0); + QTRY_COMPARE(three->x(), 50.0); + QTRY_COMPARE(three->y(), 0.0); //Add 'two' two->setOpacity(1.0); @@ -154,9 +154,9 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated() QTest::qWait(0);//Let the animation start QCOMPARE(two->x(), -100.0); QCOMPARE(three->x(), 50.0); - QTest::qWait(300);//Let the animation complete - QCOMPARE(two->x(), 50.0); - QCOMPARE(three->x(), 100.0); + + QTRY_COMPARE(two->x(), 50.0); + QTRY_COMPARE(three->x(), 100.0); } void tst_QmlGraphicsPositioners::test_vertical() @@ -164,15 +164,14 @@ void tst_QmlGraphicsPositioners::test_vertical() QmlView *canvas = createView(SRCDIR "/data/vertical.qml"); canvas->execute(); - qApp->processEvents(); - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -188,15 +187,14 @@ void tst_QmlGraphicsPositioners::test_vertical_spacing() QmlView *canvas = createView(SRCDIR "/data/vertical-spacing.qml"); canvas->execute(); - qApp->processEvents(); - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -212,41 +210,40 @@ void tst_QmlGraphicsPositioners::test_vertical_animated() QmlView *canvas = createView(SRCDIR "/data/vertical-animated.qml"); canvas->execute(); - qApp->processEvents(); - QTest::qWait(0);//Let the animation start //Note that they animate in - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); QCOMPARE(one->y(), -100.0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); QCOMPARE(two->y(), -100.0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); QCOMPARE(three->y(), -100.0); - QTest::qWait(300);//Let the animation complete + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested - QCOMPARE(one->y(), 0.0); - QCOMPARE(one->x(), 0.0); - QCOMPARE(two->opacity(), 0.0); - QCOMPARE(two->y(), -100.0);//Not 'in' yet - QCOMPARE(two->x(), 0.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(three->x(), 0.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet + QTRY_COMPARE(two->x(), 0.0); + QTRY_COMPARE(three->y(), 50.0); + QTRY_COMPARE(three->x(), 0.0); //Add 'two' two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); + QTRY_COMPARE(two->opacity(), 1.0); QTest::qWait(0);//Let the animation start QCOMPARE(two->y(), -100.0); QCOMPARE(three->y(), 50.0); - QTest::qWait(300);//Let the animation complete - QCOMPARE(two->y(), 50.0); - QCOMPARE(three->y(), 100.0); + + QTRY_COMPARE(two->y(), 50.0); + QTRY_COMPARE(three->y(), 100.0); } @@ -255,17 +252,16 @@ void tst_QmlGraphicsPositioners::test_grid() QmlView *canvas = createView("data/grid.qml"); canvas->execute(); - qApp->processEvents(); - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); - QmlGraphicsRectangle *four = canvas->root()->findChild<QmlGraphicsRectangle*>("four"); + QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four"); QVERIFY(four != 0); - QmlGraphicsRectangle *five = canvas->root()->findChild<QmlGraphicsRectangle*>("five"); + QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -285,17 +281,16 @@ void tst_QmlGraphicsPositioners::test_grid_spacing() QmlView *canvas = createView("data/grid-spacing.qml"); canvas->execute(); - qApp->processEvents(); - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); - QmlGraphicsRectangle *four = canvas->root()->findChild<QmlGraphicsRectangle*>("four"); + QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four"); QVERIFY(four != 0); - QmlGraphicsRectangle *five = canvas->root()->findChild<QmlGraphicsRectangle*>("five"); + QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -314,48 +309,47 @@ void tst_QmlGraphicsPositioners::test_grid_animated() { QmlView *canvas = createView(SRCDIR "/data/grid-animated.qml"); canvas->execute(); - qApp->processEvents(); - QTest::qWait(0);//Let the animation start //Note that all animate in - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); QCOMPARE(one->x(), -100.0); QCOMPARE(one->y(), -100.0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); QCOMPARE(two->x(), -100.0); QCOMPARE(two->y(), -100.0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); QCOMPARE(three->x(), -100.0); QCOMPARE(three->y(), -100.0); - QmlGraphicsRectangle *four = canvas->root()->findChild<QmlGraphicsRectangle*>("four"); + QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four"); QVERIFY(four != 0); QCOMPARE(four->x(), -100.0); QCOMPARE(four->y(), -100.0); - QmlGraphicsRectangle *five = canvas->root()->findChild<QmlGraphicsRectangle*>("five"); + QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five"); QVERIFY(five != 0); QCOMPARE(five->x(), -100.0); QCOMPARE(five->y(), -100.0); - QTest::qWait(300);//Let the animation complete - - QCOMPARE(one->y(), 0.0); - QCOMPARE(one->x(), 0.0); - QCOMPARE(two->opacity(), 0.0); - QCOMPARE(two->y(), -100.0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(four->x(), 100.0); - QCOMPARE(five->y(), 50.0); - QCOMPARE(five->x(), 0.0); + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested + + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->y(), -100.0); + QTRY_COMPARE(two->x(), -100.0); + QTRY_COMPARE(three->y(), 0.0); + QTRY_COMPARE(three->x(), 50.0); + QTRY_COMPARE(four->y(), 0.0); + QTRY_COMPARE(four->x(), 100.0); + QTRY_COMPARE(five->y(), 50.0); + QTRY_COMPARE(five->x(), 0.0); //Add 'two' two->setOpacity(1.0); @@ -371,17 +365,17 @@ void tst_QmlGraphicsPositioners::test_grid_animated() QCOMPARE(four->y(), 0.0); QCOMPARE(five->x(), 0.0); QCOMPARE(five->y(), 50.0); - QTest::qWait(300);//Let the animation complete - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(three->x(), 100.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 50.0); - QCOMPARE(five->y(), 50.0); + //Let the animation complete + QTRY_COMPARE(two->x(), 50.0); + QTRY_COMPARE(two->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(three->x(), 100.0); + QTRY_COMPARE(three->y(), 0.0); + QTRY_COMPARE(four->x(), 0.0); + QTRY_COMPARE(four->y(), 50.0); + QTRY_COMPARE(five->x(), 50.0); + QTRY_COMPARE(five->y(), 50.0); } @@ -390,15 +384,14 @@ void tst_QmlGraphicsPositioners::test_repeater() QmlView *canvas = createView("data/repeater.qml"); canvas->execute(); - qApp->processEvents(); - QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -413,10 +406,7 @@ QmlView *tst_QmlGraphicsPositioners::createView(const QString &filename) { QmlView *canvas = new QmlView(0); - QFile file(filename); - file.open(QFile::ReadOnly); - QString xml = file.readAll(); - canvas->setQml(xml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml b/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml new file mode 100644 index 0000000..550ce8d --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml @@ -0,0 +1,11 @@ +import Qt 4.6 + +Row { + Repeater { + objectName: "repeater" + model: 5 + Text { + text: "I'm item " + index + } + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp index a81b990..9e3a028 100644 --- a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp +++ b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp @@ -38,12 +38,20 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include <QtTest/QtTest> +#include <QtTest/QSignalSpy> #include <private/qlistmodelinterface_p.h> -#include <qmlview.h> +#include <QtDeclarative/qmlengine.h> +#include <QtDeclarative/qmlview.h> +#include <QtDeclarative/qmlcontext.h> #include <private/qmlgraphicsrepeater_p.h> #include <private/qmlgraphicstext_p.h> -#include <qmlcontext.h> + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} class tst_QmlGraphicsRepeater : public QObject { @@ -57,11 +65,12 @@ private slots: void stringList(); void dataModel(); void itemModel(); + void properties(); private: QmlView *createView(const QString &filename); template<typename T> - T *findItem(QmlGraphicsItem *parent, const QString &id); + T *findItem(QGraphicsObject *parent, const QString &id); }; class TestObject : public QObject @@ -165,11 +174,11 @@ void tst_QmlGraphicsRepeater::numberModel() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QCOMPARE(repeater->parentItem()->childItems().count(), 5+1); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); delete canvas; @@ -191,7 +200,7 @@ void tst_QmlGraphicsRepeater::objectList() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data QCOMPARE(repeater->property("instantiated").toInt(), 100); @@ -218,10 +227,10 @@ void tst_QmlGraphicsRepeater::stringList() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); - QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->root(), "container"); + QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container"); QVERIFY(container != 0); QCOMPARE(container->childItems().count(), data.count() + 3); @@ -271,10 +280,10 @@ void tst_QmlGraphicsRepeater::dataModel() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); - QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->root(), "container"); + QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container"); QVERIFY(container != 0); QCOMPARE(container->childItems().count(), 4); @@ -296,16 +305,16 @@ void tst_QmlGraphicsRepeater::itemModel() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); - QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->root(), "container"); + QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container"); QVERIFY(container != 0); QCOMPARE(container->childItems().count(), 1); testObject->setUseModel(true); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QCOMPARE(container->childItems().count(), 4); @@ -317,22 +326,46 @@ void tst_QmlGraphicsRepeater::itemModel() delete canvas; } +void tst_QmlGraphicsRepeater::properties() +{ + QmlEngine engine; + QmlComponent component(&engine, TEST_FILE("/properties.qml")); + + QmlGraphicsItem *rootObject = qobject_cast<QmlGraphicsItem*>(component.create()); + QVERIFY(rootObject); + + QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(rootObject, "repeater"); + QVERIFY(repeater); + + QSignalSpy modelSpy(repeater, SIGNAL(modelChanged())); + repeater->setModel(3); + QCOMPARE(modelSpy.count(),1); + repeater->setModel(3); + QCOMPARE(modelSpy.count(),1); + + QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged())); + + QmlComponent rectComponent(&engine); + rectComponent.setData("import Qt 4.6; Rectangle {}", QUrl::fromLocalFile("")); + + repeater->setDelegate(&rectComponent); + QCOMPARE(delegateSpy.count(),1); + repeater->setDelegate(&rectComponent); + QCOMPARE(delegateSpy.count(),1); +} QmlView *tst_QmlGraphicsRepeater::createView(const QString &filename) { QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } template<typename T> -T *tst_QmlGraphicsRepeater::findItem(QmlGraphicsItem *parent, const QString &objectName) +T *tst_QmlGraphicsRepeater::findItem(QGraphicsObject *parent, const QString &objectName) { const QMetaObject &mo = T::staticMetaObject; if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName)) diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp index 11fe689..cc2f929 100644 --- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp +++ b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp @@ -608,8 +608,8 @@ void tst_qmlgraphicstextedit::inputMethodHints() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); - QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit *>(canvas->root()); + QVERIFY(canvas->rootObject() != 0); + QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit *>(canvas->rootObject()); QVERIFY(textEditObject != 0); QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText); textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly); @@ -622,7 +622,7 @@ void tst_qmlgraphicstextedit::cursorDelegate() view->execute(); view->show(); view->setFocus(); - QmlGraphicsTextEdit *textEditObject = view->root()->findChild<QmlGraphicsTextEdit*>("textEditObject"); + QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild<QmlGraphicsTextEdit*>("textEditObject"); QVERIFY(textEditObject != 0); QVERIFY(textEditObject->findChild<QmlGraphicsItem*>("cursorInstance")); //Test Delegate gets created @@ -650,40 +650,34 @@ void tst_qmlgraphicstextedit::delegateLoading() server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay); server.serveDirectory(SRCDIR "/data/http"); QmlView* view = new QmlView(0); - view->setUrl(QUrl("http://localhost:42332/cursorHttpTestPass.qml")); + view->setSource(QUrl("http://localhost:42332/cursorHttpTestPass.qml")); view->execute(); view->show(); view->setFocus(); - QTRY_VERIFY(view->root());//Wait for loading to finish. - QmlGraphicsTextEdit *textEditObject = view->root()->findChild<QmlGraphicsTextEdit*>("textEditObject"); - // view->root()->dumpObjectTree(); + QTRY_VERIFY(view->rootObject());//Wait for loading to finish. + QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild<QmlGraphicsTextEdit*>("textEditObject"); + // view->rootObject()->dumpObjectTree(); QVERIFY(textEditObject != 0); textEditObject->setFocus(true); QmlGraphicsItem *delegate; - delegate = view->root()->findChild<QmlGraphicsItem*>("delegateOkay"); + delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateOkay"); QVERIFY(delegate); - delegate = view->root()->findChild<QmlGraphicsItem*>("delegateSlow"); + delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateSlow"); QVERIFY(delegate); - view->setUrl(QUrl("http://localhost:42332/cursorHttpTestFail1.qml")); + view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml")); view->execute(); view->show(); view->setFocus(); - delegate = view->root()->findChild<QmlGraphicsItem*>("delegateOkay"); - QVERIFY(delegate); - delegate = view->root()->findChild<QmlGraphicsItem*>("delegateFail"); - QVERIFY(!delegate); - view->setUrl(QUrl("http://localhost:42332/cursorHttpTestFail2.qml")); + QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test + view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml")); view->execute(); view->show(); view->setFocus(); - delegate = view->root()->findChild<QmlGraphicsItem*>("delegateOkay"); - QVERIFY(delegate); - delegate = view->root()->findChild<QmlGraphicsItem*>("delegateErrorA"); - QVERIFY(!delegate); + QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test //ErrorB should get a component which is ready but component.create() returns null //Not sure how to accomplish this with QmlGraphicsTextEdits cursor delegate //###This could be a case of overzealous defensive programming - //delegate = view->root()->findChild<QmlGraphicsItem*>("delegateErrorB"); + //delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateErrorB"); //QVERIFY(!delegate); } @@ -698,9 +692,9 @@ void tst_qmlgraphicstextedit::navigation() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput"))); + QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); QTRY_VERIFY(input->hasFocus() == true); @@ -721,9 +715,9 @@ void tst_qmlgraphicstextedit::readOnly() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsTextEdit *edit = qobject_cast<QmlGraphicsTextEdit *>(qvariant_cast<QObject *>(canvas->root()->property("myInput"))); + QmlGraphicsTextEdit *edit = qobject_cast<QmlGraphicsTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(edit != 0); QTRY_VERIFY(edit->hasFocus() == true); @@ -750,10 +744,7 @@ QmlView *tst_qmlgraphicstextedit::createView(const QString &filename) { QmlView *canvas = new QmlView(0); - QFile file(filename); - file.open(QFile::ReadOnly); - QString xml = file.readAll(); - canvas->setQml(xml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml index 7a2e914..493db5b 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml +++ b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml @@ -11,6 +11,7 @@ Rectangle { } TextInput { id: input; focus: true + text: "Needs some text" KeyNavigation.left: firstItem KeyNavigation.right: lastItem KeyNavigation.up: firstItem diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml index 673790d..0c81548 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml +++ b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { property var intInput: intInput diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp index cf08bff..8b45fc7 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp +++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp @@ -352,8 +352,8 @@ void tst_qmlgraphicstextinput::maxLength() canvas->execute(); canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); - QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->root()); + QVERIFY(canvas->rootObject() != 0); + QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject()); QVERIFY(textinputObject != 0); QVERIFY(textinputObject->text().isEmpty()); QVERIFY(textinputObject->maxLength() == 10); @@ -381,8 +381,8 @@ void tst_qmlgraphicstextinput::masks() canvas->execute(); canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); - QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->root()); + QVERIFY(canvas->rootObject() != 0); + QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject()); QVERIFY(textinputObject != 0); QTRY_VERIFY(textinputObject->hasFocus() == true); QVERIFY(textinputObject->text().length() == 0); @@ -407,9 +407,9 @@ void tst_qmlgraphicstextinput::validators() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsTextInput *intInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("intInput"))); + QmlGraphicsTextInput *intInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput"))); QVERIFY(intInput); intInput->setFocus(true); QTRY_VERIFY(intInput->hasFocus()); @@ -430,7 +430,7 @@ void tst_qmlgraphicstextinput::validators() QCOMPARE(intInput->text(), QLatin1String("11")); QCOMPARE(intInput->hasAcceptableInput(), true); - QmlGraphicsTextInput *dblInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("dblInput"))); + QmlGraphicsTextInput *dblInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput"))); QTRY_VERIFY(dblInput); dblInput->setFocus(true); QVERIFY(dblInput->hasFocus() == true); @@ -459,7 +459,7 @@ void tst_qmlgraphicstextinput::validators() QCOMPARE(dblInput->text(), QLatin1String("12.11")); QCOMPARE(dblInput->hasAcceptableInput(), true); - QmlGraphicsTextInput *strInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("strInput"))); + QmlGraphicsTextInput *strInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput"))); QTRY_VERIFY(strInput); strInput->setFocus(true); QVERIFY(strInput->hasFocus() == true); @@ -497,8 +497,8 @@ void tst_qmlgraphicstextinput::inputMethodHints() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); - QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->root()); + QVERIFY(canvas->rootObject() != 0); + QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject()); QVERIFY(textinputObject != 0); QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText); textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly); @@ -508,6 +508,7 @@ void tst_qmlgraphicstextinput::inputMethodHints() /* TextInput element should only handle left/right keys until the cursor reaches the extent of the text, then they should ignore the keys. + */ void tst_qmlgraphicstextinput::navigation() { @@ -516,16 +517,26 @@ void tst_qmlgraphicstextinput::navigation() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput"))); + QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); + input->setCursorPosition(0); QTRY_VERIFY(input->hasFocus() == true); simulateKey(canvas, Qt::Key_Left); QVERIFY(input->hasFocus() == false); simulateKey(canvas, Qt::Key_Right); QVERIFY(input->hasFocus() == true); + //QT-2944: If text is selected, then we should deselect first. + input->setCursorPosition(input->text().length()); + input->setSelectionStart(0); + input->setSelectionEnd(input->text().length()); + QVERIFY(input->selectionStart() != input->selectionEnd()); + simulateKey(canvas, Qt::Key_Right); + QVERIFY(input->selectionStart() == input->selectionEnd()); + QVERIFY(input->selectionStart() == input->text().length()); + QVERIFY(input->hasFocus() == true); simulateKey(canvas, Qt::Key_Right); QVERIFY(input->hasFocus() == false); simulateKey(canvas, Qt::Key_Left); @@ -538,7 +549,7 @@ void tst_qmlgraphicstextinput::cursorDelegate() view->execute(); view->show(); view->setFocus(); - QmlGraphicsTextInput *textInputObject = view->root()->findChild<QmlGraphicsTextInput*>("textInputObject"); + QmlGraphicsTextInput *textInputObject = view->rootObject()->findChild<QmlGraphicsTextInput*>("textInputObject"); QVERIFY(textInputObject != 0); QVERIFY(textInputObject->findChild<QmlGraphicsItem*>("cursorInstance")); //Test Delegate gets created @@ -567,9 +578,9 @@ void tst_qmlgraphicstextinput::readOnly() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("myInput"))); + QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); QTRY_VERIFY(input->hasFocus() == true); @@ -596,10 +607,7 @@ QmlView *tst_qmlgraphicstextinput::createView(const QString &filename) { QmlView *canvas = new QmlView(0); - QFile file(filename); - file.open(QFile::ReadOnly); - QString xml = file.readAll(); - canvas->setQml(xml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } diff --git a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml index b8524af..0bc8263 100644 --- a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml +++ b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml @@ -17,6 +17,7 @@ Grid { WebView { id: webView + width: 150 // force predictable for test newWindowComponent: webViewPage newWindowParent: pages url: "newwindows.html" diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp index e7b996d..f3c39f8 100644 --- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp +++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp @@ -304,6 +304,9 @@ void tst_qmlgraphicswebview::multipleWindows() QmlGraphicsGrid *grid = qobject_cast<QmlGraphicsGrid*>(component.create()); QVERIFY(grid != 0); QTRY_COMPARE(grid->children().count(), 2+5); // Component, Loader, 5 WebViews + QmlGraphicsItem* popup = qobject_cast<QmlGraphicsItem*>(grid->children().at(3)); // first popup after Component, Loaded, original. + QVERIFY(popup != 0); + QTRY_COMPARE(popup->x(), 150.0); } void tst_qmlgraphicswebview::loadError() diff --git a/tests/auto/declarative/qmlimageprovider/data/exists.png b/tests/auto/declarative/qmlimageprovider/data/exists.png Binary files differnew file mode 100644 index 0000000..399bd0b --- /dev/null +++ b/tests/auto/declarative/qmlimageprovider/data/exists.png diff --git a/tests/auto/declarative/qmlimageprovider/data/exists1.png b/tests/auto/declarative/qmlimageprovider/data/exists1.png Binary files differnew file mode 100644 index 0000000..399bd0b --- /dev/null +++ b/tests/auto/declarative/qmlimageprovider/data/exists1.png diff --git a/tests/auto/declarative/qmlimageprovider/data/exists2.png b/tests/auto/declarative/qmlimageprovider/data/exists2.png Binary files differnew file mode 100644 index 0000000..399bd0b --- /dev/null +++ b/tests/auto/declarative/qmlimageprovider/data/exists2.png diff --git a/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro b/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro new file mode 100644 index 0000000..0ef7739 --- /dev/null +++ b/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro @@ -0,0 +1,12 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +QT += network +macx:CONFIG -= app_bundle + +SOURCES += tst_qmlimageprovider.cpp + +# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage +# LIBS += -lgcov + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp new file mode 100644 index 0000000..d07558a --- /dev/null +++ b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 <QtTest/QtTest> +#include <QtDeclarative/qmlengine.h> +#include <QtDeclarative/qmlimageprovider.h> +#include <private/qmlgraphicsimage_p.h> + +// QmlImageProvider::request() is run in an idle thread where possible +// Be generous in our timeout. +#define TRY_WAIT(expr) \ + do { \ + for (int ii = 0; ii < 10; ++ii) { \ + if ((expr)) break; \ + QTest::qWait(100); \ + } \ + QVERIFY((expr)); \ + } while (false) + + +class tst_qmlimageprovider : public QObject +{ + Q_OBJECT +public: + tst_qmlimageprovider() + { + } + +private slots: + void imageSource(); + void imageSource_data(); + void removeProvider(); + +private: + QmlEngine engine; +}; + +class TestProvider : public QmlImageProvider +{ +public: + QImage request(const QString &id) { + QImage image; + image.load(SRCDIR "/data/" + id); + return image; + } +}; + +void tst_qmlimageprovider::imageSource_data() +{ + QTest::addColumn<QString>("source"); + QTest::addColumn<QString>("error"); + + QTest::newRow("exists") << "image://test/exists.png" << ""; + QTest::newRow("missing") << "image://test/no-such-file.png" + << "\"Failed to get image from provider: image://test/no-such-file.png\" "; + QTest::newRow("unknown provider") << "image://bogus/exists.png" + << "\"Failed to get image from provider: image://bogus/exists.png\" "; +} + +void tst_qmlimageprovider::imageSource() +{ + QFETCH(QString, source); + QFETCH(QString, error); + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + engine.addImageProvider("test", new TestProvider); + QVERIFY(engine.imageProvider("test") != 0); + + QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }"; + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); + QVERIFY(obj != 0); + + TRY_WAIT(obj->status() == QmlGraphicsImage::Loading); + + QCOMPARE(obj->source(), QUrl(source)); + + if (error.isEmpty()) { + TRY_WAIT(obj->status() == QmlGraphicsImage::Ready); + QCOMPARE(obj->width(), 100.); + QCOMPARE(obj->height(), 100.); + QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch); + QCOMPARE(obj->progress(), 1.0); + } else { + TRY_WAIT(obj->status() == QmlGraphicsImage::Error); + } + + delete obj; +} + +void tst_qmlimageprovider::removeProvider() +{ + engine.addImageProvider("test2", new TestProvider); + QVERIFY(engine.imageProvider("test2") != 0); + + // add provider, confirm it works + QString componentStr = "import Qt 4.6\nImage { source: \"image://test2/exists1.png\" }"; + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); + QVERIFY(obj != 0); + + TRY_WAIT(obj->status() == QmlGraphicsImage::Loading); + TRY_WAIT(obj->status() == QmlGraphicsImage::Ready); + + QCOMPARE(obj->width(), 100.0); + + // remove the provider and confirm + QString error("\"Failed to get image from provider: image://test2/exists2.png\" "); + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + engine.removeImageProvider("test2"); + + obj->setSource(QUrl("image://test2/exists2.png")); + + TRY_WAIT(obj->status() == QmlGraphicsImage::Loading); + TRY_WAIT(obj->status() == QmlGraphicsImage::Error); + + delete obj; +} + + +QTEST_MAIN(tst_qmlimageprovider) + +#include "tst_qmlimageprovider.moc" diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index fa45a01..e70c7f1 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -51,6 +51,8 @@ public: tst_QmlListModel() {} private slots: + void static_types(); + void static_types_data(); void static_i18n(); void static_nestedElements(); void static_nestedElements_data(); @@ -223,6 +225,59 @@ void tst_QmlListModel::dynamic() QCOMPARE(actual,result); } +void tst_QmlListModel::static_types_data() +{ + QTest::addColumn<QString>("qml"); + QTest::addColumn<QVariant>("value"); + + QTest::newRow("string") + << "ListElement { foo: \"bar\" }" + << QVariant(QString("bar")); + + QTest::newRow("real") + << "ListElement { foo: 10.5 }" + << QVariant(10.5); + + QTest::newRow("real0") + << "ListElement { foo: 0 }" + << QVariant(double(0)); + + QTest::newRow("bool") + << "ListElement { foo: false }" + << QVariant(false); + + QTest::newRow("bool") + << "ListElement { foo: true }" + << QVariant(true); +} + +void tst_QmlListModel::static_types() +{ + QFETCH(QString, qml); + QFETCH(QVariant, value); + + qml = "import Qt 4.6\nListModel { " + qml + " }"; + + QmlEngine engine; + QmlComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + QVERIFY(!component.isError()); + + QmlListModel *obj = qobject_cast<QmlListModel*>(component.create()); + QVERIFY(obj != 0); + + QScriptValue actual = obj->get(0).property(QLatin1String("foo")); + + QCOMPARE(actual.isString(), value.type() == QVariant::String); + QCOMPARE(actual.isBoolean(), value.type() == QVariant::Bool); + QCOMPARE(actual.isNumber(), value.type() == QVariant::Double); + + QCOMPARE(actual.toString(), value.toString()); + + delete obj; +} + void tst_QmlListModel::error_data() { QTest::addColumn<QString>("qml"); @@ -246,7 +301,7 @@ void tst_QmlListModel::error_data() QTest::newRow("bindings not allowed in ListElement") << "import Qt 4.6\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }" - << "QTBUG-6203 ListElement should not allow binding its data to something"; + << "ListElement: cannot use script for property value"; QTest::newRow("random object list properties allowed in ListElement") << "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp index d668bf6..91ff727 100644 --- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp +++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp @@ -122,6 +122,9 @@ private slots: //writeToReadOnly(); + // Bugs + void crashOnValueProperty(); + private: QmlEngine engine; }; @@ -208,6 +211,9 @@ private: QUrl m_url; }; +QML_DECLARE_TYPE(PropertyObject); +QML_DEFINE_TYPE(Test,1,0,PropertyObject,PropertyObject); + void tst_qmlmetaproperty::qmlmetaproperty_object() { QObject object; // Has no default property @@ -1118,6 +1124,30 @@ void tst_qmlmetaproperty::writeObjectToQmlList() QCOMPARE(container->qmlChildren()->at(1), object); } +void tst_qmlmetaproperty::crashOnValueProperty() +{ + QmlEngine *engine = new QmlEngine; + QmlComponent component(engine); + + component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl()); + PropertyObject *obj = qobject_cast<PropertyObject*>(component.create()); + QVERIFY(obj != 0); + + QmlMetaProperty p = QmlMetaProperty::createProperty(obj, "wrectProperty.x", qmlContext(obj)); + QCOMPARE(p.name(), QString("wrectProperty.x")); + + QCOMPARE(p.read(), QVariant(10)); + + //don't crash once the engine is deleted + delete engine; + engine = 0; + + QCOMPARE(p.propertyTypeName(), "int"); + QCOMPARE(p.read(), QVariant(10)); + p.write(QVariant(20)); + QCOMPARE(p.read(), QVariant(20)); +} + QTEST_MAIN(tst_qmlmetaproperty) #include "tst_qmlmetaproperty.moc" diff --git a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp index 4ca132e..6d1887f 100644 --- a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp +++ b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp @@ -157,9 +157,12 @@ void tst_qmlmetatype::copy() QT_COPY_TEST(QStringList, QStringList() << "QML" << "Rocks"); QT_COPY_TEST(QByteArray, QByteArray("0x1102DDD")); QT_COPY_TEST(QBitArray, QBitArray(102, true)); - QT_COPY_TEST(QDate, QDate::currentDate()); - QT_COPY_TEST(QTime, QTime::currentTime()); - QT_COPY_TEST(QDateTime, QDateTime::currentDateTime()); + QDate cd = QDate::currentDate(); + QT_COPY_TEST(QDate, cd); + QTime ct = QTime::currentTime(); + QT_COPY_TEST(QTime, ct); + QDateTime cdt = QDateTime::currentDateTime(); + QT_COPY_TEST(QDateTime, cdt); QT_COPY_TEST(QUrl, QUrl("http://www.nokia.com")); QT_COPY_TEST(QLocale, QLocale(QLocale::English, QLocale::Australia)); QT_COPY_TEST(QRect, QRect(-10, 10, 102, 99)); diff --git a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp b/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp index 3161cbc..30f2fea 100644 --- a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp +++ b/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp @@ -45,12 +45,12 @@ #include <private/qnumberformat_p.h> #include <private/qmlnumberformatter_p.h> -class tst_numberformat : public QObject +class tst_qmlnumberformatter : public QObject { Q_OBJECT public: - tst_numberformat(); - + tst_qmlnumberformatter(); + void init() {} void initTestCase() {} @@ -67,7 +67,7 @@ private: QStringList texts; }; -tst_numberformat::tst_numberformat() +tst_qmlnumberformatter::tst_qmlnumberformatter() { strings << "100.0" << "12345" @@ -177,7 +177,7 @@ tst_numberformat::tst_numberformat() << "texts.size()" << texts.size(); } -void tst_numberformat::text_data() +void tst_qmlnumberformatter::text_data() { QTest::addColumn<QString>("string"); QTest::addColumn<QString>("format"); @@ -194,7 +194,7 @@ void tst_numberformat::text_data() } -void tst_numberformat::text() +void tst_qmlnumberformatter::text() { QFETCH(QString, string); QFETCH(QString, format); @@ -217,6 +217,6 @@ void tst_numberformat::text() delete formatter; } -QTEST_MAIN(tst_numberformat) +QTEST_MAIN(tst_qmlnumberformatter) #include "tst_qmlnumberformatter.moc" diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp index 4402d03..81145a8 100644 --- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp +++ b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp @@ -46,11 +46,11 @@ #include <private/qmlpropertychanges_p.h> #include <private/qmlstategroup_p.h> -class tst_states : public QObject +class tst_qmlstates : public QObject { Q_OBJECT public: - tst_states() {} + tst_qmlstates() {} private: static QByteArray fullDataPath(const QString &path); @@ -81,12 +81,12 @@ private slots: void nonExistantProperty(); }; -QByteArray tst_states::fullDataPath(const QString &path) +QByteArray tst_qmlstates::fullDataPath(const QString &path) { return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8(); } -void tst_states::basicChanges() +void tst_qmlstates::basicChanges() { QmlEngine engine; @@ -156,7 +156,7 @@ void tst_states::basicChanges() } } -void tst_states::basicExtension() +void tst_qmlstates::basicExtension() { QmlEngine engine; @@ -220,7 +220,7 @@ void tst_states::basicExtension() } } -void tst_states::basicBinding() +void tst_qmlstates::basicBinding() { QmlEngine engine; @@ -346,7 +346,7 @@ Q_SIGNALS: QML_DECLARE_TYPE(MyRect) QML_DEFINE_TYPE(Qt.test, 1, 0, MyRectangle,MyRect); -void tst_states::signalOverride() +void tst_qmlstates::signalOverride() { QmlEngine engine; @@ -383,7 +383,7 @@ void tst_states::signalOverride() } } -void tst_states::signalOverrideCrash() +void tst_qmlstates::signalOverrideCrash() { QmlEngine engine; @@ -395,7 +395,7 @@ void tst_states::signalOverrideCrash() rect->doSomething(); } -void tst_states::parentChange() +void tst_qmlstates::parentChange() { QmlEngine engine; @@ -462,7 +462,7 @@ void tst_states::parentChange() } } -void tst_states::parentChangeErrors() +void tst_qmlstates::parentChangeErrors() { QmlEngine engine; @@ -499,7 +499,7 @@ void tst_states::parentChangeErrors() } } -void tst_states::anchorChanges() +void tst_qmlstates::anchorChanges() { QmlEngine engine; @@ -527,7 +527,7 @@ void tst_states::anchorChanges() delete rect; } -void tst_states::anchorChanges2() +void tst_qmlstates::anchorChanges2() { QmlEngine engine; @@ -548,7 +548,7 @@ void tst_states::anchorChanges2() delete rect; } -void tst_states::anchorChanges3() +void tst_qmlstates::anchorChanges3() { QmlEngine engine; @@ -594,7 +594,7 @@ void tst_states::anchorChanges3() delete rect; } -void tst_states::anchorChanges4() +void tst_qmlstates::anchorChanges4() { QmlEngine engine; @@ -625,7 +625,7 @@ void tst_states::anchorChanges4() delete rect; } -void tst_states::anchorChanges5() +void tst_qmlstates::anchorChanges5() { QmlEngine engine; @@ -656,7 +656,7 @@ void tst_states::anchorChanges5() delete rect; } -void tst_states::script() +void tst_qmlstates::script() { QmlEngine engine; @@ -675,7 +675,7 @@ void tst_states::script() } } -void tst_states::restoreEntryValues() +void tst_qmlstates::restoreEntryValues() { QmlEngine engine; @@ -692,7 +692,7 @@ void tst_states::restoreEntryValues() QCOMPARE(rect->color(),QColor("blue")); } -void tst_states::explicitChanges() +void tst_qmlstates::explicitChanges() { QmlEngine engine; @@ -722,7 +722,7 @@ void tst_states::explicitChanges() QCOMPARE(rect->color(),QColor("yellow")); } -void tst_states::propertyErrors() +void tst_qmlstates::propertyErrors() { QmlEngine engine; QmlComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml"); @@ -736,7 +736,7 @@ void tst_states::propertyErrors() rect->setState("blue"); } -void tst_states::incorrectRestoreBug() +void tst_qmlstates::incorrectRestoreBug() { QmlEngine engine; @@ -762,7 +762,7 @@ void tst_states::incorrectRestoreBug() QCOMPARE(rect->color(),QColor("green")); } -void tst_states::autoStateAtStartupRestoreBug() +void tst_qmlstates::autoStateAtStartupRestoreBug() { QmlEngine engine; @@ -779,7 +779,7 @@ void tst_states::autoStateAtStartupRestoreBug() delete obj; } -void tst_states::deletingChange() +void tst_qmlstates::deletingChange() { QmlEngine engine; @@ -811,7 +811,7 @@ void tst_states::deletingChange() delete rect; } -void tst_states::deletingState() +void tst_qmlstates::deletingState() { QmlEngine engine; @@ -842,7 +842,7 @@ void tst_states::deletingState() delete rect; } -void tst_states::tempState() +void tst_qmlstates::tempState() { QmlEngine engine; @@ -856,7 +856,7 @@ void tst_states::tempState() QCOMPARE(rect->state(), QLatin1String("idle")); } -void tst_states::illegalTempState() +void tst_qmlstates::illegalTempState() { QmlEngine engine; @@ -869,7 +869,7 @@ void tst_states::illegalTempState() QCOMPARE(rect->state(), QLatin1String("placed")); } -void tst_states::nonExistantProperty() +void tst_qmlstates::nonExistantProperty() { QmlEngine engine; @@ -882,6 +882,6 @@ void tst_states::nonExistantProperty() QCOMPARE(rect->state(), QLatin1String("blue")); } -QTEST_MAIN(tst_states) +QTEST_MAIN(tst_qmlstates) #include "tst_qmlstates.moc" diff --git a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp index 47b35f7..f99d3ce 100644 --- a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp +++ b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp @@ -46,11 +46,11 @@ #include <private/qmlvaluetype_p.h> #include "testtypes.h" -class tst_valuetypes : public QObject +class tst_qmlvaluetypes : public QObject { Q_OBJECT public: - tst_valuetypes() {} + tst_qmlvaluetypes() {} private slots: void point(); @@ -84,7 +84,7 @@ inline QUrl TEST_FILE(const QString &filename) return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); } -void tst_valuetypes::point() +void tst_qmlvaluetypes::point() { { QmlComponent component(&engine, TEST_FILE("point_read.qml")); @@ -109,7 +109,7 @@ void tst_valuetypes::point() } } -void tst_valuetypes::pointf() +void tst_qmlvaluetypes::pointf() { { QmlComponent component(&engine, TEST_FILE("pointf_read.qml")); @@ -134,7 +134,7 @@ void tst_valuetypes::pointf() } } -void tst_valuetypes::size() +void tst_qmlvaluetypes::size() { { QmlComponent component(&engine, TEST_FILE("size_read.qml")); @@ -159,7 +159,7 @@ void tst_valuetypes::size() } } -void tst_valuetypes::sizef() +void tst_qmlvaluetypes::sizef() { { QmlComponent component(&engine, TEST_FILE("sizef_read.qml")); @@ -184,7 +184,7 @@ void tst_valuetypes::sizef() } } -void tst_valuetypes::rect() +void tst_qmlvaluetypes::rect() { { QmlComponent component(&engine, TEST_FILE("rect_read.qml")); @@ -211,7 +211,7 @@ void tst_valuetypes::rect() } } -void tst_valuetypes::rectf() +void tst_qmlvaluetypes::rectf() { { QmlComponent component(&engine, TEST_FILE("rectf_read.qml")); @@ -238,7 +238,7 @@ void tst_valuetypes::rectf() } } -void tst_valuetypes::vector3d() +void tst_qmlvaluetypes::vector3d() { { QmlComponent component(&engine, TEST_FILE("vector3d_read.qml")); @@ -264,7 +264,7 @@ void tst_valuetypes::vector3d() } } -void tst_valuetypes::font() +void tst_qmlvaluetypes::font() { { QmlComponent component(&engine, TEST_FILE("font_read.qml")); @@ -337,7 +337,7 @@ void tst_valuetypes::font() } // Test bindings can write to value types -void tst_valuetypes::bindingAssignment() +void tst_qmlvaluetypes::bindingAssignment() { QmlComponent component(&engine, TEST_FILE("bindingAssignment.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -353,7 +353,7 @@ void tst_valuetypes::bindingAssignment() } // Test bindings can read from value types -void tst_valuetypes::bindingRead() +void tst_qmlvaluetypes::bindingRead() { QmlComponent component(&engine, TEST_FILE("bindingRead.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -369,7 +369,7 @@ void tst_valuetypes::bindingRead() } // Test static values can assign to value types -void tst_valuetypes::staticAssignment() +void tst_qmlvaluetypes::staticAssignment() { QmlComponent component(&engine, TEST_FILE("staticAssignment.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -381,7 +381,7 @@ void tst_valuetypes::staticAssignment() } // Test scripts can read/write value types -void tst_valuetypes::scriptAccess() +void tst_qmlvaluetypes::scriptAccess() { QmlComponent component(&engine, TEST_FILE("scriptAccess.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -395,7 +395,7 @@ void tst_valuetypes::scriptAccess() } // Test that assigning a constant from script removes any binding -void tst_valuetypes::autoBindingRemoval() +void tst_qmlvaluetypes::autoBindingRemoval() { { QmlComponent component(&engine, TEST_FILE("autoBindingRemoval.qml")); @@ -466,7 +466,7 @@ void tst_valuetypes::autoBindingRemoval() } // Test that property value sources assign to value types -void tst_valuetypes::valueSources() +void tst_qmlvaluetypes::valueSources() { QmlComponent component(&engine, TEST_FILE("valueSources.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -489,7 +489,7 @@ static void checkNoErrors(QmlComponent& component) } // Test that property value interceptors can be applied to value types -void tst_valuetypes::valueInterceptors() +void tst_qmlvaluetypes::valueInterceptors() { QmlComponent component(&engine, TEST_FILE("valueInterceptors.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -507,7 +507,7 @@ void tst_valuetypes::valueInterceptors() } // Test that you can't assign a binding to the "root" value type, and a sub-property -void tst_valuetypes::bindingConflict() +void tst_qmlvaluetypes::bindingConflict() { QmlComponent component(&engine, TEST_FILE("bindingConflict.qml")); QCOMPARE(component.isError(), true); @@ -524,7 +524,7 @@ void tst_valuetypes::bindingConflict() // Test that accessing a reference to a valuetype after the owning object is deleted // doesn't crash -void tst_valuetypes::deletedObject() +void tst_qmlvaluetypes::deletedObject() { QmlComponent component(&engine, TEST_FILE("deletedObject.qml")); QTest::ignoreMessage(QtDebugMsg, "Test: 2"); @@ -542,7 +542,7 @@ void tst_valuetypes::deletedObject() } // Test that value types can be assigned to another value type property in a binding -void tst_valuetypes::bindingVariantCopy() +void tst_qmlvaluetypes::bindingVariantCopy() { QmlComponent component(&engine, TEST_FILE("bindingVariantCopy.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -554,7 +554,7 @@ void tst_valuetypes::bindingVariantCopy() } // Test that value types can be assigned to another value type property in script -void tst_valuetypes::scriptVariantCopy() +void tst_qmlvaluetypes::scriptVariantCopy() { QmlComponent component(&engine, TEST_FILE("scriptVariantCopy.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -571,7 +571,7 @@ void tst_valuetypes::scriptVariantCopy() // Test that the value type classes can be used manually -void tst_valuetypes::cppClasses() +void tst_qmlvaluetypes::cppClasses() { CPP_TEST(QmlPointValueType, QPoint(19, 33)); CPP_TEST(QmlPointFValueType, QPointF(33.6, -23)); @@ -583,6 +583,6 @@ void tst_valuetypes::cppClasses() CPP_TEST(QmlFontValueType, QFont("Helvetica")); } -QTEST_MAIN(tst_valuetypes) +QTEST_MAIN(tst_qmlvaluetypes) #include "tst_qmlvaluetypes.moc" diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml index 02a8083..8d67fad 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml @@ -42,7 +42,7 @@ QtObject { openedException = true; } - var headers = "content-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11"; + var headers = "connection: close\r\ncontent-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11"; // Test to the end x.onreadystatechange = function() { diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply index 62ec67b..c4b4bb2 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply @@ -1,4 +1,5 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 Test-Header: TestValue MultiTest-Header: TestValue diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply index 964a7a8..2e29f56 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply @@ -1,2 +1,3 @@ HTTP/1.0 404 Document not found +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp index 54738f6..e675566 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp +++ b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp @@ -48,11 +48,11 @@ #define SERVER_PORT 14445 -class tst_xmlhttprequest : public QObject +class tst_qmlxmlhttprequest : public QObject { Q_OBJECT public: - tst_xmlhttprequest() {} + tst_qmlxmlhttprequest() {} private slots: void initTestCase() { @@ -123,7 +123,7 @@ inline QUrl TEST_FILE(const QString &filename) } // Test that the dom exception codes are correct -void tst_xmlhttprequest::domExceptionCodes() +void tst_qmlxmlhttprequest::domExceptionCodes() { QmlComponent component(&engine, TEST_FILE("domExceptionCodes.qml")); QObject *object = component.create(); @@ -160,7 +160,7 @@ void tst_xmlhttprequest::domExceptionCodes() } while (false) -void tst_xmlhttprequest::callbackException_data() +void tst_qmlxmlhttprequest::callbackException_data() { QTest::addColumn<QString>("which"); QTest::addColumn<int>("line"); @@ -170,7 +170,7 @@ void tst_xmlhttprequest::callbackException_data() QTest::newRow("on-done") << "4" << 15; } -void tst_xmlhttprequest::callbackException() +void tst_qmlxmlhttprequest::callbackException() { // Test exception reporting for exceptions thrown at various points. @@ -194,7 +194,7 @@ void tst_xmlhttprequest::callbackException() // Test that the state value properties on the XMLHttpRequest constructor have the correct values. // ### WebKit does not do this, but it seems to fit the standard and QML better -void tst_xmlhttprequest::staticStateValues() +void tst_qmlxmlhttprequest::staticStateValues() { QmlComponent component(&engine, TEST_FILE("staticStateValues.qml")); QObject *object = component.create(); @@ -210,7 +210,7 @@ void tst_xmlhttprequest::staticStateValues() } // Test that the state value properties on instances have the correct values. -void tst_xmlhttprequest::instanceStateValues() +void tst_qmlxmlhttprequest::instanceStateValues() { QmlComponent component(&engine, TEST_FILE("instanceStateValues.qml")); QObject *object = component.create(); @@ -226,7 +226,7 @@ void tst_xmlhttprequest::instanceStateValues() } // Test calling constructor -void tst_xmlhttprequest::constructor() +void tst_qmlxmlhttprequest::constructor() { QmlComponent component(&engine, TEST_FILE("constructor.qml")); QObject *object = component.create(); @@ -239,7 +239,7 @@ void tst_xmlhttprequest::constructor() } // Test that all the properties are set correctly before any request is sent -void tst_xmlhttprequest::defaultState() +void tst_qmlxmlhttprequest::defaultState() { QmlComponent component(&engine, TEST_FILE("defaultState.qml")); QObject *object = component.create(); @@ -255,7 +255,7 @@ void tst_xmlhttprequest::defaultState() } // Test valid XMLHttpRequest.open() calls -void tst_xmlhttprequest::open() +void tst_qmlxmlhttprequest::open() { // Relative url { @@ -353,7 +353,7 @@ void tst_xmlhttprequest::open() } // Test that calling XMLHttpRequest.open() with an invalid method raises an exception -void tst_xmlhttprequest::open_invalid_method() +void tst_qmlxmlhttprequest::open_invalid_method() { QmlComponent component(&engine, TEST_FILE("open_invalid_method.qml")); QObject *object = component.create(); @@ -365,7 +365,7 @@ void tst_xmlhttprequest::open_invalid_method() } // Test that calling XMLHttpRequest.open() with sync raises an exception -void tst_xmlhttprequest::open_sync() +void tst_qmlxmlhttprequest::open_sync() { QmlComponent component(&engine, TEST_FILE("open_sync.qml")); QObject *object = component.create(); @@ -377,7 +377,7 @@ void tst_xmlhttprequest::open_sync() } // Calling with incorrect arg count raises an exception -void tst_xmlhttprequest::open_arg_count() +void tst_qmlxmlhttprequest::open_arg_count() { { QmlComponent component(&engine, TEST_FILE("open_arg_count.1.qml")); @@ -401,7 +401,7 @@ void tst_xmlhttprequest::open_arg_count() } // Test valid setRequestHeader() calls -void tst_xmlhttprequest::setRequestHeader() +void tst_qmlxmlhttprequest::setRequestHeader() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); @@ -421,7 +421,7 @@ void tst_xmlhttprequest::setRequestHeader() } // Test setting headers before open() throws exception -void tst_xmlhttprequest::setRequestHeader_unsent() +void tst_qmlxmlhttprequest::setRequestHeader_unsent() { QmlComponent component(&engine, TEST_FILE("setRequestHeader_unsent.qml")); QObject *object = component.create(); @@ -432,7 +432,7 @@ void tst_xmlhttprequest::setRequestHeader_unsent() delete object; } -void tst_xmlhttprequest::setRequestHeader_illegalName_data() +void tst_qmlxmlhttprequest::setRequestHeader_illegalName_data() { QTest::addColumn<QString>("name"); @@ -461,7 +461,7 @@ void tst_xmlhttprequest::setRequestHeader_illegalName_data() } // Tests that using illegal header names has no effect -void tst_xmlhttprequest::setRequestHeader_illegalName() +void tst_qmlxmlhttprequest::setRequestHeader_illegalName() { QFETCH(QString, name); @@ -491,7 +491,7 @@ void tst_xmlhttprequest::setRequestHeader_illegalName() } // Test that attempting to set a header after a request is sent throws an exception -void tst_xmlhttprequest::setRequestHeader_sent() +void tst_qmlxmlhttprequest::setRequestHeader_sent() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); @@ -513,7 +513,7 @@ void tst_xmlhttprequest::setRequestHeader_sent() } // Invalid arg count throws exception -void tst_xmlhttprequest::setRequestHeader_args() +void tst_qmlxmlhttprequest::setRequestHeader_args() { QmlComponent component(&engine, TEST_FILE("setRequestHeader_args.qml")); QObject *object = component.create(); @@ -525,7 +525,7 @@ void tst_xmlhttprequest::setRequestHeader_args() } // Test that calling send() in UNSENT state throws an exception -void tst_xmlhttprequest::send_unsent() +void tst_qmlxmlhttprequest::send_unsent() { QmlComponent component(&engine, TEST_FILE("send_unsent.qml")); QObject *object = component.create(); @@ -537,7 +537,7 @@ void tst_xmlhttprequest::send_unsent() } // Test attempting to resend a sent request throws an exception -void tst_xmlhttprequest::send_alreadySent() +void tst_qmlxmlhttprequest::send_alreadySent() { QmlComponent component(&engine, TEST_FILE("send_alreadySent.qml")); QObject *object = component.create(); @@ -550,7 +550,7 @@ void tst_xmlhttprequest::send_alreadySent() } // Test that send for a GET or HEAD ignores data -void tst_xmlhttprequest::send_ignoreData() +void tst_qmlxmlhttprequest::send_ignoreData() { { TestHTTPServer server(SERVER_PORT); @@ -592,7 +592,7 @@ void tst_xmlhttprequest::send_ignoreData() } // Test that send()'ing data works -void tst_xmlhttprequest::send_withdata() +void tst_qmlxmlhttprequest::send_withdata() { // No content-type { @@ -729,7 +729,7 @@ void tst_xmlhttprequest::send_withdata() } // Test abort() has no effect in unsent state -void tst_xmlhttprequest::abort_unsent() +void tst_qmlxmlhttprequest::abort_unsent() { QmlComponent component(&engine, TEST_FILE("abort_unsent.qml")); QObject *object = component.beginCreate(engine.rootContext()); @@ -750,7 +750,7 @@ void tst_xmlhttprequest::abort_unsent() } // Test abort() cancels an open (but unsent) request -void tst_xmlhttprequest::abort_opened() +void tst_qmlxmlhttprequest::abort_opened() { QmlComponent component(&engine, TEST_FILE("abort_opened.qml")); QObject *object = component.beginCreate(engine.rootContext()); @@ -771,7 +771,7 @@ void tst_xmlhttprequest::abort_opened() } // Test abort() aborts in progress send -void tst_xmlhttprequest::abort() +void tst_qmlxmlhttprequest::abort() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); @@ -795,7 +795,7 @@ void tst_xmlhttprequest::abort() delete object; } -void tst_xmlhttprequest::getResponseHeader() +void tst_qmlxmlhttprequest::getResponseHeader() { QmlEngine engine; // Avoid cookie contamination @@ -835,7 +835,7 @@ void tst_xmlhttprequest::getResponseHeader() } // Test getResponseHeader throws an exception in an invalid state -void tst_xmlhttprequest::getResponseHeader_unsent() +void tst_qmlxmlhttprequest::getResponseHeader_unsent() { QmlComponent component(&engine, TEST_FILE("getResponseHeader_unsent.qml")); QObject *object = component.create(); @@ -847,7 +847,7 @@ void tst_xmlhttprequest::getResponseHeader_unsent() } // Test getResponseHeader throws an exception in an invalid state -void tst_xmlhttprequest::getResponseHeader_sent() +void tst_qmlxmlhttprequest::getResponseHeader_sent() { QmlComponent component(&engine, TEST_FILE("getResponseHeader_sent.qml")); QObject *object = component.create(); @@ -859,7 +859,7 @@ void tst_xmlhttprequest::getResponseHeader_sent() } // Invalid arg count throws exception -void tst_xmlhttprequest::getResponseHeader_args() +void tst_qmlxmlhttprequest::getResponseHeader_args() { QmlComponent component(&engine, TEST_FILE("getResponseHeader_args.qml")); QObject *object = component.create(); @@ -870,7 +870,7 @@ void tst_xmlhttprequest::getResponseHeader_args() delete object; } -void tst_xmlhttprequest::getAllResponseHeaders() +void tst_qmlxmlhttprequest::getAllResponseHeaders() { QmlEngine engine; // Avoid cookie contamination @@ -903,7 +903,7 @@ void tst_xmlhttprequest::getAllResponseHeaders() } // Test getAllResponseHeaders throws an exception in an invalid state -void tst_xmlhttprequest::getAllResponseHeaders_unsent() +void tst_qmlxmlhttprequest::getAllResponseHeaders_unsent() { QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_unsent.qml")); QObject *object = component.create(); @@ -915,7 +915,7 @@ void tst_xmlhttprequest::getAllResponseHeaders_unsent() } // Test getAllResponseHeaders throws an exception in an invalid state -void tst_xmlhttprequest::getAllResponseHeaders_sent() +void tst_qmlxmlhttprequest::getAllResponseHeaders_sent() { QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_sent.qml")); QObject *object = component.create(); @@ -927,7 +927,7 @@ void tst_xmlhttprequest::getAllResponseHeaders_sent() } // Invalid arg count throws exception -void tst_xmlhttprequest::getAllResponseHeaders_args() +void tst_qmlxmlhttprequest::getAllResponseHeaders_args() { QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_args.qml")); QObject *object = component.create(); @@ -938,7 +938,7 @@ void tst_xmlhttprequest::getAllResponseHeaders_args() delete object; } -void tst_xmlhttprequest::status() +void tst_qmlxmlhttprequest::status() { { TestHTTPServer server(SERVER_PORT); @@ -995,7 +995,7 @@ void tst_xmlhttprequest::status() } } -void tst_xmlhttprequest::statusText() +void tst_qmlxmlhttprequest::statusText() { { TestHTTPServer server(SERVER_PORT); @@ -1052,7 +1052,7 @@ void tst_xmlhttprequest::statusText() } } -void tst_xmlhttprequest::responseText() +void tst_qmlxmlhttprequest::responseText() { { TestHTTPServer server(SERVER_PORT); @@ -1138,7 +1138,7 @@ void tst_xmlhttprequest::responseText() // Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object // throws an exception -void tst_xmlhttprequest::invalidMethodUsage() +void tst_qmlxmlhttprequest::invalidMethodUsage() { QmlComponent component(&engine, TEST_FILE("invalidMethodUsage.qml")); QObject *object = component.create(); @@ -1162,7 +1162,7 @@ void tst_xmlhttprequest::invalidMethodUsage() } // Test that XMLHttpRequest transparently redirects -void tst_xmlhttprequest::redirects() +void tst_qmlxmlhttprequest::redirects() { { TestHTTPServer server(SERVER_PORT); @@ -1227,7 +1227,7 @@ void tst_xmlhttprequest::redirects() } } -void tst_xmlhttprequest::responseXML_invalid() +void tst_qmlxmlhttprequest::responseXML_invalid() { QmlComponent component(&engine, TEST_FILE("responseXML_invalid.qml")); QObject *object = component.create(); @@ -1241,7 +1241,7 @@ void tst_xmlhttprequest::responseXML_invalid() } // Test the Document DOM element -void tst_xmlhttprequest::document() +void tst_qmlxmlhttprequest::document() { QmlComponent component(&engine, TEST_FILE("document.qml")); QObject *object = component.create(); @@ -1255,7 +1255,7 @@ void tst_xmlhttprequest::document() } // Test the Element DOM element -void tst_xmlhttprequest::element() +void tst_qmlxmlhttprequest::element() { QmlComponent component(&engine, TEST_FILE("element.qml")); QObject *object = component.create(); @@ -1269,7 +1269,7 @@ void tst_xmlhttprequest::element() } // Test the Attr DOM element -void tst_xmlhttprequest::attr() +void tst_qmlxmlhttprequest::attr() { QmlComponent component(&engine, TEST_FILE("attr.qml")); QObject *object = component.create(); @@ -1283,7 +1283,7 @@ void tst_xmlhttprequest::attr() } // Test the Text DOM element -void tst_xmlhttprequest::text() +void tst_qmlxmlhttprequest::text() { QmlComponent component(&engine, TEST_FILE("text.qml")); QObject *object = component.create(); @@ -1297,7 +1297,7 @@ void tst_xmlhttprequest::text() } // Test the CDataSection DOM element -void tst_xmlhttprequest::cdata() +void tst_qmlxmlhttprequest::cdata() { QmlComponent component(&engine, TEST_FILE("cdata.qml")); QObject *object = component.create(); @@ -1310,6 +1310,6 @@ void tst_xmlhttprequest::cdata() delete object; } -QTEST_MAIN(tst_xmlhttprequest) +QTEST_MAIN(tst_qmlxmlhttprequest) #include "tst_qmlxmlhttprequest.moc" diff --git a/tests/auto/declarative/runall.sh b/tests/auto/declarative/runall.sh index 5e32c90..39485d3 100755 --- a/tests/auto/declarative/runall.sh +++ b/tests/auto/declarative/runall.sh @@ -46,13 +46,19 @@ sleep 1 trap "kill $!" EXIT export DISPLAY=:7 -make -k -j1 install 2>&1 | +( make -k -j1 install 2>&1; + for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p') + do + $exe + done +) | while read line do case "$line" in make*Error) echo "$line";; make*Stop) echo "$line";; make*) ;; + install*) ;; */qmake*) ;; */bin/moc*) ;; *targ.debug*) ;; diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp index 56518d7..864bb63 100644 --- a/tests/auto/declarative/shared/debugutil.cpp +++ b/tests/auto/declarative/shared/debugutil.cpp @@ -47,6 +47,8 @@ #include "debugutil_p.h" +#include <iostream> + bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) { QEventLoop loop; QTimer timer; @@ -117,21 +119,22 @@ void QmlDebugTestClient::messageReceived(const QByteArray &ba) tst_QmlDebug_Thread::tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory) - : m_ready(false), m_data(data), m_factory(factory) + : m_data(data), m_factory(factory) { } void tst_QmlDebug_Thread::run() { - QTest::qWait(1000); + bool ok = false; QmlDebugConnection conn; conn.connectToHost("127.0.0.1", 3768); - bool ok = conn.waitForConnected(5000); + ok = conn.waitForConnected(); Q_ASSERT(ok); - while (!m_ready) - QTest::qWait(100); + QEventLoop loop; + connect(m_data, SIGNAL(engineCreated()), &loop, SLOT(quit())); + loop.exec(); m_data->conn = &conn; @@ -139,10 +142,10 @@ void tst_QmlDebug_Thread::run() QObject *test = m_factory->createTest(m_data); Q_ASSERT(test); int code = QTest::qExec(test, QCoreApplication::arguments()); + delete test; emit testsFinished(code); } - int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml) { qputenv("QML_DEBUG_SERVER_PORT", "3768"); @@ -152,7 +155,8 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml tst_QmlDebug_Thread thread(&data, factory); QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int))); - thread.start(); + + QmlDebugService::notifyOnServerStart(&thread, "start"); QmlEngine engine; // blocks until client connects @@ -165,7 +169,7 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml // start the test data.engine = &engine; - thread.m_ready = true; + emit data.engineCreated(); loop.exec(); thread.wait(); @@ -173,4 +177,3 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml return data.exitCode; } - diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h index d32e8ac..6815b3c 100644 --- a/tests/auto/declarative/shared/debugutil_p.h +++ b/tests/auto/declarative/shared/debugutil_p.h @@ -51,6 +51,15 @@ #include <private/qmldebugservice_p.h> #include <private/qmlgraphicsitem_p.h> +class QmlTestFactory; + +class QmlDebugTest +{ +public: + static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000); + + static int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>()); +}; class QmlDebugTestData : public QObject { @@ -68,8 +77,14 @@ public: QList<QmlGraphicsItem *> items; +signals: + void engineCreated(); + public slots: void testsFinished(int code); + +private: + friend class QmlDebugTest; }; @@ -82,14 +97,6 @@ public: virtual QObject *createTest(QmlDebugTestData *data) = 0; }; - -namespace QmlDebugTest { - - bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000); - - int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>()); -} - class QmlDebugTestService : public QmlDebugService { Q_OBJECT @@ -132,8 +139,6 @@ public: void run(); - bool m_ready; - signals: void testsFinished(int); diff --git a/tests/auto/declarative/shared/testhttpserver.cpp b/tests/auto/declarative/shared/testhttpserver.cpp index fe2b2cf..5d56327 100644 --- a/tests/auto/declarative/shared/testhttpserver.cpp +++ b/tests/auto/declarative/shared/testhttpserver.cpp @@ -190,13 +190,14 @@ void TestHTTPServer::disconnected() --ii; } } + socket->disconnect(); socket->deleteLater(); } void TestHTTPServer::readyRead() { QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender()); - if (!socket) return; + if (!socket || socket->state() == QTcpSocket::ClosingState) return; QByteArray ba = socket->readAll(); @@ -222,14 +223,14 @@ void TestHTTPServer::readyRead() QByteArray data = ba.mid(ii); qWarning() << "TestHTTPServer: Unexpected data" << data << "\nExpected: " << waitData; m_hasFailed = true; - socket->disconnect(); + socket->disconnectFromHost(); return; } } if (waitData.isEmpty()) { socket->write(replyData); - socket->disconnect(); + socket->disconnectFromHost(); } } @@ -316,8 +317,8 @@ void TestHTTPServer::serveGET(QTcpSocket *socket, const QByteArray &data) } dataCache.remove(socket); - if (close) - socket->close(); + if (close) + socket->disconnectFromHost(); } } diff --git a/tests/auto/declarative/visual/Package_Views/packageviews.qml b/tests/auto/declarative/visual/Package_Views/packageviews.qml index c8016b6..dcfe7de 100644 --- a/tests/auto/declarative/visual/Package_Views/packageviews.qml +++ b/tests/auto/declarative/visual/Package_Views/packageviews.qml @@ -64,7 +64,7 @@ Rectangle { from: "*"; to: "*" SequentialAnimation { ParentAction{} - NumberAnimation { matchProperties: "x,y,width"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,width"; easing: "easeInOutQuad" } } } ] diff --git a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml index 732eb59..5230ca4 100644 --- a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml +++ b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml @@ -28,7 +28,7 @@ Rectangle { transitions: [ Transition { NumberAnimation { - matchProperties: "x" + properties: "x" } } ] diff --git a/tests/auto/declarative/visual/animation/easing/easing.qml b/tests/auto/declarative/visual/animation/easing/easing.qml index 1e8e907..f81400b 100644 --- a/tests/auto/declarative/visual/animation/easing/easing.qml +++ b/tests/auto/declarative/visual/animation/easing/easing.qml @@ -176,7 +176,7 @@ Rectangle { to: "to" reversible: true NumberAnimation { - matchProperties: "x" + properties: "x" easing: type duration: 1000 } diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.0.png b/tests/auto/declarative/visual/animation/loop/data/loop.0.png Binary files differnew file mode 100644 index 0000000..f4301d3 --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/data/loop.0.png diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.1.png b/tests/auto/declarative/visual/animation/loop/data/loop.1.png Binary files differnew file mode 100644 index 0000000..ceb0e20 --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/data/loop.1.png diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.2.png b/tests/auto/declarative/visual/animation/loop/data/loop.2.png Binary files differnew file mode 100644 index 0000000..197c8c0 --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/data/loop.2.png diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.3.png b/tests/auto/declarative/visual/animation/loop/data/loop.3.png Binary files differnew file mode 100644 index 0000000..3a4327e --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/data/loop.3.png diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.4.png b/tests/auto/declarative/visual/animation/loop/data/loop.4.png Binary files differnew file mode 100644 index 0000000..2397719 --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/data/loop.4.png diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.5.png b/tests/auto/declarative/visual/animation/loop/data/loop.5.png Binary files differnew file mode 100644 index 0000000..70d91a2 --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/data/loop.5.png diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.qml b/tests/auto/declarative/visual/animation/loop/data/loop.qml new file mode 100644 index 0000000..8804d44 --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/data/loop.qml @@ -0,0 +1,1471 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "eff7cc4b163dceb6084270cc589393f1" + } + Frame { + msec: 32 + hash: "1012b52727ae98522061945e32a6269a" + } + Frame { + msec: 48 + hash: "06c3f3c1fa014b0eb7341e0a45ca16e4" + } + Frame { + msec: 64 + hash: "71ecb0af25649c056310d3b865d4144d" + } + Frame { + msec: 80 + hash: "e249fe5b113797433f96a2f84d47e42b" + } + Frame { + msec: 96 + hash: "2a7256921c25c79c22263f2b48d4e98c" + } + Frame { + msec: 112 + hash: "8657944b456402622f2991a0c9acc2fb" + } + Frame { + msec: 128 + hash: "c919a94cd7afb1fbad4c88537af00869" + } + Frame { + msec: 144 + hash: "303b5057d94e328f9447a01d54eea93d" + } + Frame { + msec: 160 + hash: "72eb974dc008c9454935b18b47d4d9e6" + } + Frame { + msec: 176 + hash: "545f258cb0ec7f5d951b74cc7d3f4f0d" + } + Frame { + msec: 192 + hash: "3b3d6046fb01adf7c8a7f67bbc46d28e" + } + Frame { + msec: 208 + hash: "12f7556076cf7a4c2f029dab80e666e7" + } + Frame { + msec: 224 + hash: "fab272c7dce2bbee4042764d38c7ceb5" + } + Frame { + msec: 240 + hash: "ff8addee408527bbaed1819bae07c23f" + } + Frame { + msec: 256 + hash: "53eb6f575db2af3635139e5ddbd7b2f9" + } + Frame { + msec: 272 + hash: "a2fa1cf169acb8ff26a2c5ec1f1d5c81" + } + Frame { + msec: 288 + hash: "ab8d5d6d146ed11b92bc93e78f28e50c" + } + Frame { + msec: 304 + hash: "0fbfc6609b082008e44592067b18ab63" + } + Frame { + msec: 320 + hash: "7fbeda19c19c62a0af5f7f98e633993f" + } + Frame { + msec: 336 + hash: "1882b591bc9d4e79d69d0baecb78b700" + } + Frame { + msec: 352 + hash: "dde429007f876206f3ec0c68d239983e" + } + Frame { + msec: 368 + hash: "b656bdba2978a9a1af511cc2bb0cb59a" + } + Frame { + msec: 384 + hash: "1f6573bf67b2893c94f0c2d40213dc73" + } + Frame { + msec: 400 + hash: "f5786fb532300a1b2f820251fc17c775" + } + Frame { + msec: 416 + hash: "a0e9c4bd3b6c4cdadd40bdf3ca5e2986" + } + Frame { + msec: 432 + hash: "073f74ab23a1173025b3c63424ce2697" + } + Frame { + msec: 448 + hash: "1ac1367d21e346c6c652a88b9ea25bfc" + } + Frame { + msec: 464 + hash: "f62720308dc9ae67c3856bc3afb32b75" + } + Frame { + msec: 480 + hash: "066476a57efba802d2497bc3731a3583" + } + Frame { + msec: 496 + hash: "fb965028a760e8d0a4d81fd982a18ff3" + } + Frame { + msec: 512 + hash: "ba008abd1a7a73c750b909d57c043649" + } + Frame { + msec: 528 + hash: "4c974470953f74d1ee7bcd0f4a4c48cf" + } + Frame { + msec: 544 + hash: "ea233f3476da26c90d67b7775b718aa2" + } + Frame { + msec: 560 + hash: "e12c3b810c0aa628d7a3827453bea9f3" + } + Frame { + msec: 576 + hash: "7451954ca0465c430fc4bae84f6d97cb" + } + Frame { + msec: 592 + hash: "503e40f193a8b099daa4013eddc2f664" + } + Frame { + msec: 608 + hash: "1f81acf94f325a51faa7aa61e73f8a25" + } + Frame { + msec: 624 + hash: "0257d7d53eda8afe182a9f97ef451679" + } + Frame { + msec: 640 + hash: "cfc260bdc977ef16311840022cc85378" + } + Frame { + msec: 656 + hash: "27483f0b89d727b32722ea153fad30ad" + } + Frame { + msec: 672 + hash: "355afa11b8e7b24a353d1aa79daf7564" + } + Frame { + msec: 688 + hash: "bbc1d55f346719476f471a2294227bda" + } + Frame { + msec: 704 + hash: "9bbab5ff75219d8bd65022c6d061e57a" + } + Frame { + msec: 720 + hash: "ff0699f02845f3c5cf5aabb19198c346" + } + Frame { + msec: 736 + hash: "26768e09270ade4c5b484154e7042f43" + } + Frame { + msec: 752 + hash: "31c9ae63071de3fb2f7e1836a22515cb" + } + Frame { + msec: 768 + hash: "783ce2acdae8d87883151532c9293336" + } + Frame { + msec: 784 + hash: "86b9fd739f437127e0cc4d7dcd4284bd" + } + Frame { + msec: 800 + hash: "5e1d6e164dd184cc197d514e5ff60a4c" + } + Frame { + msec: 816 + hash: "13063a8d73704165d64dd2a95803ec0f" + } + Frame { + msec: 832 + hash: "c244e0c0d60f4be2e017bba21a17ab3f" + } + Frame { + msec: 848 + hash: "b3bd657873f1b49c888b9b98d8c0e23f" + } + Frame { + msec: 864 + hash: "65a011e4f62ecddd820bdbdeb0084b65" + } + Frame { + msec: 880 + hash: "86018de7b4a93b267fe94c4de9e61bab" + } + Frame { + msec: 896 + hash: "44827055c99ae3ed924c101c9d1be5c5" + } + Frame { + msec: 912 + hash: "1c31fcb20ec1abc7ea815b703ae05363" + } + Frame { + msec: 928 + hash: "9d7825b7b05ca696846a4116ab27f966" + } + Frame { + msec: 944 + hash: "61b6690dd14fc76dbac4d785bbddb8ee" + } + Frame { + msec: 960 + image: "loop.0.png" + } + Frame { + msec: 976 + hash: "2cc40e1119060483ae067f3881af0391" + } + Frame { + msec: 992 + hash: "9747fdff3429f7a2dbc9e3173ad43a67" + } + Frame { + msec: 1008 + hash: "e68058b9565138f2d7f0f96b74c38dec" + } + Frame { + msec: 1024 + hash: "f32aceabb929471dffd73bf0290e75a2" + } + Frame { + msec: 1040 + hash: "9112838cc8f9a0cfb94e0ef6ca7eca71" + } + Frame { + msec: 1056 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 1072 + hash: "d5105f958a592324e53aae4a83beb049" + } + Frame { + msec: 1088 + hash: "862249432e6fc6114b63284ad9c97cb6" + } + Frame { + msec: 1104 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 1120 + hash: "0f5b2b05f72b86bd2b0a6d0ea2b6bf37" + } + Frame { + msec: 1136 + hash: "922520f7ec954d6d1061208cbd63877e" + } + Frame { + msec: 1152 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 1168 + hash: "ebb41112b687ecb062dedc3b49cb93fc" + } + Frame { + msec: 1184 + hash: "7bc87d71d532aa52abc26ac9c1cbb665" + } + Frame { + msec: 1200 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 1216 + hash: "ca17c870c55f2947bb5f85d28f30ee7c" + } + Frame { + msec: 1232 + hash: "48b123cfd6d2ea1c2bc9f2ba822ec7bf" + } + Frame { + msec: 1248 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 1264 + hash: "f10a0a11ed54a910fe434311f67343a4" + } + Frame { + msec: 1280 + hash: "47b6e1beabdcd3cd3d21d77c62e5bed8" + } + Frame { + msec: 1296 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 1312 + hash: "9e018f9e7a5ba22bbb9be3049373124a" + } + Frame { + msec: 1328 + hash: "d63069a8e7b0eb5611cc34caaecef2fb" + } + Frame { + msec: 1344 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 1360 + hash: "fd3036e559fd31eeadb0032666a95864" + } + Frame { + msec: 1376 + hash: "cf9f82b9e2a03f63f75b6ac113b3d4e5" + } + Frame { + msec: 1392 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 1408 + hash: "0d6d6cb2ca808f5a57acfa32e10fc335" + } + Frame { + msec: 1424 + hash: "9a660a0fed41211a37d3ac82be40f81a" + } + Frame { + msec: 1440 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 1456 + hash: "cd86fe5894e5d061f7ffe37913f00ce6" + } + Frame { + msec: 1472 + hash: "a5fdb825c18d43f3ae18f5c28e715174" + } + Frame { + msec: 1488 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 1504 + hash: "8849a36af064503dbccad69a35b6ab03" + } + Frame { + msec: 1520 + hash: "baeb4f90b0e2efc09225dbb5dd003e9e" + } + Frame { + msec: 1536 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 1552 + hash: "10d166d7da9949370a66251415522186" + } + Frame { + msec: 1568 + hash: "ada1608055b221dc9f1f7650a9764930" + } + Frame { + msec: 1584 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 1600 + hash: "dc4a1c44d08328965b53ff079a8fa57b" + } + Frame { + msec: 1616 + hash: "d3d88cf635ba38e5035732cb36014417" + } + Frame { + msec: 1632 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 1648 + hash: "34f193daf199ab45310be2b407499e57" + } + Frame { + msec: 1664 + hash: "d87c854e1c16642dba0d87e25f0e416f" + } + Frame { + msec: 1680 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 1696 + hash: "84828f8e0cace1a39d9b7f19b6e4cbaa" + } + Frame { + msec: 1712 + hash: "8a0c6e1f597e699c3e2be816ae4e1dd4" + } + Frame { + msec: 1728 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 1744 + hash: "a298b3ab2939819ced7e7f903ec63be4" + } + Frame { + msec: 1760 + hash: "99789b6e168355a3960986c7d1f21f82" + } + Frame { + msec: 1776 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 1792 + hash: "9c9b3fb5b623d3deaf9920c99279d71b" + } + Frame { + msec: 1808 + hash: "8f0be6d4d6fd7f66a43fd604e17717dd" + } + Frame { + msec: 1824 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 1840 + hash: "fd7157aef6dfb303472cd33b176f91d8" + } + Frame { + msec: 1856 + hash: "e6521a3c74c190c193af2c913e5326e2" + } + Frame { + msec: 1872 + hash: "19862dcb88fcbbb2c4ecdc42821c7fef" + } + Frame { + msec: 1888 + hash: "5e29a9f9c6c4131c5b71f84d24503ad2" + } + Frame { + msec: 1904 + hash: "140e63c071ef77d26034d0bb6a5d5b7a" + } + Frame { + msec: 1920 + image: "loop.1.png" + } + Frame { + msec: 1936 + hash: "7f79dd50a0af8e8871191ee80afcad0f" + } + Frame { + msec: 1952 + hash: "a5eb3334044999f56c759ce8727d627f" + } + Frame { + msec: 1968 + hash: "3fb70a7591b6decfa44f7cad18f73855" + } + Frame { + msec: 1984 + hash: "3fab99be73f7f12b9463dea359fc86d2" + } + Frame { + msec: 2000 + hash: "50ce6b869e42c949b84cf2dd0cca3af9" + } + Frame { + msec: 2016 + hash: "5369125b23e2f954c18f2fd4e0ba6f6a" + } + Frame { + msec: 2032 + hash: "a76f624be0db97ec4450b10f748065df" + } + Frame { + msec: 2048 + hash: "3fb70a7591b6decfa44f7cad18f73855" + } + Frame { + msec: 2064 + hash: "dada267799b6e57acfcc5de3b8822c7c" + } + Frame { + msec: 2080 + hash: "72c0bf8225504e86ff023242b84513a8" + } + Frame { + msec: 2096 + hash: "1e8b095c39bd359637b1b9c975ee514c" + } + Frame { + msec: 2112 + hash: "19862dcb88fcbbb2c4ecdc42821c7fef" + } + Frame { + msec: 2128 + hash: "60c95993a894e1c6e2d476db365b7746" + } + Frame { + msec: 2144 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 2160 + hash: "15e8959bfa4d206b2f0607322b21cba6" + } + Frame { + msec: 2176 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 2192 + hash: "6d278926822d044fff04c3f182dcb058" + } + Frame { + msec: 2208 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 2224 + hash: "b36f70f138e6deecf5b105bcd89d1a15" + } + Frame { + msec: 2240 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 2256 + hash: "6469d0bee7ab280639b565ebf174f251" + } + Frame { + msec: 2272 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 2288 + hash: "5214e578bc78b729ddf35c140093c0da" + } + Frame { + msec: 2304 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 2320 + hash: "2ddf31aeac4815be56848703a9b5aa14" + } + Frame { + msec: 2336 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 2352 + hash: "d8415ba4fb19b62b838ef2e09ae7607a" + } + Frame { + msec: 2368 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 2384 + hash: "68fac60713af7cb130e92fa381be411c" + } + Frame { + msec: 2400 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 2416 + hash: "64e49282d97ba864d2f6be632ae048e4" + } + Frame { + msec: 2432 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 2448 + hash: "f302a9ce45187ff1001c967a4c753b2b" + } + Frame { + msec: 2464 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 2480 + hash: "fd177a7ae3b5b9205fd38e955be327e0" + } + Frame { + msec: 2496 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 2512 + hash: "32b16dd62ccf06e44be38fd5885f297e" + } + Frame { + msec: 2528 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 2544 + hash: "8637606843905d6ae3f95fcb745f2a6e" + } + Frame { + msec: 2560 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 2576 + hash: "704ca30ddc0a637f3d1cd4926a6f7983" + } + Frame { + msec: 2592 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 2608 + hash: "7759418b4fe412857ab8e7294f5a3206" + } + Frame { + msec: 2624 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 2640 + hash: "3e6089b47573cd53b0a220275202c80b" + } + Frame { + msec: 2656 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 2672 + hash: "f30202ae354a587c5949a16c1f8b95c3" + } + Frame { + msec: 2688 + hash: "66f78a34fe9d297af1ae8e98f84ead55" + } + Frame { + msec: 2704 + hash: "3e2fc29876812fe57ea008a71db299a4" + } + Frame { + msec: 2720 + hash: "7234b6df2220e418ef8ebe8f1c82bf26" + } + Frame { + msec: 2736 + hash: "82dd491c3b34e702a24ece8e55761a6f" + } + Frame { + msec: 2752 + hash: "d7f1065f5c42088dfc5ce36687fd8010" + } + Frame { + msec: 2768 + hash: "15bfbb0261b66ccbe3b34d0ac807165c" + } + Frame { + msec: 2784 + hash: "69963ce07eb434d787588b21fd020fa3" + } + Frame { + msec: 2800 + hash: "2fb9e078573ebd1a5cf0f615c97f1d20" + } + Frame { + msec: 2816 + hash: "31fa31ed47ea16390be8ea9d41f483e7" + } + Frame { + msec: 2832 + hash: "0f9ed8cd5cfbdab03bcb05cf6dd92620" + } + Frame { + msec: 2848 + hash: "a0e737132ae642c465e991e770ab3e34" + } + Frame { + msec: 2864 + hash: "d57cc5045f01ab4e7eb72575aef22a10" + } + Frame { + msec: 2880 + image: "loop.2.png" + } + Frame { + msec: 2896 + hash: "df41be1fa564353ceb2088af209610d3" + } + Frame { + msec: 2912 + hash: "2d294613ed10dfdbca829b43b6990574" + } + Frame { + msec: 2928 + hash: "0a278a4ec3626442c94ef2da30771171" + } + Frame { + msec: 2944 + hash: "7071526c830fdfde9d520ad1578d27a8" + } + Frame { + msec: 2960 + hash: "ad02e7b90f223d3fc5a433bc4ffbee9e" + } + Frame { + msec: 2976 + hash: "e7ef412697c7df3887980ed1b079ffd5" + } + Frame { + msec: 2992 + hash: "ebda21f95079b37f4862b42523bbc1c0" + } + Frame { + msec: 3008 + hash: "6e8889e9b44ff8ed44e228d97fb5034c" + } + Frame { + msec: 3024 + hash: "f32aceabb929471dffd73bf0290e75a2" + } + Frame { + msec: 3040 + hash: "9112838cc8f9a0cfb94e0ef6ca7eca71" + } + Frame { + msec: 3056 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 3072 + hash: "d5105f958a592324e53aae4a83beb049" + } + Frame { + msec: 3088 + hash: "862249432e6fc6114b63284ad9c97cb6" + } + Frame { + msec: 3104 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 3120 + hash: "0f5b2b05f72b86bd2b0a6d0ea2b6bf37" + } + Frame { + msec: 3136 + hash: "922520f7ec954d6d1061208cbd63877e" + } + Frame { + msec: 3152 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 3168 + hash: "ebb41112b687ecb062dedc3b49cb93fc" + } + Frame { + msec: 3184 + hash: "7bc87d71d532aa52abc26ac9c1cbb665" + } + Frame { + msec: 3200 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 3216 + hash: "ca17c870c55f2947bb5f85d28f30ee7c" + } + Frame { + msec: 3232 + hash: "48b123cfd6d2ea1c2bc9f2ba822ec7bf" + } + Frame { + msec: 3248 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 3264 + hash: "f10a0a11ed54a910fe434311f67343a4" + } + Frame { + msec: 3280 + hash: "47b6e1beabdcd3cd3d21d77c62e5bed8" + } + Frame { + msec: 3296 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 3312 + hash: "9e018f9e7a5ba22bbb9be3049373124a" + } + Frame { + msec: 3328 + hash: "d63069a8e7b0eb5611cc34caaecef2fb" + } + Frame { + msec: 3344 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 3360 + hash: "fd3036e559fd31eeadb0032666a95864" + } + Frame { + msec: 3376 + hash: "cf9f82b9e2a03f63f75b6ac113b3d4e5" + } + Frame { + msec: 3392 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 3408 + hash: "0d6d6cb2ca808f5a57acfa32e10fc335" + } + Frame { + msec: 3424 + hash: "9a660a0fed41211a37d3ac82be40f81a" + } + Frame { + msec: 3440 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 3456 + hash: "cd86fe5894e5d061f7ffe37913f00ce6" + } + Frame { + msec: 3472 + hash: "a5fdb825c18d43f3ae18f5c28e715174" + } + Frame { + msec: 3488 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 3504 + hash: "8849a36af064503dbccad69a35b6ab03" + } + Frame { + msec: 3520 + hash: "baeb4f90b0e2efc09225dbb5dd003e9e" + } + Frame { + msec: 3536 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 3552 + hash: "10d166d7da9949370a66251415522186" + } + Frame { + msec: 3568 + hash: "ada1608055b221dc9f1f7650a9764930" + } + Frame { + msec: 3584 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 3600 + hash: "dc4a1c44d08328965b53ff079a8fa57b" + } + Frame { + msec: 3616 + hash: "d3d88cf635ba38e5035732cb36014417" + } + Frame { + msec: 3632 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 3648 + hash: "34f193daf199ab45310be2b407499e57" + } + Frame { + msec: 3664 + hash: "d87c854e1c16642dba0d87e25f0e416f" + } + Frame { + msec: 3680 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 3696 + hash: "84828f8e0cace1a39d9b7f19b6e4cbaa" + } + Frame { + msec: 3712 + hash: "8a0c6e1f597e699c3e2be816ae4e1dd4" + } + Frame { + msec: 3728 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 3744 + hash: "a298b3ab2939819ced7e7f903ec63be4" + } + Frame { + msec: 3760 + hash: "99789b6e168355a3960986c7d1f21f82" + } + Frame { + msec: 3776 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 3792 + hash: "9c9b3fb5b623d3deaf9920c99279d71b" + } + Frame { + msec: 3808 + hash: "8f0be6d4d6fd7f66a43fd604e17717dd" + } + Frame { + msec: 3824 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 3840 + image: "loop.3.png" + } + Frame { + msec: 3856 + hash: "e6521a3c74c190c193af2c913e5326e2" + } + Frame { + msec: 3872 + hash: "19862dcb88fcbbb2c4ecdc42821c7fef" + } + Frame { + msec: 3888 + hash: "5e29a9f9c6c4131c5b71f84d24503ad2" + } + Frame { + msec: 3904 + hash: "140e63c071ef77d26034d0bb6a5d5b7a" + } + Frame { + msec: 3920 + hash: "72c0bf8225504e86ff023242b84513a8" + } + Frame { + msec: 3936 + hash: "7f79dd50a0af8e8871191ee80afcad0f" + } + Frame { + msec: 3952 + hash: "a5eb3334044999f56c759ce8727d627f" + } + Frame { + msec: 3968 + hash: "3fb70a7591b6decfa44f7cad18f73855" + } + Frame { + msec: 3984 + hash: "3fab99be73f7f12b9463dea359fc86d2" + } + Frame { + msec: 4000 + hash: "50ce6b869e42c949b84cf2dd0cca3af9" + } + Frame { + msec: 4016 + hash: "5369125b23e2f954c18f2fd4e0ba6f6a" + } + Frame { + msec: 4032 + hash: "a76f624be0db97ec4450b10f748065df" + } + Frame { + msec: 4048 + hash: "3fb70a7591b6decfa44f7cad18f73855" + } + Frame { + msec: 4064 + hash: "dada267799b6e57acfcc5de3b8822c7c" + } + Frame { + msec: 4080 + hash: "72c0bf8225504e86ff023242b84513a8" + } + Frame { + msec: 4096 + hash: "1e8b095c39bd359637b1b9c975ee514c" + } + Frame { + msec: 4112 + hash: "19862dcb88fcbbb2c4ecdc42821c7fef" + } + Frame { + msec: 4128 + hash: "60c95993a894e1c6e2d476db365b7746" + } + Frame { + msec: 4144 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 4160 + hash: "15e8959bfa4d206b2f0607322b21cba6" + } + Frame { + msec: 4176 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 4192 + hash: "6d278926822d044fff04c3f182dcb058" + } + Frame { + msec: 4208 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 4224 + hash: "b36f70f138e6deecf5b105bcd89d1a15" + } + Frame { + msec: 4240 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 4256 + hash: "6469d0bee7ab280639b565ebf174f251" + } + Frame { + msec: 4272 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 4288 + hash: "5214e578bc78b729ddf35c140093c0da" + } + Frame { + msec: 4304 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 4320 + hash: "2ddf31aeac4815be56848703a9b5aa14" + } + Frame { + msec: 4336 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 4352 + hash: "d8415ba4fb19b62b838ef2e09ae7607a" + } + Frame { + msec: 4368 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 4384 + hash: "68fac60713af7cb130e92fa381be411c" + } + Frame { + msec: 4400 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 4416 + hash: "64e49282d97ba864d2f6be632ae048e4" + } + Frame { + msec: 4432 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 4448 + hash: "f302a9ce45187ff1001c967a4c753b2b" + } + Frame { + msec: 4464 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 4480 + hash: "fd177a7ae3b5b9205fd38e955be327e0" + } + Frame { + msec: 4496 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 4512 + hash: "32b16dd62ccf06e44be38fd5885f297e" + } + Frame { + msec: 4528 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 4544 + hash: "8637606843905d6ae3f95fcb745f2a6e" + } + Frame { + msec: 4560 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 4576 + hash: "704ca30ddc0a637f3d1cd4926a6f7983" + } + Frame { + msec: 4592 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 4608 + hash: "7759418b4fe412857ab8e7294f5a3206" + } + Frame { + msec: 4624 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 4640 + hash: "3e6089b47573cd53b0a220275202c80b" + } + Frame { + msec: 4656 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 4672 + hash: "f30202ae354a587c5949a16c1f8b95c3" + } + Frame { + msec: 4688 + hash: "66f78a34fe9d297af1ae8e98f84ead55" + } + Frame { + msec: 4704 + hash: "3e2fc29876812fe57ea008a71db299a4" + } + Frame { + msec: 4720 + hash: "7234b6df2220e418ef8ebe8f1c82bf26" + } + Frame { + msec: 4736 + hash: "82dd491c3b34e702a24ece8e55761a6f" + } + Frame { + msec: 4752 + hash: "d7f1065f5c42088dfc5ce36687fd8010" + } + Frame { + msec: 4768 + hash: "15bfbb0261b66ccbe3b34d0ac807165c" + } + Frame { + msec: 4784 + hash: "69963ce07eb434d787588b21fd020fa3" + } + Frame { + msec: 4800 + image: "loop.4.png" + } + Frame { + msec: 4816 + hash: "31fa31ed47ea16390be8ea9d41f483e7" + } + Frame { + msec: 4832 + hash: "0f9ed8cd5cfbdab03bcb05cf6dd92620" + } + Frame { + msec: 4848 + hash: "a0e737132ae642c465e991e770ab3e34" + } + Frame { + msec: 4864 + hash: "d57cc5045f01ab4e7eb72575aef22a10" + } + Frame { + msec: 4880 + hash: "d57e1a10e48938e1f7fc219220fe1204" + } + Frame { + msec: 4896 + hash: "df41be1fa564353ceb2088af209610d3" + } + Frame { + msec: 4912 + hash: "2d294613ed10dfdbca829b43b6990574" + } + Frame { + msec: 4928 + hash: "0a278a4ec3626442c94ef2da30771171" + } + Frame { + msec: 4944 + hash: "7071526c830fdfde9d520ad1578d27a8" + } + Frame { + msec: 4960 + hash: "ad02e7b90f223d3fc5a433bc4ffbee9e" + } + Frame { + msec: 4976 + hash: "e7ef412697c7df3887980ed1b079ffd5" + } + Frame { + msec: 4992 + hash: "ebda21f95079b37f4862b42523bbc1c0" + } + Frame { + msec: 5008 + hash: "6e8889e9b44ff8ed44e228d97fb5034c" + } + Frame { + msec: 5024 + hash: "f32aceabb929471dffd73bf0290e75a2" + } + Frame { + msec: 5040 + hash: "9112838cc8f9a0cfb94e0ef6ca7eca71" + } + Frame { + msec: 5056 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 5072 + hash: "d5105f958a592324e53aae4a83beb049" + } + Frame { + msec: 5088 + hash: "862249432e6fc6114b63284ad9c97cb6" + } + Frame { + msec: 5104 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 5120 + hash: "0f5b2b05f72b86bd2b0a6d0ea2b6bf37" + } + Frame { + msec: 5136 + hash: "922520f7ec954d6d1061208cbd63877e" + } + Frame { + msec: 5152 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 5168 + hash: "ebb41112b687ecb062dedc3b49cb93fc" + } + Frame { + msec: 5184 + hash: "7bc87d71d532aa52abc26ac9c1cbb665" + } + Frame { + msec: 5200 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 5216 + hash: "ca17c870c55f2947bb5f85d28f30ee7c" + } + Frame { + msec: 5232 + hash: "48b123cfd6d2ea1c2bc9f2ba822ec7bf" + } + Frame { + msec: 5248 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 5264 + hash: "f10a0a11ed54a910fe434311f67343a4" + } + Frame { + msec: 5280 + hash: "47b6e1beabdcd3cd3d21d77c62e5bed8" + } + Frame { + msec: 5296 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 5312 + hash: "9e018f9e7a5ba22bbb9be3049373124a" + } + Frame { + msec: 5328 + hash: "d63069a8e7b0eb5611cc34caaecef2fb" + } + Frame { + msec: 5344 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 5360 + hash: "fd3036e559fd31eeadb0032666a95864" + } + Frame { + msec: 5376 + hash: "cf9f82b9e2a03f63f75b6ac113b3d4e5" + } + Frame { + msec: 5392 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 5408 + hash: "0d6d6cb2ca808f5a57acfa32e10fc335" + } + Frame { + msec: 5424 + hash: "9a660a0fed41211a37d3ac82be40f81a" + } + Frame { + msec: 5440 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 5456 + hash: "cd86fe5894e5d061f7ffe37913f00ce6" + } + Frame { + msec: 5472 + hash: "a5fdb825c18d43f3ae18f5c28e715174" + } + Frame { + msec: 5488 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 5504 + hash: "8849a36af064503dbccad69a35b6ab03" + } + Frame { + msec: 5520 + hash: "baeb4f90b0e2efc09225dbb5dd003e9e" + } + Frame { + msec: 5536 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 5552 + hash: "10d166d7da9949370a66251415522186" + } + Frame { + msec: 5568 + hash: "ada1608055b221dc9f1f7650a9764930" + } + Frame { + msec: 5584 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 5600 + hash: "dc4a1c44d08328965b53ff079a8fa57b" + } + Frame { + msec: 5616 + hash: "d3d88cf635ba38e5035732cb36014417" + } + Frame { + msec: 5632 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 5648 + hash: "34f193daf199ab45310be2b407499e57" + } + Frame { + msec: 5664 + hash: "d87c854e1c16642dba0d87e25f0e416f" + } + Frame { + msec: 5680 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 5696 + hash: "84828f8e0cace1a39d9b7f19b6e4cbaa" + } + Frame { + msec: 5712 + hash: "8a0c6e1f597e699c3e2be816ae4e1dd4" + } + Frame { + msec: 5728 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 5744 + hash: "a298b3ab2939819ced7e7f903ec63be4" + } + Frame { + msec: 5760 + image: "loop.5.png" + } + Frame { + msec: 5776 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 5792 + hash: "9c9b3fb5b623d3deaf9920c99279d71b" + } + Frame { + msec: 5808 + hash: "8f0be6d4d6fd7f66a43fd604e17717dd" + } + Frame { + msec: 5824 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 5840 + hash: "fd7157aef6dfb303472cd33b176f91d8" + } + Frame { + msec: 5856 + hash: "e6521a3c74c190c193af2c913e5326e2" + } +} diff --git a/tests/auto/declarative/visual/animation/loop/loop.qml b/tests/auto/declarative/visual/animation/loop/loop.qml new file mode 100644 index 0000000..f6049ae --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/loop.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 100 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + /* This should produce an animation that starts at 0, animates smoothly + to 100, jumps to 200, animates smoothly to 400, animates smoothly + back to 100, jumps to 200, and so on. + */ + x: SequentialAnimation { + repeat: true + NumberAnimation { to: 100; duration: 1000 } + NumberAnimation { from: 200; to: 400; duration: 1000 } + } + + } + +} diff --git a/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml b/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml index 9e0422f..7021e05 100644 --- a/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml +++ b/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml @@ -34,10 +34,10 @@ Rectangle { } transitions: Transition { - PropertyAnimation { matchTargets: redRect; matchProperties: "x,color"; duration: 300 } + PropertyAnimation { targets: redRect; properties: "x,color"; duration: 300 } ParallelAnimation { - NumberAnimation { matchTargets: redRect2; matchProperties: "x"; duration: 300 } - ColorAnimation { matchTargets: redRect2; matchProperties: "color"; duration: 300 } + NumberAnimation { targets: redRect2; properties: "x"; duration: 300 } + ColorAnimation { targets: redRect2; properties: "color"; duration: 300 } } } } diff --git a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml index 1e3f402..e4f4406 100644 --- a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml +++ b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml @@ -49,7 +49,7 @@ Rectangle { SequentialAnimation { ColorAnimation { duration: 500} ParentAction {} - NumberAnimation { matchProperties: "rotation, scale"; duration: 1000 } + NumberAnimation { properties: "rotation, scale"; duration: 1000 } } } } diff --git a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml index b670166..68671e1 100644 --- a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml +++ b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml @@ -27,8 +27,8 @@ Rectangle { reversible: true SequentialAnimation { ColorAnimation {} - PropertyAction { matchProperties: "x" } - NumberAnimation { matchProperties: "y"; easing: "InOutQuad" } + PropertyAction { properties: "x" } + NumberAnimation { properties: "y"; easing: "InOutQuad" } } } } diff --git a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml index 1cc68a9..359346f 100644 --- a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml +++ b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml @@ -52,7 +52,7 @@ Rectangle { }] transitions: Transition { - NumberAnimation { matchProperties: "x,y,width,height" } + NumberAnimation { properties: "x,y,width,height" } } MouseRegion { diff --git a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml index 872701b..f121906 100644 --- a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml +++ b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml @@ -27,9 +27,9 @@ Rectangle { transitions: Transition { SequentialAnimation { - NumberAnimation { matchProperties: "x"; easing: "InOutQuad" } + NumberAnimation { properties: "x"; easing: "InOutQuad" } ScriptAction { stateChangeScriptName: "setColor" } - NumberAnimation { matchProperties: "y"; easing: "InOutQuad" } + NumberAnimation { properties: "y"; easing: "InOutQuad" } } } } diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml b/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml index c376e39..db70298 100644 --- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml +++ b/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml @@ -7034,4 +7034,4 @@ VisualTest { } Frame { msec: 23264 - hash: "8443c45791c906a9fe23831844f48a1c
\ No newline at end of file + hash: "8443c45791c906a9fe23831844f48a1c diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml index 64adb61..c33a319 100644 --- a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml +++ b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml @@ -36,7 +36,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 3000 } + NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 } } } @@ -64,7 +64,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 3000 } + NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 } } } diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml b/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml index 4b03749..f45e9a4 100644 --- a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml +++ b/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml @@ -37,7 +37,7 @@ Item { Row{ y:20 id: row2 - move: Transition{NumberAnimation{matchProperties:"x"}} + move: Transition{NumberAnimation{properties:"x"}} Repeater{ id: repeater model: 0; @@ -48,7 +48,7 @@ Item { Rectangle{id: r2c; width:20; height:20; color: "blue"} } Row{ - move: Transition{NumberAnimation{matchProperties:"x"}} + move: Transition{NumberAnimation{properties:"x"}} y:40 id: row3 Rectangle{id: r3a; width:20; height:20; color: "red"} diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml index 2faefc1..e0c5db4 100644 --- a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml +++ b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml @@ -11,8 +11,8 @@ import Qt 4.6 Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;} opacity: 1 opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true; - NumberAnimation { matchProperties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} - NumberAnimation { matchProperties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} + NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} + NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} } } width: 1; diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml index d10755c..0038664 100644 --- a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml +++ b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml @@ -11,8 +11,8 @@ import Qt 4.6 Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;} opacity: 1 opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true; - NumberAnimation { matchProperties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} - NumberAnimation { matchProperties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} + NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} + NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} } } width: 1; diff --git a/tests/benchmarks/declarative/painting/data/63x63.png b/tests/benchmarks/declarative/painting/data/63x63.png Binary files differnew file mode 100644 index 0000000..d9efda8 --- /dev/null +++ b/tests/benchmarks/declarative/painting/data/63x63.png diff --git a/tests/benchmarks/declarative/painting/data/63x63_opaque.png b/tests/benchmarks/declarative/painting/data/63x63_opaque.png Binary files differnew file mode 100644 index 0000000..d142908 --- /dev/null +++ b/tests/benchmarks/declarative/painting/data/63x63_opaque.png diff --git a/tests/benchmarks/declarative/painting/data/64x64.png b/tests/benchmarks/declarative/painting/data/64x64.png Binary files differnew file mode 100644 index 0000000..b149f33 --- /dev/null +++ b/tests/benchmarks/declarative/painting/data/64x64.png diff --git a/tests/benchmarks/declarative/painting/data/64x64_opaque.png b/tests/benchmarks/declarative/painting/data/64x64_opaque.png Binary files differnew file mode 100644 index 0000000..94c07f3 --- /dev/null +++ b/tests/benchmarks/declarative/painting/data/64x64_opaque.png diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.cpp b/tests/benchmarks/declarative/painting/paintbenchmark.cpp index dd52740..9231b67 100644 --- a/tests/benchmarks/declarative/painting/paintbenchmark.cpp +++ b/tests/benchmarks/declarative/painting/paintbenchmark.cpp @@ -57,6 +57,7 @@ const int spacing = 36; QSizeF size(1000, 800); const qreal lineWidth = 1000; QString strings[lines]; +QGLWidget *testWidget = 0; void paint_QTextLayout(QPainter &p, bool useCache) { @@ -158,6 +159,15 @@ void paint_QPixmapCachedText(QPainter &p) void paint_RoundedRect(QPainter &p) { + static bool first = true; + if (first) { + if (testWidget) { + QGLFormat format = testWidget->format(); + if (!format.sampleBuffers()) + qWarning() << "Cannot paint antialiased rounded rect without sampleBuffers"; + } + first = false; + } p.setRenderHint(QPainter::Antialiasing, true); p.setPen(Qt::black); p.setBrush(Qt::red); @@ -172,27 +182,101 @@ void paint_RoundedRect(QPainter &p) void paint_QPixmapCachedRoundedRect(QPainter &p) { static bool first = true; - static QPixmap cacheRect[lines]; + static QPixmap cacheRect; if (first) { - for (int i = 0; i < lines; ++i) { - QSize size((i+1)*50, spacing-1); - cacheRect[i] = QPixmap(size); - cacheRect[i].fill(Qt::transparent); - QPainter paint(&cacheRect[i]); - paint.setRenderHint(QPainter::Antialiasing); - paint.setPen(Qt::black); - paint.setBrush(Qt::red); - paint.drawRoundedRect(QRect(QPoint(0,0), size), 8, 8); + const int pw = 0; + const int radius = 8; + cacheRect = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2); + cacheRect.fill(Qt::transparent); + QPainter paint(&cacheRect); + paint.setRenderHint(QPainter::Antialiasing); + paint.setPen(Qt::black); + paint.setBrush(Qt::red); + if (pw%2) + paint.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, cacheRect.width()-(pw+1), cacheRect.height()-(pw+1)), radius, radius); + else + paint.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, cacheRect.width()-pw, cacheRect.height()-pw), radius, radius); + + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + QSize size((j+1)*50, spacing-1); + + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true); + + const int pw = 0; + + int xOffset = (cacheRect.width()-1)/2; + int yOffset = (cacheRect.height()-1)/2; + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects + qDrawBorderPixmap(&p, QRect(-pw/2, j*spacing-pw/2, size.width()+pw, size.height()+pw), margins, cacheRect, cacheRect.rect(), margins, rules); + } + } +} + +void paint_QPixmap63x63_opaque(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/63x63_opaque.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} + +void paint_QPixmap64x64_opaque(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/64x64_opaque.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); } + } +} + +void paint_QPixmap63x63(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/63x63.png"); first = false; } for (int i = 0; i < count; i++) { for (int j = 0; j < lines; ++j) { - p.drawPixmap(0,j*spacing,cacheRect[j]); + p.drawPixmap((i%10) * 64,j*spacing, pm); } } } +void paint_QPixmap64x64(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/64x64.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} typedef void(*PaintFunc)(QPainter &); struct { @@ -206,6 +290,10 @@ struct { { "CachedText", &paint_QPixmapCachedText }, { "RoundedRect", &paint_RoundedRect }, { "CachedRoundedRect", &paint_QPixmapCachedRoundedRect }, + { "QPixmap63x63_opaque", &paint_QPixmap63x63_opaque }, + { "QPixmap64x64_opaque", &paint_QPixmap64x64_opaque }, + { "QPixmap63x63", &paint_QPixmap63x63 }, + { "QPixmap64x64", &paint_QPixmap64x64 }, { 0, 0 } }; @@ -293,11 +381,11 @@ int main(int argc, char *argv[]) QWidget w; QGLFormat format = QGLFormat::defaultFormat(); format.setSampleBuffers(sampleBuffers); - MyGLWidget *glw = new MyGLWidget(format); - glw->setAutoFillBackground(false); + testWidget = new MyGLWidget(format); + testWidget->setAutoFillBackground(false); QVBoxLayout *layout = new QVBoxLayout(&w); w.setLayout(layout); - layout->addWidget(glw); + layout->addWidget(testWidget); w.showFullScreen(); app.exec(); diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 7154fd4..77b2f66 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -961,6 +961,7 @@ void Configure::parseCmdLine() if(i==argCount) break; qmakeDefines += "QT_NAMESPACE="+configCmdLine.at(i); + dictionary[ "QT_NAMESPACE" ] = configCmdLine.at(i); } else if( configCmdLine.at(i) == "-qtlibinfix" ) { ++i; if(i==argCount) @@ -2792,6 +2793,9 @@ void Configure::generateCachefile() if(!dictionary["ARM_FPU_TYPE"].isEmpty()) { configStream<<"MMP_RULES += \"ARMFPU "<< dictionary["ARM_FPU_TYPE"]<< "\""; } + if (!dictionary["QT_NAMESPACE"].isEmpty()) { + configStream << "#namespaces" << endl << "QT_NAMESPACE = " << dictionary["QT_NAMESPACE"] << endl; + } configStream.flush(); configFile.close(); diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 3a30027..543c405 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -48,6 +48,8 @@ #include <iostream> +QT_USE_NAMESPACE + static int usage(const QStringList &args) { Q_UNUSED(args); diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp index 6f34c2b..33276e6 100644 --- a/tools/linguist/lupdate/qscript.cpp +++ b/tools/linguist/lupdate/qscript.cpp @@ -40,6 +40,26 @@ ** ****************************************************************************/ + +#define Q_SCRIPT_REGEXPLITERAL_RULE1 7 + +#define Q_SCRIPT_REGEXPLITERAL_RULE2 8 + +#include <translator.h> + +#include <QtCore/qdebug.h> +#include <QtCore/qnumeric.h> +#include <QtCore/qstring.h> +#include <QtCore/qtextcodec.h> +#include <QtCore/qvariant.h> + +#include <ctype.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +QT_BEGIN_NAMESPACE + class QScriptGrammar { public: @@ -174,7 +194,6 @@ public: } }; - const char *const QScriptGrammar::spell [] = { "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ";", "continue", "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===", @@ -747,26 +766,6 @@ const int QScriptGrammar::action_check [] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; - -#define Q_SCRIPT_REGEXPLITERAL_RULE1 7 - -#define Q_SCRIPT_REGEXPLITERAL_RULE2 8 - -#include <translator.h> - -#include <QtCore/qdebug.h> -#include <QtCore/qnumeric.h> -#include <QtCore/qstring.h> -#include <QtCore/qtextcodec.h> -#include <QtCore/qvariant.h> - -#include <ctype.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -QT_BEGIN_NAMESPACE - static void recordMessage( Translator *tor, const QString &context, const QString &text, const QString &comment, const QString &extracomment, bool plural, const QString &fileName, int lineNo) diff --git a/tools/qmldebugger/qmldebugger.pro b/tools/qmldebugger/qmldebugger.pro deleted file mode 100644 index 679cae6..0000000 --- a/tools/qmldebugger/qmldebugger.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs -CONFIG += ordered - -SUBDIRS = standalone - diff --git a/tools/qmldebugger/standalone/canvasframerate.cpp b/tools/qmldebugger/standalone/canvasframerate.cpp deleted file mode 100644 index 1bf7bf6..0000000 --- a/tools/qmldebugger/standalone/canvasframerate.cpp +++ /dev/null @@ -1,581 +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 Qt QML Debugger 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 <QtCore/qdebug.h> -#include <QtCore/qstringlist.h> -#include <QtCore/qdatastream.h> -#include <QtCore/qmargins.h> - -#include <QtGui/qapplication.h> -#include <QtGui/qpainter.h> -#include <QtGui/qtooltip.h> -#include <QtGui/qslider.h> -#include <QtGui/qscrollbar.h> -#include <QtGui/qspinbox.h> -#include <QtGui/qgroupbox.h> -#include <QtGui/qboxlayout.h> -#include <QtGui/qlabel.h> -#include <QtGui/qlineedit.h> -#include <QtGui/qpushbutton.h> -#include <QtGui/qtabwidget.h> - -#include <QResizeEvent> -#include <QShowEvent> - -#include <private/qmldebugclient_p.h> -#include "canvasframerate.h" - -QT_BEGIN_NAMESPACE - -class QLineGraph : public QWidget -{ -Q_OBJECT -public: - QLineGraph(QAbstractSlider *slider, QWidget * = 0); - - void setPosition(int); - -public slots: - void addSample(int, int, int, bool); - void setResolutionForHeight(int); - void clear(); - -protected: - virtual void paintEvent(QPaintEvent *); - virtual void mouseMoveEvent(QMouseEvent *); - virtual void leaveEvent(QEvent *); - virtual void wheelEvent(QWheelEvent *event); - -private slots: - void sliderChanged(int); - -private: - void updateSlider(); - void drawSample(QPainter *, int, const QRect &, QList<QRect> *); - void drawTime(QPainter *, const QRect &); - QRect findContainingRect(const QList<QRect> &rects, const QPoint &pos) const; - struct Sample { - int sample[3]; - bool isBreak; - }; - QList<Sample> _samples; - - QAbstractSlider *slider; - int position; - int samplesPerWidth; - int resolutionForHeight; - bool ignoreScroll; - QMargins graphMargins; - - QList<QRect> rectsPaintTime; // time to do a paintEvent() - QList<QRect> rectsTimeBetween; // time between frames - QRect highlightedBar; -}; - -QLineGraph::QLineGraph(QAbstractSlider *slider, QWidget *parent) -: QWidget(parent), slider(slider), position(-1), samplesPerWidth(99), resolutionForHeight(50), - ignoreScroll(false), graphMargins(65, 10, 71, 35) -{ - setMouseTracking(true); - - slider->setMaximum(0); - slider->setMinimum(0); - slider->setSingleStep(1); - - connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int))); -} - -void QLineGraph::sliderChanged(int v) -{ - if(ignoreScroll) - return; - - if (v == slider->maximum()) - position = -1; - else - position = v; - - update(); - - // update highlightedRect - QPoint pos = mapFromGlobal(QCursor::pos()); - if (geometry().contains(pos)) { - QMouseEvent *me = new QMouseEvent(QEvent::MouseMove, pos, - Qt::NoButton, Qt::NoButton, Qt::NoModifier); - QApplication::postEvent(this, me); - } -} - -void QLineGraph::clear() -{ - _samples.clear(); - rectsPaintTime.clear(); - rectsTimeBetween.clear(); - highlightedBar = QRect(); - position = -1; - - updateSlider(); - update(); -} - -void QLineGraph::updateSlider() -{ - ignoreScroll = true; - slider->setMaximum(qMax(0, _samples.count() - samplesPerWidth - 1)); - - if(position == -1) { - slider->setValue(slider->maximum()); - } else { - slider->setValue(position); - } - ignoreScroll = false; -} - -void QLineGraph::addSample(int a, int b, int d, bool isBreak) -{ - Sample s; - s.isBreak = isBreak; - s.sample[0] = a; - s.sample[1] = b; - s.sample[2] = d; - _samples << s; - updateSlider(); - update(); -} - -void QLineGraph::setPosition(int p) -{ - sliderChanged(p); -} - -void QLineGraph::drawTime(QPainter *p, const QRect &rect) -{ - if(_samples.isEmpty()) - return; - - int first = position; - if(first == -1) - first = qMax(0, _samples.count() - samplesPerWidth - 1); - int last = qMin(_samples.count() - 1, first + samplesPerWidth); - - qreal scaleX = qreal(rect.width()) / qreal(samplesPerWidth); - - int t = 0; - - for(int ii = first; ii <= last; ++ii) { - int sampleTime = _samples.at(ii).sample[2] / 1000; - if(sampleTime != t) { - - int xEnd = rect.left() + scaleX * (ii - first); - p->drawLine(xEnd, rect.bottom(), xEnd, rect.bottom() + 7); - - QRect text(xEnd - 30, rect.bottom() + 10, 60, 30); - - p->drawText(text, Qt::AlignHCenter | Qt::AlignTop, QString::number(_samples.at(ii).sample[2])); - - t = sampleTime; - } - } - -} - -void QLineGraph::drawSample(QPainter *p, int s, const QRect &rect, QList<QRect> *record) -{ - if(_samples.isEmpty()) - return; - - int first = position; - if(first == -1) - first = qMax(0, _samples.count() - samplesPerWidth - 1); - int last = qMin(_samples.count() - 1, first + samplesPerWidth); - - qreal scaleY = qreal(rect.height()) / resolutionForHeight; - qreal scaleX = qreal(rect.width()) / qreal(samplesPerWidth); - - int xEnd; - int lastXEnd = rect.left(); - - p->save(); - p->setPen(Qt::NoPen); - for(int ii = first + 1; ii <= last; ++ii) { - - xEnd = rect.left() + scaleX * (ii - first); - int yEnd = rect.bottom() - _samples.at(ii).sample[s] * scaleY; - - if (!(s == 0 && _samples.at(ii).isBreak)) { - QRect bar(lastXEnd, yEnd, scaleX, _samples.at(ii).sample[s] * scaleY); - record->append(bar); - p->drawRect(bar); - } - - lastXEnd = xEnd; - } - p->restore(); -} - -void QLineGraph::paintEvent(QPaintEvent *) -{ - QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); - - QRect r(graphMargins.left(), graphMargins.top(), - width() - graphMargins.right(), height() - graphMargins.bottom()); - - p.save(); - p.rotate(-90); - p.translate(-r.height()/2 - r.width()/2 - graphMargins.right(), -r.height()/2); - p.drawText(r, Qt::AlignCenter, tr("Frame rate")); - p.restore(); - - p.setBrush(QColor("lightsteelblue")); - rectsTimeBetween.clear(); - drawSample(&p, 0, r, &rectsTimeBetween); - - p.setBrush(QColor("pink")); - rectsPaintTime.clear(); - drawSample(&p, 1, r, &rectsPaintTime); - - if (!highlightedBar.isNull()) { - p.setBrush(Qt::darkGreen); - p.drawRect(highlightedBar); - } - - p.setBrush(Qt::NoBrush); - p.drawRect(r); - - slider->setGeometry(x() + r.x(), slider->y(), r.width(), slider->height()); - - for(int ii = 0; ii <= resolutionForHeight; ++ii) { - int y = 1 + r.bottom() - ii * r.height() / resolutionForHeight; - - if((ii % 10) == 0) { - p.drawLine(r.left() - 20, y, r.left(), y); - QRect text(r.left() - 20 - 53, y - 10, 50, 20); - p.drawText(text, Qt::AlignRight | Qt::AlignVCenter, QString::number(ii)); - } else { - p.drawLine(r.left() - 7, y, r.left(), y); - } - } - - drawTime(&p, r); -} - -void QLineGraph::mouseMoveEvent(QMouseEvent *event) -{ - QPoint pos = event->pos(); - - QRect rect = findContainingRect(rectsPaintTime, pos); - if (rect.isNull()) - rect = findContainingRect(rectsTimeBetween, pos); - - if (!highlightedBar.isNull()) - update(highlightedBar.adjusted(-1, -1, 1, 1)); - highlightedBar = rect; - - if (!rect.isNull()) { - QRect graph(graphMargins.left(), graphMargins.top(), - width() - graphMargins.right(), height() - graphMargins.bottom()); - qreal scaleY = qreal(graph.height()) / resolutionForHeight; - QToolTip::showText(event->globalPos(), QString::number(qRound(rect.height() / scaleY)), this, rect); - update(rect.adjusted(-1, -1, 1, 1)); - } -} - -void QLineGraph::leaveEvent(QEvent *) -{ - if (!highlightedBar.isNull()) { - QRect bar = highlightedBar.adjusted(-1, -1, 1, 1); - highlightedBar = QRect(); - update(bar); - } -} - -void QLineGraph::wheelEvent(QWheelEvent *event) -{ - QWheelEvent we(QPoint(0,0), event->delta(), event->buttons(), event->modifiers(), event->orientation()); - QApplication::sendEvent(slider, &we); -} - -void QLineGraph::setResolutionForHeight(int resolution) -{ - resolutionForHeight = resolution; - update(); -} - -QRect QLineGraph::findContainingRect(const QList<QRect> &rects, const QPoint &pos) const -{ - for (int i=0; i<rects.count(); i++) { - if (rects[i].contains(pos)) - return rects[i]; - } - return QRect(); -} - - -class GraphWindow : public QWidget -{ - Q_OBJECT -public: - GraphWindow(QWidget *parent = 0); - - virtual QSize sizeHint() const; - -public slots: - void addSample(int, int, int, bool); - void setResolutionForHeight(int); - void clear(); - -private: - QLineGraph *m_graph; -}; - -GraphWindow::GraphWindow(QWidget *parent) - : QWidget(parent) -{ - QSlider *scroll = new QSlider(Qt::Horizontal); - scroll->setFocusPolicy(Qt::WheelFocus); - m_graph = new QLineGraph(scroll); - - setFocusPolicy(Qt::WheelFocus); - setFocusProxy(scroll); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 5, 0); - layout->setSpacing(0); - layout->addWidget(m_graph, 2); - layout->addWidget(new QLabel(tr("Total time elapsed (ms)")), 0, Qt::AlignHCenter); - layout->addWidget(scroll); -} - -void GraphWindow::addSample(int a, int b, int d, bool isBreak) -{ - m_graph->addSample(a, b, d, isBreak); -} - -void GraphWindow::setResolutionForHeight(int res) -{ - m_graph->setResolutionForHeight(res); -} - -void GraphWindow::clear() -{ - m_graph->clear(); -} - -QSize GraphWindow::sizeHint() const -{ - return QSize(400, 220); -} - - -class CanvasFrameRatePlugin : public QmlDebugClient -{ - Q_OBJECT -public: - CanvasFrameRatePlugin(QmlDebugConnection *client); - -signals: - void sample(int, int, int, bool); - -protected: - virtual void messageReceived(const QByteArray &); - -private: - int lb; - int ld; -}; - -CanvasFrameRatePlugin::CanvasFrameRatePlugin(QmlDebugConnection *client) -: QmlDebugClient(QLatin1String("CanvasFrameRate"), client), lb(-1) -{ -} - -void CanvasFrameRatePlugin::messageReceived(const QByteArray &data) -{ - QByteArray rwData = data; - QDataStream stream(&rwData, QIODevice::ReadOnly); - - int b; int c; int d; bool isBreak; - stream >> b >> c >> d >> isBreak; - - if (lb != -1) - emit sample(c, lb, ld, isBreak); - - lb = b; - ld = d; -} - -CanvasFrameRate::CanvasFrameRate(QWidget *parent) -: QWidget(parent), - m_plugin(0) -{ - m_tabs = new QTabWidget(this); - - QHBoxLayout *bottom = new QHBoxLayout; - bottom->setMargin(0); - bottom->setSpacing(10); - - m_res = new QSpinBox; - m_res->setRange(30, 200); - m_res->setValue(m_res->minimum()); - m_res->setSingleStep(10); - m_res->setSuffix(QLatin1String("ms")); - bottom->addWidget(new QLabel(tr("Resolution:"))); - bottom->addWidget(m_res); - - bottom->addStretch(); - - m_clearButton = new QPushButton(tr("Clear")); - connect(m_clearButton, SIGNAL(clicked()), SLOT(clearGraph())); - bottom->addWidget(m_clearButton); - - QPushButton *pb = new QPushButton(tr("New Graph"), this); - connect(pb, SIGNAL(clicked()), this, SLOT(newTab())); - bottom->addWidget(pb); - - m_group = new QGroupBox(tr("Enabled")); - m_group->setCheckable(true); - m_group->setChecked(false); - connect(m_group, SIGNAL(toggled(bool)), SLOT(enabledToggled(bool))); - - QVBoxLayout *groupLayout = new QVBoxLayout(m_group); - groupLayout->setContentsMargins(5, 0, 5, 0); - groupLayout->setSpacing(2); - groupLayout->addWidget(m_tabs); - groupLayout->addLayout(bottom); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, 10, 0, 0); - layout->setSpacing(0); - layout->addWidget(m_group); - setLayout(layout); -} - -void CanvasFrameRate::reset(QmlDebugConnection *conn) -{ - delete m_plugin; - m_plugin = 0; - - QWidget *w; - for (int i=0; i<m_tabs->count(); i++) { - w = m_tabs->widget(i); - m_tabs->removeTab(i); - delete w; - } - - if (conn) { - connect(conn, SIGNAL(stateChanged(QAbstractSocket::SocketState)), - SLOT(connectionStateChanged(QAbstractSocket::SocketState))); - if (conn->state() == QAbstractSocket::ConnectedState) - handleConnected(conn); - } -} - -void CanvasFrameRate::connectionStateChanged(QAbstractSocket::SocketState state) -{ - if (state == QAbstractSocket::UnconnectedState) { - delete m_plugin; - m_plugin = 0; - } else if (state == QAbstractSocket::ConnectedState) { - handleConnected(qobject_cast<QmlDebugConnection*>(sender())); - } -} - -void CanvasFrameRate::handleConnected(QmlDebugConnection *conn) -{ - delete m_plugin; - m_plugin = new CanvasFrameRatePlugin(conn); - enabledToggled(m_group->isChecked()); - newTab(); -} - -void CanvasFrameRate::setSizeHint(const QSize &size) -{ - m_sizeHint = size; -} - -QSize CanvasFrameRate::sizeHint() const -{ - return m_sizeHint; -} - -void CanvasFrameRate::clearGraph() -{ - if (m_tabs->count()) { - GraphWindow *w = qobject_cast<GraphWindow*>(m_tabs->currentWidget()); - if (w) - w->clear(); - } -} - -void CanvasFrameRate::newTab() -{ - if (!m_plugin) - return; - - if (m_tabs->count()) { - QWidget *w = m_tabs->widget(m_tabs->count() - 1); - QObject::disconnect(m_plugin, SIGNAL(sample(int,int,int,bool)), - w, SLOT(addSample(int,int,int,bool))); - } - - int count = m_tabs->count(); - - GraphWindow *graph = new GraphWindow; - graph->setResolutionForHeight(m_res->value()); - connect(m_plugin, SIGNAL(sample(int,int,int,bool)), - graph, SLOT(addSample(int,int,int,bool))); - connect(m_res, SIGNAL(valueChanged(int)), - graph, SLOT(setResolutionForHeight(int))); - - QString name = QLatin1String("Graph ") + QString::number(count + 1); - m_tabs->addTab(graph, name); - m_tabs->setCurrentIndex(count); -} - -void CanvasFrameRate::enabledToggled(bool checked) -{ - if (m_plugin) - static_cast<QmlDebugClient *>(m_plugin)->setEnabled(checked); -} - -QT_END_NAMESPACE - -#include "canvasframerate.moc" diff --git a/tools/qmldebugger/standalone/engine.cpp b/tools/qmldebugger/standalone/engine.cpp deleted file mode 100644 index 894f97d..0000000 --- a/tools/qmldebugger/standalone/engine.cpp +++ /dev/null @@ -1,219 +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 Qt QML Debugger 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 <QVBoxLayout> -#include <QHBoxLayout> -#include <QSplitter> -#include <QTabWidget> -#include <QFile> - -#include <private/qmlenginedebug_p.h> -#include <private/qmldebugclient_p.h> -#include <QtDeclarative/qmlcomponent.h> -#include <QtDeclarative/qmlgraphicsitem.h> -#include <private/qmldebugservice_p.h> - -#include "engine.h" -#include "objectpropertiesview.h" -#include "expressionquerywidget.h" -#include "objecttree.h" -#include "watchtable.h" - -QT_BEGIN_NAMESPACE - - -class DebuggerEngineItem : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name CONSTANT); - Q_PROPERTY(int engineId READ engineId CONSTANT); - -public: - DebuggerEngineItem(const QString &name, int id) - : m_name(name), m_engineId(id) {} - - QString name() const { return m_name; } - int engineId() const { return m_engineId; } - -private: - QString m_name; - int m_engineId; -}; - -EnginePane::EnginePane(QmlDebugConnection *conn, QWidget *parent) -: QWidget(parent), m_client(new QmlEngineDebug(conn, this)), m_engines(0), m_context(0), m_watchTableModel(0), m_exprQueryWidget(0) -{ - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - - QFile enginesFile(":/engines.qml"); - enginesFile.open(QFile::ReadOnly); - Q_ASSERT(enginesFile.isOpen()); - - m_engineView = new QmlView(this); - m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); - m_engineView->setContentResizable(true); - m_engineView->setQml(enginesFile.readAll()); - m_engineView->execute(); - m_engineView->setFixedHeight(100); - QObject::connect(m_engineView->root(), SIGNAL(engineClicked(int)), - this, SLOT(engineSelected(int))); - QObject::connect(m_engineView->root(), SIGNAL(refreshEngines()), - this, SLOT(refreshEngines())); - - m_engineView->setVisible(false); - layout->addWidget(m_engineView); - - QSplitter *splitter = new QSplitter; - - m_objTree = new ObjectTree(m_client, this); - m_propertiesView = new ObjectPropertiesView(m_client); - m_watchTableModel = new WatchTableModel(m_client, this); - - m_watchTableView = new WatchTableView(m_watchTableModel); - m_watchTableView->setModel(m_watchTableModel); - WatchTableHeaderView *header = new WatchTableHeaderView(m_watchTableModel); - m_watchTableView->setHorizontalHeader(header); - - connect(m_objTree, SIGNAL(currentObjectChanged(QmlDebugObjectReference)), - m_propertiesView, SLOT(reload(QmlDebugObjectReference))); - connect(m_objTree, SIGNAL(expressionWatchRequested(QmlDebugObjectReference,QString)), - m_watchTableModel, SLOT(expressionWatchRequested(QmlDebugObjectReference,QString))); - - connect(m_propertiesView, SIGNAL(activated(QmlDebugObjectReference,QmlDebugPropertyReference)), - m_watchTableModel, SLOT(togglePropertyWatch(QmlDebugObjectReference,QmlDebugPropertyReference))); - - connect(m_watchTableModel, SIGNAL(watchCreated(QmlDebugWatch*)), - m_propertiesView, SLOT(watchCreated(QmlDebugWatch*))); - - connect(m_watchTableView, SIGNAL(objectActivated(int)), - m_objTree, SLOT(setCurrentObject(int))); - - m_exprQueryWidget = new ExpressionQueryWidget(ExpressionQueryWidget::SeparateEntryMode, m_client); - connect(m_objTree, SIGNAL(currentObjectChanged(QmlDebugObjectReference)), - m_exprQueryWidget, SLOT(setCurrentObject(QmlDebugObjectReference))); - - QSplitter *propertiesTab = new QSplitter(Qt::Vertical); - propertiesTab->addWidget(m_propertiesView); - propertiesTab->addWidget(m_exprQueryWidget); - propertiesTab->setStretchFactor(0, 2); - propertiesTab->setStretchFactor(1, 1); - - m_tabs = new QTabWidget(this); - m_tabs->addTab(propertiesTab, tr("Properties")); - m_tabs->addTab(m_watchTableView, tr("Watched")); - - splitter->addWidget(m_objTree); - splitter->addWidget(m_tabs); - splitter->setStretchFactor(1, 2); - layout->addWidget(splitter); -} - -void EnginePane::engineSelected(int id) -{ - qWarning() << "Engine selected" << id; - queryContext(id); -} - -void EnginePane::queryContext(int id) -{ - if (m_context) { - delete m_context; - m_context = 0; - } - - m_context = m_client->queryRootContexts(QmlDebugEngineReference(id), this); - if (!m_context->isWaiting()) - contextChanged(); - else - QObject::connect(m_context, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(contextChanged())); -} - -void EnginePane::contextChanged() -{ - //dump(m_context->rootContext(), 0); - - foreach (const QmlDebugObjectReference &object, m_context->rootContext().objects()) - m_objTree->reload(object.debugId()); - - delete m_context; m_context = 0; -} - -void EnginePane::refreshEngines() -{ - if (m_engines) - return; - - m_engines = m_client->queryAvailableEngines(this); - if (!m_engines->isWaiting()) - enginesChanged(); - else - QObject::connect(m_engines, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(enginesChanged())); -} - -void EnginePane::enginesChanged() -{ - qDeleteAll(m_engineItems); - m_engineItems.clear(); - - QList<QmlDebugEngineReference> engines = m_engines->engines(); - delete m_engines; m_engines = 0; - - if (engines.isEmpty()) - qWarning("qmldebugger: no engines found!"); - - for (int ii = 0; ii < engines.count(); ++ii) - m_engineItems << new DebuggerEngineItem(engines.at(ii).name(), - engines.at(ii).debugId()); - - m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); - - m_engineView->setVisible(m_engineItems.count() > 1); - if (m_engineItems.count() == 1) - engineSelected(qobject_cast<DebuggerEngineItem*>(m_engineItems.at(0))->engineId()); -} - - -#include "engine.moc" - -QT_END_NAMESPACE - diff --git a/tools/qmldebugger/standalone/engine.png b/tools/qmldebugger/standalone/engine.png Binary files differdeleted file mode 100644 index a0a8a04..0000000 --- a/tools/qmldebugger/standalone/engine.png +++ /dev/null diff --git a/tools/qmldebugger/standalone/engines.qml b/tools/qmldebugger/standalone/engines.qml deleted file mode 100644 index 0b2b7ac..0000000 --- a/tools/qmldebugger/standalone/engines.qml +++ /dev/null @@ -1,46 +0,0 @@ -import Qt 4.6 - -Item { - height: 100 - id: root - signal engineClicked(int id) - signal refreshEngines() - - Row { - anchors.fill: parent - Repeater { - model: engines - Item { - width: 100; height: 100; - Image { - id: engineIcon; - source: "qrc:/engine.png" - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - anchors.top: engineIcon.bottom; - text: modelData.name + "(" + modelData.engineId + ")" - anchors.horizontalCenter: parent.horizontalCenter - } - MouseRegion { - anchors.fill: parent - onClicked: root.engineClicked(modelData.engineId); - } - } - } - } - - - Image { - y: 15 - source: "qrc:/refresh.png"; - width: 75; - height: 63; - smooth: true - anchors.right: parent.right - MouseRegion { - anchors.fill: parent - onClicked: root.refreshEngines() - } - } -} diff --git a/tools/qmldebugger/standalone/expressionquerywidget.cpp b/tools/qmldebugger/standalone/expressionquerywidget.cpp deleted file mode 100644 index a068982..0000000 --- a/tools/qmldebugger/standalone/expressionquerywidget.cpp +++ /dev/null @@ -1,276 +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 Qt QML Debugger 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 <QtCore/qdebug.h> - -#include <QtGui/qlabel.h> -#include <QtGui/qtextedit.h> -#include <QtGui/qlineedit.h> -#include <QtGui/qpushbutton.h> -#include <QtGui/qevent.h> -#include <QtGui/qgroupbox.h> -#include <QtGui/qtextobject.h> -#include <QtGui/qlayout.h> - -#include "expressionquerywidget.h" - -ExpressionQueryWidget::ExpressionQueryWidget(Mode mode, QmlEngineDebug *client, QWidget *parent) - : QWidget(parent), - m_mode(mode), - m_client(client), - m_query(0), - m_textEdit(new QTextEdit), - m_lineEdit(0) -{ - m_prompt = QLatin1String(">> "); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); - layout->addWidget(m_textEdit); - - updateTitle(); - - if (m_mode == SeparateEntryMode) { - m_lineEdit = new QLineEdit; - connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(executeExpression())); - QHBoxLayout *hbox = new QHBoxLayout; - hbox->setMargin(5); - hbox->setSpacing(5); - hbox->addWidget(new QLabel(tr("Expression:"))); - hbox->addWidget(m_lineEdit); - layout->addLayout(hbox); - - m_textEdit->setReadOnly(true); - m_lineEdit->installEventFilter(this); - } else { - m_textEdit->installEventFilter(this); - appendPrompt(); - } -} - -void ExpressionQueryWidget::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void ExpressionQueryWidget::clear() -{ - m_textEdit->clear(); - if (m_lineEdit) - m_lineEdit->clear(); - if (m_mode == ShellMode) - appendPrompt(); -} - -void ExpressionQueryWidget::updateTitle() -{ - if (m_currObject.debugId() < 0) { - m_title = tr("Expression queries"); - } else { - QString desc = QLatin1String("<") - + m_currObject.className() + QLatin1String(": ") - + (m_currObject.name().isEmpty() ? QLatin1String("<unnamed>") : m_currObject.name()) - + QLatin1String(">"); - m_title = tr("Expression queries (using context for %1)" , "Selected object").arg(desc); - } -} - -void ExpressionQueryWidget::appendPrompt() -{ - m_textEdit->moveCursor(QTextCursor::End); - - if (m_mode == SeparateEntryMode) { - m_textEdit->insertPlainText("\n"); - } else { - m_textEdit->setTextColor(Qt::gray); - m_textEdit->append(m_prompt); - } -} - -void ExpressionQueryWidget::setCurrentObject(const QmlDebugObjectReference &obj) -{ - m_currObject = obj; - updateTitle(); -} - -void ExpressionQueryWidget::checkCurrentContext() -{ - m_textEdit->moveCursor(QTextCursor::End); - - if (m_currObject.debugId() != -1 && m_currObject.debugId() != m_objectAtLastFocus.debugId()) - showCurrentContext(); - m_objectAtLastFocus = m_currObject; -} - -void ExpressionQueryWidget::showCurrentContext() -{ - if (m_mode == ShellMode) { - // clear the initial prompt - if (m_textEdit->document()->lineCount() == 1) - m_textEdit->clear(); - } - - m_textEdit->moveCursor(QTextCursor::End); - m_textEdit->setTextColor(Qt::darkGreen); - m_textEdit->append(m_currObject.className() - + QLatin1String(": ") - + (m_currObject.name().isEmpty() ? QLatin1String("<unnamed object>") : m_currObject.name())); - appendPrompt(); -} - -void ExpressionQueryWidget::executeExpression() -{ - if (!m_client) - return; - - if (m_mode == SeparateEntryMode) - m_expr = m_lineEdit->text().trimmed(); - else - m_expr = m_expr.trimmed(); - - if (!m_expr.isEmpty() && m_currObject.debugId() != -1) { - if (m_query) - delete m_query; - m_query = m_client->queryExpressionResult(m_currObject.debugId(), m_expr, this); - if (!m_query->isWaiting()) - showResult(); - else - QObject::connect(m_query, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(showResult())); - - m_lastExpr = m_expr; - if (m_lineEdit) - m_lineEdit->clear(); - } -} - -void ExpressionQueryWidget::showResult() -{ - if (m_query) { - m_textEdit->moveCursor(QTextCursor::End); - QVariant value = m_query->result(); - QString result; - - if (value.type() == QVariant::List || value.type() == QVariant::StringList) { - result = tr("<%1 items>", "%1 = number of items").arg(value.toList().count()); - } else if (value.isNull()) { - result = QLatin1String("<no value>"); - } else { - result = value.toString(); - } - - if (m_mode == SeparateEntryMode) { - m_textEdit->setTextColor(Qt::black); - m_textEdit->setFontWeight(QFont::Bold); - m_textEdit->insertPlainText(m_expr + " : "); - m_textEdit->setFontWeight(QFont::Normal); - m_textEdit->insertPlainText(result); - } else { - m_textEdit->setTextColor(Qt::darkGreen); - m_textEdit->insertPlainText(" => "); - m_textEdit->setTextColor(Qt::black); - m_textEdit->insertPlainText(result); - } - appendPrompt(); - m_expr.clear(); - } -} - -bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == m_textEdit) { - switch (event->type()) { - case QEvent::KeyPress: - { - QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); - int key = keyEvent->key(); - if (key == Qt::Key_Return || key == Qt::Key_Enter) { - executeExpression(); - return true; - } else if (key == Qt::Key_Backspace) { - // ensure m_expr doesn't contain backspace characters - QTextCursor cursor = m_textEdit->textCursor(); - bool atLastLine = !(cursor.block().next().isValid()); - if (!atLastLine) - return true; - if (cursor.columnNumber() <= m_prompt.count()) - return true; - cursor.deletePreviousChar(); - m_expr = cursor.block().text().mid(m_prompt.count()); - return true; - } else { - m_textEdit->moveCursor(QTextCursor::End); - m_textEdit->setTextColor(Qt::black); - m_expr += keyEvent->text(); - } - break; - } - case QEvent::FocusIn: - checkCurrentContext(); - m_textEdit->moveCursor(QTextCursor::End); - break; - default: - break; - } - } else if (obj == m_lineEdit) { - switch (event->type()) { - case QEvent::KeyPress: - { - QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); - int key = keyEvent->key(); - if (key == Qt::Key_Up && m_lineEdit->text() != m_lastExpr) { - m_expr = m_lineEdit->text(); - if (!m_lastExpr.isEmpty()) - m_lineEdit->setText(m_lastExpr); - } else if (key == Qt::Key_Down) { - m_lineEdit->setText(m_expr); - } - break; - } - case QEvent::FocusIn: - checkCurrentContext(); - break; - default: - break; - } - } - return QWidget::eventFilter(obj, event); -} diff --git a/tools/qmldebugger/standalone/expressionquerywidget.h b/tools/qmldebugger/standalone/expressionquerywidget.h deleted file mode 100644 index 5bba5c3..0000000 --- a/tools/qmldebugger/standalone/expressionquerywidget.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef EXPRESSIONQUERYWIDGET_H -#define EXPRESSIONQUERYWIDGET_H - -#include <QWidget> - -#include <private/qmldebug_p.h> - -QT_BEGIN_NAMESPACE - -class QGroupBox; -class QTextEdit; -class QLineEdit; -class QPushButton; - -class ExpressionQueryWidget : public QWidget -{ - Q_OBJECT -public: - enum Mode { - SeparateEntryMode, - ShellMode - }; - - ExpressionQueryWidget(Mode mode = SeparateEntryMode, QmlEngineDebug *client = 0, QWidget *parent = 0); - - void setEngineDebug(QmlEngineDebug *client); - void clear(); - -protected: - bool eventFilter(QObject *obj, QEvent *event); - -public slots: - void setCurrentObject(const QmlDebugObjectReference &obj); - -private slots: - void executeExpression(); - void showResult(); - -private: - void appendPrompt(); - void checkCurrentContext(); - void showCurrentContext(); - void updateTitle(); - - Mode m_mode; - - QmlEngineDebug *m_client; - QmlDebugExpressionQuery *m_query; - QTextEdit *m_textEdit; - QLineEdit *m_lineEdit; - QPushButton *m_button; - QString m_prompt; - QString m_expr; - QString m_lastExpr; - - QString m_title; - - QmlDebugObjectReference m_currObject; - QmlDebugObjectReference m_objectAtLastFocus; -}; - -QT_END_NAMESPACE - -#endif - diff --git a/tools/qmldebugger/standalone/objectpropertiesview.cpp b/tools/qmldebugger/standalone/objectpropertiesview.cpp deleted file mode 100644 index b6089c3..0000000 --- a/tools/qmldebugger/standalone/objectpropertiesview.cpp +++ /dev/null @@ -1,274 +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 Qt QML Debugger 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 <QtCore/qdebug.h> - -#include <QtGui/qtreewidget.h> -#include <QtGui/qlayout.h> -#include <QtGui/qheaderview.h> - -#include <private/qmldebugservice_p.h> -#include <private/qmldebug_p.h> -#include <private/qmldebugclient_p.h> - -#include "objectpropertiesview.h" - -QT_BEGIN_NAMESPACE - -class PropertiesViewItem : public QObject, public QTreeWidgetItem -{ - Q_OBJECT -public: - enum Type { - BindingType, - OtherType - }; - - PropertiesViewItem(QTreeWidget *widget, Type type = OtherType); - PropertiesViewItem(QTreeWidgetItem *parent, Type type = OtherType); - - QmlDebugPropertyReference property; - Type type; -}; - -PropertiesViewItem::PropertiesViewItem(QTreeWidget *widget, Type type) - : QTreeWidgetItem(widget), type(type) -{ -} - -PropertiesViewItem::PropertiesViewItem(QTreeWidgetItem *parent, Type type) - : QTreeWidgetItem(parent), type(type) -{ -} - -ObjectPropertiesView::ObjectPropertiesView(QmlEngineDebug *client, QWidget *parent) - : QWidget(parent), - m_client(client), - m_query(0), - m_watch(0) -{ - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - setLayout(layout); - - m_tree = new QTreeWidget(this); - m_tree->setAlternatingRowColors(true); - m_tree->setExpandsOnDoubleClick(false); - m_tree->setHeaderLabels(QStringList() - << tr("Name") << tr("Value") << tr("Type")); - QObject::connect(m_tree, SIGNAL(itemActivated(QTreeWidgetItem *, int)), - this, SLOT(itemActivated(QTreeWidgetItem *))); - - m_tree->setColumnCount(3); - m_tree->header()->setDefaultSectionSize(150); - - layout->addWidget(m_tree); -} - -void ObjectPropertiesView::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void ObjectPropertiesView::clear() -{ - setObject(QmlDebugObjectReference()); -} - -void ObjectPropertiesView::reload(const QmlDebugObjectReference &obj) -{ - if (!m_client) - return; - if (m_query) - delete m_query; - - m_query = m_client->queryObjectRecursive(obj, this); - if (!m_query->isWaiting()) - queryFinished(); - else - QObject::connect(m_query, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(queryFinished())); -} - -void ObjectPropertiesView::queryFinished() -{ - if (!m_client || !m_query) - return; - - QmlDebugObjectReference obj = m_query->object(); - - QmlDebugWatch *watch = m_client->addWatch(obj, this); - if (watch->state() == QmlDebugWatch::Dead) { - delete watch; - watch = 0; - } else { - if (m_watch) { - m_client->removeWatch(m_watch); - delete m_watch; - } - m_watch = watch; - QObject::connect(watch, SIGNAL(valueChanged(QByteArray,QVariant)), - this, SLOT(valueChanged(QByteArray,QVariant))); - } - - delete m_query; - m_query = 0; - - setObject(obj); -} - -void ObjectPropertiesView::setPropertyValue(PropertiesViewItem *item, const QVariant &value, bool makeGray) -{ - if (value.type() == QVariant::List || value.type() == QVariant::StringList) { - PropertiesViewItem *bindingItem = static_cast<PropertiesViewItem*>(item->takeChild(item->childCount() - 1)); - if (bindingItem && bindingItem->type != PropertiesViewItem::BindingType) { - delete bindingItem; - bindingItem = 0; - } - - qDeleteAll(item->takeChildren()); - - QVariantList variants = value.toList(); - item->setText(1, tr("<%1 items>", "%1 = number of items").arg(variants.count())); - item->setText(2, QString::fromUtf8(value.typeName())); - - PropertiesViewItem *child; - for (int i=0; i<variants.count(); i++) { - child = new PropertiesViewItem(item); - setPropertyValue(child, variants[i], makeGray); - } - - if (bindingItem) - item->addChild(bindingItem); - - item->setExpanded(false); - } else { - item->setText(1, (value.isNull() ? QLatin1String("<no value>") : value.toString())); - item->setExpanded(true); - } - - if (makeGray) { - for (int i=0; i<m_tree->columnCount(); i++) - item->setForeground(i, Qt::gray); - } -} - -void ObjectPropertiesView::setObject(const QmlDebugObjectReference &object) -{ - m_object = object; - m_tree->clear(); - - QList<QmlDebugPropertyReference> properties = object.properties(); - for (int i=0; i<properties.count(); i++) { - const QmlDebugPropertyReference &p = properties[i]; - - PropertiesViewItem *item = new PropertiesViewItem(m_tree); - item->property = p; - - item->setText(0, p.name()); - item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - setPropertyValue(item, p.value(), !p.hasNotifySignal()); - item->setText(2, p.valueTypeName()); - - // binding is set after property value to ensure it is added to the end of the - // list, if the value is a list - if (!p.binding().isEmpty()) { - PropertiesViewItem *binding = new PropertiesViewItem(item, PropertiesViewItem::BindingType); - binding->setText(1, p.binding()); - binding->setForeground(1, Qt::darkGreen); - } - } -} - -void ObjectPropertiesView::watchCreated(QmlDebugWatch *watch) -{ - if (watch->objectDebugId() == m_object.debugId() - && qobject_cast<QmlDebugPropertyWatch*>(watch)) { - connect(watch, SIGNAL(stateChanged(QmlDebugWatch::State)), SLOT(watchStateChanged())); - setWatched(qobject_cast<QmlDebugPropertyWatch*>(watch)->name(), true); - } -} - -void ObjectPropertiesView::watchStateChanged() -{ - QmlDebugWatch *watch = qobject_cast<QmlDebugWatch*>(sender()); - - if (watch->objectDebugId() == m_object.debugId() - && qobject_cast<QmlDebugPropertyWatch*>(watch) - && watch->state() == QmlDebugWatch::Inactive) { - setWatched(qobject_cast<QmlDebugPropertyWatch*>(watch)->name(), false); - } -} - -void ObjectPropertiesView::setWatched(const QString &property, bool watched) -{ - for (int i=0; i<m_tree->topLevelItemCount(); i++) { - PropertiesViewItem *item = static_cast<PropertiesViewItem *>(m_tree->topLevelItem(i)); - if (item->property.name() == property && item->property.hasNotifySignal()) { - QFont font = m_tree->font(); - font.setBold(watched); - item->setFont(0, font); - } - } -} - -void ObjectPropertiesView::valueChanged(const QByteArray &name, const QVariant &value) -{ - for (int i=0; i<m_tree->topLevelItemCount(); i++) { - PropertiesViewItem *item = static_cast<PropertiesViewItem *>(m_tree->topLevelItem(i)); - if (item->property.name() == name) { - setPropertyValue(item, value, !item->property.hasNotifySignal()); - return; - } - } -} - -void ObjectPropertiesView::itemActivated(QTreeWidgetItem *i) -{ - PropertiesViewItem *item = static_cast<PropertiesViewItem *>(i); - if (!item->property.name().isEmpty()) - emit activated(m_object, item->property); -} - -QT_END_NAMESPACE - -#include "objectpropertiesview.moc" diff --git a/tools/qmldebugger/standalone/objectpropertiesview.h b/tools/qmldebugger/standalone/objectpropertiesview.h deleted file mode 100644 index e524033..0000000 --- a/tools/qmldebugger/standalone/objectpropertiesview.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PROPERTIESTABLEMODEL_H -#define PROPERTIESTABLEMODEL_H - -#include <private/qmldebug_p.h> - -#include <QtGui/qwidget.h> - -QT_BEGIN_NAMESPACE - -class QTreeWidget; -class QTreeWidgetItem; -class QmlDebugConnection; -class PropertiesViewItem; - -class ObjectPropertiesView : public QWidget -{ - Q_OBJECT -public: - ObjectPropertiesView(QmlEngineDebug *client = 0, QWidget *parent = 0); - - void setEngineDebug(QmlEngineDebug *client); - void clear(); - -signals: - void activated(const QmlDebugObjectReference &, const QmlDebugPropertyReference &); - -public slots: - void reload(const QmlDebugObjectReference &); - void watchCreated(QmlDebugWatch *); - -private slots: - void queryFinished(); - void watchStateChanged(); - void valueChanged(const QByteArray &name, const QVariant &value); - void itemActivated(QTreeWidgetItem *i); - -private: - void setObject(const QmlDebugObjectReference &object); - void setWatched(const QString &property, bool watched); - void setPropertyValue(PropertiesViewItem *item, const QVariant &value, bool makeGray); - - QmlEngineDebug *m_client; - QmlDebugObjectQuery *m_query; - QmlDebugWatch *m_watch; - - QTreeWidget *m_tree; - QmlDebugObjectReference m_object; -}; - - -QT_END_NAMESPACE - -#endif diff --git a/tools/qmldebugger/standalone/objecttree.cpp b/tools/qmldebugger/standalone/objecttree.cpp deleted file mode 100644 index 11857a6..0000000 --- a/tools/qmldebugger/standalone/objecttree.cpp +++ /dev/null @@ -1,231 +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 Qt QML Debugger 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 <QtGui/qevent.h> -#include <QtGui/qmenu.h> -#include <QtGui/qaction.h> - -#include <QInputDialog> - -#include <private/qmldebugservice_p.h> -#include <private/qmldebug_p.h> -#include <private/qmldebugclient_p.h> - -#include "objecttree.h" - -Q_DECLARE_METATYPE(QmlDebugObjectReference) - -ObjectTree::ObjectTree(QmlEngineDebug *client, QWidget *parent) - : QTreeWidget(parent), - m_client(client), - m_query(0) -{ - setHeaderHidden(true); - setMinimumWidth(250); - setExpandsOnDoubleClick(false); - - connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), - SLOT(currentItemChanged(QTreeWidgetItem *))); - connect(this, SIGNAL(itemActivated(QTreeWidgetItem *, int)), - SLOT(activated(QTreeWidgetItem *))); -} - -void ObjectTree::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void ObjectTree::reload(int objectDebugId) -{ - if (!m_client) - return; - - if (m_query) { - delete m_query; - m_query = 0; - } - - m_query = m_client->queryObjectRecursive(QmlDebugObjectReference(objectDebugId), this); - if (!m_query->isWaiting()) - objectFetched(); - else - QObject::connect(m_query, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(objectFetched())); -} - -void ObjectTree::setCurrentObject(int debugId) -{ - QTreeWidgetItem *item = findItemByObjectId(debugId); - if (item) { - setCurrentItem(item); - scrollToItem(item); - item->setExpanded(true); - } -} - -void ObjectTree::objectFetched() -{ - dump(m_query->object(), 0); - buildTree(m_query->object(), 0); - setCurrentItem(topLevelItem(0)); - - delete m_query; - m_query = 0; -} - -void ObjectTree::currentItemChanged(QTreeWidgetItem *item) -{ - if (!item) - return; - - QmlDebugObjectReference obj = item->data(0, Qt::UserRole).value<QmlDebugObjectReference>(); - if (obj.debugId() >= 0) - emit currentObjectChanged(obj); -} - -void ObjectTree::activated(QTreeWidgetItem *item) -{ - if (!item) - return; - - QmlDebugObjectReference obj = item->data(0, Qt::UserRole).value<QmlDebugObjectReference>(); - if (obj.debugId() >= 0) - emit activated(obj); -} - -void ObjectTree::buildTree(const QmlDebugObjectReference &obj, QTreeWidgetItem *parent) -{ - if (!parent) - clear(); - - QTreeWidgetItem *item = parent ? new QTreeWidgetItem(parent) : new QTreeWidgetItem(this); - item->setText(0, obj.className()); - item->setData(0, Qt::UserRole, qVariantFromValue(obj)); - - if (parent && obj.contextDebugId() >= 0 - && obj.contextDebugId() != parent->data(0, Qt::UserRole - ).value<QmlDebugObjectReference>().contextDebugId()) { - QmlDebugFileReference source = obj.source(); - if (!source.url().isEmpty()) { - QString toolTipString = QLatin1String("URL: ") + source.url().toString(); - item->setToolTip(0, toolTipString); - } - item->setForeground(0, QColor("orange")); - } else { - item->setExpanded(true); - } - - if (obj.contextDebugId() < 0) - item->setForeground(0, Qt::lightGray); - - for (int ii = 0; ii < obj.children().count(); ++ii) - buildTree(obj.children().at(ii), item); -} - -void ObjectTree::dump(const QmlDebugContextReference &ctxt, int ind) -{ - QByteArray indent(ind * 4, ' '); - qWarning().nospace() << indent.constData() << ctxt.debugId() << " " - << qPrintable(ctxt.name()); - - for (int ii = 0; ii < ctxt.contexts().count(); ++ii) - dump(ctxt.contexts().at(ii), ind + 1); - - for (int ii = 0; ii < ctxt.objects().count(); ++ii) - dump(ctxt.objects().at(ii), ind); -} - -void ObjectTree::dump(const QmlDebugObjectReference &obj, int ind) -{ - QByteArray indent(ind * 4, ' '); - qWarning().nospace() << indent.constData() << qPrintable(obj.className()) - << " " << qPrintable(obj.name()) << " " - << obj.debugId(); - - for (int ii = 0; ii < obj.children().count(); ++ii) - dump(obj.children().at(ii), ind + 1); -} - -QTreeWidgetItem *ObjectTree::findItemByObjectId(int debugId) const -{ - for (int i=0; i<topLevelItemCount(); i++) { - QTreeWidgetItem *item = findItem(topLevelItem(i), debugId); - if (item) - return item; - } - - return 0; -} - -QTreeWidgetItem *ObjectTree::findItem(QTreeWidgetItem *item, int debugId) const -{ - if (item->data(0, Qt::UserRole).value<QmlDebugObjectReference>().debugId() == debugId) - return item; - - QTreeWidgetItem *child; - for (int i=0; i<item->childCount(); i++) { - child = findItem(item->child(i), debugId); - if (child) - return child; - } - - return 0; -} - -void ObjectTree::mousePressEvent(QMouseEvent *me) -{ - QTreeWidget::mousePressEvent(me); - if (!currentItem()) - return; - if(me->button() == Qt::RightButton && me->type() == QEvent::MouseButtonPress) { - QAction action(tr("Add watch..."), 0); - QList<QAction *> actions; - actions << &action; - QmlDebugObjectReference obj = - currentItem()->data(0, Qt::UserRole).value<QmlDebugObjectReference>(); - if (QMenu::exec(actions, me->globalPos())) { - bool ok = false; - QString watch = QInputDialog::getText(this, tr("Watch expression"), - tr("Expression:"), QLineEdit::Normal, QString(), &ok); - if (ok && !watch.isEmpty()) - emit expressionWatchRequested(obj, watch); - } - } -} diff --git a/tools/qmldebugger/standalone/qmldebugger.cpp b/tools/qmldebugger/standalone/qmldebugger.cpp deleted file mode 100644 index d713ce8..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.cpp +++ /dev/null @@ -1,181 +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 Qt QML Debugger 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 <QtCore/qtimer.h> -#include <QtCore/qdebug.h> -#include <QtCore/qsettings.h> - -#include <QtGui/qlayout.h> -#include <QtGui/qpushbutton.h> -#include <QtGui/qlineedit.h> -#include <QtGui/qtabwidget.h> -#include <QtGui/qspinbox.h> -#include <QtGui/qlabel.h> - -#include "canvasframerate.h" -#include "engine.h" -#include "qmldebugger.h" - -QmlDebugger::QmlDebugger(QWidget *parent) -: QWidget(parent) -{ - QVBoxLayout *layout = new QVBoxLayout; - setLayout(layout); - - QHBoxLayout *connectLayout = new QHBoxLayout; - layout->addLayout(connectLayout); - connectLayout->addStretch(2); - - m_connectionState = new QLabel(this); - connectLayout->addWidget(m_connectionState); - m_host = new QLineEdit(this); - connectLayout->addWidget(m_host); - m_port = new QSpinBox(this); - m_port->setMinimum(1024); - m_port->setMaximum(20000); - connectLayout->addWidget(m_port); - m_connectButton = new QPushButton(tr("Connect"), this); - QObject::connect(m_connectButton, SIGNAL(clicked()), - this, SLOT(connectToHost())); - connectLayout->addWidget(m_connectButton); - m_disconnectButton = new QPushButton(tr("Disconnect"), this); - QObject::connect(m_disconnectButton, SIGNAL(clicked()), - this, SLOT(disconnectFromHost())); - m_disconnectButton->setEnabled(false); - connectLayout->addWidget(m_disconnectButton); - - m_tabs = new QTabWidget(this); - layout->addWidget(m_tabs); - - CanvasFrameRate *cfr = new CanvasFrameRate(this); - cfr->reset(&client); - cfr->setSizeHint(QSize(800, 600)); - m_tabs->addTab(cfr, tr("Frame Rate")); - - m_enginePane = new EnginePane(&client, this); - m_tabs->addTab(m_enginePane, tr("QML Engine")); - - QObject::connect(&client, SIGNAL(stateChanged(QAbstractSocket::SocketState)), - this, SLOT(connectionStateChanged())); - connectionStateChanged(); - - QObject::connect(&client, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(connectionError(QAbstractSocket::SocketError))); - - QSettings settings; - m_host->setText(settings.value("Host", "127.0.0.1").toString()); - m_port->setValue(settings.value("Port", 3768).toInt()); - - connectToHost(); -} - -void QmlDebugger::setHost(const QString &host) -{ - m_host->setText(host); -} - -void QmlDebugger::setPort(quint16 port) -{ - m_port->setValue(port); -} - -void QmlDebugger::showEngineTab() -{ - m_tabs->setCurrentWidget(m_enginePane); -} - -void QmlDebugger::closeEvent(QCloseEvent *event) -{ - QSettings settings; - settings.setValue("Host", m_host->text()); - settings.setValue("Port", m_port->value()); - - QWidget::closeEvent(event); -} - -void QmlDebugger::connectionStateChanged() -{ - switch (client.state()) { - default: - case QAbstractSocket::UnconnectedState: - m_connectionState->setText(tr("Disconnected")); - m_connectButton->setEnabled(true); - m_disconnectButton->setEnabled(false); - break; - case QAbstractSocket::HostLookupState: - m_connectionState->setText(tr("Resolving")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(true); - break; - case QAbstractSocket::ConnectingState: - m_connectionState->setText(tr("Connecting")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(true); - break; - case QAbstractSocket::ConnectedState: - m_connectionState->setText(tr("Connected")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(true); - - QTimer::singleShot(0, m_enginePane, SLOT(refreshEngines())); - break; - case QAbstractSocket::ClosingState: - m_connectionState->setText(tr("Closing")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(false); - break; - } -} - -void QmlDebugger::connectionError(QAbstractSocket::SocketError socketError) -{ - qWarning() << "qmldebugger cannot connect:" << socketError - << client.errorString(); -} - -void QmlDebugger::connectToHost() -{ - client.connectToHost(m_host->text(), m_port->value()); -} - -void QmlDebugger::disconnectFromHost() -{ - client.disconnectFromHost(); -} diff --git a/tools/qmldebugger/standalone/qmldebugger.pri b/tools/qmldebugger/standalone/qmldebugger.pri deleted file mode 100644 index ede7d31..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.pri +++ /dev/null @@ -1,18 +0,0 @@ -QT += network declarative -contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl - -INCLUDEPATH += ../../../src/declarative/debugger - -# Input -HEADERS += $$PWD/canvasframerate.h \ - $$PWD/watchtable.h \ - $$PWD/objecttree.h \ - $$PWD/objectpropertiesview.h \ - $$PWD/expressionquerywidget.h - -SOURCES += $$PWD/canvasframerate.cpp \ - $$PWD/watchtable.cpp \ - $$PWD/objecttree.cpp \ - $$PWD/objectpropertiesview.cpp \ - $$PWD/expressionquerywidget.cpp - diff --git a/tools/qmldebugger/standalone/qmldebugger.qrc b/tools/qmldebugger/standalone/qmldebugger.qrc deleted file mode 100644 index cb53ad5..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>engines.qml</file> - <file>engine.png</file> - <file>refresh.png</file> - </qresource> -</RCC> diff --git a/tools/qmldebugger/standalone/refresh.png b/tools/qmldebugger/standalone/refresh.png Binary files differdeleted file mode 100644 index 8befc80..0000000 --- a/tools/qmldebugger/standalone/refresh.png +++ /dev/null diff --git a/tools/qmldebugger/standalone/standalone.pro b/tools/qmldebugger/standalone/standalone.pro deleted file mode 100644 index 72d051f..0000000 --- a/tools/qmldebugger/standalone/standalone.pro +++ /dev/null @@ -1,19 +0,0 @@ -DESTDIR = ../../../bin -TARGET = qmldebugger - -include(qmldebugger.pri) - -HEADERS += $$PWD/qmldebugger.h \ - $$PWD/engine.h - -SOURCES += $$PWD/qmldebugger.cpp \ - $$PWD/engine.cpp \ - $$PWD/main.cpp - -RESOURCES += $$PWD/qmldebugger.qrc -OTHER_FILES += $$PWD/engines.qml - -target.path=$$[QT_INSTALL_BINS] -INSTALLS += target - -CONFIG += console diff --git a/tools/qmldebugger/standalone/watchtable.cpp b/tools/qmldebugger/standalone/watchtable.cpp deleted file mode 100644 index 9d79a63..0000000 --- a/tools/qmldebugger/standalone/watchtable.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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 "watchtable.h" - -#include <QtCore/qdebug.h> -#include <QtGui/qevent.h> -#include <QtGui/qaction.h> -#include <QtGui/qmenu.h> - -#include <private/qmldebug_p.h> -#include <QtDeclarative/qmlmetatype.h> - -QT_BEGIN_NAMESPACE - - -WatchTableModel::WatchTableModel(QmlEngineDebug *client, QObject *parent) - : QAbstractTableModel(parent), - m_client(client) -{ -} - -WatchTableModel::~WatchTableModel() -{ - for (int i=0; i<m_columns.count(); i++) - delete m_columns[i].watch; -} - -void WatchTableModel::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void WatchTableModel::addWatch(QmlDebugWatch *watch, const QString &title) -{ - QString property; - if (qobject_cast<QmlDebugPropertyWatch *>(watch)) - property = qobject_cast<QmlDebugPropertyWatch *>(watch)->name(); - - connect(watch, SIGNAL(valueChanged(QByteArray,QVariant)), - SLOT(watchedValueChanged(QByteArray,QVariant))); - - connect(watch, SIGNAL(stateChanged(QmlDebugWatch::State)), SLOT(watchStateChanged())); - - int col = columnCount(QModelIndex()); - beginInsertColumns(QModelIndex(), col, col); - - WatchedEntity e; - e.title = title; - e.hasFirstValue = false; - e.property = property; - e.watch = watch; - m_columns.append(e); - - endInsertColumns(); -} - -void WatchTableModel::removeWatch(QmlDebugWatch *watch) -{ - int column = columnForWatch(watch); - if (column == -1) - return; - - WatchedEntity entity = m_columns.takeAt(column); - - for (QList<Value>::Iterator iter = m_values.begin(); iter != m_values.end();) { - if (iter->column == column) { - iter = m_values.erase(iter); - } else { - if(iter->column > column) - --iter->column; - ++iter; - } - } - - reset(); -} - -void WatchTableModel::updateWatch(QmlDebugWatch *watch, const QVariant &value) -{ - int column = columnForWatch(watch); - if (column == -1) - return; - - addValue(column, value); - - if (!m_columns[column].hasFirstValue) { - m_columns[column].hasFirstValue = true; - m_values[m_values.count() - 1].first = true; - } -} - -QmlDebugWatch *WatchTableModel::findWatch(int column) const -{ - if (column < m_columns.count()) - return m_columns.at(column).watch; - return 0; -} - -QmlDebugWatch *WatchTableModel::findWatch(int objectDebugId, const QString &property) const -{ - for (int i=0; i<m_columns.count(); i++) { - if (m_columns[i].watch->objectDebugId() == objectDebugId - && m_columns[i].property == property) { - return m_columns[i].watch; - } - } - return 0; -} - -int WatchTableModel::rowCount(const QModelIndex &) const -{ - return m_values.count(); -} - -int WatchTableModel::columnCount(const QModelIndex &) const -{ - return m_columns.count(); -} - -QVariant WatchTableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal) { - if (section < m_columns.count() && role == Qt::DisplayRole) - return m_columns.at(section).title; - } else { - if (role == Qt::DisplayRole) - return section + 1; - } - return QVariant(); -} - -QVariant WatchTableModel::data(const QModelIndex &idx, int role) const -{ - if (m_values.at(idx.row()).column == idx.column()) { - if (role == Qt::DisplayRole) { - const QVariant &value = m_values.at(idx.row()).variant; - QString str = value.toString(); - - if (str.isEmpty() && QmlMetaType::isQObject(value.userType())) { - QObject *o = QmlMetaType::toQObject(value); - if(o) { - QString objectName = o->objectName(); - if(objectName.isEmpty()) - objectName = QLatin1String("<unnamed>"); - str = QLatin1String(o->metaObject()->className()) + - QLatin1String(": ") + objectName; - } - } - - if(str.isEmpty()) { - QDebug d(&str); - d << value; - } - return QVariant(str); - } else if(role == Qt::BackgroundRole) { - if(m_values.at(idx.row()).first) - return QColor(Qt::green); - else - return QVariant(); - } else { - return QVariant(); - } - } else { - return QVariant(); - } -} - -void WatchTableModel::watchStateChanged() -{ - QmlDebugWatch *watch = qobject_cast<QmlDebugWatch*>(sender()); - - if (watch && watch->state() == QmlDebugWatch::Inactive) { - removeWatch(watch); - watch->deleteLater(); - } -} - -int WatchTableModel::columnForWatch(QmlDebugWatch *watch) const -{ - for (int i=0; i<m_columns.count(); i++) { - if (m_columns.at(i).watch == watch) - return i; - } - return -1; -} - -void WatchTableModel::addValue(int column, const QVariant &value) -{ - int row = columnCount(QModelIndex()); - beginInsertRows(QModelIndex(), row, row); - - Value v; - v.column = column; - v.variant = value; - v.first = false; - m_values.append(v); - - endInsertRows(); -} - -void WatchTableModel::togglePropertyWatch(const QmlDebugObjectReference &object, const QmlDebugPropertyReference &property) -{ - if (!m_client || !property.hasNotifySignal()) - return; - - QmlDebugWatch *watch = findWatch(object.debugId(), property.name()); - if (watch) { - // watch will be deleted in watchStateChanged() - m_client->removeWatch(watch); - return; - } - - watch = m_client->addWatch(property, this); - if (watch->state() == QmlDebugWatch::Dead) { - delete watch; - watch = 0; - } else { - QString desc = property.name() - + QLatin1String(" on\n") - + object.className() - + QLatin1String(":\n") - + (object.name().isEmpty() ? QLatin1String("<unnamed object>") : object.name()); - addWatch(watch, desc); - emit watchCreated(watch); - } -} - -void WatchTableModel::watchedValueChanged(const QByteArray &propertyName, const QVariant &value) -{ - Q_UNUSED(propertyName); - QmlDebugWatch *watch = qobject_cast<QmlDebugWatch*>(sender()); - if (watch) - updateWatch(watch, value); -} - -void WatchTableModel::expressionWatchRequested(const QmlDebugObjectReference &obj, const QString &expr) -{ - if (!m_client) - return; - - QmlDebugWatch *watch = m_client->addWatch(obj, expr, this); - - if (watch->state() == QmlDebugWatch::Dead) { - delete watch; - watch = 0; - } else { - addWatch(watch, expr); - emit watchCreated(watch); - } -} - -void WatchTableModel::removeWatchAt(int column) -{ - if (!m_client) - return; - - QmlDebugWatch *watch = findWatch(column); - if (watch) { - m_client->removeWatch(watch); - delete watch; - watch = 0; - } -} - -void WatchTableModel::removeAllWatches() -{ - for (int i=0; i<m_columns.count(); i++) { - if (m_client) - m_client->removeWatch(m_columns[i].watch); - else - delete m_columns[i].watch; - } - m_columns.clear(); - m_values.clear(); - reset(); -} - -//---------------------------------------------- - -WatchTableHeaderView::WatchTableHeaderView(WatchTableModel *model, QWidget *parent) - : QHeaderView(Qt::Horizontal, parent), - m_model(model) -{ - setClickable(true); -} - -void WatchTableHeaderView::mousePressEvent(QMouseEvent *me) -{ - QHeaderView::mousePressEvent(me); - - if (me->button() == Qt::RightButton && me->type() == QEvent::MouseButtonPress) { - int col = logicalIndexAt(me->pos()); - if (col >= 0) { - QAction action(tr("Stop watching"), 0); - QList<QAction *> actions; - actions << &action; - if (QMenu::exec(actions, me->globalPos())) - m_model->removeWatchAt(col); - } - } -} - - -//---------------------------------------------- - -WatchTableView::WatchTableView(WatchTableModel *model, QWidget *parent) - : QTableView(parent), - m_model(model) -{ - setAlternatingRowColors(true); - connect(model, SIGNAL(watchCreated(QmlDebugWatch*)), SLOT(watchCreated(QmlDebugWatch*))); - connect(this, SIGNAL(activated(QModelIndex)), SLOT(indexActivated(QModelIndex))); -} - -void WatchTableView::indexActivated(const QModelIndex &index) -{ - QmlDebugWatch *watch = m_model->findWatch(index.column()); - if (watch) - emit objectActivated(watch->objectDebugId()); -} - -void WatchTableView::watchCreated(QmlDebugWatch *watch) -{ - int column = m_model->columnForWatch(watch); - resizeColumnToContents(column); -} - -QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/watchtable.h b/tools/qmldebugger/standalone/watchtable.h deleted file mode 100644 index 3dbba63..0000000 --- a/tools/qmldebugger/standalone/watchtable.h +++ /dev/null @@ -1,154 +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 Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef WATCHTABLEMODEL_H -#define WATCHTABLEMODEL_H - -#include <QtCore/qpointer.h> -#include <QtCore/qlist.h> - -#include <QWidget> -#include <QHeaderView> -#include <QAbstractTableModel> -#include <QTableView> - -QT_BEGIN_NAMESPACE - -class QmlDebugWatch; -class QmlEngineDebug; -class QmlDebugConnection; -class QmlDebugPropertyReference; -class QmlDebugObjectReference; - -class WatchTableModel : public QAbstractTableModel -{ - Q_OBJECT -public: - WatchTableModel(QmlEngineDebug *client = 0, QObject *parent = 0); - ~WatchTableModel(); - - void setEngineDebug(QmlEngineDebug *client); - - QmlDebugWatch *findWatch(int column) const; - int columnForWatch(QmlDebugWatch *watch) const; - - void removeWatchAt(int column); - void removeAllWatches(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - -signals: - void watchCreated(QmlDebugWatch *watch); - -public slots: - void togglePropertyWatch(const QmlDebugObjectReference &obj, const QmlDebugPropertyReference &prop); - void expressionWatchRequested(const QmlDebugObjectReference &, const QString &); - -private slots: - void watchStateChanged(); - void watchedValueChanged(const QByteArray &propertyName, const QVariant &value); - -private: - void addWatch(QmlDebugWatch *watch, const QString &title); - void removeWatch(QmlDebugWatch *watch); - void updateWatch(QmlDebugWatch *watch, const QVariant &value); - - QmlDebugWatch *findWatch(int objectDebugId, const QString &property) const; - - void addValue(int column, const QVariant &value); - - struct WatchedEntity - { - QString title; - bool hasFirstValue; - QString property; - QPointer<QmlDebugWatch> watch; - }; - - struct Value { - int column; - QVariant variant; - bool first; - }; - - QmlEngineDebug *m_client; - QList<WatchedEntity> m_columns; - QList<Value> m_values; -}; - - -class WatchTableHeaderView : public QHeaderView -{ - Q_OBJECT -public: - WatchTableHeaderView(WatchTableModel *model, QWidget *parent = 0); - -protected: - void mousePressEvent(QMouseEvent *me); - -private: - WatchTableModel *m_model; -}; - - -class WatchTableView : public QTableView -{ - Q_OBJECT -public: - WatchTableView(WatchTableModel *model, QWidget *parent = 0); - -signals: - void objectActivated(int objectDebugId); - -private slots: - void indexActivated(const QModelIndex &index); - void watchCreated(QmlDebugWatch *watch); - -private: - WatchTableModel *m_model; -}; - - -QT_END_NAMESPACE - -#endif // WATCHTABLEMODEL_H diff --git a/tools/qmlviewer/deviceorientation.cpp b/tools/qmlviewer/deviceorientation.cpp index 75ea48e..e7c70d5 100644 --- a/tools/qmlviewer/deviceorientation.cpp +++ b/tools/qmlviewer/deviceorientation.cpp @@ -41,6 +41,8 @@ #include "deviceorientation.h" +QT_USE_NAMESPACE + class DefaultDeviceOrientation : public DeviceOrientation { Q_OBJECT diff --git a/tools/qmlviewer/deviceorientation.h b/tools/qmlviewer/deviceorientation.h index a2ed6ec..c8125cd 100644 --- a/tools/qmlviewer/deviceorientation.h +++ b/tools/qmlviewer/deviceorientation.h @@ -44,6 +44,8 @@ #include <QObject> +QT_BEGIN_NAMESPACE + class DeviceOrientationPrivate; class DeviceOrientation : public QObject { @@ -66,4 +68,6 @@ private: friend class DeviceOrientationPrivate; }; +QT_END_NAMESPACE + #endif diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index 18213ef..57c445f 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -47,6 +47,8 @@ #include <QTranslator> #include <QDebug> +QT_USE_NAMESPACE + #if defined (Q_OS_SYMBIAN) #include <unistd.h> #include <sys/types.h> @@ -93,6 +95,7 @@ void usage() qWarning(" -record arg .............................. add a recording process argument"); qWarning(" -autorecord [from-]<tomilliseconds> ...... set recording to start and stop"); qWarning(" -devicekeys .............................. use numeric keys (see F1)"); + qWarning(" -dragthreshold <size> .................... set mouse drag threshold size"); qWarning(" -netcache <size> ......................... set disk cache to size bytes"); qWarning(" -translation <translationfile> ........... set the language to run in"); qWarning(" -L <directory> ........................... prepend to the library search path"); @@ -215,6 +218,9 @@ int main(int argc, char ** argv) autorecord_to = range.mid(dash+1).toInt(); } else if (arg == "-devicekeys") { devkeys = true; + } else if (arg == "-dragthreshold") { + if (lastArg) usage(); + app.setStartDragDistance(QString(argv[++i]).toInt()); } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR); return 0; diff --git a/tools/qmlviewer/proxysettings.cpp b/tools/qmlviewer/proxysettings.cpp index b6caf6c..3255e42 100644 --- a/tools/qmlviewer/proxysettings.cpp +++ b/tools/qmlviewer/proxysettings.cpp @@ -45,6 +45,8 @@ #include "proxysettings.h" +QT_BEGIN_NAMESPACE + ProxySettings::ProxySettings (QWidget * parent) : QDialog (parent), Ui::ProxySettings() { @@ -104,3 +106,5 @@ bool ProxySettings::httpProxyInUse() QSettings settings; return settings.value ("http_proxy/use", 0).toBool (); } + +QT_END_NAMESPACE diff --git a/tools/qmlviewer/proxysettings.h b/tools/qmlviewer/proxysettings.h index 41bd7dc..325929a 100644 --- a/tools/qmlviewer/proxysettings.h +++ b/tools/qmlviewer/proxysettings.h @@ -46,6 +46,7 @@ #include <QNetworkProxy> #include "ui_proxysettings.h" +QT_BEGIN_NAMESPACE /** */ class ProxySettings : public QDialog, public Ui::ProxySettings @@ -65,4 +66,6 @@ public slots: virtual void accept (); }; +QT_END_NAMESPACE + #endif // PROXYSETTINGS_H diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp index 1d5175d..c3c0124 100644 --- a/tools/qmlviewer/qfxtester.cpp +++ b/tools/qmlviewer/qfxtester.cpp @@ -147,7 +147,7 @@ void QmlGraphicsTester::imagefailure() void QmlGraphicsTester::complete() { if ((options & QmlViewer::TestErrorProperty) && !hasFailed) { - QString e = m_view->root()->property("error").toString(); + QString e = m_view->rootObject()->property("error").toString(); if (!e.isEmpty()) { qWarning() << "Test failed:" << e; hasFailed = true; diff --git a/tools/qmlviewer/qfxtester.h b/tools/qmlviewer/qfxtester.h index 0e7108e..4b8ff9f 100644 --- a/tools/qmlviewer/qfxtester.h +++ b/tools/qmlviewer/qfxtester.h @@ -65,8 +65,13 @@ public: private: QList<QObject *> m_events; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTest) +QT_BEGIN_NAMESPACE + class QmlGraphicsVisualTestFrame : public QObject { Q_OBJECT @@ -90,8 +95,13 @@ private: QString m_hash; QUrl m_image; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTestFrame) +QT_BEGIN_NAMESPACE + class QmlGraphicsVisualTestMouse : public QObject { Q_OBJECT @@ -134,8 +144,13 @@ private: int m_modifiers; bool m_viewport; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTestMouse) +QT_BEGIN_NAMESPACE + class QmlGraphicsVisualTestKey : public QObject { Q_OBJECT @@ -178,8 +193,13 @@ private: int m_count; bool m_viewport; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTestKey) +QT_BEGIN_NAMESPACE + class QmlGraphicsTester : public QAbstractAnimation { public: diff --git a/tools/qmlviewer/qmlfolderlistmodel.cpp b/tools/qmlviewer/qmlfolderlistmodel.cpp index 52caf13..698df54 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.cpp +++ b/tools/qmlviewer/qmlfolderlistmodel.cpp @@ -44,6 +44,8 @@ #include <QDebug> #include <qmlcontext.h> +QT_BEGIN_NAMESPACE + class QmlFolderListModelPrivate { public: diff --git a/tools/qmlviewer/qmlfolderlistmodel.h b/tools/qmlviewer/qmlfolderlistmodel.h index 2063896..c180e97 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.h +++ b/tools/qmlviewer/qmlfolderlistmodel.h @@ -45,6 +45,8 @@ #include <qml.h> #include "../../src/declarative/3rdparty/qlistmodelinterface_p.h" +QT_BEGIN_NAMESPACE + class QmlContext; class QModelIndex; @@ -114,6 +116,8 @@ private: QmlFolderListModelPrivate *d; }; +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlFolderListModel) #endif // QMLFOLDERLISTMODEL_H diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index f4f04be..626e4c4 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -56,8 +56,9 @@ #include <QAbstractAnimation> #include "deviceskin.h" -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 3)) #include <private/qzipreader_p.h> +#define QMLVIEWER_ZIP_SUPPORT #endif #include <QSettings> @@ -83,6 +84,7 @@ #include <QAction> #include <QFileDialog> #include <QTimer> +#include <QGraphicsObject> #include <QNetworkProxyFactory> #include <QKeyEvent> #include <QMutex> @@ -111,7 +113,6 @@ QT_BEGIN_NAMESPACE - class Screen : public QObject { Q_OBJECT @@ -134,9 +135,14 @@ signals: void orientationChanged(); }; +QT_END_NAMESPACE + QML_DECLARE_TYPE(Screen) + QML_DEFINE_TYPE(QmlViewer, 1, 0, Screen, Screen) +QT_BEGIN_NAMESPACE + class SizedMenuBar : public QMenuBar { Q_OBJECT @@ -472,13 +478,12 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) canvas = new QmlView(this); canvas->setAttribute(Qt::WA_OpaquePaintEvent); canvas->setAttribute(Qt::WA_NoSystemBackground); - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); canvas->setFocus(); QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); - QObject::connect(canvas, SIGNAL(initialSize(QSize)), this, SLOT(adjustSizeSlot())); - QObject::connect(canvas, SIGNAL(errors(QList<QmlError>)), this, SLOT(executeErrors())); - QObject::connect(canvas, SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); + QObject::connect(canvas, SIGNAL(statusChanged(QmlView::Status)), this, SLOT(statusChanged())); + QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); if (!(flags & Qt::FramelessWindowHint)) { createMenu(menuBar(),0); @@ -515,11 +520,6 @@ QmlViewer::~QmlViewer() delete namFactory; } -void QmlViewer::adjustSizeSlot() -{ - resize(sizeHint()); -} - QMenuBar *QmlViewer::menuBar() const { #if !defined(Q_OS_SYMBIAN) @@ -730,7 +730,7 @@ void QmlViewer::setScaleSkin() if (scaleSkin) return; scaleSkin = true; - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); if (skin) { canvas->setFixedSize(canvas->sizeHint()); skin->setScreenSize(canvas->sizeHint()); @@ -743,7 +743,7 @@ void QmlViewer::setScaleView() return; scaleSkin = false; if (skin) { - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); canvas->setMinimumSize(QSize(0,0)); canvas->setMaximumSize(QSize(16777215,16777215)); canvas->resize(skin->standardScreenSize()); @@ -870,7 +870,7 @@ void QmlViewer::reload() void QmlViewer::open(const QString& doc) { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT if (doc.endsWith(".wgt",Qt::CaseInsensitive) || doc.endsWith(".wgz",Qt::CaseInsensitive) || doc.endsWith(".zip",Qt::CaseInsensitive)) @@ -882,20 +882,21 @@ void QmlViewer::open(const QString& doc) void QmlViewer::openWgt(const QString& doc) { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT // XXX This functionality could be migrated to QmlView once refined QUrl url(doc); if (url.isRelative()) url = QUrl::fromLocalFile(doc); - canvas->reset(); + delete canvas->rootObject(); + canvas->engine()->clearComponentCache(); QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); wgtreply = nam->get(QNetworkRequest(url)); connect(wgtreply,SIGNAL(finished()),this,SLOT(unpackWgt())); #endif } -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT static void removeRecursive(const QString& dirname) { QDir dir(dirname); @@ -911,7 +912,7 @@ static void removeRecursive(const QString& dirname) void QmlViewer::unpackWgt() { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT QByteArray all = wgtreply->readAll(); QBuffer buf(&all); buf.open(QIODevice::ReadOnly); @@ -970,7 +971,7 @@ void QmlViewer::unpackWgt() void QmlViewer::openFile() { - QString cur = canvas->url().toLocalFile(); + QString cur = canvas->source().toLocalFile(); if (useQmlFileBrowser) { openQml("qrc:/content/Browser.qml"); } else { @@ -982,9 +983,13 @@ void QmlViewer::openFile() } } -void QmlViewer::executeErrors() +void QmlViewer::statusChanged() { - if (tester) tester->executefailure(); + if (canvas->status() == QmlView::Error && tester) + tester->executefailure(); + + if (canvas->status() == QmlView::Ready) + resize(sizeHint()); } void QmlViewer::launch(const QString& file_or_url) @@ -1007,7 +1012,8 @@ void QmlViewer::openQml(const QString& file_or_url) if (!m_script.isEmpty()) tester = new QmlGraphicsTester(m_script, m_scriptOptions, canvas); - canvas->reset(); + delete canvas->rootObject(); + canvas->engine()->clearComponentCache(); QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("qmlViewer", this); #ifdef Q_OS_SYMBIAN @@ -1057,7 +1063,7 @@ void QmlViewer::openQml(const QString& file_or_url) } } - canvas->setUrl(url); + canvas->setSource(url); QTime t; t.start(); @@ -1124,7 +1130,7 @@ void QmlViewer::setSkin(const QString& skinDirOrName) skin->deleteLater(); } - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); DeviceSkinParameters parameters; if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) { diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 958210e..c7f87ed 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -116,7 +116,7 @@ public slots: void showProxySettings (); void proxySettingsChanged (); void setScaleView(); - void executeErrors(); + void statusChanged(); void setSlowMode(bool); void launch(const QString &); @@ -132,7 +132,6 @@ private slots: void chooseRecordingOptions(); void pickRecordingFile(); void setScaleSkin(); - void adjustSizeSlot(); void setPortrait(); void setLandscape(); void toggleOrientation(); diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index 35e4ba8..aba3cf5 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -33,6 +33,7 @@ FORMS = recopts.ui \ proxysettings.ui INCLUDEPATH += ../../include/QtDeclarative INCLUDEPATH += ../../src/declarative/util +INCLUDEPATH += ../../src/declarative/graphicsitems include(../shared/deviceskin/deviceskin.pri) target.path = $$[QT_INSTALL_BINS] INSTALLS += target @@ -41,8 +42,11 @@ wince* { QT += scripttools \ xml \ xmlpatterns \ - webkit \ phonon + + contains(QT_CONFIG, webkit) { + QT += webkit + } } symbian { # TARGET.UID3 = diff --git a/tools/qtestlib/chart/database.cpp b/tools/qtestlib/chart/database.cpp index dfc0fc5..1f1f7da 100644 --- a/tools/qtestlib/chart/database.cpp +++ b/tools/qtestlib/chart/database.cpp @@ -42,6 +42,7 @@ #include <QtGui> #include <QtXml> +QT_BEGIN_NAMESPACE // Database schema definition and open/create functions QString resultsTable = QString("(TestName varchar, TestCaseName varchar, Series varchar, Idx varchar, ") + @@ -319,3 +320,5 @@ void DataBaseWriter::addResult(const QString &series, const QString &index, cons query.bindValue(":ChartType", "BarChart"); execQuery(query); } + +QT_END_NAMESPACE diff --git a/tools/qtestlib/chart/database.h b/tools/qtestlib/chart/database.h index d9861ad..9a67490 100644 --- a/tools/qtestlib/chart/database.h +++ b/tools/qtestlib/chart/database.h @@ -43,6 +43,9 @@ #include <QtCore> #include <QtSql> +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE extern QString resultsTable; QSqlDatabase openDataBase(const QString &databaseFile = "database"); @@ -57,6 +60,7 @@ void execQuery(const QString &spec, bool warnOnFail = true); void printDataBase(); void displayTable(const QString &table); + class TempTable { public: @@ -95,5 +99,7 @@ public: QSqlDatabase db; }; +QT_END_NAMESPACE #endif + diff --git a/tools/qtestlib/chart/reportgenerator.cpp b/tools/qtestlib/chart/reportgenerator.cpp index 1ce362c..c3b42a0 100644 --- a/tools/qtestlib/chart/reportgenerator.cpp +++ b/tools/qtestlib/chart/reportgenerator.cpp @@ -41,6 +41,7 @@ #include "reportgenerator.h" // Report generator file utility functions +QT_BEGIN_NAMESPACE QList<QByteArray> readLines(const QString &fileName) { @@ -559,3 +560,4 @@ QByteArray ReportGenerator::printColors(const QString &tableName, const QString return colors; } +QT_END_NAMESPACE diff --git a/tools/qtestlib/chart/reportgenerator.h b/tools/qtestlib/chart/reportgenerator.h index d44aea9..1f075bd 100644 --- a/tools/qtestlib/chart/reportgenerator.h +++ b/tools/qtestlib/chart/reportgenerator.h @@ -42,6 +42,9 @@ #define REPORTGENERATOR_H #include "database.h" +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE class ReportGenerator { @@ -59,5 +62,7 @@ private: void printTestCaseResults(const QString &testCaseName); +QT_END_NAMESPACE + #endif diff --git a/tools/tools.pro b/tools/tools.pro index 4cff507..d5569b6 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -26,7 +26,7 @@ mac { embedded:SUBDIRS += kmap2qmap -contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer qmldebugger +contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer contains(QT_CONFIG, dbus):SUBDIRS += qdbus !wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns xmlpatternsvalidator embedded: SUBDIRS += makeqpf |