summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-05-11 05:57:50 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-05-11 05:57:50 (GMT)
commitb3526f5edf6425289ef2aa5c8adfc89892817ac0 (patch)
tree6291a50711e80dbe7037f52d71f538b1a5410741 /src/declarative/fx
parent7f22443b3cb6cd56a906dbb6edb0c2f7a1314887 (diff)
parent692931ae2fec4fa8fc4ebcbcff20c952d6319536 (diff)
downloadQt-b3526f5edf6425289ef2aa5c8adfc89892817ac0.zip
Qt-b3526f5edf6425289ef2aa5c8adfc89892817ac0.tar.gz
Qt-b3526f5edf6425289ef2aa5c8adfc89892817ac0.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/qfxanchors.cpp438
-rw-r--r--src/declarative/fx/qfxanchors.h30
-rw-r--r--src/declarative/fx/qfxanchors_p.h10
-rw-r--r--src/declarative/fx/qfxtextedit.cpp2
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp1
5 files changed, 314 insertions, 167 deletions
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp
index 540e1cb..53d0187 100644
--- a/src/declarative/fx/qfxanchors.cpp
+++ b/src/declarative/fx/qfxanchors.cpp
@@ -43,9 +43,10 @@
#include "qfxitem.h"
#include <QDebug>
#include <QtDeclarative/qmlinfo.h>
-
+#include <QtDeclarative/qmlbindablevalue.h>
QT_BEGIN_NAMESPACE
+
QML_DEFINE_TYPE(QFxAnchors,Anchors);
//TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)?
@@ -227,7 +228,7 @@ void QFxAnchors::setCenteredIn(QFxItem* c)
setVerticalCenter(c->verticalCenter());
}
-void QFxAnchorsPrivate::connectVHelper(const QFxAnchorLine &edge, const char *slotString)
+void QFxAnchorsPrivate::connectVHelper(const QFxAnchorLine &edge)
{
//### should we do disconnects first? (will it be called more than once?)
Q_Q(QFxAnchors);
@@ -235,7 +236,7 @@ void QFxAnchorsPrivate::connectVHelper(const QFxAnchorLine &edge, const char *sl
switch(edge.anchorLine) {
case QFxAnchorLine::Bottom:
case QFxAnchorLine::VCenter:
- QObject::connect(edge.item, SIGNAL(heightChanged()), q, slotString);
+ QObject::connect(edge.item, SIGNAL(heightChanged()), q, SLOT(updateVerticalAnchors()));
break;
case QFxAnchorLine::Top: //no connection needed
default:
@@ -244,13 +245,13 @@ void QFxAnchorsPrivate::connectVHelper(const QFxAnchorLine &edge, const char *sl
} else if (edge.item->itemParent() == item->itemParent()) { //siblings
switch(edge.anchorLine) {
case QFxAnchorLine::Top:
- QObject::connect(edge.item, SIGNAL(topChanged()), q, slotString);
+ QObject::connect(edge.item, SIGNAL(topChanged()), q, SLOT(updateVerticalAnchors()));
break;
case QFxAnchorLine::Bottom:
- QObject::connect(edge.item, SIGNAL(bottomChanged()), q, slotString);
+ QObject::connect(edge.item, SIGNAL(bottomChanged()), q, SLOT(updateVerticalAnchors()));
break;
case QFxAnchorLine::VCenter:
- QObject::connect(edge.item, SIGNAL(vcenterChanged()), q, slotString);
+ QObject::connect(edge.item, SIGNAL(vcenterChanged()), q, SLOT(updateVerticalAnchors()));
break;
default:
break;
@@ -267,49 +268,44 @@ void QFxAnchors::connectVAnchors()
return;
if (d->usedAnchors & HasTopAnchor) {
- const char *slotStr = SLOT(updateTopAnchor());
-
//Handle stretching connections (if we have multiple horizontal anchors)
QFxAnchorLine *edge = 0;
if (d->usedAnchors & HasBottomAnchor) {
edge = &d->bottom;
- connect(this, SIGNAL(bottomMarginChanged()), this, slotStr);
+ connect(this, SIGNAL(bottomMarginChanged()), this, SLOT(updateVerticalAnchors()));
} else if (d->usedAnchors & HasVCenterAnchor) {
edge = &d->vCenter;
- connect(this, SIGNAL(verticalCenterOffsetChanged()), this, slotStr);
+ connect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors()));
}
if (edge) {
//we need to stretch
- d->connectVHelper(*edge, slotStr);
+ d->connectVHelper(*edge);
}
//Handle top
- d->connectVHelper(d->top, slotStr);
- connect(this, SIGNAL(topMarginChanged()), this, slotStr);
- updateTopAnchor();
+ d->connectVHelper(d->top);
+ connect(this, SIGNAL(topMarginChanged()), this, SLOT(updateVerticalAnchors()));
+ updateVerticalAnchors();
} else if (d->usedAnchors & HasBottomAnchor) {
- const char *slotStr = SLOT(updateBottomAnchor());
-
//Handle stretching connections (if we have multiple horizontal anchors)
if (d->usedAnchors & HasVCenterAnchor) {
- d->connectVHelper(d->vCenter, slotStr);
- connect(this, SIGNAL(verticalCenterOffsetChanged()), this, slotStr);
+ d->connectVHelper(d->vCenter);
+ connect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors()));
}
//Handle bottom
- d->connectVHelper(d->bottom, slotStr);
- connect(this, SIGNAL(bottomMarginChanged()), this, slotStr);
- updateBottomAnchor();
+ d->connectVHelper(d->bottom);
+ connect(this, SIGNAL(bottomMarginChanged()), this, SLOT(updateVerticalAnchors()));
+ updateVerticalAnchors();
} else if (d->usedAnchors & HasVCenterAnchor) {
//Handle vCenter
- const char *slotStr = SLOT(updateVCenterAnchor());
- d->connectVHelper(d->vCenter, slotStr);
- connect(this, SIGNAL(verticalCenterOffsetChanged()), this, slotStr);
- updateVCenterAnchor();
+ d->connectVHelper(d->vCenter);
+ connect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors()));
+ updateVerticalAnchors();
}
}
-void QFxAnchorsPrivate::connectHHelper(const QFxAnchorLine &edge, const char *slotString)
+void QFxAnchorsPrivate::connectHHelper(const QFxAnchorLine &edge)
{
//### should we do disconnects first? (will it be called more than once?)
Q_Q(QFxAnchors);
@@ -317,7 +313,7 @@ void QFxAnchorsPrivate::connectHHelper(const QFxAnchorLine &edge, const char *sl
switch(edge.anchorLine) {
case QFxAnchorLine::Right:
case QFxAnchorLine::HCenter:
- QObject::connect(edge.item, SIGNAL(widthChanged()), q, slotString);
+ QObject::connect(edge.item, SIGNAL(widthChanged()), q, SLOT(updateHorizontalAnchors()));
break;
case QFxAnchorLine::Left: //no connection needed
default:
@@ -326,13 +322,13 @@ void QFxAnchorsPrivate::connectHHelper(const QFxAnchorLine &edge, const char *sl
} else if (edge.item->itemParent() == item->itemParent()) { //siblings
switch(edge.anchorLine) {
case QFxAnchorLine::Left:
- QObject::connect(edge.item, SIGNAL(leftChanged()), q, slotString);
+ QObject::connect(edge.item, SIGNAL(leftChanged()), q, SLOT(updateHorizontalAnchors()));
break;
case QFxAnchorLine::Right:
- QObject::connect(edge.item, SIGNAL(rightChanged()), q, slotString);
+ QObject::connect(edge.item, SIGNAL(rightChanged()), q, SLOT(updateHorizontalAnchors()));
break;
case QFxAnchorLine::HCenter:
- QObject::connect(edge.item, SIGNAL(hcenterChanged()), q, slotString);
+ QObject::connect(edge.item, SIGNAL(hcenterChanged()), q, SLOT(updateHorizontalAnchors()));
break;
default:
break;
@@ -349,45 +345,40 @@ void QFxAnchors::connectHAnchors()
return;
if (d->usedAnchors & HasLeftAnchor) {
- const char *slotStr = SLOT(updateLeftAnchor());
-
//Handle stretching connections (if we have multiple horizontal anchors)
QFxAnchorLine *edge = 0;
if (d->usedAnchors & HasRightAnchor) {
edge = &d->right;
- connect(this, SIGNAL(rightMarginChanged()), this, slotStr);
+ connect(this, SIGNAL(rightMarginChanged()), this, SLOT(updateHorizontalAnchors()));
} else if (d->usedAnchors & HasHCenterAnchor) {
edge = &d->hCenter;
- connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, slotStr);
+ connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors()));
}
if (edge) {
//we need to stretch
- d->connectHHelper(*edge, slotStr);
+ d->connectHHelper(*edge);
}
//Handle left
- d->connectHHelper(d->left, slotStr);
- connect(this, SIGNAL(leftMarginChanged()), this, slotStr);
- updateLeftAnchor();
+ d->connectHHelper(d->left);
+ connect(this, SIGNAL(leftMarginChanged()), this, SLOT(updateHorizontalAnchors()));
+ updateHorizontalAnchors();
} else if (d->usedAnchors & HasRightAnchor) {
- const char *slotStr = SLOT(updateRightAnchor());
-
//Handle stretching connections (if we have multiple horizontal anchors)
if (d->usedAnchors & HasHCenterAnchor) {
- d->connectHHelper(d->hCenter, slotStr);
- connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, slotStr);
+ d->connectHHelper(d->hCenter);
+ connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors()));
}
//Handle right
- d->connectHHelper(d->right, slotStr);
- connect(this, SIGNAL(rightMarginChanged()), this, slotStr);
- updateRightAnchor();
+ d->connectHHelper(d->right);
+ connect(this, SIGNAL(rightMarginChanged()), this, SLOT(updateHorizontalAnchors()));
+ updateHorizontalAnchors();
} else if (d->usedAnchors & HasHCenterAnchor) {
//Handle hCenter
- const char *slotStr = SLOT(updateHCenterAnchor());
- d->connectHHelper(d->hCenter, slotStr);
- connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, slotStr);
- updateHCenterAnchor();
+ d->connectHHelper(d->hCenter);
+ connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors()));
+ updateHorizontalAnchors();
}
}
@@ -420,126 +411,168 @@ bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1,
return invalid;
}
-void QFxAnchors::updateTopAnchor()
+void QFxAnchors::updateVerticalAnchors()
{
Q_D(QFxAnchors);
- if (d->usedAnchors & HasTopAnchor) {
- //Handle stretching
- bool invalid = true;
- int height = 0;
- if (d->usedAnchors & HasBottomAnchor) {
- invalid = d->calcStretch(d->top, d->bottom, d->topMargin, -d->bottomMargin, QFxAnchorLine::Top, height);
- } else if (d->usedAnchors & HasVCenterAnchor) {
- invalid = d->calcStretch(d->top, d->vCenter, d->topMargin, d->vCenterOffset, QFxAnchorLine::Top, height);
- height *= 2;
- }
- if (!invalid)
- d->item->setHeight(height);
-
- //Handle top
- if (d->top.item == d->item->itemParent()) {
- d->item->setY(adjustedPosition(d->top.item, d->top.anchorLine) + d->topMargin);
- } else if (d->top.item->itemParent() == d->item->itemParent()) {
- d->item->setY(position(d->top.item, d->top.anchorLine) + d->topMargin);
- }
- }
-}
-
-void QFxAnchors::updateBottomAnchor()
-{
- Q_D(QFxAnchors);
- if (d->usedAnchors & HasBottomAnchor) {
- //Handle stretching (top + bottom case is handled in updateLeftAnchor)
- if (d->usedAnchors & HasVCenterAnchor) {
+ if (!d->updatingVerticalAnchor) {
+ d->updatingVerticalAnchor = true;
+ if (d->usedAnchors & HasTopAnchor) {
+ //Handle stretching
+ bool invalid = true;
int height = 0;
- bool invalid = d->calcStretch(d->vCenter, d->bottom, d->vCenterOffset, -d->bottomMargin,
- QFxAnchorLine::Top, height);
+ if (d->usedAnchors & HasBottomAnchor) {
+ invalid = d->calcStretch(d->top, d->bottom, d->topMargin, -d->bottomMargin, QFxAnchorLine::Top, height);
+ } else if (d->usedAnchors & HasVCenterAnchor) {
+ invalid = d->calcStretch(d->top, d->vCenter, d->topMargin, d->vCenterOffset, QFxAnchorLine::Top, height);
+ height *= 2;
+ }
if (!invalid)
- d->item->setHeight(height*2);
- }
+ d->item->setHeight(height);
+
+ //Handle top
+ if (d->top.item == d->item->itemParent()) {
+ d->item->setY(adjustedPosition(d->top.item, d->top.anchorLine) + d->topMargin);
+ } else if (d->top.item->itemParent() == d->item->itemParent()) {
+ d->item->setY(position(d->top.item, d->top.anchorLine) + d->topMargin);
+ }
+ } else if (d->usedAnchors & HasBottomAnchor) {
+ //Handle stretching (top + bottom case is handled above)
+ if (d->usedAnchors & HasVCenterAnchor) {
+ int height = 0;
+ bool invalid = d->calcStretch(d->vCenter, d->bottom, d->vCenterOffset, -d->bottomMargin,
+ QFxAnchorLine::Top, height);
+ if (!invalid)
+ d->item->setHeight(height*2);
+ }
+
+ //Handle bottom
+ if (d->bottom.item == d->item->itemParent()) {
+ d->item->setY(adjustedPosition(d->bottom.item, d->bottom.anchorLine) - d->item->height() - d->bottomMargin);
+ } else if (d->bottom.item->itemParent() == d->item->itemParent()) {
+ d->item->setY(position(d->bottom.item, d->bottom.anchorLine) - d->item->height() - d->bottomMargin);
+ }
- //Handle bottom
- if (d->bottom.item == d->item->itemParent()) {
- d->item->setY(adjustedPosition(d->bottom.item, d->bottom.anchorLine) - d->item->height() - d->bottomMargin);
- } else if (d->bottom.item->itemParent() == d->item->itemParent()) {
- d->item->setY(position(d->bottom.item, d->bottom.anchorLine) - d->item->height() - d->bottomMargin);
+
+ } else if (d->usedAnchors & HasVCenterAnchor) {
+ //(stetching handled above)
+
+ //Handle vCenter
+ if (d->vCenter.item == d->item->itemParent()) {
+ d->item->setY(adjustedPosition(d->vCenter.item, d->vCenter.anchorLine)
+ - d->item->height()/2 + d->vCenterOffset);
+ } else if (d->vCenter.item->itemParent() == d->item->itemParent()) {
+ d->item->setY(position(d->vCenter.item, d->vCenter.anchorLine) - d->item->height()/2 + d->vCenterOffset);
+ }
}
+ d->updatingVerticalAnchor = false;
+ } else {
+ qmlInfo(d->item) << "Anchor loop detected on vertical anchor.";
}
}
-void QFxAnchors::updateVCenterAnchor()
+void QFxAnchors::updateHorizontalAnchors()
{
Q_D(QFxAnchors);
- if (d->usedAnchors & HasVCenterAnchor) {
- //(stetching handled in other update functions)
+ if (!d->updatingHorizontalAnchor) {
+ d->updatingHorizontalAnchor = true;
- //Handle vCenter
- if (d->vCenter.item == d->item->itemParent()) {
- d->item->setY(adjustedPosition(d->vCenter.item, d->vCenter.anchorLine)
- - d->item->height()/2 + d->vCenterOffset);
- } else if (d->vCenter.item->itemParent() == d->item->itemParent()) {
- d->item->setY(position(d->vCenter.item, d->vCenter.anchorLine) - d->item->height()/2 + d->vCenterOffset);
+ //alternate implementation (needs performance testing)
+ /*switch(d->usedAnchors & QFxAnchors::Horizontal_Mask) {
+ case 0x03: //(HasLeftAnchor | HasRightAnchor)
+ {
+ int width = 0;
+ if (!d->calcStretch(d->left, d->right, d->leftMargin, -d->rightMargin, QFxAnchorLine::Left, width))
+ d->item->setWidth(width);
+ //fall though
}
- }
-}
-
-void QFxAnchors::updateLeftAnchor()
-{
- Q_D(QFxAnchors);
- if (d->usedAnchors & HasLeftAnchor) {
- //Handle stretching
- bool invalid = true;
- int width = 0;
- if (d->usedAnchors & HasRightAnchor) {
- invalid = d->calcStretch(d->left, d->right, d->leftMargin, -d->rightMargin, QFxAnchorLine::Left, width);
- } else if (d->usedAnchors & HasHCenterAnchor) {
- invalid = d->calcStretch(d->left, d->hCenter, d->leftMargin, d->hCenterOffset, QFxAnchorLine::Left, width);
- width *= 2;
+ case 0x11: //(HasLeftAnchor | HasHCenterAnchor)
+ {
+ if (d->usedAnchors & HasHCenterAnchor) {
+ int width = 0;
+ if (!d->calcStretch(d->left, d->hCenter, d->leftMargin, d->hCenterOffset, QFxAnchorLine::Left, width))
+ d->item->setWidth(width*2);
+ }
+ //fall though
}
- if (!invalid)
- d->item->setWidth(width);
-
- //Handle left
- if (d->left.item == d->item->itemParent()) {
- d->item->setX(adjustedPosition(d->left.item, d->left.anchorLine) + d->leftMargin);
- } else if (d->left.item->itemParent() == d->item->itemParent()) {
- d->item->setX(position(d->left.item, d->left.anchorLine) + d->leftMargin);
+ case HasLeftAnchor:
+ if (d->left.item == d->item->itemParent()) {
+ d->item->setX(adjustedPosition(d->left.item, d->left.anchorLine) + d->leftMargin);
+ } else if (d->left.item->itemParent() == d->item->itemParent()) {
+ d->item->setX(position(d->left.item, d->left.anchorLine) + d->leftMargin);
+ }
+ break;
+ case 0x12: //(HasRightAnchor | HasHCenterAnchor)
+ {
+ int width = 0;
+ if (!d->calcStretch(d->hCenter, d->right, d->hCenterOffset, -d->rightMargin, QFxAnchorLine::Left, width))
+ d->item->setWidth(width*2);
+ //fall though
}
- }
-}
+ case HasRightAnchor:
+ if (d->right.item == d->item->itemParent()) {
+ d->item->setX(adjustedPosition(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
+ } else if (d->right.item->itemParent() == d->item->itemParent()) {
+ d->item->setX(position(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
+ }
+ break;
+ case HasHCenterAnchor:
+ if (d->hCenter.item == d->item->itemParent()) {
+ d->item->setX(adjustedPosition(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
+ } else if (d->hCenter.item->itemParent() == d->item->itemParent()) {
+ d->item->setX(position(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
+ }
+ break;
+ default:
+ break;
+ }*/
-void QFxAnchors::updateRightAnchor()
-{
- Q_D(QFxAnchors);
- if (d->usedAnchors & HasRightAnchor) {
- //Handle stretching (left + right case is handled in updateLeftAnchor)
- if (d->usedAnchors & HasHCenterAnchor) {
+ if (d->usedAnchors & HasLeftAnchor) {
+ //Handle stretching
+ bool invalid = true;
int width = 0;
- bool invalid = d->calcStretch(d->hCenter, d->right, d->hCenterOffset, -d->rightMargin,
- QFxAnchorLine::Left, width);
+ if (d->usedAnchors & HasRightAnchor) {
+ invalid = d->calcStretch(d->left, d->right, d->leftMargin, -d->rightMargin, QFxAnchorLine::Left, width);
+ } else if (d->usedAnchors & HasHCenterAnchor) {
+ invalid = d->calcStretch(d->left, d->hCenter, d->leftMargin, d->hCenterOffset, QFxAnchorLine::Left, width);
+ width *= 2;
+ }
if (!invalid)
- d->item->setWidth(width*2);
+ d->item->setWidth(width);
+
+ //Handle left
+ if (d->left.item == d->item->itemParent()) {
+ d->item->setX(adjustedPosition(d->left.item, d->left.anchorLine) + d->leftMargin);
+ } else if (d->left.item->itemParent() == d->item->itemParent()) {
+ d->item->setX(position(d->left.item, d->left.anchorLine) + d->leftMargin);
+ }
+ } else if (d->usedAnchors & HasRightAnchor) {
+ //Handle stretching (left + right case is handled in updateLeftAnchor)
+ if (d->usedAnchors & HasHCenterAnchor) {
+ int width = 0;
+ bool invalid = d->calcStretch(d->hCenter, d->right, d->hCenterOffset, -d->rightMargin,
+ QFxAnchorLine::Left, width);
+ if (!invalid)
+ d->item->setWidth(width*2);
+ }
+
+ //Handle right
+ if (d->right.item == d->item->itemParent()) {
+ d->item->setX(adjustedPosition(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
+ } else if (d->right.item->itemParent() == d->item->itemParent()) {
+ d->item->setX(position(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
+ }
+ } else if (d->usedAnchors & HasHCenterAnchor) {
+ //Handle hCenter
+ if (d->hCenter.item == d->item->itemParent()) {
+ d->item->setX(adjustedPosition(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
+ } else if (d->hCenter.item->itemParent() == d->item->itemParent()) {
+ d->item->setX(position(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
+ }
}
- //Handle right
- if (d->right.item == d->item->itemParent()) {
- d->item->setX(adjustedPosition(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
- } else if (d->right.item->itemParent() == d->item->itemParent()) {
- d->item->setX(position(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
- }
- }
-}
-
-void QFxAnchors::updateHCenterAnchor()
-{
- Q_D(QFxAnchors);
- if (d->usedAnchors & HasHCenterAnchor) {
- //Handle hCenter
- if (d->hCenter.item == d->item->itemParent()) {
- d->item->setX(adjustedPosition(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
- } else if (d->hCenter.item->itemParent() == d->item->itemParent()) {
- d->item->setX(position(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
- }
+ d->updatingHorizontalAnchor = false;
+ } else {
+ qmlInfo(d->item) << "Anchor loop detected on horizontal anchor.";
}
}
@@ -562,6 +595,24 @@ void QFxAnchors::setTop(const QFxAnchorLine &edge)
d->top = edge;
}
+void QFxAnchors::resetTop()
+{
+ Q_D(QFxAnchors);
+
+ //update flags
+ d->usedAnchors &= ~HasTopAnchor;
+
+ //clear binding
+ QmlMetaProperty prop(this, "top");
+ prop.binding()->clearExpression();
+
+ //disconnect signal/slot connections as needed
+ disconnect(this, SIGNAL(topMarginChanged()), this, SLOT(updateVerticalAnchors()));
+ disconnect(d->top.item, 0, this, 0);
+
+ updateVerticalAnchors();
+}
+
QFxAnchorLine QFxAnchors::bottom() const
{
Q_D(const QFxAnchors);
@@ -579,7 +630,24 @@ void QFxAnchors::setBottom(const QFxAnchorLine &edge)
d->checkVValid();
d->bottom = edge;
+}
+
+void QFxAnchors::resetBottom()
+{
+ Q_D(QFxAnchors);
+
+ //update flags
+ d->usedAnchors &= ~HasBottomAnchor;
+
+ //clear binding
+ QmlMetaProperty prop(this, "bottom");
+ prop.binding()->clearExpression();
+
+ //disconnect signal/slot connections as needed
+ disconnect(this, SIGNAL(bottomMarginChanged()), this, SLOT(updateVerticalAnchors()));
+ disconnect(d->bottom.item, 0, this, 0);
+ updateVerticalAnchors();
}
QFxAnchorLine QFxAnchors::verticalCenter() const
@@ -601,6 +669,24 @@ void QFxAnchors::setVerticalCenter(const QFxAnchorLine &edge)
d->vCenter = edge;
}
+void QFxAnchors::resetVerticalCenter()
+{
+ Q_D(QFxAnchors);
+
+ //update flags
+ d->usedAnchors &= ~HasVCenterAnchor;
+
+ //clear binding
+ QmlMetaProperty prop(this, "verticalCenter");
+ prop.binding()->clearExpression();
+
+ //disconnect signal/slot connections as needed
+ disconnect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors()));
+ disconnect(d->vCenter.item, 0, this, 0);
+
+ updateVerticalAnchors();
+}
+
QFxAnchorLine QFxAnchors::left() const
{
Q_D(const QFxAnchors);
@@ -620,6 +706,24 @@ void QFxAnchors::setLeft(const QFxAnchorLine &edge)
d->left = edge;
}
+void QFxAnchors::resetLeft()
+{
+ Q_D(QFxAnchors);
+
+ //update flags
+ d->usedAnchors &= ~HasLeftAnchor;
+
+ //clear binding
+ QmlMetaProperty prop(this, "left");
+ prop.binding()->clearExpression();
+
+ //disconnect signal/slot connections as needed
+ disconnect(this, SIGNAL(leftMarginChanged()), this, SLOT(updateHorizontalAnchors()));
+ disconnect(d->left.item, 0, this, 0);
+
+ updateHorizontalAnchors();
+}
+
QFxAnchorLine QFxAnchors::right() const
{
Q_D(const QFxAnchors);
@@ -637,7 +741,24 @@ void QFxAnchors::setRight(const QFxAnchorLine &edge)
d->checkHValid();
d->right = edge;
+}
+
+void QFxAnchors::resetRight()
+{
+ Q_D(QFxAnchors);
+
+ //update flags
+ d->usedAnchors &= ~HasRightAnchor;
+
+ //clear binding
+ QmlMetaProperty prop(this, "right");
+ prop.binding()->clearExpression();
+
+ //disconnect signal/slot connections as needed
+ disconnect(this, SIGNAL(rightMarginChanged()), this, SLOT(updateHorizontalAnchors()));
+ disconnect(d->right.item, 0, this, 0);
+ updateHorizontalAnchors();
}
QFxAnchorLine QFxAnchors::horizontalCenter() const
@@ -659,6 +780,24 @@ void QFxAnchors::setHorizontalCenter(const QFxAnchorLine &edge)
d->hCenter = edge;
}
+void QFxAnchors::resetHorizontalCenter()
+{
+ Q_D(QFxAnchors);
+
+ //update flags
+ d->usedAnchors &= ~HasHCenterAnchor;
+
+ //clear binding
+ QmlMetaProperty prop(this, "horizontalCenter");
+ prop.binding()->clearExpression();
+
+ //disconnect signal/slot connections as needed
+ disconnect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors()));
+ disconnect(d->hCenter.item, 0, this, 0);
+
+ updateHorizontalAnchors();
+}
+
int QFxAnchors::leftMargin() const
{
Q_D(const QFxAnchors);
@@ -854,4 +993,5 @@ bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const
return true;
}
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h
index 3a250b9..5a8cc1a 100644
--- a/src/declarative/fx/qfxanchors.h
+++ b/src/declarative/fx/qfxanchors.h
@@ -84,12 +84,12 @@ class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject
{
Q_OBJECT
- Q_PROPERTY(QFxAnchorLine left READ left WRITE setLeft);
- Q_PROPERTY(QFxAnchorLine right READ right WRITE setRight);
- Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter);
- Q_PROPERTY(QFxAnchorLine top READ top WRITE setTop);
- Q_PROPERTY(QFxAnchorLine bottom READ bottom WRITE setBottom);
- Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter);
+ Q_PROPERTY(QFxAnchorLine left READ left WRITE setLeft RESET resetLeft);
+ Q_PROPERTY(QFxAnchorLine right READ right WRITE setRight RESET resetRight);
+ Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter);
+ Q_PROPERTY(QFxAnchorLine top READ top WRITE setTop RESET resetTop);
+ Q_PROPERTY(QFxAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom);
+ Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter);
Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged);
Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged);
Q_PROPERTY(int horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged());
@@ -109,27 +109,35 @@ public:
HasBottomAnchor = 0x08,
HasHCenterAnchor = 0x10,
HasVCenterAnchor = 0x20,
- HasBaselineAnchor = 0x40
+ HasBaselineAnchor = 0x40,
+ Horizontal_Mask = HasLeftAnchor | HasRightAnchor | HasHCenterAnchor,
+ Vertical_Mask = HasTopAnchor | HasBottomAnchor | HasVCenterAnchor | HasBaselineAnchor
};
Q_DECLARE_FLAGS(UsedAnchors, UsedAnchor);
QFxAnchorLine left() const;
void setLeft(const QFxAnchorLine &edge);
+ Q_INVOKABLE void resetLeft(); //### temporarily invokable for testing
QFxAnchorLine right() const;
void setRight(const QFxAnchorLine &edge);
+ void resetRight();
QFxAnchorLine horizontalCenter() const;
void setHorizontalCenter(const QFxAnchorLine &edge);
+ void resetHorizontalCenter();
QFxAnchorLine top() const;
void setTop(const QFxAnchorLine &edge);
+ void resetTop();
QFxAnchorLine bottom() const;
void setBottom(const QFxAnchorLine &edge);
+ void resetBottom();
QFxAnchorLine verticalCenter() const;
void setVerticalCenter(const QFxAnchorLine &edge);
+ void resetVerticalCenter();
int leftMargin() const;
void setLeftMargin(int);
@@ -172,12 +180,8 @@ Q_SIGNALS:
private Q_SLOTS:
void fillChanged();
- void updateLeftAnchor();
- void updateRightAnchor();
- void updateHCenterAnchor();
- void updateTopAnchor();
- void updateBottomAnchor();
- void updateVCenterAnchor();
+ void updateHorizontalAnchors();
+ void updateVerticalAnchors();
private:
//### should item be a friend? (and make some of the public methods private or protected)
diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h
index 3a5d1c7..82c2086 100644
--- a/src/declarative/fx/qfxanchors_p.h
+++ b/src/declarative/fx/qfxanchors_p.h
@@ -64,7 +64,8 @@ class QFxAnchorsPrivate : public QObjectPrivate
public:
QFxAnchorsPrivate()
: item(0), usedAnchors(0), fill(0), centeredIn(0), leftMargin(0), rightMargin(0),
- topMargin(0), bottomMargin(0), vCenterOffset(0), hCenterOffset(0)
+ topMargin(0), bottomMargin(0), vCenterOffset(0), hCenterOffset(0),
+ updatingHorizontalAnchor(false), updatingVerticalAnchor(false)
{
}
@@ -76,8 +77,8 @@ public:
bool checkVValid() const;
bool checkHAnchorValid(QFxAnchorLine anchor) const;
bool checkVAnchorValid(QFxAnchorLine anchor) const;
- void connectHHelper(const QFxAnchorLine &anchorLine, const char *slotString);
- void connectVHelper(const QFxAnchorLine &anchorLine, const char *slotString);
+ void connectHHelper(const QFxAnchorLine &anchorLine);
+ void connectVHelper(const QFxAnchorLine &anchorLine);
bool calcStretch(const QFxAnchorLine &edge1, const QFxAnchorLine &edge2, int offset1, int offset2, QFxAnchorLine::AnchorLine line, int &stretch);
QFxItem *item;
@@ -99,6 +100,9 @@ public:
int bottomMargin;
int vCenterOffset;
int hCenterOffset;
+
+ bool updatingHorizontalAnchor;
+ bool updatingVerticalAnchor;
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index fb46a0e..74c9b5b 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -851,7 +851,6 @@ void QFxTextEditPrivate::updateDefaultTextOption()
QTextOption::WrapMode oldWrapMode = opt.wrapMode();
-qDebug() << "wrap mode is" << opt.wrapMode();
if (wrap)
opt.setWrapMode(QTextOption::WordWrap);
else
@@ -859,7 +858,6 @@ qDebug() << "wrap mode is" << opt.wrapMode();
if (oldWrapMode == opt.wrapMode() && oldAlignment == opt.alignment())
return;
-qDebug() << "wrap mode set to" << opt.wrapMode();
document->setDefaultTextOption(opt);
}
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index 9428281..61f08de 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -47,6 +47,7 @@
#include "qhash.h"
#include "qlist.h"
#include "private/qobject_p.h"
+#include "private/qmetaobjectbuilder_p.h"
#include "qmlopenmetaobject.h"
#include "qmllistaccessor.h"
#include "qfxvisualitemmodel.h"