summaryrefslogtreecommitdiffstats
path: root/demos/declarative/minehunt
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-03-22 15:08:25 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-03-23 07:15:44 (GMT)
commit90e401d350a75dfa365a8f3090514a2741f7bef6 (patch)
treefc090313766a88e6594d302c29e34124b64f7fb9 /demos/declarative/minehunt
parentced9f453fb7648c04a60932901bd370405c701eb (diff)
downloadQt-90e401d350a75dfa365a8f3090514a2741f7bef6.zip
Qt-90e401d350a75dfa365a8f3090514a2741f7bef6.tar.gz
Qt-90e401d350a75dfa365a8f3090514a2741f7bef6.tar.bz2
Use QDeclarativeListProperty properly
Task-number: QTBUG-8713 Reviewed-by: Aaron Kennedy
Diffstat (limited to 'demos/declarative/minehunt')
-rw-r--r--demos/declarative/minehunt/minehunt.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/demos/declarative/minehunt/minehunt.cpp b/demos/declarative/minehunt/minehunt.cpp
index 5e44d1b..e54508a 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)
{