diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-06-24 01:50:16 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-06-24 01:50:16 (GMT) |
commit | b8fba323c817a00df3c3639eb172104cf68d259d (patch) | |
tree | 437edb5e7c0672636f2bcc7fa3af59665b99d0d6 /src/declarative/fx/qfxanchors.cpp | |
parent | c1283b68d5b02afb5f225d455ae057753b91a5b9 (diff) | |
parent | 124f5714e8e6ec1945d536e622b51304f2b32dd7 (diff) | |
download | Qt-b8fba323c817a00df3c3639eb172104cf68d259d.zip Qt-b8fba323c817a00df3c3639eb172104cf68d259d.tar.gz Qt-b8fba323c817a00df3c3639eb172104cf68d259d.tar.bz2 |
Merge branch 'kinetic-declarativeui' into kinetic-declarativeui-gv
Conflicts:
src/declarative/canvas/qsimplecanvasitem.cpp
src/declarative/canvas/qsimplecanvasitem_p.h
src/declarative/fx/qfxwebview.cpp
Diffstat (limited to 'src/declarative/fx/qfxanchors.cpp')
-rw-r--r-- | src/declarative/fx/qfxanchors.cpp | 124 |
1 files changed, 79 insertions, 45 deletions
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index d25b679..509e2c8 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -533,12 +533,12 @@ void QFxAnchors::setTop(const QFxAnchorLine &edge) if (!d->checkVAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasTopAnchor; - else - d->usedAnchors &= ~HasTopAnchor; + d->usedAnchors |= HasTopAnchor; - d->checkVValid(); + if (!d->checkVValid()) { + d->usedAnchors &= ~HasTopAnchor; + return; + } d->remDepend(d->top.item); d->top = edge; @@ -548,7 +548,11 @@ void QFxAnchors::setTop(const QFxAnchorLine &edge) void QFxAnchors::resetTop() { - setTop(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasTopAnchor; + d->remDepend(d->top.item); + d->top = QFxAnchorLine(); + d->updateVerticalAnchors(); } QFxAnchorLine QFxAnchors::bottom() const @@ -563,12 +567,12 @@ void QFxAnchors::setBottom(const QFxAnchorLine &edge) if (!d->checkVAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasBottomAnchor; - else - d->usedAnchors &= ~HasBottomAnchor; + d->usedAnchors |= HasBottomAnchor; - d->checkVValid(); + if (!d->checkVValid()) { + d->usedAnchors &= ~HasBottomAnchor; + return; + } d->remDepend(d->bottom.item); d->bottom = edge; @@ -578,7 +582,11 @@ void QFxAnchors::setBottom(const QFxAnchorLine &edge) void QFxAnchors::resetBottom() { - setBottom(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasBottomAnchor; + d->remDepend(d->bottom.item); + d->bottom = QFxAnchorLine(); + d->updateVerticalAnchors(); } QFxAnchorLine QFxAnchors::verticalCenter() const @@ -593,12 +601,12 @@ void QFxAnchors::setVerticalCenter(const QFxAnchorLine &edge) if (!d->checkVAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasVCenterAnchor; - else - d->usedAnchors &= ~HasVCenterAnchor; + d->usedAnchors |= HasVCenterAnchor; - d->checkVValid(); + if (!d->checkVValid()) { + d->usedAnchors &= ~HasVCenterAnchor; + return; + } d->remDepend(d->vCenter.item); d->vCenter = edge; @@ -608,7 +616,11 @@ void QFxAnchors::setVerticalCenter(const QFxAnchorLine &edge) void QFxAnchors::resetVerticalCenter() { - setVerticalCenter(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasVCenterAnchor; + d->remDepend(d->vCenter.item); + d->vCenter = QFxAnchorLine(); + d->updateVerticalAnchors(); } QFxAnchorLine QFxAnchors::baseline() const @@ -623,12 +635,12 @@ void QFxAnchors::setBaseline(const QFxAnchorLine &edge) if (!d->checkVAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasBaselineAnchor; - else - d->usedAnchors &= ~HasBaselineAnchor; + d->usedAnchors |= HasBaselineAnchor; - d->checkVValid(); + if (!d->checkVValid()) { + d->usedAnchors &= ~HasBaselineAnchor; + return; + } d->remDepend(d->baseline.item); d->baseline = edge; @@ -638,7 +650,11 @@ void QFxAnchors::setBaseline(const QFxAnchorLine &edge) void QFxAnchors::resetBaseline() { - setBaseline(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasBaselineAnchor; + d->remDepend(d->baseline.item); + d->baseline = QFxAnchorLine(); + d->updateVerticalAnchors(); } QFxAnchorLine QFxAnchors::left() const @@ -653,12 +669,12 @@ void QFxAnchors::setLeft(const QFxAnchorLine &edge) if (!d->checkHAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasLeftAnchor; - else - d->usedAnchors &= ~HasLeftAnchor; + d->usedAnchors |= HasLeftAnchor; - d->checkHValid(); + if (!d->checkHValid()) { + d->usedAnchors &= ~HasLeftAnchor; + return; + } d->remDepend(d->left.item); d->left = edge; @@ -668,7 +684,11 @@ void QFxAnchors::setLeft(const QFxAnchorLine &edge) void QFxAnchors::resetLeft() { - setLeft(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasLeftAnchor; + d->remDepend(d->left.item); + d->left = QFxAnchorLine(); + d->updateHorizontalAnchors(); } QFxAnchorLine QFxAnchors::right() const @@ -683,12 +703,12 @@ void QFxAnchors::setRight(const QFxAnchorLine &edge) if (!d->checkHAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasRightAnchor; - else - d->usedAnchors &= ~HasRightAnchor; + d->usedAnchors |= HasRightAnchor; - d->checkHValid(); + if (!d->checkHValid()) { + d->usedAnchors &= ~HasRightAnchor; + return; + } d->remDepend(d->right.item); d->right = edge; @@ -699,7 +719,11 @@ void QFxAnchors::setRight(const QFxAnchorLine &edge) void QFxAnchors::resetRight() { - setRight(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasRightAnchor; + d->remDepend(d->right.item); + d->right = QFxAnchorLine(); + d->updateHorizontalAnchors(); } QFxAnchorLine QFxAnchors::horizontalCenter() const @@ -714,12 +738,12 @@ void QFxAnchors::setHorizontalCenter(const QFxAnchorLine &edge) if (!d->checkHAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasHCenterAnchor; - else - d->usedAnchors &= ~HasHCenterAnchor; + d->usedAnchors |= HasHCenterAnchor; - d->checkHValid(); + if (!d->checkHValid()) { + d->usedAnchors &= ~HasHCenterAnchor; + return; + } d->remDepend(d->hCenter.item); d->hCenter = edge; @@ -729,7 +753,11 @@ void QFxAnchors::setHorizontalCenter(const QFxAnchorLine &edge) void QFxAnchors::resetHorizontalCenter() { - setHorizontalCenter(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasHCenterAnchor; + d->remDepend(d->hCenter.item); + d->hCenter = QFxAnchorLine(); + d->updateHorizontalAnchors(); } int QFxAnchors::leftMargin() const @@ -848,13 +876,16 @@ bool QFxAnchorsPrivate::checkHValid() const bool QFxAnchorsPrivate::checkHAnchorValid(QFxAnchorLine anchor) const { - if (anchor.anchorLine & QFxAnchorLine::Vertical_Mask) { + if (!anchor.item) { + qmlInfo(item) << "Can't anchor to a null item."; + return false; + } else if (anchor.anchorLine & QFxAnchorLine::Vertical_Mask) { qmlInfo(item) << "Can't anchor a horizontal edge to a vertical edge."; return false; } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){ qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling."; return false; - } else if (anchor.item == item){ + } else if (anchor.item == item) { qmlInfo(item) << "Can't anchor item to self."; return false; } @@ -882,7 +913,10 @@ bool QFxAnchorsPrivate::checkVValid() const bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const { - if (anchor.anchorLine & QFxAnchorLine::Horizontal_Mask) { + if (!anchor.item) { + qmlInfo(item) << "Can't anchor to a null item."; + return false; + } else if (anchor.anchorLine & QFxAnchorLine::Horizontal_Mask) { qmlInfo(item) << "Can't anchor a vertical edge to a horizontal edge."; return false; } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){ |