From fb0765f5285b8518b3336a6aa36de1adc37bc1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 11 Nov 2010 07:13:35 +0100 Subject: Fix a behaviour change of sizeHint() introduced by 6d4d265e7e67dde58 Commit 6d4d265e7e67dde58e45d7d89f4974d0bd8b70e4 added a behaviour change in the cases if there was an item with height-for-width and sizeHint() was called with no constraint. The commit tried to return the height needed for the preferred width, but it still did not satisfy the constraints, since the width used as the constraint could be less than the preferred width. This also meant that the sizeHint(Qt::MinimumSize) could actually be larger than the smallest possible size. The behaviour should be that it should return the smallest width possible regardless of height. For instance, for a label it could return the size of the longest word (to avoid hyphenation issues). The same logic applies for the height: It should return the smallest height possible regardless of width. For instance, for a label it could then return the height of the font. I also had to fix some stuff in the heightForWidthWithSpanning() autotest since it wrongly expected the maximum size to be QWIDGETSIZE_MAX in several of the cases. However, that is the current behaviour (and it is a bug), but it is unrelated to the problem with spans so I simply fix the test and mark them with QEXPECT_FAIL. Reviewed-by: John Tapsell --- src/gui/graphicsview/qgridlayoutengine.cpp | 95 ++++++++++------------ .../tst_qgraphicsgridlayout.cpp | 19 +++-- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index e486b4d..9785b15 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -1107,7 +1107,50 @@ QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHi { QGridLayoutBox sizehint_totalBoxes[NOrientations]; - if(rowCount() < 1 || columnCount() < 1 || !hasDynamicConstraint()) { + bool sizeHintCalculated = false; + + if (hasDynamicConstraint() && rowCount() > 0 && columnCount() > 0) { + if (constraintOrientation() == Qt::Vertical) { + //We have items whose height depends on their width + if (constraint.width() >= 0) { + if(q_cachedDataForStyleInfo != styleInfo) + ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, NULL, NULL, Qt::Horizontal); + else + sizehint_totalBoxes[Hor] = q_totalBoxes[Hor]; + QVector sizehint_xx; + QVector sizehint_widths; + + sizehint_xx.resize(columnCount()); + sizehint_widths.resize(columnCount()); + qreal width = constraint.width(); + //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as + //constraints to find the row heights + q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(), + 0, sizehint_totalBoxes[Hor]); + ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical); + sizeHintCalculated = true; + } + } else { + if (constraint.height() >= 0) { + //We have items whose width depends on their height + ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, NULL, NULL, Qt::Vertical); + QVector sizehint_yy; + QVector sizehint_heights; + + sizehint_yy.resize(rowCount()); + sizehint_heights.resize(rowCount()); + qreal height = constraint.height(); + //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as + //constraints to find the column widths + q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(), + 0, sizehint_totalBoxes[Ver]); + ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, sizehint_yy.data(), sizehint_heights.data(), Qt::Vertical); + sizeHintCalculated = true; + } + } + } + + if (!sizeHintCalculated) { //No items with height for width, so it doesn't matter which order we do these in if(q_cachedDataForStyleInfo != styleInfo) { ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, NULL, NULL, Qt::Horizontal); @@ -1116,55 +1159,7 @@ QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHi sizehint_totalBoxes[Hor] = q_totalBoxes[Hor]; sizehint_totalBoxes[Ver] = q_totalBoxes[Ver]; } - } else if(constraintOrientation() == Qt::Vertical) { - //We have items whose width depends on their height - if(q_cachedDataForStyleInfo != styleInfo) - ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, NULL, NULL, Qt::Horizontal); - else - sizehint_totalBoxes[Hor] = q_totalBoxes[Hor]; - QVector sizehint_xx; - QVector sizehint_widths; - - sizehint_xx.resize(columnCount()); - sizehint_widths.resize(columnCount()); - qreal width = constraint.width(); - if(width < 0) { - /* It's not obvious what the behaviour should be. */ -/* if(which == Qt::MaximumSize) - width = sizehint_totalBoxes[Hor].q_maximumSize; - else if(which == Qt::MinimumSize) - width = sizehint_totalBoxes[Hor].q_minimumSize; - else*/ - width = sizehint_totalBoxes[Hor].q_preferredSize; - } - //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as - //constraints to find the row heights - q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(), - 0, sizehint_totalBoxes[Hor]); - ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical); - } else { - //We have items whose height depends on their width - ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, NULL, NULL, Qt::Vertical); - QVector sizehint_yy; - QVector sizehint_heights; - - sizehint_yy.resize(rowCount()); - sizehint_heights.resize(rowCount()); - qreal height = constraint.height(); - if(height < 0) { -/* if(which == Qt::MaximumSize) - height = sizehint_totalBoxes[Ver].q_maximumSize; - else if(which == Qt::MinimumSize) - height = sizehint_totalBoxes[Ver].q_minimumSize; - else*/ - height = sizehint_totalBoxes[Ver].q_preferredSize; - } - //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as - //constraints to find the column widths - q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(), - 0, sizehint_totalBoxes[Ver]); - ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, sizehint_yy.data(), sizehint_heights.data(), Qt::Vertical); - } + } switch (which) { case Qt::MinimumSize: diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 174e4aa..ff49b27 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -2556,8 +2556,9 @@ void tst_QGraphicsGridLayout::heightForWidth() w11->setSizePolicy(sp); layout->addItem(w11, 1, 1); - QSizeF prefSize = layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)); - QCOMPARE(prefSize, QSizeF(10+200, 10+100)); + QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)), QSizeF(2, 2)); + QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)), QSizeF(210, 110)); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(30100, 30100)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(2, -1)), QSizeF(2, 20001)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 20010)); @@ -2610,21 +2611,25 @@ void tst_QGraphicsGridLayout::heightForWidthWithSpanning() w->setSizePolicy(sp); layout->addItem(w, 0,0,2,2); - QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)), QSizeF(1, 100)); + QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)), QSizeF(1, 1)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)), QSizeF(200, 100)); - QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(30000, 30000)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(200, -1)), QSizeF(200, 100)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(200, -1)), QSizeF(200, 100)); - QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, QWIDGETSIZE_MAX)); + QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 100)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(2, -1)), QSizeF(2, 10000)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 10000)); - QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(2, -1)), QSizeF(2, QWIDGETSIZE_MAX)); + QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(2, -1)), QSizeF(2, 10000)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(200, -1)), QSizeF(200, 100)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(200, -1)), QSizeF(200, 100)); - QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, QWIDGETSIZE_MAX)); + QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 10000)); } QTEST_MAIN(tst_QGraphicsGridLayout) -- cgit v0.12 From 5c129ceed8cb157354250e1a938f0b8af5dfe507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 12 Nov 2010 12:14:11 +0100 Subject: Add back the tests that were removed by commit fcda1b785bd7d86011f49bfe96cb22b04202933f Also add a proper test for the alignment problem --- .../tst_qgraphicsgridlayout.cpp | 174 +++++++++++++++++++++ 1 file changed, 174 insertions(+) diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index ff49b27..e448e4c 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -2306,6 +2306,11 @@ static QSizeF hfw1(Qt::SizeHint, const QSizeF &constraint) return result; } +static QSizeF hfw2(Qt::SizeHint /*which*/, const QSizeF &constraint) +{ + return QSizeF(constraint.width(), constraint.width()); +} + void tst_QGraphicsGridLayout::geometries_data() { @@ -2361,6 +2366,31 @@ void tst_QGraphicsGridLayout::geometries_data() << QRectF(0, 1, 50,100) << QRectF(50, 1, 50,400) ); + + QTest::newRow("hfw-h408") << (ItemList() + << ItemDesc(0,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(0,1) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,1) + .sizeHint(Qt::MinimumSize, QSizeF(40,40)) + .sizeHint(Qt::PreferredSize, QSizeF(50,400)) + .sizeHint(Qt::MaximumSize, QSizeF(500, 500)) + .heightForWidth(hfw1) + ) + << QSizeF(100, 408) + << (RectList() + << QRectF(0, 0, 50, 8) << QRectF(50, 0, 50, 8) + << QRectF(0, 8, 50,100) << QRectF(50, 8, 50,400) + ); QTest::newRow("hfw-h410") << (ItemList() << ItemDesc(0,0) .minSize(QSizeF(1,1)) @@ -2386,6 +2416,150 @@ void tst_QGraphicsGridLayout::geometries_data() << QRectF(0, 10, 50,100) << QRectF(50, 10, 50,400) ); + QTest::newRow("hfw-h470") << (ItemList() + << ItemDesc(0,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(0,1) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,1) + .sizeHint(Qt::MinimumSize, QSizeF(40,40)) + .sizeHint(Qt::PreferredSize, QSizeF(50,400)) + .sizeHint(Qt::MaximumSize, QSizeF(500,500)) + .heightForWidth(hfw1) + ) + << QSizeF(100, 470) + << (RectList() + << QRectF(0, 0, 50,70) << QRectF(50, 0, 50,70) + << QRectF(0, 70, 50,100) << QRectF(50, 70, 50,400) + ); + + + // change layout width and verify + QTest::newRow("hfw-w100") << (ItemList() + << ItemDesc(0,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(0,1) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,1) + .sizeHint(Qt::MinimumSize, QSizeF(40,40)) + .sizeHint(Qt::PreferredSize, QSizeF(50,400)) + .sizeHint(Qt::MaximumSize, QSizeF(5000,5000)) + .heightForWidth(hfw1) + ) + << QSizeF(100, 401) + << (RectList() + << QRectF( 0, 0, 50, 1) << QRectF( 50, 0, 50, 1) + << QRectF( 0, 1, 50, 100) << QRectF( 50, 1, 50, 400) + ); + + QTest::newRow("hfw-w160") << (ItemList() + << ItemDesc(0,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(0,1) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,1) + .sizeHint(Qt::MinimumSize, QSizeF(40,40)) + .sizeHint(Qt::PreferredSize, QSizeF(50,400)) + .sizeHint(Qt::MaximumSize, QSizeF(5000,5000)) + .heightForWidth(hfw1) + ) + << QSizeF(160, 401) + << (RectList() + << QRectF( 0, 0, 80, 100) << QRectF( 80, 0, 80, 100) + << QRectF( 0, 100, 80, 100) << QRectF( 80, 100, 80, 250) + ); + + QTest::newRow("hfw-w500") << (ItemList() + << ItemDesc(0,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(0,1) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,0) + .minSize(QSizeF(1,1)) + .preferredSize(QSizeF(50,10)) + .maxSize(QSizeF(100, 100)) + << ItemDesc(1,1) + .sizeHint(Qt::MinimumSize, QSizeF(40,40)) + .sizeHint(Qt::PreferredSize, QSizeF(50,400)) + .sizeHint(Qt::MaximumSize, QSizeF(5000,5000)) + .heightForWidth(hfw1) + ) + << QSizeF(500, 401) + << (RectList() + << QRectF( 0, 0, 100, 100) << QRectF(100, 0, 100, 100) + << QRectF( 0, 100, 100, 100) << QRectF(100, 100, 400, 50) + ); + + QTest::newRow("hfw-alignment-defaults") << (ItemList() + << ItemDesc(0,0) + .minSize(QSizeF(100, 100)) + .maxSize(QSizeF(100, 100)) + .heightForWidth(hfw2) + << ItemDesc(1,0) + .minSize(QSizeF(200, 200)) + .maxSize(QSizeF(200, 200)) + .heightForWidth(hfw2) + << ItemDesc(2,0) + .minSize(QSizeF(300, 300)) + .maxSize(QSizeF(300, 300)) + ) + << QSizeF(300, 600) + << (RectList() + << QRectF(0, 0, 100, 100) + << QRectF(0, 100, 200, 200) + << QRectF(0, 300, 300, 300) + ); + + QTest::newRow("hfw-alignment2") << (ItemList() + << ItemDesc(0,0) + .minSize(QSizeF(100, 100)) + .maxSize(QSizeF(100, 100)) + .heightForWidth(hfw2) + .alignment(Qt::AlignRight) + << ItemDesc(1,0) + .minSize(QSizeF(200, 200)) + .maxSize(QSizeF(200, 200)) + .heightForWidth(hfw2) + .alignment(Qt::AlignHCenter) + << ItemDesc(2,0) + .minSize(QSizeF(300, 300)) + .maxSize(QSizeF(300, 300)) + ) + << QSizeF(300, 600) + << (RectList() + << QRectF(200, 0, 100, 100) + << QRectF( 50, 100, 200, 200) + << QRectF( 0, 300, 300, 300) + ); + } void tst_QGraphicsGridLayout::geometries() -- cgit v0.12 From 8f23788ec21896135f182778cf48362162b88969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 12 Nov 2010 13:16:53 +0100 Subject: Code style cleanup for merge request 847 --- src/gui/graphicsview/qgridlayoutengine.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index 9785b15..b7fe5a0 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -637,7 +637,7 @@ QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal heig if (dynamicConstraintOrientation() == Qt::Vertical) { if (size.width() > cellWidth) size = effectiveMaxSize(QSizeF(cellWidth, -1)); - } else if(size.height() > cellHeight) { + } else if (size.height() > cellHeight) { size = effectiveMaxSize(QSizeF(-1, cellHeight)); } } @@ -1113,7 +1113,7 @@ QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHi if (constraintOrientation() == Qt::Vertical) { //We have items whose height depends on their width if (constraint.width() >= 0) { - if(q_cachedDataForStyleInfo != styleInfo) + if (q_cachedDataForStyleInfo != styleInfo) ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, NULL, NULL, Qt::Horizontal); else sizehint_totalBoxes[Hor] = q_totalBoxes[Hor]; @@ -1152,7 +1152,7 @@ QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHi if (!sizeHintCalculated) { //No items with height for width, so it doesn't matter which order we do these in - if(q_cachedDataForStyleInfo != styleInfo) { + if (q_cachedDataForStyleInfo != styleInfo) { ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, NULL, NULL, Qt::Horizontal); ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, NULL, NULL, Qt::Vertical); } else { @@ -1680,7 +1680,7 @@ void QGridLayoutEngine::ensureGeometries(const QLayoutStyleInfo &styleInfo, q_heights.resize(rowCount()); q_descents.resize(rowCount()); - if(constraintOrientation() != Qt::Horizontal) { + if (constraintOrientation() != Qt::Horizontal) { //We might have items whose width depends on their height ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], styleInfo, NULL, NULL, Qt::Horizontal); //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as -- cgit v0.12 From 659c889f64e76ec9aece2dd9e24a7f65875c46ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 15 Nov 2010 08:56:58 +0100 Subject: Add autotest to test a issue with stretches and preferred width. The issue seemed to claim that the preferred size was not respected when there was another item that could stretch along the same axis: "A widget with a horizontal stretch next to it should get its preferredWidth()". This seems to works as expected, so nothing to fix. Task-number: QTBUG-12835 --- .../tst_qgraphicsgridlayout.cpp | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index e448e4c..7170059 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -122,6 +122,7 @@ private slots: void task236367_maxSizeHint(); void heightForWidth(); void heightForWidthWithSpanning(); + void stretchAndHeightForWidth(); }; class RectWidget : public QGraphicsWidget @@ -2806,6 +2807,67 @@ void tst_QGraphicsGridLayout::heightForWidthWithSpanning() QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 10000)); } + +void tst_QGraphicsGridLayout::stretchAndHeightForWidth() +{ + QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); + QGraphicsGridLayout *layout = new QGraphicsGridLayout; + widget->setLayout(layout); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + RectWidget *w1 = new RectWidget; + w1->setSizeHint(Qt::MinimumSize, QSizeF(10, 10)); + w1->setSizeHint(Qt::PreferredSize, QSizeF(100, 100)); + w1->setSizeHint(Qt::MaximumSize, QSizeF(500, 500)); + layout->addItem(w1, 0,0,1,1); + + RectWidget *w2 = new RectWidget; + w2->setSizeHint(Qt::MinimumSize, QSizeF(10, 10)); + w2->setSizeHint(Qt::PreferredSize, QSizeF(100, 100)); + w2->setSizeHint(Qt::MaximumSize, QSizeF(500, 500)); + layout->addItem(w2, 0,1,1,1); + layout->setColumnStretchFactor(1, 2); + + QApplication::sendPostedEvents(); + QGraphicsScene scene; + QGraphicsView *view = new QGraphicsView(&scene); + + scene.addItem(widget); + + view->show(); + + widget->resize(500, 100); + // w1 should stay at its preferred size + QCOMPARE(w1->geometry(), QRectF(0, 0, 100, 100)); + QCOMPARE(w2->geometry(), QRectF(100, 0, 400, 100)); + + + // only w1 has hfw + w1->setConstraintFunction(hfw); + QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Preferred); + sp.setHeightForWidth(true); + w1->setSizePolicy(sp); + QApplication::sendPostedEvents(); + + QCOMPARE(w1->geometry(), QRectF(0, 0, 100, 200)); + QCOMPARE(w2->geometry(), QRectF(100, 0, 400, 200)); + + // only w2 has hfw + w2->setConstraintFunction(hfw); + w2->setSizePolicy(sp); + + w1->setConstraintFunction(0); + sp.setHeightForWidth(false); + w1->setSizePolicy(sp); + QApplication::sendPostedEvents(); + + QCOMPARE(w1->geometry(), QRectF(0, 0, 100, 100)); + QCOMPARE(w2->geometry(), QRectF(100, 0, 400, 50)); + +} + + QTEST_MAIN(tst_QGraphicsGridLayout) #include "tst_qgraphicsgridlayout.moc" -- cgit v0.12 From 604c51f1fc5c79b7fad12cda911b06b9e6e5005f Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Mon, 15 Nov 2010 12:55:06 +0100 Subject: Fix item alignment in layouts bigger than the items thay they contain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-13551 Task-number: QTBUG-7756 Merge-request: 894 Reviewed-by: Jan-Arve Sæther --- src/gui/graphicsview/qgridlayoutengine.cpp | 92 ++++++++++++++-------- src/gui/graphicsview/qgridlayoutengine_p.h | 7 +- .../tst_qgraphicsgridlayout.cpp | 70 +++++++++++++--- .../tst_qgraphicslinearlayout.cpp | 85 ++++++++++++++++++++ 4 files changed, 208 insertions(+), 46 deletions(-) diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index b7fe5a0..f1055ba 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -166,7 +166,7 @@ void QGridLayoutRowData::reset(int count) hasIgnoreFlag = false; } -void QGridLayoutRowData::distributeMultiCells() +void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo) { MultiCellMap::const_iterator i = multiCellMap.constBegin(); for (; i != multiCellMap.constEnd(); ++i) { @@ -185,7 +185,7 @@ void QGridLayoutRowData::distributeMultiCells() qreal extra = compare(box, totalBox, j); if (extra > 0.0) { calculateGeometries(start, end, box.q_sizes(j), dummy.data(), newSizes.data(), - 0, totalBox); + 0, totalBox, rowInfo); for (int k = 0; k < span; ++k) extras[k].q_sizes(j) = newSizes[k]; @@ -202,11 +202,12 @@ void QGridLayoutRowData::distributeMultiCells() void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSize, qreal *positions, qreal *sizes, qreal *descents, - const QGridLayoutBox &totalBox) + const QGridLayoutBox &totalBox, + const QGridLayoutRowInfo &rowInfo) { Q_ASSERT(end > start); - targetSize = qBound(totalBox.q_minimumSize, targetSize, totalBox.q_maximumSize); + targetSize = qMax(totalBox.q_minimumSize, targetSize); int n = end - start; QVarLengthArray newSizes(n); @@ -246,16 +247,22 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz } } } else { - stealBox(start, end, PreferredSize, positions, sizes); + bool isLargerThanMaximum = (targetSize > totalBox.q_maximumSize); + if (isLargerThanMaximum) { + stealBox(start, end, MaximumSize, positions, sizes); + sumAvailable = targetSize - totalBox.q_maximumSize; + } else { + stealBox(start, end, PreferredSize, positions, sizes); + sumAvailable = targetSize - totalBox.q_preferredSize; + } - sumAvailable = targetSize - totalBox.q_preferredSize; if (sumAvailable > 0.0) { qreal sumCurrentAvailable = sumAvailable; bool somethingHasAMaximumSize = false; - qreal sumPreferredSizes = 0.0; + qreal sumSizes = 0.0; for (int i = 0; i < n; ++i) - sumPreferredSizes += sizes[i]; + sumSizes += sizes[i]; for (int i = 0; i < n; ++i) { if (ignore.testBit(start + i)) { @@ -265,7 +272,16 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz } const QGridLayoutBox &box = boxes.at(start + i); - qreal desired = box.q_maximumSize - box.q_preferredSize; + qreal boxSize; + + qreal desired; + if (isLargerThanMaximum) { + boxSize = box.q_maximumSize; + desired = rowInfo.boxes.value(start + i).q_maximumSize - boxSize; + } else { + boxSize = box.q_preferredSize; + desired = box.q_maximumSize - boxSize; + } if (desired == 0.0) { newSizes[i] = sizes[i]; factors[i] = 0.0; @@ -284,17 +300,17 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz } else if (stretch <= 0) { factors[i] = 0.0; } else { - qreal ultimatePreferredSize; - qreal ultimateSumPreferredSizes; - qreal x = ((stretch * sumPreferredSizes) - - (sumStretches * box.q_preferredSize)) + qreal ultimateSize; + qreal ultimateSumSizes; + qreal x = ((stretch * sumSizes) + - (sumStretches * boxSize)) / (sumStretches - stretch); if (x >= 0.0) { - ultimatePreferredSize = box.q_preferredSize + x; - ultimateSumPreferredSizes = sumPreferredSizes + x; + ultimateSize = boxSize + x; + ultimateSumSizes = sumSizes + x; } else { - ultimatePreferredSize = box.q_preferredSize; - ultimateSumPreferredSizes = (sumStretches * box.q_preferredSize) + ultimateSize = boxSize; + ultimateSumSizes = (sumStretches * boxSize) / stretch; } @@ -303,17 +319,17 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz (at the expense of the stretch factors, which are not fully respected during the transition). */ - ultimatePreferredSize = ultimatePreferredSize * 3 / 2; - ultimateSumPreferredSizes = ultimateSumPreferredSizes * 3 / 2; + ultimateSize = ultimateSize * 3 / 2; + ultimateSumSizes = ultimateSumSizes * 3 / 2; - qreal beta = ultimateSumPreferredSizes - sumPreferredSizes; + qreal beta = ultimateSumSizes - sumSizes; if (!beta) { factors[i] = 1; } else { qreal alpha = qMin(sumCurrentAvailable, beta); - qreal ultimateFactor = (stretch * ultimateSumPreferredSizes / sumStretches) - - (box.q_preferredSize); - qreal transitionalFactor = sumCurrentAvailable * (ultimatePreferredSize - box.q_preferredSize) / beta; + qreal ultimateFactor = (stretch * ultimateSumSizes / sumStretches) + - (boxSize); + qreal transitionalFactor = sumCurrentAvailable * (ultimateSize - boxSize) / beta; factors[i] = ((alpha * ultimateFactor) + ((beta - alpha) * transitionalFactor)) / beta; @@ -336,11 +352,16 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz if (newSizes[i] >= 0.0) continue; - const QGridLayoutBox &box = boxes.at(start + i); + qreal maxBoxSize; + if (isLargerThanMaximum) + maxBoxSize = rowInfo.boxes.value(start + i).q_maximumSize; + else + maxBoxSize = boxes.at(start + i).q_maximumSize; + qreal avail = sumCurrentAvailable * factors[i] / sumFactors; - if (sizes[i] + avail >= box.q_maximumSize) { - newSizes[i] = box.q_maximumSize; - sumCurrentAvailable -= box.q_maximumSize - sizes[i]; + if (sizes[i] + avail >= maxBoxSize) { + newSizes[i] = maxBoxSize; + sumCurrentAvailable -= maxBoxSize - sizes[i]; sumFactors -= factors[i]; keepGoing = (sumCurrentAvailable > 0.0); if (!keepGoing) @@ -1126,7 +1147,7 @@ QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHi //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as //constraints to find the row heights q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(), - 0, sizehint_totalBoxes[Hor]); + 0, sizehint_totalBoxes[Hor], q_infos[Hor]); ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical); sizeHintCalculated = true; } @@ -1143,7 +1164,7 @@ QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHi //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as //constraints to find the column widths q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(), - 0, sizehint_totalBoxes[Ver]); + 0, sizehint_totalBoxes[Ver], q_infos[Ver]); ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, sizehint_yy.data(), sizehint_heights.data(), Qt::Vertical); sizeHintCalculated = true; } @@ -1159,7 +1180,7 @@ QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHi sizehint_totalBoxes[Hor] = q_totalBoxes[Hor]; sizehint_totalBoxes[Ver] = q_totalBoxes[Ver]; } - } + } switch (which) { case Qt::MinimumSize: @@ -1617,7 +1638,8 @@ void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGri { rowData->reset(rowCount(orientation)); fillRowData(rowData, styleInfo, colPositions, colSizes, orientation); - rowData->distributeMultiCells(); + const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; + rowData->distributeMultiCells(rowInfo); *totalBox = rowData->totalBox(0, rowCount(orientation)); //We have items whose width depends on their height } @@ -1686,22 +1708,22 @@ void QGridLayoutEngine::ensureGeometries(const QLayoutStyleInfo &styleInfo, //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as //constraints to find the row heights q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), - 0, q_totalBoxes[Hor]); + 0, q_totalBoxes[Hor], q_infos[Hor] ); ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], styleInfo, q_xx.data(), q_widths.data(), Qt::Vertical); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), - q_descents.data(), q_totalBoxes[Ver]); + q_descents.data(), q_totalBoxes[Ver], q_infos[Ver]); } else { //We have items whose height depends on their width ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], styleInfo, NULL, NULL, Qt::Vertical); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as //constraints to find the column widths q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), - q_descents.data(), q_totalBoxes[Ver]); + q_descents.data(), q_totalBoxes[Ver], q_infos[Ver]); ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], styleInfo, q_yy.data(), q_heights.data(), Qt::Horizontal); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), - 0, q_totalBoxes[Hor]); + 0, q_totalBoxes[Hor], q_infos[Hor]); } } diff --git a/src/gui/graphicsview/qgridlayoutengine_p.h b/src/gui/graphicsview/qgridlayoutengine_p.h index 02c74b0..44efbba 100644 --- a/src/gui/graphicsview/qgridlayoutengine_p.h +++ b/src/gui/graphicsview/qgridlayoutengine_p.h @@ -224,13 +224,16 @@ public: typedef QMap, QGridLayoutMultiCellData> MultiCellMap; +class QGridLayoutRowInfo; + class QGridLayoutRowData { public: void reset(int count); - void distributeMultiCells(); + void distributeMultiCells(const QGridLayoutRowInfo &rowInfo); void calculateGeometries(int start, int end, qreal targetSize, qreal *positions, qreal *sizes, - qreal *descents, const QGridLayoutBox &totalBox); + qreal *descents, const QGridLayoutBox &totalBox, + const QGridLayoutRowInfo &rowInfo); QGridLayoutBox totalBox(int start, int end) const; void stealBox(int start, int end, int which, qreal *positions, qreal *sizes); diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 7170059..248778f 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -700,6 +700,10 @@ void tst_QGraphicsGridLayout::columnMaximumWidth() layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); + QCOMPARE(layout->minimumSize(), QSizeF(10+10+10, 10+10)); + QCOMPARE(layout->preferredSize(), QSizeF(25+25+25, 25+25)); + QCOMPARE(layout->maximumSize(), QSizeF(50+50+50, 50+50)); + // should at least be a very large number QVERIFY(layout->columnMaximumWidth(0) >= 10000); QCOMPARE(layout->columnMaximumWidth(0), layout->columnMaximumWidth(1)); @@ -707,17 +711,65 @@ void tst_QGraphicsGridLayout::columnMaximumWidth() layout->setColumnMaximumWidth(0, 20); layout->setColumnMaximumWidth(2, 60); - view.show(); - widget->show(); + QCOMPARE(layout->minimumSize(), QSizeF(10+10+10, 10+10)); + QCOMPARE(layout->preferredSize(), QSizeF(20+25+25, 25+25)); + QCOMPARE(layout->maximumSize(), QSizeF(20+50+60, 50+50)); + QCOMPARE(layout->maximumSize(), widget->maximumSize()); + widget->resize(widget->effectiveSizeHint(Qt::PreferredSize)); - QApplication::processEvents(); + layout->activate(); - QCOMPARE(layout->itemAt(0,0)->geometry().width(), 20.0); - QCOMPARE(layout->itemAt(1,0)->geometry().width(), 20.0); - QCOMPARE(layout->itemAt(0,1)->geometry().width(), 25.0); - QCOMPARE(layout->itemAt(1,1)->geometry().width(), 25.0); - QCOMPARE(layout->itemAt(0,2)->geometry().width(), 25.0); - QCOMPARE(layout->itemAt(1,2)->geometry().width(), 25.0); + QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(0, 0, 20, 25)); + QCOMPARE(layout->itemAt(1,0)->geometry(), QRectF(0, 25, 20, 25)); + QCOMPARE(layout->itemAt(0,1)->geometry(), QRectF(20, 0, 25, 25)); + QCOMPARE(layout->itemAt(1,1)->geometry(), QRectF(20, 25, 25, 25)); + QCOMPARE(layout->itemAt(0,2)->geometry(), QRectF(45, 0, 25, 25)); + QCOMPARE(layout->itemAt(1,2)->geometry(), QRectF(45, 25, 25, 25)); + + layout->setColumnAlignment(2, Qt::AlignCenter); //FIXME This shouldn't be needed because the documentation says that center is default + widget->resize(widget->effectiveSizeHint(Qt::MaximumSize)); + layout->activate(); + QCOMPARE(layout->geometry(), QRectF(0,0,20+50+60, 50+50)); + QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(0, 0, 20, 50)); + QCOMPARE(layout->itemAt(1,0)->geometry(), QRectF(0, 50, 20, 50)); + QCOMPARE(layout->itemAt(0,1)->geometry(), QRectF(20, 0, 50, 50)); + QCOMPARE(layout->itemAt(1,1)->geometry(), QRectF(20, 50, 50, 50)); + QCOMPARE(layout->itemAt(0,2)->geometry(), QRectF(75, 0, 50, 50)); + QCOMPARE(layout->itemAt(1,2)->geometry(), QRectF(75, 50, 50, 50)); + + for(int i = 0; i < layout->count(); i++) + layout->setAlignment(layout->itemAt(i), Qt::AlignRight | Qt::AlignBottom); + layout->activate(); + QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(0, 0, 20, 50)); + QCOMPARE(layout->itemAt(1,0)->geometry(), QRectF(0, 50, 20, 50)); + QCOMPARE(layout->itemAt(0,1)->geometry(), QRectF(20, 0, 50, 50)); + QCOMPARE(layout->itemAt(1,1)->geometry(), QRectF(20, 50, 50, 50)); + QCOMPARE(layout->itemAt(0,2)->geometry(), QRectF(80, 0, 50, 50)); + QCOMPARE(layout->itemAt(1,2)->geometry(), QRectF(80, 50, 50, 50)); + for(int i = 0; i < layout->count(); i++) + layout->setAlignment(layout->itemAt(i), Qt::AlignCenter); + + layout->setMaximumSize(layout->maximumSize() + QSizeF(60,60)); + widget->resize(widget->effectiveSizeHint(Qt::MaximumSize)); + layout->activate(); + + QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(0, 15, 20, 50)); + QCOMPARE(layout->itemAt(1,0)->geometry(), QRectF(0, 95, 20, 50)); + QCOMPARE(layout->itemAt(0,1)->geometry(), QRectF(20+30, 15, 50, 50)); + QCOMPARE(layout->itemAt(1,1)->geometry(), QRectF(20+30, 95, 50, 50)); + QCOMPARE(layout->itemAt(0,2)->geometry(), QRectF(20+60+50+5, 15, 50, 50)); + QCOMPARE(layout->itemAt(1,2)->geometry(), QRectF(20+60+50+5, 95, 50, 50)); + + layout->setMaximumSize(layout->preferredSize() + QSizeF(20,20)); + widget->resize(widget->effectiveSizeHint(Qt::MaximumSize)); + layout->activate(); + + QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(0, 0, 20, 35)); + QCOMPARE(layout->itemAt(1,0)->geometry(), QRectF(0, 35, 20, 35)); + QCOMPARE(layout->itemAt(0,1)->geometry(), QRectF(20, 0, 35, 35)); + QCOMPARE(layout->itemAt(1,1)->geometry(), QRectF(20, 35, 35, 35)); + QCOMPARE(layout->itemAt(0,2)->geometry(), QRectF(55, 0, 35, 35)); + QCOMPARE(layout->itemAt(1,2)->geometry(), QRectF(55, 35, 35, 35)); delete widget; } diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 6107fa1..e271aee 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -103,6 +103,8 @@ private slots: void removeLayout(); void avoidRecursionInInsertItem(); void styleInfoLeak(); + void testAlignmentInLargerLayout(); + void testOffByOneInLargerLayout(); // Task specific tests void task218400_insertStretchCrash(); @@ -1465,6 +1467,89 @@ void tst_QGraphicsLinearLayout::task218400_insertStretchCrash() form->setLayout(layout); // crash } +void tst_QGraphicsLinearLayout::testAlignmentInLargerLayout() +{ + QGraphicsScene *scene = new QGraphicsScene; + QGraphicsWidget *form = new QGraphicsWidget; + scene->addItem(form); + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, form); + layout->setSpacing(0); + layout->setContentsMargins(0,0,0,0); + + QGraphicsWidget *a = new QGraphicsWidget; + a->setMaximumSize(100,100); + layout->addItem(a); + + QCOMPARE(form->maximumSize(), QSizeF(100,100)); + QCOMPARE(layout->maximumSize(), QSizeF(100,100)); + layout->setMinimumSize(QSizeF(200,200)); + layout->setMaximumSize(QSizeF(200,200)); + + layout->setAlignment(a, Qt::AlignCenter); + layout->activate(); + QCOMPARE(a->geometry(), QRectF(50,50,100,100)); + + layout->setAlignment(a, Qt::AlignRight | Qt::AlignBottom); + layout->activate(); + QCOMPARE(a->geometry(), QRectF(100,100,100,100)); + + layout->setAlignment(a, Qt::AlignHCenter | Qt::AlignTop); + layout->activate(); + QCOMPARE(a->geometry(), QRectF(50,0,100,100)); + + QGraphicsWidget *b = new QGraphicsWidget; + b->setMaximumSize(100,100); + layout->addItem(b); + + layout->setAlignment(a, Qt::AlignCenter); + layout->setAlignment(b, Qt::AlignCenter); + layout->activate(); + QCOMPARE(a->geometry(), QRectF(50,0,100,100)); + QCOMPARE(b->geometry(), QRectF(50,100,100,100)); + + layout->setAlignment(a, Qt::AlignRight | Qt::AlignBottom); + layout->setAlignment(b, Qt::AlignLeft | Qt::AlignTop); + layout->activate(); + QCOMPARE(a->geometry(), QRectF(100,0,100,100)); + QCOMPARE(b->geometry(), QRectF(0,100,100,100)); +} + +void tst_QGraphicsLinearLayout::testOffByOneInLargerLayout() { + QGraphicsScene *scene = new QGraphicsScene; + QGraphicsWidget *form = new QGraphicsWidget; + scene->addItem(form); + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, form); + layout->setSpacing(0); + layout->setContentsMargins(0,0,0,0); + + QGraphicsWidget *a = new QGraphicsWidget; + QGraphicsWidget *b = new QGraphicsWidget; + a->setMaximumSize(100,100); + b->setMaximumSize(100,100); + layout->addItem(a); + layout->addItem(b); + + layout->setAlignment(a, Qt::AlignRight | Qt::AlignBottom); + layout->setAlignment(b, Qt::AlignLeft | Qt::AlignTop); + layout->setMinimumSize(QSizeF(101,201)); + layout->setMaximumSize(QSizeF(101,201)); + layout->activate(); + QCOMPARE(a->geometry(), QRectF(1,0.5,100,100)); + QCOMPARE(b->geometry(), QRectF(0,100.5,100,100)); + + layout->setMinimumSize(QSizeF(100,200)); + layout->setMaximumSize(QSizeF(100,200)); + layout->activate(); + QCOMPARE(a->geometry(), QRectF(0,0,100,100)); + QCOMPARE(b->geometry(), QRectF(0,100,100,100)); + + layout->setMinimumSize(QSizeF(99,199)); + layout->setMaximumSize(QSizeF(99,199)); + layout->activate(); + QCOMPARE(a->geometry(), QRectF(0,0,99,99.5)); + QCOMPARE(b->geometry(), QRectF(0,99.5,99,99.5)); +} + QTEST_MAIN(tst_QGraphicsLinearLayout) #include "tst_qgraphicslinearlayout.moc" -- cgit v0.12 From 1781b3c876b4e1025b2a85f4e7975c171b1a1404 Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Mon, 15 Nov 2010 12:55:13 +0100 Subject: Change the QGraphics*Layout documentation to match the code - that the default alignment is top-left. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This includes unit tests to confirm that the alignment is top-left in a variety of different cases. Merge-request: 894 Reviewed-by: Jan-Arve Sæther --- src/gui/graphicsview/qgraphicsgridlayout.cpp | 11 ++++++ src/gui/graphicsview/qgraphicslinearlayout.cpp | 4 +- .../tst_qgraphicsgridlayout.cpp | 45 +++++++++++++++++++++- .../tst_qgraphicslinearlayout.cpp | 33 ++++++++++++++++ 4 files changed, 89 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp index 3fc7f10..c3bb6c3 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.cpp +++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp @@ -64,6 +64,17 @@ removeAt() will remove an item from the layout, without destroying it. + \section1 Size Hints and Size Policies in QGraphicsGridLayout + + QGraphicsGridLayout respects each item's size hints and size policies, + and when the layout contains more space than the items can fill, each item + is arranged according to the layout's alignment for that item. You can set + an alignment for each item by calling setAlignment(), and check the + alignment for any item by calling alignment(). You can also set the alignment + for an entire row or column by calling setRowAlignment() and setColumnAlignment() + respectively. By default, items are aligned to the top left. + + \sa QGraphicsLinearLayout, QGraphicsWidget */ diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp index 7e8d19f..244a728 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.cpp +++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp @@ -75,7 +75,7 @@ is arranged according to the layout's alignment for that item. You can set an alignment for each item by calling setAlignment(), and check the alignment for any item by calling alignment(). By default, items are - centered both vertically and horizontally. + aligned to the top left. \section1 Spacing within QGraphicsLinearLayout @@ -446,7 +446,7 @@ void QGraphicsLinearLayout::setAlignment(QGraphicsLayoutItem *item, Qt::Alignmen /*! Returns the alignment for \a item. The default alignment is - Qt::AlignCenter. + Qt::AlignTop | Qt::AlignLeft. The alignment decides how the item is positioned within its assigned space in the case where there's more space available in the layout than the diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 248778f..8d1f282 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -123,6 +123,7 @@ private slots: void heightForWidth(); void heightForWidthWithSpanning(); void stretchAndHeightForWidth(); + void testDefaultAlignment(); }; class RectWidget : public QGraphicsWidget @@ -726,7 +727,7 @@ void tst_QGraphicsGridLayout::columnMaximumWidth() QCOMPARE(layout->itemAt(0,2)->geometry(), QRectF(45, 0, 25, 25)); QCOMPARE(layout->itemAt(1,2)->geometry(), QRectF(45, 25, 25, 25)); - layout->setColumnAlignment(2, Qt::AlignCenter); //FIXME This shouldn't be needed because the documentation says that center is default + layout->setColumnAlignment(2, Qt::AlignCenter); widget->resize(widget->effectiveSizeHint(Qt::MaximumSize)); layout->activate(); QCOMPARE(layout->geometry(), QRectF(0,0,20+50+60, 50+50)); @@ -2859,7 +2860,6 @@ void tst_QGraphicsGridLayout::heightForWidthWithSpanning() QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 10000)); } - void tst_QGraphicsGridLayout::stretchAndHeightForWidth() { QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); @@ -2919,7 +2919,48 @@ void tst_QGraphicsGridLayout::stretchAndHeightForWidth() } +void tst_QGraphicsGridLayout::testDefaultAlignment() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsGridLayout *layout = new QGraphicsGridLayout(widget); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + QGraphicsWidget *w = new QGraphicsWidget; + w->setMinimumSize(50,50); + w->setMaximumSize(50,50); + layout->addItem(w,0,0); + + //Default alignment should be to the top-left + //First, check by forcing the layout to be bigger + layout->setMinimumSize(100,100); + layout->activate(); + QCOMPARE(layout->geometry(), QRectF(0,0,100,100)); + QCOMPARE(w->geometry(), QRectF(0,0,50,50)); + layout->setMinimumSize(-1,-1); + + //Second, check by forcing the column and row to be bigger instead + layout->setColumnMinimumWidth(0, 100); + layout->setRowMinimumHeight(0, 100); + layout->activate(); + QCOMPARE(layout->geometry(), QRectF(0,0,100,100)); + QCOMPARE(w->geometry(), QRectF(0,0,50,50)); + layout->setMinimumSize(-1,-1); + layout->setColumnMinimumWidth(0, 0); + layout->setRowMinimumHeight(0, 0); + + + //Third, check by adding a larger item in the column + QGraphicsWidget *w2 = new QGraphicsWidget; + w2->setMinimumSize(100,100); + w2->setMaximumSize(100,100); + layout->addItem(w2,1,0); + layout->activate(); + QCOMPARE(layout->geometry(), QRectF(0,0,100,150)); + QCOMPARE(w->geometry(), QRectF(0,0,50,50)); + QCOMPARE(w2->geometry(), QRectF(0,50,100,100)); +} QTEST_MAIN(tst_QGraphicsGridLayout) #include "tst_qgraphicsgridlayout.moc" diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index e271aee..cbc90be 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -105,6 +105,7 @@ private slots: void styleInfoLeak(); void testAlignmentInLargerLayout(); void testOffByOneInLargerLayout(); + void testDefaultAlignment(); // Task specific tests void task218400_insertStretchCrash(); @@ -1549,6 +1550,38 @@ void tst_QGraphicsLinearLayout::testOffByOneInLargerLayout() { QCOMPARE(a->geometry(), QRectF(0,0,99,99.5)); QCOMPARE(b->geometry(), QRectF(0,99.5,99,99.5)); } +void tst_QGraphicsLinearLayout::testDefaultAlignment() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, widget); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + QGraphicsWidget *w = new QGraphicsWidget; + w->setMinimumSize(50,50); + w->setMaximumSize(50,50); + layout->addItem(w); + + //Default alignment should be to the top-left + QCOMPARE(layout->alignment(w), 0); + + //First, check by forcing the layout to be bigger + layout->setMinimumSize(100,100); + layout->activate(); + QCOMPARE(layout->geometry(), QRectF(0,0,100,100)); + QCOMPARE(w->geometry(), QRectF(0,0,50,50)); + layout->setMinimumSize(-1,-1); + + //Second, check by adding a larger item in the column + QGraphicsWidget *w2 = new QGraphicsWidget; + w2->setMinimumSize(100,100); + w2->setMaximumSize(100,100); + layout->addItem(w2); + layout->activate(); + QCOMPARE(layout->geometry(), QRectF(0,0,100,150)); + QCOMPARE(w->geometry(), QRectF(0,0,50,50)); + QCOMPARE(w2->geometry(), QRectF(0,50,100,100)); +} QTEST_MAIN(tst_QGraphicsLinearLayout) #include "tst_qgraphicslinearlayout.moc" -- cgit v0.12 From f0990583431166e721d038e150ba00b0edc4e105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 15 Nov 2010 14:28:59 +0100 Subject: Some improvements to the docs that was added in merge request 894 --- src/gui/graphicsview/qgraphicsgridlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp index c3bb6c3..20ebab6 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.cpp +++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp @@ -67,7 +67,7 @@ \section1 Size Hints and Size Policies in QGraphicsGridLayout QGraphicsGridLayout respects each item's size hints and size policies, - and when the layout contains more space than the items can fill, each item + and when a cell in the grid has more space than the items can fill, each item is arranged according to the layout's alignment for that item. You can set an alignment for each item by calling setAlignment(), and check the alignment for any item by calling alignment(). You can also set the alignment -- cgit v0.12 From 68fc0a299b9268007ae68f5d8a8dce40ed1e4e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 15 Nov 2010 14:33:51 +0100 Subject: Adhere to code style --- tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 8 ++++---- tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 8d1f282..2e52c4e 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -704,7 +704,7 @@ void tst_QGraphicsGridLayout::columnMaximumWidth() QCOMPARE(layout->minimumSize(), QSizeF(10+10+10, 10+10)); QCOMPARE(layout->preferredSize(), QSizeF(25+25+25, 25+25)); QCOMPARE(layout->maximumSize(), QSizeF(50+50+50, 50+50)); - + // should at least be a very large number QVERIFY(layout->columnMaximumWidth(0) >= 10000); QCOMPARE(layout->columnMaximumWidth(0), layout->columnMaximumWidth(1)); @@ -738,7 +738,7 @@ void tst_QGraphicsGridLayout::columnMaximumWidth() QCOMPARE(layout->itemAt(0,2)->geometry(), QRectF(75, 0, 50, 50)); QCOMPARE(layout->itemAt(1,2)->geometry(), QRectF(75, 50, 50, 50)); - for(int i = 0; i < layout->count(); i++) + for (int i = 0; i < layout->count(); i++) layout->setAlignment(layout->itemAt(i), Qt::AlignRight | Qt::AlignBottom); layout->activate(); QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(0, 0, 20, 50)); @@ -747,13 +747,13 @@ void tst_QGraphicsGridLayout::columnMaximumWidth() QCOMPARE(layout->itemAt(1,1)->geometry(), QRectF(20, 50, 50, 50)); QCOMPARE(layout->itemAt(0,2)->geometry(), QRectF(80, 0, 50, 50)); QCOMPARE(layout->itemAt(1,2)->geometry(), QRectF(80, 50, 50, 50)); - for(int i = 0; i < layout->count(); i++) + for (int i = 0; i < layout->count(); i++) layout->setAlignment(layout->itemAt(i), Qt::AlignCenter); layout->setMaximumSize(layout->maximumSize() + QSizeF(60,60)); widget->resize(widget->effectiveSizeHint(Qt::MaximumSize)); layout->activate(); - + QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(0, 15, 20, 50)); QCOMPARE(layout->itemAt(1,0)->geometry(), QRectF(0, 95, 20, 50)); QCOMPARE(layout->itemAt(0,1)->geometry(), QRectF(20+30, 15, 50, 50)); diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index cbc90be..965e340 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -1543,7 +1543,7 @@ void tst_QGraphicsLinearLayout::testOffByOneInLargerLayout() { layout->activate(); QCOMPARE(a->geometry(), QRectF(0,0,100,100)); QCOMPARE(b->geometry(), QRectF(0,100,100,100)); - + layout->setMinimumSize(QSizeF(99,199)); layout->setMaximumSize(QSizeF(99,199)); layout->activate(); -- cgit v0.12 From 2c40c98a5b3ff4f16c4ad71b5707d5271945819e Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 18 Nov 2010 12:15:03 +0200 Subject: QToolbar should fill available width on Symbian Normally QStyle provides a minimum size for a widget. However, to imitate native toolbar behavior, QToolBar should occupy available screen estate on Symbian (with QS60Style). This is only supported for horizontal QToolBars as native side does not have same functionality for vertical toolbars. QToolbar size now tries to take into account available size of parent reduced by margins (if several parents, then each can reduce the available space by their margins). Also, toolbar internal pixel metrics data (item spacing, item margins) are taken into account. Task-number: QTBUG-13120 Reviewed-by: Janne Koskinen --- src/gui/styles/qs60style.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 5fe9050..5eddc98 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2536,6 +2536,56 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast(opt)) if (toolBtn->subControls & SC_ToolButtonMenu) sz += QSize(pixelMetric(PM_MenuButtonIndicator), 0); + + //Make toolbuttons in toolbar stretch the whole screen area + if (widget && qobject_cast(widget->parentWidget())) { + const QToolBar *tb = qobject_cast(widget->parentWidget()); + const bool parentCanGrowHorizontally = !(tb->sizePolicy().horizontalPolicy() == QSizePolicy::Fixed || + tb->sizePolicy().horizontalPolicy() == QSizePolicy::Maximum) && tb->orientation() == Qt::Horizontal; + + if (parentCanGrowHorizontally) { + int visibleButtons = 0; + //Make the auto-stretch to happen only for horizontal orientation + if (tb && tb->orientation() == Qt::Horizontal) { + QList actionList = tb->actions(); + for (int i = 0; i < actionList.count(); i++) { + if (actionList.at(i)->isVisible()) + visibleButtons++; + } + } + + if (widget->parentWidget() && visibleButtons > 0) { + QWidget *w = const_cast(widget); + int toolBarMaxWidth = 0; + int totalMargin = 0; + while (w) { + //honor fixed width parents + if (w->maximumWidth() == w->minimumWidth()) + toolBarMaxWidth = qMax(toolBarMaxWidth, w->maximumWidth()); + if (w->layout() && w->windowType() == Qt::Widget) { + totalMargin += w->layout()->contentsMargins().left() + + w->layout()->contentsMargins().right(); + } + w = w->parentWidget(); + } + totalMargin += 2 * pixelMetric(QStyle::PM_ToolBarFrameWidth); + + if (toolBarMaxWidth == 0) + toolBarMaxWidth = + QApplication::desktop()->availableGeometry(widget->parentWidget()).width(); + //Reduce the margins, toolbar frame, item spacing and internal margin from available area + toolBarMaxWidth -= totalMargin; + + //ensure that buttons are side-by-side and not on top of each other + const int toolButtonWidth = (toolBarMaxWidth / visibleButtons) + - pixelMetric(QStyle::PM_ToolBarItemSpacing) + - pixelMetric(QStyle::PM_ToolBarItemMargin) + //toolbar frame needs to be reduced again, since QToolBarLayout adds it for each toolbar action + - 2 * pixelMetric(QStyle::PM_ToolBarFrameWidth) - 1; + sz.setWidth(qMax(toolButtonWidth, sz.width())); + } + } + } break; case CT_PushButton: sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); -- cgit v0.12 From faf0e9966c319ac774db3d4967d902772c30e526 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 18 Nov 2010 13:06:10 +0200 Subject: Tactile Feedback plugin is not compiled in latest Sym^3 RnD envs Due to somewhat questionable .pro-file flagging, the plugin is not currently compiled at all for latest Sym^3 environments. Flagging is now more bulletproof (not 3.1 & not 3.2), so even if the upcoming platform versions change, this should work in the future. Task-number: QTBUG-15428 Reviewed-by: Mikka Heikkinen --- src/plugins/s60/feedback/feedback.pro | 2 +- src/plugins/s60/s60.pro | 2 +- src/s60installs/s60installs.pro | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/s60/feedback/feedback.pro b/src/plugins/s60/feedback/feedback.pro index 1069220..5e577ec 100644 --- a/src/plugins/s60/feedback/feedback.pro +++ b/src/plugins/s60/feedback/feedback.pro @@ -6,7 +6,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/s60/feedback INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE -contains(S60_VERSION, 5.0)|contains(S60_VERSION, symbian3) { +!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { HEADERS += qtactileFeedback.h SOURCES += qtactileFeedback_s60.cpp diff --git a/src/plugins/s60/s60.pro b/src/plugins/s60/s60.pro index ffcd170..1ddf326 100644 --- a/src/plugins/s60/s60.pro +++ b/src/plugins/s60/s60.pro @@ -6,7 +6,7 @@ symbian { SUBDIRS += 3_1 3_2 } - contains(S60_VERSION, 5.0)|contains(S60_VERSION, symbian3) { + !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { SUBDIRS += feedback } diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 65b8781..7827fb6 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -87,7 +87,7 @@ symbian: { DEPLOYMENT += bearer_plugin } - contains(S60_VERSION, 5.0)|contains(S60_VERSION, symbian3) { + !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { feedback_plugin.sources = $$QT_BUILD_TREE/plugins/s60/feedback/qtactilefeedback$${QT_LIBINFIX}.dll feedback_plugin.path = c:$$QT_PLUGINS_BASE_DIR/feedback DEPLOYMENT += feedback_plugin -- cgit v0.12 From 31feffb92570c6e13618cc2d0d03a5f243a7e350 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 18 Nov 2010 13:06:10 +0200 Subject: Tactile Feedback plugin is not compiled in latest Sym^3 RnD envs Due to somewhat questionable .pro-file flagging, the plugin is not currently compiled at all for latest Sym^3 environments. Flagging is now more bulletproof (not 3.1 & not 3.2), so even if the upcoming platform versions change, this should work in the future. Task-number: QTBUG-15428 Reviewed-by: Miikka Heikkinen --- src/plugins/s60/feedback/feedback.pro | 2 +- src/plugins/s60/s60.pro | 2 +- src/s60installs/s60installs.pro | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/s60/feedback/feedback.pro b/src/plugins/s60/feedback/feedback.pro index 1069220..5e577ec 100644 --- a/src/plugins/s60/feedback/feedback.pro +++ b/src/plugins/s60/feedback/feedback.pro @@ -6,7 +6,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/s60/feedback INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE -contains(S60_VERSION, 5.0)|contains(S60_VERSION, symbian3) { +!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { HEADERS += qtactileFeedback.h SOURCES += qtactileFeedback_s60.cpp diff --git a/src/plugins/s60/s60.pro b/src/plugins/s60/s60.pro index ffcd170..1ddf326 100644 --- a/src/plugins/s60/s60.pro +++ b/src/plugins/s60/s60.pro @@ -6,7 +6,7 @@ symbian { SUBDIRS += 3_1 3_2 } - contains(S60_VERSION, 5.0)|contains(S60_VERSION, symbian3) { + !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { SUBDIRS += feedback } diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 65b8781..7827fb6 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -87,7 +87,7 @@ symbian: { DEPLOYMENT += bearer_plugin } - contains(S60_VERSION, 5.0)|contains(S60_VERSION, symbian3) { + !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { feedback_plugin.sources = $$QT_BUILD_TREE/plugins/s60/feedback/qtactilefeedback$${QT_LIBINFIX}.dll feedback_plugin.path = c:$$QT_PLUGINS_BASE_DIR/feedback DEPLOYMENT += feedback_plugin -- cgit v0.12 From a26d41fc2732e225dc9a1b5eb5224cc499ae87b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 18 Nov 2010 15:06:45 +0100 Subject: Improve performance of hfw in qgridlayoutengine by adding more caching. The previous code tried to do caching of queries with constraints too, but it's usecase was rather limited. The caching worked for the simple case of effectiveSizeHint(Qt::PreferredSize, QSize(10, -1)); effectiveSizeHint(Qt::PreferredSize, QSize(10, -1)); // uses cache The problem was that if somebody called this sequence: effectiveSizeHint(Qt::PreferredSize, QSize(10, -1)); effectiveSizeHint(Qt::PreferredSize, QSize(-1, -1)); effectiveSizeHint(Qt::PreferredSize, QSize(10, -1)); Each call would disregard the cache because the constraint was different. Now the pattern is used in the qgridlayoutengine itself when we calculate hfw: (yes, height-for-width). First, we ask for the horizontal size hints with no constraints. Then, we'll ask for the vertical size hints with constraints. Since horizontal and vertical ultimately comes from the same function (effectiveSizeHint) it will invalidate the cache each time. The solution is to add another cache for the sizeHints with constraints. The most notable improvement is in the hfw, nested case. Result: RESULT : tst_QGraphicsLinearLayout::heightForWidth():"hfw, nested": 546 msecs per iteration (total: 546, iterations: 1) RESULT : tst_QGraphicsLinearLayout::heightForWidth():"hfw, nested": 0.000029 msecs per iteration (total: 62, iterations: 2097152) Improvement: 18,827,586 times faster (!!) --- src/gui/graphicsview/qgraphicslayoutitem.cpp | 35 ++++-- src/gui/graphicsview/qgraphicslayoutitem_p.h | 2 + .../qgraphicslinearlayout.pro | 6 + .../tst_qgraphicslinearlayout.cpp | 133 +++++++++++++++++++++ 4 files changed, 165 insertions(+), 11 deletions(-) create mode 100644 tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/qgraphicslinearlayout.pro create mode 100644 tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index e43f7fa..016cfbf 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -137,19 +137,28 @@ void QGraphicsLayoutItemPrivate::init() QSizeF *QGraphicsLayoutItemPrivate::effectiveSizeHints(const QSizeF &constraint) const { Q_Q(const QGraphicsLayoutItem); - if (!sizeHintCacheDirty && cachedConstraint == constraint) - return cachedSizeHints; + QSizeF *sizeHintCache; + const bool hasConstraint = constraint.width() >= 0 || constraint.height() >= 0; + if (hasConstraint) { + if (!sizeHintWithConstraintCacheDirty && constraint == cachedConstraint) + return cachedSizeHintsWithConstraints; + sizeHintCache = cachedSizeHintsWithConstraints; + } else { + if (!sizeHintCacheDirty) + return cachedSizeHints; + sizeHintCache = cachedSizeHints; + } for (int i = 0; i < Qt::NSizeHints; ++i) { - cachedSizeHints[i] = constraint; + sizeHintCache[i] = constraint; if (userSizeHints) - combineSize(cachedSizeHints[i], userSizeHints[i]); + combineSize(sizeHintCache[i], userSizeHints[i]); } - QSizeF &minS = cachedSizeHints[Qt::MinimumSize]; - QSizeF &prefS = cachedSizeHints[Qt::PreferredSize]; - QSizeF &maxS = cachedSizeHints[Qt::MaximumSize]; - QSizeF &descentS = cachedSizeHints[Qt::MinimumDescent]; + QSizeF &minS = sizeHintCache[Qt::MinimumSize]; + QSizeF &prefS = sizeHintCache[Qt::PreferredSize]; + QSizeF &maxS = sizeHintCache[Qt::MaximumSize]; + QSizeF &descentS = sizeHintCache[Qt::MinimumDescent]; normalizeHints(minS.rwidth(), prefS.rwidth(), maxS.rwidth(), descentS.rwidth()); normalizeHints(minS.rheight(), prefS.rheight(), maxS.rheight(), descentS.rheight()); @@ -175,9 +184,13 @@ QSizeF *QGraphicsLayoutItemPrivate::effectiveSizeHints(const QSizeF &constraint) // Not supported yet // COMBINE_SIZE(descentS, q->sizeHint(Qt::MinimumDescent, constraint)); - cachedConstraint = constraint; - sizeHintCacheDirty = false; - return cachedSizeHints; + if (hasConstraint) { + cachedConstraint = constraint; + sizeHintWithConstraintCacheDirty = false; + } else { + sizeHintCacheDirty = false; + } + return sizeHintCache; } diff --git a/src/gui/graphicsview/qgraphicslayoutitem_p.h b/src/gui/graphicsview/qgraphicslayoutitem_p.h index b752e03..d72ee9f 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem_p.h +++ b/src/gui/graphicsview/qgraphicslayoutitem_p.h @@ -85,8 +85,10 @@ public: QSizeF *userSizeHints; mutable QSizeF cachedSizeHints[Qt::NSizeHints]; mutable QSizeF cachedConstraint; + mutable QSizeF cachedSizeHintsWithConstraints[Qt::NSizeHints]; mutable quint32 sizeHintCacheDirty : 1; + mutable quint32 sizeHintWithConstraintCacheDirty : 1; quint32 isLayout : 1; quint32 ownedByLayout : 1; diff --git a/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/qgraphicslinearlayout.pro b/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/qgraphicslinearlayout.pro new file mode 100644 index 0000000..ff85fe8 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/qgraphicslinearlayout.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_qgraphicslinearlayout + +SOURCES += tst_qgraphicslinearlayout.cpp + diff --git a/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp new file mode 100644 index 0000000..0dd9543 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class tst_QGraphicsLinearLayout : public QObject +{ + Q_OBJECT +public: + tst_QGraphicsLinearLayout() {} + ~tst_QGraphicsLinearLayout() {} + +private slots: + void heightForWidth_data(); + void heightForWidth(); +}; + + +struct MySquareWidget : public QGraphicsWidget +{ + MySquareWidget() {} + virtual QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const + { + if (which != Qt::PreferredSize) + return QGraphicsWidget::sizeHint(which, constraint); + if (constraint.width() < 0) + return QGraphicsWidget::sizeHint(which, constraint); + return QSizeF(constraint.width(), constraint.width()); + } +}; + +void tst_QGraphicsLinearLayout::heightForWidth_data() +{ + QTest::addColumn("hfw"); + QTest::addColumn("nested"); + + QTest::newRow("hfw") << true << false; + QTest::newRow("hfw, nested") << true << true; + QTest::newRow("not hfw") << false << false; + QTest::newRow("not hfw, nested") << false << true; +} + +void tst_QGraphicsLinearLayout::heightForWidth() +{ + QFETCH(bool, hfw); + QFETCH(bool, nested); + + QGraphicsScene scene; + QGraphicsWidget *form = new QGraphicsWidget; + scene.addItem(form); + + QGraphicsLinearLayout *outerlayout = 0; + if (nested) { + outerlayout = new QGraphicsLinearLayout(form); + for(int i = 0; i < 8; i++) { + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); + outerlayout->addItem(layout); + outerlayout = layout; + } + } + + QGraphicsLinearLayout *qlayout = 0; + qlayout = new QGraphicsLinearLayout(Qt::Vertical); + if (nested) + outerlayout->addItem(qlayout); + else + form->setLayout(qlayout); + + MySquareWidget *widget = new MySquareWidget; + for (int i = 0; i < 1; i++) { + widget = new MySquareWidget; + QSizePolicy sizepolicy = widget->sizePolicy(); + sizepolicy.setHeightForWidth(hfw); + widget->setSizePolicy(sizepolicy); + qlayout->addItem(widget); + } + // make sure only one iteration is done. + // run with tst_QGraphicsLinearLayout.exe "heightForWidth" -tickcounter -iterations 6 + // this will iterate 6 times the whole test, (not only the benchmark) + // which should reduce warmup time and give a realistic picture of the performance of + // effectiveSizeHint() + QSizeF constraint(hfw ? 100 : -1, -1); + QBENCHMARK { + (void)form->effectiveSizeHint(Qt::PreferredSize, constraint); + } + +} + + +QTEST_MAIN(tst_QGraphicsLinearLayout) + +#include "tst_qgraphicslinearlayout.moc" -- cgit v0.12 From 4258dd04e25c8831be9e8a7dc45b52d34782cb35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 19 Nov 2010 11:19:32 +0100 Subject: Fix the tests that got affected by the behaviour added in 604c51f1fc5c79 Task-number: QTBUG-13551 Task-number: QTBUG-7756 --- tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 2e52c4e..35ea059 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -2541,7 +2541,7 @@ void tst_QGraphicsGridLayout::geometries_data() .sizeHint(Qt::MaximumSize, QSizeF(5000,5000)) .heightForWidth(hfw1) ) - << QSizeF(160, 401) + << QSizeF(160, 350) << (RectList() << QRectF( 0, 0, 80, 100) << QRectF( 80, 0, 80, 100) << QRectF( 0, 100, 80, 100) << QRectF( 80, 100, 80, 250) @@ -2566,7 +2566,7 @@ void tst_QGraphicsGridLayout::geometries_data() .sizeHint(Qt::MaximumSize, QSizeF(5000,5000)) .heightForWidth(hfw1) ) - << QSizeF(500, 401) + << QSizeF(500, 200) << (RectList() << QRectF( 0, 0, 100, 100) << QRectF(100, 0, 100, 100) << QRectF( 0, 100, 100, 100) << QRectF(100, 100, 400, 50) -- cgit v0.12 From b0691b5a95c80ecd94867873e912e6952a2ec1b4 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 19 Nov 2010 12:45:46 +0200 Subject: QS60Style: Null pointer crash when using itemviews in some cases QS60Style attempts to use null pointer when drawing CE_ItemViewItem, if the parameter widget is provided as null. This leads to, for example, Chart example app crash in startup. Reviewed-by: Janne Anttila --- src/gui/styles/qs60style.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 5fe9050..22cb7d6 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1438,10 +1438,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget); QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget); const QAbstractItemView *itemView = qobject_cast(widget); - const bool singleSelection = - (itemView->selectionMode() == QAbstractItemView::SingleSelection || - itemView->selectionMode() == QAbstractItemView::NoSelection); - const bool selectItems = (itemView->selectionBehavior() == QAbstractItemView::SelectItems); + + const bool singleSelection = itemView && + ((itemView->selectionMode() == QAbstractItemView::SingleSelection || + itemView->selectionMode() == QAbstractItemView::NoSelection)); + const bool selectItems = itemView && (itemView->selectionBehavior() == QAbstractItemView::SelectItems); // draw themed background for itemview unless background brush has been defined. if (vopt->backgroundBrush == Qt::NoBrush) { -- cgit v0.12 From 1be70363b77b0a2ff75a23b5973861922f7a85c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 19 Nov 2010 11:47:42 +0100 Subject: Fix code style --- .../graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 0dd9543..dc415fb 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -93,7 +93,7 @@ void tst_QGraphicsLinearLayout::heightForWidth() QGraphicsLinearLayout *outerlayout = 0; if (nested) { outerlayout = new QGraphicsLinearLayout(form); - for(int i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); outerlayout->addItem(layout); outerlayout = layout; -- cgit v0.12 From becc25ad78a89199764a54f45248e4113600f0af Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 19 Nov 2010 12:52:06 +0200 Subject: QS60Style: Null pointer crash when using itemviews in some cases (pt2) Also remove accidentally added whitespaces. Task-number: QTBUG-15455 Reviewed-by: TrustMe --- src/gui/styles/qs60style.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index a58c8e5..2f09529 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1438,8 +1438,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget); QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget); const QAbstractItemView *itemView = qobject_cast(widget); - - const bool singleSelection = itemView && + + const bool singleSelection = itemView && ((itemView->selectionMode() == QAbstractItemView::SingleSelection || itemView->selectionMode() == QAbstractItemView::NoSelection)); const bool selectItems = itemView && (itemView->selectionBehavior() == QAbstractItemView::SelectItems); -- cgit v0.12 From ea84d7431810951aff2d6f85dca5f4ae4aeb4490 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Mon, 22 Nov 2010 22:49:36 +0100 Subject: Doc: Fixing typo --- src/gui/text/qfontengine_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_x11.cpp b/src/gui/text/qfontengine_x11.cpp index b7e4be2..c06be3b 100644 --- a/src/gui/text/qfontengine_x11.cpp +++ b/src/gui/text/qfontengine_x11.cpp @@ -429,7 +429,7 @@ void QFontEngineXLFD::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFl { int i = glyphs->numGlyphs; XCharStruct *xcs; - // inlined for better perfomance + // inlined for better performance if (!_fs->per_char) { xcs = &_fs->min_bounds; while (i != 0) { -- cgit v0.12 From 88dd7568fff419510a7c26ffb93d93cc276d7b3b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 23 Nov 2010 15:31:12 +0100 Subject: Fix filtering of columns in QSFPM. Fixes a crash introduced in 315c09c3873f7c5d8b785443372bf975bae47ee7 Reviewed-by: Gabriel de Dietrich Reviewed-by: Olivier --- src/gui/itemviews/qsortfilterproxymodel.cpp | 4 +-- .../qsortfilterproxymodel.pro | 5 +-- .../tst_qsortfilterproxymodel.cpp | 39 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index dc8d938..0d9819e 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -782,14 +782,14 @@ void QSortFilterProxyModelPrivate::source_items_inserted( if (orthogonal_source_to_proxy.isEmpty()) { const int ortho_end = (orient == Qt::Horizontal) ? model->rowCount(source_parent) : model->columnCount(source_parent); + orthogonal_source_to_proxy.resize(ortho_end); + for (int ortho_item = 0; ortho_item < ortho_end; ++ortho_item) { if ((orient == Qt::Horizontal) ? q->filterAcceptsRow(ortho_item, source_parent) : q->filterAcceptsColumn(ortho_item, source_parent)) { orthogonal_proxy_to_source.append(ortho_item); } } - orthogonal_source_to_proxy.resize(orthogonal_proxy_to_source.size()); - if (orient == Qt::Horizontal) { // We're reacting to columnsInserted, but we've just inserted new rows. Sort them. sort_source_rows(orthogonal_proxy_to_source, source_parent); diff --git a/tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro b/tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro index d2c1147..7edd4a5 100644 --- a/tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro +++ b/tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro @@ -1,6 +1,7 @@ load(qttest_p4) -SOURCES += tst_qsortfilterproxymodel.cpp - +INCLUDEPATH += $$PWD/../modeltest +SOURCES += tst_qsortfilterproxymodel.cpp ../modeltest/dynamictreemodel.cpp ../modeltest/modeltest.cpp +HEADERS += ../modeltest/dynamictreemodel.h ../modeltest/modeltest.h diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 66caf4a..93b9d30 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -43,6 +43,9 @@ #include #include "../../shared/util.h" +#include "dynamictreemodel.h" +#include "modeltest.h" + #include #include @@ -144,6 +147,7 @@ private slots: void testMultipleProxiesWithSelection(); void mapSelectionFromSource(); + void filteredColumns(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -3174,5 +3178,40 @@ void tst_QSortFilterProxyModel::taskQTBUG_10287_unnecessaryMapCreation() // No assert failure, it passes. } +class FilteredColumnProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + FilteredColumnProxyModel(QObject *parent = 0) + : QSortFilterProxyModel(parent) + { + + } + +protected: + bool filterAcceptsColumn(int column, const QModelIndex &source_parent) const + { + return column % 2 != 0; + } +}; + +void tst_QSortFilterProxyModel::filteredColumns() +{ + DynamicTreeModel *model = new DynamicTreeModel(this); + + FilteredColumnProxyModel *proxy = new FilteredColumnProxyModel(this); + proxy->setSourceModel(model); + + new ModelTest(proxy, this); + + ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this); + insertCommand->setNumCols(2); + insertCommand->setStartRow(0); + insertCommand->setEndRow(0); + // Parent is QModelIndex() + insertCommand->doCommand(); + +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" -- cgit v0.12