From 90e401d350a75dfa365a8f3090514a2741f7bef6 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 22 Mar 2010 16:08:25 +0100 Subject: Use QDeclarativeListProperty properly Task-number: QTBUG-8713 Reviewed-by: Aaron Kennedy --- demos/declarative/minehunt/minehunt.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 tiles READ tiles CONSTANT); - QDeclarativeListProperty tiles() { return QDeclarativeListProperty(this, _tiles); } + QDeclarativeListProperty tiles(); Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged); bool isPlaying() {return playing;} @@ -134,6 +134,28 @@ private: int nFlags; }; +void tilesPropAppend(QDeclarativeListProperty* prop, Tile* value) +{ + Q_UNUSED(prop); + Q_UNUSED(value); + return; //Append not supported +} + +int tilesPropCount(QDeclarativeListProperty* prop) +{ + return static_cast*>(prop->data)->count(); +} + +Tile* tilesPropAt(QDeclarativeListProperty* prop, int index) +{ + return static_cast*>(prop->data)->at(index); +} + +QDeclarativeListProperty MinehuntGame::tiles(){ + return QDeclarativeListProperty(this, &_tiles, &tilesPropAppend, + &tilesPropCount, &tilesPropAt, 0); +} + MinehuntGame::MinehuntGame() : numCols(9), numRows(9), playing(true), won(false) { -- cgit v0.12