diff options
-rwxr-xr-x | demos/declarative/samegame/content/samegame.js | 2 | ||||
-rw-r--r-- | demos/declarative/samegame/samegame.qml | 7 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicspositioners.cpp | 20 |
3 files changed, 23 insertions, 6 deletions
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 8651c84..0a42e88 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -56,7 +56,7 @@ function initBoard() } timer = new Date(); - print(timer.valueOf() - a.valueOf()); + //print(timer.valueOf() - a.valueOf()); } var fillFound;//Set after a floodFill call to the number of tiles found diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 19b929f..d40d644 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -67,11 +67,18 @@ Rectangle { anchors.verticalCenter: parent.verticalCenter } + Button { + id: btnB; text: "Quit"; onClicked: {Qt.quit();} + anchors.left: btnA.right; anchors.leftMargin: 3 + anchors.verticalCenter: parent.verticalCenter + } + Text { id: score text: "Score: " + gameCanvas.score; font.bold: true anchors.right: parent.right; anchors.rightMargin: 3 anchors.verticalCenter: parent.verticalCenter + color: activePalette.text } } } diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp index ecaab80..17fe59f 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp @@ -172,8 +172,20 @@ void QmlGraphicsBasePositioner::componentComplete() QVariant QmlGraphicsBasePositioner::itemChange(GraphicsItemChange change, const QVariant &value) { - if (change == ItemChildAddedChange || - change == ItemChildRemovedChange) { + Q_D(QmlGraphicsBasePositioner); + if (change == ItemChildAddedChange){ + QmlGraphicsItem* child = value.value<QmlGraphicsItem*>(); + if(!child) + return QVariant(); + if(!d->watched.contains(child)) + d->watchChanges(child); + prePositioning(); + }else if (change == ItemChildRemovedChange) { + QmlGraphicsItem* child = value.value<QmlGraphicsItem*>(); + if(!child) + return QVariant(); + if(d->watched.contains(child)) + d->unwatchChanges(child); prePositioning(); } @@ -211,10 +223,8 @@ void QmlGraphicsBasePositioner::prePositioning() //Assumed that (aside from init) every add/remove triggers this check //thus the above check will be triggered every time an item is removed QSet<QmlGraphicsItem *> deletedItems = d->items - positionedItems.toSet(); - foreach(QmlGraphicsItem *child, deletedItems){ - d->unwatchChanges(child); + foreach(QmlGraphicsItem *child, deletedItems) d->items -= child; - } } doPositioning(); if(d->addTransition || d->moveTransition) |