summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-13 23:05:26 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-13 23:05:26 (GMT)
commita5e9e86a6daddde6fb906cbf09bf562e50b17698 (patch)
tree18e1fbc22574ae2168500349a04f758d91a37c8e
parentc46c06d363b7c90fecd84e7ef333ffa449f1d71c (diff)
parenta15c2d6ba9c2da1c709fbb23d0c07ad51450d93e (diff)
downloadQt-a5e9e86a6daddde6fb906cbf09bf562e50b17698.zip
Qt-a5e9e86a6daddde6fb906cbf09bf562e50b17698.tar.gz
Qt-a5e9e86a6daddde6fb906cbf09bf562e50b17698.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (26 commits) Remove warning on ASCII cast Fix compilation on Solaris, AIX and HP-UX. Speed up borderimage test. Exclude webview examples when compiled without webview Fix test Use SRCDIR to make examples test work with shadow builds. Example fixes Improve efficiency of model dataChanged. Optimize some autotests Fix test (run with -qws on QWS). Stabilize behaviors test. Struct -> class because class is better. Move effect property where it should be. Tweak tests to run in parallel Network-related test fails on the rare occasion Fix code style in examples Make demo code more consistent with example code in terms of variable Fix score from previous change Doc improvements Fix example code style ...
-rw-r--r--demos/declarative/samegame/SamegameCore/BoomBlock.qml21
-rw-r--r--demos/declarative/samegame/SamegameCore/Button.qml25
-rw-r--r--demos/declarative/samegame/SamegameCore/Dialog.qml25
-rwxr-xr-xdemos/declarative/samegame/SamegameCore/samegame.js167
-rw-r--r--demos/declarative/samegame/samegame.qml78
-rw-r--r--doc/src/declarative/advtutorial.qdoc3
-rw-r--r--doc/src/declarative/qtbinding.qdoc2
-rw-r--r--examples/declarative/behaviors/SideRect.qml12
-rw-r--r--examples/declarative/behaviors/behavior-example.qml28
-rw-r--r--examples/declarative/border-image/animated.qml1
-rw-r--r--examples/declarative/border-image/borders.qml1
-rw-r--r--examples/declarative/clocks/content/Clock.qml9
-rw-r--r--examples/declarative/connections/connections-example.qml25
-rw-r--r--examples/declarative/dial/dial-example.qml21
-rw-r--r--examples/declarative/dynamic/dynamic.qml2
-rw-r--r--examples/declarative/effects/effects.qml13
-rw-r--r--examples/declarative/fillmode/fillmode.qml7
-rw-r--r--examples/declarative/flipable/flipable-example.qml4
-rw-r--r--examples/declarative/focus/Core/ContextMenu.qml5
-rw-r--r--examples/declarative/focus/Core/GridMenu.qml19
-rw-r--r--examples/declarative/focus/Core/ListViewDelegate.qml12
-rw-r--r--examples/declarative/focus/Core/ListViews.qml33
-rw-r--r--examples/declarative/focus/focus.qml35
-rw-r--r--examples/declarative/fonts/banner.qml5
-rw-r--r--examples/declarative/fonts/fonts.qml52
-rw-r--r--examples/declarative/fonts/hello.qml27
-rw-r--r--examples/declarative/gridview/gridview-example.qml19
-rw-r--r--examples/declarative/imageprovider/imageprovider-example.qml5
-rw-r--r--examples/declarative/images/images.qml11
-rw-r--r--examples/declarative/layouts/layouts.qml13
-rw-r--r--examples/declarative/layouts/positioners.qml162
-rw-r--r--examples/declarative/listmodel-threaded/timedisplay.qml4
-rw-r--r--examples/declarative/listview/dynamic.qml139
-rw-r--r--examples/declarative/listview/highlight.qml32
-rw-r--r--examples/declarative/listview/itemlist.qml27
-rw-r--r--examples/declarative/listview/listview-example.qml36
-rw-r--r--examples/declarative/listview/recipes.qml76
-rw-r--r--examples/declarative/listview/sections.qml30
-rw-r--r--examples/declarative/mousearea/mouse.qml37
-rw-r--r--examples/declarative/progressbar/content/ProgressBar.qml30
-rw-r--r--examples/declarative/progressbar/progressbars.qml15
-rw-r--r--examples/declarative/proxywidgets/proxywidgets.qml57
-rw-r--r--examples/declarative/scrollbar/ScrollBar.qml12
-rw-r--r--examples/declarative/scrollbar/display.qml48
-rw-r--r--examples/declarative/searchbox/SearchBox.qml23
-rw-r--r--examples/declarative/searchbox/main.qml6
-rw-r--r--examples/declarative/slideswitch/content/Switch.qml7
-rw-r--r--examples/declarative/sql/hello.qml3
-rw-r--r--examples/declarative/states/states.qml59
-rw-r--r--examples/declarative/states/transitions.qml78
-rw-r--r--examples/declarative/tabwidget/TabWidget.qml21
-rw-r--r--examples/declarative/tabwidget/tabs.qml27
-rw-r--r--examples/declarative/tic-tac-toe/content/Button.qml22
-rw-r--r--examples/declarative/tic-tac-toe/tic-tac-toe.qml29
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Block.qml7
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Button.qml20
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/samegame.qml23
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/Block.qml7
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/Button.qml20
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.qml23
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Block.qml22
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Button.qml20
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Dialog.qml13
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.qml34
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml65
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Button.qml20
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml13
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/content/samegame.js2
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/samegame.qml43
-rw-r--r--examples/declarative/tvtennis/tvtennis.qml5
-rw-r--r--examples/declarative/velocity/Day.qml31
-rw-r--r--examples/declarative/velocity/velocity.qml51
-rw-r--r--examples/declarative/webview/alerts.qml6
-rw-r--r--examples/declarative/webview/autosize.qml5
-rw-r--r--examples/declarative/webview/googleMaps.qml12
-rw-r--r--examples/declarative/webview/transparent.qml1
-rw-r--r--examples/declarative/workerscript/workerscript.qml12
-rw-r--r--examples/declarative/xmldata/daringfireball.qml11
-rw-r--r--examples/declarative/xmldata/yahoonews.qml20
-rw-r--r--examples/declarative/xmlhttprequest/test.qml40
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp15
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp4
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp5
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h1
-rw-r--r--tests/auto/declarative/examples/examples.pro3
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp130
-rw-r--r--tests/auto/declarative/graphicswidgets/graphicswidgets.pro2
-rw-r--r--tests/auto/declarative/parserstress/parserstress.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/qmldir1
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro3
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/binding.qml2
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml2
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro3
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp161
-rw-r--r--tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp12
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro3
-rw-r--r--tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro3
-rw-r--r--tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro3
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro3
-rw-r--r--tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro3
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro1
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro3
-rw-r--r--tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro3
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp561
-rw-r--r--tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro3
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestNamed.qml1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp39
-rw-r--r--tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro3
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro3
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro3
-rw-r--r--tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro2
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp601
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/qmldir1
-rw-r--r--tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro2
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro3
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro1
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro3
-rw-r--r--tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro3
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro3
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro3
-rw-r--r--tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro3
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro2
-rw-r--r--tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro3
-rw-r--r--tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro3
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro3
-rw-r--r--tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro2
-rw-r--r--tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro2
-rw-r--r--tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro3
-rw-r--r--tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro3
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml1
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp62
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml2
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro1
-rw-r--r--tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro2
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro3
-rw-r--r--tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro2
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro3
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro3
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro3
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp20
-rw-r--r--tests/auto/declarative/qmetaobjectbuilder/qmetaobjectbuilder.pro1
-rw-r--r--tests/auto/declarative/qmlvisual/qmlvisual.pro3
-rw-r--r--tests/auto/declarative/qpacketprotocol/qpacketprotocol.pro2
-rw-r--r--tests/auto/declarative/sql/sql.pro3
168 files changed, 2392 insertions, 1607 deletions
diff --git a/demos/declarative/samegame/SamegameCore/BoomBlock.qml b/demos/declarative/samegame/SamegameCore/BoomBlock.qml
index db43182..bad1bf4 100644
--- a/demos/declarative/samegame/SamegameCore/BoomBlock.qml
+++ b/demos/declarative/samegame/SamegameCore/BoomBlock.qml
@@ -26,12 +26,16 @@ Item { id:block
anchors.fill: parent
}
- Particles { id: particles
- width:1; height:1; anchors.centerIn: parent;
- emissionRate: 0;
- lifeSpan: 700; lifeSpanDeviation: 600;
+ Particles {
+ id: particles
+
+ width: 1; height: 1
+ anchors.centerIn: parent
+
+ emissionRate: 0
+ lifeSpan: 700; lifeSpanDeviation: 600
angle: 0; angleDeviation: 360;
- velocity: 100; velocityDeviation:30;
+ velocity: 100; velocityDeviation: 30
source: {
if(type == 0){
"pics/redStar.png";
@@ -44,10 +48,13 @@ Item { id:block
}
states: [
- State{ name: "AliveState"; when: spawned == true && dying == false
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
PropertyChanges { target: img; opacity: 1 }
},
- State{ name: "DeathState"; when: dying == true
+
+ State {
+ name: "DeathState"; when: dying == true
StateChangeScript { script: particles.burst(50); }
PropertyChanges { target: img; opacity: 0 }
StateChangeScript { script: block.destroy(1000); }
diff --git a/demos/declarative/samegame/SamegameCore/Button.qml b/demos/declarative/samegame/SamegameCore/Button.qml
index 9c7986b..0faabc9 100644
--- a/demos/declarative/samegame/SamegameCore/Button.qml
+++ b/demos/declarative/samegame/SamegameCore/Button.qml
@@ -3,23 +3,32 @@ import Qt 4.7
Rectangle {
id: container
- signal clicked
property string text: "Button"
- color: activePalette.button; smooth: true
- width: txtItem.width + 20; height: txtItem.height + 6
- border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 6
+ smooth: true
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ radius: 8
+ color: activePalette.button
gradient: Gradient {
GradientStop {
- id: topGrad; position: 0.0
- color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
Text {
- id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
}
}
diff --git a/demos/declarative/samegame/SamegameCore/Dialog.qml b/demos/declarative/samegame/SamegameCore/Dialog.qml
index 7f1189e..8784348 100644
--- a/demos/declarative/samegame/SamegameCore/Dialog.qml
+++ b/demos/declarative/samegame/SamegameCore/Dialog.qml
@@ -2,21 +2,32 @@ import Qt 4.7
Rectangle {
id: page
+
+ property Item text: dialogText
+
+ signal closed
+
function forceClose() {
page.closed();
page.opacity = 0;
}
+
function show(txt) {
- myText.text = txt;
+ dialogText.text = txt;
page.opacity = 1;
}
- signal closed();
- property Item text: myText
- color: "white"; border.width: 1; width: myText.width + 20; height: myText.height + 40;
+
+ width: dialogText.width + 20; height: dialogText.height + 20
+ color: "white"
+ border.width: 1
opacity: 0
- Behavior on opacity {
+
+ Behavior on opacity {
NumberAnimation { duration: 1000 }
}
- Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
- MouseArea { id: mr; anchors.fill: parent; onClicked: forceClose(); }
+
+ Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
+
+ MouseArea { anchors.fill: parent; onClicked: forceClose(); }
}
+
diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js
index a119a88..3888381 100755
--- a/demos/declarative/samegame/SamegameCore/samegame.js
+++ b/demos/declarative/samegame/SamegameCore/samegame.js
@@ -1,18 +1,18 @@
/* This script file handles the game logic */
-//Note that X/Y referred to here are in game coordinates
-var maxX = 10;//Nums are for gameCanvas.tileSize 40
-var maxY = 15;
-var maxIndex = maxX*maxY;
+
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn*maxRow;
var board = new Array(maxIndex);
-var tileSrc = "SamegameCore/BoomBlock.qml";
+var blockSrc = "SamegameCore/BoomBlock.qml";
var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php";
var scoresURL = "";
-var timer;
-var component = createComponent(tileSrc);
+var gameDuration;
+var component = createComponent(blockSrc);
//Index function used instead of a 2D array
-function index(xIdx,yIdx) {
- return xIdx + (yIdx * maxX);
+function index(column,row) {
+ return column + (row * maxColumn);
}
function timeStr(msecs) {
@@ -22,51 +22,48 @@ function timeStr(msecs) {
return ret;
}
-function initBoard()
+function startNewGame()
{
+ //Delete blocks from previous game
for(var i = 0; i<maxIndex; i++){
- //Delete old blocks
if(board[i] != null)
board[i].destroy();
}
//Calculate board size
- maxX = Math.floor(gameCanvas.width/gameCanvas.tileSize);
- maxY = Math.floor(gameCanvas.height/gameCanvas.tileSize);
- maxIndex = maxY*maxX;
+ maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize);
+ maxIndex = maxRow*maxColumn;
//Close dialogs
- scoreName.forceClose();
+ nameInputDialog.forceClose();
dialog.forceClose();
- var a = new Date();
//Initialize Board
board = new Array(maxIndex);
gameCanvas.score = 0;
- for(var xIdx=0; xIdx<maxX; xIdx++){
- for(var yIdx=0; yIdx<maxY; yIdx++){
- board[index(xIdx,yIdx)] = null;
- createBlock(xIdx,yIdx);
+ for(var column=0; column<maxColumn; column++){
+ for(var row=0; row<maxRow; row++){
+ board[index(column,row)] = null;
+ createBlock(column,row);
}
}
- timer = new Date();
-
- //print(timer.valueOf() - a.valueOf());
+ gameDuration = new Date();
}
-var fillFound;//Set after a floodFill call to the number of tiles found
+var fillFound;//Set after a floodFill call to the number of blocks found
var floodBoard;//Set to 1 if the floodFill reaches off that node
//NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
function handleClick(x,y)
{
- var xIdx = Math.floor(x/gameCanvas.tileSize);
- var yIdx = Math.floor(y/gameCanvas.tileSize);
- if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ var column = Math.floor(x/gameCanvas.blockSize);
+ var row = Math.floor(y/gameCanvas.blockSize);
+ if(column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return;
- if(board[index(xIdx, yIdx)] == null)
+ if(board[index(column, row)] == null)
return;
- //If it's a valid tile, remove it and all connected (does nothing if it's not connected)
- floodFill(xIdx,yIdx, -1);
+ //If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column,row, -1);
if(fillFound <= 0)
return;
gameCanvas.score += (fillFound - 1) * (fillFound - 1);
@@ -74,67 +71,67 @@ function handleClick(x,y)
victoryCheck();
}
-function floodFill(xIdx,yIdx,type)
+function floodFill(column,row,type)
{
- if(board[index(xIdx, yIdx)] == null)
+ if(board[index(column, row)] == null)
return;
var first = false;
if(type == -1){
first = true;
- type = board[index(xIdx,yIdx)].type;
+ type = board[index(column,row)].type;
//Flood fill initialization
fillFound = 0;
floodBoard = new Array(maxIndex);
}
- if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ if(column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return;
- if(floodBoard[index(xIdx, yIdx)] == 1 || (!first && type != board[index(xIdx,yIdx)].type))
+ if(floodBoard[index(column, row)] == 1 || (!first && type != board[index(column,row)].type))
return;
- floodBoard[index(xIdx, yIdx)] = 1;
- floodFill(xIdx+1,yIdx,type);
- floodFill(xIdx-1,yIdx,type);
- floodFill(xIdx,yIdx+1,type);
- floodFill(xIdx,yIdx-1,type);
+ floodBoard[index(column, row)] = 1;
+ floodFill(column+1,row,type);
+ floodFill(column-1,row,type);
+ floodFill(column,row+1,type);
+ floodFill(column,row-1,type);
if(first==true && fillFound == 0)
- return;//Can't remove single tiles
- board[index(xIdx,yIdx)].dying = true;
- board[index(xIdx,yIdx)] = null;
+ return;//Can't remove single blocks
+ board[index(column,row)].dying = true;
+ board[index(column,row)] = null;
fillFound += 1;
}
function shuffleDown()
{
//Fall down
- for(var xIdx=0; xIdx<maxX; xIdx++){
+ for(var column=0; column<maxColumn; column++){
var fallDist = 0;
- for(var yIdx=maxY-1; yIdx>=0; yIdx--){
- if(board[index(xIdx,yIdx)] == null){
+ for(var row=maxRow-1; row>=0; row--){
+ if(board[index(column,row)] == null){
fallDist += 1;
}else{
if(fallDist > 0){
- var obj = board[index(xIdx,yIdx)];
- obj.targetY += fallDist * gameCanvas.tileSize;
- board[index(xIdx,yIdx+fallDist)] = obj;
- board[index(xIdx,yIdx)] = null;
+ var obj = board[index(column,row)];
+ obj.targetY += fallDist * gameCanvas.blockSize;
+ board[index(column,row+fallDist)] = obj;
+ board[index(column,row)] = null;
}
}
}
}
//Fall to the left
fallDist = 0;
- for(xIdx=0; xIdx<maxX; xIdx++){
- if(board[index(xIdx, maxY - 1)] == null){
+ for(column=0; column<maxColumn; column++){
+ if(board[index(column, maxRow - 1)] == null){
fallDist += 1;
}else{
if(fallDist > 0){
- for(yIdx=0; yIdx<maxY; yIdx++){
- obj = board[index(xIdx,yIdx)];
+ for(row=0; row<maxRow; row++){
+ obj = board[index(column,row)];
if(obj == null)
continue;
- obj.targetX -= fallDist * gameCanvas.tileSize;
- board[index(xIdx-fallDist,yIdx)] = obj;
- board[index(xIdx,yIdx)] = null;
+ obj.targetX -= fallDist * gameCanvas.blockSize;
+ board[index(column-fallDist,row)] = obj;
+ board[index(column,row)] = null;
}
}
}
@@ -143,40 +140,38 @@ function shuffleDown()
function victoryCheck()
{
- //awards bonuses for no tiles left
+ //awards bonuses for no blocks left
var deservesBonus = true;
- for(var xIdx=maxX-1; xIdx>=0; xIdx--)
- if(board[index(xIdx, maxY - 1)] != null)
+ for(var column=maxColumn-1; column>=0; column--)
+ if(board[index(column, maxRow - 1)] != null)
deservesBonus = false;
if(deservesBonus)
gameCanvas.score += 500;
//Checks for game over
- if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){
- timer = new Date() - timer;
- //scoreName.show("You won! Please enter your name: ");
- 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);
+ if(deservesBonus || !(floodMoveCheck(0,maxRow-1, -1))){
+ gameDuration = new Date() - gameDuration;
+ nameInputDialog.show("You won! Please enter your name: ");
+ nameInputDialog.initialWidth = nameInputDialog.text.width + 20;
+ nameInputDialog.width = nameInputDialog.initialWidth;
+ nameInputDialog.text.opacity = 0;//Just a spacer
}
}
-//only floods up and right, to see if it can find adjacent same-typed tiles
-function floodMoveCheck(xIdx, yIdx, type)
+//only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type)
{
- if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ if(column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return false;
- if(board[index(xIdx, yIdx)] == null)
+ if(board[index(column, row)] == null)
return false;
- var myType = board[index(xIdx, yIdx)].type;
+ var myType = board[index(column, row)].type;
if(type == myType)
return true;
- return floodMoveCheck(xIdx + 1, yIdx, myType) ||
- floodMoveCheck(xIdx, yIdx - 1, board[index(xIdx,yIdx)].type);
+ return floodMoveCheck(column + 1, row, myType) ||
+ floodMoveCheck(column, row - 1, board[index(column,row)].type);
}
-function createBlock(xIdx,yIdx){
+function createBlock(column,row){
// Note that we don't wait for the component to become ready. This will
// only work if the block QML is a local file. Otherwise the component will
// not be ready immediately. There is a statusChanged signal on the
@@ -190,14 +185,14 @@ function createBlock(xIdx,yIdx){
}
dynamicObject.type = Math.floor(Math.random() * 3);
dynamicObject.parent = gameCanvas;
- dynamicObject.x = xIdx*gameCanvas.tileSize;
- dynamicObject.targetX = xIdx*gameCanvas.tileSize;
- dynamicObject.targetY = yIdx*gameCanvas.tileSize;
- dynamicObject.width = gameCanvas.tileSize;
- dynamicObject.height = gameCanvas.tileSize;
+ dynamicObject.x = column*gameCanvas.blockSize;
+ dynamicObject.targetX = column*gameCanvas.blockSize;
+ dynamicObject.targetY = row*gameCanvas.blockSize;
+ dynamicObject.width = gameCanvas.blockSize;
+ dynamicObject.height = gameCanvas.blockSize;
dynamicObject.spawned = true;
- board[index(xIdx,yIdx)] = dynamicObject;
- }else{//isError or isLoading
+ board[index(column,row)] = dynamicObject;
+ }else{
print("error loading block component");
print(component.errorsString());
return false;
@@ -211,14 +206,14 @@ function saveHighScore(name) {
//OfflineStorage
var db = openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores",100);
var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
- var data = [name, gameCanvas.score, maxX+"x"+maxY ,Math.floor(timer/1000)];
+ var data = [name, gameCanvas.score, maxColumn+"x"+maxRow ,Math.floor(gameDuration/1000)];
db.transaction(
function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
tx.executeSql(dataStr, data);
//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 rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'+maxColumn+"x"+maxRow+'" 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 '
@@ -233,7 +228,7 @@ function saveHighScore(name) {
function sendHighScore(name) {
var postman = new XMLHttpRequest()
var postData = "name="+name+"&score="+gameCanvas.score
- +"&gridSize="+maxX+"x"+maxY +"&time="+Math.floor(timer/1000);
+ +"&gridSize="+maxColumn+"x"+maxRow +"&time="+Math.floor(gameDuration/1000);
postman.open("POST", scoresURL, true);
postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
postman.onreadystatechange = function() {
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 94f5c24..92201f5 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -9,85 +9,95 @@ Rectangle {
SystemPalette { id: activePalette }
Item {
- width: parent.width; anchors.top: parent.top; anchors.bottom: toolBar.top
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
Image {
id: background
- anchors.fill: parent; source: "SamegameCore/pics/background.png"
+ anchors.fill: parent
+ source: "SamegameCore/pics/background.png"
fillMode: Image.PreserveAspectCrop
- smooth: true
}
Item {
id: gameCanvas
property int score: 0
- property int tileSize: 40
+ property int blockSize: 40
z: 20; anchors.centerIn: parent
- width: parent.width - (parent.width % tileSize);
- height: parent.height - (parent.height % tileSize);
+ width: parent.width - (parent.width % blockSize);
+ height: parent.height - (parent.height % blockSize);
MouseArea {
- id: gameMR
anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y);
}
}
}
Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
+
Dialog {
- id: scoreName; anchors.centerIn: parent; z: 22;
+ id: nameInputDialog
+
property int initialWidth: 0
- Behavior on width {NumberAnimation{} enabled: initialWidth!=0}
+
+ anchors.centerIn: parent
+ z: 22;
+
+ Behavior on width {
+ NumberAnimation {}
+ enabled: initialWidth != 0
+ }
+
Text {
- id: spacer
- anchors.left: scoreName.left
- anchors.leftMargin: 20
- anchors.verticalCenter: parent.verticalCenter
+ id: dialogText
+ anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter }
text: "You won! Please enter your name: "
}
+
TextInput {
- id: editor
+ id: nameInputText
+ anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
+ focus: true
+
onTextChanged: {
- var newWidth = editor.width + spacer.width + 40;
- if((newWidth > scoreName.width && newWidth < screen.width)
- || (scoreName.width > scoreName.initialWidth))
- scoreName.width = newWidth;
+ var newWidth = nameInputText.width + dialogText.width + 40;
+ if ( (newWidth > nameInputDialog.width && newWidth < screen.width)
+ || (nameInputDialog.width > nameInputDialog.initialWidth) )
+ nameInputDialog.width = newWidth;
}
onAccepted: {
- if(scoreName.opacity==1&&editor.text!="")
- Logic.saveHighScore(editor.text);
- scoreName.forceClose();
+ if (nameInputDialog.opacity == 1 && nameInputText.text != "")
+ Logic.saveHighScore(nameInputText.text);
+ nameInputDialog.forceClose();
}
- anchors.verticalCenter: parent.verticalCenter
- focus: true
- anchors.left: spacer.right
}
}
Rectangle {
id: toolBar
+ width: parent.width; height: 32
color: activePalette.window
- height: 32; width: parent.width
anchors.bottom: screen.bottom
Button {
- id: btnA; text: "New Game"; onClicked: Logic.initBoard();
- anchors.left: parent.left; anchors.leftMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ id: newGameButton
+ anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: Logic.startNewGame()
}
Button {
- id: btnB; text: "Quit"; onClicked: Qt.quit();
- anchors.left: btnA.right; anchors.leftMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ text: "Quit"
+ anchors { left: newGameButton.right; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ onClicked: Qt.quit();
}
Text {
id: score
- text: "Score: " + gameCanvas.score; font.bold: true
- anchors.right: parent.right; anchors.rightMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "Score: " + gameCanvas.score
+ font.bold: true
color: activePalette.windowText
}
}
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index 4807fd2..3a70eee 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -101,6 +101,9 @@ One item you may not recognize here
is the \l SystemPalette item. This provides access to the Qt system palette
and is used to give the button a more native look-and-feel.
+Notice the anchors for the \c Item, \c Button and \c Text elements are set using
+\l {Grouped Properties}{group notation} for readability.
+
\section2 Adding \c Button and \c Block components
The \c Button item in the code above is defined in a separate file named \c Button.qml.
diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc
index 181c504..fa0d13c 100644
--- a/doc/src/declarative/qtbinding.qdoc
+++ b/doc/src/declarative/qtbinding.qdoc
@@ -74,7 +74,7 @@ an example of loading a QML document, and creating an object from it.
\code
QDeclarativeEngine *engine = new QDeclarativeEngine(parent);
-QDeclarativeComponent component(engine, QUrl("main.qml"));
+QDeclarativeComponent component(engine, QUrl::fromLocalFile("main.qml"));
QObject *myObject = component.create();
\endcode
diff --git a/examples/declarative/behaviors/SideRect.qml b/examples/declarative/behaviors/SideRect.qml
index d06f73c..d32bd7b 100644
--- a/examples/declarative/behaviors/SideRect.qml
+++ b/examples/declarative/behaviors/SideRect.qml
@@ -5,12 +5,18 @@ Rectangle {
property string text
- width: 75; height: 50; radius: 6
- color: "#646464"; border.width: 4; border.color: "white"
+ width: 75; height: 50
+ radius: 6
+ color: "#646464"
+ border.width: 4; border.color: "white"
MouseArea {
anchors.fill: parent
hoverEnabled: true
- onEntered: { focusRect.x = myRect.x; focusRect.y = myRect.y; focusRect.text = myRect.text }
+ onEntered: {
+ focusRect.x = myRect.x;
+ focusRect.y = myRect.y;
+ focusRect.text = myRect.text;
+ }
}
}
diff --git a/examples/declarative/behaviors/behavior-example.qml b/examples/declarative/behaviors/behavior-example.qml
index b21f4f0..b7bae6c 100644
--- a/examples/declarative/behaviors/behavior-example.qml
+++ b/examples/declarative/behaviors/behavior-example.qml
@@ -1,40 +1,38 @@
import Qt 4.7
Rectangle {
- color: "#343434"
width: 600; height: 400
+ color: "#343434"
Rectangle {
anchors.centerIn: parent
- width: 200; height: 200; radius: 30
- color: "transparent"; border.width: 4; border.color: "white"
+ width: 200; height: 200
+ radius: 30
+ color: "transparent"
+ border.width: 4; border.color: "white"
SideRect {
id: leftRect
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.left
+ anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left }
text: "Left"
}
SideRect {
id: rightRect
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.right
+ anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right }
text: "Right"
}
SideRect {
id: topRect
- anchors.verticalCenter: parent.top
- anchors.horizontalCenter: parent.horizontalCenter
+ anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter }
text: "Top"
}
SideRect {
id: bottomRect
- anchors.verticalCenter: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
+ anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter }
text: "Bottom"
}
@@ -44,9 +42,10 @@ Rectangle {
property string text
- color: "firebrick"
x: 62.5; y: 75; width: 75; height: 50
- radius: 6; border.width: 4; border.color: "white"
+ radius: 6
+ border.width: 4; border.color: "white"
+ color: "firebrick"
// Setting an 'elastic' behavior on the focusRect's x property.
Behavior on x {
@@ -62,7 +61,8 @@ Rectangle {
id: focusText
text: focusRect.text
anchors.centerIn: parent
- color: "white"; font.pixelSize: 16; font.bold: true
+ color: "white"
+ font.pixelSize: 16; font.bold: true
// Setting a behavior on the focusText's x property:
// Set the opacity to 0, set the new text value, then set the opacity back to 1.
diff --git a/examples/declarative/border-image/animated.qml b/examples/declarative/border-image/animated.qml
index 730aeca..c3ff9ef 100644
--- a/examples/declarative/border-image/animated.qml
+++ b/examples/declarative/border-image/animated.qml
@@ -3,7 +3,6 @@ import "content"
Rectangle {
id: page
- color: "white"
width: 1030; height: 540
MyBorderImage {
diff --git a/examples/declarative/border-image/borders.qml b/examples/declarative/border-image/borders.qml
index 8956128..3743f7e 100644
--- a/examples/declarative/border-image/borders.qml
+++ b/examples/declarative/border-image/borders.qml
@@ -2,7 +2,6 @@ import Qt 4.7
Rectangle {
id: page
- color: "white"
width: 520; height: 280
BorderImage {
diff --git a/examples/declarative/clocks/content/Clock.qml b/examples/declarative/clocks/content/Clock.qml
index 036df46..3426e6a 100644
--- a/examples/declarative/clocks/content/Clock.qml
+++ b/examples/declarative/clocks/content/Clock.qml
@@ -14,7 +14,7 @@ Item {
function timeChanged() {
var date = new Date;
hours = shift ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours()
- if ( hours < 7 || hours > 19 ) night = true; else night = false
+ night = ( hours < 7 || hours > 19 )
minutes = shift ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes()
seconds = date.getUTCSeconds();
}
@@ -74,7 +74,10 @@ Item {
}
Text {
- id: cityLabel; font.bold: true; font.pixelSize: 14; y: 200; color: "white"
- anchors.horizontalCenter: parent.horizontalCenter; style: Text.Raised; styleColor: "black"
+ id: cityLabel
+ y: 200; anchors.horizontalCenter: parent.horizontalCenter
+ color: "white"
+ font.bold: true; font.pixelSize: 14
+ style: Text.Raised; styleColor: "black"
}
}
diff --git a/examples/declarative/connections/connections-example.qml b/examples/declarative/connections/connections-example.qml
index 0b4ca45..fbef968 100644
--- a/examples/declarative/connections/connections-example.qml
+++ b/examples/declarative/connections/connections-example.qml
@@ -2,23 +2,34 @@ import Qt 4.7
import "content"
Rectangle {
- id: window; color: "#646464"
- width: 640; height: 480
+ id: window
property int angle: 0
+ width: 640; height: 480
+ color: "#646464"
+
Image {
- id: image; source: "content/bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center
- rotation: window.angle
- Behavior on rotation { NumberAnimation { easing.type: "OutCubic"; duration: 300 } }
+ id: image
+ source: "content/bg1.jpg"
+ anchors.centerIn: parent
+ transformOrigin: Item.Center
+ rotation: window.angle
+
+ Behavior on rotation {
+ NumberAnimation { easing.type: "OutCubic"; duration: 300 }
+ }
}
Button {
- id: leftButton; image: "content/rotate-left.png"
+ id: leftButton
+ image: "content/rotate-left.png"
anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 10 }
}
+
Button {
- id: rightButton; image: "content/rotate-right.png"
+ id: rightButton
+ image: "content/rotate-right.png"
anchors { right: parent.right; bottom: parent.bottom; rightMargin: 10; bottomMargin: 10 }
}
diff --git a/examples/declarative/dial/dial-example.qml b/examples/declarative/dial/dial-example.qml
index 1ca958a..fd899a5 100644
--- a/examples/declarative/dial/dial-example.qml
+++ b/examples/declarative/dial/dial-example.qml
@@ -6,26 +6,35 @@ Rectangle {
width: 300; height: 300
// Dial with a slider to adjust it
- Dial { id: dial; anchors.centerIn: parent; value: slider.x *100 / (container.width - 34) }
+ Dial {
+ id: dial
+ anchors.centerIn: parent
+ value: slider.x * 100 / (container.width - 34)
+ }
Rectangle {
id: container
- anchors.bottom: parent.bottom; anchors.bottomMargin: 10
- anchors.left: parent.left; anchors.leftMargin: 20
- anchors.right: parent.right; anchors.rightMargin: 20; height: 16
+ anchors { bottom: parent.bottom; left: parent.left; right: parent.right; leftMargin: 20; rightMargin: 20; bottomMargin: 10 }
+ height: 16
+
+ radius: 8
+ opacity: 0.7
+ smooth: true
gradient: Gradient {
GradientStop { position: 0.0; color: "gray" }
GradientStop { position: 1.0; color: "white" }
}
- radius: 8; opacity: 0.7; smooth: true
+
Rectangle {
id: slider
x: 1; y: 1; width: 30; height: 14
- radius: 6; smooth: true
+ radius: 6
+ smooth: true
gradient: Gradient {
GradientStop { position: 0.0; color: "#424242" }
GradientStop { position: 1.0; color: "black" }
}
+
MouseArea {
anchors.fill: parent
drag.target: parent; drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: container.width - 32
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
index 7331b3f..eea528f 100644
--- a/examples/declarative/dynamic/dynamic.qml
+++ b/examples/declarative/dynamic/dynamic.qml
@@ -60,7 +60,7 @@ Item {
width: 480
anchors { right: parent.right; top:parent.top; bottom: parent.bottom }
Rectangle { //Not a child of any positioner
- color: "white"; border.color: "black";
+ border.color: "black";
width: toolRow.width + 4
height: toolRow.height + 4
x: toolboxPositioner.x + toolRow.x - 2
diff --git a/examples/declarative/effects/effects.qml b/examples/declarative/effects/effects.qml
index d325e11..feb7c69 100644
--- a/examples/declarative/effects/effects.qml
+++ b/examples/declarative/effects/effects.qml
@@ -1,9 +1,7 @@
import Qt 4.7
Rectangle {
- color: "white"
- width: 400
- height: 200
+ width: 400; height: 200
Image {
id: blur
@@ -33,7 +31,14 @@ Rectangle {
effect: DropShadow {
blurRadius: 3
offset.x: 3
- NumberAnimation on offset.y { id: dropShadowEffect; from: 0; to: 10; duration: 1000; running: false; loops: Animation.Infinite; }
+
+ NumberAnimation on offset.y {
+ id: dropShadowEffect
+ from: 0; to: 10
+ duration: 1000
+ running: false
+ loops: Animation.Infinite
+ }
}
MouseArea { anchors.fill: parent; onClicked: dropShadowEffect.running = !dropShadowEffect.running }
diff --git a/examples/declarative/fillmode/fillmode.qml b/examples/declarative/fillmode/fillmode.qml
index 249674b..e47fc9b 100644
--- a/examples/declarative/fillmode/fillmode.qml
+++ b/examples/declarative/fillmode/fillmode.qml
@@ -4,6 +4,7 @@ Image {
width: 400
height: 250
source: "face.png"
+
SequentialAnimation on fillMode {
loops: Animation.Infinite
PropertyAction { value: Image.Stretch }
@@ -25,17 +26,19 @@ Image {
PropertyAction { target: label; property: "text"; value: "TileVertically" }
PauseAnimation { duration: 1000 }
}
+
Text {
id: label
font.pointSize: 24
color: "blue"
style: Text.Outline
styleColor: "white"
- anchors { centerIn: parent }
+ anchors.centerIn: parent
}
+
Rectangle {
border.color: "black"
color: "transparent"
- anchors { fill: parent; rightMargin: 1; bottomMargin: 1}
+ anchors { fill: parent; rightMargin: 1; bottomMargin: 1 }
}
}
diff --git a/examples/declarative/flipable/flipable-example.qml b/examples/declarative/flipable/flipable-example.qml
index 171353f..4e09569 100644
--- a/examples/declarative/flipable/flipable-example.qml
+++ b/examples/declarative/flipable/flipable-example.qml
@@ -2,7 +2,9 @@ import Qt 4.7
import "content"
Rectangle {
- id: window; width: 480; height: 320
+ id: window
+
+ width: 480; height: 320
color: "darkgreen"
Row {
diff --git a/examples/declarative/focus/Core/ContextMenu.qml b/examples/declarative/focus/Core/ContextMenu.qml
index 56a1b3e..49a54bc 100644
--- a/examples/declarative/focus/Core/ContextMenu.qml
+++ b/examples/declarative/focus/Core/ContextMenu.qml
@@ -2,13 +2,16 @@ import Qt 4.7
FocusScope {
id: container
+
property bool open: false
Item {
anchors.fill: parent
Rectangle {
- anchors.fill: parent; color: "#D1DBBD"; focus: true
+ anchors.fill: parent
+ color: "#D1DBBD"
+ focus: true
Keys.onRightPressed: mainView.focus = true
}
}
diff --git a/examples/declarative/focus/Core/GridMenu.qml b/examples/declarative/focus/Core/GridMenu.qml
index 75f6be0..c37b17a 100644
--- a/examples/declarative/focus/Core/GridMenu.qml
+++ b/examples/declarative/focus/Core/GridMenu.qml
@@ -6,32 +6,41 @@ FocusScope {
onWantsFocusChanged: if (wantsFocus) mainView.state = ""
Rectangle {
- clip: true; anchors.fill: parent
+ anchors.fill: parent
+ clip: true
gradient: Gradient {
GradientStop { position: 0.0; color: "#193441" }
GradientStop { position: 1.0; color: Qt.darker("#193441") }
}
GridView {
- id: gridView; cellWidth: 152; cellHeight: 152; focus: true
+ id: gridView
x: 20; width: parent.width - 40; height: parent.height
+ cellWidth: 152; cellHeight: 152
+ focus: true
model: 12
KeyNavigation.down: listViews
KeyNavigation.left: contextMenu
delegate: Item {
- id: container; width: GridView.view.cellWidth; height: GridView.view.cellHeight
+ id: container
+ width: GridView.view.cellWidth; height: GridView.view.cellHeight
Rectangle {
id: content
- color: "transparent"; smooth: true
+ color: "transparent"
+ smooth: true
anchors.centerIn: parent; width: container.width - 40; height: container.height - 40; radius: 10
+
Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true }
}
MouseArea {
- id: mouseArea; anchors.fill: parent; hoverEnabled: true
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
onClicked: {
GridView.view.currentIndex = index
container.focus = true
diff --git a/examples/declarative/focus/Core/ListViewDelegate.qml b/examples/declarative/focus/Core/ListViewDelegate.qml
index 35c04cf..96324d7 100644
--- a/examples/declarative/focus/Core/ListViewDelegate.qml
+++ b/examples/declarative/focus/Core/ListViewDelegate.qml
@@ -7,8 +7,11 @@ Component {
Rectangle {
id: content
- color: "transparent"; smooth: true
- anchors.centerIn: parent; width: container.width - 40; height: container.height - 10; radius: 10
+ anchors.centerIn: parent; width: container.width - 40; height: container.height - 10
+ color: "transparent"
+ smooth: true
+ radius: 10
+
Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
Text {
text: "List element " + (index + 1); color: "#193441"; font.bold: false; anchors.centerIn: parent
@@ -17,7 +20,10 @@ Component {
}
MouseArea {
- id: mouseArea; anchors.fill: parent; hoverEnabled: true
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
onClicked: {
ListView.view.currentIndex = index
container.focus = true
diff --git a/examples/declarative/focus/Core/ListViews.qml b/examples/declarative/focus/Core/ListViews.qml
index b28cc1c..f4384c8 100644
--- a/examples/declarative/focus/Core/ListViews.qml
+++ b/examples/declarative/focus/Core/ListViews.qml
@@ -7,29 +7,43 @@ FocusScope {
ListView {
id: list1
+ y: wantsFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20
+ focus: true
+ KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2
+ model: 10
delegate: ListViewDelegate {}
- y: wantsFocus ? 10 : 40; focus: true; width: parent.width / 3; height: parent.height - 20
- model: 10; KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2
- Behavior on y { NumberAnimation { duration: 600; easing.type: "OutQuint" } }
+
+ Behavior on y {
+ NumberAnimation { duration: 600; easing.type: "OutQuint" }
+ }
}
ListView {
id: list2
- delegate: ListViewDelegate {}
y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20
- model: 10; KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
- Behavior on y { NumberAnimation { duration: 600; easing.type: "OutQuint" } }
+ KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
+ model: 10
+ delegate: ListViewDelegate {}
+
+ Behavior on y {
+ NumberAnimation { duration: 600; easing.type: "OutQuint" }
+ }
}
ListView {
id: list3
- delegate: ListViewDelegate {}
y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20
- model: 10; KeyNavigation.up: gridMenu; KeyNavigation.left: list2
- Behavior on y { NumberAnimation { duration: 600; easing.type: "OutQuint" } }
+ KeyNavigation.up: gridMenu; KeyNavigation.left: list2
+ model: 10
+ delegate: ListViewDelegate {}
+
+ Behavior on y {
+ NumberAnimation { duration: 600; easing.type: "OutQuint" }
+ }
}
Rectangle { width: parent.width; height: 1; color: "#D1DBBD" }
+
Rectangle {
y: 1; width: parent.width; height: 10
gradient: Gradient {
@@ -37,6 +51,7 @@ FocusScope {
GradientStop { position: 1.0; color: "transparent" }
}
}
+
Rectangle {
y: parent.height - 10; width: parent.width; height: 10
gradient: Gradient {
diff --git a/examples/declarative/focus/focus.qml b/examples/declarative/focus/focus.qml
index d9b6549..22b0e50 100644
--- a/examples/declarative/focus/focus.qml
+++ b/examples/declarative/focus/focus.qml
@@ -2,19 +2,34 @@ import Qt 4.7
import "Core"
Rectangle {
- id: window; width: 800; height: 480; color: "#3E606F"
+ id: window
+
+ width: 800; height: 480
+ color: "#3E606F"
FocusScope {
- id: mainView; focus: true; width: parent.width; height: parent.height
+ id: mainView
+
+ width: parent.width; height: parent.height
+ focus: true
GridMenu {
- id: gridMenu; focus: true
- width: parent.width; height: 320; interactive: parent.wantsFocus
+ id: gridMenu
+
+ width: parent.width; height: 320
+ focus: true
+ interactive: parent.wantsFocus
}
- ListViews { id: listViews; y: 320; width: parent.width; height: 320 }
+ ListViews {
+ id: listViews
+ y: 320; width: parent.width; height: 320
+ }
- Rectangle { id: shade; color: "black"; opacity: 0; anchors.fill: parent }
+ Rectangle {
+ id: shade
+ color: "black"; opacity: 0; anchors.fill: parent
+ }
states: State {
name: "showListViews"
@@ -28,7 +43,10 @@ Rectangle {
}
Image {
- source: "Core/images/arrow.png"; rotation: 90; anchors.verticalCenter: parent.verticalCenter
+ source: "Core/images/arrow.png"
+ rotation: 90
+ anchors.verticalCenter: parent.verticalCenter
+
MouseArea {
anchors { fill: parent; leftMargin: -10; topMargin: -10; rightMargin: -10; bottomMargin: -10 }
onClicked: window.state = "contextMenuOpen"
@@ -38,7 +56,8 @@ Rectangle {
ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height }
states: State {
- name: "contextMenuOpen"; when: !mainView.wantsFocus
+ name: "contextMenuOpen"
+ when: !mainView.wantsFocus
PropertyChanges { target: contextMenu; x: 0; open: true }
PropertyChanges { target: mainView; x: 130 }
PropertyChanges { target: shade; opacity: 0.25 }
diff --git a/examples/declarative/fonts/banner.qml b/examples/declarative/fonts/banner.qml
index b7f5344..353354a 100644
--- a/examples/declarative/fonts/banner.qml
+++ b/examples/declarative/fonts/banner.qml
@@ -2,14 +2,17 @@ import Qt 4.7
Rectangle {
id: screen
- width: 640; height: 320; color: "steelblue"
property int pixelSize: screen.height * 1.25
property color textColor: "lightsteelblue"
property string text: "Hello world! "
+ width: 640; height: 320
+ color: "steelblue"
+
Row {
y: -screen.height / 4.5
+
NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite }
Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml
index 49c3d0a..97dd645 100644
--- a/examples/declarative/fonts/fonts.qml
+++ b/examples/declarative/fonts/fonts.qml
@@ -11,36 +11,43 @@ Rectangle {
FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" }
Column {
- anchors.fill: parent; spacing: 15
- anchors.leftMargin: 10; anchors.rightMargin: 10
+ anchors { fill: parent; leftMargin: 10; rightMargin: 10 }
+ spacing: 15
+
Text {
- text: myText; color: "lightsteelblue"
- width: parent.width; elide: Text.ElideRight
- font.family: "Times"; font.pointSize: 42
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideRight
+ font.family: "Times"; font.pointSize: 42
}
Text {
- text: myText; color: "lightsteelblue"
- width: parent.width; elide: Text.ElideLeft
- font.family: "Times"; font.pointSize: 42
- font.capitalization: Font.AllUppercase
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideLeft
+ font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase }
}
Text {
- text: myText; color: "lightsteelblue"
- width: parent.width; elide: Text.ElideMiddle
- font.family: fixedFont.name; font.pointSize: 42; font.weight: Font.Bold
- font.capitalization: Font.AllLowercase
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideMiddle
+ font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase }
}
Text {
- text: myText; color: "lightsteelblue"
- width: parent.width; elide: Text.ElideRight
- font.family: fixedFont.name; font.pointSize: 42; font.italic: true
- font.capitalization: Font.SmallCaps
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideRight
+ font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps }
}
Text {
- text: myText; color: "lightsteelblue"
- width: parent.width; elide: Text.ElideLeft
- font.family: localFont.name; font.pointSize: 42
- font.capitalization: Font.Capitalize
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideLeft
+ font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize }
}
Text {
text: {
@@ -49,7 +56,8 @@ Rectangle {
else if (webFont.status == 3) "Error loading font"
}
color: "lightsteelblue"
- width: parent.width; elide: Text.ElideMiddle
+ width: parent.width
+ elide: Text.ElideMiddle
font.family: webFont.name; font.pointSize: 42
}
}
diff --git a/examples/declarative/fonts/hello.qml b/examples/declarative/fonts/hello.qml
index 9d926fb..d4d0e4c 100644
--- a/examples/declarative/fonts/hello.qml
+++ b/examples/declarative/fonts/hello.qml
@@ -1,22 +1,33 @@
import Qt 4.7
Rectangle {
- id: screen; width: 800; height: 480; color: "black"
+ id: screen
+
+ width: 800; height: 480
+ color: "black"
Item {
- id: container; x: screen.width / 2; y: screen.height / 2
+ id: container
+ x: screen.width / 2; y: screen.height / 2
+
Text {
- id: text; color: "white"; anchors.centerIn: parent
- text: "Hello world!"; font.pixelSize: 60
+ id: text
+ anchors.centerIn: parent
+ color: "white"
+ text: "Hello world!"
+ font.pixelSize: 60
SequentialAnimation on font.letterSpacing {
loops: Animation.Infinite;
NumberAnimation { from: 100; to: 300; easing.type: "InQuad"; duration: 3000 }
- ScriptAction { script: {
- container.y = (screen.height / 4) + (Math.random() * screen.height / 2)
- container.x = (screen.width / 4) + (Math.random() * screen.width / 2)
- } }
+ ScriptAction {
+ script: {
+ container.y = (screen.height / 4) + (Math.random() * screen.height / 2)
+ container.x = (screen.width / 4) + (Math.random() * screen.width / 2)
+ }
+ }
}
+
SequentialAnimation on opacity {
loops: Animation.Infinite;
NumberAnimation { from: 1; to: 0; duration: 2600 }
diff --git a/examples/declarative/gridview/gridview-example.qml b/examples/declarative/gridview/gridview-example.qml
index fd5f430..a5f41fb 100644
--- a/examples/declarative/gridview/gridview-example.qml
+++ b/examples/declarative/gridview/gridview-example.qml
@@ -1,7 +1,8 @@
import Qt 4.7
Rectangle {
- width: 300; height: 400; color: "white"
+ width: 300; height: 400
+ color: "white"
ListModel {
id: appModel
@@ -16,10 +17,19 @@ Rectangle {
Component {
id: appDelegate
+
Item {
width: 100; height: 100
- Image { id: myIcon; y: 20; anchors.horizontalCenter: parent.horizontalCenter; source: icon }
- Text { anchors.top: myIcon.bottom; anchors.horizontalCenter: parent.horizontalCenter; text: name }
+
+ Image {
+ id: myIcon
+ y: 20; anchors.horizontalCenter: parent.horizontalCenter
+ source: icon
+ }
+ Text {
+ anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter }
+ text: name
+ }
}
}
@@ -31,8 +41,9 @@ Rectangle {
GridView {
anchors.fill: parent
cellWidth: 100; cellHeight: 100
- model: appModel; delegate: appDelegate
highlight: appHighlight
focus: true
+ model: appModel
+ delegate: appDelegate
}
}
diff --git a/examples/declarative/imageprovider/imageprovider-example.qml b/examples/declarative/imageprovider/imageprovider-example.qml
index 9d22576..d774112 100644
--- a/examples/declarative/imageprovider/imageprovider-example.qml
+++ b/examples/declarative/imageprovider/imageprovider-example.qml
@@ -2,10 +2,11 @@ import Qt 4.7
import "ImageProviderCore"
//![0]
ListView {
- width: 100
- height: 100
+ width: 100; height: 100
anchors.fill: parent
+
model: myModel
+
delegate: Component {
Item {
width: 100
diff --git a/examples/declarative/images/images.qml b/examples/declarative/images/images.qml
index 7980088..e48ad50 100644
--- a/examples/declarative/images/images.qml
+++ b/examples/declarative/images/images.qml
@@ -6,8 +6,8 @@ Rectangle {
height: grid.height + 50
Grid {
- x: 25; y: 25
id: grid
+ x: 25; y: 25
columns: 3
Image {
@@ -48,19 +48,22 @@ Rectangle {
}
Image {
- width: 50; height: 50; transform: Translate { x: 50 }
+ width: 50; height: 50
+ transform: Translate { x: 50 }
source: "content/lemonade.jpg"
}
Image {
- width: 50; height: 50; transform: Translate { x: 50 }
+ width: 50; height: 50
+ transform: Translate { x: 50 }
sourceSize.width: 50
sourceSize.height: 50
source: "content/lemonade.jpg"
}
Image {
- width: 50; height: 50; transform: Translate { x: 50 }
+ width: 50; height: 50
+ transform: Translate { x: 50 }
sourceSize: "50x50" // syntactic sugar
smooth: true
source: "content/lemonade.jpg"
diff --git a/examples/declarative/layouts/layouts.qml b/examples/declarative/layouts/layouts.qml
index 1d34afd..391eab7 100644
--- a/examples/declarative/layouts/layouts.qml
+++ b/examples/declarative/layouts/layouts.qml
@@ -1,12 +1,15 @@
import Qt 4.7
-import Qt.widgets 4.6
+import Qt.widgets 4.7
+
Item {
id: resizable
- width:400
- height:400
+
+ width: 400
+ height: 400
+
QGraphicsWidget {
- size.width:parent.width
- size.height:parent.height
+ size.width: parent.width
+ size.height: parent.height
layout: QGraphicsLinearLayout {
LayoutItem {
diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml
index ef225d0..3703b59 100644
--- a/examples/declarative/layouts/positioners.qml
+++ b/examples/declarative/layouts/positioners.qml
@@ -2,31 +2,40 @@ import Qt 4.7
Rectangle {
id: page
- width: 420
- height: 420
- color: "white"
+ width: 420; height: 420
Column {
id: layout1
y: 0
move: Transition {
- NumberAnimation {
- properties: "y"; easing.type: "OutBounce"
- }
+ NumberAnimation { properties: "y"; easing.type: "OutBounce" }
}
add: Transition {
- NumberAnimation {
- properties: "y"; easing.type: "OutQuad"
- }
+ NumberAnimation { properties: "y"; easing.type: "OutQuad" }
}
+
Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 }
- Rectangle { id: blueV1; color: "lightsteelblue"; width: 100; height: 50; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueV1
+ width: 100; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 }
- Rectangle { id: blueV2; color: "lightsteelblue"; width: 100; height: 50; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueV2
+ width: 100; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 }
}
@@ -34,31 +43,41 @@ Rectangle {
id: layout2
y: 300
move: Transition {
- NumberAnimation {
- properties: "x"; easing.type: "OutBounce"
- }
+ NumberAnimation { properties: "x"; easing.type: "OutBounce" }
}
add: Transition {
- NumberAnimation {
- properties: "x"; easing.type: "OutQuad"
- }
+ NumberAnimation { properties: "x"; easing.type: "OutQuad" }
}
+
Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
- Rectangle { id: blueH1; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueH1
+ width: 50; height: 100
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 }
- Rectangle { id: blueH2; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueH2
+ width: 50; height: 100
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 }
}
Button {
+ x: 135; y: 90
text: "Remove"
icon: "del.png"
- x: 135
- y: 90
onClicked: {
blueH2.opacity = 0
@@ -75,10 +94,9 @@ Rectangle {
}
Button {
+ x: 145; y: 140
text: "Add"
icon: "add.png"
- x: 145
- y: 140
onClicked: {
blueH2.opacity = 1
@@ -95,34 +113,50 @@ Rectangle {
}
Grid {
- x: 260
- y: 0
+ x: 260; y: 0
columns: 3
move: Transition {
- NumberAnimation {
- properties: "x,y"; easing.type: "OutBounce"
- }
+ NumberAnimation { properties: "x,y"; easing.type: "OutBounce" }
}
add: Transition {
- NumberAnimation {
- properties: "x,y"; easing.type: "OutBounce"
- }
+ NumberAnimation { properties: "x,y"; easing.type: "OutBounce" }
}
Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
- Rectangle { id: blueG1; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueG1
+ width: 50; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
- Rectangle { id: blueG2; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueG2
+ width: 50; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
- Rectangle { id: blueG3; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueG3
+ width: 50; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
@@ -130,33 +164,49 @@ Rectangle {
Flow {
id: layout4
- x: 260
- y: 250
- width: 150
+ x: 260; y: 250; width: 150
move: Transition {
- NumberAnimation {
- properties: "x,y"; easing.type: "OutBounce"
- }
+ NumberAnimation { properties: "x,y"; easing.type: "OutBounce" }
}
add: Transition {
- NumberAnimation {
- properties: "x,y"; easing.type: "OutBounce"
- }
+ NumberAnimation { properties: "x,y"; easing.type: "OutBounce" }
}
+
Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
- Rectangle { id: blueF1; color: "lightsteelblue"; width: 60; height: 50; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueF1
+ width: 60; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 }
- Rectangle { id: blueF2; color: "lightsteelblue"; width: 60; height: 50; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueF2
+ width: 60; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
- Rectangle { id: blueF3; color: "lightsteelblue"; width: 40; height: 50; border.color: "black"; radius: 15
- Behavior on opacity {NumberAnimation{}}
+
+ Rectangle {
+ id: blueF3
+ width: 40; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
}
+
Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 }
}
diff --git a/examples/declarative/listmodel-threaded/timedisplay.qml b/examples/declarative/listmodel-threaded/timedisplay.qml
index 848192e..80ac9fa 100644
--- a/examples/declarative/listmodel-threaded/timedisplay.qml
+++ b/examples/declarative/listmodel-threaded/timedisplay.qml
@@ -22,7 +22,9 @@ ListView {
Timer {
id: timer
- interval: 2000; repeat: true; running: true; triggeredOnStart: true
+ interval: 2000; repeat: true
+ running: true
+ triggeredOnStart: true
onTriggered: {
var msg = {'action': 'appendCurrentTime', 'model': listModel};
diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml
index 32483fa..236a9c5 100644
--- a/examples/declarative/listview/dynamic.qml
+++ b/examples/declarative/listview/dynamic.qml
@@ -3,11 +3,13 @@ import "content"
import "../scrollbar"
Rectangle {
+ id: container
width: 640; height: 480
color: "#343434"
ListModel {
id: fruitModel
+
ListElement {
name: "Apple"; cost: 2.45
attributes: [
@@ -51,12 +53,16 @@ Rectangle {
Component {
id: fruitDelegate
+
Item {
- width: parent.width; height: 55
+ width: container.width; height: 55
Column {
- id: moveButtons; x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter
- Image { source: "content/pics/go-up.png"
+ id: moveButtons
+ x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter
+
+ Image {
+ source: "content/pics/go-up.png"
MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) }
}
Image { source: "content/pics/go-down.png"
@@ -66,33 +72,63 @@ Rectangle {
Column {
anchors { right: itemButtons.left; verticalCenter: parent.verticalCenter; left: moveButtons.right; leftMargin: 10 }
+
Text {
- id: label; font.bold: true; text: name; elide: Text.ElideRight; font.pixelSize: 15
- width: parent.width; color: "White"
+ id: label
+ width: parent.width
+ color: "White"
+ font.bold: true; font.pixelSize: 15
+ text: name; elide: Text.ElideRight
}
Row {
spacing: 5
- Repeater { model: attributes; Component { Text { text: description; color: "White" } } }
+ Repeater {
+ model: attributes
+ Component {
+ Text { text: description; color: "White" }
+ }
+ }
}
}
Row {
id: itemButtons
- 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.setProperty(index,"cost",cost+0.25) }
- scale: clickUp.isPressed ? 0.9 : 1; transformOrigin: Item.Center
+
+ anchors { right: removeButton.left; rightMargin: 35; verticalCenter: parent.verticalCenter }
+ width: childrenRect.width
+ spacing: 10
+
+ Image {
+ source: "content/pics/list-add.png"
+ scale: clickUp.isPressed ? 0.9 : 1
+ transformOrigin: Item.Center
+
+ ClickAutoRepeating {
+ id: clickUp
+ anchors.fill: parent
+ onClicked: fruitModel.setProperty(index, "cost", cost+0.25)
+ }
}
+
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.setProperty(index,"cost",Math.max(0,cost-0.25)) }
- scale: clickDown.isPressed ? 0.9 : 1; transformOrigin: Item.Center
+
+ Image {
+ source: "content/pics/list-remove.png"
+ scale: clickDown.isPressed ? 0.9 : 1
+ transformOrigin: Item.Center
+
+ ClickAutoRepeating {
+ id: clickDown
+ anchors.fill: parent
+ onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25))
+ }
}
}
Image {
- id: removeButton; source: "content/pics/archive-remove.png"
+ id: removeButton
anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 }
+ source: "content/pics/archive-remove.png"
+
MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) }
}
}
@@ -100,60 +136,75 @@ Rectangle {
ListView {
id: view
- model: fruitModel; delegate: fruitDelegate
anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top }
+ model: fruitModel
+ delegate: fruitDelegate
}
// Attach scrollbar to the right edge of the view.
ScrollBar {
id: verticalScrollBar
+
+ width: 8; height: view.height; anchors.right: view.right
opacity: 0
orientation: "Vertical"
position: view.visibleArea.yPosition
pageSize: view.visibleArea.heightRatio
- width: 8
- height: view.height
- anchors.right: view.right
+
// Only show the scrollbar when the view is moving.
- states: [
- State {
- name: "ShowBars"; when: view.moving
- PropertyChanges { target: verticalScrollBar; opacity: 1 }
- }
- ]
- transitions: [ Transition { NumberAnimation { properties: "opacity"; duration: 400 } } ]
+ states: State {
+ name: "ShowBars"; when: view.moving
+ PropertyChanges { target: verticalScrollBar; opacity: 1 }
+ }
+ transitions: Transition {
+ NumberAnimation { properties: "opacity"; duration: 400 }
+ }
}
Row {
- x: 8; width: childrenRect.width
- height: childrenRect.height
+ id: buttons
+
+ x: 8; width: childrenRect.width; height: childrenRect.height
anchors { bottom: parent.bottom; bottomMargin: 8 }
spacing: 8
- id: buttons
- Image { source: "content/pics/archive-insert.png"
- MouseArea { anchors.fill: parent;
+
+ Image {
+ source: "content/pics/archive-insert.png"
+
+ MouseArea {
+ anchors.fill: parent
onClicked: {
fruitModel.append({
- "name":"Pizza Margarita",
- "cost":5.95,
- "attributes":[{"description": "Cheese"},{"description": "Tomato"}]
- })
+ "name": "Pizza Margarita",
+ "cost": 5.95,
+ "attributes": [{"description": "Cheese"},{"description": "Tomato"}]
+ })
}
}
}
- Image { source: "content/pics/archive-insert.png"
- MouseArea { anchors.fill: parent;
+
+ Image {
+ source: "content/pics/archive-insert.png"
+
+ MouseArea {
+ anchors.fill: parent;
onClicked: {
- fruitModel.insert(0,{
- "name":"Pizza Supreme",
- "cost":9.95,
- "attributes":[{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}]
- })
+ fruitModel.insert(0, {
+ "name": "Pizza Supreme",
+ "cost": 9.95,
+ "attributes": [{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}]
+ })
}
}
}
- Image { source: "content/pics/archive-remove.png"
- MouseArea { anchors.fill: parent; onClicked: fruitModel.clear() }
+
+ Image {
+ source: "content/pics/archive-remove.png"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: fruitModel.clear()
+ }
}
}
}
diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml
index 2b54dd8..50ba2f7 100644
--- a/examples/declarative/listview/highlight.qml
+++ b/examples/declarative/listview/highlight.qml
@@ -1,12 +1,13 @@
import Qt 4.7
Rectangle {
- width: 400; height: 300; color: "white"
+ width: 400; height: 300
// MyPets model is defined in dummydata/MyPetsModel.qml
// The viewer automatically loads files in dummydata/* to assist
// development without a real data source.
// This one contains my pets.
+
// Define a delegate component. A component will be
// instantiated for each visible item in the list.
Component {
@@ -21,20 +22,14 @@ Rectangle {
}
// Use the ListView.isCurrentItem attached property to
// indent the item if it is the current item.
- states: [
- State {
- name: "Current"
- when: wrapper.ListView.isCurrentItem
- PropertyChanges { target: wrapper; x: 10 }
- }
- ]
- transitions: [
- Transition {
- NumberAnimation {
- properties: "x"; duration: 200
- }
- }
- ]
+ states: State {
+ name: "Current"
+ when: wrapper.ListView.isCurrentItem
+ PropertyChanges { target: wrapper; x: 10 }
+ }
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 200 }
+ }
}
}
// Specify a highlight with custom movement. Note that highlightFollowsCurrentItem
@@ -43,14 +38,17 @@ Rectangle {
Component {
id: petHighlight
Rectangle {
- width: 200; height: 50; color: "#FFFF88"
+ width: 200; height: 50
+ color: "#FFFF88"
SpringFollow on y { to: list1.currentItem.y; spring: 3; damping: 0.1 }
}
}
+
ListView {
id: list1
width: 200; height: parent.height
- model: MyPetsModel; delegate: petDelegate
+ model: MyPetsModel
+ delegate: petDelegate
highlight: petHighlight; highlightFollowsCurrentItem: false
focus: true
}
diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml
index 2f4aa31..e387f28 100644
--- a/examples/declarative/listview/itemlist.qml
+++ b/examples/declarative/listview/itemlist.qml
@@ -10,23 +10,27 @@ Rectangle {
VisualItemModel {
id: itemModel
+
Rectangle {
- height: view.height; width: view.width; color: "#FFFEF0"
+ width: view.width; height: view.height
+ color: "#FFFEF0"
Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent }
}
Rectangle {
- height: view.height; width: view.width; color: "#F0FFF7"
+ width: view.width; height: view.height
+ color: "#F0FFF7"
Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent }
}
Rectangle {
- height: view.height; width: view.width; color: "#F4F0FF"
+ width: view.width; height: view.height
+ color: "#F4F0FF"
Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent }
}
}
ListView {
id: view
- anchors.fill: parent; anchors.bottomMargin: 30
+ anchors { fill: parent; bottomMargin: 30 }
model: itemModel
preferredHighlightBegin: 0; preferredHighlightEnd: 0
highlightRangeMode: "StrictlyEnforceRange"
@@ -35,22 +39,27 @@ Rectangle {
}
Rectangle {
+ width: 240; height: 30
+ anchors { top: view.bottom; bottom: parent.bottom }
color: "gray"
- anchors.top: view.bottom
- anchors.bottom: parent.bottom
- height: 30
- width: 240
Row {
anchors.centerIn: parent
spacing: 20
+
Repeater {
model: itemModel.count
+
Rectangle {
width: 5; height: 5
radius: 3
- MouseArea { width: 20; height: 20; anchors.centerIn: parent; onClicked: view.currentIndex = index }
color: view.currentIndex == index ? "blue" : "white"
+
+ MouseArea {
+ width: 20; height: 20
+ anchors.centerIn: parent
+ onClicked: view.currentIndex = index
+ }
}
}
}
diff --git a/examples/declarative/listview/listview-example.qml b/examples/declarative/listview/listview-example.qml
index d648b60..6feedf6 100644
--- a/examples/declarative/listview/listview-example.qml
+++ b/examples/declarative/listview/listview-example.qml
@@ -1,12 +1,13 @@
import Qt 4.7
Rectangle {
- width: 600; height: 300; color: "white"
+ width: 600; height: 300
// MyPets model is defined in dummydata/MyPetsModel.qml
// The viewer automatically loads files in dummydata/* to assist
// development without a real data source.
// This one contains my pets.
+
// Define a delegate component. A component will be
// instantiated for each visible item in the list.
Component {
@@ -31,46 +32,61 @@ Rectangle {
// Show the model in three lists, with different highlight ranges.
// preferredHighlightBegin and preferredHighlightEnd set the
// range in which to attempt to maintain the highlight.
+ //
// Note that the second and third ListView
// set their currentIndex to be the same as the first, and that
// the first ListView is given keyboard focus.
+ //
// The default mode allows the currentItem to move freely
// within the visible area. If it would move outside the visible
// area, the view is scrolled to keep it visible.
+ //
// The second list sets a highlight range which attempts to keep the
// current item within the the bounds of the range, however
// items will not scroll beyond the beginning or end of the view,
// forcing the highlight to move outside the range at the ends.
+ //
// The third list sets the highlightRangeMode to StrictlyEnforceRange
// and sets a range smaller than the height of an item. This
// forces the current item to change when the view is flicked,
// since the highlight is unable to move.
+ //
// Note that the first ListView sets its currentIndex to be equal to
// the third ListView's currentIndex. By flicking List3 with
// the mouse, the current index of List1 will be changed.
+
ListView {
id: list1
width: 200; height: parent.height
- model: MyPetsModel; delegate: petDelegate
- highlight: petHighlight; currentIndex: list3.currentIndex
+ model: MyPetsModel
+ delegate: petDelegate
+
+ highlight: petHighlight
+ currentIndex: list3.currentIndex
focus: true
}
+
ListView {
id: list2
x: 200; width: 200; height: parent.height
- model: MyPetsModel; delegate: petDelegate; highlight: petHighlight
- preferredHighlightBegin: 80
- preferredHighlightEnd: 220
- highlightRangeMode: "ApplyRange"
+ model: MyPetsModel
+ delegate: petDelegate
+
+ highlight: petHighlight
currentIndex: list1.currentIndex
+ preferredHighlightBegin: 80; preferredHighlightEnd: 220
+ highlightRangeMode: "ApplyRange"
}
+
ListView {
id: list3
x: 400; width: 200; height: parent.height
- model: MyPetsModel; delegate: petDelegate; highlight: petHighlight
+ model: MyPetsModel
+ delegate: petDelegate
+
+ highlight: Rectangle { color: "lightsteelblue" }
currentIndex: list1.currentIndex
- preferredHighlightBegin: 125
- preferredHighlightEnd: 125
+ preferredHighlightBegin: 125; preferredHighlightEnd: 125
highlightRangeMode: "StrictlyEnforceRange"
flickDeceleration: 1000
}
diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml
index 66c4109..990e272 100644
--- a/examples/declarative/listview/recipes.qml
+++ b/examples/declarative/listview/recipes.qml
@@ -5,16 +5,17 @@ import "content"
Rectangle {
id: page
- width: 400; height: 240; color: "black"
+ width: 400; height: 240
+ color: "black"
// Delegate for the recipes. This delegate has two modes:
// 1. the list mode (default), which just shows the picture and title of the recipe.
// 2. the details mode, which also shows the ingredients and method.
Component {
id: recipeDelegate
+
Item {
id: wrapper
- width: list.width
// Create a property to contain the visibility of the details.
// We can bind multiple element's opacity to this one property,
@@ -22,11 +23,15 @@ Rectangle {
// want to fade.
property real detailsOpacity : 0
+ width: list.width
+
// A simple rounded rectangle for the background
Rectangle {
id: background
x: 1; y: 2; width: parent.width - 2; height: parent.height - 4
- color: "#FEFFEE"; border.color: "#FFBE4F"; radius: 5
+ color: "#FEFFEE"
+ border.color: "#FFBE4F"
+ radius: 5
}
// This mouse region covers the entire delegate.
@@ -52,13 +57,17 @@ Rectangle {
}
Column {
- height: recipePic.height; width: background.width-recipePic.width-20
+ width: background.width-recipePic.width-20; height: recipePic.height;
spacing: 5
+
Text { id: name; text: title; font.bold: true; font.pointSize: 16 }
+
Text {
- text: "Ingredients"; font.pointSize: 12; font.bold: true
+ text: "Ingredients"
+ font.pointSize: 12; font.bold: true
opacity: wrapper.detailsOpacity
}
+
Text {
text: ingredients
wrapMode: Text.WordWrap
@@ -71,52 +80,61 @@ Rectangle {
Item {
id: details
x: 10; width: parent.width-20
- anchors.top: topLayout.bottom; anchors.topMargin: 10
- anchors.bottom: parent.bottom; anchors.bottomMargin: 10
+ anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 }
opacity: wrapper.detailsOpacity
Text {
id: methodTitle
- text: "Method"; font.pointSize: 12; font.bold: true
anchors.top: parent.top
+ text: "Method"
+ font.pointSize: 12; font.bold: true
}
+
Flickable {
id: flick
- anchors.top: methodTitle.bottom; anchors.bottom: parent.bottom
- width: parent.width; contentHeight: methodText.height; clip: true
+ width: parent.width
+ anchors { top: methodTitle.bottom; bottom: parent.bottom }
+ contentHeight: methodText.height; clip: true
+
Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width }
}
+
Image {
- anchors.right: flick.right; anchors.top: flick.top
- source: "content/pics/moreUp.png"; opacity: flick.atYBeginning ? 0 : 1
+ anchors { right: flick.right; top: flick.top }
+ source: "content/pics/moreUp.png"
+ opacity: flick.atYBeginning ? 0 : 1
}
+
Image {
- anchors.right: flick.right; anchors.bottom: flick.bottom
- source: "content/pics/moreDown.png"; opacity: flick.atYEnd ? 0 : 1
+ anchors { right: flick.right; bottom: flick.bottom }
+ source: "content/pics/moreDown.png"
+ opacity: flick.atYEnd ? 0 : 1
}
}
// A button to close the detailed view, i.e. set the state back to default ('').
MediaButton {
- anchors.right: background.right; anchors.rightMargin: 5
- y: 10; opacity: wrapper.detailsOpacity
- text: "Close"; onClicked: wrapper.state = '';
+ y: 10; anchors { right: background.right; rightMargin: 5 }
+ opacity: wrapper.detailsOpacity
+ text: "Close"
+
+ onClicked: wrapper.state = '';
}
- // Make the default height equal the hight of the picture, plus margin.
+ // Set the default height to the height of the picture, plus margin.
height: 68
states: State {
name: "Details"
+
PropertyChanges { target: background; color: "white" }
- // Make the picture bigger
- PropertyChanges { target: recipePic; width: 128; height: 128 }
- // Make details visible
- PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 }
- // Make the detailed view fill the entire list area
- PropertyChanges { target: wrapper; height: list.height }
+ PropertyChanges { target: recipePic; width: 128; height: 128 } // Make picture bigger
+ PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 } // Make details visible
+ PropertyChanges { target: wrapper; height: list.height } // Fill the entire list area with the detailed view
+
// Move the list so that this item is at the top.
PropertyChanges { target: wrapper.ListView.view; explicit: true; contentY: wrapper.y }
+
// Disallow flicking while we're in detailed view
PropertyChanges { target: wrapper.ListView.view; interactive: false }
}
@@ -125,9 +143,7 @@ Rectangle {
// Make the state changes smooth
ParallelAnimation {
ColorAnimation { property: "color"; duration: 500 }
- NumberAnimation {
- duration: 300; properties: "detailsOpacity,x,contentY,height,width"
- }
+ NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" }
}
}
}
@@ -136,7 +152,9 @@ Rectangle {
// The actual list
ListView {
id: list
- model: Recipes; delegate: recipeDelegate
- anchors.fill: parent; clip: true
+ anchors.fill: parent
+ clip: true
+ model: Recipes
+ delegate: recipeDelegate
}
}
diff --git a/examples/declarative/listview/sections.qml b/examples/declarative/listview/sections.qml
index 7c132a4..0a81f63 100644
--- a/examples/declarative/listview/sections.qml
+++ b/examples/declarative/listview/sections.qml
@@ -4,7 +4,7 @@ import Qt 4.7
Rectangle {
width: 200
height: 240
- color: "white"
+
// MyPets model is defined in dummydata/MyPetsModel.qml
// The viewer automatically loads files in dummydata/* to assist
// development without a real data source.
@@ -13,15 +13,16 @@ Rectangle {
// Define a delegate component that includes a separator for sections.
Component {
id: petDelegate
+
Item {
id: wrapper
width: 200
- // My height is the combined height of the description and the section separator
- height: desc.height
+ height: desc.height // height is the combined height of the description and the section separator
+
Item {
id: desc
- x: 5
- height: layout.height + 4
+ x: 5; height: layout.height + 4
+
Column {
id: layout
y: 2
@@ -32,22 +33,24 @@ Rectangle {
}
}
}
+
// Define a highlight component. Just one of these will be instantiated
// by each ListView and placed behind the current item.
Component {
id: petHighlight
- Rectangle {
- color: "#FFFF88"
- }
+ Rectangle { color: "#FFFF88" }
}
+
// The list
ListView {
id: myList
- width: 200
- height: parent.height
+
+ width: 200; height: parent.height
model: MyPetsModel
delegate: petDelegate
highlight: petHighlight
+ focus: true
+
// The sectionExpression is simply the size of the pet.
// We use this to determine which section we are in above.
section.property: "size"
@@ -57,11 +60,12 @@ Rectangle {
width: 200
height: 20
Text {
- text: section; font.bold: true
- x: 2; height: parent.height; verticalAlignment: 'AlignVCenter'
+ x: 2; height: parent.height
+ verticalAlignment: 'AlignVCenter'
+ text: section
+ font.bold: true
}
}
- focus: true
}
}
//! [0]
diff --git a/examples/declarative/mousearea/mouse.qml b/examples/declarative/mousearea/mouse.qml
index efbfb53..67302a8 100644
--- a/examples/declarative/mousearea/mouse.qml
+++ b/examples/declarative/mousearea/mouse.qml
@@ -1,40 +1,47 @@
import Qt 4.7
Rectangle {
- color: "white"
width: 200; height: 200
+
Rectangle {
width: 50; height: 50
color: "red"
+
Text { text: "Click"; anchors.centerIn: parent }
+
MouseArea {
+ anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
- onPressed: { console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
- onReleased: { console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') }
- onClicked: { console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') }
- onDoubleClicked: { console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') }
- onPressAndHold: { console.log('press and hold') }
- onEntered: { console.log('entered ' + pressed) }
- onExited: { console.log('exited ' + pressed) }
- anchors.fill: parent
+
+ onPressed: console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')')
+ onReleased: console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')')
+ onClicked: console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')')
+ onDoubleClicked: console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')')
+ onPressAndHold: console.log('press and hold')
+ onEntered: console.log('entered ' + pressed)
+ onExited: console.log('exited ' + pressed)
}
}
+
Rectangle {
y: 100; width: 50; height: 50
color: "blue"
+
Text { text: "Drag"; anchors.centerIn: parent }
+
MouseArea {
+ anchors.fill: parent
drag.target: parent
drag.axis: "XAxis"
drag.minimumX: 0
drag.maximumX: 150
- onPressed: { console.log('press') }
- onReleased: { console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') }
- onClicked: { console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')') }
- onDoubleClicked: { console.log('double click') }
- onPressAndHold: { console.log('press and hold') }
- anchors.fill: parent
+
+ onPressed: console.log('press')
+ onReleased: console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')')
+ onClicked: console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')')
+ onDoubleClicked: console.log('double click')
+ onPressAndHold: console.log('press and hold')
}
}
}
diff --git a/examples/declarative/progressbar/content/ProgressBar.qml b/examples/declarative/progressbar/content/ProgressBar.qml
index d82d89d..bc36df5 100644
--- a/examples/declarative/progressbar/content/ProgressBar.qml
+++ b/examples/declarative/progressbar/content/ProgressBar.qml
@@ -2,36 +2,42 @@ import Qt 4.7
Item {
id: progressbar
- width: 250; height: 23; clip: true
property int minimum: 0
property int maximum: 100
property int value: 0
- property alias color: g1.color
- property alias secondColor: g2.color
+ property alias color: gradient1.color
+ property alias secondColor: gradient2.color
+
+ width: 250; height: 23
+ clip: true
BorderImage {
source: "background.png"
width: parent.width; height: parent.height
- border.left: 4; border.top: 4; border.right: 4; border.bottom: 4
+ border { left: 4; top: 4; right: 4; bottom: 4 }
}
Rectangle {
+ id: highlight
+
property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6)
- id: highlight; radius: 1
- anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom
- anchors.leftMargin: 3; anchors.topMargin: 3; anchors.bottomMargin: 3
+
width: highlight.widthDest
Behavior on width { SmoothedAnimation { velocity: 1200 } }
+
+ anchors { left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 3; topMargin: 3; bottomMargin: 3 }
+ radius: 1
gradient: Gradient {
- GradientStop { id: g1; position: 0.0 }
- GradientStop { id: g2; position: 1.0 }
+ GradientStop { id: gradient1; position: 0.0 }
+ GradientStop { id: gradient2; position: 1.0 }
}
+
}
Text {
- anchors.right: highlight.right; anchors.rightMargin: 6
- color: "white"; font.bold: true
- anchors.verticalCenter: parent.verticalCenter
+ anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter }
+ color: "white"
+ font.bold: true
text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%'
}
}
diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml
index e10c9f0..55fd682 100644
--- a/examples/declarative/progressbar/progressbars.qml
+++ b/examples/declarative/progressbar/progressbars.qml
@@ -3,17 +3,26 @@ import "content"
Rectangle {
id: main
- width: 600; height: 405; color: "#edecec"
+
+ width: 600; height: 405
+ color: "#edecec"
Flickable {
- anchors.fill: parent; contentHeight: column.height + 20
+ anchors.fill: parent
+ contentHeight: column.height + 20
+
Column {
- id: column; x: 10; y: 10; spacing: 10
+ id: column
+ x: 10; y: 10
+ spacing: 10
+
Repeater {
model: 25
+
ProgressBar {
property int r: Math.floor(Math.random() * 5000 + 1000)
width: main.width - 20
+
NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite }
ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite }
ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite }
diff --git a/examples/declarative/proxywidgets/proxywidgets.qml b/examples/declarative/proxywidgets/proxywidgets.qml
index 6fa0c40..46dcf99 100644
--- a/examples/declarative/proxywidgets/proxywidgets.qml
+++ b/examples/declarative/proxywidgets/proxywidgets.qml
@@ -3,45 +3,62 @@ import "ProxyWidgets" 1.0
Rectangle {
id: window
- width: 640; height: 480; color: palette.window
property int margin: 30
+ width: 640; height: 480
+ color: palette.window
+
SystemPalette { id: palette }
MyPushButton {
- id: button1; x: margin; y: margin; text: "Right"; onClicked: window.state = "right"
+ id: button1
+ x: margin; y: margin
+ text: "Right"
transformOriginPoint: Qt.point(width / 2, height / 2)
+
+ onClicked: window.state = "right"
}
MyPushButton {
- id: button2; x: margin; y: margin + 30; text: "Bottom"; onClicked: window.state = "bottom"
+ id: button2
+ x: margin; y: margin + 30
+ text: "Bottom"
transformOriginPoint: Qt.point(width / 2, height / 2)
+
+ onClicked: window.state = "bottom"
}
MyPushButton {
- id: button3; x: margin; y: margin + 60; text: "Quit"; onClicked: Qt.quit()
+ id: button3
+ x: margin; y: margin + 60
+ text: "Quit"
transformOriginPoint: Qt.point(width / 2, height / 2)
+
+ onClicked: Qt.quit()
}
states: [
- State {
- name: "right"
- PropertyChanges { target: button1; x: window.width - width - margin; text: "Left"; onClicked: window.state = "" }
- PropertyChanges { target: button2; x: window.width - width - margin }
- PropertyChanges { target: button3; x: window.width - width - margin }
- PropertyChanges { target: window; color: Qt.darker(palette.window) }
- },
- State {
- name: "bottom"
- PropertyChanges { target: button1; y: window.height - height - margin; rotation: 180 }
- PropertyChanges {
- target: button2; x: button1.x + button1.width + 10; y: window.height - height - margin; rotation: 180
- text: "Top"; onClicked: window.state = ""
+ State {
+ name: "right"
+ PropertyChanges { target: button1; x: window.width - width - margin; text: "Left"; onClicked: window.state = "" }
+ PropertyChanges { target: button2; x: window.width - width - margin }
+ PropertyChanges { target: button3; x: window.width - width - margin }
+ PropertyChanges { target: window; color: Qt.darker(palette.window) }
+ },
+ State {
+ name: "bottom"
+ PropertyChanges { target: button1; y: window.height - height - margin; rotation: 180 }
+ PropertyChanges {
+ target: button2
+ x: button1.x + button1.width + 10; y: window.height - height - margin
+ rotation: 180
+ text: "Top"
+ onClicked: window.state = ""
+ }
+ PropertyChanges { target: button3; x: button2.x + button2.width + 10; y: window.height - height - margin; rotation: 180 }
+ PropertyChanges { target: window; color: Qt.lighter(palette.window) }
}
- PropertyChanges { target: button3; x: button2.x + button2.width + 10; y: window.height - height - margin; rotation: 180 }
- PropertyChanges { target: window; color: Qt.lighter(palette.window) }
- }
]
transitions: Transition {
diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml
index 2186b35..5433156 100644
--- a/examples/declarative/scrollbar/ScrollBar.qml
+++ b/examples/declarative/scrollbar/ScrollBar.qml
@@ -2,6 +2,7 @@ import Qt 4.7
Item {
id: scrollBar
+
// The properties that define the scrollbar's state.
// position and pageSize are in the range 0.0 - 1.0. They are relative to the
// height of the page, i.e. a pageSize of 0.5 means that you can see 50%
@@ -14,18 +15,19 @@ Item {
// A light, semi-transparent background
Rectangle {
id: background
- radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
- color: "white"; opacity: 0.3
anchors.fill: parent
+ radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
+ color: "white"
+ opacity: 0.3
}
// Size the bar to the required size, depending upon the orientation.
Rectangle {
- opacity: 0.7
- color: "black"
- radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1)
y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1
width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2))
height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2)
+ radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
+ color: "black"
+ opacity: 0.7
}
}
diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml
index 421cb7f..cb1da16 100644
--- a/examples/declarative/scrollbar/display.qml
+++ b/examples/declarative/scrollbar/display.qml
@@ -3,56 +3,52 @@ import Qt 4.7
Rectangle {
width: 640
height: 480
+
// Create a flickable to view a large image.
Flickable {
id: view
anchors.fill: parent
+ contentWidth: picture.width
+ contentHeight: picture.height
+
Image {
id: picture
source: "pics/niagara_falls.jpg"
asynchronous: true
}
- contentWidth: picture.width
- contentHeight: picture.height
+
// Only show the scrollbars when the view is moving.
- states: [
- State {
- name: "ShowBars"
- when: view.moving
- PropertyChanges { target: verticalScrollBar; opacity: 1 }
- PropertyChanges { target: horizontalScrollBar; opacity: 1 }
- }
- ]
- transitions: [
- Transition {
- from: "*"
- to: "*"
- NumberAnimation {
- properties: "opacity"
- duration: 400
- }
- }
- ]
+ states: State {
+ name: "ShowBars"
+ when: view.moving
+ PropertyChanges { target: verticalScrollBar; opacity: 1 }
+ PropertyChanges { target: horizontalScrollBar; opacity: 1 }
+ }
+
+ transitions: Transition {
+ from: "*"; to: "*"
+ NumberAnimation { properties: "opacity"; duration: 400 }
+ }
}
+
// Attach scrollbars to the right and bottom edges of the view.
ScrollBar {
id: verticalScrollBar
+ width: 12; height: view.height-12
+ anchors.right: view.right
opacity: 0
orientation: "Vertical"
position: view.visibleArea.yPosition
pageSize: view.visibleArea.heightRatio
- width: 12
- height: view.height-12
- anchors.right: view.right
}
+
ScrollBar {
id: horizontalScrollBar
+ width: view.width-12; height: 12
+ anchors.bottom: view.bottom
opacity: 0
orientation: "Horizontal"
position: view.visibleArea.xPosition
pageSize: view.visibleArea.widthRatio
- height: 12
- width: view.width-12
- anchors.bottom: view.bottom
}
}
diff --git a/examples/declarative/searchbox/SearchBox.qml b/examples/declarative/searchbox/SearchBox.qml
index be85023..aae7ee9 100644
--- a/examples/declarative/searchbox/SearchBox.qml
+++ b/examples/declarative/searchbox/SearchBox.qml
@@ -18,27 +18,32 @@ FocusScope {
}
Text {
- id: typeSomething; anchors.fill: parent; anchors.leftMargin: 8
+ id: typeSomething
+ anchors.fill: parent; anchors.leftMargin: 8
verticalAlignment: Text.AlignVCenter
- text: "Type something..."; color: "gray"; font.italic: true
+ text: "Type something..."
+ color: "gray"
+ font.italic: true
}
MouseArea { anchors.fill: parent; onClicked: focusScope.focus = true }
TextInput {
id: textInput
- anchors.left: parent.left; anchors.leftMargin: 8
- anchors.verticalCenter: parent.verticalCenter
- focus: if (1) true
+ anchors { left: parent.left; leftMargin: 8; verticalCenter: parent.verticalCenter }
+ focus: true
}
Image {
id: clear
- anchors.right: parent.right; anchors.rightMargin: 8
- anchors.verticalCenter: parent.verticalCenter
- source: "images/edit-clear-locationbar-rtl.png"; opacity: 0
+ anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
+ source: "images/edit-clear-locationbar-rtl.png"
+ opacity: 0
- MouseArea { anchors.fill: parent; onClicked: { textInput.text = ''; focusScope.focus = true } }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { textInput.text = ''; focusScope.focus = true }
+ }
}
states: State {
diff --git a/examples/declarative/searchbox/main.qml b/examples/declarative/searchbox/main.qml
index eb95a23..9f73473 100644
--- a/examples/declarative/searchbox/main.qml
+++ b/examples/declarative/searchbox/main.qml
@@ -1,10 +1,12 @@
import Qt 4.7
Rectangle {
- width: 500; height: 250; color: "#edecec"
+ width: 500; height: 250
+ color: "#edecec"
Column {
- anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter; spacing: 10
+ anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter }
+ spacing: 10
SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true }
SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 }
diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml
index e16198d..a8fa6ef 100644
--- a/examples/declarative/slideswitch/content/Switch.qml
+++ b/examples/declarative/slideswitch/content/Switch.qml
@@ -31,14 +31,17 @@ Item {
//![4]
Image {
- id: background; source: "background.svg"
+ id: background
+ source: "background.svg"
MouseArea { anchors.fill: parent; onClicked: toggle() }
}
//![4]
//![5]
Image {
- id: knob; source: "knob.svg"; x: 1; y: 2
+ id: knob
+ x: 1; y: 2
+ source: "knob.svg"
MouseArea {
anchors.fill: parent
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml
index a9f77ca..8b021b7 100644
--- a/examples/declarative/sql/hello.qml
+++ b/examples/declarative/sql/hello.qml
@@ -1,6 +1,8 @@
import Qt 4.7
Text {
+ text: "?"
+
function findGreetings() {
var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000);
@@ -24,7 +26,6 @@ Text {
)
}
- text: "?"
Component.onCompleted: findGreetings()
}
diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml
index c35cd63..4429e78 100644
--- a/examples/declarative/states/states.qml
+++ b/examples/declarative/states/states.qml
@@ -2,49 +2,60 @@ import Qt 4.7
Rectangle {
id: page
- width: 640; height: 480; color: "#343434"
+ width: 640; height: 480
+ color: "#343434"
+
+ Image {
+ id: userIcon
+ x: topLeftRect.x; y: topLeftRect.y
+ source: "user.png"
+ }
- // A target region. Clicking in here sets the state to the default state
Rectangle {
- id: initialPosition
+ id: topLeftRect
+
anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
- width: 64; height: 64; radius: 6
- color: "Transparent"; border.color: "Gray"
+ width: 64; height: 64
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to the default state, returning the image to
+ // its initial position
MouseArea { anchors.fill: parent; onClicked: page.state = '' }
}
- // Another target region. Clicking in here sets the state to 'Position1'
Rectangle {
- id: position1
+ id: middleRightRect
+
anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
- width: 64; height: 64; radius: 6
- color: "Transparent"; border.color: "Gray"
- MouseArea { anchors.fill: parent; onClicked: page.state = 'Position1' }
+ width: 64; height: 64
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'middleRight'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' }
}
- // Another target region. Clicking in here sets the state to 'Position2'
Rectangle {
- id: position2
+ id: bottomLeftRect
+
anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
- width: 64; height: 64; radius: 6
- color: "Transparent"; border.color: "Gray"
- MouseArea { anchors.fill: parent; onClicked: page.state = 'Position2' }
- }
+ width: 64; height: 64
+ color: "Transparent"; border.color: "Gray"; radius: 6
- // The image which will be moved when my state changes
- Image { id: user; source: "user.png"; x: initialPosition.x; y: initialPosition.y }
+ // Clicking in here sets the state to 'bottomLeft'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' }
+ }
states: [
- // In state 'Position1', change the 'user' item position to rect2's position.
+ // In state 'middleRight', move the image to middleRightRect
State {
- name: "Position1"
- PropertyChanges { target: user; x: position1.x; y: position1.y }
+ name: "middleRight"
+ PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y }
},
- // In state 'Position2', change the 'user' item position to rect3's position.
+ // In state 'bottomLeft', move the image to bottomLeftRect
State {
- name: "Position2"
- PropertyChanges { target: user; x: position2.x; y: position2.y }
+ name: "bottomLeft"
+ PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y }
}
]
}
diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml
index 3cb5543..d1b1dd6 100644
--- a/examples/declarative/states/transitions.qml
+++ b/examples/declarative/states/transitions.qml
@@ -1,67 +1,87 @@
import Qt 4.7
+/*
+ This is exactly the same as states.qml, except that we have appended
+ a set of transitions to apply animations when the item changes
+ between each state.
+*/
+
Rectangle {
id: page
- width: 640; height: 480; color: "#343434"
+ width: 640; height: 480
+ color: "#343434"
+
+ Image {
+ id: userIcon
+ x: topLeftRect.x; y: topLeftRect.y
+ source: "user.png"
+ }
- // A target region. Clicking in here sets the state to the default state
Rectangle {
- id: initialPosition
+ id: topLeftRect
+
anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
- width: 64; height: 64; radius: 6
- color: "Transparent"; border.color: "Gray"
+ width: 64; height: 64
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to the default state, returning the image to
+ // its initial position
MouseArea { anchors.fill: parent; onClicked: page.state = '' }
}
- // Another target region. Clicking in here sets the state to 'Position1'
Rectangle {
- id: position1
+ id: middleRightRect
+
anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
- width: 64; height: 64; radius: 6
- color: "Transparent"; border.color: "Gray"
- MouseArea { anchors.fill: parent; onClicked: page.state = 'Position1' }
+ width: 64; height: 64
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'middleRight'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' }
}
- // Another target region. Clicking in here sets the state to 'Position2'
Rectangle {
- id: position2
+ id: bottomLeftRect
+
anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
- width: 64; height: 64; radius: 6
- color: "Transparent"; border.color: "Gray"
- MouseArea { anchors.fill: parent; onClicked: page.state = 'Position2' }
- }
+ width: 64; height: 64
+ color: "Transparent"; border.color: "Gray"; radius: 6
- // The image which will be moved when my state changes
- Image { id: user; source: "user.png"; x: initialPosition.x; y: initialPosition.y }
+ // Clicking in here sets the state to 'bottomLeft'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' }
+ }
states: [
- // In state 'Position1', change the 'user' item position to rect2's position.
+ // In state 'middleRight', move the image to middleRightRect
State {
- name: "Position1"
- PropertyChanges { target: user; x: position1.x; y: position1.y }
+ name: "middleRight"
+ PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y }
},
- // In state 'Position2', change the 'user' item position to rect3's position.
+ // In state 'bottomLeft', move the image to bottomLeftRect
State {
- name: "Position2"
- PropertyChanges { target: user; x: position2.x; y: position2.y }
+ name: "bottomLeft"
+ PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y }
}
]
- // transitions define how the properties change.
+ // Transitions define how the properties change when the item moves between each state
transitions: [
- // When transitioning to 'Position1' move x,y over a duration of 1 second,
+
+ // When transitioning to 'middleRight' move x,y over a duration of 1 second,
// with OutBounce easing function.
Transition {
- from: "*"; to: "Position1"
+ from: "*"; to: "middleRight"
NumberAnimation { properties: "x,y"; easing.type: "OutBounce"; duration: 1000 }
},
- // When transitioning to 'Position2' move x,y over a duration of 2 seconds,
+
+ // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds,
// with InOutQuad easing function.
Transition {
- from: "*"; to: "Position2"
+ from: "*"; to: "bottomLeft"
NumberAnimation { properties: "x,y"; easing.type: "InOutQuad"; duration: 2000 }
},
+
// For any other state changes move x,y linearly over duration of 200ms.
Transition {
NumberAnimation { properties: "x,y"; duration: 200 }
diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml
index e6b40fd..26d25b4 100644
--- a/examples/declarative/tabwidget/TabWidget.qml
+++ b/examples/declarative/tabwidget/TabWidget.qml
@@ -2,6 +2,7 @@ import Qt 4.7
Item {
id: tabWidget
+
property int current: 0
default property alias content: stack.children
@@ -18,21 +19,26 @@ Item {
Row {
id: header
Repeater {
- delegate:
- Rectangle {
+ delegate: Rectangle {
width: tabWidget.width / stack.children.length; height: 36
+
Rectangle {
- color: "#acb2c2"; width: parent.width; height: 1
+ width: parent.width; height: 1
anchors { bottom: parent.bottom; bottomMargin: 1 }
+ color: "#acb2c2"
}
BorderImage {
- source: "tab.png"; visible: tabWidget.current == index; border.left: 7; border.right: 7
anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 }
+ border { left: 7; right: 7 }
+ source: "tab.png"
+ visible: tabWidget.current == index
}
Text {
horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter
- anchors.fill: parent; text: stack.children[index].title
- elide: Text.ElideRight; font.bold: tabWidget.current == index
+ anchors.fill: parent
+ text: stack.children[index].title
+ elide: Text.ElideRight
+ font.bold: tabWidget.current == index
}
MouseArea {
anchors.fill: parent
@@ -45,6 +51,7 @@ Item {
Item {
id: stack
- anchors.top: header.bottom; anchors.bottom: tabWidget.bottom; width: tabWidget.width
+ width: tabWidget.width
+ anchors.top: header.bottom; anchors.bottom: tabWidget.bottom
}
}
diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml
index e1bbdef..fba203c 100644
--- a/examples/declarative/tabwidget/tabs.qml
+++ b/examples/declarative/tabwidget/tabs.qml
@@ -6,28 +6,36 @@ TabWidget {
Rectangle {
property string title: "Red"
- anchors.fill: parent; color: "#e3e3e3"
+ anchors.fill: parent
+ color: "#e3e3e3"
+
Rectangle {
anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
color: "#ff7f7f"
Text {
+ width: parent.width - 20
anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
- text: "Roses are red"; font.pixelSize: 20
- wrapMode: Text.WordWrap; width: parent.width - 20
+ text: "Roses are red"
+ font.pixelSize: 20
+ wrapMode: Text.WordWrap
}
}
}
Rectangle {
property string title: "Green"
- anchors.fill: parent; color: "#e3e3e3"
+ anchors.fill: parent
+ color: "#e3e3e3"
+
Rectangle {
anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
color: "#7fff7f"
Text {
+ width: parent.width - 20
anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
- text: "Flower stems are green"; font.pixelSize: 20
- wrapMode: Text.WordWrap; width: parent.width - 20
+ text: "Flower stems are green"
+ font.pixelSize: 20
+ wrapMode: Text.WordWrap
}
}
}
@@ -35,13 +43,16 @@ TabWidget {
Rectangle {
property string title: "Blue"
anchors.fill: parent; color: "#e3e3e3"
+
Rectangle {
anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
color: "#7f7fff"
Text {
+ width: parent.width - 20
anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
- text: "Violets are blue"; font.pixelSize: 20
- wrapMode: Text.WordWrap; width: parent.width - 20
+ text: "Violets are blue"
+ font.pixelSize: 20
+ wrapMode: Text.WordWrap
}
}
}
diff --git a/examples/declarative/tic-tac-toe/content/Button.qml b/examples/declarative/tic-tac-toe/content/Button.qml
index 05d3f8d..ecf18cd 100644
--- a/examples/declarative/tic-tac-toe/content/Button.qml
+++ b/examples/declarative/tic-tac-toe/content/Button.qml
@@ -3,33 +3,35 @@ import Qt 4.7
Rectangle {
id: container
- signal clicked
property string text: "Button"
property bool down: false
property string mainCol: "lightgray"
property string darkCol: "darkgray"
property string lightCol: "white"
- color: mainCol; smooth: true
- width: txtItem.width + 20; height: txtItem.height + 6
- border.width: 1; border.color: Qt.darker(mainCol); radius: 8;
+ width: buttonLabel.width + 20; height: buttonLabel.height + 6
+ border { width: 1; color: Qt.darker(mainCol) }
+ radius: 8;
+ color: mainCol
+ smooth: true
gradient: Gradient {
GradientStop {
id: topGrad; position: 0.0
- color: if (container.down) { darkCol } else { lightCol } }
+ color: if (container.down) { darkCol } else { lightCol }
+ }
GradientStop { position: 1.0; color: mainCol }
}
+ signal clicked
+
MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
Text {
- id: txtItem; text: container.text;
+ id: buttonLabel
+
anchors.centerIn: container
- color: "blue"
- styleColor: "white"
- style: Text.Outline
+ text: container.text;
font.pixelSize: 14
- font.bold: true
}
}
diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/tic-tac-toe/tic-tac-toe.qml
index ca66a46..dd13052 100644
--- a/examples/declarative/tic-tac-toe/tic-tac-toe.qml
+++ b/examples/declarative/tic-tac-toe/tic-tac-toe.qml
@@ -4,23 +4,23 @@ import "content/tic-tac-toe.js" as Logic
Item {
id: game
- property bool show: false;
+
+ property bool show: false
+ property real difficulty: 1.0 //chance it will actually think
+
width: 440
height: 480
anchors.fill: parent
- property real difficulty: 1.0; //chance it will actually think
Image {
id: boardimage
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.horizontalCenter
+ anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.horizontalCenter }
source: "content/pics/board.png"
}
Grid {
id: board
anchors.fill: boardimage
-
columns: 3
Repeater {
@@ -46,33 +46,32 @@ Item {
Row {
spacing: 4
- anchors.top: board.bottom
- anchors.horizontalCenter: board.horizontalCenter
+ anchors { top: board.bottom; horizontalCenter: board.horizontalCenter }
+
Button {
text: "Hard"
- onClicked: game.difficulty=1.0;
+ onClicked: game.difficulty = 1.0;
down: game.difficulty == 1.0
}
Button {
text: "Moderate"
- onClicked: game.difficulty=0.8;
+ onClicked: game.difficulty = 0.8;
down: game.difficulty == 0.8
}
Button {
text: "Easy"
- onClicked: game.difficulty=0.2;
+ onClicked: game.difficulty = 0.2;
down: game.difficulty == 0.2
}
}
Text {
id: msg
- opacity: 0
+
anchors.centerIn: parent
+ opacity: 0
color: "blue"
- styleColor: "white"
- style: Text.Outline
- font.pixelSize: 50
- font.bold: true
+ style: Text.Outline; styleColor: "white"
+ font.pixelSize: 50; font.bold: true
}
}
diff --git a/examples/declarative/tutorials/samegame/samegame1/Block.qml b/examples/declarative/tutorials/samegame/samegame1/Block.qml
index 7cf819b..a535235 100644
--- a/examples/declarative/tutorials/samegame/samegame1/Block.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/Block.qml
@@ -2,11 +2,12 @@
import Qt 4.7
Item {
- id:block
+ id: block
- Image { id: img
- source: "../shared/pics/redStone.png";
+ Image {
+ id: img
anchors.fill: parent
+ source: "../shared/pics/redStone.png";
}
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml
index 8ad7c0f..e8034ac 100644
--- a/examples/declarative/tutorials/samegame/samegame1/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml
@@ -4,25 +4,31 @@ import Qt 4.7
Rectangle {
id: container
- signal clicked
property string text: "Button"
- color: activePalette.button; smooth: true
+ signal clicked
+
width: buttonLabel.width + 20; height: buttonLabel.height + 6
- border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+ smooth: true
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ radius: 8
+ // color the button with a gradient
gradient: Gradient {
GradientStop {
position: 0.0
- color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light }
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
}
GradientStop { position: 1.0; color: activePalette.button }
}
MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
- Text {
- id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
- }
+ Text { id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText }
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
index ae881ba..b6e01fd 100644
--- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
@@ -3,37 +3,40 @@ import Qt 4.7
Rectangle {
id: screen
+
width: 490; height: 720
SystemPalette { id: activePalette }
Item {
- width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
Image {
id: background
- anchors.fill: parent; source: "../shared/pics/background.jpg"
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
fillMode: Image.PreserveAspectCrop
}
}
Rectangle {
- id: toolbar
+ id: toolBar
+ width: parent.width; height: 32
color: activePalette.window
- height: 32; width: parent.width
anchors.bottom: screen.bottom
Button {
- text: "New Game"; onClicked: console.log("Starting a new game...");
- anchors.left: parent.left; anchors.leftMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: console.log("This doesn't do anything yet...")
}
Text {
id: score
- text: "Score: Who knows?"; font.bold: true
- anchors.right: parent.right; anchors.rightMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ font.bold: true
}
}
}
diff --git a/examples/declarative/tutorials/samegame/samegame2/Block.qml b/examples/declarative/tutorials/samegame/samegame2/Block.qml
index 44ff5d7..88b3d79 100644
--- a/examples/declarative/tutorials/samegame/samegame2/Block.qml
+++ b/examples/declarative/tutorials/samegame/samegame2/Block.qml
@@ -1,10 +1,11 @@
import Qt 4.7
Item {
- id:block
+ id: block
- Image { id: img
- source: "../shared/pics/redStone.png";
+ Image {
+ id: img
anchors.fill: parent
+ source: "../shared/pics/redStone.png";
}
}
diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml
index cf4c61b..8d322de5 100644
--- a/examples/declarative/tutorials/samegame/samegame2/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml
@@ -3,24 +3,30 @@ import Qt 4.7
Rectangle {
id: container
- signal clicked
property string text: "Button"
- color: activePalette.button; smooth: true
+ signal clicked
+
width: buttonLabel.width + 20; height: buttonLabel.height + 6
- border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+ smooth: true
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ radius: 8
+ // color the button with a gradient
gradient: Gradient {
GradientStop {
position: 0.0
- color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light }
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
}
GradientStop { position: 1.0; color: activePalette.button }
}
MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
- Text {
- id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
- }
+ Text { id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText }
}
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
index e0706c2..7a17d16 100644
--- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
@@ -5,39 +5,42 @@ import "samegame.js" as SameGame
Rectangle {
id: screen
+
width: 490; height: 720
SystemPalette { id: activePalette }
Item {
- width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
Image {
id: background
- anchors.fill: parent; source: "../shared/pics/background.jpg"
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
fillMode: Image.PreserveAspectCrop
}
}
Rectangle {
- id: toolbar
+ id: toolBar
+ width: parent.width; height: 32
color: activePalette.window
- height: 32; width: parent.width
anchors.bottom: screen.bottom
//![1]
Button {
- text: "New Game"; onClicked: SameGame.startNewGame();
- anchors.left: parent.left; anchors.leftMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
}
//![1]
Text {
id: score
- text: "Score: Who knows?"; font.bold: true
- anchors.right: parent.right; anchors.rightMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ font.bold: true
}
}
}
diff --git a/examples/declarative/tutorials/samegame/samegame3/Block.qml b/examples/declarative/tutorials/samegame/samegame3/Block.qml
index bb48ac8..dd0fb48 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Block.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Block.qml
@@ -2,20 +2,22 @@
import Qt 4.7
Item {
- id:block
+ id: block
+
property int type: 0
- Image { id: img
+ Image {
+ id: img
+
+ anchors.fill: parent
source: {
- if(type == 0){
- "../shared/pics/redStone.png";
- } else if(type == 1) {
- "../shared/pics/blueStone.png";
- } else {
- "../shared/pics/greenStone.png";
- }
+ if (type == 0)
+ return "../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../shared/pics/blueStone.png";
+ else
+ return "../shared/pics/greenStone.png";
}
- anchors.fill: parent
}
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml
index cf4c61b..8d322de5 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml
@@ -3,24 +3,30 @@ import Qt 4.7
Rectangle {
id: container
- signal clicked
property string text: "Button"
- color: activePalette.button; smooth: true
+ signal clicked
+
width: buttonLabel.width + 20; height: buttonLabel.height + 6
- border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+ smooth: true
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ radius: 8
+ // color the button with a gradient
gradient: Gradient {
GradientStop {
position: 0.0
- color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light }
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
}
GradientStop { position: 1.0; color: activePalette.button }
}
MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
- Text {
- id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
- }
+ Text { id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText }
}
diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
index a76b517..be3a7b7 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
@@ -3,21 +3,30 @@ import Qt 4.7
Rectangle {
id: page
+
+ signal closed
+
function forceClose() {
page.closed();
page.opacity = 0;
}
+
function show(txt) {
dialogText.text = txt;
page.opacity = 1;
}
- signal closed();
- color: "white"; border.width: 1; width: dialogText.width + 20; height: dialogText.height + 20;
+
+ width: dialogText.width + 20; height: dialogText.height + 20
+ color: "white"
+ border.width: 1
opacity: 0
+
Behavior on opacity {
NumberAnimation { duration: 1000 }
}
+
Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
+
MouseArea { anchors.fill: parent; onClicked: forceClose(); }
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
index cdf99d7..bc5f2f8 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
@@ -4,31 +4,37 @@ import "samegame.js" as SameGame
Rectangle {
id: screen
+
width: 490; height: 720
SystemPalette { id: activePalette }
Item {
- width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
Image {
id: background
- anchors.fill: parent; source: "../shared/pics/background.jpg"
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
fillMode: Image.PreserveAspectCrop
}
//![1]
Item {
id: gameCanvas
+
property int score: 0
property int blockSize: 40
- z: 20; anchors.centerIn: parent
- width: parent.width - (parent.width % blockSize);
- height: parent.height - (parent.height % blockSize);
+ width: parent.width - (parent.width % blockSize)
+ height: parent.height - (parent.height % blockSize)
+ anchors.centerIn: parent
+ z: 20
MouseArea {
- anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y);
+ anchors.fill: parent
+ onClicked: SameGame.handleClick(mouse.x, mouse.y)
}
}
//![1]
@@ -39,22 +45,22 @@ Rectangle {
//![2]
Rectangle {
- id: toolbar
+ id: toolBar
+ width: parent.width; height: 32
color: activePalette.window
- height: 32; width: parent.width
anchors.bottom: screen.bottom
Button {
- text: "New Game"; onClicked: SameGame.startNewGame();
- anchors.left: parent.left; anchors.leftMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
}
Text {
id: score
- text: "Score: " + gameCanvas.score; font.bold: true
- anchors.right: parent.right; anchors.rightMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ font.bold: true
}
}
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
index 243df75..d3a9df7 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
@@ -1,9 +1,12 @@
import Qt 4.7
import Qt.labs.particles 1.0
-Item { id:block
+Item {
+ id: block
+
property int type: 0
property bool dying: false
+
//![1]
property bool spawned: false
property int targetX: 0
@@ -14,47 +17,59 @@ Item { id:block
//![1]
//![2]
- Image { id: img
+ Image {
+ id: img
+
+ anchors.fill: parent
source: {
- if(type == 0){
- "../../shared/pics/redStone.png";
- } else if(type == 1) {
- "../../shared/pics/blueStone.png";
- } else {
- "../../shared/pics/greenStone.png";
- }
+ if (type == 0)
+ return "../../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStone.png";
+ else
+ return "../../shared/pics/greenStone.png";
}
opacity: 0
- Behavior on opacity { NumberAnimation { properties:"opacity"; duration: 200 } }
- anchors.fill: parent
+
+ Behavior on opacity {
+ NumberAnimation { properties:"opacity"; duration: 200 }
+ }
}
//![2]
//![3]
- Particles { id: particles
- width:1; height:1; anchors.centerIn: parent;
- emissionRate: 0;
- lifeSpan: 700; lifeSpanDeviation: 600;
+ Particles {
+ id: particles
+
+ width: 1; height: 1
+ anchors.centerIn: parent
+
+ emissionRate: 0
+ lifeSpan: 700; lifeSpanDeviation: 600
angle: 0; angleDeviation: 360;
- velocity: 100; velocityDeviation:30;
+ velocity: 100; velocityDeviation: 30
source: {
- if(type == 0){
- "../../shared/pics/redStar.png";
- } else if (type == 1) {
- "../../shared/pics/blueStar.png";
- } else {
- "../../shared/pics/greenStar.png";
- }
+ if (type == 0)
+ return "../../shared/pics/redStar.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStar.png";
+ else
+ return "../../shared/pics/greenStar.png";
}
}
//![3]
//![4]
states: [
- State{ name: "AliveState"; when: spawned == true && dying == false
+ State {
+ name: "AliveState"
+ when: spawned == true && dying == false
PropertyChanges { target: img; opacity: 1 }
},
- State{ name: "DeathState"; when: dying == true
+
+ State {
+ name: "DeathState"
+ when: dying == true
StateChangeScript { script: particles.burst(50); }
PropertyChanges { target: img; opacity: 0 }
StateChangeScript { script: block.destroy(1000); }
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
index cf4c61b..8d322de5 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
@@ -3,24 +3,30 @@ import Qt 4.7
Rectangle {
id: container
- signal clicked
property string text: "Button"
- color: activePalette.button; smooth: true
+ signal clicked
+
width: buttonLabel.width + 20; height: buttonLabel.height + 6
- border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+ smooth: true
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ radius: 8
+ // color the button with a gradient
gradient: Gradient {
GradientStop {
position: 0.0
- color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light }
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
}
GradientStop { position: 1.0; color: activePalette.button }
}
MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
- Text {
- id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
- }
+ Text { id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText }
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
index 15f5b19..adb3f9e 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
@@ -2,20 +2,29 @@ import Qt 4.7
Rectangle {
id: page
+
+ signal closed
+
function forceClose() {
page.closed();
page.opacity = 0;
}
+
function show(txt) {
dialogText.text = txt;
page.opacity = 1;
}
- signal closed();
- color: "white"; border.width: 1; width: dialogText.width + 20; height: dialogText.height + 20;
+
+ width: dialogText.width + 20; height: dialogText.height + 20
+ color: "white"
+ border.width: 1
opacity: 0
+
Behavior on opacity {
NumberAnimation { duration: 1000 }
}
+
Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
+
MouseArea { anchors.fill: parent; onClicked: forceClose(); }
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
index 47985de..7800b6e 100755
--- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
@@ -13,8 +13,8 @@ function index(column, row) {
}
function startNewGame() {
+ //Delete blocks from previous game
for (var i = 0; i < maxIndex; i++) {
- //Delete blocks from previous game
if (board[i] != null)
board[i].destroy();
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
index 5d5c81f..b2a490d 100644
--- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
@@ -4,16 +4,19 @@ import "content/samegame.js" as SameGame
Rectangle {
id: screen
+
width: 490; height: 720
SystemPalette { id: activePalette }
Item {
- width: parent.width; anchors.top: parent.top; anchors.bottom: toolBar.top
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
Image {
id: background
- anchors.fill: parent; source: "../shared/pics/background.jpg"
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
fillMode: Image.PreserveAspectCrop
}
@@ -36,43 +39,49 @@ Rectangle {
//![0]
Dialog {
- id: nameInputDialog; anchors.centerIn: parent; z: 22;
+ id: nameInputDialog
+
+ anchors.centerIn: parent
+ z: 22
+
Text {
- id: spacer
+ id: dialogText
opacity: 0
text: " You won! Please enter your name:"
}
+
TextInput {
- id: editor
+ id: nameInput
+ width: 72
+ anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
+ focus: true
+
onAccepted: {
- if(nameInputDialog.opacity==1&&editor.text!="")
- SameGame.saveHighScore(editor.text);
+ if (nameInputDialog.opacity == 1 && nameInput.text != "")
+ SameGame.saveHighScore(nameInput.text);
nameInputDialog.forceClose();
}
- anchors.verticalCenter: parent.verticalCenter
- width: 72; focus: true
- anchors.left: spacer.right
}
}
//![0]
Rectangle {
id: toolBar
+ width: parent.width; height: 32
color: activePalette.window
- height: 32; width: parent.width
anchors.bottom: screen.bottom
Button {
- text: "New Game"; onClicked: SameGame.startNewGame();
- anchors.left: parent.left; anchors.leftMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
}
Text {
id: score
- text: "Score: " + gameCanvas.score; font.bold: true
- anchors.right: parent.right; anchors.rightMargin: 3
- anchors.verticalCenter: parent.verticalCenter
+ anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "Score: " + gameCanvas.score
+ font.bold: true
}
}
}
diff --git a/examples/declarative/tvtennis/tvtennis.qml b/examples/declarative/tvtennis/tvtennis.qml
index 9d107ad..354a16f 100644
--- a/examples/declarative/tvtennis/tvtennis.qml
+++ b/examples/declarative/tvtennis/tvtennis.qml
@@ -8,13 +8,14 @@ Rectangle {
// Make a ball to bounce
Rectangle {
+ id: ball
+
// Add a property for the target y coordinate
property int targetY : page.height - 10
property variant direction : "right"
- id: ball
- color: "Lime"
x: 20; width: 20; height: 20; z: 1
+ color: "Lime"
SoundEffect { id: paddle; source: "paddle.wav" }
SoundEffect { id: wall; source: "click.wav" }
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index a39ec94..433295b 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -18,10 +18,11 @@ Component {
Repeater {
model: notes
Item {
+ id: stickyPage
+
property int randomX: Math.random() * 500 + 100
property int randomY: Math.random() * 200 + 50
- id: stickyPage
x: randomX; y: randomY
SpringFollow on rotation {
@@ -32,26 +33,32 @@ Component {
Item {
id: sticky
scale: 0.7
+
Image {
id: stickyImage
- source: "note-yellow.png"; transformOrigin: Item.TopLeft
- smooth: true; y: -20; x: 8 + -width * 0.6 / 2; scale: 0.6
+ x: 8 + -width * 0.6 / 2; y: -20
+ source: "note-yellow.png"
+ scale: 0.6; transformOrigin: Item.TopLeft
+ smooth: true
}
TextEdit {
- id: myText; smooth: true; font.pixelSize: 24
- readOnly: false; x: -104; y: 36
- rotation: -8; text: noteText; width: 215; height: 200
+ id: myText
+ x: -104; y: 36; width: 215; height: 200
+ smooth: true
+ font.pixelSize: 24
+ readOnly: false
+ rotation: -8
+ text: noteText
}
Item {
- y: -20
- x: stickyImage.x
+ x: stickyImage.x; y: -20
width: stickyImage.width * stickyImage.scale
height: stickyImage.height * stickyImage.scale
+
MouseArea {
id: mouse
- onClicked: { myText.focus = true }
anchors.fill: parent
drag.target: stickyPage
drag.axis: "XandYAxis"
@@ -59,13 +66,15 @@ Component {
drag.maximumY: page.height - 80
drag.minimumX: 100
drag.maximumX: page.width - 140
+ onClicked: { myText.focus = true }
}
}
}
Image {
- source: "tack.png"; transformOrigin: Item.TopLeft
- x: -width / 2; y: -height * 0.5 / 2; scale: 0.7
+ x: -width / 2; y: -height * 0.5 / 2
+ source: "tack.png"
+ scale: 0.7; transformOrigin: Item.TopLeft
}
states: State {
diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml
index 20821d6..871bafc 100644
--- a/examples/declarative/velocity/velocity.qml
+++ b/examples/declarative/velocity/velocity.qml
@@ -1,46 +1,75 @@
import Qt 4.7
Rectangle {
- width: 800; height: 480; color: "#464646"
+ width: 800; height: 480
+ color: "#464646"
ListModel {
id: list
+
ListElement {
name: "Sunday"
- notes: [ ListElement { noteText: "Lunch" }, ListElement { noteText: "Birthday Party" } ]
+ notes: [
+ ListElement { noteText: "Lunch" },
+ ListElement { noteText: "Birthday Party" }
+ ]
}
+
ListElement {
name: "Monday"
- notes: [ ListElement { noteText: "Pickup kids from\nschool\n4.30pm" },
- ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } ]
+ notes: [
+ ListElement { noteText: "Pickup kids from\nschool\n4.30pm" },
+ ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" }
+ ]
}
+
ListElement {
name: "Tuesday"
- notes: [ ListElement { noteText: "Walk dog" }, ListElement { noteText: "Buy newspaper" } ]
+ notes: [
+ ListElement { noteText: "Walk dog" },
+ ListElement { noteText: "Buy newspaper" }
+ ]
}
+
ListElement {
- name: "Wednesday"; notes: [ ListElement { noteText: "Cook dinner" } ]
+ name: "Wednesday"
+ notes: [ ListElement { noteText: "Cook dinner" } ]
}
+
ListElement {
name: "Thursday"
- notes: [ ListElement { noteText: "Meeting\n5.30pm" }, ListElement { noteText: "Weed garden" } ]
+ notes: [
+ ListElement { noteText: "Meeting\n5.30pm" },
+ ListElement { noteText: "Weed garden" }
+ ]
}
+
ListElement {
name: "Friday"
- notes: [ ListElement { noteText: "More work" }, ListElement { noteText: "Grocery shopping" } ]
+ notes: [
+ ListElement { noteText: "More work" },
+ ListElement { noteText: "Grocery shopping" }
+ ]
}
+
ListElement {
name: "Saturday"
- notes: [ ListElement { noteText: "Drink" }, ListElement { noteText: "Download Qt\nPlay with QML" } ]
+ notes: [
+ ListElement { noteText: "Drink" },
+ ListElement { noteText: "Download Qt\nPlay with QML" }
+ ]
}
}
ListView {
id: flickable
- anchors.fill: parent; focus: true
- model: list; delegate: Day { }
+
+ anchors.fill: parent
+ focus: true
highlightRangeMode: ListView.StrictlyEnforceRange
orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
+ model: list
+ delegate: Day { }
}
}
diff --git a/examples/declarative/webview/alerts.qml b/examples/declarative/webview/alerts.qml
index 2ba4300..6a5a0d2 100644
--- a/examples/declarative/webview/alerts.qml
+++ b/examples/declarative/webview/alerts.qml
@@ -3,17 +3,17 @@ import org.webkit 1.0
WebView {
id: webView
- onAlert: popup.show(message)
width: 120
height: 150
url: "alerts.html"
+ onAlert: popup.show(message)
+
Rectangle {
id: popup
color: "red"
- border.color: "black"
- border.width: 2
+ border.color: "black"; border.width: 2
radius: 4
y: parent.height // off "screen"
diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml
index c4a502e..9632883 100644
--- a/examples/declarative/webview/autosize.qml
+++ b/examples/declarative/webview/autosize.qml
@@ -5,15 +5,16 @@ import org.webkit 1.0
// preferredWidth, and preferredHeight properties.
Rectangle {
id: rect
- color: "white"
width: 200
height: layout.height
+
Column {
id: layout
spacing: 2
WebView {
html: "No width defined."
- Rectangle { color: "#10000000"
+ Rectangle {
+ color: "#10000000"
anchors.fill: parent
}
}
diff --git a/examples/declarative/webview/googleMaps.qml b/examples/declarative/webview/googleMaps.qml
index 4702dea..5506012 100644
--- a/examples/declarative/webview/googleMaps.qml
+++ b/examples/declarative/webview/googleMaps.qml
@@ -14,15 +14,15 @@ Map {
width: 300
height: 300
address: "Paris"
+
Rectangle {
- color: "white"
+ x: 70
width: input.width + 20
height: input.height + 4
+ anchors.bottom: parent.bottom; anchors.bottomMargin: 5
radius: 5
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 5
opacity: map.status == "Ready" ? 1 : 0
- x: 70
+
TextInput {
id: input
text: map.address
@@ -30,12 +30,14 @@ Map {
Keys.onReturnPressed: map.address = input.text
}
}
+
Text {
id: loading
anchors.centerIn: parent
text: map.status == "Error" ? "Error" : "Loading"
opacity: map.status == "Ready" ? 0 : 1
font.pixelSize: 30
- Behavior on opacity {NumberAnimation{}}
+
+ Behavior on opacity { NumberAnimation{} }
}
}
diff --git a/examples/declarative/webview/transparent.qml b/examples/declarative/webview/transparent.qml
index a0676f4..e4efc31 100644
--- a/examples/declarative/webview/transparent.qml
+++ b/examples/declarative/webview/transparent.qml
@@ -7,6 +7,7 @@ Rectangle {
color: "green"
width: web.width
height: web.height
+
WebView {
id: web
html: "Hello <b>World!</b>"
diff --git a/examples/declarative/workerscript/workerscript.qml b/examples/declarative/workerscript/workerscript.qml
index 1c7a920..6c6253b 100644
--- a/examples/declarative/workerscript/workerscript.qml
+++ b/examples/declarative/workerscript/workerscript.qml
@@ -1,7 +1,7 @@
import Qt 4.7
Rectangle {
- width: 480; height: 320;
+ width: 480; height: 320
WorkerScript {
id: myWorker
@@ -16,8 +16,7 @@ Rectangle {
Rectangle {
width: 200; height: 200
- anchors.left: parent.left
- anchors.leftMargin: 20
+ anchors.left: parent.left; anchors.leftMargin: 20
color: "red"
MouseArea {
@@ -28,8 +27,7 @@ Rectangle {
Rectangle {
width: 200; height: 200
- anchors.right: parent.right
- anchors.rightMargin: 20
+ anchors.right: parent.right; anchors.rightMargin: 20
color: "blue"
MouseArea {
@@ -40,8 +38,6 @@ Rectangle {
Text {
text: "Click a Rectangle!"
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 50
+ anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 }
}
}
diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml
index c5732c0..a1df809 100644
--- a/examples/declarative/xmldata/daringfireball.qml
+++ b/examples/declarative/xmldata/daringfireball.qml
@@ -24,15 +24,17 @@ Rectangle {
text: title; font.bold: true
}
Text {
+ anchors { left: titleText.right; leftMargin: 10 }
text: 'by ' + tagline
- anchors.left: titleText.right; anchors.leftMargin: 10
font.italic: true
}
Text {
x: 10
- text: content
+ width: 580
anchors.top: titleText.bottom
- width: 580; wrapMode: Text.WordWrap
+ text: content
+ wrapMode: Text.WordWrap
+
onLinkActivated: { console.log('link clicked: ' + link) }
}
}
@@ -40,6 +42,7 @@ Rectangle {
ListView {
anchors.fill: parent
- model: feedModel; delegate: feedDelegate
+ model: feedModel
+ delegate: feedDelegate
}
}
diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml
index e6cb373..668778e 100644
--- a/examples/declarative/xmldata/yahoonews.qml
+++ b/examples/declarative/xmldata/yahoonews.qml
@@ -1,11 +1,12 @@
import Qt 4.7
Rectangle {
+ width: 600; height: 600
+
gradient: Gradient {
GradientStop { position: 0; color: "black" }
GradientStop { position: 1.0; color: "#AAAAAA" }
}
- width: 600; height: 600
XmlListModel {
id: feedModel
@@ -18,6 +19,7 @@ Rectangle {
Component {
id: feedDelegate
+
Item {
id: delegate
height: wrapper.height + 10
@@ -30,25 +32,27 @@ Rectangle {
Rectangle {
id: wrapper
- y: 5; height: titleText.height + 10; width: 580
- color: "#F0F0F0"; radius: 5
+
+ width: 580; y: 5; height: titleText.height + 10
+ color: "#F0F0F0"
+ radius: 5
+
Text {
id: titleText
x: 10; y: 5
text: '<a href=\'' + link + '\'>' + title + '</a>'
- font.bold: true; font.family: "Helvetica"; font.pointSize: 14
+ font { bold: true; family: "Helvetica"; pointSize: 14 }
+
onLinkActivated: { console.log('link clicked: ' + link) }
}
Text {
- x: 10
id: descriptionText
+ x: 10; width: 560
+ anchors.top: titleText.bottom; anchors.topMargin: 5
text: description
- width: 560
wrapMode: Text.WordWrap
font.family: "Helvetica"
- anchors.top: titleText.bottom
- anchors.topMargin: 5
opacity: 0
}
diff --git a/examples/declarative/xmlhttprequest/test.qml b/examples/declarative/xmlhttprequest/test.qml
index ef9d5f3..c7e7e6d 100644
--- a/examples/declarative/xmlhttprequest/test.qml
+++ b/examples/declarative/xmlhttprequest/test.qml
@@ -5,32 +5,32 @@ Rectangle {
MouseArea {
anchors.fill: parent
+
onClicked: {
+ var doc = new XMLHttpRequest();
+ doc.onreadystatechange = function() {
+ if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ console.log("Headers -->");
+ console.log(doc.getAllResponseHeaders ());
+ console.log("Last modified -->");
+ console.log(doc.getResponseHeader ("Last-Modified"));
+ }
+ else if (doc.readyState == XMLHttpRequest.DONE) {
- var doc = new XMLHttpRequest();
- doc.onreadystatechange = function() {
- if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
- console.log("Headers -->");
- console.log(doc.getAllResponseHeaders ());
- console.log("Last modified -->");
- console.log(doc.getResponseHeader ("Last-Modified"));
+ var a = doc.responseXML.documentElement;
+ for (var ii = 0; ii < a.childNodes.length; ++ii) {
+ console.log(a.childNodes[ii].nodeName);
}
- else if (doc.readyState == XMLHttpRequest.DONE) {
-
- var a = doc.responseXML.documentElement;
- for (var ii = 0; ii < a.childNodes.length; ++ii) {
- console.log(a.childNodes[ii].nodeName);
- }
- console.log("Headers -->");
- console.log(doc.getAllResponseHeaders ());
- console.log("Last modified -->");
- console.log(doc.getResponseHeader ("Last-Modified"));
+ console.log("Headers -->");
+ console.log(doc.getAllResponseHeaders ());
+ console.log("Last modified -->");
+ console.log(doc.getResponseHeader ("Last-Modified"));
- }
}
+ }
- doc.open("GET", "test.xml");
- doc.send();
+ doc.open("GET", "test.xml");
+ doc.send();
}
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p.h
index 1961fdd..0b97e8c 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p.h
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeAnchorsPrivate;
-struct QDeclarativeAnchorLine;
+class QDeclarativeAnchorLine;
class Q_DECLARATIVE_EXPORT QDeclarativeAnchors : public QObject
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
index ba6359a..4cadb43 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
@@ -59,8 +59,9 @@
QT_BEGIN_NAMESPACE
-struct QDeclarativeAnchorLine
+class QDeclarativeAnchorLine
{
+public:
QDeclarativeAnchorLine() : item(0), anchorLine(Invalid) {}
enum AnchorLine {
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index 917e480..51889f6 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeState;
-struct QDeclarativeAnchorLine;
+class QDeclarativeAnchorLine;
class QDeclarativeTransition;
class QDeclarativeKeyEvent;
class QDeclarativeAnchors;
@@ -91,7 +91,6 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDe
Q_PROPERTY(QDeclarativeListProperty<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 NOTIFY smoothChanged)
- Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect)
Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 15348ed..dc325ce 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -1127,20 +1127,21 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count,
const QList<int> &roles)
{
Q_D(QDeclarativeVisualDataModel);
- // XXX - highly inefficient
- for (int ii = index; ii < index + count; ++ii) {
-
- if (QObject *item = d->m_cache.item(ii)) {
- QDeclarativeVisualDataModelData *data = d->data(item);
+ for (QHash<int,QDeclarativeVisualDataModelPrivate::ObjectRef>::ConstIterator iter = d->m_cache.begin();
+ iter != d->m_cache.end(); ++iter) {
+ const int idx = iter.key();
+ if (idx >= index && idx < index+count) {
+ QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter;
+ QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) {
int role = roles.at(roleIdx);
int propId = data->propForRole(role);
if (propId != -1) {
if (d->m_listModelInterface) {
- data->setValue(propId, d->m_listModelInterface->data(ii, QList<int>() << role).value(role));
+ data->setValue(propId, d->m_listModelInterface->data(idx, QList<int>() << role).value(role));
} else if (d->m_abstractItemModel) {
- QModelIndex index = d->m_abstractItemModel->index(ii, 0, d->m_root);
+ QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root);
data->setValue(propId, d->m_abstractItemModel->data(index, role));
}
}
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index 05e8d22..133b71f 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -723,6 +723,10 @@ void QDeclarativeCompositeTypeManager::compile(QDeclarativeCompositeTypeData *un
}
}
+ QUrl importUrl = unit->imports.baseUrl().resolved(QUrl(QLatin1String("qmldir")));
+ if (toLocalFileOrQrc(importUrl).isEmpty())
+ resourceList.prepend(importUrl);
+
for (int ii = 0; ii < resourceList.count(); ++ii) {
QUrl url = unit->imports.baseUrl().resolved(resourceList.at(ii));
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 0addfabd..3575c17 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -246,12 +246,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
{
QObject *o = (QObject *)operator new(instr.createSimple.typeSize +
sizeof(QDeclarativeDeclarativeData));
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
::memset(o, 0, instr.createSimple.typeSize + sizeof(QDeclarativeDeclarativeData));
-#else
- // faster than memset
- ::bzero(o, instr.createSimple.typeSize + sizeof(QDeclarativeDeclarativeData));
-#endif
instr.createSimple.create(o);
QDeclarativeDeclarativeData *ddata =
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index e3680f2..2616ccf 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -219,13 +219,13 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM
\tt dataloader.js, which appends the current time to the list model.
Note the call to sync() from the \c WorkerScript.onMessage() handler.
- Without this call, the changes made to the list are not reflected in the
- list model in the main thread.
+ You must call sync() or else the changes made to the list from the external
+ thread will not be reflected in the list model in the main thread.
\section3 Limitations
If a list model is to be accessed from a WorkerScript, it \bold cannot
- contain nested list data. So, the following model cannot be used from a WorkerScript
+ contain list data. So, the following model cannot be used from a WorkerScript
because of the list contained in the "attributes" property:
\code
@@ -242,7 +242,7 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM
}
\endcode
- In addition, the WorkerScript cannot add any nested list data to the model.
+ In addition, the WorkerScript cannot add any list data to the model.
\sa {qmlmodels}{Data Models}, WorkerScript
*/
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index 9cc75af..5a65232 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -554,6 +554,7 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint)
+ Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect)
Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), QDeclarativeListProperty<QGraphicsObject> children READ childrenList DESIGNABLE false NOTIFY childrenChanged)
Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL)
Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL)
diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro
index 85d2a73..b316cb9 100644
--- a/tests/auto/declarative/examples/examples.pro
+++ b/tests/auto/declarative/examples/examples.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_examples.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 3d717bc..dfcc9c0 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -44,6 +44,13 @@
#include <QProcess>
#include <QDebug>
+#define CONCURRENT
+
+#ifdef CONCURRENT
+#include <QFutureSynchronizer>
+#include <QtConcurrentRun>
+#endif
+
class tst_examples : public QObject
{
Q_OBJECT
@@ -51,7 +58,9 @@ public:
tst_examples();
private slots:
+#ifndef CONCURRENT
void examples_data();
+#endif
void examples();
void namingConvention();
@@ -81,6 +90,12 @@ tst_examples::tst_examples()
excludedDirs << "examples/declarative/plugins";
excludedDirs << "examples/declarative/proxywidgets";
excludedDirs << "examples/declarative/gestures";
+
+#ifdef QT_NO_WEBKIT
+ excludedDirs << "examples/declarative/webview";
+ excludedDirs << "demos/declarative/webbrowser";
+#endif
+
#ifdef QT_NO_XMLPATTERNS
excludedDirs << "examples/declarative/xmldata";
excludedDirs << "demos/declarative/twitter";
@@ -101,19 +116,19 @@ void tst_examples::namingConvention(const QDir &d)
return;
}
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
QDir::Files);
bool seenQml = !files.isEmpty();
bool seenLowercase = false;
foreach (const QString &file, files) {
- if (file.at(0).isLower())
+ if (file.at(0).isLower())
seenLowercase = true;
}
if (!seenQml) {
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
QDir::NoSymLinks);
foreach (const QString &dir, dirs) {
QDir sub = d;
@@ -144,7 +159,7 @@ QStringList tst_examples::findQmlFiles(const QDir &d)
QStringList rv;
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
QDir::Files);
foreach (const QString &file, files) {
if (file.at(0).isLower()) {
@@ -152,7 +167,7 @@ QStringList tst_examples::findQmlFiles(const QDir &d)
}
}
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
QDir::NoSymLinks);
foreach (const QString &dir, dirs) {
QDir sub = d;
@@ -163,32 +178,126 @@ QStringList tst_examples::findQmlFiles(const QDir &d)
return rv;
}
+
+
/*
-This test runs all the examples in the declarative UI source tree and ensures
+This test runs all the examples in the declarative UI source tree and ensures
that they start and exit cleanly.
Examples are any .qml files under the examples/ or demos/ directory that start
-with a lower case letter.
+with a lower case letter.
*/
+#ifndef CONCURRENT
void tst_examples::examples_data()
{
QTest::addColumn<QString>("file");
- QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
- QString demos = QLibraryInfo::location(QLibraryInfo::DemosPath);
+ QString examples = QLatin1String(SRCDIR) + "/../../../../demos/declarative/";
+ QString demos = QLatin1String(SRCDIR) + "/../../../../examples/declarative/";
QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/";
+ qWarning() << examples << demos << snippets;
+
QStringList files;
files << findQmlFiles(QDir(examples));
files << findQmlFiles(QDir(demos));
files << findQmlFiles(QDir(snippets));
+ qWarning() << files;
+
foreach (const QString &file, files)
QTest::newRow(file.toLatin1().constData()) << file;
}
+#endif
+
+#ifdef CONCURRENT
+#define THREADS 5
+
+struct Example {
+public:
+ Example() : result(Unknown) {}
+
+ enum Result { Pass, Unknown, Fail };
+ Result result;
+ QString file;
+ QString qmlruntime;
+
+ void run();
+};
+void Example::run()
+{
+ QFileInfo fi(file);
+ QFileInfo dir(fi.path());
+ QString script = SRCDIR "/data/"+dir.baseName()+"/"+fi.baseName();
+ QFileInfo testdata(script+".qml");
+ QStringList arguments;
+ arguments << "-script" << (testdata.exists() ? script : QLatin1String(SRCDIR "/data/dummytest"))
+ << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure"
+ << file;
+#ifdef Q_WS_QWS
+ arguments << "-qws";
+#endif
+
+ QProcess p;
+ p.start(qmlruntime, arguments);
+ if (!p.waitForFinished()) {
+ result = Fail;
+ return;
+ }
+
+ if (p.exitStatus() != QProcess::NormalExit || p.exitCode() != 0)
+ qWarning() << p.readAllStandardOutput() << p.readAllStandardError();
+
+ if (p.exitStatus() != QProcess::NormalExit ||
+ p.exitCode() != 0) {
+ result = Fail;
+ return;
+ } else {
+ result = Pass;
+ return;
+ }
+}
+
+#endif
void tst_examples::examples()
{
+#ifdef CONCURRENT
+ QThreadPool::globalInstance()->setMaxThreadCount(5);
+
+ QString examples = QLatin1String(SRCDIR) + "/../../../../demos/declarative/";
+ QString demos = QLatin1String(SRCDIR) + "/../../../../examples/declarative/";
+ QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/";
+
+ QStringList files;
+ files << findQmlFiles(QDir(examples));
+ files << findQmlFiles(QDir(demos));
+ files << findQmlFiles(QDir(snippets));
+
+ QList<Example> tests;
+
+ for (int ii = 0; ii < files.count(); ++ii) {
+ Example e;
+ e.file = files.at(ii);
+ e.qmlruntime = qmlruntime;
+ tests << e;
+ }
+
+ QFutureSynchronizer<void> sync;
+
+ for (int ii = 0; ii < tests.count(); ++ii) {
+ Example *e = &tests[ii];
+ QFuture<void> r = QtConcurrent::run(e, &Example::run);
+ sync.addFuture(r);
+ }
+
+ sync.waitForFinished();
+
+ for (int ii = 0; ii < tests.count(); ++ii)
+ QVERIFY(tests.at(ii).result == Example::Pass);
+
+#else
+
QFETCH(QString, file);
QFileInfo fi(file);
@@ -197,7 +306,7 @@ void tst_examples::examples()
QFileInfo testdata(script+".qml");
QStringList arguments;
arguments << "-script" << (testdata.exists() ? script : QLatin1String(SRCDIR "/data/dummytest"))
- << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure"
+ << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure"
<< file;
#ifdef Q_WS_QWS
arguments << "-qws";
@@ -210,6 +319,7 @@ void tst_examples::examples()
qWarning() << p.readAllStandardOutput() << p.readAllStandardError();
QCOMPARE(p.exitStatus(), QProcess::NormalExit);
QCOMPARE(p.exitCode(), 0);
+#endif
}
QTEST_MAIN(tst_examples)
diff --git a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro b/tests/auto/declarative/graphicswidgets/graphicswidgets.pro
index 712c34c..b77b430 100644
--- a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro
+++ b/tests/auto/declarative/graphicswidgets/graphicswidgets.pro
@@ -6,3 +6,5 @@ SOURCES += tst_graphicswidgets.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/parserstress/parserstress.pro b/tests/auto/declarative/parserstress/parserstress.pro
index 48f147a..8830511 100644
--- a/tests/auto/declarative/parserstress/parserstress.pro
+++ b/tests/auto/declarative/parserstress/parserstress.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_parserstress.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro
index ca2f68f..a2403f2 100644
--- a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro
+++ b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro
@@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativeanchors.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/qmldir b/tests/auto/declarative/qdeclarativeanimatedimage/data/qmldir
new file mode 100644
index 0000000..ef7c1f4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/qmldir
@@ -0,0 +1 @@
+# No local types
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro
index 2904986..74f9be0 100644
--- a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro
@@ -5,3 +5,6 @@ SOURCES += tst_qdeclarativeanimatedimage.cpp ../shared/testhttpserver.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro
index 8eac75f..ce38eeb 100644
--- a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro
+++ b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro
@@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativeanimations.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml
index e982f21..e9fb286 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml
@@ -9,7 +9,7 @@ Rectangle {
objectName: "MyRect"
width: 100; height: 100; color: "green"
x: basex
- Behavior on x { NumberAnimation { duration: 500; } }
+ Behavior on x { NumberAnimation { duration: 800; } }
}
MouseArea {
id: clicker
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml
index b22441a..795b309 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml
@@ -11,6 +11,6 @@ Rectangle {
id: rect
objectName: "MyRect"
width: 100; height: 100; color: "green"
- Behavior on x { NumberAnimation { duration: 500; } }
+ Behavior on x { NumberAnimation { duration: 800; } }
}
}
diff --git a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro
index a1dac32..c2781b8 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro
+++ b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro
@@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativebehaviors.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index 4c9c9ca..3bff2f5 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -45,6 +45,7 @@
#include <private/qdeclarativerectangle_p.h>
#include <private/qdeclarativebehavior_p.h>
#include <private/qdeclarativeanimation_p.h>
+#include "../../../shared/util.h"
class tst_qdeclarativebehaviors : public QObject
{
@@ -76,13 +77,13 @@ void tst_qdeclarativebehaviors::simpleBehavior()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
- QVERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation());
+ QTRY_VERIFY(rect);
+ QTRY_VERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation());
rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
delete rect;
}
@@ -92,12 +93,12 @@ void tst_qdeclarativebehaviors::scriptTriggered()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
rect->setColor(QColor("red"));
- QTest::qWait(200);
- qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
delete rect;
}
@@ -107,15 +108,14 @@ void tst_qdeclarativebehaviors::cppTriggered()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
- QVERIFY(innerRect);
+ QTRY_VERIFY(innerRect);
innerRect->setProperty("x", 200);
- QTest::qWait(200);
- qreal x = innerRect->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ QTRY_VERIFY(innerRect->x() > 0);
+ QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered
delete rect;
}
@@ -125,7 +125,7 @@ void tst_qdeclarativebehaviors::loop()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
//don't crash
rect->setState("moved");
@@ -138,12 +138,12 @@ void tst_qdeclarativebehaviors::colorBehavior()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
rect->setState("red");
- QTest::qWait(200);
- QColor color = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->color();
- QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->color() != QColor("red"));
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->color() != QColor("green"));
+ //i.e. the behavior has been triggered
delete rect;
}
@@ -153,16 +153,11 @@ void tst_qdeclarativebehaviors::parentBehavior()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
rect->setState("reparented");
- QTest::qWait(200);
- QDeclarativeItem *newParent = rect->findChild<QDeclarativeItem*>("NewParent");
- QDeclarativeItem *parent = rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem();
- QVERIFY(parent != newParent);
- QTest::qWait(600);
- parent = rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem();
- QVERIFY(parent == newParent);
+ QTRY_VERIFY(rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem() != rect->findChild<QDeclarativeItem*>("NewParent"));
+ QTRY_VERIFY(rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem() == rect->findChild<QDeclarativeItem*>("NewParent"));
delete rect;
}
@@ -172,33 +167,28 @@ void tst_qdeclarativebehaviors::replaceBinding()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
rect->setState("moved");
- QTest::qWait(200);
QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
- QVERIFY(innerRect);
- qreal x = innerRect->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)200);
+ QTRY_VERIFY(innerRect);
+ QTRY_VERIFY(innerRect->x() > 0);
+ QTRY_VERIFY(innerRect->x() < 200);
+ //i.e. the behavior has been triggered
+ QTRY_COMPARE(innerRect->x(), (qreal)200);
rect->setProperty("basex", 10);
- QCOMPARE(innerRect->x(), (qreal)200);
+ QTRY_COMPARE(innerRect->x(), (qreal)200);
rect->setProperty("movedx", 210);
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)210);
+ QTRY_COMPARE(innerRect->x(), (qreal)210);
rect->setState("");
- QTest::qWait(200);
- x = innerRect->x();
- QVERIFY(x > 10 && x < 210); //i.e. the behavior has been triggered
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)10);
+ QTRY_VERIFY(innerRect->x() > 10);
+ QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered
+ QTRY_COMPARE(innerRect->x(), (qreal)10);
rect->setProperty("movedx", 200);
- QCOMPARE(innerRect->x(), (qreal)10);
+ QTRY_COMPARE(innerRect->x(), (qreal)10);
rect->setProperty("basex", 20);
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)20);
+ QTRY_COMPARE(innerRect->x(), (qreal)20);
delete rect;
}
@@ -209,12 +199,13 @@ void tst_qdeclarativebehaviors::group()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ //QTest::qWait(200);
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
delete rect;
}
@@ -223,12 +214,12 @@ void tst_qdeclarativebehaviors::group()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty2.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
delete rect;
}
@@ -239,46 +230,42 @@ void tst_qdeclarativebehaviors::emptyBehavior()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
rect->setState("moved");
qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
+ QTRY_COMPARE(x, qreal(200)); //should change immediately
delete rect;
}
void tst_qdeclarativebehaviors::explicitSelection()
{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
- QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QTRY_VERIFY(rect);
- rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ rect->setState("moved");
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
- delete rect;
- }
+ delete rect;
}
void tst_qdeclarativebehaviors::nonSelectingBehavior()
{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
- QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QTRY_VERIFY(rect);
- rect->setState("moved");
- qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
+ rect->setState("moved");
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QTRY_COMPARE(x, qreal(200)); //should change immediately
- delete rect;
- }
+ delete rect;
}
void tst_qdeclarativebehaviors::reassignedAnimation()
@@ -287,8 +274,8 @@ void tst_qdeclarativebehaviors::reassignedAnimation()
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml"));
QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9) Cannot change the animation assigned to a Behavior.").toUtf8().constData());
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
+ QTRY_VERIFY(rect);
+ QTRY_COMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
qobject_cast<QDeclarativeBehavior*>(
rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation())->duration(), 200);
@@ -300,12 +287,12 @@ void tst_qdeclarativebehaviors::disabled()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
+ QTRY_VERIFY(rect);
+ QTRY_COMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
rect->setState("moved");
qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
+ QTRY_COMPARE(x, qreal(200)); //should change immediately
delete rect;
}
@@ -318,11 +305,11 @@ void tst_qdeclarativebehaviors::dontStart()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ QTRY_VERIFY(myAnim && myAnim->qtAnimation());
+ QTRY_VERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
delete rect;
}
@@ -332,12 +319,12 @@ void tst_qdeclarativebehaviors::startup()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
+ QTRY_VERIFY(rect);
QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect");
- QVERIFY(innerRect);
+ QTRY_VERIFY(innerRect);
- QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
+ QTRY_COMPARE(innerRect->x(), qreal(100)); //should be set immediately
delete rect;
}
diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
index 7879976..04dd6f5 100644
--- a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
+++ b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativebinding.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro
index 0574ddb..e754923 100644
--- a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro
+++ b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro
@@ -7,3 +7,6 @@ SOURCES += tst_qdeclarativeborderimage.cpp ../shared/testhttpserver.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
index 8aeba6d..bb965a9 100644
--- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
+++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
@@ -148,7 +148,7 @@ void tst_qdeclarativeborderimage::imageSource()
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
QVERIFY(obj != 0);
-
+
if (remote)
TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
@@ -267,14 +267,14 @@ void tst_qdeclarativeborderimage::sciSource()
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
QVERIFY(obj != 0);
-
+
if (remote)
TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
-
+
QCOMPARE(obj->source(), remote ? source : QUrl(source));
QCOMPARE(obj->width(), 300.);
QCOMPARE(obj->height(), 300.);
-
+
if (valid) {
TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready);
QCOMPARE(obj->border()->left(), 10);
@@ -342,8 +342,8 @@ void tst_qdeclarativeborderimage::pendingRemoteRequest_data()
{
QTest::addColumn<QString>("source");
- QTest::newRow("png file") << "http://no-such-qt-server-like-this/none.png";
- QTest::newRow("sci file") << "http://no-such-qt-server-like-this/none.sci";
+ QTest::newRow("png file") << "http://localhost/none.png";
+ QTest::newRow("sci file") << "http://localhost/none.sci";
}
QTEST_MAIN(tst_qdeclarativeborderimage)
diff --git a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
index c7affb7..e58c798 100644
--- a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
+++ b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
@@ -6,3 +6,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativecomponent.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
index a6adfa4..959354d 100644
--- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
+++ b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativeconnection.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
index adace70..5db9a9e 100644
--- a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
+++ b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
@@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativecontext.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro
index ff1d0d4..1214fcf 100644
--- a/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro
+++ b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
HEADERS += ../shared/debugutil_p.h
SOURCES += tst_qdeclarativedebug.cpp \
../shared/debugutil.cpp
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro
index e375889..a62e148 100644
--- a/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro
+++ b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
HEADERS += ../shared/debugutil_p.h
SOURCES += tst_qdeclarativedebugservice.cpp \
../shared/debugutil.cpp
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro
index 35df26e..466c563 100644
--- a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro
+++ b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativedom.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
index 0e21cb2..eabed26 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
+++ b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
@@ -8,3 +8,6 @@ HEADERS += testtypes.h
# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
# LIBS += -lgcov
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
index 5b6530d..e0ea2e5 100644
--- a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
+++ b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativeengine.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
index 6591406..501f32c 100644
--- a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
+++ b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
@@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativeerror.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro
index 4b71381..07637c9 100644
--- a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro
+++ b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativeflickable.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro
index e29d324..9830b55 100644
--- a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro
+++ b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativeflipable.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro
index 4d7a9b3..687c80c 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro
+++ b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro
@@ -4,3 +4,4 @@ SOURCES += tst_qdeclarativefocusscope.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
index 3ba50be..9a8a3ff 100644
--- a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
+++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
@@ -7,3 +7,6 @@ SOURCES += tst_qdeclarativefontloader.cpp ../shared/testhttpserver.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro
index af206d7..b069260 100644
--- a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro
+++ b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativegridview.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 7add9c6..07fc3aa 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -50,6 +50,7 @@
#include <QtDeclarative/private/qdeclarativegridview_p.h>
#include <QtDeclarative/private/qdeclarativetext_p.h>
#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
+#include "../../../shared/util.h"
class tst_QDeclarativeGridView : public QObject
{
@@ -169,21 +170,21 @@ void tst_QDeclarativeGridView::items()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
- QCOMPARE(gridview->count(), model.count());
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(gridview->count(), model.count());
+ QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
for (int i = 0; i < model.count(); ++i) {
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
}
// set an empty model and confirm that items are destroyed
@@ -191,7 +192,7 @@ void tst_QDeclarativeGridView::items()
ctxt->setContextProperty("testModel", &model2);
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
- QVERIFY(itemCount == 0);
+ QTRY_VERIFY(itemCount == 0);
delete canvas;
}
@@ -217,18 +218,18 @@ void tst_QDeclarativeGridView::changed()
qApp->processEvents();
QDeclarativeFlickable *gridview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
model.modifyItem(1, "Will", "9876");
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
delete canvas;
}
@@ -250,71 +251,62 @@ void tst_QDeclarativeGridView::inserted()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
model.insertItem(1, "Will", "9876");
- // let transitions settle.
- QTest::qWait(100);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
// Checks that onAdd is called
int added = canvas->rootObject()->property("added").toInt();
- QCOMPARE(added, 1);
+ QTRY_COMPARE(added, 1);
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0);
}
model.insertItem(0, "Foo", "1111"); // zero index, and current item
- // let transitions settle.
- QTest::qWait(100);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
name = findItem<QDeclarativeText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
- QCOMPARE(gridview->currentIndex(), 1);
+ QTRY_COMPARE(gridview->currentIndex(), 1);
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
}
for (int i = model.count(); i < 30; ++i)
model.insertItem(i, "Hello", QString::number(i));
- QTest::qWait(100);
gridview->setContentY(120);
- QTest::qWait(100);
// Insert item outside visible area
model.insertItem(1, "Hello", "1324");
- QTest::qWait(100);
- QVERIFY(gridview->contentY() == 120);
+ QTRY_VERIFY(gridview->contentY() == 120);
delete canvas;
}
@@ -335,107 +327,91 @@ void tst_QDeclarativeGridView::removed()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
model.removeItem(1);
- // let transitions settle.
- QTest::qWait(100);
-
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
// Checks that onRemove is called
QString removed = canvas->rootObject()->property("removed").toString();
- QCOMPARE(removed, QString("Item1"));
+ QTRY_COMPARE(removed, QString("Item1"));
// Confirm items positioned correctly
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
}
// Remove first item (which is the current item);
model.removeItem(0);
- // let transitions settle.
- QTest::qWait(100);
-
name = findItem<QDeclarativeText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
}
// Remove items not visible
model.removeItem(25);
- // let transitions settle.
- QTest::qWait(100);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
}
// Remove items before visible
gridview->setContentY(120);
- QTest::qWait(100);
gridview->setCurrentIndex(10);
- // let transitions settle.
- QTest::qWait(100);
-
// Setting currentIndex above shouldn't cause view to scroll
- QCOMPARE(gridview->contentY(), 120.0);
+ QTRY_COMPARE(gridview->contentY(), 120.0);
model.removeItem(1);
- // let transitions settle.
- QTest::qWait(100);
-
// Confirm items positioned correctly
for (int i = 6; i < 18; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
}
// Remove currentIndex
QDeclarativeItem *oldCurrent = gridview->currentItem();
model.removeItem(9);
- QTest::qWait(100);
- QCOMPARE(gridview->currentIndex(), 9);
- QVERIFY(gridview->currentItem() != oldCurrent);
+ QTRY_COMPARE(gridview->currentIndex(), 9);
+ QTRY_VERIFY(gridview->currentItem() != oldCurrent);
gridview->setContentY(0);
// let transitions settle.
@@ -446,39 +422,34 @@ void tst_QDeclarativeGridView::removed()
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
}
// remove item outside current view.
gridview->setCurrentIndex(32);
- QTest::qWait(100);
gridview->setContentY(240);
model.removeItem(30);
- QVERIFY(gridview->currentIndex() == 31);
+ QTRY_VERIFY(gridview->currentIndex() == 31);
// remove current item beyond visible items.
gridview->setCurrentIndex(20);
- QTest::qWait(100);
gridview->setContentY(0);
model.removeItem(20);
- QTest::qWait(100);
- QCOMPARE(gridview->currentIndex(), 20);
- QVERIFY(gridview->currentItem() != 0);
+ QTRY_COMPARE(gridview->currentIndex(), 20);
+ QTRY_VERIFY(gridview->currentItem() != 0);
// remove item before current, but visible
gridview->setCurrentIndex(8);
- QTest::qWait(100);
gridview->setContentY(240);
oldCurrent = gridview->currentItem();
model.removeItem(6);
- QTest::qWait(100);
- QCOMPARE(gridview->currentIndex(), 7);
- QVERIFY(gridview->currentItem() == oldCurrent);
+ QTRY_COMPARE(gridview->currentIndex(), 7);
+ QTRY_VERIFY(gridview->currentItem() == oldCurrent);
delete canvas;
}
@@ -499,38 +470,35 @@ void tst_QDeclarativeGridView::moved()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
model.moveItem(1, 8);
- // let transitions settle.
- QTest::qWait(100);
-
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
name = findItem<QDeclarativeText>(viewport, "textName", 8);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(8));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(8));
number = findItem<QDeclarativeText>(viewport, "textNumber", 8);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(8));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(8));
// Confirm items positioned correctly
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
}
gridview->setContentY(120);
@@ -538,50 +506,44 @@ void tst_QDeclarativeGridView::moved()
// move outside visible area
model.moveItem(1, 25);
- // let transitions settle.
- QTest::qWait(100);
-
// Confirm items positioned correctly and indexes correct
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count()-1;
for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i%3)*80));
- QCOMPARE(item->y(), qreal((i/3)*60));
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
name = findItem<QDeclarativeText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
number = findItem<QDeclarativeText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
}
// move from outside visible into visible
model.moveItem(28, 8);
- // let transitions settle.
- QTest::qWait(100);
-
// Confirm items positioned correctly and indexes correct
for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
name = findItem<QDeclarativeText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
number = findItem<QDeclarativeText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
}
// ensure content position is stable
gridview->setContentY(0);
model.moveItem(10, 0);
- QVERIFY(gridview->contentY() == 0);
+ QTRY_VERIFY(gridview->contentY() == 0);
delete canvas;
}
@@ -604,65 +566,59 @@ void tst_QDeclarativeGridView::currentIndex()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- QTest::qWait(300);
+ QTRY_VERIFY(viewport != 0);
// current item should be third item
- QCOMPARE(gridview->currentIndex(), 5);
- QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 5));
- QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QTRY_COMPARE(gridview->currentIndex(), 5);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 5));
+ QTRY_COMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 6);
+ QTRY_COMPARE(gridview->currentIndex(), 6);
gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), 9);
+ QTRY_COMPARE(gridview->currentIndex(), 9);
gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 6);
+ QTRY_COMPARE(gridview->currentIndex(), 6);
gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 5);
+ QTRY_COMPARE(gridview->currentIndex(), 5);
// no wrap
gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
gridview->setCurrentIndex(model.count()-1);
- QTest::qWait(100);
- QCOMPARE(gridview->currentIndex(), model.count()-1);
+ QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
+ QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
+ QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
// with wrap
gridview->setWrapEnabled(true);
gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
- QTest::qWait(500);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
+ QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
- QTest::qWait(500);
- QCOMPARE(gridview->contentY(), 279.0);
+ QTRY_COMPARE(gridview->contentY(), 279.0);
gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
- QTest::qWait(500);
- QCOMPARE(gridview->contentY(), 0.0);
+ QTRY_COMPARE(gridview->contentY(), 0.0);
// Test keys
canvas->show();
@@ -671,47 +627,46 @@ void tst_QDeclarativeGridView::currentIndex()
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(canvas);
#endif
- QVERIFY(canvas->hasFocus());
- QVERIFY(canvas->scene()->hasFocus());
+ QTRY_VERIFY(canvas->hasFocus());
+ QTRY_VERIFY(canvas->scene()->hasFocus());
qApp->processEvents();
QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 3);
+ QTRY_COMPARE(gridview->currentIndex(), 3);
QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
gridview->setFlow(QDeclarativeGridView::TopToBottom);
QTest::keyClick(canvas, Qt::Key_Right);
- QCOMPARE(gridview->currentIndex(), 5);
+ QTRY_COMPARE(gridview->currentIndex(), 5);
QTest::keyClick(canvas, Qt::Key_Left);
- QCOMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 1);
+ QTRY_COMPARE(gridview->currentIndex(), 1);
QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
// turn off auto highlight
gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
- QVERIFY(gridview->highlightItem());
+ QTRY_VERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QTRY_VERIFY(gridview->highlightItem());
qreal hlPosX = gridview->highlightItem()->x();
qreal hlPosY = gridview->highlightItem()->y();
gridview->setCurrentIndex(5);
- QTest::qWait(500);
- QCOMPARE(gridview->highlightItem()->x(), hlPosX);
- QCOMPARE(gridview->highlightItem()->y(), hlPosY);
+ QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
+ QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
// insert item before currentIndex
gridview->setCurrentIndex(28);
model.insertItem(0, "Foo", "1111");
- QCOMPARE(canvas->rootObject()->property("current").toInt(), 29);
+ QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
delete canvas;
}
@@ -732,44 +687,43 @@ void tst_QDeclarativeGridView::changeFlow()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
// Confirm items positioned correctly and indexes correct
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i%3)*80));
- QCOMPARE(item->y(), qreal((i/3)*60));
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
}
ctxt->setContextProperty("testTopToBottom", QVariant(true));
- QTest::qWait(100);
// Confirm items positioned correctly and indexes correct
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i/5)*80));
- QCOMPARE(item->y(), qreal((i%5)*60));
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i/5)*80));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
}
delete canvas;
@@ -781,20 +735,20 @@ void tst_QDeclarativeGridView::defaultValues()
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview3.qml"));
QDeclarativeGridView *obj = qobject_cast<QDeclarativeGridView*>(c.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->model() == QVariant());
- QVERIFY(obj->delegate() == 0);
- QCOMPARE(obj->currentIndex(), -1);
- QVERIFY(obj->currentItem() == 0);
- QCOMPARE(obj->count(), 0);
- QVERIFY(obj->highlight() == 0);
- QVERIFY(obj->highlightItem() == 0);
- QCOMPARE(obj->highlightFollowsCurrentItem(), true);
- QVERIFY(obj->flow() == 0);
- QCOMPARE(obj->isWrapEnabled(), false);
- QCOMPARE(obj->cacheBuffer(), 0);
- QCOMPARE(obj->cellWidth(), 100); //### Should 100 be the default?
- QCOMPARE(obj->cellHeight(), 100);
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->model() == QVariant());
+ QTRY_VERIFY(obj->delegate() == 0);
+ QTRY_COMPARE(obj->currentIndex(), -1);
+ QTRY_VERIFY(obj->currentItem() == 0);
+ QTRY_COMPARE(obj->count(), 0);
+ QTRY_VERIFY(obj->highlight() == 0);
+ QTRY_VERIFY(obj->highlightItem() == 0);
+ QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true);
+ QTRY_VERIFY(obj->flow() == 0);
+ QTRY_COMPARE(obj->isWrapEnabled(), false);
+ QTRY_COMPARE(obj->cacheBuffer(), 0);
+ QTRY_COMPARE(obj->cellWidth(), 100); //### Should 100 be the default?
+ QTRY_COMPARE(obj->cellHeight(), 100);
delete obj;
}
@@ -804,59 +758,59 @@ void tst_QDeclarativeGridView::properties()
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview2.qml"));
QDeclarativeGridView *obj = qobject_cast<QDeclarativeGridView*>(c.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->model() != QVariant());
- QVERIFY(obj->delegate() != 0);
- QCOMPARE(obj->currentIndex(), 0);
- QVERIFY(obj->currentItem() != 0);
- QCOMPARE(obj->count(), 4);
- QVERIFY(obj->highlight() != 0);
- QVERIFY(obj->highlightItem() != 0);
- QCOMPARE(obj->highlightFollowsCurrentItem(), false);
- QVERIFY(obj->flow() == 0);
- QCOMPARE(obj->isWrapEnabled(), true);
- QCOMPARE(obj->cacheBuffer(), 200);
- QCOMPARE(obj->cellWidth(), 100);
- QCOMPARE(obj->cellHeight(), 100);
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->model() != QVariant());
+ QTRY_VERIFY(obj->delegate() != 0);
+ QTRY_COMPARE(obj->currentIndex(), 0);
+ QTRY_VERIFY(obj->currentItem() != 0);
+ QTRY_COMPARE(obj->count(), 4);
+ QTRY_VERIFY(obj->highlight() != 0);
+ QTRY_VERIFY(obj->highlightItem() != 0);
+ QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false);
+ QTRY_VERIFY(obj->flow() == 0);
+ QTRY_COMPARE(obj->isWrapEnabled(), true);
+ QTRY_COMPARE(obj->cacheBuffer(), 200);
+ QTRY_COMPARE(obj->cellWidth(), 100);
+ QTRY_COMPARE(obj->cellHeight(), 100);
delete obj;
}
void tst_QDeclarativeGridView::propertyChanges()
{
QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
+ QTRY_VERIFY(canvas);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView");
- QVERIFY(gridView);
+ QTRY_VERIFY(gridView);
QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged()));
QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged()));
QSignalSpy flowSpy(gridView, SIGNAL(flowChanged()));
- QCOMPARE(gridView->isWrapEnabled(), true);
- QCOMPARE(gridView->cacheBuffer(), 10);
- QCOMPARE(gridView->flow(), QDeclarativeGridView::LeftToRight);
+ QTRY_COMPARE(gridView->isWrapEnabled(), true);
+ QTRY_COMPARE(gridView->cacheBuffer(), 10);
+ QTRY_COMPARE(gridView->flow(), QDeclarativeGridView::LeftToRight);
gridView->setWrapEnabled(false);
gridView->setCacheBuffer(3);
gridView->setFlow(QDeclarativeGridView::TopToBottom);
- QCOMPARE(gridView->isWrapEnabled(), false);
- QCOMPARE(gridView->cacheBuffer(), 3);
- QCOMPARE(gridView->flow(), QDeclarativeGridView::TopToBottom);
+ QTRY_COMPARE(gridView->isWrapEnabled(), false);
+ QTRY_COMPARE(gridView->cacheBuffer(), 3);
+ QTRY_COMPARE(gridView->flow(), QDeclarativeGridView::TopToBottom);
- QCOMPARE(keyNavigationWrapsSpy.count(),1);
- QCOMPARE(cacheBufferSpy.count(),1);
- QCOMPARE(flowSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),1);
gridView->setWrapEnabled(false);
gridView->setCacheBuffer(3);
gridView->setFlow(QDeclarativeGridView::TopToBottom);
- QCOMPARE(keyNavigationWrapsSpy.count(),1);
- QCOMPARE(cacheBufferSpy.count(),1);
- QCOMPARE(flowSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),1);
delete canvas;
}
@@ -864,11 +818,11 @@ void tst_QDeclarativeGridView::propertyChanges()
void tst_QDeclarativeGridView::componentChanges()
{
QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
+ QTRY_VERIFY(canvas);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView");
- QVERIFY(gridView);
+ QTRY_VERIFY(gridView);
QDeclarativeComponent component(canvas->engine());
component.setData("import Qt 4.6; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
@@ -882,43 +836,43 @@ void tst_QDeclarativeGridView::componentChanges()
gridView->setHighlight(&component);
gridView->setDelegate(&delegateComponent);
- QCOMPARE(gridView->highlight(), &component);
- QCOMPARE(gridView->delegate(), &delegateComponent);
+ QTRY_COMPARE(gridView->highlight(), &component);
+ QTRY_COMPARE(gridView->delegate(), &delegateComponent);
- QCOMPARE(highlightSpy.count(),1);
- QCOMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
gridView->setHighlight(&component);
gridView->setDelegate(&delegateComponent);
- QCOMPARE(highlightSpy.count(),1);
- QCOMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
delete canvas;
}
void tst_QDeclarativeGridView::modelChanges()
{
QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
+ QTRY_VERIFY(canvas);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView");
- QVERIFY(gridView);
+ QTRY_VERIFY(gridView);
QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
- QVERIFY(alternateModel);
+ QTRY_VERIFY(alternateModel);
QVariant modelVariant = QVariant::fromValue(alternateModel);
QSignalSpy modelSpy(gridView, SIGNAL(modelChanged()));
gridView->setModel(modelVariant);
- QCOMPARE(gridView->model(), modelVariant);
- QCOMPARE(modelSpy.count(),1);
+ QTRY_COMPARE(gridView->model(), modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
gridView->setModel(modelVariant);
- QCOMPARE(modelSpy.count(),1);
+ QTRY_COMPARE(modelSpy.count(),1);
gridView->setModel(QVariant());
- QCOMPARE(modelSpy.count(),2);
+ QTRY_COMPARE(modelSpy.count(),2);
delete canvas;
}
@@ -938,117 +892,117 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
// Confirm items positioned correctly
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
}
// Position on a currently visible item
gridview->positionViewAtIndex(4, QDeclarativeGridView::Beginning);
- QCOMPARE(gridview->contentY(), 60.);
+ QTRY_COMPARE(gridview->contentY(), 60.);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
}
// Position on an item beyond the visible items
gridview->positionViewAtIndex(21, QDeclarativeGridView::Beginning);
- QCOMPARE(gridview->contentY(), 420.);
+ QTRY_COMPARE(gridview->contentY(), 420.);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
}
// Position on an item that would leave empty space if positioned at the top
gridview->positionViewAtIndex(31, QDeclarativeGridView::Beginning);
- QCOMPARE(gridview->contentY(), 520.);
+ QTRY_COMPARE(gridview->contentY(), 520.);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
}
// Position at the beginning again
gridview->positionViewAtIndex(0, QDeclarativeGridView::Beginning);
- QCOMPARE(gridview->contentY(), 0.);
+ QTRY_COMPARE(gridview->contentY(), 0.);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
}
// Position at End
gridview->positionViewAtIndex(30, QDeclarativeGridView::End);
- QCOMPARE(gridview->contentY(), 340.);
+ QTRY_COMPARE(gridview->contentY(), 340.);
// Position in Center
gridview->positionViewAtIndex(15, QDeclarativeGridView::Center);
- QCOMPARE(gridview->contentY(), 170.);
+ QTRY_COMPARE(gridview->contentY(), 170.);
// Ensure at least partially visible
gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible);
- QCOMPARE(gridview->contentY(), 170.);
+ QTRY_COMPARE(gridview->contentY(), 170.);
gridview->setContentY(302);
gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible);
- QCOMPARE(gridview->contentY(), 302.);
+ QTRY_COMPARE(gridview->contentY(), 302.);
gridview->setContentY(360);
gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible);
- QCOMPARE(gridview->contentY(), 300.);
+ QTRY_COMPARE(gridview->contentY(), 300.);
gridview->setContentY(60);
gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible);
- QCOMPARE(gridview->contentY(), 60.);
+ QTRY_COMPARE(gridview->contentY(), 60.);
gridview->setContentY(20);
gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible);
- QCOMPARE(gridview->contentY(), 100.);
+ QTRY_COMPARE(gridview->contentY(), 100.);
// Ensure completely visible
gridview->setContentY(120);
gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain);
- QCOMPARE(gridview->contentY(), 120.);
+ QTRY_COMPARE(gridview->contentY(), 120.);
gridview->setContentY(302);
gridview->positionViewAtIndex(15, QDeclarativeGridView::Contain);
- QCOMPARE(gridview->contentY(), 300.);
+ QTRY_COMPARE(gridview->contentY(), 300.);
gridview->setContentY(60);
gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain);
- QCOMPARE(gridview->contentY(), 100.);
+ QTRY_COMPARE(gridview->contentY(), 100.);
delete canvas;
}
@@ -1068,29 +1022,29 @@ void tst_QDeclarativeGridView::resetModel()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
- QCOMPARE(gridview->count(), model.rowCount());
+ QTRY_COMPARE(gridview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
}
strings.clear();
strings << "four" << "five" << "six" << "seven";
model.setStringList(strings);
- QCOMPARE(gridview->count(), model.rowCount());
+ QTRY_COMPARE(gridview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
}
}
@@ -1109,34 +1063,33 @@ void tst_QDeclarativeGridView::enforceRange()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
- QCOMPARE(gridview->preferredHighlightBegin(), 100.0);
- QCOMPARE(gridview->preferredHighlightEnd(), 100.0);
- QCOMPARE(gridview->highlightRangeMode(), QDeclarativeGridView::StrictlyEnforceRange);
+ QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0);
+ QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
+ QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarativeGridView::StrictlyEnforceRange);
QDeclarativeItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
// view should be positioned at the top of the range.
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(gridview->contentY(), -100.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(gridview->contentY(), -100.0);
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
// Check currentIndex is updated when viewport moves
gridview->setContentY(0);
- QCOMPARE(gridview->currentIndex(), 2);
+ QTRY_COMPARE(gridview->currentIndex(), 2);
gridview->setCurrentIndex(5);
- QTest::qWait(500);
- QCOMPARE(gridview->contentY(), 100.);
+ QTRY_COMPARE(gridview->contentY(), 100.);
delete canvas;
}
@@ -1149,9 +1102,9 @@ void tst_QDeclarativeGridView::QTBUG_8456()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
+ QTRY_VERIFY(gridview != 0);
- QCOMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
}
QDeclarativeView *tst_QDeclarativeGridView::createView()
diff --git a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro
index 7634c12..ff365ee 100644
--- a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro
+++ b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro
@@ -7,3 +7,6 @@ SOURCES += tst_qdeclarativeimage.cpp ../shared/testhttpserver.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
index a4d3eb2..22be991 100644
--- a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
+++ b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
@@ -10,3 +10,6 @@ SOURCES += tst_qdeclarativeimageprovider.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
index 015c094..bb54d6c 100644
--- a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
+++ b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativeinfo.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
index b8f7d27..0daa9e5 100644
--- a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
+++ b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
@@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativeinstruction.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro
index 0eb2141..e834a4e 100644
--- a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro
+++ b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativeitem.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
index d7c1def..5771469 100644
--- a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
+++ b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
@@ -12,3 +12,5 @@ HEADERS += ../shared/testhttpserver.h
SOURCES += ../shared/testhttpserver.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestNamed.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestNamed.qml
new file mode 100644
index 0000000..672cb8f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestNamed.qml
@@ -0,0 +1 @@
+NamedLocal { }
diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir
index da10ba9..60150f8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir
@@ -1,4 +1,5 @@
Test Test.qml
TestSubDir TestSubDir.qml
TestLocal TestLocal.qml
+NamedLocal LocalInternal.qml
internal LocalInternal LocalInternal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index bfb56ba..c033c48 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -52,6 +52,7 @@
#include "testtypes.h"
#include "../../../shared/util.h"
+#include "testhttpserver.h"
/*
This test case covers QML language issues. This covers everything that does not
@@ -116,6 +117,8 @@ private slots:
void defaultPropertyListOrder();
void declaredPropertyValues();
+ void basicRemote_data();
+ void basicRemote();
void importsBuiltin_data();
void importsBuiltin();
void importsLocal_data();
@@ -1298,6 +1301,40 @@ void tst_qdeclarativelanguage::importsLocal()
testType(qml,type,error);
}
+void tst_qdeclarativelanguage::basicRemote_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ QString serverdir = "http://127.0.0.1:14445/qtest/declarative/qmllanguage/";
+
+ QTest::newRow("no need for qmldir") << QUrl(serverdir+"Test.qml") << "" << "";
+ QTest::newRow("need qmldir") << QUrl(serverdir+"TestLocal.qml") << "" << "";
+}
+
+void tst_qdeclarativelanguage::basicRemote()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(14445);
+ server.serveDirectory(SRCDIR);
+
+ QDeclarativeComponent component(&engine, url);
+
+ QTRY_VERIFY(!component.isLoading());
+
+ if (error.isEmpty()) {
+ if (component.isError())
+ qDebug() << component.errors();
+ QVERIFY(!component.isError());
+ } else {
+ QVERIFY(component.isError());
+ }
+}
+
void tst_qdeclarativelanguage::importsRemote_data()
{
QTest::addColumn<QString>("qml");
@@ -1320,8 +1357,6 @@ void tst_qdeclarativelanguage::importsRemote_data()
<< "UndeclaredLocal is not a type";
}
-#include "testhttpserver.h"
-
void tst_qdeclarativelanguage::importsRemote()
{
QFETCH(QString, qml);
diff --git a/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro b/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro
index 7276162..a2065f4 100644
--- a/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro
+++ b/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
index 8813242..9f1e146 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
+++ b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
@@ -7,3 +7,6 @@ SOURCES += tst_qdeclarativelistmodel.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
index 0c9b2d9..f3e6f52 100644
--- a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
+++ b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
@@ -3,3 +3,6 @@ contains(QT_CONFIG,declarative): QT += declarative
macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativelistreference.cpp
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro
index 3a076f8..5d962c0 100644
--- a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro
+++ b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro
@@ -6,3 +6,5 @@ SOURCES += tst_qdeclarativelistview.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 8d94804..e76da42 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -50,6 +50,7 @@
#include <QtDeclarative/private/qdeclarativevisualitemmodel_p.h>
#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
#include <QtDeclarative/private/qlistmodelinterface_p.h>
+#include "../../../shared/util.h"
class tst_QDeclarativeListView : public QObject
{
@@ -325,62 +326,59 @@ void tst_QDeclarativeListView::items()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
+ QTRY_VERIFY(testObject->error() == false);
- QVERIFY(listview->highlightItem() != 0);
- QCOMPARE(listview->count(), model.count());
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_VERIFY(listview->highlightItem() != 0);
+ QTRY_COMPARE(listview->count(), model.count());
+ QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
// current item should be first item
- QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
+ QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
for (int i = 0; i < model.count(); ++i) {
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
}
// switch to other delegate
testObject->setAnimate(true);
QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
- QVERIFY(listview->currentItem());
+ QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(listview->currentItem());
// set invalid highlight
testObject->setInvalidHighlight(true);
QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
- QVERIFY(listview->currentItem());
- QVERIFY(listview->highlightItem() == 0);
+ QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(listview->currentItem());
+ QTRY_VERIFY(listview->highlightItem() == 0);
// back to normal highlight
testObject->setInvalidHighlight(false);
QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
- QVERIFY(listview->currentItem());
- QVERIFY(listview->highlightItem() != 0);
+ QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(listview->currentItem());
+ QTRY_VERIFY(listview->highlightItem() != 0);
// set an empty model and confirm that items are destroyed
T model2;
ctxt->setContextProperty("testModel", &model2);
- // Allow deleteLaters to process
- QTest::qWait(500);
-
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
- QVERIFY(itemCount == 0);
+ QTRY_VERIFY(itemCount == 0);
- QCOMPARE(listview->highlightResizeSpeed(), 1000.0);
- QCOMPARE(listview->highlightMoveSpeed(), 1000.0);
+ QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0);
+ QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0);
delete canvas;
}
@@ -406,18 +404,18 @@ void tst_QDeclarativeListView::changed()
qApp->processEvents();
QDeclarativeFlickable *listview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
model.modifyItem(1, "Will", "9876");
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
delete canvas;
}
@@ -442,75 +440,66 @@ void tst_QDeclarativeListView::inserted()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
model.insertItem(1, "Will", "9876");
- // let transitions settle.
- QTest::qWait(300);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
- QCOMPARE(item->y(), i*20.0);
+ QTRY_COMPARE(item->y(), i*20.0);
}
model.insertItem(0, "Foo", "1111"); // zero index, and current item
- // let transitions settle.
- QTest::qWait(300);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
name = findItem<QDeclarativeText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
- QCOMPARE(listview->currentIndex(), 1);
+ QTRY_COMPARE(listview->currentIndex(), 1);
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
- QCOMPARE(item->y(), i*20.0);
+ QTRY_COMPARE(item->y(), i*20.0);
}
for (int i = model.count(); i < 30; ++i)
model.insertItem(i, "Hello", QString::number(i));
- QTest::qWait(300);
listview->setContentY(80);
- QTest::qWait(300);
// Insert item outside visible area
model.insertItem(1, "Hello", "1324");
- QTest::qWait(300);
- QVERIFY(listview->contentY() == 80);
+ QTRY_VERIFY(listview->contentY() == 80);
// Confirm items positioned correctly
for (int i = 5; i < 5+15; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0 - 20.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.0 - 20.0);
}
-// QCOMPARE(listview->viewportHeight(), model.count() * 20.0);
+// QTRY_COMPARE(listview->viewportHeight(), model.count() * 20.0);
delete canvas;
}
@@ -535,66 +524,60 @@ void tst_QDeclarativeListView::removed(bool animated)
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
model.removeItem(1);
- // let transitions settle.
- QTest::qWait(300);
-
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
}
// Remove first item (which is the current item);
model.removeItem(0); // post: top item starts at 20
- // let transitions settle.
QTest::qWait(300);
name = findItem<QDeclarativeText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),i*20.0 + 20.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),i*20.0 + 20.0);
}
// Remove items not visible
model.removeItem(18);
- // let transitions settle.
- QTest::qWait(300);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),i*20.0+20.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),i*20.0+20.0);
}
// Remove items before visible
@@ -602,25 +585,22 @@ void tst_QDeclarativeListView::removed(bool animated)
listview->setCurrentIndex(10);
model.removeItem(1); // post: top item will be at 40
- // let transitions settle.
- QTest::qWait(300);
// Confirm items positioned correctly
for (int i = 2; i < 18; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),40+i*20.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),40+i*20.0);
}
// Remove current index
- QVERIFY(listview->currentIndex() == 9);
+ QTRY_VERIFY(listview->currentIndex() == 9);
QDeclarativeItem *oldCurrent = listview->currentItem();
model.removeItem(9);
- QTest::qWait(300);
- QCOMPARE(listview->currentIndex(), 9);
- QVERIFY(listview->currentItem() != oldCurrent);
+ QTRY_COMPARE(listview->currentIndex(), 9);
+ QTRY_VERIFY(listview->currentItem() != oldCurrent);
listview->setContentY(40); // That's the top now
// let transitions settle.
@@ -631,29 +611,25 @@ void tst_QDeclarativeListView::removed(bool animated)
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),40+i*20.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),40+i*20.0);
}
// remove current item beyond visible items.
listview->setCurrentIndex(20);
- QTest::qWait(300);
listview->setContentY(40);
model.removeItem(20);
- QTest::qWait(300);
- QCOMPARE(listview->currentIndex(), 20);
- QVERIFY(listview->currentItem() != 0);
+ QTRY_COMPARE(listview->currentIndex(), 20);
+ QTRY_VERIFY(listview->currentItem() != 0);
// remove item before current, but visible
listview->setCurrentIndex(8);
- QTest::qWait(300);
oldCurrent = listview->currentItem();
model.removeItem(6);
- QTest::qWait(300);
- QCOMPARE(listview->currentIndex(), 7);
- QVERIFY(listview->currentItem() == oldCurrent);
+ QTRY_COMPARE(listview->currentIndex(), 7);
+ QTRY_VERIFY(listview->currentItem() == oldCurrent);
delete canvas;
}
@@ -677,19 +653,16 @@ void tst_QDeclarativeListView::clear()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
model.clear();
- // let transitions settle.
- QTest::qWait(500);
-
- QVERIFY(listview->count() == 0);
- QVERIFY(listview->currentItem() == 0);
- QVERIFY(listview->contentY() == 0);
+ QTRY_VERIFY(listview->count() == 0);
+ QTRY_VERIFY(listview->currentItem() == 0);
+ QTRY_VERIFY(listview->contentY() == 0);
delete canvas;
}
@@ -714,37 +687,34 @@ void tst_QDeclarativeListView::moved()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
model.moveItem(1, 4);
- // let transitions settle.
- QTest::qWait(500);
-
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
name = findItem<QDeclarativeText>(viewport, "textName", 4);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(4));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(4));
number = findItem<QDeclarativeText>(viewport, "textNumber", 4);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(4));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(4));
// Confirm items positioned correctly
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
}
listview->setContentY(80);
@@ -752,41 +722,35 @@ void tst_QDeclarativeListView::moved()
// move outside visible area
model.moveItem(1, 18);
- // let transitions settle.
- QTest::qWait(500);
-
// Confirm items positioned correctly and indexes correct
for (int i = 3; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0 + 20);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.0 + 20);
name = findItem<QDeclarativeText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
number = findItem<QDeclarativeText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
}
// move from outside visible into visible
model.moveItem(20, 4);
- // let transitions settle.
- QTest::qWait(500);
-
// Confirm items positioned correctly and indexes correct
for (int i = 3; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0 + 20);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.0 + 20);
name = findItem<QDeclarativeText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
number = findItem<QDeclarativeText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
}
delete canvas;
@@ -807,32 +771,31 @@ void tst_QDeclarativeListView::enforceRange()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
- QCOMPARE(listview->preferredHighlightBegin(), 100.0);
- QCOMPARE(listview->preferredHighlightEnd(), 100.0);
- QCOMPARE(listview->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange);
+ QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0);
+ QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0);
+ QTRY_COMPARE(listview->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
// view should be positioned at the top of the range.
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(listview->contentY(), -100.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(listview->contentY(), -100.0);
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
// Check currentIndex is updated when viewport moves
listview->setContentY(20);
- QTest::qWait(500);
- QCOMPARE(listview->currentIndex(), 6);
+ QTRY_COMPARE(listview->currentIndex(), 6);
delete canvas;
}
@@ -855,30 +818,30 @@ void tst_QDeclarativeListView::spacing()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
// Confirm items positioned correctly
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
}
listview->setSpacing(10);
- QVERIFY(listview->spacing() == 10);
+ QTRY_VERIFY(listview->spacing() == 10);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*30);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*30);
}
listview->setSpacing(0);
@@ -888,8 +851,8 @@ void tst_QDeclarativeListView::spacing()
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.0);
}
delete canvas;
@@ -910,63 +873,60 @@ void tst_QDeclarativeListView::sections()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
// Confirm items positioned correctly
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
- QVERIFY(item);
- QCOMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
}
// Remove section boundary
model.removeItem(5);
- QTest::qWait(100);
// New section header created
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
- QVERIFY(item);
- QCOMPARE(item->height(), 40.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
model.insertItem(3, "New Item", "0");
- QTest::qWait(100);
// Section header moved
item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
- QVERIFY(item);
- QCOMPARE(item->height(), 20.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 20.0);
item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
- QVERIFY(item);
- QCOMPARE(item->height(), 40.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
// insert item which will become a section header
model.insertItem(6, "Replace header", "1");
- QTest::qWait(100);
item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
- QVERIFY(item);
- QCOMPARE(item->height(), 40.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
item = findItem<QDeclarativeItem>(viewport, "wrapper", 7);
- QVERIFY(item);
- QCOMPARE(item->height(), 20.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 20.0);
- QCOMPARE(listview->currentSection(), QString("0"));
+ QTRY_COMPARE(listview->currentSection(), QString("0"));
listview->setContentY(140);
- QCOMPARE(listview->currentSection(), QString("1"));
+ QTRY_COMPARE(listview->currentSection(), QString("1"));
listview->setContentY(20);
- QCOMPARE(listview->currentSection(), QString("0"));
+ QTRY_COMPARE(listview->currentSection(), QString("0"));
item = findItem<QDeclarativeItem>(viewport, "wrapper", 1);
- QVERIFY(item);
- QCOMPARE(item->height(), 20.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 20.0);
delete canvas;
}
@@ -990,45 +950,41 @@ void tst_QDeclarativeListView::currentIndex()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- QTest::qWait(500);
+ QTRY_VERIFY(viewport != 0);
// current item should be third item
- QCOMPARE(listview->currentIndex(), 3);
- QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 3));
- QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
+ QTRY_COMPARE(listview->currentIndex(), 3);
+ QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 3));
+ QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
// no wrap
listview->setCurrentIndex(0);
- QCOMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->currentIndex(), 0);
listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 1);
+ QTRY_COMPARE(listview->currentIndex(), 1);
listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->currentIndex(), 0);
listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->currentIndex(), 0);
// with wrap
ctxt->setContextProperty("testWrap", QVariant(true));
- QVERIFY(listview->isWrapEnabled());
+ QTRY_VERIFY(listview->isWrapEnabled());
listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), model.count()-1);
+ QTRY_COMPARE(listview->currentIndex(), model.count()-1);
- QTest::qWait(1000);
- QCOMPARE(listview->contentY(), 279.0);
+ QTRY_COMPARE(listview->contentY(), 279.0);
listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->currentIndex(), 0);
- QTest::qWait(1000);
- QCOMPARE(listview->contentY(), 0.0);
+ QTRY_COMPARE(listview->contentY(), 0.0);
// Test keys
canvas->show();
@@ -1037,32 +993,30 @@ void tst_QDeclarativeListView::currentIndex()
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(canvas);
#endif
- QVERIFY(canvas->hasFocus());
- QVERIFY(canvas->scene()->hasFocus());
+ QTRY_VERIFY(canvas->hasFocus());
+ QTRY_VERIFY(canvas->scene()->hasFocus());
qApp->processEvents();
QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(listview->currentIndex(), 1);
+ QTRY_COMPARE(listview->currentIndex(), 1);
QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->currentIndex(), 0);
// turn off auto highlight
listview->setHighlightFollowsCurrentItem(false);
- QVERIFY(listview->highlightFollowsCurrentItem() == false);
+ QTRY_VERIFY(listview->highlightFollowsCurrentItem() == false);
- QTest::qWait(500);
- QVERIFY(listview->highlightItem());
+ QTRY_VERIFY(listview->highlightItem());
qreal hlPos = listview->highlightItem()->y();
listview->setCurrentIndex(4);
- QTest::qWait(500);
- QCOMPARE(listview->highlightItem()->y(), hlPos);
+ QTRY_COMPARE(listview->highlightItem()->y(), hlPos);
// insert item before currentIndex
listview->setCurrentIndex(28);
model.insertItem(0, "Foo", "1111");
- QCOMPARE(canvas->rootObject()->property("current").toInt(), 29);
+ QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
delete canvas;
}
@@ -1075,35 +1029,34 @@ void tst_QDeclarativeListView::itemList()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "view");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
QDeclarativeVisualItemModel *model = canvas->rootObject()->findChild<QDeclarativeVisualItemModel*>("itemModel");
- QVERIFY(model != 0);
+ QTRY_VERIFY(model != 0);
- QVERIFY(model->count() == 3);
- QCOMPARE(listview->currentIndex(), 0);
+ QTRY_VERIFY(model->count() == 3);
+ QTRY_COMPARE(listview->currentIndex(), 0);
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "item1");
- QVERIFY(item);
- QCOMPARE(item->x(), 0.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), 0.0);
QDeclarativeText *text = findItem<QDeclarativeText>(viewport, "text1");
- QVERIFY(text);
- QCOMPARE(text->text(), QLatin1String("index: 0"));
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
listview->setCurrentIndex(2);
- QTest::qWait(1000);
item = findItem<QDeclarativeItem>(viewport, "item3");
- QVERIFY(item);
- QCOMPARE(item->x(), 480.0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), 480.0);
text = findItem<QDeclarativeText>(viewport, "text3");
- QVERIFY(text);
- QCOMPARE(text->text(), QLatin1String("index: 2"));
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
delete canvas;
}
@@ -1126,35 +1079,35 @@ void tst_QDeclarativeListView::cacheBuffer()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
- QVERIFY(listview->delegate() != 0);
- QVERIFY(listview->model() != 0);
- QVERIFY(listview->highlight() != 0);
+ QTRY_VERIFY(viewport != 0);
+ QTRY_VERIFY(listview->delegate() != 0);
+ QTRY_VERIFY(listview->model() != 0);
+ QTRY_VERIFY(listview->highlight() != 0);
// Confirm items positioned correctly
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
}
testObject->setCacheBuffer(400);
- QVERIFY(listview->cacheBuffer() == 400);
+ QTRY_VERIFY(listview->cacheBuffer() == 400);
int newItemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
- QVERIFY(newItemCount > itemCount);
+ QTRY_VERIFY(newItemCount > itemCount);
// Confirm items positioned correctly
for (int i = 0; i < model.count() && i < newItemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
}
delete canvas;
@@ -1178,112 +1131,112 @@ void tst_QDeclarativeListView::positionViewAtIndex()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
// Confirm items positioned correctly
int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
}
// Position on a currently visible item
listview->positionViewAtIndex(3, QDeclarativeListView::Beginning);
- QCOMPARE(listview->contentY(), 60.);
+ QTRY_COMPARE(listview->contentY(), 60.);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
}
// Position on an item beyond the visible items
listview->positionViewAtIndex(22, QDeclarativeListView::Beginning);
- QCOMPARE(listview->contentY(), 440.);
+ QTRY_COMPARE(listview->contentY(), 440.);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
}
// Position on an item that would leave empty space if positioned at the top
listview->positionViewAtIndex(28, QDeclarativeListView::Beginning);
- QCOMPARE(listview->contentY(), 480.);
+ QTRY_COMPARE(listview->contentY(), 480.);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
}
// Position at the beginning again
listview->positionViewAtIndex(0, QDeclarativeListView::Beginning);
- QCOMPARE(listview->contentY(), 0.);
+ QTRY_COMPARE(listview->contentY(), 0.);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
}
// Position at End
listview->positionViewAtIndex(20, QDeclarativeListView::End);
- QCOMPARE(listview->contentY(), 100.);
+ QTRY_COMPARE(listview->contentY(), 100.);
// Position in Center
listview->positionViewAtIndex(15, QDeclarativeListView::Center);
- QCOMPARE(listview->contentY(), 150.);
+ QTRY_COMPARE(listview->contentY(), 150.);
// Ensure at least partially visible
listview->positionViewAtIndex(15, QDeclarativeListView::Visible);
- QCOMPARE(listview->contentY(), 150.);
+ QTRY_COMPARE(listview->contentY(), 150.);
listview->setContentY(302);
listview->positionViewAtIndex(15, QDeclarativeListView::Visible);
- QCOMPARE(listview->contentY(), 302.);
+ QTRY_COMPARE(listview->contentY(), 302.);
listview->setContentY(320);
listview->positionViewAtIndex(15, QDeclarativeListView::Visible);
- QCOMPARE(listview->contentY(), 300.);
+ QTRY_COMPARE(listview->contentY(), 300.);
listview->setContentY(85);
listview->positionViewAtIndex(20, QDeclarativeListView::Visible);
- QCOMPARE(listview->contentY(), 85.);
+ QTRY_COMPARE(listview->contentY(), 85.);
listview->setContentY(75);
listview->positionViewAtIndex(20, QDeclarativeListView::Visible);
- QCOMPARE(listview->contentY(), 100.);
+ QTRY_COMPARE(listview->contentY(), 100.);
// Ensure completely visible
listview->setContentY(120);
listview->positionViewAtIndex(20, QDeclarativeListView::Contain);
- QCOMPARE(listview->contentY(), 120.);
+ QTRY_COMPARE(listview->contentY(), 120.);
listview->setContentY(302);
listview->positionViewAtIndex(15, QDeclarativeListView::Contain);
- QCOMPARE(listview->contentY(), 300.);
+ QTRY_COMPARE(listview->contentY(), 300.);
listview->setContentY(85);
listview->positionViewAtIndex(20, QDeclarativeListView::Contain);
- QCOMPARE(listview->contentY(), 100.);
+ QTRY_COMPARE(listview->contentY(), 100.);
delete canvas;
}
@@ -1303,40 +1256,40 @@ void tst_QDeclarativeListView::resetModel()
qApp->processEvents();
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
+ QTRY_VERIFY(listview != 0);
QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QTRY_VERIFY(viewport != 0);
- QCOMPARE(listview->count(), model.rowCount());
+ QTRY_COMPARE(listview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
}
strings.clear();
strings << "four" << "five" << "six" << "seven";
model.setStringList(strings);
- QCOMPARE(listview->count(), model.rowCount());
+ QTRY_COMPARE(listview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
}
}
void tst_QDeclarativeListView::propertyChanges()
{
QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
+ QTRY_VERIFY(canvas);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView");
- QVERIFY(listView);
+ QTRY_VERIFY(listView);
QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged()));
QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged()));
@@ -1346,13 +1299,13 @@ void tst_QDeclarativeListView::propertyChanges()
QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged()));
QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged()));
- QCOMPARE(listView->highlightFollowsCurrentItem(), true);
- QCOMPARE(listView->preferredHighlightBegin(), 0.0);
- QCOMPARE(listView->preferredHighlightEnd(), 0.0);
- QCOMPARE(listView->highlightRangeMode(), QDeclarativeListView::ApplyRange);
- QCOMPARE(listView->isWrapEnabled(), true);
- QCOMPARE(listView->cacheBuffer(), 10);
- QCOMPARE(listView->snapMode(), QDeclarativeListView::SnapToItem);
+ QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true);
+ QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0);
+ QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0);
+ QTRY_COMPARE(listView->highlightRangeMode(), QDeclarativeListView::ApplyRange);
+ QTRY_COMPARE(listView->isWrapEnabled(), true);
+ QTRY_COMPARE(listView->cacheBuffer(), 10);
+ QTRY_COMPARE(listView->snapMode(), QDeclarativeListView::SnapToItem);
listView->setHighlightFollowsCurrentItem(false);
listView->setPreferredHighlightBegin(1.0);
@@ -1362,21 +1315,21 @@ void tst_QDeclarativeListView::propertyChanges()
listView->setCacheBuffer(3);
listView->setSnapMode(QDeclarativeListView::SnapOneItem);
- QCOMPARE(listView->highlightFollowsCurrentItem(), false);
- QCOMPARE(listView->preferredHighlightBegin(), 1.0);
- QCOMPARE(listView->preferredHighlightEnd(), 1.0);
- QCOMPARE(listView->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange);
- QCOMPARE(listView->isWrapEnabled(), false);
- QCOMPARE(listView->cacheBuffer(), 3);
- QCOMPARE(listView->snapMode(), QDeclarativeListView::SnapOneItem);
-
- QCOMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QCOMPARE(preferredHighlightBeginSpy.count(),1);
- QCOMPARE(preferredHighlightEndSpy.count(),1);
- QCOMPARE(highlightRangeModeSpy.count(),1);
- QCOMPARE(keyNavigationWrapsSpy.count(),1);
- QCOMPARE(cacheBufferSpy.count(),1);
- QCOMPARE(snapModeSpy.count(),1);
+ QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false);
+ QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0);
+ QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0);
+ QTRY_COMPARE(listView->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange);
+ QTRY_COMPARE(listView->isWrapEnabled(), false);
+ QTRY_COMPARE(listView->cacheBuffer(), 3);
+ QTRY_COMPARE(listView->snapMode(), QDeclarativeListView::SnapOneItem);
+
+ QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
+ QTRY_COMPARE(highlightRangeModeSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(snapModeSpy.count(),1);
listView->setHighlightFollowsCurrentItem(false);
listView->setPreferredHighlightBegin(1.0);
@@ -1386,13 +1339,13 @@ void tst_QDeclarativeListView::propertyChanges()
listView->setCacheBuffer(3);
listView->setSnapMode(QDeclarativeListView::SnapOneItem);
- QCOMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QCOMPARE(preferredHighlightBeginSpy.count(),1);
- QCOMPARE(preferredHighlightEndSpy.count(),1);
- QCOMPARE(highlightRangeModeSpy.count(),1);
- QCOMPARE(keyNavigationWrapsSpy.count(),1);
- QCOMPARE(cacheBufferSpy.count(),1);
- QCOMPARE(snapModeSpy.count(),1);
+ QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
+ QTRY_COMPARE(highlightRangeModeSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(snapModeSpy.count(),1);
delete canvas;
}
@@ -1400,11 +1353,11 @@ void tst_QDeclarativeListView::propertyChanges()
void tst_QDeclarativeListView::componentChanges()
{
QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
+ QTRY_VERIFY(canvas);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView");
- QVERIFY(listView);
+ QTRY_VERIFY(listView);
QDeclarativeComponent component(canvas->engine());
component.setData("import Qt 4.6; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
@@ -1422,25 +1375,25 @@ void tst_QDeclarativeListView::componentChanges()
listView->setFooter(&component);
listView->setDelegate(&delegateComponent);
- QCOMPARE(listView->highlight(), &component);
- QCOMPARE(listView->header(), &component);
- QCOMPARE(listView->footer(), &component);
- QCOMPARE(listView->delegate(), &delegateComponent);
+ QTRY_COMPARE(listView->highlight(), &component);
+ QTRY_COMPARE(listView->header(), &component);
+ QTRY_COMPARE(listView->footer(), &component);
+ QTRY_COMPARE(listView->delegate(), &delegateComponent);
- QCOMPARE(highlightSpy.count(),1);
- QCOMPARE(delegateSpy.count(),1);
- QCOMPARE(headerSpy.count(),1);
- QCOMPARE(footerSpy.count(),1);
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
listView->setHighlight(&component);
listView->setHeader(&component);
listView->setFooter(&component);
listView->setDelegate(&delegateComponent);
- QCOMPARE(highlightSpy.count(),1);
- QCOMPARE(delegateSpy.count(),1);
- QCOMPARE(headerSpy.count(),1);
- QCOMPARE(footerSpy.count(),1);
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
delete canvas;
}
@@ -1448,28 +1401,28 @@ void tst_QDeclarativeListView::componentChanges()
void tst_QDeclarativeListView::modelChanges()
{
QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
+ QTRY_VERIFY(canvas);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView");
- QVERIFY(listView);
+ QTRY_VERIFY(listView);
QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
- QVERIFY(alternateModel);
+ QTRY_VERIFY(alternateModel);
QVariant modelVariant = QVariant::fromValue(alternateModel);
QSignalSpy modelSpy(listView, SIGNAL(modelChanged()));
listView->setModel(modelVariant);
- QCOMPARE(listView->model(), modelVariant);
- QCOMPARE(modelSpy.count(),1);
+ QTRY_COMPARE(listView->model(), modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
listView->setModel(modelVariant);
- QCOMPARE(modelSpy.count(),1);
+ QTRY_COMPARE(modelSpy.count(),1);
listView->setModel(QVariant());
- QCOMPARE(modelSpy.count(),2);
+ QTRY_COMPARE(modelSpy.count(),2);
- delete canvas;
+ delete canvas;
}
void tst_QDeclarativeListView::qListModelInterface_items()
diff --git a/tests/auto/declarative/qdeclarativeloader/data/qmldir b/tests/auto/declarative/qdeclarativeloader/data/qmldir
new file mode 100644
index 0000000..bf42b50
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeloader/data/qmldir
@@ -0,0 +1 @@
+# For tst_QDeclarativeLoader::networkRequestUrl; no types needed though.
diff --git a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro
index 8ff2be4..96fea5b 100644
--- a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro
+++ b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro
@@ -9,3 +9,5 @@ SOURCES += tst_qdeclarativeloader.cpp \
DEFINES += SRCDIR=\\\"$$PWD\\\"
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
index abdd210..20e709d 100644
--- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -412,7 +412,9 @@ void tst_QDeclarativeLoader::networkRequestUrl()
server.serveDirectory(SRCDIR "/data");
QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), QUrl("http://127.0.0.1:14445/dummy.qml"));
+ component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), QUrl(SRCDIR "/dummy.qml"));
+ if (component.isError())
+ qDebug() << component.errors();
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
QVERIFY(loader != 0);
diff --git a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
index 2f7ff82..cf3fa65 100644
--- a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
+++ b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
@@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativemetatype.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
index 96f4454..824b402 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
@@ -4,4 +4,5 @@ SUBDIRS = plugin
tst_qdeclarativemoduleplugin_pro.depends += plugin
SUBDIRS += tst_qdeclarativemoduleplugin.pro
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro
index d01955b..48fe025 100644
--- a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro
+++ b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro
@@ -7,3 +7,6 @@ SOURCES += tst_qdeclarativemousearea.cpp ../shared/testhttpserver.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro
index 043bb85..8a061c3 100644
--- a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro
+++ b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativeparticles.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro
index 2f6ae32..3c327d5 100644
--- a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro
+++ b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativepathview.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
index 899c43f..b5b033a 100644
--- a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
+++ b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
@@ -7,3 +7,6 @@ SOURCES += tst_qdeclarativepixmapcache.cpp
# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
# LIBS += -lgcov
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro
index 5edfa55..dbe2cbee 100644
--- a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro
+++ b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
index af1e1b6..6910ccc 100644
--- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
+++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativeproperty.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro b/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
index aeccf9b..3c0f7b3 100644
--- a/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
+++ b/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
@@ -3,3 +3,6 @@ contains(QT_CONFIG,declarative): QT += declarative
macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativepropertymap.cpp
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
index aff00ad..10e10a3 100644
--- a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
+++ b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
@@ -7,3 +7,6 @@ DEFINES += SRCDIR=\\\"$$PWD\\\"
# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
# LIBS += -lgcov
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro
index 132123a..abd36e0 100644
--- a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro
+++ b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro
@@ -6,3 +6,5 @@ SOURCES += tst_qdeclarativerepeater.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro
index b41b23a..80b757d 100644
--- a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro
+++ b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativesmoothedanimation.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro
index f8e97a0..7f737c2 100644
--- a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro
+++ b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativesmoothedfollow.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro
index 61aad0f..6f400a3 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro
+++ b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativespringfollow.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro
index f874803..706d045 100644
--- a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro
+++ b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro
@@ -6,3 +6,5 @@ SOURCES += tst_qdeclarativestates.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro b/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro
index bd4d829..87d0e5b 100644
--- a/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro
+++ b/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro
@@ -7,3 +7,5 @@ SOURCES += tst_qdeclarativestyledtext.cpp
# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
# LIBS += -lgcov
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro
index 0781774..b2705fa 100644
--- a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro
+++ b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro
@@ -3,3 +3,6 @@ contains(QT_CONFIG,declarative): QT += declarative gui
macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativesystempalette.cpp
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro
index 8b4b4d1..73c05b5 100644
--- a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro
+++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro
@@ -3,3 +3,6 @@ contains(QT_CONFIG,declarative): QT += declarative gui
macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativetext.cpp
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml
index de4de00..a44e867 100644
--- a/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml
@@ -1,5 +1,4 @@
import Qt 4.6
-import "http://localhost:42332"
Rectangle { width: 300; height: 300; color: "white"
resources: [
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index d578f68..6ef1f9f 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -79,6 +79,7 @@ private slots:
void inputMethodHints();
void cursorDelegate();
+ void delegateLoading_data();
void delegateLoading();
void navigation();
void readOnly();
@@ -641,41 +642,60 @@ void tst_qdeclarativetextedit::cursorDelegate()
QVERIFY(!textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
}
+void tst_qdeclarativetextedit::delegateLoading_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<QString>("error");
+
+ // import installed
+ QTest::newRow("pass") << "cursorHttpTestPass.qml" << "";
+ QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << ":-1: Network error for URL http://localhost:42332/FailItem.qml ";
+ QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type ";
+}
+
void tst_qdeclarativetextedit::delegateLoading()
{
+ QFETCH(QString, qmlfile);
+ QFETCH(QString, error);
+
TestHTTPServer server(42332);
server.serveDirectory(SRCDIR "/data/httpfail", TestHTTPServer::Disconnect);
server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay);
server.serveDirectory(SRCDIR "/data/http");
+
QDeclarativeView* view = new QDeclarativeView(0);
- view->setSource(QUrl("http://localhost:42332/cursorHttpTestPass.qml"));
- view->show();
- view->setFocus();
- QTRY_VERIFY(view->rootObject());//Wait for loading to finish.
- QDeclarativeTextEdit *textEditObject = view->rootObject()->findChild<QDeclarativeTextEdit*>("textEditObject");
- // view->rootObject()->dumpObjectTree();
- QVERIFY(textEditObject != 0);
- textEditObject->setFocus(true);
- QDeclarativeItem *delegate;
- delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateOkay");
- QVERIFY(delegate);
- delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateSlow");
- QVERIFY(delegate);
- view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml"));
- view->show();
- QTRY_VERIFY(view->status()==QDeclarativeView::Error);
- view->setFocus();
- QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
- view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml"));
+
+ view->setSource(QUrl(QLatin1String("http://localhost:42332/") + qmlfile));
view->show();
- QTRY_VERIFY(view->status()==QDeclarativeView::Error);
view->setFocus();
- QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
+
+ if (!error.isEmpty()) {
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+ QTRY_VERIFY(view->status()==QDeclarativeView::Error);
+ QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
+ } else {
+ QTRY_VERIFY(view->rootObject());//Wait for loading to finish.
+ QDeclarativeTextEdit *textEditObject = view->rootObject()->findChild<QDeclarativeTextEdit*>("textEditObject");
+ // view->rootObject()->dumpObjectTree();
+ QVERIFY(textEditObject != 0);
+ textEditObject->setFocus(true);
+ QDeclarativeItem *delegate;
+ delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateOkay");
+ QVERIFY(delegate);
+ delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateSlow");
+ QVERIFY(delegate);
+
+ delete delegate;
+ }
+
+
//A test should be added here with a component which is ready but component.create() returns null
//Not sure how to accomplish this with QDeclarativeTextEdits cursor delegate
//###This was only needed for code coverage, and could be a case of overzealous defensive programming
//delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateErrorB");
//QVERIFY(!delegate);
+
+ delete view;
}
/*
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml b/tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml
index 5773cc2..66a2017 100644
--- a/tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml
@@ -1,7 +1,7 @@
import Qt 4.7
Rectangle {
- property var myInput: input
+ property QtObject myInput: input
width: 400; height: 200; color: "green"
diff --git a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro
index 5aed51f..957e75c 100644
--- a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro
+++ b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro
@@ -6,3 +6,4 @@ SOURCES += tst_qdeclarativetextinput.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
diff --git a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro
index b162739..42604d8 100644
--- a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro
+++ b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro
@@ -5,3 +5,5 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativetimer.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
index 028fc57..d9f1c13 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
+++ b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
@@ -8,3 +8,6 @@ SOURCES += tst_qdeclarativevaluetypes.cpp \
testtypes.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
index 20173c6..956272f 100644
--- a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
+++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
@@ -7,3 +7,5 @@ SOURCES += tst_qdeclarativewebview.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
index e2b31c7..2e3da4d 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
+++ b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
@@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativeworkerscript.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
index 7bc92af..160300e 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
@@ -11,3 +11,6 @@ SOURCES += tst_qdeclarativexmlhttprequest.cpp \
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
index 88832dc..8c5052a 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
@@ -9,3 +9,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativexmllistmodel.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 7edf7e9..cf7e357 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -320,7 +320,21 @@ void tst_qdeclarativexmllistmodel::source()
QCOMPARE(model->progress(), qreal(0.0));
QTRY_COMPARE(spy.count(), 1); spy.clear();
QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
+
+ QEventLoop loop;
+ QTimer timer;
+ timer.setSingleShot(true);
+ connect(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)), &loop, SLOT(quit()));
+ connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.start(20000);
+ loop.exec();
+
+ if (spy.count() == 0 && status != QDeclarativeXmlListModel::Ready) {
+ qWarning("QDeclarativeXmlListModel invalid source test timed out");
+ } else {
+ QCOMPARE(spy.count(), 1); spy.clear();
+ }
+
QCOMPARE(model->status(), status);
QCOMPARE(model->count(), count);
if (status == QDeclarativeXmlListModel::Ready)
@@ -336,9 +350,7 @@ void tst_qdeclarativexmllistmodel::source_data()
QTest::addColumn<QDeclarativeXmlListModel::Status>("status");
QTest::newRow("valid") << QUrl::fromLocalFile(SRCDIR "/data/model2.xml") << 2 << QDeclarativeXmlListModel::Ready;
-
- // XXX This test fails on the rare occasion due to networking, fix the test for Error status signal (323)
- //QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarativeXmlListModel::Error;
+ QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarativeXmlListModel::Error;
// empty file
QTemporaryFile *temp = new QTemporaryFile(this);
diff --git a/tests/auto/declarative/qmetaobjectbuilder/qmetaobjectbuilder.pro b/tests/auto/declarative/qmetaobjectbuilder/qmetaobjectbuilder.pro
index 94ffe4b..988177e 100644
--- a/tests/auto/declarative/qmetaobjectbuilder/qmetaobjectbuilder.pro
+++ b/tests/auto/declarative/qmetaobjectbuilder/qmetaobjectbuilder.pro
@@ -5,3 +5,4 @@ macx:CONFIG -= app_bundle
SOURCES += \
tst_qmetaobjectbuilder.cpp
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qmlvisual/qmlvisual.pro b/tests/auto/declarative/qmlvisual/qmlvisual.pro
index f2b3bca..a3abbe3 100644
--- a/tests/auto/declarative/qmlvisual/qmlvisual.pro
+++ b/tests/auto/declarative/qmlvisual/qmlvisual.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qmlvisual.cpp
DEFINES += QT_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/qpacketprotocol/qpacketprotocol.pro b/tests/auto/declarative/qpacketprotocol/qpacketprotocol.pro
index f42cecc..7ffda93 100644
--- a/tests/auto/declarative/qpacketprotocol/qpacketprotocol.pro
+++ b/tests/auto/declarative/qpacketprotocol/qpacketprotocol.pro
@@ -5,3 +5,5 @@ macx:CONFIG -= app_bundle
HEADERS += ../shared/debugutil_p.h
SOURCES += tst_qpacketprotocol.cpp \
../shared/debugutil.cpp
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/sql/sql.pro b/tests/auto/declarative/sql/sql.pro
index 4217eac..7e4fdd8 100644
--- a/tests/auto/declarative/sql/sql.pro
+++ b/tests/auto/declarative/sql/sql.pro
@@ -7,3 +7,6 @@ SOURCES += tst_sql.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+