summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-11-27 11:40:48 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-11-27 11:40:48 (GMT)
commit9e68da0680d5b85a0713142df9b7ad9674960353 (patch)
tree6b8a7a6e53f80112ce1030f3943b204acfd4316a
parentaa911fcc8cae12c92941e21a02b7621d4e4bf118 (diff)
parentf95cf16c3330cea6821bcaf26aa7d0948f61729f (diff)
downloadQt-9e68da0680d5b85a0713142df9b7ad9674960353.zip
Qt-9e68da0680d5b85a0713142df9b7ad9674960353.tar.gz
Qt-9e68da0680d5b85a0713142df9b7ad9674960353.tar.bz2
Merge branch 'fixes' of git://gitorious.org/~fleury/qt/fleury-openbossa-clone into fleury-fixes
Conflicts: tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.cpp23
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp41
2 files changed, 43 insertions, 21 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
index 7e5929e..686096c 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
@@ -370,12 +370,6 @@ void QGraphicsAnchorLayout::setHorizontalSpacing(qreal spacing)
{
Q_D(QGraphicsAnchorLayout);
- // ### We don't support negative spacing yet
- if (spacing < 0) {
- spacing = 0;
- qWarning() << "QGraphicsAnchorLayout does not support negative spacing.";
- }
-
d->spacings[0] = spacing;
invalidate();
}
@@ -389,12 +383,6 @@ void QGraphicsAnchorLayout::setVerticalSpacing(qreal spacing)
{
Q_D(QGraphicsAnchorLayout);
- // ### We don't support negative spacing yet
- if (spacing < 0) {
- spacing = 0;
- qWarning() << "QGraphicsAnchorLayout does not support negative spacing.";
- }
-
d->spacings[1] = spacing;
invalidate();
}
@@ -405,7 +393,8 @@ void QGraphicsAnchorLayout::setVerticalSpacing(qreal spacing)
If an item is anchored with no spacing associated with the anchor, it will use the default
spacing.
- Currently QGraphicsAnchorLayout does not support negative default spacings.
+ QGraphicsAnchorLayout does not support negative spacings. Setting a negative value will unset the
+ previous spacing and make the layout use the spacing provided by the current widget style.
\sa setHorizontalSpacing(), setVerticalSpacing()
*/
@@ -413,14 +402,6 @@ void QGraphicsAnchorLayout::setSpacing(qreal spacing)
{
Q_D(QGraphicsAnchorLayout);
- // ### Currently we do not support negative anchors inside the graph.
- // To avoid those being created by a negative spacing, we must
- // make this test.
- if (spacing < 0) {
- spacing = 0;
- qWarning() << "QGraphicsAnchorLayout does not support negative spacing.";
- }
-
d->spacings[0] = d->spacings[1] = spacing;
invalidate();
}
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index e2f87b8..aa67ac5 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -88,6 +88,7 @@ private slots:
void spacingPersistency();
void snakeParallelWithLayout();
void parallelToHalfLayout();
+ void globalSpacing();
};
class RectWidget : public QGraphicsWidget
@@ -1976,5 +1977,45 @@ void tst_QGraphicsAnchorLayout::parallelToHalfLayout()
QCOMPARE(maximumSizeHint, QSizeF(400, 100) + overhead);
}
+void tst_QGraphicsAnchorLayout::globalSpacing()
+{
+ QGraphicsWidget *a = createItem();
+ QGraphicsWidget *b = createItem();
+
+ QGraphicsWidget w;
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&w);
+
+ l->addCornerAnchors(l, Qt::TopLeftCorner, a, Qt::TopLeftCorner);
+ l->addCornerAnchors(a, Qt::BottomRightCorner, b, Qt::TopLeftCorner);
+ l->addCornerAnchors(b, Qt::BottomRightCorner, l, Qt::BottomRightCorner);
+
+ w.resize(w.effectiveSizeHint(Qt::PreferredSize));
+ qreal vSpacing = b->geometry().top() - a->geometry().bottom();
+ qreal hSpacing = b->geometry().left() - a->geometry().right();
+
+ // Set spacings manually
+ l->setVerticalSpacing(vSpacing + 10);
+ l->setHorizontalSpacing(hSpacing + 5);
+
+ w.resize(w.effectiveSizeHint(Qt::PreferredSize));
+ qreal newVSpacing = b->geometry().top() - a->geometry().bottom();
+ qreal newHSpacing = b->geometry().left() - a->geometry().right();
+
+ QCOMPARE(newVSpacing, vSpacing + 10);
+ QCOMPARE(newHSpacing, hSpacing + 5);
+
+ // Set a negative spacing. This will unset the previous spacing and
+ // bring back the widget-defined spacing.
+ l->setSpacing(-1);
+
+ w.resize(w.effectiveSizeHint(Qt::PreferredSize));
+ newVSpacing = b->geometry().top() - a->geometry().bottom();
+ newHSpacing = b->geometry().left() - a->geometry().right();
+
+ QCOMPARE(newVSpacing, vSpacing);
+ QCOMPARE(newHSpacing, hSpacing);
+}
+
+
QTEST_MAIN(tst_QGraphicsAnchorLayout)
#include "tst_qgraphicsanchorlayout.moc"