summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativepositioners.cpp
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-04-27 09:06:32 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-04-28 01:42:19 (GMT)
commit946134b0ff303a1b44ae1ce5e3dcde7bfd8febcc (patch)
tree9f6b6e75a8f54aa203b6caad0b38dd7556a1b752 /src/declarative/graphicsitems/qdeclarativepositioners.cpp
parenta17339e943f21bb6c6e16884f716dd9ab8f94938 (diff)
downloadQt-946134b0ff303a1b44ae1ce5e3dcde7bfd8febcc.zip
Qt-946134b0ff303a1b44ae1ce5e3dcde7bfd8febcc.tar.gz
Qt-946134b0ff303a1b44ae1ce5e3dcde7bfd8febcc.tar.bz2
Setting conflicting anchors to items inside positioners should print a warning
Task-number: QTBUG-9025 Reviewed-by: Martin Jones
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativepositioners.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 21c33e2..32a512b 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -46,6 +46,7 @@
#include <qdeclarativestate_p.h>
#include <qdeclarativestategroup_p.h>
#include <qdeclarativestateoperations_p.h>
+#include <qdeclarativeinfo.h>
#include <QtCore/qmath.h>
#include <QDebug>
@@ -165,6 +166,7 @@ void QDeclarativeBasePositioner::componentComplete()
QDeclarativeItem::componentComplete();
positionedItems.reserve(d->QGraphicsItemPrivate::children.count());
prePositioning();
+ reportConflictingAnchors();
}
QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change,
@@ -436,6 +438,26 @@ void QDeclarativeColumn::doPositioning(QSizeF *contentSize)
contentSize->setHeight(voffset - spacing());
}
+void QDeclarativeColumn::reportConflictingAnchors()
+{
+ bool childsWithConflictingAnchors(false);
+ for (int ii = 0; ii < positionedItems.count(); ++ii) {
+ const PositionedItem &child = positionedItems.at(ii);
+ if (child.item) {
+ QDeclarativeAnchors::Anchors usedAnchors = child.item->anchors()->usedAnchors();
+ if (usedAnchors & QDeclarativeAnchors::TopAnchor ||
+ usedAnchors & QDeclarativeAnchors::BottomAnchor ||
+ usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
+ childsWithConflictingAnchors = true;
+ break;
+ }
+ }
+ }
+ if (childsWithConflictingAnchors) {
+ qmlInfo(this) << "Cannot specify top, bottom or verticalCenter anchors for items inside Column";
+ }
+}
+
/*!
\qmlclass Row QDeclarativeRow
\since 4.7
@@ -551,6 +573,25 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize)
contentSize->setWidth(hoffset - spacing());
}
+void QDeclarativeRow::reportConflictingAnchors()
+{
+ bool childsWithConflictingAnchors(false);
+ for (int ii = 0; ii < positionedItems.count(); ++ii) {
+ const PositionedItem &child = positionedItems.at(ii);
+ if (child.item) {
+ QDeclarativeAnchors::Anchors usedAnchors = child.item->anchors()->usedAnchors();
+ if (usedAnchors & QDeclarativeAnchors::LeftAnchor ||
+ usedAnchors & QDeclarativeAnchors::RightAnchor ||
+ usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
+ childsWithConflictingAnchors = true;
+ break;
+ }
+ }
+ }
+ if (childsWithConflictingAnchors) {
+ qmlInfo(this) << "Cannot specify left, right or horizontalCenter anchors for items inside Row";
+ }
+}
/*!
\qmlclass Grid QDeclarativeGrid
@@ -823,6 +864,20 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
}
}
+void QDeclarativeGrid::reportConflictingAnchors()
+{
+ bool childsWithConflictingAnchors(false);
+ for (int ii = 0; ii < positionedItems.count(); ++ii) {
+ const PositionedItem &child = positionedItems.at(ii);
+ if (child.item && child.item->anchors()->usedAnchors()) {
+ childsWithConflictingAnchors = true;
+ break;
+ }
+ }
+ if (childsWithConflictingAnchors) {
+ qmlInfo(this) << "Cannot specify anchors for items inside Grid";
+ }
+}
/*!
\qmlclass Flow QDeclarativeFlow
@@ -966,5 +1021,19 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
}
}
+void QDeclarativeFlow::reportConflictingAnchors()
+{
+ bool childsWithConflictingAnchors(false);
+ for (int ii = 0; ii < positionedItems.count(); ++ii) {
+ const PositionedItem &child = positionedItems.at(ii);
+ if (child.item && child.item->anchors()->usedAnchors()) {
+ childsWithConflictingAnchors = true;
+ break;
+ }
+ }
+ if (childsWithConflictingAnchors) {
+ qmlInfo(this) << "Cannot specify anchors for items inside Flow";
+ }
+}
QT_END_NAMESPACE