summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors.cpp104
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p.h26
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p_p.h2
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp91
-rw-r--r--src/declarative/util/qdeclarativestateoperations_p.h2
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp20
6 files changed, 122 insertions, 123 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
index 96d0867..f15316b 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
@@ -221,31 +221,31 @@ void QDeclarativeAnchorsPrivate::clearItem(QGraphicsObject *item)
centerIn = 0;
if (left.item == item) {
left.item = 0;
- usedAnchors &= ~QDeclarativeAnchors::HasLeftAnchor;
+ usedAnchors &= ~QDeclarativeAnchors::LeftAnchor;
}
if (right.item == item) {
right.item = 0;
- usedAnchors &= ~QDeclarativeAnchors::HasRightAnchor;
+ usedAnchors &= ~QDeclarativeAnchors::RightAnchor;
}
if (top.item == item) {
top.item = 0;
- usedAnchors &= ~QDeclarativeAnchors::HasTopAnchor;
+ usedAnchors &= ~QDeclarativeAnchors::TopAnchor;
}
if (bottom.item == item) {
bottom.item = 0;
- usedAnchors &= ~QDeclarativeAnchors::HasBottomAnchor;
+ usedAnchors &= ~QDeclarativeAnchors::BottomAnchor;
}
if (vCenter.item == item) {
vCenter.item = 0;
- usedAnchors &= ~QDeclarativeAnchors::HasVCenterAnchor;
+ usedAnchors &= ~QDeclarativeAnchors::VCenterAnchor;
}
if (hCenter.item == item) {
hCenter.item = 0;
- usedAnchors &= ~QDeclarativeAnchors::HasHCenterAnchor;
+ usedAnchors &= ~QDeclarativeAnchors::HCenterAnchor;
}
if (baseline.item == item) {
baseline.item = 0;
- usedAnchors &= ~QDeclarativeAnchors::HasBaselineAnchor;
+ usedAnchors &= ~QDeclarativeAnchors::BaselineAnchor;
}
}
@@ -495,13 +495,13 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
if (updatingVerticalAnchor < 2) {
++updatingVerticalAnchor;
QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item);
- if (usedAnchors & QDeclarativeAnchors::HasTopAnchor) {
+ if (usedAnchors & QDeclarativeAnchors::TopAnchor) {
//Handle stretching
bool invalid = true;
int height = 0;
- if (usedAnchors & QDeclarativeAnchors::HasBottomAnchor) {
+ if (usedAnchors & QDeclarativeAnchors::BottomAnchor) {
invalid = calcStretch(top, bottom, topMargin, -bottomMargin, QDeclarativeAnchorLine::Top, height);
- } else if (usedAnchors & QDeclarativeAnchors::HasVCenterAnchor) {
+ } else if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
invalid = calcStretch(top, vCenter, topMargin, vCenterOffset, QDeclarativeAnchorLine::Top, height);
height *= 2;
}
@@ -514,9 +514,9 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
} else if (top.item->parentItem() == item->parentItem()) {
setItemY(position(top.item, top.anchorLine) + topMargin);
}
- } else if (usedAnchors & QDeclarativeAnchors::HasBottomAnchor) {
+ } else if (usedAnchors & QDeclarativeAnchors::BottomAnchor) {
//Handle stretching (top + bottom case is handled above)
- if (usedAnchors & QDeclarativeAnchors::HasVCenterAnchor) {
+ if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
int height = 0;
bool invalid = calcStretch(vCenter, bottom, vCenterOffset, -bottomMargin,
QDeclarativeAnchorLine::Top, height);
@@ -530,7 +530,7 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
} else if (bottom.item->parentItem() == item->parentItem()) {
setItemY(position(bottom.item, bottom.anchorLine) - itemPrivate->height() - bottomMargin);
}
- } else if (usedAnchors & QDeclarativeAnchors::HasVCenterAnchor) {
+ } else if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
//(stetching handled above)
//Handle vCenter
@@ -540,7 +540,7 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
} else if (vCenter.item->parentItem() == item->parentItem()) {
setItemY(position(vCenter.item, vCenter.anchorLine) - itemPrivate->height()/2 + vCenterOffset);
}
- } else if (usedAnchors & QDeclarativeAnchors::HasBaselineAnchor) {
+ } else if (usedAnchors & QDeclarativeAnchors::BaselineAnchor) {
//Handle baseline
if (baseline.item == item->parentItem()) {
if (itemPrivate->isDeclarativeItem)
@@ -567,13 +567,13 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors()
if (updatingHorizontalAnchor < 2) {
++updatingHorizontalAnchor;
QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item);
- if (usedAnchors & QDeclarativeAnchors::HasLeftAnchor) {
+ if (usedAnchors & QDeclarativeAnchors::LeftAnchor) {
//Handle stretching
bool invalid = true;
int width = 0;
- if (usedAnchors & QDeclarativeAnchors::HasRightAnchor) {
+ if (usedAnchors & QDeclarativeAnchors::RightAnchor) {
invalid = calcStretch(left, right, leftMargin, -rightMargin, QDeclarativeAnchorLine::Left, width);
- } else if (usedAnchors & QDeclarativeAnchors::HasHCenterAnchor) {
+ } else if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
invalid = calcStretch(left, hCenter, leftMargin, hCenterOffset, QDeclarativeAnchorLine::Left, width);
width *= 2;
}
@@ -586,9 +586,9 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors()
} else if (left.item->parentItem() == item->parentItem()) {
setItemX(position(left.item, left.anchorLine) + leftMargin);
}
- } else if (usedAnchors & QDeclarativeAnchors::HasRightAnchor) {
+ } else if (usedAnchors & QDeclarativeAnchors::RightAnchor) {
//Handle stretching (left + right case is handled in updateLeftAnchor)
- if (usedAnchors & QDeclarativeAnchors::HasHCenterAnchor) {
+ if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
int width = 0;
bool invalid = calcStretch(hCenter, right, hCenterOffset, -rightMargin,
QDeclarativeAnchorLine::Left, width);
@@ -602,7 +602,7 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors()
} else if (right.item->parentItem() == item->parentItem()) {
setItemX(position(right.item, right.anchorLine) - itemPrivate->width() - rightMargin);
}
- } else if (usedAnchors & QDeclarativeAnchors::HasHCenterAnchor) {
+ } else if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
//Handle hCenter
if (hCenter.item == item->parentItem()) {
setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - itemPrivate->width()/2 + hCenterOffset);
@@ -630,10 +630,10 @@ void QDeclarativeAnchors::setTop(const QDeclarativeAnchorLine &edge)
if (!d->checkVAnchorValid(edge) || d->top == edge)
return;
- d->usedAnchors |= HasTopAnchor;
+ d->usedAnchors |= TopAnchor;
if (!d->checkVValid()) {
- d->usedAnchors &= ~HasTopAnchor;
+ d->usedAnchors &= ~TopAnchor;
return;
}
@@ -647,7 +647,7 @@ void QDeclarativeAnchors::setTop(const QDeclarativeAnchorLine &edge)
void QDeclarativeAnchors::resetTop()
{
Q_D(QDeclarativeAnchors);
- d->usedAnchors &= ~HasTopAnchor;
+ d->usedAnchors &= ~TopAnchor;
d->remDepend(d->top.item);
d->top = QDeclarativeAnchorLine();
emit topChanged();
@@ -666,10 +666,10 @@ void QDeclarativeAnchors::setBottom(const QDeclarativeAnchorLine &edge)
if (!d->checkVAnchorValid(edge) || d->bottom == edge)
return;
- d->usedAnchors |= HasBottomAnchor;
+ d->usedAnchors |= BottomAnchor;
if (!d->checkVValid()) {
- d->usedAnchors &= ~HasBottomAnchor;
+ d->usedAnchors &= ~BottomAnchor;
return;
}
@@ -683,7 +683,7 @@ void QDeclarativeAnchors::setBottom(const QDeclarativeAnchorLine &edge)
void QDeclarativeAnchors::resetBottom()
{
Q_D(QDeclarativeAnchors);
- d->usedAnchors &= ~HasBottomAnchor;
+ d->usedAnchors &= ~BottomAnchor;
d->remDepend(d->bottom.item);
d->bottom = QDeclarativeAnchorLine();
emit bottomChanged();
@@ -702,10 +702,10 @@ void QDeclarativeAnchors::setVerticalCenter(const QDeclarativeAnchorLine &edge)
if (!d->checkVAnchorValid(edge) || d->vCenter == edge)
return;
- d->usedAnchors |= HasVCenterAnchor;
+ d->usedAnchors |= VCenterAnchor;
if (!d->checkVValid()) {
- d->usedAnchors &= ~HasVCenterAnchor;
+ d->usedAnchors &= ~VCenterAnchor;
return;
}
@@ -719,7 +719,7 @@ void QDeclarativeAnchors::setVerticalCenter(const QDeclarativeAnchorLine &edge)
void QDeclarativeAnchors::resetVerticalCenter()
{
Q_D(QDeclarativeAnchors);
- d->usedAnchors &= ~HasVCenterAnchor;
+ d->usedAnchors &= ~VCenterAnchor;
d->remDepend(d->vCenter.item);
d->vCenter = QDeclarativeAnchorLine();
emit verticalCenterChanged();
@@ -738,10 +738,10 @@ void QDeclarativeAnchors::setBaseline(const QDeclarativeAnchorLine &edge)
if (!d->checkVAnchorValid(edge) || d->baseline == edge)
return;
- d->usedAnchors |= HasBaselineAnchor;
+ d->usedAnchors |= BaselineAnchor;
if (!d->checkVValid()) {
- d->usedAnchors &= ~HasBaselineAnchor;
+ d->usedAnchors &= ~BaselineAnchor;
return;
}
@@ -755,7 +755,7 @@ void QDeclarativeAnchors::setBaseline(const QDeclarativeAnchorLine &edge)
void QDeclarativeAnchors::resetBaseline()
{
Q_D(QDeclarativeAnchors);
- d->usedAnchors &= ~HasBaselineAnchor;
+ d->usedAnchors &= ~BaselineAnchor;
d->remDepend(d->baseline.item);
d->baseline = QDeclarativeAnchorLine();
emit baselineChanged();
@@ -774,10 +774,10 @@ void QDeclarativeAnchors::setLeft(const QDeclarativeAnchorLine &edge)
if (!d->checkHAnchorValid(edge) || d->left == edge)
return;
- d->usedAnchors |= HasLeftAnchor;
+ d->usedAnchors |= LeftAnchor;
if (!d->checkHValid()) {
- d->usedAnchors &= ~HasLeftAnchor;
+ d->usedAnchors &= ~LeftAnchor;
return;
}
@@ -791,7 +791,7 @@ void QDeclarativeAnchors::setLeft(const QDeclarativeAnchorLine &edge)
void QDeclarativeAnchors::resetLeft()
{
Q_D(QDeclarativeAnchors);
- d->usedAnchors &= ~HasLeftAnchor;
+ d->usedAnchors &= ~LeftAnchor;
d->remDepend(d->left.item);
d->left = QDeclarativeAnchorLine();
emit leftChanged();
@@ -810,10 +810,10 @@ void QDeclarativeAnchors::setRight(const QDeclarativeAnchorLine &edge)
if (!d->checkHAnchorValid(edge) || d->right == edge)
return;
- d->usedAnchors |= HasRightAnchor;
+ d->usedAnchors |= RightAnchor;
if (!d->checkHValid()) {
- d->usedAnchors &= ~HasRightAnchor;
+ d->usedAnchors &= ~RightAnchor;
return;
}
@@ -827,7 +827,7 @@ void QDeclarativeAnchors::setRight(const QDeclarativeAnchorLine &edge)
void QDeclarativeAnchors::resetRight()
{
Q_D(QDeclarativeAnchors);
- d->usedAnchors &= ~HasRightAnchor;
+ d->usedAnchors &= ~RightAnchor;
d->remDepend(d->right.item);
d->right = QDeclarativeAnchorLine();
emit rightChanged();
@@ -846,10 +846,10 @@ void QDeclarativeAnchors::setHorizontalCenter(const QDeclarativeAnchorLine &edge
if (!d->checkHAnchorValid(edge) || d->hCenter == edge)
return;
- d->usedAnchors |= HasHCenterAnchor;
+ d->usedAnchors |= HCenterAnchor;
if (!d->checkHValid()) {
- d->usedAnchors &= ~HasHCenterAnchor;
+ d->usedAnchors &= ~HCenterAnchor;
return;
}
@@ -863,7 +863,7 @@ void QDeclarativeAnchors::setHorizontalCenter(const QDeclarativeAnchorLine &edge
void QDeclarativeAnchors::resetHorizontalCenter()
{
Q_D(QDeclarativeAnchors);
- d->usedAnchors &= ~HasHCenterAnchor;
+ d->usedAnchors &= ~HCenterAnchor;
d->remDepend(d->hCenter.item);
d->hCenter = QDeclarativeAnchorLine();
emit horizontalCenterChanged();
@@ -1025,7 +1025,7 @@ void QDeclarativeAnchors::setBaselineOffset(qreal offset)
emit baselineOffsetChanged();
}
-QDeclarativeAnchors::UsedAnchors QDeclarativeAnchors::usedAnchors() const
+QDeclarativeAnchors::Anchors QDeclarativeAnchors::usedAnchors() const
{
Q_D(const QDeclarativeAnchors);
return d->usedAnchors;
@@ -1033,9 +1033,9 @@ QDeclarativeAnchors::UsedAnchors QDeclarativeAnchors::usedAnchors() const
bool QDeclarativeAnchorsPrivate::checkHValid() const
{
- if (usedAnchors & QDeclarativeAnchors::HasLeftAnchor &&
- usedAnchors & QDeclarativeAnchors::HasRightAnchor &&
- usedAnchors & QDeclarativeAnchors::HasHCenterAnchor) {
+ if (usedAnchors & QDeclarativeAnchors::LeftAnchor &&
+ usedAnchors & QDeclarativeAnchors::RightAnchor &&
+ usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
qmlInfo(item) << QDeclarativeAnchors::tr("Cannot specify left, right, and hcenter anchors.");
return false;
}
@@ -1064,15 +1064,15 @@ bool QDeclarativeAnchorsPrivate::checkHAnchorValid(QDeclarativeAnchorLine anchor
bool QDeclarativeAnchorsPrivate::checkVValid() const
{
- if (usedAnchors & QDeclarativeAnchors::HasTopAnchor &&
- usedAnchors & QDeclarativeAnchors::HasBottomAnchor &&
- usedAnchors & QDeclarativeAnchors::HasVCenterAnchor) {
+ if (usedAnchors & QDeclarativeAnchors::TopAnchor &&
+ usedAnchors & QDeclarativeAnchors::BottomAnchor &&
+ usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
qmlInfo(item) << QDeclarativeAnchors::tr("Cannot specify top, bottom, and vcenter anchors.");
return false;
- } else if (usedAnchors & QDeclarativeAnchors::HasBaselineAnchor &&
- (usedAnchors & QDeclarativeAnchors::HasTopAnchor ||
- usedAnchors & QDeclarativeAnchors::HasBottomAnchor ||
- usedAnchors & QDeclarativeAnchors::HasVCenterAnchor)) {
+ } else if (usedAnchors & QDeclarativeAnchors::BaselineAnchor &&
+ (usedAnchors & QDeclarativeAnchors::TopAnchor ||
+ usedAnchors & QDeclarativeAnchors::BottomAnchor ||
+ usedAnchors & QDeclarativeAnchors::VCenterAnchor)) {
qmlInfo(item) << QDeclarativeAnchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.");
return false;
}
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p.h
index f2e57cc..1bd7608 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p.h
@@ -83,18 +83,18 @@ public:
QDeclarativeAnchors(QGraphicsObject *item, QObject *parent=0);
virtual ~QDeclarativeAnchors();
- enum UsedAnchor {
- HasLeftAnchor = 0x01,
- HasRightAnchor = 0x02,
- HasTopAnchor = 0x04,
- HasBottomAnchor = 0x08,
- HasHCenterAnchor = 0x10,
- HasVCenterAnchor = 0x20,
- HasBaselineAnchor = 0x40,
- Horizontal_Mask = HasLeftAnchor | HasRightAnchor | HasHCenterAnchor,
- Vertical_Mask = HasTopAnchor | HasBottomAnchor | HasVCenterAnchor | HasBaselineAnchor
+ enum Anchor {
+ LeftAnchor = 0x01,
+ RightAnchor = 0x02,
+ TopAnchor = 0x04,
+ BottomAnchor = 0x08,
+ HCenterAnchor = 0x10,
+ VCenterAnchor = 0x20,
+ BaselineAnchor = 0x40,
+ Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor,
+ Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor
};
- Q_DECLARE_FLAGS(UsedAnchors, UsedAnchor)
+ Q_DECLARE_FLAGS(Anchors, Anchor)
QDeclarativeAnchorLine left() const;
void setLeft(const QDeclarativeAnchorLine &edge);
@@ -156,7 +156,7 @@ public:
void setCenterIn(QGraphicsObject *);
void resetCenterIn();
- UsedAnchors usedAnchors() const;
+ Anchors usedAnchors() const;
void classBegin();
void componentComplete();
@@ -188,7 +188,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_widgetGeometryChanged())
Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *obj))
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeAnchors::UsedAnchors)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeAnchors::Anchors)
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
index f8489aa..05be6c5 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
@@ -139,7 +139,7 @@ public:
void centerInChanged();
QGraphicsObject *item;
- QDeclarativeAnchors::UsedAnchors usedAnchors;
+ QDeclarativeAnchors::Anchors usedAnchors;
QGraphicsObject *fill;
QGraphicsObject *centerIn;
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index eb6ac7b..56ed335 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -620,15 +620,14 @@ class QDeclarativeAnchorSetPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QDeclarativeAnchorSet)
public:
QDeclarativeAnchorSetPrivate()
- : usedAnchors(0), fill(0),
+ : usedAnchors(0), resetAnchors(0), fill(0),
centerIn(0)/*, leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)*/
{
}
- QDeclarativeAnchors::UsedAnchors usedAnchors;
- //### change to QDeclarativeAnchors::UsedAnchors resetAnchors
- QStringList resetList;
+ QDeclarativeAnchors::Anchors usedAnchors;
+ QDeclarativeAnchors::Anchors resetAnchors;
QDeclarativeItem *fill;
QDeclarativeItem *centerIn;
@@ -669,16 +668,16 @@ QDeclarativeAnchorLine QDeclarativeAnchorSet::top() const
void QDeclarativeAnchorSet::setTop(const QDeclarativeAnchorLine &edge)
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors |= QDeclarativeAnchors::HasTopAnchor;
+ d->usedAnchors |= QDeclarativeAnchors::TopAnchor;
d->top = edge;
}
void QDeclarativeAnchorSet::resetTop()
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors &= ~QDeclarativeAnchors::HasTopAnchor;
+ d->usedAnchors &= ~QDeclarativeAnchors::TopAnchor;
d->top = QDeclarativeAnchorLine();
- d->resetList << QLatin1String("top");
+ d->resetAnchors |= QDeclarativeAnchors::TopAnchor;
}
QDeclarativeAnchorLine QDeclarativeAnchorSet::bottom() const
@@ -690,16 +689,16 @@ QDeclarativeAnchorLine QDeclarativeAnchorSet::bottom() const
void QDeclarativeAnchorSet::setBottom(const QDeclarativeAnchorLine &edge)
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors |= QDeclarativeAnchors::HasBottomAnchor;
+ d->usedAnchors |= QDeclarativeAnchors::BottomAnchor;
d->bottom = edge;
}
void QDeclarativeAnchorSet::resetBottom()
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors &= ~QDeclarativeAnchors::HasBottomAnchor;
+ d->usedAnchors &= ~QDeclarativeAnchors::BottomAnchor;
d->bottom = QDeclarativeAnchorLine();
- d->resetList << QLatin1String("bottom");
+ d->resetAnchors |= QDeclarativeAnchors::BottomAnchor;
}
QDeclarativeAnchorLine QDeclarativeAnchorSet::verticalCenter() const
@@ -711,16 +710,16 @@ QDeclarativeAnchorLine QDeclarativeAnchorSet::verticalCenter() const
void QDeclarativeAnchorSet::setVerticalCenter(const QDeclarativeAnchorLine &edge)
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors |= QDeclarativeAnchors::HasVCenterAnchor;
+ d->usedAnchors |= QDeclarativeAnchors::VCenterAnchor;
d->vCenter = edge;
}
void QDeclarativeAnchorSet::resetVerticalCenter()
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors &= ~QDeclarativeAnchors::HasVCenterAnchor;
+ d->usedAnchors &= ~QDeclarativeAnchors::VCenterAnchor;
d->vCenter = QDeclarativeAnchorLine();
- d->resetList << QLatin1String("verticalCenter");
+ d->resetAnchors |= QDeclarativeAnchors::VCenterAnchor;
}
QDeclarativeAnchorLine QDeclarativeAnchorSet::baseline() const
@@ -732,16 +731,16 @@ QDeclarativeAnchorLine QDeclarativeAnchorSet::baseline() const
void QDeclarativeAnchorSet::setBaseline(const QDeclarativeAnchorLine &edge)
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors |= QDeclarativeAnchors::HasBaselineAnchor;
+ d->usedAnchors |= QDeclarativeAnchors::BaselineAnchor;
d->baseline = edge;
}
void QDeclarativeAnchorSet::resetBaseline()
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors &= ~QDeclarativeAnchors::HasBaselineAnchor;
+ d->usedAnchors &= ~QDeclarativeAnchors::BaselineAnchor;
d->baseline = QDeclarativeAnchorLine();
- d->resetList << QLatin1String("baseline");
+ d->resetAnchors |= QDeclarativeAnchors::BaselineAnchor;
}
QDeclarativeAnchorLine QDeclarativeAnchorSet::left() const
@@ -753,16 +752,16 @@ QDeclarativeAnchorLine QDeclarativeAnchorSet::left() const
void QDeclarativeAnchorSet::setLeft(const QDeclarativeAnchorLine &edge)
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors |= QDeclarativeAnchors::HasLeftAnchor;
+ d->usedAnchors |= QDeclarativeAnchors::LeftAnchor;
d->left = edge;
}
void QDeclarativeAnchorSet::resetLeft()
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors &= ~QDeclarativeAnchors::HasLeftAnchor;
+ d->usedAnchors &= ~QDeclarativeAnchors::LeftAnchor;
d->left = QDeclarativeAnchorLine();
- d->resetList << QLatin1String("left");
+ d->resetAnchors |= QDeclarativeAnchors::LeftAnchor;
}
QDeclarativeAnchorLine QDeclarativeAnchorSet::right() const
@@ -774,16 +773,16 @@ QDeclarativeAnchorLine QDeclarativeAnchorSet::right() const
void QDeclarativeAnchorSet::setRight(const QDeclarativeAnchorLine &edge)
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors |= QDeclarativeAnchors::HasRightAnchor;
+ d->usedAnchors |= QDeclarativeAnchors::RightAnchor;
d->right = edge;
}
void QDeclarativeAnchorSet::resetRight()
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors &= ~QDeclarativeAnchors::HasRightAnchor;
+ d->usedAnchors &= ~QDeclarativeAnchors::RightAnchor;
d->right = QDeclarativeAnchorLine();
- d->resetList << QLatin1String("right");
+ d->resetAnchors |= QDeclarativeAnchors::RightAnchor;
}
QDeclarativeAnchorLine QDeclarativeAnchorSet::horizontalCenter() const
@@ -795,16 +794,16 @@ QDeclarativeAnchorLine QDeclarativeAnchorSet::horizontalCenter() const
void QDeclarativeAnchorSet::setHorizontalCenter(const QDeclarativeAnchorLine &edge)
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors |= QDeclarativeAnchors::HasHCenterAnchor;
+ d->usedAnchors |= QDeclarativeAnchors::HCenterAnchor;
d->hCenter = edge;
}
void QDeclarativeAnchorSet::resetHorizontalCenter()
{
Q_D(QDeclarativeAnchorSet);
- d->usedAnchors &= ~QDeclarativeAnchors::HasHCenterAnchor;
+ d->usedAnchors &= ~QDeclarativeAnchors::HCenterAnchor;
d->hCenter = QDeclarativeAnchorLine();
- d->resetList << QLatin1String("horizontalCenter");
+ d->resetAnchors |= QDeclarativeAnchors::HCenterAnchor;
}
QDeclarativeItem *QDeclarativeAnchorSet::fill() const
@@ -975,19 +974,19 @@ void QDeclarativeAnchorChanges::execute()
d->target->anchors()->setBaseline(d->origBaseline);
//reset any anchors that have been specified
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("left")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::LeftAnchor)
d->target->anchors()->resetLeft();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("right")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::RightAnchor)
d->target->anchors()->resetRight();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("horizontalCenter")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::HCenterAnchor)
d->target->anchors()->resetHorizontalCenter();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("top")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::TopAnchor)
d->target->anchors()->resetTop();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("bottom")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BottomAnchor)
d->target->anchors()->resetBottom();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("verticalCenter")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::VCenterAnchor)
d->target->anchors()->resetVerticalCenter();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("baseline")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BaselineAnchor)
d->target->anchors()->resetBaseline();
//set any anchors that have been specified
@@ -1121,25 +1120,25 @@ void QDeclarativeAnchorChanges::copyOriginals(QDeclarativeActionEvent *other)
//probably also need to revert some things
d->applyOrigLeft = (acp->anchorSet->d_func()->left.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->anchorSet->d_func()->resetList.contains(QLatin1String("left")));
+ acp->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::LeftAnchor);
d->applyOrigRight = (acp->anchorSet->d_func()->right.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->anchorSet->d_func()->resetList.contains(QLatin1String("right")));
+ acp->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::RightAnchor);
d->applyOrigHCenter = (acp->anchorSet->d_func()->hCenter.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->anchorSet->d_func()->resetList.contains(QLatin1String("horizontalCenter")));
+ acp->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::HCenterAnchor);
d->applyOrigTop = (acp->anchorSet->d_func()->top.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->anchorSet->d_func()->resetList.contains(QLatin1String("top")));
+ acp->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::TopAnchor);
d->applyOrigBottom = (acp->anchorSet->d_func()->bottom.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->anchorSet->d_func()->resetList.contains(QLatin1String("bottom")));
+ acp->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BottomAnchor);
d->applyOrigVCenter = (acp->anchorSet->d_func()->vCenter.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->anchorSet->d_func()->resetList.contains(QLatin1String("verticalCenter")));
+ acp->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::VCenterAnchor);
d->applyOrigBaseline = (acp->anchorSet->d_func()->baseline.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->anchorSet->d_func()->resetList.contains(QLatin1String("baseline")));
+ acp->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BaselineAnchor);
d->origLeft = ac->d_func()->origLeft;
d->origRight = ac->d_func()->origRight;
@@ -1180,19 +1179,19 @@ void QDeclarativeAnchorChanges::clearBindings()
d->target->anchors()->resetBaseline();
//reset any anchors that have been specified
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("left")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::LeftAnchor)
d->target->anchors()->resetLeft();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("right")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::RightAnchor)
d->target->anchors()->resetRight();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("horizontalCenter")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::HCenterAnchor)
d->target->anchors()->resetHorizontalCenter();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("top")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::TopAnchor)
d->target->anchors()->resetTop();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("bottom")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BottomAnchor)
d->target->anchors()->resetBottom();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("verticalCenter")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::VCenterAnchor)
d->target->anchors()->resetVerticalCenter();
- if (d->anchorSet->d_func()->resetList .contains(QLatin1String("baseline")))
+ if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BaselineAnchor)
d->target->anchors()->resetBaseline();
//reset any anchors that we'll be setting in the state
diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h
index d49ec63..5dc21e1 100644
--- a/src/declarative/util/qdeclarativestateoperations_p.h
+++ b/src/declarative/util/qdeclarativestateoperations_p.h
@@ -232,7 +232,7 @@ public:
qreal baselineOffset() const;
void setBaselineOffset(qreal);*/
- QDeclarativeAnchors::UsedAnchors usedAnchors() const;
+ QDeclarativeAnchors::Anchors usedAnchors() const;
/*Q_SIGNALS:
void leftMarginChanged();
diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
index 06a8f64..dff62c7 100644
--- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
+++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
@@ -49,7 +49,7 @@
#include <private/qdeclarativetext_p.h>
#include <QtDeclarative/private/qdeclarativeanchors_p_p.h>
-Q_DECLARE_METATYPE(QDeclarativeAnchors::UsedAnchor)
+Q_DECLARE_METATYPE(QDeclarativeAnchors::Anchor)
Q_DECLARE_METATYPE(QDeclarativeAnchorLine::AnchorLine)
@@ -367,7 +367,7 @@ void tst_qdeclarativeanchors::reset()
{
QFETCH(QString, side);
QFETCH(QDeclarativeAnchorLine::AnchorLine, anchorLine);
- QFETCH(QDeclarativeAnchors::UsedAnchor, usedAnchor);
+ QFETCH(QDeclarativeAnchors::Anchor, usedAnchor);
QDeclarativeItem *baseItem = new QDeclarativeItem;
@@ -394,16 +394,16 @@ void tst_qdeclarativeanchors::reset_data()
{
QTest::addColumn<QString>("side");
QTest::addColumn<QDeclarativeAnchorLine::AnchorLine>("anchorLine");
- QTest::addColumn<QDeclarativeAnchors::UsedAnchor>("usedAnchor");
+ QTest::addColumn<QDeclarativeAnchors::Anchor>("usedAnchor");
- QTest::newRow("left") << "left" << QDeclarativeAnchorLine::Left << QDeclarativeAnchors::HasLeftAnchor;
- QTest::newRow("top") << "top" << QDeclarativeAnchorLine::Top << QDeclarativeAnchors::HasTopAnchor;
- QTest::newRow("right") << "right" << QDeclarativeAnchorLine::Right << QDeclarativeAnchors::HasRightAnchor;
- QTest::newRow("bottom") << "bottom" << QDeclarativeAnchorLine::Bottom << QDeclarativeAnchors::HasBottomAnchor;
+ QTest::newRow("left") << "left" << QDeclarativeAnchorLine::Left << QDeclarativeAnchors::LeftAnchor;
+ QTest::newRow("top") << "top" << QDeclarativeAnchorLine::Top << QDeclarativeAnchors::TopAnchor;
+ QTest::newRow("right") << "right" << QDeclarativeAnchorLine::Right << QDeclarativeAnchors::RightAnchor;
+ QTest::newRow("bottom") << "bottom" << QDeclarativeAnchorLine::Bottom << QDeclarativeAnchors::BottomAnchor;
- QTest::newRow("hcenter") << "horizontalCenter" << QDeclarativeAnchorLine::HCenter << QDeclarativeAnchors::HasHCenterAnchor;
- QTest::newRow("vcenter") << "verticalCenter" << QDeclarativeAnchorLine::VCenter << QDeclarativeAnchors::HasVCenterAnchor;
- QTest::newRow("baseline") << "baseline" << QDeclarativeAnchorLine::Baseline << QDeclarativeAnchors::HasBaselineAnchor;
+ QTest::newRow("hcenter") << "horizontalCenter" << QDeclarativeAnchorLine::HCenter << QDeclarativeAnchors::HCenterAnchor;
+ QTest::newRow("vcenter") << "verticalCenter" << QDeclarativeAnchorLine::VCenter << QDeclarativeAnchors::VCenterAnchor;
+ QTest::newRow("baseline") << "baseline" << QDeclarativeAnchorLine::Baseline << QDeclarativeAnchors::BaselineAnchor;
}
void tst_qdeclarativeanchors::resetConvenience()