summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-11-11 08:37:12 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-11-11 08:37:12 (GMT)
commit835a23891567831cf184e5bbaba8d00bfc912699 (patch)
treea181ff2bbf6fc50e0ea582ffc4747667c17cac37
parent66c88ce06e61ea58977fad9646fe5f072652a051 (diff)
parentd1d900561a9a51bd44707546e691b013341e221c (diff)
downloadQt-835a23891567831cf184e5bbaba8d00bfc912699.zip
Qt-835a23891567831cf184e5bbaba8d00bfc912699.tar.gz
Qt-835a23891567831cf184e5bbaba8d00bfc912699.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/declarative/minehunt/main.cpp1
-rwxr-xr-xdemos/declarative/minehunt/minehuntbin0 -> 302213 bytes
-rw-r--r--demos/declarative/minehunt/minehunt.qml5
-rw-r--r--demos/declarative/minehunt/test.qml13
-rw-r--r--doc/src/declarative/advtutorial.qdoc8
-rw-r--r--doc/src/declarative/advtutorial1.qdoc5
-rw-r--r--doc/src/declarative/advtutorial2.qdoc4
-rw-r--r--doc/src/declarative/advtutorial3.qdoc4
-rw-r--r--doc/src/declarative/advtutorial4.qdoc25
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/content/samegame.js4
-rw-r--r--src/declarative/util/qmlpropertymap.cpp2
-rw-r--r--src/declarative/util/qmlpropertymap.h (renamed from src/declarative/util/qmlpropertymap_p.h)0
-rw-r--r--src/declarative/util/util.pri2
-rw-r--r--tests/auto/declarative/repeater/data/intmodel.qml17
-rw-r--r--tests/auto/declarative/repeater/data/objlist.qml21
-rw-r--r--tests/auto/declarative/repeater/tst_repeater.cpp38
16 files changed, 125 insertions, 24 deletions
diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp
index 5e67cc1..895648f 100644
--- a/demos/declarative/minehunt/main.cpp
+++ b/demos/declarative/minehunt/main.cpp
@@ -174,6 +174,7 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags
QmlContext *ctxt = canvas->rootContext();
ctxt->addDefaultObject(this);
+ ctxt->setContextProperty("tiles", QVariant::fromValue<QList<Tile*>*>(&_tiles));//QTBUG-5675
canvas->execute();
}
diff --git a/demos/declarative/minehunt/minehunt b/demos/declarative/minehunt/minehunt
new file mode 100755
index 0000000..94584a9
--- /dev/null
+++ b/demos/declarative/minehunt/minehunt
Binary files differ
diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml
index 596e82d..ff00d83 100644
--- a/demos/declarative/minehunt/minehunt.qml
+++ b/demos/declarative/minehunt/minehunt.qml
@@ -107,8 +107,8 @@ Item {
onPressed: {
field.clickx = flipable.parent.x;
field.clicky = flipable.parent.y;
- row = Math.floor(index/9);
- col = index - (Math.floor(index/9) * 9);
+ var row = Math.floor(index/9);
+ var col = index - (Math.floor(index/9) * 9);
if (mouse.button==undefined || mouse.button==Qt.RightButton) {
flag(row,col);
} else {
@@ -131,6 +131,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
}
Repeater {
+ id: repeater
model: tiles
x: 1
y: 1
diff --git a/demos/declarative/minehunt/test.qml b/demos/declarative/minehunt/test.qml
new file mode 100644
index 0000000..11ed182
--- /dev/null
+++ b/demos/declarative/minehunt/test.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+
+ Image {
+ source: "pics/front.png"
+ width: 40
+ height: 40
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ source: "pics/flag.png"
+ opacity: 1
+ }
+ }
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index 21eab92..c796633 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -53,10 +53,10 @@ The results of the individual steps are in the $QTDIR/examples/declarative/tutor
Tutorial chapters:
\list
-\o \l {advtutorial1}{Advanced Tutorial 1 - Basic Game Screen and Block}
-\o \l {advtutorial2}{Advanced Tutorial 2 - Dynamically create the Blocks}
-\o \l {advtutorial3}{Advanced Tutorial 3 - Implement the Game Logic}
-\o \l {advtutorial4}{Advanced Tutorial 4 - Finishing Touches}
+\o \l {Advanced Tutorial 1 - Creating the Game Canvas and Blocks}
+\o \l {Advanced Tutorial 2 - Populating the Game Canvas}
+\o \l {Advanced Tutorial 3 - Implementing the Game Logic}
+\o \l {Advanced Tutorial 4 - Finishing Touches}
\endlist
*/
diff --git a/doc/src/declarative/advtutorial1.qdoc b/doc/src/declarative/advtutorial1.qdoc
index 1d47615..66fa607 100644
--- a/doc/src/declarative/advtutorial1.qdoc
+++ b/doc/src/declarative/advtutorial1.qdoc
@@ -42,8 +42,7 @@
/*!
\page advtutorial1.html
\example declarative/tutorials/samegame/samegame1
-\target advtutorial1
-\title Advanced Tutorial 1 - Creating the Game canvas and block
+\title Advanced Tutorial 1 - Creating the Game Canvas and Blocks
The first step is to create the items in your application. In Same Game we have a main game screen and the blocks that populate it.
@@ -79,6 +78,6 @@ You should be familiar with all that goes on in these files so far. This is a
very basic start and doesn't move at all - next we will populate the game canvas
with some blocks.
-[\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {advtutorial2}{Advanced Tutorial 2}]
+[\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {Advanced Tutorial 2 - Populating the Game Canvas}]
*/
diff --git a/doc/src/declarative/advtutorial2.qdoc b/doc/src/declarative/advtutorial2.qdoc
index 0265446..abfdbc6 100644
--- a/doc/src/declarative/advtutorial2.qdoc
+++ b/doc/src/declarative/advtutorial2.qdoc
@@ -41,7 +41,7 @@
/*!
\page advtutorial2.html
-\target advtutorial2
+\example declarative/tutorials/samegame/samegame2
\title Advanced Tutorial 2 - Populating the Game Canvas
Now that we've written some basic elements, let's start writing the game. The
@@ -103,6 +103,6 @@ by adding a script element to it.
With those two changes, and the script file, you are now dynamically creating a field of blocks you can play with.
They don't do anything now though; the next chapter will add the game mechanics.
-[Previous: \l {advtutorial1}{Advanced Tutorial 1}] [\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {advtutorial3}{Advanced Tutorial 3}]
+[Previous: \l {Advanced Tutorial 1 - Creating the Game canvas and block}] [\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {Advanced Tutorial 3 - Implementing the Game Logic}]
*/
diff --git a/doc/src/declarative/advtutorial3.qdoc b/doc/src/declarative/advtutorial3.qdoc
index ea504aa..0d236e4 100644
--- a/doc/src/declarative/advtutorial3.qdoc
+++ b/doc/src/declarative/advtutorial3.qdoc
@@ -41,7 +41,7 @@
/*!
\page advtutorial3.html
-\target advtutorial3
+\example declarative/tutorials/samegame/samegame3
\title Advanced Tutorial 3 - Implementing the Game Logic
To the \c initBoard function we added clearing the board beforehand, so that clicking new game won't leave the previous game
@@ -111,7 +111,7 @@ The game works, but it's a little boring right now. Where's the smooth animated
If you were a QML expert you could have written these in for the first iteration, but in this tutorial they've been saved
until the next chapter - where your application becomes alive!
-[Previous: \l {advtutorial2}{Advanced Tutorial 2}] [\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {advtutorial4}{Advanced Tutorial 4}]
+[Previous: \l {Advanced Tutorial 2 - Populating the Game Canvas}] [\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {Advanced Tutorial 4 - Finishing Touches}]
*/
diff --git a/doc/src/declarative/advtutorial4.qdoc b/doc/src/declarative/advtutorial4.qdoc
index 5f8c0e9..f4724d8 100644
--- a/doc/src/declarative/advtutorial4.qdoc
+++ b/doc/src/declarative/advtutorial4.qdoc
@@ -41,7 +41,7 @@
/*!
\page advtutorial4.html
-\target advtutorial4
+\example declarative/tutorials/samegame/samegame4
\title Advanced Tutorial 4 - Finishing Touches
Now we're going to do two things to liven the game up. Animate the blocks and add a web-based high score system.
@@ -118,17 +118,26 @@ player's actions. The end result is shown below:
\image declarative-adv-tutorial4.gif
+\section2 Offline High Scores
+Another extension we might want for the game is some way of storing and retrieving high scores. This tutorial contains both online and offline high score storage.
+
+For better high score data, we want the name and time of the player. The time is obtained in the script fairly simply, but we
+have to ask the player for their name. We thus re-use the dialog QML file to pop up a dialog asking for the player's name (and
+if they exit this dialog without entering it they have a way to opt out of posting their high score). When the dialog is closed we store the name and high score, using the code below.
+
+\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 2
+
+For offline storage, we use the HTML 5 offline storage javascript API to maintain a persistant SQL database unique to this application. This first line in this function calls the function for the web-based high scores, described later, if it has been setup. Next we create an offline storage database for the high scores using openDatabase and prepare the data and SQL query that we want to use to save it. The offline storage API uses SQL queries for data manipulation and retrival, and in the db.transaction call we use three SQL queries to initialize the database (if necessary), and then add to and retrieve high scores. To use the returned data, we turn it into a string with one line per row returned, and show a dialog containing that string. For a more detailed explanation of the offline storage API in QML, consult the global object documentation.
+
+This is one way of storing and displaying high scores locally, but not the only way. A more complex alternative would have been to create a high score dialog component, and pass the results to it for processing and display (instead of resusing the Dialog). This would allow a more themable dialog that could present the high scores better. If your QML is the UI for a C++ application, you could also have passed the score to a C++ function to store it locally in a variety of ways, including a simple format without SQL.
+
\section2 Web-based High Scores
-Another extension we might want for the game is some way of storing and retrieving high scores. In this tutorial we'll show you
-how to integrate a web enabled high score storage into your QML application. The implementation we've done is very
+You've seen how to store high scores locally, but it is also easy to integrate a web enabled high score storage into your QML application. This tutorial also shows you how to communicate the high scores to a web server. The implementation we've done is very
simple - the high score data is posted to a php script running on a server somewhere, and that server then stores it and
displays it to visitors. You could request an XML or QML file from that same server, which contained and displayed the scores,
-but that's beyond the scope of this tutorial.
+but that's beyond the scope of this tutorial. The php script we've used is available in the examples directory.
-For better high score data, we want the name and time of the player. The time is obtained in the script fairly simply, but we
-have to ask the player for their name. We thus re-use the dialog QML file to pop up a dialog asking for the player's name (and
-if they exit this dialog without entering it they have a way to opt out of posting their high score). When the dialog is closed,
if the player entered their name we can send the data to the web service in the following snippet out of the script file:
\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 1
@@ -145,5 +154,5 @@ By following this tutorial you've now ben shown how to write a fully functional
written in a script file and with both many fluid animations and being web-enabled. Congratulations, you should now be skilled
enough to write your own QML applications.
-[Previous: \l {advtutorial3}{Advanced Tutorial 3}] [\l {advtutorial.html}{Advanced Tutorial}]
+[Previous: \l {Advanced Tutorial 3 - Implementing the Game Logic}] [\l {advtutorial.html}{Advanced Tutorial}]
*/
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
index 58de55f..d5778fe 100755
--- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
@@ -5,7 +5,7 @@ var maxY = 15;
var maxIndex = maxX*maxY;
var board = new Array(maxIndex);
var tileSrc = "content/BoomBlock.qml";
-var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php";
+//var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php";
var scoresURL = "";
var timer;
var component = createComponent(tileSrc);
@@ -206,6 +206,7 @@ function createBlock(xIdx,yIdx){
return true;
}
+//![2]
function saveHighScore(name) {
if(scoresURL!="")
sendHighScore(name);
@@ -241,6 +242,7 @@ function saveHighScore(name) {
}
);
}
+//![2]
//![1]
function sendHighScore(name) {
diff --git a/src/declarative/util/qmlpropertymap.cpp b/src/declarative/util/qmlpropertymap.cpp
index 8abf09f..c0e3340 100644
--- a/src/declarative/util/qmlpropertymap.cpp
+++ b/src/declarative/util/qmlpropertymap.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qmlpropertymap_p.h"
+#include "qmlpropertymap.h"
#include <private/qmlopenmetaobject_p.h>
#include <QDebug>
diff --git a/src/declarative/util/qmlpropertymap_p.h b/src/declarative/util/qmlpropertymap.h
index bb397fe..bb397fe 100644
--- a/src/declarative/util/qmlpropertymap_p.h
+++ b/src/declarative/util/qmlpropertymap.h
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index 4223f4e..d2faec9 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -53,7 +53,7 @@ HEADERS += \
util/qmltimeline_p_p.h \
util/qmltimer_p.h \
util/qmlbind_p.h \
- util/qmlpropertymap_p.h \
+ util/qmlpropertymap.h \
util/qmlpixmapcache_p.h \
util/qnumberformat_p.h \
util/qmlnumberformatter_p.h \
diff --git a/tests/auto/declarative/repeater/data/intmodel.qml b/tests/auto/declarative/repeater/data/intmodel.qml
new file mode 100644
index 0000000..a779079
--- /dev/null
+++ b/tests/auto/declarative/repeater/data/intmodel.qml
@@ -0,0 +1,17 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+ objectName: "container"
+ width: 240
+ height: 320
+ color: "white"
+ Repeater {
+ id: repeater
+ objectName: "repeater"
+ model: testData
+ Component {
+ Item{}
+ }
+ }
+}
diff --git a/tests/auto/declarative/repeater/data/objlist.qml b/tests/auto/declarative/repeater/data/objlist.qml
new file mode 100644
index 0000000..ecc6d02
--- /dev/null
+++ b/tests/auto/declarative/repeater/data/objlist.qml
@@ -0,0 +1,21 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+ objectName: "container"
+ width: 240
+ height: 320
+ color: "white"
+ Repeater {
+ id: repeater
+ objectName: "repeater"
+ model: testData
+ property int errors: 0
+ property int instantiated: 0
+ Component {
+ Item{
+ Component.onCompleted: {if(index!=modelData.idx) repeater.errors += 1; repeater.instantiated++}
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/repeater/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp
index dc0f1be..e002ee1 100644
--- a/tests/auto/declarative/repeater/tst_repeater.cpp
+++ b/tests/auto/declarative/repeater/tst_repeater.cpp
@@ -52,6 +52,8 @@ public:
tst_QmlGraphicsRepeater();
private slots:
+ void numberModel();
+ void objectList();
void stringList();
private:
@@ -64,6 +66,42 @@ tst_QmlGraphicsRepeater::tst_QmlGraphicsRepeater()
{
}
+void tst_QmlGraphicsRepeater::numberModel()
+{
+ QmlView *canvas = createView(SRCDIR "/data/intmodel.qml");
+ canvas->execute();
+ qApp->processEvents();
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", 5);
+
+ QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater");
+ QVERIFY(repeater != 0);
+ QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
+}
+
+void tst_QmlGraphicsRepeater::objectList()
+{
+ QmlView *canvas = createView(SRCDIR "/data/objlist.qml");
+
+ QObjectList* data = new QObjectList;
+ for(int i=0; i<100; i++){
+ *data << new QObject();
+ data->back()->setProperty("idx", i);
+ }
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", QVariant::fromValue<QObjectList*>(data));
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater");
+ QVERIFY(repeater != 0);
+ QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data
+ QCOMPARE(repeater->property("instantiated").toInt(), 100);
+}
+
/*
The Repeater element creates children at its own position in its parent's
stacking order. In this test we insert a repeater between two other Text