summaryrefslogtreecommitdiffstats
path: root/demos/declarative/minehunt
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2010-03-25 07:42:21 (GMT)
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2010-03-25 07:42:21 (GMT)
commit20779098f4eb73f8789d704e1a2818ddbbf5b4d2 (patch)
treeb1c4e3edb447ee47f9bc724f106d1bbefcff5456 /demos/declarative/minehunt
parent8cc346604ed1e1504964772613ed9fe531361f69 (diff)
parent194013d9db1b3e4ba6f56a864f3b64f523202948 (diff)
downloadQt-20779098f4eb73f8789d704e1a2818ddbbf5b4d2.zip
Qt-20779098f4eb73f8789d704e1a2818ddbbf5b4d2.tar.gz
Qt-20779098f4eb73f8789d704e1a2818ddbbf5b4d2.tar.bz2
Merge remote branch 'main/4.7' into 4.7
Conflicts: demos/declarative/minehunt/minehunt.cpp src/declarative/qml/qdeclarativecompiler.cpp
Diffstat (limited to 'demos/declarative/minehunt')
-rw-r--r--demos/declarative/minehunt/README2
-rw-r--r--demos/declarative/minehunt/minehunt.cpp24
2 files changed, 25 insertions, 1 deletions
diff --git a/demos/declarative/minehunt/README b/demos/declarative/minehunt/README
index 7379dcf..1b6cf81 100644
--- a/demos/declarative/minehunt/README
+++ b/demos/declarative/minehunt/README
@@ -1,3 +1,5 @@
+To compile the C++ part, do 'qmake && make'. Minehunt will not run properly if the C++ plugin is not compiled.
+
To run, simply load the minehunt.qml file with the qml runtime.
Note that on X11, this demo has problems with the native graphicssystem. If you are using the X11 window system, please pass -graphicssystem raster to the qml binary.
diff --git a/demos/declarative/minehunt/minehunt.cpp b/demos/declarative/minehunt/minehunt.cpp
index e5f1ddb..a953c5a 100644
--- a/demos/declarative/minehunt/minehunt.cpp
+++ b/demos/declarative/minehunt/minehunt.cpp
@@ -92,7 +92,7 @@ public:
MinehuntGame();
Q_PROPERTY(QDeclarativeListProperty<Tile> tiles READ tiles CONSTANT)
- QDeclarativeListProperty<Tile> tiles() { return QDeclarativeListProperty<Tile>(this, _tiles); }
+ QDeclarativeListProperty<Tile> tiles();
Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
bool isPlaying() {return playing;}
@@ -134,6 +134,28 @@ private:
int nFlags;
};
+void tilesPropAppend(QDeclarativeListProperty<Tile>* prop, Tile* value)
+{
+ Q_UNUSED(prop);
+ Q_UNUSED(value);
+ return; //Append not supported
+}
+
+int tilesPropCount(QDeclarativeListProperty<Tile>* prop)
+{
+ return static_cast<QList<Tile*>*>(prop->data)->count();
+}
+
+Tile* tilesPropAt(QDeclarativeListProperty<Tile>* prop, int index)
+{
+ return static_cast<QList<Tile*>*>(prop->data)->at(index);
+}
+
+QDeclarativeListProperty<Tile> MinehuntGame::tiles(){
+ return QDeclarativeListProperty<Tile>(this, &_tiles, &tilesPropAppend,
+ &tilesPropCount, &tilesPropAt, 0);
+}
+
MinehuntGame::MinehuntGame()
: numCols(9), numRows(9), playing(true), won(false)
{