diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2014-01-15 15:29:50 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-18 04:39:21 +0100 |
commit | 556c3209e2067664d6774ac049000d2aa05f5d85 (patch) | |
tree | 7ad66296d402ea923ee4b6336273893c8964139d /src/gui/util/qgridlayoutengine.cpp | |
parent | 603eac2dfbd14e05a810873c1417aa8dcfa246b4 (diff) |
Improve caching in ensureColumnAndRowData()
Change-Id: I02d9f818f8e1d6fcb8c25d1b73c08171cfc1f74d
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/gui/util/qgridlayoutengine.cpp')
-rw-r--r-- | src/gui/util/qgridlayoutengine.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index d22dcfb8e9..be38e92f21 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -985,6 +985,8 @@ void QGridLayoutEngine::invalidate() q_cachedEffectiveLastRows[Hor] = -1; q_cachedEffectiveLastRows[Ver] = -1; q_totalBoxesValid = false; + q_sizeHintValid[Hor] = false; + q_sizeHintValid[Ver] = false; q_cachedSize = QSizeF(); q_cachedConstraintOrientation = UnknownConstraint; } @@ -1528,12 +1530,22 @@ void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGri Qt::Orientation orientation, const QAbstractLayoutStyleInfo *styleInfo) const { + const int o = (orientation == Qt::Vertical ? Ver : Hor); + if (q_sizeHintValid[o] && !colPositions && !colSizes) { + if (totalBox != &q_totalBoxes[o]) + *totalBox = q_totalBoxes[o]; + return; + } rowData->reset(rowCount(orientation)); fillRowData(rowData, colPositions, colSizes, orientation, styleInfo); 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 + + if (!colPositions && !colSizes) { + q_totalBoxes[o] = *totalBox; + q_sizeHintValid[o] = true; + } } /** |