summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2013-04-05 10:32:14 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-08 13:40:03 +0200
commit2dd9ce1cf6549565b0f57d6663798bd25412506c (patch)
tree5d4a592f93227e981684189df7af1892fb7de86b
parent055b4a73e2b0c8d26a7581085885fe3b8b1b2219 (diff)
Fixed a bug where the MaximumSizeHint of a layout with spans was wrong
This was spotted while tracking down a similar bug related to spans. The problem was only for the maximum size, since the size of an ignored row/column was min: 0, pref: 0, max: FLT_MAX (the default constructed values for a QGridLayoutBox). Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com> (cherry picked from qtbase/9d7ae6dfbe25fb70a362a4cf955c187cd24cb007) Change-Id: Ic0f3cf12639fbb6ab85c4946d9e8cc1d8d68e753 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
-rw-r--r--src/layouts/qgridlayoutengine.cpp2
-rw-r--r--tests/auto/controls/data/tst_gridlayout.qml48
2 files changed, 35 insertions, 15 deletions
diff --git a/src/layouts/qgridlayoutengine.cpp b/src/layouts/qgridlayoutengine.cpp
index f72bffe26..d091d124e 100644
--- a/src/layouts/qgridlayoutengine.cpp
+++ b/src/layouts/qgridlayoutengine.cpp
@@ -432,6 +432,8 @@ QGridLayoutBox QGridLayoutRowData::totalBox(int start, int end) const
result.q_maximumSize = 0.0;
qreal nextSpacing = 0.0;
for (int i = start; i < end; ++i) {
+ if (ignore.testBit(i))
+ continue;
result.add(boxes.at(i), stretches.at(i), nextSpacing);
nextSpacing = spacings.at(i);
}
diff --git a/tests/auto/controls/data/tst_gridlayout.qml b/tests/auto/controls/data/tst_gridlayout.qml
index 2315dc14e..e92c75586 100644
--- a/tests/auto/controls/data/tst_gridlayout.qml
+++ b/tests/auto/controls/data/tst_gridlayout.qml
@@ -322,9 +322,14 @@ Item {
layout.destroy();
}
-
Component {
- id: layout_spans_Component
+ id: layout_spanAcrossEmptyRows_Component
+ /* This test has a large number of empty rows and columns, but there is one item
+ that spans across some of these empty rows/columns.
+ Do not modify (especially do not add items unless you understand what this is
+ testing)
+ */
+
GridLayout {
columnSpacing: 0
rowSpacing: 0
@@ -333,46 +338,59 @@ Item {
// (0,0)
id: r0
color: "black"
- width: 20
- height: 20
Layout.row: 0
Layout.column: 0
+ Layout.preferredWidth: 20
+ Layout.preferredHeight: 20
+ Layout.maximumWidth: 40
+ Layout.maximumHeight: 40
+ Layout.fillWidth: true
+ Layout.fillHeight: true
}
Rectangle {
// (0,1)
id: r1
color: "black"
- width: 20
- height: 20
Layout.row: 0
Layout.column: 1
Layout.columnSpan: 2
Layout.rowSpan: 2
+ Layout.preferredWidth: 20
+ Layout.preferredHeight: 20
+ Layout.maximumWidth: 40
+ Layout.maximumHeight: 40
+ Layout.fillWidth: true
+ Layout.fillHeight: true
}
Rectangle {
- // (99,99)
+ // (0,99)
id: r2
color: "black"
- width: 20
- height: 20
- Layout.row: 99
+ Layout.row: 0
Layout.column: 99
+ Layout.preferredWidth: 20
+ Layout.preferredHeight: 20
+ Layout.maximumWidth: 40
+ Layout.maximumHeight: 40
+ Layout.fillWidth: true
+ Layout.fillHeight: true
}
}
}
- function test_spans() {
- var layout = layout_spans_Component.createObject(container);
+ function test_spanAcrossEmptyRows() {
+ var layout = layout_spanAcrossEmptyRows_Component.createObject(container);
compare(layout.children[0].x, 0);
compare(layout.children[0].y, 0);
compare(layout.children[1].x, 20);
compare(layout.children[1].y, 0);
compare(layout.children[2].x, 40);
- compare(layout.children[2].y, 20);
+ compare(layout.children[2].y, 0);
+
+ compare(layout.implicitWidth, 60);
+ compare(layout.Layout.maximumWidth, 120);
layout.destroy();
}
-
-
}
}