summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-29 07:46:06 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-29 11:01:45 (GMT)
commitcdfcdbacc543bc0b67e615adf7bb8d885285b425 (patch)
treebc80d175ba08948fbb3e46ea957608b827e543bd
parent02989fc21d15dcbf5ceb6a55fc124b5eaf191169 (diff)
downloadQt-cdfcdbacc543bc0b67e615adf7bb8d885285b425.zip
Qt-cdfcdbacc543bc0b67e615adf7bb8d885285b425.tar.gz
Qt-cdfcdbacc543bc0b67e615adf7bb8d885285b425.tar.bz2
After some discussion we decided to remove hasConflicts() from the API.
hasConflicts() does only make sense for a tool/editor of the layout, and how this function would help the tool is only guesswork at the moment. We keep the private API though, in order to let the autotests we inherited from Orbit pass.
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.cpp12
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.h1
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp7
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h7
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp52
-rw-r--r--tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp5
6 files changed, 35 insertions, 49 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
index baea5d9..fdb1708 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
@@ -306,18 +306,6 @@ void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem *firstItem,
}
/*!
- Returns true if there are no arrangement that satisfies all constraints.
- Otherwise returns false.
-
- \sa addAnchor()
-*/
-bool QGraphicsAnchorLayout::hasConflicts() const
-{
- Q_D(const QGraphicsAnchorLayout);
- return d->hasConflicts();
-}
-
-/*!
Sets the default horizontal spacing for the anchor layout to \a spacing.
\sa horizontalSpacing(), setVerticalSpacing(), setSpacing()
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h
index 44074d1..d9a87ba 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.h
@@ -93,7 +93,6 @@ public:
QGraphicsLayoutItem *secondItem,
Qt::Orientations orientations = Qt::Horizontal | Qt::Vertical);
- bool hasConflicts() const;
void setHorizontalSpacing(qreal spacing);
void setVerticalSpacing(qreal spacing);
void setSpacing(qreal spacing);
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index 49aabf5..f75118b 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -2287,6 +2287,13 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(QList<QSimplexConstraint *> co
return feasible;
}
+/*!
+ \internal
+ Returns true if there are no arrangement that satisfies all constraints.
+ Otherwise returns false.
+
+ \sa addAnchor()
+*/
bool QGraphicsAnchorLayoutPrivate::hasConflicts() const
{
QGraphicsAnchorLayoutPrivate *that = const_cast<QGraphicsAnchorLayoutPrivate*>(this);
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index 4e1bcd4..c86bfa3 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -343,7 +343,7 @@ public:
QGraphicsAnchorLayout private methods and attributes.
*/
-class QGraphicsAnchorLayoutPrivate : public QGraphicsLayoutPrivate
+class Q_AUTOTEST_EXPORT QGraphicsAnchorLayoutPrivate : public QGraphicsLayoutPrivate
{
Q_DECLARE_PUBLIC(QGraphicsAnchorLayout)
@@ -370,6 +370,11 @@ public:
QGraphicsAnchorLayoutPrivate();
+ static QGraphicsAnchorLayoutPrivate *get(QGraphicsAnchorLayout *q)
+ {
+ return q ? q->d_func() : 0;
+ }
+
static Qt::AnchorPoint oppositeEdge(
Qt::AnchorPoint edge);
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 2fee98d..9f13aca 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -40,9 +40,10 @@
****************************************************************************/
#include <QtTest/QtTest>
-#include <qgraphicsanchorlayout.h>
-#include <qgraphicswidget.h>
-#include <qgraphicsproxywidget.h>
+#include <QtGui/qgraphicsanchorlayout.h>
+#include <private/qgraphicsanchorlayout_p.h>
+#include <QtGui/qgraphicswidget.h>
+#include <QtGui/qgraphicsproxywidget.h>
#include <QtGui/qgraphicsview.h>
class tst_QGraphicsAnchorLayout : public QObject {
@@ -142,6 +143,11 @@ static bool checkReverseDirection(QGraphicsWidget *w)
return true;
}
+static bool layoutHasConflict(QGraphicsAnchorLayout *l)
+{
+ return QGraphicsAnchorLayoutPrivate::get(l)->hasConflicts();
+}
+
void tst_QGraphicsAnchorLayout::simple()
{
QGraphicsWidget *w1 = createItem();
@@ -154,8 +160,6 @@ void tst_QGraphicsAnchorLayout::simple()
QGraphicsWidget p;
p.setLayout(l);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 2);
}
@@ -185,8 +189,6 @@ void tst_QGraphicsAnchorLayout::simple_center()
setAnchor(l, b, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
setAnchor(l, c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 3);
QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
@@ -234,8 +236,6 @@ void tst_QGraphicsAnchorLayout::simple_semifloat()
setAnchor(l, a, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 4);
QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
@@ -296,7 +296,6 @@ void tst_QGraphicsAnchorLayout::layoutDirection()
view->show();
QCOMPARE(checkReverseDirection(p), true);
- QVERIFY(l->hasConflicts() == false);
delete p;
delete view;
@@ -340,8 +339,6 @@ void tst_QGraphicsAnchorLayout::diagonal()
l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 5);
QGraphicsWidget p;
@@ -391,7 +388,7 @@ void tst_QGraphicsAnchorLayout::diagonal()
QCOMPARE(checkReverseDirection(&p), true);
c->setMinimumWidth(300);
- QVERIFY(l->hasConflicts());
+ QVERIFY(layoutHasConflict(l));
}
void tst_QGraphicsAnchorLayout::parallel()
@@ -484,8 +481,6 @@ void tst_QGraphicsAnchorLayout::parallel()
QCOMPARE(e->geometry(), QRectF(375, 400, 175, 100));
QCOMPARE(f->geometry(), QRectF(550, 500, 200, 100));
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::parallel2()
@@ -510,7 +505,6 @@ void tst_QGraphicsAnchorLayout::parallel2()
l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft);
l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 2);
QGraphicsWidget p;
@@ -592,8 +586,6 @@ void tst_QGraphicsAnchorLayout::snake()
QCOMPARE(b->geometry(), QRectF(90.0, 100.0, 10.0, 100.0));
QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
@@ -627,7 +619,6 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 3);
QGraphicsWidget p;
@@ -731,8 +722,6 @@ void tst_QGraphicsAnchorLayout::fairDistribution()
QCOMPARE(c->geometry(), QRectF(200.0, 200.0, 100.0, 100.0));
QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 300.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
@@ -809,8 +798,6 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
QCOMPARE(a->size(), d->size());
QCOMPARE(e->size().width(), 4 * a->size().width());
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::proportionalPreferred()
@@ -873,8 +860,6 @@ void tst_QGraphicsAnchorLayout::proportionalPreferred()
QCOMPARE(a->size().width(), 10 * factor);
QCOMPARE(c->size().width(), 14 * factor);
QCOMPARE(p.size(), QSizeF(12, 400));
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::example()
@@ -928,7 +913,6 @@ void tst_QGraphicsAnchorLayout::example()
l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 7);
QGraphicsWidget p;
@@ -1017,8 +1001,6 @@ void tst_QGraphicsAnchorLayout::setSpacing()
QCOMPARE(b->geometry(), QRectF(24, 0, 20, 20));
QCOMPARE(c->geometry(), QRectF(0, 20, 44, 20));
- QVERIFY(l->hasConflicts() == false);
-
delete p;
delete view;
}
@@ -1103,7 +1085,6 @@ void tst_QGraphicsAnchorLayout::hardComplexS60()
QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
QCOMPARE(layoutMaximumSize, QSizeF(240, 40));
- QVERIFY(l->hasConflicts() == false);
delete p;
}
@@ -1166,7 +1147,6 @@ void tst_QGraphicsAnchorLayout::delete_anchor()
QGraphicsWidget *p = new QGraphicsWidget;
p->setLayout(l);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 3);
scene.addItem(p);
@@ -1281,6 +1261,12 @@ void tst_QGraphicsAnchorLayout::sizePolicy()
delete view;
}
+/*!
+ \internal
+
+ Uses private API. (We have decided to pull hasConflicts() out of the API). However, it also
+ tests some tight conditions (almost-in-conflict) that we really want to test.
+*/
void tst_QGraphicsAnchorLayout::conflicts()
{
QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a");
@@ -1311,13 +1297,13 @@ void tst_QGraphicsAnchorLayout::conflicts()
p->setLayout(l);
- QCOMPARE(l->hasConflicts(), true);
+ QCOMPARE(layoutHasConflict(l), true);
a->setMinimumSize(QSizeF(29,10));
- QCOMPARE(l->hasConflicts(), false);
+ QCOMPARE(layoutHasConflict(l), false);
a->setMinimumSize(QSizeF(30,10));
- QCOMPARE(l->hasConflicts(), false);
+ QCOMPARE(layoutHasConflict(l), false);
delete p;
}
diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index a6746db..a521b78 100644
--- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -43,7 +43,8 @@
#include <QtTest/QtTest>
#include <QTest>
#include <QMetaType>
-#include <QGraphicsAnchorLayout>
+#include <QtGui/qgraphicsanchorlayout.h>
+#include <private/qgraphicsanchorlayout_p.h>
#define TEST_COMPLEX_CASES
@@ -60,7 +61,7 @@ public:
bool isValid()
{
- return !hasConflicts();
+ return !QGraphicsAnchorLayoutPrivate::get(this)->hasConflicts();
}
void setAnchor(