diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-04-14 14:55:44 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-06-01 09:35:29 +0000 |
commit | a24b90a21c4f2feb61630ca6a1684312556a6bc7 (patch) | |
tree | 1717ed9f699dd5cb119471ccb51f661b7d207f8b /src/gui/util | |
parent | d11abc8bd7ac10da4bfd548b3d1d9d4e0dd6a264 (diff) |
Gui: use const (and const APIs) more
For CoW types, prefer const methods to avoid needless detach()ing.
Change-Id: I88d08d499e1be72c1f6d983fecdcee513df18aa2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/gui/util')
-rw-r--r-- | src/gui/util/qgridlayoutengine.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 20bc7166ab..8ff2a3eeec 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -218,8 +218,9 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz qreal sumAvailable; for (int i = 0; i < n; ++i) { - if (stretches[start + i] > 0) - sumStretches += stretches[start + i]; + const int stretch = stretches.at(start + i); + if (stretch > 0) + sumStretches += stretch; } if (targetSize < totalBox.q_preferredSize) { @@ -1034,19 +1035,19 @@ void QGridLayoutEngine::setGeometries(const QRectF &contentsGeometry, const QAbs for (int i = q_items.count() - 1; i >= 0; --i) { QGridLayoutItem *item = q_items.at(i); - qreal x = q_xx[item->firstColumn()]; - qreal y = q_yy[item->firstRow()]; - qreal width = q_widths[item->lastColumn()]; - qreal height = q_heights[item->lastRow()]; + qreal x = q_xx.at(item->firstColumn()); + qreal y = q_yy.at(item->firstRow()); + qreal width = q_widths.at(item->lastColumn()); + qreal height = q_heights.at(item->lastRow()); if (item->columnSpan() != 1) - width += q_xx[item->lastColumn()] - x; + width += q_xx.at(item->lastColumn()) - x; if (item->rowSpan() != 1) - height += q_yy[item->lastRow()] - y; + height += q_yy.at(item->lastRow()) - y; const Qt::Alignment align = effectiveAlignment(item); QRectF geom = item->geometryWithin(contentsGeometry.x() + x, contentsGeometry.y() + y, - width, height, q_descents[item->lastRow()], align, m_snapToPixelGrid); + width, height, q_descents.at(item->lastRow()), align, m_snapToPixelGrid); if (m_snapToPixelGrid) { // x and y should already be rounded, but the call to geometryWithin() above might // result in a geom with x,y at half-pixels (due to centering within the cell) |