44 #ifndef QT_NO_GRAPHICSVIEW 54 #include <QtCore/qmath.h> 61 int count = items.
count();
64 items.
insert(index, delta, T());
65 }
else if (delta < 0) {
66 items.
remove(index,
qMin(-delta, count - index));
74 return desired *
qPow(sumAvailable / sumDesired, desired / sumDesired);
84 Q_ASSERT(targetSize >= ascent + descent);
86 qreal extra = targetSize - (ascent + descent);
87 return descent + (extra /
qreal(2.0));
151 for (
int i = 0; i <
NSizes; ++i) {
161 ignore.fill(
false, count);
163 multiCellMap.clear();
164 stretches.fill(0, count);
165 spacings.fill(0.0, count);
166 hasIgnoreFlag =
false;
172 for (; i != multiCellMap.constEnd(); ++i) {
173 int start = i.key().first;
174 int span = i.key().second;
175 int end = start + span;
177 int stretch = i.value().q_stretch;
184 for (
int j = 0; j <
NSizes; ++j) {
187 calculateGeometries(start, end, box.
q_sizes(j), dummy.
data(), newSizes.
data(),
188 0, totalBox, rowInfo);
190 for (
int k = 0; k < span; ++k)
191 extras[k].
q_sizes(j) = newSizes[k];
195 for (
int k = 0; k < span; ++k) {
196 boxes[start + k].combine(extras[k]);
198 stretches[start + k] =
qMax(stretches[start + k], stretch);
201 multiCellMap.clear();
216 qreal sumFactors = 0.0;
217 int sumStretches = 0;
220 for (
int i = 0; i < n; ++i) {
221 if (stretches[start + i] > 0)
222 sumStretches += stretches[start + i];
226 stealBox(start, end,
MinimumSize, positions, sizes);
229 if (sumAvailable > 0.0) {
232 for (
int i = 0; i < n; ++i) {
233 if (
ignore.testBit(start + i)) {
241 sumFactors += factors[i];
244 for (
int i = 0; i < n; ++i) {
246 qreal delta = sumAvailable * factors[i] / sumFactors;
247 newSizes[i] = sizes[i] + delta;
251 bool isLargerThanMaximum = (targetSize > totalBox.
q_maximumSize);
252 if (isLargerThanMaximum) {
253 stealBox(start, end,
MaximumSize, positions, sizes);
260 if (sumAvailable > 0.0) {
261 qreal sumCurrentAvailable = sumAvailable;
262 bool somethingHasAMaximumSize =
false;
264 qreal sumSizes = 0.0;
265 for (
int i = 0; i < n; ++i)
266 sumSizes += sizes[i];
268 for (
int i = 0; i < n; ++i) {
269 if (
ignore.testBit(start + i)) {
279 if (isLargerThanMaximum) {
286 if (desired == 0.0) {
287 newSizes[i] = sizes[i];
292 int stretch = stretches[start + i];
293 if (sumStretches == 0) {
295 factors[i] = (stretch < 0) ?
qreal(1.0) :
qreal(0.0);
297 factors[i] = (stretch < 0) ? sizes[i] :
qreal(0.0);
299 }
else if (stretch == sumStretches) {
301 }
else if (stretch <= 0) {
305 qreal ultimateSumSizes;
306 qreal x = ((stretch * sumSizes)
307 - (sumStretches * boxSize))
308 / (sumStretches - stretch);
310 ultimateSize = boxSize + x;
311 ultimateSumSizes = sumSizes + x;
313 ultimateSize = boxSize;
314 ultimateSumSizes = (sumStretches * boxSize)
323 ultimateSize = ultimateSize * 3 / 2;
324 ultimateSumSizes = ultimateSumSizes * 3 / 2;
326 qreal beta = ultimateSumSizes - sumSizes;
330 qreal alpha =
qMin(sumCurrentAvailable, beta);
331 qreal ultimateFactor = (stretch * ultimateSumSizes / sumStretches)
333 qreal transitionalFactor = sumCurrentAvailable * (ultimateSize - boxSize) / beta;
335 factors[i] = ((alpha * ultimateFactor)
336 + ((beta - alpha) * transitionalFactor)) / beta;
340 sumFactors += factors[i];
341 if (desired < sumCurrentAvailable)
342 somethingHasAMaximumSize =
true;
348 bool keepGoing = somethingHasAMaximumSize;
352 for (
int i = 0; i < n; ++i) {
353 if (newSizes[i] >= 0.0)
357 if (isLargerThanMaximum)
360 maxBoxSize = boxes.at(start + i).q_maximumSize;
362 qreal avail = sumCurrentAvailable * factors[i] / sumFactors;
363 if (sizes[i] + avail >= maxBoxSize) {
364 newSizes[i] = maxBoxSize;
365 sumCurrentAvailable -= maxBoxSize - sizes[i];
366 sumFactors -= factors[i];
367 keepGoing = (sumCurrentAvailable > 0.0);
374 for (
int i = 0; i < n; ++i) {
375 if (newSizes[i] < 0.0) {
376 qreal delta = (sumFactors == 0.0) ?
qreal(0.0)
377 : sumCurrentAvailable * factors[i] / sumFactors;
378 newSizes[i] = sizes[i] + delta;
384 if (sumAvailable > 0) {
386 for (
int i = 0; i < n; ++i) {
387 qreal delta = newSizes[i] - sizes[i];
388 positions[i] += offset;
393 #if 0 // some "pixel allocation" 394 int surplus = targetSize - (positions[n - 1] + sizes[n - 1]);
395 Q_ASSERT(surplus >= 0 && surplus <= n);
397 int prevSurplus = -1;
398 while (surplus > 0 && surplus != prevSurplus) {
399 prevSurplus = surplus;
402 for (
int i = 0; i < n; ++i) {
404 int delta = (!
ignore.testBit(start + i) && surplus > 0
408 positions[i] += offset;
419 for (
int i = 0; i < n; ++i) {
420 if (
ignore.testBit(start + i))
433 qreal nextSpacing = 0.0;
434 for (
int i = start; i <
end; ++i) {
437 result.
add(boxes.at(i), stretches.at(i), nextSpacing);
438 nextSpacing = spacings.at(i);
447 qreal nextSpacing = 0.0;
449 for (
int i = start; i <
end; ++i) {
455 offset += nextSpacing;
456 nextSpacing = spacings.at(i);
459 *positions++ = offset;
468 qDebug(
"%*sData", indent,
"");
470 for (
int i = 0; i <
ignore.count(); ++i) {
471 qDebug(
"%*s Row %d (stretch %d, spacing %g)", indent,
"", i, stretches.at(i),
474 qDebug(
"%*s Ignored", indent,
"");
475 boxes.at(i).dump(indent + 2);
479 while (it != multiCellMap.constEnd()) {
480 qDebug(
"%*s Multi-cell entry <%d, %d> (stretch %d)", indent,
"", it.key().first,
481 it.key().second, it.value().q_stretch);
482 it.value().q_box.dump(indent + 2);
488 int row,
int column,
int rowSpan,
int columnSpan,
489 Qt::Alignment alignment,
int itemAtIndex)
490 : q_engine(engine), q_layoutItem(layoutItem), q_alignment(alignment)
606 QSizeF constraintSize(-1.0, constraint);
622 QSizeF constraintSize(constraint, -1.0);
649 qreal rowDescent)
const 655 qreal cellWidth = width;
656 qreal cellHeight = height;
662 if (size.
width() > cellWidth)
664 }
else if (size.
height() > cellHeight) {
669 width = size.
width();
675 x += (cellWidth - width)/2;
678 x += cellWidth - width;
685 y += (cellHeight - height)/2;
688 y += cellHeight - height;
693 return QRectF(x, y, width, height);
697 return QRectF(x, y + height - rowDescent - ascent, width, ascent + descent);
715 int oldFirstRow =
firstRow(orientation);
716 if (oldFirstRow >= row) {
718 }
else if (
lastRow(orientation) >= row) {
735 if (!vGrow || !hGrow) {
745 if (size.
width() == -1)
765 qDebug(
"%*s Horizontal size policy: %x Vertical size policy: %x",
783 qDebug(
"%*sInfo (count: %d)", indent,
"", count);
784 for (
int i = 0; i < count; ++i) {
787 if (stretches.value(i).value() >= 0)
789 if (spacings.value(i).value() >= 0.0)
791 if (alignments.value(i) != 0)
797 boxes.value(i).dump(indent + 1);
821 return q_items.count();
826 Q_ASSERT(index >= 0 && index < itemCount());
827 return q_items.at(index);
832 for (
int i = 0; i < q_items.size(); ++i) {
833 if (item == q_items.at(i)->layoutItem())
841 ensureEffectiveFirstAndLastRows();
842 return q_cachedEffectiveFirstRows[orientation ==
Qt::Vertical];
847 ensureEffectiveFirstAndLastRows();
848 return q_cachedEffectiveLastRows[orientation ==
Qt::Vertical];
855 q_defaultSpacings[
Hor].setUserValue(spacing);
857 q_defaultSpacings[
Ver].setUserValue(spacing);
864 if (q_defaultSpacings[orientation ==
Qt::Vertical].isDefault()) {
870 q_defaultSpacings[orientation ==
Qt::Vertical].setCachedValue(defaultSpacing);
872 return q_defaultSpacings[orientation ==
Qt::Vertical].value();
883 rowInfo.
spacings[row].setUserValue(spacing);
893 return spacing.
value();
894 return q_defaultSpacings[orientation ==
Qt::Vertical].value();
902 maybeExpandGrid(row, -1, orientation);
907 rowInfo.
stretches[row].setUserValue(stretch);
914 return stretch.
value();
924 item->setStretchFactor(stretch, orientation);
930 return item->stretchFactor(orientation);
940 maybeExpandGrid(row, -1, orientation);
945 rowInfo.
boxes[row].q_sizes(which) = size;
950 return q_infos[orientation ==
Qt::Vertical].boxes.value(row).q_sizes(which);
958 maybeExpandGrid(row, -1, orientation);
969 return q_infos[orientation ==
Qt::Vertical].alignments.value(row);
975 item->setAlignment(alignment);
982 return item->alignment();
988 Qt::Alignment align = layoutItem->
alignment();
1016 q_items.append(item);
1018 q_items.insert(index, item);
1023 qWarning(
"QGridLayoutEngine::addItem: Cell (%d, %d) already taken", i, j);
1024 setItemAt(i, j, item);
1031 insertItem(item, -1);
1042 if (itemAt(i, j) == item)
1047 q_items.removeAll(item);
1052 for (
int i = q_items.count() - 1; i >= 0; --i) {
1066 return q_grid.at((row * internalGridColumnCount()) + column);
1071 q_cachedEffectiveFirstRows[
Hor] = -1;
1072 q_cachedEffectiveFirstRows[
Ver] = -1;
1073 q_cachedEffectiveLastRows[
Hor] = -1;
1074 q_cachedEffectiveLastRows[
Ver] = -1;
1075 q_cachedDataForStyleInfo.invalidate();
1087 const QRectF &contentsGeometry)
1089 if (rowCount() < 1 || columnCount() < 1)
1092 ensureGeometries(styleInfo, contentsGeometry.
size());
1094 for (
int i = q_items.count() - 1; i >= 0; --i) {
1105 height += q_yy[item->
lastRow()] - y;
1108 width, height, q_descents[item->
lastRow()]);
1109 visualRect(&geom, visualDirection(), contentsGeometry);
1116 const QRectF &contentsGeometry,
int row,
int column,
int rowSpan,
1120 || rowSpan < 1 || columnSpan < 1)
1123 ensureGeometries(styleInfo, contentsGeometry.
size());
1126 int lastRow =
qMax(row + rowSpan, rowCount()) - 1;
1128 qreal x = q_xx[column];
1129 qreal y = q_yy[row];
1133 if (columnSpan != 1)
1138 return QRectF(contentsGeometry.
x() + x, contentsGeometry.
y() + y, width, height);
1142 const QSizeF &constraint)
const 1146 bool sizeHintCalculated =
false;
1151 if (constraint.
width() >= 0) {
1152 if (q_cachedDataForStyleInfo != styleInfo)
1153 ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[
Hor], styleInfo, NULL, NULL,
Qt::Horizontal);
1155 sizehint_totalBoxes[
Hor] = q_totalBoxes[
Hor];
1159 sizehint_xx.
resize(columnCount());
1160 sizehint_widths.
resize(columnCount());
1164 q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.
data(), sizehint_widths.
data(),
1165 0, sizehint_totalBoxes[
Hor], q_infos[
Hor]);
1166 ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[
Ver], styleInfo, sizehint_xx.
data(), sizehint_widths.
data(),
Qt::Vertical);
1167 sizeHintCalculated =
true;
1170 if (constraint.
height() >= 0) {
1172 ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[
Ver], styleInfo, NULL, NULL,
Qt::Vertical);
1176 sizehint_yy.
resize(rowCount());
1177 sizehint_heights.
resize(rowCount());
1181 q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.
data(), sizehint_heights.
data(),
1182 0, sizehint_totalBoxes[
Ver], q_infos[
Ver]);
1183 ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[
Hor], styleInfo, sizehint_yy.
data(), sizehint_heights.
data(),
Qt::Horizontal);
1184 sizeHintCalculated =
true;
1189 if (!sizeHintCalculated) {
1191 if (q_cachedDataForStyleInfo != styleInfo) {
1192 ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[
Hor], styleInfo, NULL, NULL,
Qt::Horizontal);
1193 ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[
Ver], styleInfo, NULL, NULL,
Qt::Vertical);
1195 sizehint_totalBoxes[
Hor] = q_totalBoxes[
Hor];
1196 sizehint_totalBoxes[
Ver] = q_totalBoxes[
Ver];
1202 return QSizeF(sizehint_totalBoxes[
Hor].q_minimumSize, sizehint_totalBoxes[
Ver].q_minimumSize);
1204 return QSizeF(sizehint_totalBoxes[
Hor].q_preferredSize, sizehint_totalBoxes[
Ver].q_preferredSize);
1206 return QSizeF(sizehint_totalBoxes[
Hor].q_maximumSize, sizehint_totalBoxes[
Ver].q_maximumSize);
1208 return QSizeF(-1.0, sizehint_totalBoxes[
Hor].q_minimumDescent);
1218 int row = (side ==
Top || side ==
Left) ? effectiveFirstRow(orientation)
1219 : effectiveLastRow(orientation);
1220 QSizePolicy::ControlTypes result = 0;
1222 for (
int column = columnCount(orientation) - 1; column >= 0; --column) {
1224 result |= item->controlTypes(side);
1233 for (
int i = q_items.count() - 1; i >= 0; --i)
1234 q_items.at(i)->transpose();
1236 qSwap(q_defaultSpacings[
Hor], q_defaultSpacings[
Ver]);
1237 qSwap(q_infos[Hor], q_infos[Ver]);
1249 return m_visualDirection;
1255 qDebug(
"%*sEngine", indent,
"");
1257 qDebug(
"%*s Items (%d)", indent,
"", q_items.count());
1259 for (i = 0; i < q_items.count(); ++i)
1260 q_items.at(i)->dump(indent + 2);
1262 qDebug(
"%*s Grid (%d x %d)", indent,
"", internalGridRowCount(),
1263 internalGridColumnCount());
1264 for (
int row = 0; row < internalGridRowCount(); ++row) {
1266 for (
int column = 0; column < internalGridColumnCount(); ++column) {
1267 message +=
QString::number(q_items.indexOf(itemAt(row, column))).rightJustified(3);
1274 if (q_defaultSpacings[
Hor].value() >= 0.0 || q_defaultSpacings[
Ver].value() >= 0.0)
1275 qDebug(
"%*s Default spacings: %g %g", indent,
"", q_defaultSpacings[
Hor].value(),
1276 q_defaultSpacings[
Ver].value());
1278 qDebug(
"%*s Column and row info", indent,
"");
1279 q_infos[
Hor].dump(indent + 2);
1280 q_infos[
Ver].dump(indent + 2);
1282 qDebug(
"%*s Column and row data", indent,
"");
1283 q_columnData.dump(indent + 2);
1284 q_rowData.dump(indent + 2);
1286 qDebug(
"%*s Geometries output", indent,
"");
1288 for (
int pass = 0; pass < 2; ++pass) {
1290 for (i = 0; i < cellPos->
count(); ++i) {
1295 qDebug(
"%*s %s %s", indent,
"", (pass == 0 ?
"rows:" :
"columns:"),
qPrintable(message));
1308 if (row < rowCount() && column < columnCount())
1311 int oldGridRowCount = internalGridRowCount();
1312 int oldGridColumnCount = internalGridColumnCount();
1314 q_infos[
Ver].count =
qMax(row + 1, rowCount());
1315 q_infos[
Hor].count =
qMax(column + 1, columnCount());
1317 int newGridRowCount = internalGridRowCount();
1318 int newGridColumnCount = internalGridColumnCount();
1320 int newGridSize = newGridRowCount * newGridColumnCount;
1321 if (newGridSize != q_grid.count()) {
1322 q_grid.resize(newGridSize);
1324 if (newGridColumnCount != oldGridColumnCount) {
1325 for (
int i = oldGridRowCount - 1; i >= 1; --i) {
1326 for (
int j = oldGridColumnCount - 1; j >= 0; --j) {
1327 int oldIndex = (i * oldGridColumnCount) + j;
1328 int newIndex = (i * newGridColumnCount) + j;
1331 q_grid[newIndex] = q_grid[oldIndex];
1332 q_grid[oldIndex] = 0;
1343 for (
int i = q_items.count() - 1; i >= 0; --i) {
1348 setItemAt(j, k, item);
1356 Q_ASSERT(row >= 0 && row < rowCount());
1357 Q_ASSERT(column >= 0 && column < columnCount());
1358 q_grid[(row * internalGridColumnCount()) + column] = item;
1363 int oldRowCount = rowCount(orientation);
1369 if (row == oldRowCount && delta > 0) {
1370 maybeExpandGrid(oldRowCount + delta - 1, -1, orientation);
1374 q_infos[orientation ==
Qt::Vertical].insertOrRemoveRows(row, delta);
1376 for (
int i = q_items.count() - 1; i >= 0; --i)
1377 q_items.at(i)->insertOrRemoveRows(row, delta, orientation);
1379 q_grid.resize(internalGridRowCount() * internalGridColumnCount());
1398 qreal innerSpacing = 0.0;
1402 &option, styleInfo.
widget());
1403 if (innerSpacing >= 0.0)
1406 for (
int row = 0; row < rowInfo.
count; ++row) {
1407 bool rowIsEmpty =
true;
1408 bool rowIsIdenticalToPrevious = (row > 0);
1410 for (
int column = 0; column < columnInfo.
count; ++column) {
1413 if (rowIsIdenticalToPrevious && item != itemAt(row - 1, column, orientation))
1414 rowIsIdenticalToPrevious =
false;
1420 if ((rowIsEmpty || rowIsIdenticalToPrevious)
1428 }
else if (!defaultSpacing.
isDefault()) {
1435 struct RowAdHocData {
1437 unsigned int q_hasButtons : 8;
1438 unsigned int q_hasNonButtons : 8;
1440 inline RowAdHocData() : q_row(-1), q_hasButtons(
false), q_hasNonButtons(
false) {}
1441 inline void init(
int row) {
1443 q_hasButtons =
false;
1444 q_hasNonButtons =
false;
1446 inline bool hasOnlyButtons()
const {
return q_hasButtons && !q_hasNonButtons; }
1447 inline bool hasOnlyNonButtons()
const {
return q_hasNonButtons && !q_hasButtons; }
1449 RowAdHocData lastRowAdHocData;
1450 RowAdHocData nextToLastRowAdHocData;
1451 RowAdHocData nextToNextToLastRowAdHocData;
1454 for (
int row = 0; row < rowInfo.
count; ++row) {
1460 nextToNextToLastRowAdHocData = nextToLastRowAdHocData;
1461 nextToLastRowAdHocData = lastRowAdHocData;
1462 lastRowAdHocData.init(row);
1466 int &rowStretch = rowData->
stretches[row];
1468 bool hasIgnoreFlag =
true;
1469 for (
int column = 0; column < columnInfo.
count; ++column) {
1472 int itemRow = item->
firstRow(orientation);
1475 if (itemRow == row && itemColumn == column) {
1478 hasIgnoreFlag =
false;
1479 int itemRowSpan = item->
rowSpan(orientation);
1481 int effectiveRowSpan = 1;
1482 for (
int i = 1; i < itemRowSpan; ++i) {
1488 if (effectiveRowSpan == 1) {
1490 if (!userRowStretch && itemStretch != 0)
1491 rowStretch =
qMax(rowStretch, itemStretch);
1495 box = &multiCell.
q_box;
1508 length += colPositions[item->
lastColumn(orientation)] - colPositions[item->
firstColumn(orientation)];
1509 box->
combine(item->
box(orientation, length));
1514 if (effectiveRowSpan == 1) {
1515 QSizePolicy::ControlTypes controls = item->
controlTypes(top);
1516 if (controls & ButtonMask)
1517 lastRowAdHocData.q_hasButtons =
true;
1518 if (controls & ~ButtonMask)
1519 lastRowAdHocData.q_hasNonButtons =
true;
1543 bool lastRowIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
1544 && nextToLastRowAdHocData.hasOnlyNonButtons());
1545 bool lastTwoRowsIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
1546 && nextToLastRowAdHocData.hasOnlyButtons()
1547 && nextToNextToLastRowAdHocData.hasOnlyNonButtons()
1552 for (
int row = 0; row < rowInfo.
count; ++row) {
1558 for (
int column = 0; column < columnInfo.
count; ++column) {
1562 if (item1 && item2 && item1 != item2) {
1563 QSizePolicy::ControlTypes controls1 = item1->
controlTypes(bottom);
1564 QSizePolicy::ControlTypes controls2 = item2->
controlTypes(top);
1567 if ((row == nextToLastRowAdHocData.q_row && lastTwoRowsIsButtonBox)
1568 || (row == lastRowAdHocData.q_row && lastRowIsButtonBox)) {
1575 orientation, &option,
1582 spacing -= (width1 - (rect1.
x() + rect1.
width())) + rect2.
x();
1596 spacing -= (height1 - (rect1.
y() + rect1.
height())) + rect2.
y();
1598 rowSpacing =
qMax(spacing, rowSpacing);
1604 }
else if (lastRowIsButtonBox || lastTwoRowsIsButtonBox) {
1610 int prevRow = lastRowIsButtonBox ? nextToLastRowAdHocData.q_row
1611 : nextToNextToLastRowAdHocData.q_row;
1616 &option, styleInfo.
widget());
1619 rowSpacing =
qMax(windowMargin, rowSpacing);
1626 if (q_cachedEffectiveFirstRows[
Hor] == -1 && !q_items.isEmpty()) {
1627 int rowCount = this->rowCount();
1628 int columnCount = this->columnCount();
1630 q_cachedEffectiveFirstRows[
Ver] = rowCount;
1631 q_cachedEffectiveFirstRows[
Hor] = columnCount;
1632 q_cachedEffectiveLastRows[
Ver] = -1;
1633 q_cachedEffectiveLastRows[
Hor] = -1;
1635 for (
int i = q_items.count() - 1; i >= 0; --i) {
1640 if (item->
firstRow(orientation) < q_cachedEffectiveFirstRows[j])
1641 q_cachedEffectiveFirstRows[j] = item->
firstRow(orientation);
1642 if (item->
lastRow(orientation) > q_cachedEffectiveLastRows[j])
1643 q_cachedEffectiveLastRows[j] = item->
lastRow(orientation);
1654 rowData->
reset(rowCount(orientation));
1655 fillRowData(rowData, styleInfo, colPositions, colSizes, orientation);
1658 *totalBox = rowData->
totalBox(0, rowCount(orientation));
1669 for (
int i = q_items.count() - 1; i >= 0; --i) {
1674 q_cachedConstraintOrientation = itemConstraintOrientation;
1675 }
else if (q_cachedConstraintOrientation != itemConstraintOrientation) {
1677 qWarning(
"QGridLayoutEngine: Unfeasible, cannot mix horizontal and" 1678 " vertical constraint in the same layout");
1691 if (!ensureDynamicConstraint())
1701 (void)ensureDynamicConstraint();
1706 const QSizeF &size)
const 1708 if (q_cachedDataForStyleInfo == styleInfo && q_cachedSize == size)
1711 q_cachedDataForStyleInfo = styleInfo;
1712 q_cachedSize = size;
1714 q_xx.resize(columnCount());
1715 q_widths.resize(columnCount());
1716 q_yy.resize(rowCount());
1717 q_heights.resize(rowCount());
1718 q_descents.resize(rowCount());
1722 ensureColumnAndRowData(&q_columnData, &q_totalBoxes[
Hor], styleInfo, NULL, NULL,
Qt::Horizontal);
1725 q_columnData.calculateGeometries(0, columnCount(), size.
width(), q_xx.data(), q_widths.data(),
1726 0, q_totalBoxes[
Hor], q_infos[
Hor] );
1727 ensureColumnAndRowData(&q_rowData, &q_totalBoxes[
Ver], styleInfo, q_xx.data(), q_widths.data(),
Qt::Vertical);
1729 q_rowData.calculateGeometries(0, rowCount(), size.
height(), q_yy.data(), q_heights.data(),
1730 q_descents.data(), q_totalBoxes[
Ver], q_infos[
Ver]);
1733 ensureColumnAndRowData(&q_rowData, &q_totalBoxes[
Ver], styleInfo, NULL, NULL,
Qt::Vertical);
1736 q_rowData.calculateGeometries(0, rowCount(), size.
height(), q_yy.data(), q_heights.data(),
1737 q_descents.data(), q_totalBoxes[
Ver], q_infos[
Ver]);
1738 ensureColumnAndRowData(&q_columnData, &q_totalBoxes[
Hor], styleInfo, q_yy.data(), q_heights.data(),
Qt::Horizontal);
1740 q_columnData.calculateGeometries(0, columnCount(), size.
width(), q_xx.data(), q_widths.data(),
1741 0, q_totalBoxes[
Hor], q_infos[
Hor]);
1747 #endif //QT_NO_GRAPHICSVIEW static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
int q_firstRows[NOrientations]
QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Returns the effective size hint for this QGraphicsLayoutItem.
virtual void setGeometry(const QRectF &rect)
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...
void setCachedValue(T value) const
qreal y() const
Returns the y-coordinate of the rectangle's top edge.
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
void addItem(QGridLayoutItem *item)
static QGraphicsLayoutItemPrivate * get(QGraphicsLayoutItem *q)
void setRowStretchFactor(int row, int stretch, Qt::Orientation orientation=Qt::Vertical)
Qt::Alignment effectiveAlignment(const QGridLayoutItem *layoutItem) const
void setSpacing(qreal spacing, Qt::Orientations orientations)
QGridLayoutEngine * q_engine
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
void setBit(int i)
Sets the bit at index position i to 1.
Qt::Orientation dynamicConstraintOrientation() const
#define QT_END_NAMESPACE
This macro expands to.
void distributeMultiCells(const QGridLayoutRowInfo &rowInfo)
bool ensureDynamicConstraint() const
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
void fillRowData(QGridLayoutRowData *rowData, const QLayoutStyleInfo &styleInfo, qreal *colPositions, qreal *colSizes, Qt::Orientation orientation=Qt::Vertical) const
void setGeometry(const QRectF &rect)
void remove(int i)
Removes the element at index position i.
void removeItem(QGridLayoutItem *item)
int effectiveFirstRow(Qt::Orientation orientation=Qt::Vertical) const
QStyle::State state
the style flags that are used when drawing the control
#define it(className, varName)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
void setRowSpan(int rowSpan, Qt::Orientation orientation=Qt::Vertical)
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
qreal width() const
Returns the width.
Qt::Alignment q_alignment
void dump(int indent=0) const
void ensureEffectiveFirstAndLastRows() const
qreal height() const
Returns the height.
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
bool hasHeightForWidth() const
static qreal growthFactorBelowPreferredSize(qreal desired, qreal sumAvailable, qreal sumDesired)
QGridLayoutItem(QGridLayoutEngine *engine, QGraphicsLayoutItem *layoutItem, int row, int column, int rowSpan=1, int columnSpan=1, Qt::Alignment alignment=0, int itemAtIndex=-1)
static bool ignore(const char *test, const char *const *table)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void insertOrRemoveRows(int row, int delta, Qt::Orientation orientation=Qt::Vertical)
void dump(int indent=0) const
The QString class provides a Unicode character string.
bool hasDynamicConstraint() const
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
void setWidth(qreal w)
Sets the width to the given width.
bool testBit(int i) const
Returns true if the bit at index position i is 1; otherwise returns false.
QSizeF sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHint which, const QSizeF &constraint) const
int effectiveLastRow(Qt::Orientation orientation=Qt::Vertical) const
void setRowSizeHint(Qt::SizeHint which, int row, qreal size, Qt::Orientation orientation=Qt::Vertical)
The QVector class is a template class that provides a dynamic array.
QSizePolicy::ControlTypes controlTypes(LayoutSide side) const
The QSizeF class defines the size of a two-dimensional object using floating point precision...
void setVisualDirection(Qt::LayoutDirection direction)
void ensureGeometries(const QLayoutStyleInfo &styleInfo, const QSizeF &size) const
QRectF geometryWithin(qreal x, qreal y, qreal width, qreal height, qreal rowDescent) const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
int rowStretchFactor(int row, Qt::Orientation orientation=Qt::Vertical) const
void resize(int size)
Sets the size of the vector to size.
Q_CORE_EXPORT void qDebug(const char *,...)
QVector< Qt::Alignment > alignments
void insertOrRemoveRows(int row, int delta)
#define QT_BEGIN_NAMESPACE
This macro expands to.
void setAlignment(QGraphicsLayoutItem *layoutItem, Qt::Alignment alignment)
The QRectF class defines a rectangle in the plane using floating point precision. ...
QSizePolicy::Policy sizePolicy(Qt::Orientation orientation) const
QVector< QGridLayoutBox > boxes
QVector< QStretchParameter > stretches
The QStyleOption class stores the parameters used by QStyle functions.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
T value(int i) const
Returns the value at index position i in the vector.
void initFrom(const QWidget *w)
qreal height() const
Returns the height of the rectangle.
Q_CORE_EXPORT void qWarning(const char *,...)
qreal spacing(const QLayoutStyleInfo &styleInfo, Qt::Orientation orientation) const
qreal width() const
Returns the width of the rectangle.
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts...
QGridLayoutBox totalBox(int start, int end) const
void add(const QGridLayoutBox &other, int stretch, qreal spacing)
QVector< QLayoutParameter< qreal > > spacings
Qt::Alignment alignment(QGraphicsLayoutItem *layoutItem) const
qreal qPow(qreal x, qreal y)
MultiCellMap multiCellMap
QGraphicsLayoutItem * layoutItem() const
void qSwap(T &value1, T &value2)
const T & at(int i) const
Returns the item at index position i in the vector.
static void insertOrRemoveItems(QVector< T > &items, int index, int delta)
QVector< qreal > spacings
void moveRight(qreal pos)
Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate...
void dump(int indent=0) const
void dump(int indent=0) const
void insert(int i, const T &t)
Inserts value at index position i in the vector.
QSizeF effectiveMaxSize(const QSizeF &constraint) const
bool hasDynamicConstraint() const
int q_rowSpans[NOrientations]
void ensureColumnAndRowData(QGridLayoutRowData *rowData, QGridLayoutBox *totalBox, const QLayoutStyleInfo &styleInfo, qreal *colPositions, qreal *colSizes, Qt::Orientation orientation) const
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
static qreal fixedDescent(qreal descent, qreal ascent, qreal targetSize)
void dump(int indent=0) const
QGridLayoutItem * itemAt(int index) const
int q_stretches[NOrientations]
bool hasWidthForHeight() const
QRectF cellRect(const QLayoutStyleInfo &styleInfo, const QRectF &contentsGeometry, int row, int column, int rowSpan, int columnSpan) const
qreal & q_sizes(int which)
QSizeF boundedTo(const QSizeF &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
qreal x() const
Returns the x-coordinate of the rectangle's left edge.
QSizePolicy sizePolicy() const
Returns the current size policy.
void setItemAt(int row, int column, QGridLayoutItem *item)
void setFirstRow(int row, Qt::Orientation orientation=Qt::Vertical)
void setStretchFactor(QGraphicsLayoutItem *layoutItem, int stretch, Qt::Orientation orientation)
Qt::Orientation constraintOrientation() const
void insertItem(QGridLayoutItem *item, int index)
The index is only used by QGraphicsLinearLayout to ensure that itemAt() reflects the order of visual ...
QGridLayoutBox box(Qt::Orientation orientation, qreal constraint=-1.0) const
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
bool operator==(const QGridLayoutBox &box1, const QGridLayoutBox &box2)
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
void setRowAlignment(int row, Qt::Alignment alignment, Qt::Orientation orientation)
void combine(const QGridLayoutBox &other)
QSizeF size() const
Returns the size of the rectangle.
void insertOrRemoveRows(int row, int delta, Qt::Orientation orientation=Qt::Vertical)
void stealBox(int start, int end, int which, qreal *positions, qreal *sizes)
Qt::Alignment alignment() const
void setHeight(qreal h)
Sets the height to the given height.
qreal rowSizeHint(Qt::SizeHint which, int row, Qt::Orientation orientation=Qt::Vertical) const
T * data()
Returns a pointer to the data stored in the vector.
Qt::LayoutDirection visualDirection() const
int stretchFactor(QGraphicsLayoutItem *layoutItem, Qt::Orientation orientation) const
QSizePolicy::ControlTypes controlTypes(LayoutSide side) const
void calculateGeometries(int start, int end, qreal targetSize, qreal *positions, qreal *sizes, qreal *descents, const QGridLayoutBox &totalBox, const QGridLayoutRowInfo &rowInfo)
QVector< QGridLayoutBox > boxes
void setRowSpacing(int row, qreal spacing, Qt::Orientation orientation=Qt::Vertical)
QGridLayoutItem * findLayoutItem(QGraphicsLayoutItem *layoutItem) const
qreal rowSpacing(int row, Qt::Orientation orientation=Qt::Vertical) const
static const KeyPair *const end
void maybeExpandGrid(int row, int column, Qt::Orientation orientation=Qt::Vertical)
#define qPrintable(string)
ControlType controlType() const
Qt::Alignment rowAlignment(int row, Qt::Orientation orientation) const
int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1, QSizePolicy::ControlTypes controls2, Qt::Orientation orientation, QStyleOption *option=0, QWidget *widget=0) const
Returns the spacing that should be used between controls1 and controls2 in a layout.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
int indexOf(QGraphicsLayoutItem *item) const
static qreal compare(const QGridLayoutBox &box1, const QGridLayoutBox &box2, int which)
void setGeometries(const QLayoutStyleInfo &styleInfo, const QRectF &contentsGeometry)
QGraphicsLayoutItem * q_layoutItem
int stretchFactor(Qt::Orientation orientation) const
friend class const_iterator
Qt::LayoutDirection direction
static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect)
void setStretchFactor(int stretch, Qt::Orientation orientation)