diff options
3 files changed, 41 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index b9231a1..179f13d 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -1027,13 +1027,13 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize) continue; if (d->flow == LeftToRight) { - if (hoffset && hoffset + child.item->width() > width()) { + if (widthValid() && hoffset && hoffset + child.item->width() > width()) { hoffset = 0; voffset += linemax + spacing(); linemax = 0; } } else { - if (voffset && voffset + child.item->height() > height()) { + if (heightValid() && voffset && voffset + child.item->height() > height()) { voffset = 0; hoffset += linemax + spacing(); linemax = 0; diff --git a/tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml b/tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml new file mode 100644 index 0000000..6dd108e --- /dev/null +++ b/tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +Rectangle { + width: 300; height: 200; + + property bool leftToRight: false + + Flow { + objectName: "flow" + flow: leftToRight ? Flow.LeftToRight : Flow.TopToBottom + spacing: 20 + anchors.horizontalCenter: parent.horizontalCenter + Rectangle { color: "red"; width: 100; height: 50 } + Rectangle { color: "blue"; width: 100; height: 50 } + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 62ec707..0663991 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -75,6 +75,7 @@ private slots: void test_repeater(); void test_flow(); void test_flow_resize(); + void test_flow_implicit_resize(); void test_conflictinganchors(); private: QDeclarativeView *createView(const QString &filename); @@ -655,6 +656,28 @@ void tst_QDeclarativePositioners::test_flow_resize() delete canvas; } +void tst_QDeclarativePositioners::test_flow_implicit_resize() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/flow-testimplicitsize.qml"); + QVERIFY(canvas->rootObject() != 0); + + QDeclarativeFlow *flow = canvas->rootObject()->findChild<QDeclarativeFlow*>("flow"); + QVERIFY(flow != 0); + + QCOMPARE(flow->width(), 100.0); + QCOMPARE(flow->height(), 120.0); + + canvas->rootObject()->setProperty("leftToRight", true); + QCOMPARE(flow->width(), 220.0); + QCOMPARE(flow->height(), 50.0); + + canvas->rootObject()->setProperty("leftToRight", false); + QCOMPARE(flow->width(), 100.0); + QCOMPARE(flow->height(), 120.0); + + delete canvas; +} + QString warningMessage; void interceptWarnings(QtMsgType type, const char *msg) |