diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-11-06 06:15:54 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-11-06 06:15:54 (GMT) |
commit | e3d14648ebf04ef2ed8bf2a72e8cff186bcd4871 (patch) | |
tree | 4582d3f9c4d223532804c50e5016c506b553fd72 /src/declarative | |
parent | dc7acac9552ce556d0388a11f6c5584ea8e10ae3 (diff) | |
parent | dc255e892d6435759921d36f59bb32050d343b70 (diff) | |
download | Qt-e3d14648ebf04ef2ed8bf2a72e8cff186bcd4871.zip Qt-e3d14648ebf04ef2ed8bf2a72e8cff186bcd4871.tar.gz Qt-e3d14648ebf04ef2ed8bf2a72e8cff186bcd4871.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsanchors.cpp | 47 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h | 4 |
2 files changed, 36 insertions, 15 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp index 404daad..f6dc5fd 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp @@ -152,13 +152,23 @@ void QmlGraphicsAnchorsPrivate::fillChanged() if (!fill || !isItemComplete()) return; - if (fill == item->parentItem()) { //child-parent - setItemPos(QPointF(leftMargin, topMargin)); - } else if (fill->parentItem() == item->parentItem()) { //siblings - setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin)); + if (updatingFill < 2) { + ++updatingFill; + + if (fill == item->parentItem()) { //child-parent + setItemPos(QPointF(leftMargin, topMargin)); + } else if (fill->parentItem() == item->parentItem()) { //siblings + setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin)); + } + setItemWidth(fill->width()-leftMargin-rightMargin); + setItemHeight(fill->height()-topMargin-bottomMargin); + + --updatingFill; + } else { + // ### Make this certain :) + qmlInfo(QmlGraphicsAnchors::tr("Possible anchor loop detected on fill."), item); } - setItemWidth(fill->width()-leftMargin-rightMargin); - setItemHeight(fill->height()-topMargin-bottomMargin); + } void QmlGraphicsAnchorsPrivate::centerInChanged() @@ -166,16 +176,25 @@ void QmlGraphicsAnchorsPrivate::centerInChanged() if (!centerIn || fill || !isItemComplete()) return; - if (centerIn == item->parentItem()) { - QPointF p((item->parentItem()->width() - item->width()) / 2., - (item->parentItem()->height() - item->height()) / 2.); - setItemPos(p); + if (updatingCenterIn < 2) { + ++updatingCenterIn; - } else if (centerIn->parentItem() == item->parentItem()) { + if (centerIn == item->parentItem()) { + QPointF p((item->parentItem()->width() - item->width()) / 2., + (item->parentItem()->height() - item->height()) / 2.); + setItemPos(p); - QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2., - centerIn->y() + (centerIn->height() - item->height()) / 2.); - setItemPos(p); + } else if (centerIn->parentItem() == item->parentItem()) { + + QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2., + centerIn->y() + (centerIn->height() - item->height()) / 2.); + setItemPos(p); + } + + --updatingCenterIn; + } else { + // ### Make this certain :) + qmlInfo(QmlGraphicsAnchors::tr("Possible anchor loop detected on centerIn."), item); } } diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h index 5f8b2c1..d21d9c5 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h @@ -89,7 +89,7 @@ class QmlGraphicsAnchorsPrivate : public QObjectPrivate public: QmlGraphicsAnchorsPrivate() : updatingMe(false), updatingHorizontalAnchor(0), - updatingVerticalAnchor(0), item(0), usedAnchors(0), fill(0), + updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(0), usedAnchors(0), fill(0), centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0), componentComplete(true) @@ -109,6 +109,8 @@ public: bool updatingMe; int updatingHorizontalAnchor; int updatingVerticalAnchor; + int updatingFill; + int updatingCenterIn; void setItemHeight(qreal); void setItemWidth(qreal); |