From 6d4d265e7e67dde58e45d7d89f4974d0bd8b70e4 Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Mon, 4 Oct 2010 01:03:41 +0100 Subject: QGridLayoutEngine - Rework height-for-width support so that row/col spanning works Task-number: QTBUG-13547 Reviewed-by: Olivier Goffart Merge-request: 847 --- src/gui/graphicsview/qgridlayoutengine.cpp | 300 ++++++++------------- src/gui/graphicsview/qgridlayoutengine_p.h | 13 +- .../tst_qgraphicsgridlayout.cpp | 35 +++ 3 files changed, 157 insertions(+), 191 deletions(-) diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index 1e3addc..acac46f 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -1102,20 +1102,76 @@ QRectF QGridLayoutEngine::cellRect(const QLayoutStyleInfo &styleInfo, QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHint which, const QSizeF &constraint) const { - ensureColumnAndRowData(styleInfo); + QGridLayoutBox sizehint_totalBoxes[NOrientations]; - if (hasDynamicConstraint()) - return dynamicallyConstrainedSizeHint(which, constraint); + if(rowCount() < 1 || columnCount() < 1 || !hasDynamicConstraint()) { + //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); + ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, NULL, NULL, Qt::Vertical); + } else { + 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: - return QSizeF(q_totalBoxes[Hor].q_minimumSize, q_totalBoxes[Ver].q_minimumSize); + return QSizeF(sizehint_totalBoxes[Hor].q_minimumSize, sizehint_totalBoxes[Ver].q_minimumSize); case Qt::PreferredSize: - return QSizeF(q_totalBoxes[Hor].q_preferredSize, q_totalBoxes[Ver].q_preferredSize); + return QSizeF(sizehint_totalBoxes[Hor].q_preferredSize, sizehint_totalBoxes[Ver].q_preferredSize); case Qt::MaximumSize: - return QSizeF(q_totalBoxes[Hor].q_maximumSize, q_totalBoxes[Ver].q_maximumSize); + return QSizeF(sizehint_totalBoxes[Hor].q_maximumSize, sizehint_totalBoxes[Ver].q_maximumSize); case Qt::MinimumDescent: - return QSizeF(-1.0, q_totalBoxes[Hor].q_minimumDescent); // ### doesn't work + return QSizeF(-1.0, sizehint_totalBoxes[Hor].q_minimumDescent); // ### doesn't work default: break; } @@ -1291,6 +1347,7 @@ void QGridLayoutEngine::insertOrRemoveRows(int row, int delta, Qt::Orientation o } void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, const QLayoutStyleInfo &styleInfo, + qreal *colPositions, qreal *colSizes, Qt::Orientation orientation) const { const int ButtonMask = QSizePolicy::ButtonBox | QSizePolicy::PushButton; @@ -1404,11 +1461,21 @@ void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, const QLayoutSt box = &multiCell.q_box; multiCell.q_stretch = itemStretch; } - // Items with constraints are not included in the orientation that - // they are constrained (since it depends on the hfw/constraint function). - // They must be combined at a later stage. - if (!item->hasDynamicConstraint() || orientation != item->dynamicConstraintOrientation()) + // Items with constraints need to be passed the constraint + if (colSizes && colPositions && item->hasDynamicConstraint() && orientation == item->dynamicConstraintOrientation()) { + /* Get the width of the item by summing up the widths of the columns that it spans. + * We need to have already calculated the widths of the columns by calling + * q_columns->calculateGeometries() before hand and passing the value in the colSizes + * and colPositions parameters. + * The variable name is still colSizes even when it actually has the row sizes + */ + qreal length = colSizes[item->lastColumn(orientation)]; + if (item->columnSpan(orientation) != 1) + length += colPositions[item->lastColumn(orientation)] - colPositions[item->firstColumn(orientation)]; + box->combine(item->box(orientation, length)); + } else { box->combine(item->box(orientation)); + } if (effectiveRowSpan == 1) { QSizePolicy::ControlTypes controls = item->controlTypes(top); @@ -1545,115 +1612,18 @@ void QGridLayoutEngine::ensureEffectiveFirstAndLastRows() const } } -void QGridLayoutEngine::ensureColumnAndRowData(const QLayoutStyleInfo &styleInfo) const +void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGridLayoutBox *totalBox, + const QLayoutStyleInfo &styleInfo, + qreal *colPositions, qreal *colSizes, + Qt::Orientation orientation) const { - if (q_cachedDataForStyleInfo == styleInfo) - return; - - q_columnData.reset(columnCount()); - q_rowData.reset(rowCount()); - - fillRowData(&q_columnData, styleInfo, Qt::Horizontal); - fillRowData(&q_rowData, styleInfo, Qt::Vertical); - - q_columnData.distributeMultiCells(); - q_rowData.distributeMultiCells(); - - q_totalBoxes[Hor] = q_columnData.totalBox(0, columnCount()); - q_totalBoxes[Ver] = q_rowData.totalBox(0, rowCount()); - - q_cachedDataForStyleInfo = styleInfo; + rowData->reset(rowCount(orientation)); + fillRowData(rowData, styleInfo, colPositions, colSizes, orientation); + rowData->distributeMultiCells(); + *totalBox = rowData->totalBox(0, rowCount(orientation)); + //We have items whose width depends on their height } -QSizeF QGridLayoutEngine::dynamicallyConstrainedSizeHint(Qt::SizeHint which, - const QSizeF &constraint) const -{ - Q_ASSERT(hasDynamicConstraint()); - if (constraint.width() < 0 && constraint.height() < 0) { - // Process the hfw / wfh items that we did not process in fillRowData() - const Qt::Orientation constraintOrient = constraintOrientation(); - - QGridLayoutRowData rowData = constraintOrient == Qt::Vertical ? q_rowData : q_columnData; - for (int i = q_items.count() - 1; i >= 0; --i) { - QGridLayoutItem *item = q_items.at(i); - if (item->hasDynamicConstraint()) { - QGridLayoutBox box = item->box(constraintOrient); - QGridLayoutBox &rowBox = rowData.boxes[item->firstRow(constraintOrient)]; - rowBox.combine(box); - } - } - - QGridLayoutBox totalBoxes[2]; - if (constraintOrient == Qt::Vertical) { - totalBoxes[Hor] = q_columnData.totalBox(0, columnCount()); - totalBoxes[Ver] = rowData.totalBox(0, rowCount()); - } else { - totalBoxes[Hor] = rowData.totalBox(0, columnCount()); - totalBoxes[Ver] = q_rowData.totalBox(0, rowCount()); - } - return QSizeF(totalBoxes[Hor].q_sizes(which), totalBoxes[Ver].q_sizes(which)); - } - - - Q_ASSERT(constraint.width() >= 0 || constraint.height() >= 0); - q_xx.resize(columnCount()); - q_yy.resize(rowCount()); - q_widths.resize(columnCount()); - q_heights.resize(rowCount()); - q_descents.resize(rowCount()); - - - const Qt::Orientation orientation = constraintOrientation(); - QGridLayoutRowData *colData; - QGridLayoutRowData constrainedRowData; - QGridLayoutBox *totalBox; - qreal *sizes; - qreal *pos; - qreal *descents; - qreal targetSize; - qreal cCount; - qreal rCount; - - if (orientation == Qt::Vertical) { - // height for width - colData = &q_columnData; - totalBox = &q_totalBoxes[Hor]; - sizes = q_widths.data(); - pos = q_xx.data(); - descents = 0; - targetSize = constraint.width(); - cCount = columnCount(); - rCount = rowCount(); - constrainedRowData = q_rowData; - } else { - // width for height - colData = &q_rowData; - totalBox = &q_totalBoxes[Ver]; - sizes = q_heights.data(); - pos = q_yy.data(); - descents = q_descents.data(); - targetSize = constraint.height(); - cCount = rowCount(); - rCount = columnCount(); - constrainedRowData = q_columnData; - } - colData->calculateGeometries(0, cCount, targetSize, pos, sizes, descents, *totalBox); - for (int i = q_items.count() - 1; i >= 0; --i) { - QGridLayoutItem *item = q_items.at(i); - - if (item->hasDynamicConstraint()) { - const qreal size = sizes[item->firstColumn(orientation)]; - QGridLayoutBox box = item->box(orientation, size); - QGridLayoutBox &rowBox = constrainedRowData.boxes[item->firstRow(orientation)]; - rowBox.combine(box); - } - } - const qreal newSize = constrainedRowData.totalBox(0, rCount).q_sizes(which); - - return (orientation == Qt::Vertical) ? QSizeF(targetSize, newSize) : QSizeF(newSize, targetSize); -} - - /** returns false if the layout has contradicting constraints (i.e. some items with a horizontal constraint and other items with a vertical constraint) @@ -1700,85 +1670,41 @@ Qt::Orientation QGridLayoutEngine::constraintOrientation() const void QGridLayoutEngine::ensureGeometries(const QLayoutStyleInfo &styleInfo, const QSizeF &size) const { - ensureColumnAndRowData(styleInfo); - if (q_cachedSize == size) + if (q_cachedDataForStyleInfo == styleInfo && q_cachedSize == size) return; + q_cachedDataForStyleInfo = styleInfo; + q_cachedSize = size; + q_xx.resize(columnCount()); - q_yy.resize(rowCount()); q_widths.resize(columnCount()); + q_yy.resize(rowCount()); q_heights.resize(rowCount()); q_descents.resize(rowCount()); - - Qt::Orientation orientation = Qt::Vertical; - if (hasDynamicConstraint()) - orientation = constraintOrientation(); - - /* - In order to do hfw we need to first distribute the columns, then the rows. - In order to do wfh we need to first distribute the rows, then the columns. - - If there is no constraint, the order of distributing the rows or columns first is irrelevant. - We choose horizontal just to keep the same behaviour as before (however, there shouldn't - be any behaviour difference). - */ - - QGridLayoutRowData *colData; - QGridLayoutRowData rowData; - qreal *widths; - qreal *heights; - qreal *xx; - qreal *yy; - qreal *xdescents = 0; - qreal *ydescents = 0; - qreal cCount; - qreal rCount; - QSizeF oSize = size; - if (orientation == Qt::Vertical) { - // height for width - colData = &q_columnData; - rowData = q_rowData; - widths = q_widths.data(); - heights = q_heights.data(); - xx = q_xx.data(); - yy = q_yy.data(); - cCount = columnCount(); - rCount = rowCount(); - ydescents = q_descents.data(); + 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 + //constraints to find the row heights + q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), + 0, q_totalBoxes[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]); } else { - // width for height - colData = &q_rowData; - rowData = q_columnData; - widths = q_heights.data(); - heights = q_widths.data(); - xx = q_yy.data(); - yy = q_xx.data(); - cCount = rowCount(); - rCount = columnCount(); - xdescents = q_descents.data(); - oSize.transpose(); + //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]); + 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]); } - - colData->calculateGeometries(0, cCount, oSize.width(), xx, widths, - xdescents, q_totalBoxes[orientation == Qt::Horizontal]); - for (int i = q_items.count() - 1; i >= 0; --i) { - QGridLayoutItem *item = q_items.at(i); - const int col = item->firstColumn(orientation); - const int row = item->firstRow(orientation); - if (item->hasDynamicConstraint()) { - const qreal sz = widths[col]; - QGridLayoutBox box = item->box(orientation, sz); - rowData.boxes[row].combine(box); - } - } - - QGridLayoutBox &totalBox = q_totalBoxes[orientation == Qt::Vertical]; - totalBox = rowData.totalBox(0, rCount); - rowData.calculateGeometries(0, rCount, oSize.height(), yy, heights, - ydescents, totalBox); - - q_cachedSize = size; } QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qgridlayoutengine_p.h b/src/gui/graphicsview/qgridlayoutengine_p.h index 580af7e..02c74b0 100644 --- a/src/gui/graphicsview/qgridlayoutengine_p.h +++ b/src/gui/graphicsview/qgridlayoutengine_p.h @@ -93,8 +93,8 @@ enum LayoutSide { enum { NoConstraint, - HorizontalConstraint, - VerticalConstraint, + HorizontalConstraint, // Width depends on the height + VerticalConstraint, // Height depends on the width UnknownConstraint, // need to update cache UnfeasibleConstraint // not feasible, it be has some items with Vertical and others with Horizontal constraints }; @@ -410,9 +410,14 @@ private: void setItemAt(int row, int column, QGridLayoutItem *item); void insertOrRemoveRows(int row, int delta, Qt::Orientation orientation = Qt::Vertical); void fillRowData(QGridLayoutRowData *rowData, const QLayoutStyleInfo &styleInfo, - Qt::Orientation orientation = Qt::Vertical) const; + qreal *colPositions, qreal *colSizes, + Qt::Orientation orientation = Qt::Vertical) const; void ensureEffectiveFirstAndLastRows() const; - void ensureColumnAndRowData(const QLayoutStyleInfo &styleInfo) const; + void ensureColumnAndRowData(QGridLayoutRowData *rowData, QGridLayoutBox *totalBox, + const QLayoutStyleInfo &styleInfo, + qreal *colPositions, qreal *colSizes, + Qt::Orientation orientation) const; + void ensureGeometries(const QLayoutStyleInfo &styleInfo, const QSizeF &size) const; // User input diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 03c1d5b..3827018 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -108,6 +108,7 @@ private slots: void styleInfoLeak(); void task236367_maxSizeHint(); void heightForWidth(); + void heightForWidthWithSpanning(); }; class RectWidget : public QGraphicsWidget @@ -2571,6 +2572,40 @@ void tst_QGraphicsGridLayout::heightForWidth() } +void tst_QGraphicsGridLayout::heightForWidthWithSpanning() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsGridLayout *layout = new QGraphicsGridLayout; + widget->setLayout(layout); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + RectWidget *w = new RectWidget; + w->setSizeHint(Qt::MinimumSize, QSizeF(1,1)); + w->setSizeHint(Qt::MaximumSize, QSizeF(30000,30000)); + w->setConstraintFunction(hfw); + QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Preferred); + sp.setHeightForWidth(true); + 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::PreferredSize, QSizeF(-1, -1)), QSizeF(200, 100)); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + + 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)); + + 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)); + + 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)); +} + QTEST_MAIN(tst_QGraphicsGridLayout) #include "tst_qgraphicsgridlayout.moc" -- cgit v0.12 From fcda1b785bd7d86011f49bfe96cb22b04202933f Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Fri, 8 Oct 2010 15:10:20 +0100 Subject: QGraphicsLayoutItem - user set sizes should always override, even if there's a constraint Notes: * I have had to remove some of the old unit tests because the tested for strange behaviour. Now that height for width items behave more like normal items, it's no longer so easy to calculate what the geometries should be in strangely-sized layouts. * This also fixes alignment of height-for-width objects and adds a unit test for this. This couldn't be done in a seperate commit since the two fixes are related. Merge-request: 847 Reviewed-by: Olivier Goffart --- src/gui/graphicsview/qgraphicslayoutitem.cpp | 4 +- src/gui/graphicsview/qgridlayoutengine.cpp | 17 +- .../tst_qgraphicsgridlayout.cpp | 333 +++++++++++---------- 3 files changed, 188 insertions(+), 166 deletions(-) diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index 634f68c..e43f7fa 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -140,11 +140,9 @@ QSizeF *QGraphicsLayoutItemPrivate::effectiveSizeHints(const QSizeF &constraint) if (!sizeHintCacheDirty && cachedConstraint == constraint) return cachedSizeHints; - const bool hasConstraint = constraint.width() >= 0 || constraint.height() >= 0; - for (int i = 0; i < Qt::NSizeHints; ++i) { cachedSizeHints[i] = constraint; - if (userSizeHints && !hasConstraint) + if (userSizeHints) combineSize(cachedSizeHints[i], userSizeHints[i]); } diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index acac46f..e486b4d 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -631,14 +631,17 @@ QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal heig qreal cellWidth = width; qreal cellHeight = height; - QSize constraint; + + QSizeF size = effectiveMaxSize(QSizeF(-1,-1)); if (hasDynamicConstraint()) { - if (dynamicConstraintOrientation() == Qt::Vertical) - constraint.setWidth(cellWidth); - else - constraint.setHeight(cellHeight); + if (dynamicConstraintOrientation() == Qt::Vertical) { + if (size.width() > cellWidth) + size = effectiveMaxSize(QSizeF(cellWidth, -1)); + } else if(size.height() > cellHeight) { + size = effectiveMaxSize(QSizeF(-1, cellHeight)); + } } - QSizeF size = effectiveMaxSize(constraint).boundedTo(QSizeF(cellWidth, cellHeight)); + size = size.boundedTo(QSizeF(cellWidth, cellHeight)); width = size.width(); height = size.height(); @@ -714,7 +717,7 @@ QSizeF QGridLayoutItem::effectiveMaxSize(const QSizeF &constraint) const } if (!size.isValid()) { - QSizeF maxSize = layoutItem()->effectiveSizeHint(Qt::MaximumSize, constraint); + QSizeF maxSize = layoutItem()->effectiveSizeHint(Qt::MaximumSize, size); if (size.width() == -1) size.setWidth(maxSize.width()); if (size.height() == -1) diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 3827018..174e4aa 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -61,13 +61,19 @@ private slots: void qgraphicsgridlayout(); void addItem_data(); void addItem(); + void alignment_data(); void alignment(); void alignment2(); void alignment2_data(); + void columnAlignment_data(); void columnAlignment(); + void columnCount_data(); void columnCount(); + void columnMaximumWidth_data(); void columnMaximumWidth(); + void columnMinimumWidth_data(); void columnMinimumWidth(); + void columnPreferredWidth_data(); void columnPreferredWidth(); void setColumnFixedWidth(); void columnSpacing(); @@ -78,12 +84,18 @@ private slots: void horizontalSpacing(); void itemAt(); void removeAt(); + void rowAlignment_data(); void rowAlignment(); + void rowCount_data(); void rowCount(); + void rowMaximumHeight_data(); void rowMaximumHeight(); + void rowMinimumHeight_data(); void rowMinimumHeight(); + void rowPreferredHeight_data(); void rowPreferredHeight(); void rowSpacing(); + void rowStretchFactor_data(); void rowStretchFactor(); void setColumnSpacing_data(); void setColumnSpacing(); @@ -98,6 +110,7 @@ private slots: void sizeHint(); void verticalSpacing_data(); void verticalSpacing(); + void layoutDirection_data(); void layoutDirection(); void removeLayout(); void defaultStretchFactors_data(); @@ -371,7 +384,7 @@ void tst_QGraphicsGridLayout::qgraphicsgridlayout() layout.verticalSpacing(); } -static void populateLayout(QGraphicsGridLayout *gridLayout, int width, int height) +static void populateLayout(QGraphicsGridLayout *gridLayout, int width, int height, bool hasHeightForWidth = false) { for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { @@ -380,6 +393,9 @@ static void populateLayout(QGraphicsGridLayout *gridLayout, int width, int heigh item->setPreferredSize(25, 25); item->setMaximumSize(50, 50); gridLayout->addItem(item, y, x); + QSizePolicy policy = item->sizePolicy(); + policy.setHeightForWidth(hasHeightForWidth); + item->setSizePolicy(policy); } } } @@ -396,18 +412,22 @@ static void populateLayout(QGraphicsGridLayout *gridLayout, int width, int heigh * |xxxx|+---|---+| * +----+----+----+ */ -static void populateLayoutWithSpansAndHoles(QGraphicsGridLayout *gridLayout) +static void populateLayoutWithSpansAndHoles(QGraphicsGridLayout *gridLayout, bool hasHeightForWidth = false) { QGraphicsWidget *item = new RectWidget(); item->setMinimumSize(10, 10); item->setPreferredSize(25, 25); item->setMaximumSize(50, 50); + QSizePolicy sizepolicy = item->sizePolicy(); + sizepolicy.setHeightForWidth(hasHeightForWidth); + item->setSizePolicy(sizepolicy); gridLayout->addItem(item, 0, 0, 1, 2); item = new RectWidget(); item->setMinimumSize(10, 10); item->setPreferredSize(25, 25); item->setMaximumSize(50, 50); + item->setSizePolicy(sizepolicy); gridLayout->addItem(item, 1, 1, 1, 2); } @@ -460,19 +480,28 @@ void tst_QGraphicsGridLayout::addItem() delete layout; } +void tst_QGraphicsGridLayout::alignment_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} + // public Qt::Alignment alignment(QGraphicsLayoutItem* item) const void tst_QGraphicsGridLayout::alignment() { #ifdef Q_WS_MAC QSKIP("Resizing a QGraphicsWidget to effectiveSizeHint(Qt::MaximumSize) is currently not supported on mac", SkipAll); #endif + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 3, 2); + populateLayout(layout, 3, 2, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -524,6 +553,14 @@ void tst_QGraphicsGridLayout::alignment() delete widget; } +void tst_QGraphicsGridLayout::columnAlignment_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} + // public void setColumnAlignment(int column, Qt::Alignment alignment) // public Qt::Alignment columnAlignment(int column) const void tst_QGraphicsGridLayout::columnAlignment() @@ -531,13 +568,14 @@ void tst_QGraphicsGridLayout::columnAlignment() #ifdef Q_WS_MAC QSKIP("Resizing a QGraphicsWidget to effectiveSizeHint(Qt::MaximumSize) is currently not supported on mac", SkipAll); #endif + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 3, 2); + populateLayout(layout, 3, 2, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(1); widget->setContentsMargins(0, 0, 0, 0); @@ -583,9 +621,17 @@ void tst_QGraphicsGridLayout::columnAlignment() delete widget; } +void tst_QGraphicsGridLayout::columnCount_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} // public int columnCount() const void tst_QGraphicsGridLayout::columnCount() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); @@ -617,7 +663,7 @@ void tst_QGraphicsGridLayout::columnCount() // ### Talk with Jasmin. Not sure if removeAt() should adjust columnCount(). widget->setLayout(0); layout = new QGraphicsGridLayout(); - populateLayout(layout, 3, 2); + populateLayout(layout, 3, 2, hasHeightForWidth); QCOMPARE(layout->columnCount(), 3); layout->removeAt(5); layout->removeAt(3); @@ -632,16 +678,24 @@ void tst_QGraphicsGridLayout::columnCount() delete widget; } +void tst_QGraphicsGridLayout::columnMaximumWidth_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} // public qreal columnMaximumWidth(int column) const void tst_QGraphicsGridLayout::columnMaximumWidth() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 3, 2); + populateLayout(layout, 3, 2, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -667,16 +721,24 @@ void tst_QGraphicsGridLayout::columnMaximumWidth() delete widget; } +void tst_QGraphicsGridLayout::columnMinimumWidth_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} // public qreal columnMinimumWidth(int column) const void tst_QGraphicsGridLayout::columnMinimumWidth() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 3, 2); + populateLayout(layout, 3, 2, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -702,16 +764,24 @@ void tst_QGraphicsGridLayout::columnMinimumWidth() delete widget; } +void tst_QGraphicsGridLayout::columnPreferredWidth_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} // public qreal columnPreferredWidth(int column) const void tst_QGraphicsGridLayout::columnPreferredWidth() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 3, 2); + populateLayout(layout, 3, 2, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -1021,16 +1091,25 @@ void tst_QGraphicsGridLayout::removeAt() delete widget; } +void tst_QGraphicsGridLayout::rowAlignment_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} + // public Qt::Alignment rowAlignment(int row) const void tst_QGraphicsGridLayout::rowAlignment() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 2, 3); + populateLayout(layout, 2, 3, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(1); widget->setContentsMargins(0, 0, 0, 0); @@ -1080,17 +1159,26 @@ void tst_QGraphicsGridLayout::rowAlignment() delete widget; } +void tst_QGraphicsGridLayout::rowCount_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} + // public int rowCount() const // public int columnCount() const void tst_QGraphicsGridLayout::rowCount() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 2, 3); + populateLayout(layout, 2, 3, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); widget->setContentsMargins(0, 0, 0, 0); @@ -1100,23 +1188,32 @@ void tst_QGraphicsGridLayout::rowCount() // with spans and holes... widget->setLayout(0); layout = new QGraphicsGridLayout(); - populateLayoutWithSpansAndHoles(layout); + populateLayoutWithSpansAndHoles(layout, hasHeightForWidth); QCOMPARE(layout->rowCount(), 2); QCOMPARE(layout->columnCount(), 3); delete widget; } +void tst_QGraphicsGridLayout::rowMaximumHeight_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} + // public qreal rowMaximumHeight(int row) const void tst_QGraphicsGridLayout::rowMaximumHeight() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout; scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 2, 3); + populateLayout(layout, 2, 3, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -1142,16 +1239,24 @@ void tst_QGraphicsGridLayout::rowMaximumHeight() delete widget; } +void tst_QGraphicsGridLayout::rowMinimumHeight_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} // public qreal rowMinimumHeight(int row) const void tst_QGraphicsGridLayout::rowMinimumHeight() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 2, 3); + populateLayout(layout, 2, 3, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -1177,16 +1282,24 @@ void tst_QGraphicsGridLayout::rowMinimumHeight() delete widget; } +void tst_QGraphicsGridLayout::rowPreferredHeight_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} // public qreal rowPreferredHeight(int row) const void tst_QGraphicsGridLayout::rowPreferredHeight() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 2, 3); + populateLayout(layout, 2, 3, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -1275,16 +1388,25 @@ void tst_QGraphicsGridLayout::rowSpacing() } +void tst_QGraphicsGridLayout::rowStretchFactor_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} + // public int rowStretchFactor(int row) const void tst_QGraphicsGridLayout::rowStretchFactor() { + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 2, 3); + populateLayout(layout, 2, 3, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -1308,9 +1430,12 @@ void tst_QGraphicsGridLayout::setColumnSpacing_data() { QTest::addColumn("column"); QTest::addColumn("spacing"); - QTest::newRow("null") << 0 << qreal(0.0); - QTest::newRow("10") << 0 << qreal(10.0); + QTest::addColumn("hasHeightForWidth"); + QTest::newRow("null") << 0 << qreal(0.0) << false; + QTest::newRow("10") << 0 << qreal(10.0) << false; + QTest::newRow("null, hasHeightForWidth") << 0 << qreal(0.0) << true; + QTest::newRow("10, hasHeightForWidth") << 0 << qreal(10.0) << true; } // public void setColumnSpacing(int column, qreal spacing) @@ -1318,6 +1443,7 @@ void tst_QGraphicsGridLayout::setColumnSpacing() { QFETCH(int, column); QFETCH(qreal, spacing); + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); @@ -1325,7 +1451,7 @@ void tst_QGraphicsGridLayout::setColumnSpacing() QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 3, 2); + populateLayout(layout, 3, 2, hasHeightForWidth); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); qreal oldSpacing = layout->columnSpacing(column); @@ -1362,9 +1488,12 @@ void tst_QGraphicsGridLayout::setRowSpacing_data() { QTest::addColumn("row"); QTest::addColumn("spacing"); - QTest::newRow("null") << 0 << qreal(0.0); - QTest::newRow("10") << 0 << qreal(10.0); + QTest::addColumn("hasHeightForWidth"); + QTest::newRow("null") << 0 << qreal(0.0) << false; + QTest::newRow("10") << 0 << qreal(10.0) << false; + QTest::newRow("null, hasHeightForWidth") << 0 << qreal(0.0) << true; + QTest::newRow("10, hasHeightForWidth") << 0 << qreal(10.0) << true; } // public void setRowSpacing(int row, qreal spacing) @@ -1372,6 +1501,7 @@ void tst_QGraphicsGridLayout::setRowSpacing() { QFETCH(int, row); QFETCH(qreal, spacing); + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); @@ -1379,7 +1509,7 @@ void tst_QGraphicsGridLayout::setRowSpacing() QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 3, 2); + populateLayout(layout, 3, 2, hasHeightForWidth); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); qreal oldSpacing = layout->rowSpacing(row); @@ -1393,21 +1523,25 @@ void tst_QGraphicsGridLayout::setRowSpacing() void tst_QGraphicsGridLayout::setSpacing_data() { QTest::addColumn("spacing"); - QTest::newRow("zero") << qreal(0.0); - QTest::newRow("17") << qreal(17.0); + QTest::addColumn("hasHeightForWidth"); + QTest::newRow("zero") << qreal(0.0) << false; + QTest::newRow("17") << qreal(17.0) << false; + QTest::newRow("zero, hasHeightForWidth") << qreal(0.0) << true; + QTest::newRow("17, hasHeightForWidth") << qreal(17.0) << true; } // public void setSpacing(qreal spacing) void tst_QGraphicsGridLayout::setSpacing() { QFETCH(qreal, spacing); + QFETCH(bool, hasHeightForWidth); QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); scene.addItem(widget); widget->setLayout(layout); - populateLayout(layout, 3, 2); + populateLayout(layout, 3, 2, hasHeightForWidth); layout->setContentsMargins(0, 0, 0, 0); QSizeF sh = layout->sizeHint(Qt::PreferredSize, QSizeF()); qreal oldVSpacing = layout->verticalSpacing(); @@ -1538,8 +1672,18 @@ void tst_QGraphicsGridLayout::verticalSpacing() delete widget; } +void tst_QGraphicsGridLayout::layoutDirection_data() +{ + QTest::addColumn("hasHeightForWidth"); + + QTest::newRow("") << false; + QTest::newRow("hasHeightForWidth") << true; +} + void tst_QGraphicsGridLayout::layoutDirection() { + QFETCH(bool, hasHeightForWidth); + QGraphicsScene scene; QGraphicsView view(&scene); @@ -1562,6 +1706,12 @@ void tst_QGraphicsGridLayout::layoutDirection() w4->setMinimumSize(30, 20); layout->addItem(w4, 1, 1); + QSizePolicy policy = w1->sizePolicy(); + policy.setHeightForWidth(hasHeightForWidth); + w1->setSizePolicy(policy); + w2->setSizePolicy(policy); + w4->setSizePolicy(policy); + layout->setAlignment(w2, Qt::AlignRight); layout->setAlignment(w3, Qt::AlignLeft); @@ -2200,9 +2350,9 @@ void tst_QGraphicsGridLayout::geometries_data() .preferredSize(QSizeF(50,10)) .maxSize(QSizeF(100, 100)) << ItemDesc(1,1) - .minSize(QSizeF(40,40)) - .preferredSize(QSizeF(50,400)) - .maxSize(QSizeF(500, 500)) + .minSize(QSizeF(40,-1)) + .preferredSize(QSizeF(50,-1)) + .maxSize(QSizeF(500, -1)) .heightForWidth(hfw1) ) << QSizeF(100, 401) @@ -2211,32 +2361,6 @@ 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) - .minSize(QSizeF(40,40)) - .preferredSize(QSizeF(50,400)) - .maxSize(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)) @@ -2262,109 +2386,6 @@ 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) - .minSize(QSizeF(40,40)) - .preferredSize(QSizeF(50,400)) - .maxSize(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) - .minSize(QSizeF(40,40)) - .preferredSize(QSizeF(50,400)) - .maxSize(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) - .minSize(QSizeF(40,40)) - .preferredSize(QSizeF(50,400)) - .maxSize(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) - .minSize(QSizeF(40,40)) - .preferredSize(QSizeF(50,400)) - .maxSize(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) - ); - } void tst_QGraphicsGridLayout::geometries() -- cgit v0.12