qgridlayout.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qgridlayout.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qgridlayout.h"-
35#include "qapplication.h"-
36#include "qwidget.h"-
37#include "qlist.h"-
38#include "qsizepolicy.h"-
39#include "qvector.h"-
40#include "qvarlengtharray.h"-
41#include "qlayoutengine_p.h"-
42#include "qlayout_p.h"-
43-
44QT_BEGIN_NAMESPACE-
45-
46struct QGridLayoutSizeTriple-
47{-
48 QSize minS;-
49 QSize hint;-
50 QSize maxS;-
51};-
52-
53/*-
54 Three internal classes related to QGridLayout: (1) QGridBox is a-
55 QLayoutItem with (row, column) information and (torow, tocolumn) information; (3) QGridLayoutData is-
56 the internal representation of a QGridLayout.-
57*/-
58-
59class QGridBox-
60{-
61public:-
62 QGridBox(QLayoutItem *lit) { item_ = lit; }
never executed: end of block
0
63-
64 QGridBox(const QLayout *l, QWidget *wid) { item_ = QLayoutPrivate::createWidgetItem(l, wid); }
never executed: end of block
0
65 ~QGridBox() { delete item_; }
never executed: end of block
0
66-
67 QSize sizeHint() const { return item_->sizeHint(); }
never executed: return item_->sizeHint();
0
68 QSize minimumSize() const { return item_->minimumSize(); }
never executed: return item_->minimumSize();
0
69 QSize maximumSize() const { return item_->maximumSize(); }
never executed: return item_->maximumSize();
0
70 Qt::Orientations expandingDirections() const { return item_->expandingDirections(); }
never executed: return item_->expandingDirections();
0
71 bool isEmpty() const { return item_->isEmpty(); }
never executed: return item_->isEmpty();
0
72-
73 bool hasHeightForWidth() const { return item_->hasHeightForWidth(); }
never executed: return item_->hasHeightForWidth();
0
74 int heightForWidth(int w) const { return item_->heightForWidth(w); }
never executed: return item_->heightForWidth(w);
0
75-
76 void setAlignment(Qt::Alignment a) { item_->setAlignment(a); }
never executed: end of block
0
77 void setGeometry(const QRect &r) { item_->setGeometry(r); }
never executed: end of block
0
78 Qt::Alignment alignment() const { return item_->alignment(); }
never executed: return item_->alignment();
0
79 QLayoutItem *item() { return item_; }
never executed: return item_;
0
80 void setItem(QLayoutItem *newitem) { item_ = newitem; }
never executed: end of block
0
81 QLayoutItem *takeItem() { QLayoutItem *i = item_; item_ = 0; return i; }
never executed: return i;
0
82-
83 int hStretch() { return item_->widget() ?
never executed: return item_->widget() ? item_->widget()->sizePolicy().horizontalStretch() : 0;
item_->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
84 item_->widget()->sizePolicy().horizontalStretch() : 0; }
never executed: return item_->widget() ? item_->widget()->sizePolicy().horizontalStretch() : 0;
0
85 int vStretch() { return item_->widget() ?
never executed: return item_->widget() ? item_->widget()->sizePolicy().verticalStretch() : 0;
item_->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
86 item_->widget()->sizePolicy().verticalStretch() : 0; }
never executed: return item_->widget() ? item_->widget()->sizePolicy().verticalStretch() : 0;
0
87-
88private:-
89 friend class QGridLayoutPrivate;-
90 friend class QGridLayout;-
91-
92 inline int toRow(int rr) const { return torow >= 0 ? torow : rr - 1; }
never executed: return torow >= 0 ? torow : rr - 1;
torow >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
93 inline int toCol(int cc) const { return tocol >= 0 ? tocol : cc - 1; }
never executed: return tocol >= 0 ? tocol : cc - 1;
tocol >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
94-
95 QLayoutItem *item_;-
96 int row, col;-
97 int torow, tocol;-
98};-
99-
100class QGridLayoutPrivate : public QLayoutPrivate-
101{-
102 Q_DECLARE_PUBLIC(QGridLayout)-
103public:-
104 QGridLayoutPrivate();-
105-
106 void add(QGridBox*, int row, int col);-
107 void add(QGridBox*, int row1, int row2, int col1, int col2);-
108 QSize sizeHint(int hSpacing, int vSpacing) const;-
109 QSize minimumSize(int hSpacing, int vSpacing) const;-
110 QSize maximumSize(int hSpacing, int vSpacing) const;-
111-
112 Qt::Orientations expandingDirections(int hSpacing, int vSpacing) const;-
113-
114 void distribute(QRect rect, int hSpacing, int vSpacing);-
115 inline int numRows() const { return rr; }
never executed: return rr;
0
116 inline int numCols() const { return cc; }
never executed: return cc;
0
117 inline void expand(int rows, int cols)-
118 { setSize(qMax(rows, rr), qMax(cols, cc)); }
never executed: end of block
0
119 inline void setRowStretch(int r, int s)-
120 { expand(r + 1, 0); rStretch[r] = s; setDirty(); }
never executed: end of block
0
121 inline void setColStretch(int c, int s)-
122 { expand(0, c + 1); cStretch[c] = s; setDirty(); }
never executed: end of block
0
123 inline int rowStretch(int r) const { return rStretch.at(r); }
never executed: return rStretch.at(r);
0
124 inline int colStretch(int c) const { return cStretch.at(c); }
never executed: return cStretch.at(c);
0
125 inline void setRowMinimumHeight(int r, int s)-
126 { expand(r + 1, 0); rMinHeights[r] = s; setDirty(); }
never executed: end of block
0
127 inline void setColumnMinimumWidth(int c, int s)-
128 { expand(0, c + 1); cMinWidths[c] = s; setDirty(); }
never executed: end of block
0
129 inline int rowSpacing(int r) const { return rMinHeights.at(r); }
never executed: return rMinHeights.at(r);
0
130 inline int colSpacing(int c) const { return cMinWidths.at(c); }
never executed: return cMinWidths.at(c);
0
131-
132 inline void setReversed(bool r, bool c) { hReversed = c; vReversed = r; }
never executed: end of block
0
133 inline bool horReversed() const { return hReversed; }
never executed: return hReversed;
0
134 inline bool verReversed() const { return vReversed; }
never executed: return vReversed;
0
135 inline void setDirty() { needRecalc = true; hfw_width = -1; }
never executed: end of block
0
136 inline bool isDirty() const { return needRecalc; }
never executed: return needRecalc;
0
137 bool hasHeightForWidth(int hSpacing, int vSpacing);-
138 int heightForWidth(int width, int hSpacing, int vSpacing);-
139 int minimumHeightForWidth(int width, int hSpacing, int vSpacing);-
140-
141 inline void getNextPos(int &row, int &col) { row = nextR; col = nextC; }
never executed: end of block
0
142 inline int count() const { return things.count(); }
never executed: return things.count();
0
143 QRect cellRect(int row, int col) const;-
144-
145 inline QLayoutItem *itemAt(int index) const {-
146 if (index < things.count())
index < things.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
147 return things.at(index)->item();
never executed: return things.at(index)->item();
0
148 else-
149 return 0;
never executed: return 0;
0
150 }-
151 inline QLayoutItem *takeAt(int index) {-
152 Q_Q(QGridLayout);-
153 if (index < things.count()) {
index < things.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
154 if (QGridBox *b = things.takeAt(index)) {
QGridBox *b = ....takeAt(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
155 QLayoutItem *item = b->takeItem();-
156 if (QLayout *l = item->layout()) {
QLayout *l = item->layout()Description
TRUEnever evaluated
FALSEnever evaluated
0
157 // sanity check in case the user passed something weird to QObject::setParent()-
158 if (l->parent() == q)
l->parent() == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
159 l->setParent(0);
never executed: l->setParent(0);
0
160 }
never executed: end of block
0
161 delete b;-
162 return item;
never executed: return item;
0
163 }-
164 }
never executed: end of block
0
165 return 0;
never executed: return 0;
0
166 }-
167 QLayoutItem* replaceAt(int index, QLayoutItem *newitem) Q_DECL_OVERRIDE-
168 {-
169 if (!newitem)
!newitemDescription
TRUEnever evaluated
FALSEnever evaluated
0
170 return 0;
never executed: return 0;
0
171 QLayoutItem *item = 0;-
172 QGridBox *b = things.value(index);-
173 if (b) {
bDescription
TRUEnever evaluated
FALSEnever evaluated
0
174 item = b->takeItem();-
175 b->setItem(newitem);-
176 }
never executed: end of block
0
177 return item;
never executed: return item;
0
178 }-
179-
180 void getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const {-
181 if (index < things.count()) {
index < things.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
182 const QGridBox *b = things.at(index);-
183 int toRow = b->toRow(rr);-
184 int toCol = b->toCol(cc);-
185 *row = b->row;-
186 *column = b->col;-
187 *rowSpan = toRow - *row + 1;-
188 *columnSpan = toCol - *column +1;-
189 }
never executed: end of block
0
190 }
never executed: end of block
0
191 void deleteAll();-
192-
193private:-
194 void setNextPosAfter(int r, int c);-
195 void recalcHFW(int w);-
196 void addHfwData(QGridBox *box, int width);-
197 void init();-
198 QSize findSize(int QLayoutStruct::*, int hSpacing, int vSpacing) const;-
199 void addData(QGridBox *b, const QGridLayoutSizeTriple &sizes, bool r, bool c);-
200 void setSize(int rows, int cols);-
201 void setupSpacings(QVector<QLayoutStruct> &chain, QGridBox *grid[], int fixedSpacing,-
202 Qt::Orientation orientation);-
203 void setupLayoutData(int hSpacing, int vSpacing);-
204 void setupHfwLayoutData();-
205 void effectiveMargins(int *left, int *top, int *right, int *bottom) const;-
206-
207 int rr;-
208 int cc;-
209 QVector<QLayoutStruct> rowData;-
210 QVector<QLayoutStruct> colData;-
211 QVector<QLayoutStruct> *hfwData;-
212 QVector<int> rStretch;-
213 QVector<int> cStretch;-
214 QVector<int> rMinHeights;-
215 QVector<int> cMinWidths;-
216 QList<QGridBox *> things;-
217-
218 int hfw_width;-
219 int hfw_height;-
220 int hfw_minheight;-
221 int nextR;-
222 int nextC;-
223-
224 int horizontalSpacing;-
225 int verticalSpacing;-
226 int leftMargin;-
227 int topMargin;-
228 int rightMargin;-
229 int bottomMargin;-
230-
231 uint hReversed : 1;-
232 uint vReversed : 1;-
233 uint needRecalc : 1;-
234 uint has_hfw : 1;-
235 uint addVertical : 1;-
236};-
237-
238void QGridLayoutPrivate::effectiveMargins(int *left, int *top, int *right, int *bottom) const-
239{-
240 int l = leftMargin;-
241 int t = topMargin;-
242 int r = rightMargin;-
243 int b = bottomMargin;-
244#ifdef Q_OS_MAC-
245 int leftMost = INT_MAX;-
246 int topMost = INT_MAX;-
247 int rightMost = 0;-
248 int bottomMost = 0;-
249-
250 QWidget *w = 0;-
251 const int n = things.count();-
252 for (int i = 0; i < n; ++i) {-
253 QGridBox *box = things.at(i);-
254 QLayoutItem *itm = box->item();-
255 w = itm->widget();-
256 if (w) {-
257 bool visualHReversed = hReversed != (w->layoutDirection() == Qt::RightToLeft);-
258 QRect lir = itm->geometry();-
259 QRect wr = w->geometry();-
260 if (box->col <= leftMost) {-
261 if (box->col < leftMost) {-
262 // we found an item even closer to the margin, discard.-
263 leftMost = box->col;-
264 if (visualHReversed)-
265 r = rightMargin;-
266 else-
267 l = leftMargin;-
268 }-
269 if (visualHReversed) {-
270 r = qMax(r, wr.right() - lir.right());-
271 } else {-
272 l = qMax(l, lir.left() - wr.left());-
273 }-
274 }-
275 if (box->row <= topMost) {-
276 if (box->row < topMost) {-
277 // we found an item even closer to the margin, discard.-
278 topMost = box->row;-
279 if (vReversed)-
280 b = bottomMargin;-
281 else-
282 t = topMargin;-
283 }-
284 if (vReversed)-
285 b = qMax(b, wr.bottom() - lir.bottom());-
286 else-
287 t = qMax(t, lir.top() - wr.top());-
288 }-
289 if (box->toCol(cc) >= rightMost) {-
290 if (box->toCol(cc) > rightMost) {-
291 // we found an item even closer to the margin, discard.-
292 rightMost = box->toCol(cc);-
293 if (visualHReversed)-
294 l = leftMargin;-
295 else-
296 r = rightMargin;-
297 }-
298 if (visualHReversed) {-
299 l = qMax(l, lir.left() - wr.left());-
300 } else {-
301 r = qMax(r, wr.right() - lir.right());-
302 }-
303-
304 }-
305 if (box->toRow(rr) >= bottomMost) {-
306 if (box->toRow(rr) > bottomMost) {-
307 // we found an item even closer to the margin, discard.-
308 bottomMost = box->toRow(rr);-
309 if (vReversed)-
310 t = topMargin;-
311 else-
312 b = bottomMargin;-
313 }-
314 if (vReversed)-
315 t = qMax(t, lir.top() - wr.top());-
316 else-
317 b = qMax(b, wr.bottom() - lir.bottom());-
318 }-
319 }-
320 }-
321-
322#endif-
323 if (left)
leftDescription
TRUEnever evaluated
FALSEnever evaluated
0
324 *left = l;
never executed: *left = l;
0
325 if (top)
topDescription
TRUEnever evaluated
FALSEnever evaluated
0
326 *top = t;
never executed: *top = t;
0
327 if (right)
rightDescription
TRUEnever evaluated
FALSEnever evaluated
0
328 *right = r;
never executed: *right = r;
0
329 if (bottom)
bottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
330 *bottom = b;
never executed: *bottom = b;
0
331}
never executed: end of block
0
332-
333QGridLayoutPrivate::QGridLayoutPrivate()-
334{-
335 addVertical = false;-
336 setDirty();-
337 rr = cc = 0;-
338 nextR = nextC = 0;-
339 hfwData = 0;-
340 hReversed = false;-
341 vReversed = false;-
342 horizontalSpacing = -1;-
343 verticalSpacing = -1;-
344}
never executed: end of block
0
345-
346#if 0-
347QGridLayoutPrivate::QGridLayoutPrivate(int nRows, int nCols)-
348 : rowData(0), colData(0)-
349{-
350 init();-
351 if (nRows < 0) {-
352 nRows = 1;-
353 addVertical = false;-
354 }-
355 if (nCols < 0) {-
356 nCols = 1;-
357 addVertical = true;-
358 }-
359 setSize(nRows, nCols);-
360}-
361#endif-
362-
363void QGridLayoutPrivate::deleteAll()-
364{-
365 while (!things.isEmpty())
!things.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
366 delete things.takeFirst();
never executed: delete things.takeFirst();
0
367 delete hfwData;-
368}
never executed: end of block
0
369-
370bool QGridLayoutPrivate::hasHeightForWidth(int hSpacing, int vSpacing)-
371{-
372 setupLayoutData(hSpacing, vSpacing);-
373 return has_hfw;
never executed: return has_hfw;
0
374}-
375-
376/*-
377 Assumes that setupLayoutData() has been called, and that-
378 qGeomCalc() has filled in colData with appropriate values.-
379*/-
380void QGridLayoutPrivate::recalcHFW(int w)-
381{-
382 /*-
383 Go through all children, using colData and heightForWidth()-
384 and put the results in hfwData.-
385 */-
386 if (!hfwData)
!hfwDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
387 hfwData = new QVector<QLayoutStruct>(rr);
never executed: hfwData = new QVector<QLayoutStruct>(rr);
0
388 setupHfwLayoutData();-
389 QVector<QLayoutStruct> &rData = *hfwData;-
390-
391 int h = 0;-
392 int mh = 0;-
393 for (int r = 0; r < rr; r++) {
r < rrDescription
TRUEnever evaluated
FALSEnever evaluated
0
394 int spacing = rData.at(r).spacing;-
395 h += rData.at(r).sizeHint + spacing;-
396 mh += rData.at(r).minimumSize + spacing;-
397 }
never executed: end of block
0
398-
399 hfw_width = w;-
400 hfw_height = qMin(QLAYOUTSIZE_MAX, h);-
401 hfw_minheight = qMin(QLAYOUTSIZE_MAX, mh);-
402}
never executed: end of block
0
403-
404int QGridLayoutPrivate::heightForWidth(int w, int hSpacing, int vSpacing)-
405{-
406 setupLayoutData(hSpacing, vSpacing);-
407 if (!has_hfw)
!has_hfwDescription
TRUEnever evaluated
FALSEnever evaluated
0
408 return -1;
never executed: return -1;
0
409 int left, top, right, bottom;-
410 effectiveMargins(&left, &top, &right, &bottom);-
411-
412 int hMargins = left + right;-
413 if (w - hMargins != hfw_width) {
w - hMargins != hfw_widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
414 qGeomCalc(colData, 0, cc, 0, w - hMargins);-
415 recalcHFW(w - hMargins);-
416 }
never executed: end of block
0
417 return hfw_height + top + bottom;
never executed: return hfw_height + top + bottom;
0
418}-
419-
420int QGridLayoutPrivate::minimumHeightForWidth(int w, int hSpacing, int vSpacing)-
421{-
422 (void)heightForWidth(w, hSpacing, vSpacing);-
423 if (!has_hfw)
!has_hfwDescription
TRUEnever evaluated
FALSEnever evaluated
0
424 return -1;
never executed: return -1;
0
425 int top, bottom;-
426 effectiveMargins(0, &top, 0, &bottom);-
427 return hfw_minheight + top + bottom;
never executed: return hfw_minheight + top + bottom;
0
428}-
429-
430QSize QGridLayoutPrivate::findSize(int QLayoutStruct::*size, int hSpacing, int vSpacing) const-
431{-
432 QGridLayoutPrivate *that = const_cast<QGridLayoutPrivate*>(this);-
433 that->setupLayoutData(hSpacing, vSpacing);-
434-
435 int w = 0;-
436 int h = 0;-
437-
438 for (int r = 0; r < rr; r++)
r < rrDescription
TRUEnever evaluated
FALSEnever evaluated
0
439 h += rowData.at(r).*size + rowData.at(r).spacing;
never executed: h += rowData.at(r).*size + rowData.at(r).spacing;
0
440 for (int c = 0; c < cc; c++)
c < ccDescription
TRUEnever evaluated
FALSEnever evaluated
0
441 w += colData.at(c).*size + colData.at(c).spacing;
never executed: w += colData.at(c).*size + colData.at(c).spacing;
0
442-
443 w = qMin(QLAYOUTSIZE_MAX, w);-
444 h = qMin(QLAYOUTSIZE_MAX, h);-
445-
446 return QSize(w, h);
never executed: return QSize(w, h);
0
447}-
448-
449Qt::Orientations QGridLayoutPrivate::expandingDirections(int hSpacing, int vSpacing) const-
450{-
451 QGridLayoutPrivate *that = const_cast<QGridLayoutPrivate*>(this);-
452 that->setupLayoutData(hSpacing, vSpacing);-
453 Qt::Orientations ret;-
454-
455 for (int r = 0; r < rr; r++) {
r < rrDescription
TRUEnever evaluated
FALSEnever evaluated
0
456 if (rowData.at(r).expansive) {
rowData.at(r).expansiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
457 ret |= Qt::Vertical;-
458 break;
never executed: break;
0
459 }-
460 }
never executed: end of block
0
461 for (int c = 0; c < cc; c++) {
c < ccDescription
TRUEnever evaluated
FALSEnever evaluated
0
462 if (colData.at(c).expansive) {
colData.at(c).expansiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
463 ret |= Qt::Horizontal;-
464 break;
never executed: break;
0
465 }-
466 }
never executed: end of block
0
467 return ret;
never executed: return ret;
0
468}-
469-
470QSize QGridLayoutPrivate::sizeHint(int hSpacing, int vSpacing) const-
471{-
472 return findSize(&QLayoutStruct::sizeHint, hSpacing, vSpacing);
never executed: return findSize(&QLayoutStruct::sizeHint, hSpacing, vSpacing);
0
473}-
474-
475QSize QGridLayoutPrivate::maximumSize(int hSpacing, int vSpacing) const-
476{-
477 return findSize(&QLayoutStruct::maximumSize, hSpacing, vSpacing);
never executed: return findSize(&QLayoutStruct::maximumSize, hSpacing, vSpacing);
0
478}-
479-
480QSize QGridLayoutPrivate::minimumSize(int hSpacing, int vSpacing) const-
481{-
482 return findSize(&QLayoutStruct::minimumSize, hSpacing, vSpacing);
never executed: return findSize(&QLayoutStruct::minimumSize, hSpacing, vSpacing);
0
483}-
484-
485void QGridLayoutPrivate::setSize(int r, int c)-
486{-
487 if ((int)rowData.size() < r) {
(int)rowData.size() < rDescription
TRUEnever evaluated
FALSEnever evaluated
0
488 int newR = qMax(r, rr * 2);-
489 rowData.resize(newR);-
490 rStretch.resize(newR);-
491 rMinHeights.resize(newR);-
492 for (int i = rr; i < newR; i++) {
i < newRDescription
TRUEnever evaluated
FALSEnever evaluated
0
493 rowData[i].init();-
494 rowData[i].maximumSize = 0;-
495 rowData[i].pos = 0;-
496 rowData[i].size = 0;-
497 rStretch[i] = 0;-
498 rMinHeights[i] = 0;-
499 }
never executed: end of block
0
500 }
never executed: end of block
0
501 if ((int)colData.size() < c) {
(int)colData.size() < cDescription
TRUEnever evaluated
FALSEnever evaluated
0
502 int newC = qMax(c, cc * 2);-
503 colData.resize(newC);-
504 cStretch.resize(newC);-
505 cMinWidths.resize(newC);-
506 for (int i = cc; i < newC; i++) {
i < newCDescription
TRUEnever evaluated
FALSEnever evaluated
0
507 colData[i].init();-
508 colData[i].maximumSize = 0;-
509 colData[i].pos = 0;-
510 colData[i].size = 0;-
511 cStretch[i] = 0;-
512 cMinWidths[i] = 0;-
513 }
never executed: end of block
0
514 }
never executed: end of block
0
515-
516 if (hfwData && (int)hfwData->size() < r) {
hfwDataDescription
TRUEnever evaluated
FALSEnever evaluated
(int)hfwData->size() < rDescription
TRUEnever evaluated
FALSEnever evaluated
0
517 delete hfwData;-
518 hfwData = 0;-
519 hfw_width = -1;-
520 }
never executed: end of block
0
521 rr = r;-
522 cc = c;-
523}
never executed: end of block
0
524-
525void QGridLayoutPrivate::setNextPosAfter(int row, int col)-
526{-
527 if (addVertical) {
addVerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
528 if (col > nextC || (col == nextC && row >= nextR)) {
col > nextCDescription
TRUEnever evaluated
FALSEnever evaluated
col == nextCDescription
TRUEnever evaluated
FALSEnever evaluated
row >= nextRDescription
TRUEnever evaluated
FALSEnever evaluated
0
529 nextR = row + 1;-
530 nextC = col;-
531 if (nextR >= rr) {
nextR >= rrDescription
TRUEnever evaluated
FALSEnever evaluated
0
532 nextR = 0;-
533 nextC++;-
534 }
never executed: end of block
0
535 }
never executed: end of block
0
536 } else {
never executed: end of block
0
537 if (row > nextR || (row == nextR && col >= nextC)) {
row > nextRDescription
TRUEnever evaluated
FALSEnever evaluated
row == nextRDescription
TRUEnever evaluated
FALSEnever evaluated
col >= nextCDescription
TRUEnever evaluated
FALSEnever evaluated
0
538 nextR = row;-
539 nextC = col + 1;-
540 if (nextC >= cc) {
nextC >= ccDescription
TRUEnever evaluated
FALSEnever evaluated
0
541 nextC = 0;-
542 nextR++;-
543 }
never executed: end of block
0
544 }
never executed: end of block
0
545 }
never executed: end of block
0
546}-
547-
548void QGridLayoutPrivate::add(QGridBox *box, int row, int col)-
549{-
550 expand(row + 1, col + 1);-
551 box->row = box->torow = row;-
552 box->col = box->tocol = col;-
553 things.append(box);-
554 setDirty();-
555 setNextPosAfter(row, col);-
556}
never executed: end of block
0
557-
558void QGridLayoutPrivate::add(QGridBox *box, int row1, int row2, int col1, int col2)-
559{-
560 if (row2 >= 0 && row2 < row1)
row2 >= 0Description
TRUEnever evaluated
FALSEnever evaluated
row2 < row1Description
TRUEnever evaluated
FALSEnever evaluated
0
561 qWarning("QGridLayout: Multi-cell fromRow greater than toRow");
never executed: QMessageLogger(__FILE__, 561, __PRETTY_FUNCTION__).warning("QGridLayout: Multi-cell fromRow greater than toRow");
0
562 if (col2 >= 0 && col2 < col1)
col2 >= 0Description
TRUEnever evaluated
FALSEnever evaluated
col2 < col1Description
TRUEnever evaluated
FALSEnever evaluated
0
563 qWarning("QGridLayout: Multi-cell fromCol greater than toCol");
never executed: QMessageLogger(__FILE__, 563, __PRETTY_FUNCTION__).warning("QGridLayout: Multi-cell fromCol greater than toCol");
0
564 if (row1 == row2 && col1 == col2) {
row1 == row2Description
TRUEnever evaluated
FALSEnever evaluated
col1 == col2Description
TRUEnever evaluated
FALSEnever evaluated
0
565 add(box, row1, col1);-
566 return;
never executed: return;
0
567 }-
568 expand(qMax(row1, row2) + 1, qMax(col1, col2) + 1);-
569 box->row = row1;-
570 box->col = col1;-
571-
572 box->torow = row2;-
573 box->tocol = col2;-
574-
575 things.append(box);-
576 setDirty();-
577 if (col2 < 0)
col2 < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
578 col2 = cc - 1;
never executed: col2 = cc - 1;
0
579-
580 setNextPosAfter(row2, col2);-
581}
never executed: end of block
0
582-
583void QGridLayoutPrivate::addData(QGridBox *box, const QGridLayoutSizeTriple &sizes, bool r, bool c)-
584{-
585 const QWidget *widget = box->item()->widget();-
586-
587 if (box->isEmpty() && widget)
box->isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
588 return;
never executed: return;
0
589-
590 if (c) {
cDescription
TRUEnever evaluated
FALSEnever evaluated
0
591 QLayoutStruct *data = &colData[box->col];-
592 if (!cStretch.at(box->col))
!cStretch.at(box->col)Description
TRUEnever evaluated
FALSEnever evaluated
0
593 data->stretch = qMax(data->stretch, box->hStretch());
never executed: data->stretch = qMax(data->stretch, box->hStretch());
0
594 data->sizeHint = qMax(sizes.hint.width(), data->sizeHint);-
595 data->minimumSize = qMax(sizes.minS.width(), data->minimumSize);-
596-
597 qMaxExpCalc(data->maximumSize, data->expansive, data->empty, sizes.maxS.width(),-
598 box->expandingDirections() & Qt::Horizontal, box->isEmpty());-
599 }
never executed: end of block
0
600 if (r) {
rDescription
TRUEnever evaluated
FALSEnever evaluated
0
601 QLayoutStruct *data = &rowData[box->row];-
602 if (!rStretch.at(box->row))
!rStretch.at(box->row)Description
TRUEnever evaluated
FALSEnever evaluated
0
603 data->stretch = qMax(data->stretch, box->vStretch());
never executed: data->stretch = qMax(data->stretch, box->vStretch());
0
604 data->sizeHint = qMax(sizes.hint.height(), data->sizeHint);-
605 data->minimumSize = qMax(sizes.minS.height(), data->minimumSize);-
606-
607 qMaxExpCalc(data->maximumSize, data->expansive, data->empty, sizes.maxS.height(),-
608 box->expandingDirections() & Qt::Vertical, box->isEmpty());-
609 }
never executed: end of block
0
610}
never executed: end of block
0
611-
612static void initEmptyMultiBox(QVector<QLayoutStruct> &chain, int start, int end)-
613{-
614 for (int i = start; i <= end; i++) {
i <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
615 QLayoutStruct *data = &chain[i];-
616 if (data->empty && data->maximumSize == 0) // truly empty box
data->emptyDescription
TRUEnever evaluated
FALSEnever evaluated
data->maximumSize == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
617 data->maximumSize = QWIDGETSIZE_MAX;
never executed: data->maximumSize = ((1<<24)-1);
0
618 data->empty = false;-
619 }
never executed: end of block
0
620}
never executed: end of block
0
621-
622static void distributeMultiBox(QVector<QLayoutStruct> &chain, int start, int end, int minSize,-
623 int sizeHint, QVector<int> &stretchArray, int stretch)-
624{-
625 int i;-
626 int w = 0;-
627 int wh = 0;-
628 int max = 0;-
629-
630 for (i = start; i <= end; i++) {
i <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
631 QLayoutStruct *data = &chain[i];-
632 w += data->minimumSize;-
633 wh += data->sizeHint;-
634 max += data->maximumSize;-
635 if (stretchArray.at(i) == 0)
stretchArray.at(i) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
636 data->stretch = qMax(data->stretch, stretch);
never executed: data->stretch = qMax(data->stretch, stretch);
0
637-
638 if (i != end) {
i != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
639 int spacing = data->spacing;-
640 w += spacing;-
641 wh += spacing;-
642 max += spacing;-
643 }
never executed: end of block
0
644 }
never executed: end of block
0
645-
646 if (max < minSize) { // implies w < minSize
max < minSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
647 /*-
648 We must increase the maximum size of at least one of the-
649 items. qGeomCalc() will put the extra space in between the-
650 items. We must recover that extra space and put it-
651 somewhere. It does not really matter where, since the user-
652 can always specify stretch factors and avoid this code.-
653 */-
654 qGeomCalc(chain, start, end - start + 1, 0, minSize);-
655 int pos = 0;-
656 for (i = start; i <= end; i++) {
i <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
657 QLayoutStruct *data = &chain[i];-
658 int nextPos = (i == end) ? minSize : chain.at(i + 1).pos;
(i == end)Description
TRUEnever evaluated
FALSEnever evaluated
0
659 int realSize = nextPos - pos;-
660 if (i != end)
i != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
661 realSize -= data->spacing;
never executed: realSize -= data->spacing;
0
662 if (data->minimumSize < realSize)
data->minimumSize < realSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
663 data->minimumSize = realSize;
never executed: data->minimumSize = realSize;
0
664 if (data->maximumSize < data->minimumSize)
data->maximumS...a->minimumSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
665 data->maximumSize = data->minimumSize;
never executed: data->maximumSize = data->minimumSize;
0
666 pos = nextPos;-
667 }
never executed: end of block
0
668 } else if (w < minSize) {
never executed: end of block
w < minSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
669 qGeomCalc(chain, start, end - start + 1, 0, minSize);-
670 for (i = start; i <= end; i++) {
i <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
671 QLayoutStruct *data = &chain[i];-
672 if (data->minimumSize < data->size)
data->minimumSize < data->sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
673 data->minimumSize = data->size;
never executed: data->minimumSize = data->size;
0
674 }
never executed: end of block
0
675 }
never executed: end of block
0
676-
677 if (wh < sizeHint) {
wh < sizeHintDescription
TRUEnever evaluated
FALSEnever evaluated
0
678 qGeomCalc(chain, start, end - start + 1, 0, sizeHint);-
679 for (i = start; i <= end; i++) {
i <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
680 QLayoutStruct *data = &chain[i];-
681 if (data->sizeHint < data->size)
data->sizeHint < data->sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
682 data->sizeHint = data->size;
never executed: data->sizeHint = data->size;
0
683 }
never executed: end of block
0
684 }
never executed: end of block
0
685}
never executed: end of block
0
686-
687static QGridBox *&gridAt(QGridBox *grid[], int r, int c, int cc,-
688 Qt::Orientation orientation = Qt::Vertical)-
689{-
690 if (orientation == Qt::Horizontal)
orientation == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
691 qSwap(r, c);
never executed: qSwap(r, c);
0
692 return grid[(r * cc) + c];
never executed: return grid[(r * cc) + c];
0
693}-
694-
695void QGridLayoutPrivate::setupSpacings(QVector<QLayoutStruct> &chain,-
696 QGridBox *grid[], int fixedSpacing,-
697 Qt::Orientation orientation)-
698{-
699 Q_Q(QGridLayout);-
700 int numRows = rr; // or columns if orientation is horizontal-
701 int numColumns = cc; // or rows if orientation is horizontal-
702-
703 if (orientation == Qt::Horizontal) {
orientation == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
704 qSwap(numRows, numColumns);-
705 }
never executed: end of block
0
706-
707 QStyle *style = 0;-
708 if (fixedSpacing < 0) {
fixedSpacing < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
709 if (QWidget *parentWidget = q->parentWidget())
QWidget *paren...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
710 style = parentWidget->style();
never executed: style = parentWidget->style();
0
711 }
never executed: end of block
0
712-
713 for (int c = 0; c < numColumns; ++c) {
c < numColumnsDescription
TRUEnever evaluated
FALSEnever evaluated
0
714 QGridBox *previousBox = 0;-
715 int previousRow = -1; // previous *non-empty* row-
716-
717 for (int r = 0; r < numRows; ++r) {
r < numRowsDescription
TRUEnever evaluated
FALSEnever evaluated
0
718 if (chain.at(r).empty)
chain.at(r).emptyDescription
TRUEnever evaluated
FALSEnever evaluated
0
719 continue;
never executed: continue;
0
720-
721 QGridBox *box = gridAt(grid, r, c, cc, orientation);-
722 if (previousRow != -1 && (!box || previousBox != box)) {
previousRow != -1Description
TRUEnever evaluated
FALSEnever evaluated
!boxDescription
TRUEnever evaluated
FALSEnever evaluated
previousBox != boxDescription
TRUEnever evaluated
FALSEnever evaluated
0
723 int spacing = fixedSpacing;-
724 if (spacing < 0) {
spacing < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
725 QSizePolicy::ControlTypes controlTypes1 = QSizePolicy::DefaultType;-
726 QSizePolicy::ControlTypes controlTypes2 = QSizePolicy::DefaultType;-
727 if (previousBox)
previousBoxDescription
TRUEnever evaluated
FALSEnever evaluated
0
728 controlTypes1 = previousBox->item()->controlTypes();
never executed: controlTypes1 = previousBox->item()->controlTypes();
0
729 if (box)
boxDescription
TRUEnever evaluated
FALSEnever evaluated
0
730 controlTypes2 = box->item()->controlTypes();
never executed: controlTypes2 = box->item()->controlTypes();
0
731-
732 if ((orientation == Qt::Horizontal && hReversed)
orientation == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
hReversedDescription
TRUEnever evaluated
FALSEnever evaluated
0
733 || (orientation == Qt::Vertical && vReversed))
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
vReversedDescription
TRUEnever evaluated
FALSEnever evaluated
0
734 qSwap(controlTypes1, controlTypes2);
never executed: qSwap(controlTypes1, controlTypes2);
0
735-
736 if (style)
styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
737 spacing = style->combinedLayoutSpacing(controlTypes1, controlTypes2,
never executed: spacing = style->combinedLayoutSpacing(controlTypes1, controlTypes2, orientation, 0, q->parentWidget());
0
738 orientation, 0, q->parentWidget());
never executed: spacing = style->combinedLayoutSpacing(controlTypes1, controlTypes2, orientation, 0, q->parentWidget());
0
739 } else {
never executed: end of block
0
740 if (orientation == Qt::Vertical) {
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
741 QGridBox *sibling = vReversed ? previousBox : box;
vReversedDescription
TRUEnever evaluated
FALSEnever evaluated
0
742 if (sibling) {
siblingDescription
TRUEnever evaluated
FALSEnever evaluated
0
743 QWidget *wid = sibling->item()->widget();-
744 if (wid)
widDescription
TRUEnever evaluated
FALSEnever evaluated
0
745 spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top() );
never executed: spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top() );
0
746 }
never executed: end of block
0
747 }
never executed: end of block
0
748 }
never executed: end of block
0
749-
750 if (spacing > chain.at(previousRow).spacing)
spacing > chai...usRow).spacingDescription
TRUEnever evaluated
FALSEnever evaluated
0
751 chain[previousRow].spacing = spacing;
never executed: chain[previousRow].spacing = spacing;
0
752 }
never executed: end of block
0
753-
754 previousBox = box;-
755 previousRow = r;-
756 }
never executed: end of block
0
757 }
never executed: end of block
0
758}
never executed: end of block
0
759-
760//#define QT_LAYOUT_DISABLE_CACHING-
761-
762void QGridLayoutPrivate::setupLayoutData(int hSpacing, int vSpacing)-
763{-
764 Q_Q(QGridLayout);-
765-
766#ifndef QT_LAYOUT_DISABLE_CACHING-
767 if (!needRecalc)
!needRecalcDescription
TRUEnever evaluated
FALSEnever evaluated
0
768 return;
never executed: return;
0
769#endif-
770 has_hfw = false;-
771 int i;-
772-
773 for (i = 0; i < rr; i++) {
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
0
774 rowData[i].init(rStretch.at(i), rMinHeights.at(i));-
775 rowData[i].maximumSize = rStretch.at(i) ? QLAYOUTSIZE_MAX : rMinHeights.at(i);
rStretch.at(i)Description
TRUEnever evaluated
FALSEnever evaluated
0
776 }
never executed: end of block
0
777 for (i = 0; i < cc; i++) {
i < ccDescription
TRUEnever evaluated
FALSEnever evaluated
0
778 colData[i].init(cStretch.at(i), cMinWidths.at(i));-
779 colData[i].maximumSize = cStretch.at(i) ? QLAYOUTSIZE_MAX : cMinWidths.at(i);
cStretch.at(i)Description
TRUEnever evaluated
FALSEnever evaluated
0
780 }
never executed: end of block
0
781-
782 int n = things.size();-
783 QVarLengthArray<QGridLayoutSizeTriple> sizes(n);-
784-
785 bool has_multi = false;-
786-
787 /*-
788 Grid of items. We use it to determine which items are-
789 adjacent to which and compute the spacings correctly.-
790 */-
791 QVarLengthArray<QGridBox *> grid(rr * cc);-
792 memset(grid.data(), 0, rr * cc * sizeof(QGridBox *));-
793-
794 /*-
795 Initialize 'sizes' and 'grid' data structures, and insert-
796 non-spanning items to our row and column data structures.-
797 */-
798 for (i = 0; i < n; ++i) {
i < nDescription
TRUEnever evaluated
FALSEnever evaluated
0
799 QGridBox * const box = things.at(i);-
800 sizes[i].minS = box->minimumSize();-
801 sizes[i].hint = box->sizeHint();-
802 sizes[i].maxS = box->maximumSize();-
803-
804 if (box->hasHeightForWidth())
box->hasHeightForWidth()Description
TRUEnever evaluated
FALSEnever evaluated
0
805 has_hfw = true;
never executed: has_hfw = true;
0
806-
807 if (box->row == box->toRow(rr)) {
box->row == box->toRow(rr)Description
TRUEnever evaluated
FALSEnever evaluated
0
808 addData(box, sizes[i], true, false);-
809 } else {
never executed: end of block
0
810 initEmptyMultiBox(rowData, box->row, box->toRow(rr));-
811 has_multi = true;-
812 }
never executed: end of block
0
813-
814 if (box->col == box->toCol(cc)) {
box->col == box->toCol(cc)Description
TRUEnever evaluated
FALSEnever evaluated
0
815 addData(box, sizes[i], false, true);-
816 } else {
never executed: end of block
0
817 initEmptyMultiBox(colData, box->col, box->toCol(cc));-
818 has_multi = true;-
819 }
never executed: end of block
0
820-
821 for (int r = box->row; r <= box->toRow(rr); ++r) {
r <= box->toRow(rr)Description
TRUEnever evaluated
FALSEnever evaluated
0
822 for (int c = box->col; c <= box->toCol(cc); ++c) {
c <= box->toCol(cc)Description
TRUEnever evaluated
FALSEnever evaluated
0
823 gridAt(grid.data(), r, c, cc) = box;-
824 }
never executed: end of block
0
825 }
never executed: end of block
0
826 }
never executed: end of block
0
827-
828 setupSpacings(colData, grid.data(), hSpacing, Qt::Horizontal);-
829 setupSpacings(rowData, grid.data(), vSpacing, Qt::Vertical);-
830-
831 /*-
832 Insert multicell items to our row and column data structures.-
833 This must be done after the non-spanning items to obtain a-
834 better distribution in distributeMultiBox().-
835 */-
836 if (has_multi) {
has_multiDescription
TRUEnever evaluated
FALSEnever evaluated
0
837 for (i = 0; i < n; ++i) {
i < nDescription
TRUEnever evaluated
FALSEnever evaluated
0
838 QGridBox * const box = things.at(i);-
839-
840 if (box->row != box->toRow(rr))
box->row != box->toRow(rr)Description
TRUEnever evaluated
FALSEnever evaluated
0
841 distributeMultiBox(rowData, box->row, box->toRow(rr), sizes[i].minS.height(),
never executed: distributeMultiBox(rowData, box->row, box->toRow(rr), sizes[i].minS.height(), sizes[i].hint.height(), rStretch, box->vStretch());
0
842 sizes[i].hint.height(), rStretch, box->vStretch());
never executed: distributeMultiBox(rowData, box->row, box->toRow(rr), sizes[i].minS.height(), sizes[i].hint.height(), rStretch, box->vStretch());
0
843 if (box->col != box->toCol(cc))
box->col != box->toCol(cc)Description
TRUEnever evaluated
FALSEnever evaluated
0
844 distributeMultiBox(colData, box->col, box->toCol(cc), sizes[i].minS.width(),
never executed: distributeMultiBox(colData, box->col, box->toCol(cc), sizes[i].minS.width(), sizes[i].hint.width(), cStretch, box->hStretch());
0
845 sizes[i].hint.width(), cStretch, box->hStretch());
never executed: distributeMultiBox(colData, box->col, box->toCol(cc), sizes[i].minS.width(), sizes[i].hint.width(), cStretch, box->hStretch());
0
846 }
never executed: end of block
0
847 }
never executed: end of block
0
848-
849 for (i = 0; i < rr; i++)
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
0
850 rowData[i].expansive = rowData.at(i).expansive || rowData.at(i).stretch > 0;
never executed: rowData[i].expansive = rowData.at(i).expansive || rowData.at(i).stretch > 0;
rowData.at(i).expansiveDescription
TRUEnever evaluated
FALSEnever evaluated
rowData.at(i).stretch > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
851 for (i = 0; i < cc; i++)
i < ccDescription
TRUEnever evaluated
FALSEnever evaluated
0
852 colData[i].expansive = colData.at(i).expansive || colData.at(i).stretch > 0;
never executed: colData[i].expansive = colData.at(i).expansive || colData.at(i).stretch > 0;
colData.at(i).expansiveDescription
TRUEnever evaluated
FALSEnever evaluated
colData.at(i).stretch > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
853-
854 q->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);-
855-
856 needRecalc = false;-
857}
never executed: end of block
0
858-
859void QGridLayoutPrivate::addHfwData(QGridBox *box, int width)-
860{-
861 QVector<QLayoutStruct> &rData = *hfwData;-
862 if (box->hasHeightForWidth()) {
box->hasHeightForWidth()Description
TRUEnever evaluated
FALSEnever evaluated
0
863 int hint = box->heightForWidth(width);-
864 rData[box->row].sizeHint = qMax(hint, rData.at(box->row).sizeHint);-
865 rData[box->row].minimumSize = qMax(hint, rData.at(box->row).minimumSize);-
866 } else {
never executed: end of block
0
867 QSize hint = box->sizeHint();-
868 QSize minS = box->minimumSize();-
869 rData[box->row].sizeHint = qMax(hint.height(), rData.at(box->row).sizeHint);-
870 rData[box->row].minimumSize = qMax(minS.height(), rData.at(box->row).minimumSize);-
871 }
never executed: end of block
0
872}-
873-
874/*-
875 Similar to setupLayoutData(), but uses heightForWidth(colData)-
876 instead of sizeHint(). Assumes that setupLayoutData() and-
877 qGeomCalc(colData) has been called.-
878*/-
879void QGridLayoutPrivate::setupHfwLayoutData()-
880{-
881 QVector<QLayoutStruct> &rData = *hfwData;-
882 for (int i = 0; i < rr; i++) {
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
0
883 rData[i] = rowData.at(i);-
884 rData[i].minimumSize = rData[i].sizeHint = rMinHeights.at(i);-
885 }
never executed: end of block
0
886-
887 for (int pass = 0; pass < 2; ++pass) {
pass < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
888 for (int i = 0; i < things.size(); ++i) {
i < things.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
889 QGridBox *box = things.at(i);-
890 int r1 = box->row;-
891 int c1 = box->col;-
892 int r2 = box->toRow(rr);-
893 int c2 = box->toCol(cc);-
894 int w = colData.at(c2).pos + colData.at(c2).size - colData.at(c1).pos;-
895-
896 if (r1 == r2) {
r1 == r2Description
TRUEnever evaluated
FALSEnever evaluated
0
897 if (pass == 0)
pass == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
898 addHfwData(box, w);
never executed: addHfwData(box, w);
0
899 } else {
never executed: end of block
0
900 if (pass == 0) {
pass == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
901 initEmptyMultiBox(rData, r1, r2);-
902 } else {
never executed: end of block
0
903 QSize hint = box->sizeHint();-
904 QSize min = box->minimumSize();-
905 if (box->hasHeightForWidth()) {
box->hasHeightForWidth()Description
TRUEnever evaluated
FALSEnever evaluated
0
906 int hfwh = box->heightForWidth(w);-
907 if (hfwh > hint.height())
hfwh > hint.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
908 hint.setHeight(hfwh);
never executed: hint.setHeight(hfwh);
0
909 if (hfwh > min.height())
hfwh > min.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
910 min.setHeight(hfwh);
never executed: min.setHeight(hfwh);
0
911 }
never executed: end of block
0
912 distributeMultiBox(rData, r1, r2, min.height(), hint.height(),-
913 rStretch, box->vStretch());-
914 }
never executed: end of block
0
915 }-
916 }-
917 }
never executed: end of block
0
918 for (int i = 0; i < rr; i++)
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
0
919 rData[i].expansive = rData.at(i).expansive || rData.at(i).stretch > 0;
never executed: rData[i].expansive = rData.at(i).expansive || rData.at(i).stretch > 0;
rData.at(i).expansiveDescription
TRUEnever evaluated
FALSEnever evaluated
rData.at(i).stretch > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
920}
never executed: end of block
0
921-
922void QGridLayoutPrivate::distribute(QRect r, int hSpacing, int vSpacing)-
923{-
924 Q_Q(QGridLayout);-
925 bool visualHReversed = hReversed;-
926 QWidget *parent = q->parentWidget();-
927 if (parent && parent->isRightToLeft())
parentDescription
TRUEnever evaluated
FALSEnever evaluated
parent->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
928 visualHReversed = !visualHReversed;
never executed: visualHReversed = !visualHReversed;
0
929-
930 setupLayoutData(hSpacing, vSpacing);-
931-
932 int left, top, right, bottom;-
933 effectiveMargins(&left, &top, &right, &bottom);-
934 r.adjust(+left, +top, -right, -bottom);-
935-
936 qGeomCalc(colData, 0, cc, r.x(), r.width());-
937 QVector<QLayoutStruct> *rDataPtr;-
938 if (has_hfw) {
has_hfwDescription
TRUEnever evaluated
FALSEnever evaluated
0
939 recalcHFW(r.width());-
940 qGeomCalc(*hfwData, 0, rr, r.y(), r.height());-
941 rDataPtr = hfwData;-
942 } else {
never executed: end of block
0
943 qGeomCalc(rowData, 0, rr, r.y(), r.height());-
944 rDataPtr = &rowData;-
945 }
never executed: end of block
0
946 QVector<QLayoutStruct> &rData = *rDataPtr;-
947 int i;-
948-
949 bool reverse = ((r.bottom() > rect.bottom()) || (r.bottom() == rect.bottom()
(r.bottom() > rect.bottom())Description
TRUEnever evaluated
FALSEnever evaluated
r.bottom() == rect.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
950 && ((r.right() > rect.right()) != visualHReversed)));
((r.right() > ...sualHReversed)Description
TRUEnever evaluated
FALSEnever evaluated
0
951 int n = things.size();-
952 for (i = 0; i < n; ++i) {
i < nDescription
TRUEnever evaluated
FALSEnever evaluated
0
953 QGridBox *box = things.at(reverse ? n-i-1 : i);-
954 int r2 = box->toRow(rr);-
955 int c2 = box->toCol(cc);-
956-
957 int x = colData.at(box->col).pos;-
958 int y = rData.at(box->row).pos;-
959 int x2p = colData.at(c2).pos + colData.at(c2).size; // x2+1-
960 int y2p = rData.at(r2).pos + rData.at(r2).size; // y2+1-
961 int w = x2p - x;-
962 int h = y2p - y;-
963-
964 if (visualHReversed)
visualHReversedDescription
TRUEnever evaluated
FALSEnever evaluated
0
965 x = r.left() + r.right() - x - w + 1;
never executed: x = r.left() + r.right() - x - w + 1;
0
966 if (vReversed)
vReversedDescription
TRUEnever evaluated
FALSEnever evaluated
0
967 y = r.top() + r.bottom() - y - h + 1;
never executed: y = r.top() + r.bottom() - y - h + 1;
0
968-
969 box->setGeometry(QRect(x, y, w, h));-
970 }
never executed: end of block
0
971}
never executed: end of block
0
972-
973QRect QGridLayoutPrivate::cellRect(int row, int col) const-
974{-
975 if (row < 0 || row >= rr || col < 0 || col >= cc)
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
row >= rrDescription
TRUEnever evaluated
FALSEnever evaluated
col < 0Description
TRUEnever evaluated
FALSEnever evaluated
col >= ccDescription
TRUEnever evaluated
FALSEnever evaluated
0
976 return QRect();
never executed: return QRect();
0
977-
978 const QVector<QLayoutStruct> *rDataPtr;-
979 if (has_hfw && hfwData)
has_hfwDescription
TRUEnever evaluated
FALSEnever evaluated
hfwDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
980 rDataPtr = hfwData;
never executed: rDataPtr = hfwData;
0
981 else-
982 rDataPtr = &rowData;
never executed: rDataPtr = &rowData;
0
983 return QRect(colData.at(col).pos, rDataPtr->at(row).pos,
never executed: return QRect(colData.at(col).pos, rDataPtr->at(row).pos, colData.at(col).size, rDataPtr->at(row).size);
0
984 colData.at(col).size, rDataPtr->at(row).size);
never executed: return QRect(colData.at(col).pos, rDataPtr->at(row).pos, colData.at(col).size, rDataPtr->at(row).size);
0
985}-
986-
987/*!-
988 \class QGridLayout-
989-
990 \brief The QGridLayout class lays out widgets in a grid.-
991-
992 \ingroup geomanagement-
993 \inmodule QtWidgets-
994-
995 QGridLayout takes the space made available to it (by its parent-
996 layout or by the parentWidget()), divides it up into rows and-
997 columns, and puts each widget it manages into the correct cell.-
998-
999 Columns and rows behave identically; we will discuss columns, but-
1000 there are equivalent functions for rows.-
1001-
1002 Each column has a minimum width and a stretch factor. The minimum-
1003 width is the greatest of that set using setColumnMinimumWidth() and the-
1004 minimum width of each widget in that column. The stretch factor is-
1005 set using setColumnStretch() and determines how much of the available-
1006 space the column will get over and above its necessary minimum.-
1007-
1008 Normally, each managed widget or layout is put into a cell of its-
1009 own using addWidget(). It is also possible for a widget to occupy-
1010 multiple cells using the row and column spanning overloads of-
1011 addItem() and addWidget(). If you do this, QGridLayout will guess-
1012 how to distribute the size over the columns/rows (based on the-
1013 stretch factors).-
1014-
1015 To remove a widget from a layout, call removeWidget(). Calling-
1016 QWidget::hide() on a widget also effectively removes the widget-
1017 from the layout until QWidget::show() is called.-
1018-
1019 This illustration shows a fragment of a dialog with a five-column,-
1020 three-row grid (the grid is shown overlaid in magenta):-
1021-
1022 \image gridlayout.png A grid layout-
1023-
1024 Columns 0, 2 and 4 in this dialog fragment are made up of a-
1025 QLabel, a QLineEdit, and a QListBox. Columns 1 and 3 are-
1026 placeholders made with setColumnMinimumWidth(). Row 0 consists of three-
1027 QLabel objects, row 1 of three QLineEdit objects and row 2 of-
1028 three QListBox objects. We used placeholder columns (1 and 3) to-
1029 get the right amount of space between the columns.-
1030-
1031 Note that the columns and rows are not equally wide or tall. If-
1032 you want two columns to have the same width, you must set their-
1033 minimum widths and stretch factors to be the same yourself. You do-
1034 this using setColumnMinimumWidth() and setColumnStretch().-
1035-
1036 If the QGridLayout is not the top-level layout (i.e. does not-
1037 manage all of the widget's area and children), you must add it to-
1038 its parent layout when you create it, but before you do anything-
1039 with it. The normal way to add a layout is by calling-
1040 addLayout() on the parent layout.-
1041-
1042 Once you have added your layout you can start putting widgets and-
1043 other layouts into the cells of your grid layout using-
1044 addWidget(), addItem(), and addLayout().-
1045-
1046 QGridLayout also includes two margin widths:-
1047 the \l{getContentsMargins()}{contents margin} and the spacing().-
1048 The contents margin is the width of the reserved space along each-
1049 of the QGridLayout's four sides. The spacing() is the width of the-
1050 automatically allocated spacing between neighboring boxes.-
1051-
1052 The default contents margin values are provided by the-
1053 \l{QStyle::pixelMetric()}{style}. The default value Qt styles specify-
1054 is 9 for child widgets and 11 for windows. The spacing defaults to the same as-
1055 the margin width for a top-level layout, or to the same as the-
1056 parent layout.-
1057-
1058 \sa QBoxLayout, QStackedLayout, {Layout Management}, {Basic Layouts Example}-
1059*/-
1060-
1061-
1062/*!-
1063 Constructs a new QGridLayout with parent widget, \a parent. The-
1064 layout has one row and one column initially, and will expand when-
1065 new items are inserted.-
1066*/-
1067QGridLayout::QGridLayout(QWidget *parent)-
1068 : QLayout(*new QGridLayoutPrivate, 0, parent)-
1069{-
1070 Q_D(QGridLayout);-
1071 d->expand(1, 1);-
1072}
never executed: end of block
0
1073-
1074/*!-
1075 Constructs a new grid layout.-
1076-
1077 You must insert this grid into another layout. You can insert-
1078 widgets and layouts into this layout at any time, but laying out-
1079 will not be performed before this is inserted into another layout.-
1080*/-
1081QGridLayout::QGridLayout()-
1082 : QLayout(*new QGridLayoutPrivate, 0, 0)-
1083{-
1084 Q_D(QGridLayout);-
1085 d->expand(1, 1);-
1086}
never executed: end of block
0
1087-
1088-
1089-
1090-
1091/*!-
1092\internal (mostly)-
1093-
1094Sets the positioning mode used by addItem(). If \a orient is-
1095Qt::Horizontal, this layout is expanded to \a n columns, and items-
1096will be added columns-first. Otherwise it is expanded to \a n rows and-
1097items will be added rows-first.-
1098*/-
1099-
1100void QGridLayout::setDefaultPositioning(int n, Qt::Orientation orient)-
1101{-
1102 Q_D(QGridLayout);-
1103 if (orient == Qt::Horizontal) {
orient == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1104 d->expand(1, n);-
1105 d->addVertical = false;-
1106 } else {
never executed: end of block
0
1107 d->expand(n,1);-
1108 d->addVertical = true;-
1109 }
never executed: end of block
0
1110}-
1111-
1112-
1113/*!-
1114 Destroys the grid layout. Geometry management is terminated if-
1115 this is a top-level grid.-
1116-
1117 The layout's widgets aren't destroyed.-
1118*/-
1119QGridLayout::~QGridLayout()-
1120{-
1121 Q_D(QGridLayout);-
1122 d->deleteAll();-
1123}
never executed: end of block
0
1124-
1125/*!-
1126 \property QGridLayout::horizontalSpacing-
1127 \brief the spacing between widgets that are laid out side by side-
1128 \since 4.3-
1129-
1130 If no value is explicitly set, the layout's horizontal spacing is-
1131 inherited from the parent layout, or from the style settings for-
1132 the parent widget.-
1133-
1134 \sa verticalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing}-
1135*/-
1136void QGridLayout::setHorizontalSpacing(int spacing)-
1137{-
1138 Q_D(QGridLayout);-
1139 d->horizontalSpacing = spacing;-
1140 invalidate();-
1141}
never executed: end of block
0
1142-
1143int QGridLayout::horizontalSpacing() const-
1144{-
1145 Q_D(const QGridLayout);-
1146 if (d->horizontalSpacing >= 0) {
d->horizontalSpacing >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1147 return d->horizontalSpacing;
never executed: return d->horizontalSpacing;
0
1148 } else {-
1149 return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
never executed: return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
0
1150 }-
1151}-
1152-
1153/*!-
1154 \property QGridLayout::verticalSpacing-
1155 \brief the spacing between widgets that are laid out on top of each other-
1156 \since 4.3-
1157-
1158 If no value is explicitly set, the layout's vertical spacing is-
1159 inherited from the parent layout, or from the style settings for-
1160 the parent widget.-
1161-
1162 \sa horizontalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing}-
1163*/-
1164void QGridLayout::setVerticalSpacing(int spacing)-
1165{-
1166 Q_D(QGridLayout);-
1167 d->verticalSpacing = spacing;-
1168 invalidate();-
1169}
never executed: end of block
0
1170-
1171int QGridLayout::verticalSpacing() const-
1172{-
1173 Q_D(const QGridLayout);-
1174 if (d->verticalSpacing >= 0) {
d->verticalSpacing >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1175 return d->verticalSpacing;
never executed: return d->verticalSpacing;
0
1176 } else {-
1177 return qSmartSpacing(this, QStyle::PM_LayoutVerticalSpacing);
never executed: return qSmartSpacing(this, QStyle::PM_LayoutVerticalSpacing);
0
1178 }-
1179}-
1180-
1181/*!-
1182 This function sets both the vertical and horizontal spacing to-
1183 \a spacing.-
1184-
1185 \sa setVerticalSpacing(), setHorizontalSpacing()-
1186*/-
1187void QGridLayout::setSpacing(int spacing)-
1188{-
1189 Q_D(QGridLayout);-
1190 d->horizontalSpacing = d->verticalSpacing = spacing;-
1191 invalidate();-
1192}
never executed: end of block
0
1193-
1194/*!-
1195 If the vertical spacing is equal to the horizontal spacing,-
1196 this function returns that value; otherwise it return -1.-
1197-
1198 \sa setSpacing(), verticalSpacing(), horizontalSpacing()-
1199*/-
1200int QGridLayout::spacing() const-
1201{-
1202 int hSpacing = horizontalSpacing();-
1203 if (hSpacing == verticalSpacing()) {
hSpacing == verticalSpacing()Description
TRUEnever evaluated
FALSEnever evaluated
0
1204 return hSpacing;
never executed: return hSpacing;
0
1205 } else {-
1206 return -1;
never executed: return -1;
0
1207 }-
1208}-
1209-
1210/*!-
1211 Returns the number of rows in this grid.-
1212*/-
1213int QGridLayout::rowCount() const-
1214{-
1215 Q_D(const QGridLayout);-
1216 return d->numRows();
never executed: return d->numRows();
0
1217}-
1218-
1219/*!-
1220 Returns the number of columns in this grid.-
1221*/-
1222int QGridLayout::columnCount() const-
1223{-
1224 Q_D(const QGridLayout);-
1225 return d->numCols();
never executed: return d->numCols();
0
1226}-
1227-
1228/*!-
1229 \reimp-
1230*/-
1231QSize QGridLayout::sizeHint() const-
1232{-
1233 Q_D(const QGridLayout);-
1234 QSize result(d->sizeHint(horizontalSpacing(), verticalSpacing()));-
1235 int left, top, right, bottom;-
1236 d->effectiveMargins(&left, &top, &right, &bottom);-
1237 result += QSize(left + right, top + bottom);-
1238 return result;
never executed: return result;
0
1239}-
1240-
1241/*!-
1242 \reimp-
1243*/-
1244QSize QGridLayout::minimumSize() const-
1245{-
1246 Q_D(const QGridLayout);-
1247 QSize result(d->minimumSize(horizontalSpacing(), verticalSpacing()));-
1248 int left, top, right, bottom;-
1249 d->effectiveMargins(&left, &top, &right, &bottom);-
1250 result += QSize(left + right, top + bottom);-
1251 return result;
never executed: return result;
0
1252}-
1253-
1254/*!-
1255 \reimp-
1256*/-
1257QSize QGridLayout::maximumSize() const-
1258{-
1259 Q_D(const QGridLayout);-
1260-
1261 QSize s = d->maximumSize(horizontalSpacing(), verticalSpacing());-
1262 int left, top, right, bottom;-
1263 d->effectiveMargins(&left, &top, &right, &bottom);-
1264 s += QSize(left + right, top + bottom);-
1265 s = s.boundedTo(QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX));-
1266 if (alignment() & Qt::AlignHorizontal_Mask)
alignment() & ...orizontal_MaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
1267 s.setWidth(QLAYOUTSIZE_MAX);
never executed: s.setWidth(QLAYOUTSIZE_MAX);
0
1268 if (alignment() & Qt::AlignVertical_Mask)
alignment() & ...nVertical_MaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
1269 s.setHeight(QLAYOUTSIZE_MAX);
never executed: s.setHeight(QLAYOUTSIZE_MAX);
0
1270 return s;
never executed: return s;
0
1271}-
1272-
1273/*!-
1274 \reimp-
1275*/-
1276bool QGridLayout::hasHeightForWidth() const-
1277{-
1278 return const_cast<QGridLayout*>(this)->d_func()->hasHeightForWidth(horizontalSpacing(), verticalSpacing());
never executed: return const_cast<QGridLayout*>(this)->d_func()->hasHeightForWidth(horizontalSpacing(), verticalSpacing());
0
1279}-
1280-
1281/*!-
1282 \reimp-
1283*/-
1284int QGridLayout::heightForWidth(int w) const-
1285{-
1286 Q_D(const QGridLayout);-
1287 QGridLayoutPrivate *dat = const_cast<QGridLayoutPrivate *>(d);-
1288 return dat->heightForWidth(w, horizontalSpacing(), verticalSpacing());
never executed: return dat->heightForWidth(w, horizontalSpacing(), verticalSpacing());
0
1289}-
1290-
1291/*!-
1292 \reimp-
1293*/-
1294int QGridLayout::minimumHeightForWidth(int w) const-
1295{-
1296 Q_D(const QGridLayout);-
1297 QGridLayoutPrivate *dat = const_cast<QGridLayoutPrivate *>(d);-
1298 return dat->minimumHeightForWidth(w, horizontalSpacing(), verticalSpacing());
never executed: return dat->minimumHeightForWidth(w, horizontalSpacing(), verticalSpacing());
0
1299}-
1300-
1301/*!-
1302 \reimp-
1303*/-
1304int QGridLayout::count() const-
1305{-
1306 Q_D(const QGridLayout);-
1307 return d->count();
never executed: return d->count();
0
1308}-
1309-
1310-
1311/*!-
1312 \reimp-
1313*/-
1314QLayoutItem *QGridLayout::itemAt(int index) const-
1315{-
1316 Q_D(const QGridLayout);-
1317 return d->itemAt(index);
never executed: return d->itemAt(index);
0
1318}-
1319-
1320/*!-
1321 \since 4.4-
1322-
1323 Returns the layout item that occupies cell (\a row, \a column), or 0 if-
1324 the cell is empty.-
1325-
1326 \sa getItemPosition(), indexOf()-
1327*/-
1328QLayoutItem *QGridLayout::itemAtPosition(int row, int column) const-
1329{-
1330 Q_D(const QGridLayout);-
1331 int n = d->things.count();-
1332 for (int i = 0; i < n; ++i) {
i < nDescription
TRUEnever evaluated
FALSEnever evaluated
0
1333 QGridBox *box = d->things.at(i);-
1334 if (row >= box->row && row <= box->toRow(d->rr)
row >= box->rowDescription
TRUEnever evaluated
FALSEnever evaluated
row <= box->toRow(d->rr)Description
TRUEnever evaluated
FALSEnever evaluated
0
1335 && column >= box->col && column <= box->toCol(d->cc)) {
column >= box->colDescription
TRUEnever evaluated
FALSEnever evaluated
column <= box->toCol(d->cc)Description
TRUEnever evaluated
FALSEnever evaluated
0
1336 return box->item();
never executed: return box->item();
0
1337 }-
1338 }
never executed: end of block
0
1339 return 0;
never executed: return 0;
0
1340}-
1341-
1342/*!-
1343 \reimp-
1344*/-
1345QLayoutItem *QGridLayout::takeAt(int index)-
1346{-
1347 Q_D(QGridLayout);-
1348 return d->takeAt(index);
never executed: return d->takeAt(index);
0
1349}-
1350-
1351/*!-
1352 Returns the position information of the item with the given \a index.-
1353-
1354 The variables passed as \a row and \a column are updated with the position of the-
1355 item in the layout, and the \a rowSpan and \a columnSpan variables are updated-
1356 with the vertical and horizontal spans of the item.-
1357-
1358 \sa itemAtPosition(), itemAt()-
1359*/-
1360void QGridLayout::getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const-
1361{-
1362 Q_D(const QGridLayout);-
1363 d->getItemPosition(index, row, column, rowSpan, columnSpan);-
1364}
never executed: end of block
0
1365-
1366-
1367/*!-
1368 \reimp-
1369*/-
1370void QGridLayout::setGeometry(const QRect &rect)-
1371{-
1372 Q_D(QGridLayout);-
1373 if (d->isDirty() || rect != geometry()) {
d->isDirty()Description
TRUEnever evaluated
FALSEnever evaluated
rect != geometry()Description
TRUEnever evaluated
FALSEnever evaluated
0
1374 QRect cr = alignment() ? alignmentRect(rect) : rect;
alignment()Description
TRUEnever evaluated
FALSEnever evaluated
0
1375 d->distribute(cr, horizontalSpacing(), verticalSpacing());-
1376 QLayout::setGeometry(rect);-
1377 }
never executed: end of block
0
1378}
never executed: end of block
0
1379-
1380/*!-
1381 Returns the geometry of the cell with row \a row and column \a column-
1382 in the grid. Returns an invalid rectangle if \a row or \a column is-
1383 outside the grid.-
1384-
1385 \warning in the current version of Qt this function does not-
1386 return valid results until setGeometry() has been called, i.e.-
1387 after the parentWidget() is visible.-
1388*/-
1389QRect QGridLayout::cellRect(int row, int column) const-
1390{-
1391 Q_D(const QGridLayout);-
1392 return d->cellRect(row, column);
never executed: return d->cellRect(row, column);
0
1393}-
1394-
1395/*!-
1396 \reimp-
1397*/-
1398void QGridLayout::addItem(QLayoutItem *item)-
1399{-
1400 Q_D(QGridLayout);-
1401 int r, c;-
1402 d->getNextPos(r, c);-
1403 addItem(item, r, c);-
1404}
never executed: end of block
0
1405-
1406/*!-
1407 Adds \a item at position \a row, \a column, spanning \a rowSpan-
1408 rows and \a columnSpan columns, and aligns it according to \a-
1409 alignment. If \a rowSpan and/or \a columnSpan is -1, then the item-
1410 will extend to the bottom and/or right edge, respectively. The-
1411 layout takes ownership of the \a item.-
1412-
1413 \warning Do not use this function to add child layouts or child-
1414 widget items. Use addLayout() or addWidget() instead.-
1415*/-
1416void QGridLayout::addItem(QLayoutItem *item, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment)-
1417{-
1418 Q_D(QGridLayout);-
1419 QGridBox *b = new QGridBox(item);-
1420 b->setAlignment(alignment);-
1421 d->add(b, row, (rowSpan < 0) ? -1 : row + rowSpan - 1, column, (columnSpan < 0) ? -1 : column + columnSpan - 1);-
1422 invalidate();-
1423}
never executed: end of block
0
1424-
1425/*!-
1426 Adds the given \a widget to the cell grid at \a row, \a column. The-
1427 top-left position is (0, 0) by default.-
1428-
1429 The alignment is specified by \a alignment. The default-
1430 alignment is 0, which means that the widget fills the entire cell.-
1431-
1432*/-
1433void QGridLayout::addWidget(QWidget *widget, int row, int column, Qt::Alignment alignment)-
1434{-
1435 Q_D(QGridLayout);-
1436 if (!d->checkWidget(widget))
!d->checkWidget(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
1437 return;
never executed: return;
0
1438 if (row < 0 || column < 0) {
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
column < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1439 qWarning("QGridLayout: Cannot add %s/%s to %s/%s at row %d column %d",-
1440 widget->metaObject()->className(), widget->objectName().toLocal8Bit().data(),-
1441 metaObject()->className(), objectName().toLocal8Bit().data(), row, column);-
1442 return;
never executed: return;
0
1443 }-
1444 addChildWidget(widget);-
1445 QWidgetItem *b = QLayoutPrivate::createWidgetItem(this, widget);-
1446 addItem(b, row, column, 1, 1, alignment);-
1447}
never executed: end of block
0
1448-
1449/*!-
1450 \overload-
1451-
1452 This version adds the given \a widget to the cell grid, spanning-
1453 multiple rows/columns. The cell will start at \a fromRow, \a-
1454 fromColumn spanning \a rowSpan rows and \a columnSpan columns. The-
1455 \a widget will have the given \a alignment.-
1456-
1457 If \a rowSpan and/or \a columnSpan is -1, then the widget will-
1458 extend to the bottom and/or right edge, respectively.-
1459-
1460*/-
1461void QGridLayout::addWidget(QWidget *widget, int fromRow, int fromColumn,-
1462 int rowSpan, int columnSpan, Qt::Alignment alignment)-
1463{-
1464 Q_D(QGridLayout);-
1465 if (!d->checkWidget(widget))
!d->checkWidget(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
1466 return;
never executed: return;
0
1467 int toRow = (rowSpan < 0) ? -1 : fromRow + rowSpan - 1;
(rowSpan < 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1468 int toColumn = (columnSpan < 0) ? -1 : fromColumn + columnSpan - 1;
(columnSpan < 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1469 addChildWidget(widget);-
1470 QGridBox *b = new QGridBox(this, widget);-
1471 b->setAlignment(alignment);-
1472 d->add(b, fromRow, toRow, fromColumn, toColumn);-
1473 invalidate();-
1474}
never executed: end of block
0
1475-
1476/*!-
1477 \fn void QGridLayout::addWidget(QWidget *widget)-
1478-
1479 \overload-
1480 \internal-
1481*/-
1482-
1483/*!-
1484 Places the \a layout at position (\a row, \a column) in the grid. The-
1485 top-left position is (0, 0).-
1486-
1487 The alignment is specified by \a alignment. The default-
1488 alignment is 0, which means that the widget fills the entire cell.-
1489-
1490 A non-zero alignment indicates that the layout should not grow to-
1491 fill the available space but should be sized according to-
1492 sizeHint().-
1493-
1494-
1495 \a layout becomes a child of the grid layout.-
1496*/-
1497void QGridLayout::addLayout(QLayout *layout, int row, int column, Qt::Alignment alignment)-
1498{-
1499 Q_D(QGridLayout);-
1500 if (!d->checkLayout(layout))
!d->checkLayout(layout)Description
TRUEnever evaluated
FALSEnever evaluated
0
1501 return;
never executed: return;
0
1502 if (!adoptLayout(layout))
!adoptLayout(layout)Description
TRUEnever evaluated
FALSEnever evaluated
0
1503 return;
never executed: return;
0
1504 QGridBox *b = new QGridBox(layout);-
1505 b->setAlignment(alignment);-
1506 d->add(b, row, column);-
1507}
never executed: end of block
0
1508-
1509/*!-
1510 \overload-
1511 This version adds the layout \a layout to the cell grid, spanning multiple-
1512 rows/columns. The cell will start at \a row, \a column spanning \a-
1513 rowSpan rows and \a columnSpan columns.-
1514-
1515 If \a rowSpan and/or \a columnSpan is -1, then the layout will extend to the bottom-
1516 and/or right edge, respectively.-
1517*/-
1518void QGridLayout::addLayout(QLayout *layout, int row, int column,-
1519 int rowSpan, int columnSpan, Qt::Alignment alignment)-
1520{-
1521 Q_D(QGridLayout);-
1522 if (!d->checkLayout(layout))
!d->checkLayout(layout)Description
TRUEnever evaluated
FALSEnever evaluated
0
1523 return;
never executed: return;
0
1524 if (!adoptLayout(layout))
!adoptLayout(layout)Description
TRUEnever evaluated
FALSEnever evaluated
0
1525 return;
never executed: return;
0
1526 QGridBox *b = new QGridBox(layout);-
1527 b->setAlignment(alignment);-
1528 d->add(b, row, (rowSpan < 0) ? -1 : row + rowSpan - 1, column, (columnSpan < 0) ? -1 : column + columnSpan - 1);-
1529}
never executed: end of block
0
1530-
1531/*!-
1532 Sets the stretch factor of row \a row to \a stretch. The first row-
1533 is number 0.-
1534-
1535 The stretch factor is relative to the other rows in this grid.-
1536 Rows with a higher stretch factor take more of the available-
1537 space.-
1538-
1539 The default stretch factor is 0. If the stretch factor is 0 and no-
1540 other row in this table can grow at all, the row may still grow.-
1541-
1542 \sa rowStretch(), setRowMinimumHeight(), setColumnStretch()-
1543*/-
1544void QGridLayout::setRowStretch(int row, int stretch)-
1545{-
1546 Q_D(QGridLayout);-
1547 d->setRowStretch(row, stretch);-
1548 invalidate();-
1549}
never executed: end of block
0
1550-
1551/*!-
1552 Returns the stretch factor for row \a row.-
1553-
1554 \sa setRowStretch()-
1555*/-
1556int QGridLayout::rowStretch(int row) const-
1557{-
1558 Q_D(const QGridLayout);-
1559 return d->rowStretch(row);
never executed: return d->rowStretch(row);
0
1560}-
1561-
1562/*!-
1563 Returns the stretch factor for column \a column.-
1564-
1565 \sa setColumnStretch()-
1566*/-
1567int QGridLayout::columnStretch(int column) const-
1568{-
1569 Q_D(const QGridLayout);-
1570 return d->colStretch(column);
never executed: return d->colStretch(column);
0
1571}-
1572-
1573/*!-
1574 Sets the stretch factor of column \a column to \a stretch. The first-
1575 column is number 0.-
1576-
1577 The stretch factor is relative to the other columns in this grid.-
1578 Columns with a higher stretch factor take more of the available-
1579 space.-
1580-
1581 The default stretch factor is 0. If the stretch factor is 0 and no-
1582 other column in this table can grow at all, the column may still-
1583 grow.-
1584-
1585 An alternative approach is to add spacing using addItem() with a-
1586 QSpacerItem.-
1587-
1588 \sa columnStretch(), setRowStretch()-
1589*/-
1590void QGridLayout::setColumnStretch(int column, int stretch)-
1591{-
1592 Q_D(QGridLayout);-
1593 d->setColStretch(column, stretch);-
1594 invalidate();-
1595}
never executed: end of block
0
1596-
1597-
1598-
1599/*!-
1600 Sets the minimum height of row \a row to \a minSize pixels.-
1601-
1602 \sa rowMinimumHeight(), setColumnMinimumWidth()-
1603*/-
1604void QGridLayout::setRowMinimumHeight(int row, int minSize)-
1605{-
1606 Q_D(QGridLayout);-
1607 d->setRowMinimumHeight(row, minSize);-
1608 invalidate();-
1609}
never executed: end of block
0
1610-
1611/*!-
1612 Returns the minimum width set for row \a row.-
1613-
1614 \sa setRowMinimumHeight()-
1615*/-
1616int QGridLayout::rowMinimumHeight(int row) const-
1617{-
1618 Q_D(const QGridLayout);-
1619 return d->rowSpacing(row);
never executed: return d->rowSpacing(row);
0
1620}-
1621-
1622/*!-
1623 Sets the minimum width of column \a column to \a minSize pixels.-
1624-
1625 \sa columnMinimumWidth(), setRowMinimumHeight()-
1626*/-
1627void QGridLayout::setColumnMinimumWidth(int column, int minSize)-
1628{-
1629 Q_D(QGridLayout);-
1630 d->setColumnMinimumWidth(column, minSize);-
1631 invalidate();-
1632}
never executed: end of block
0
1633-
1634/*!-
1635 Returns the column spacing for column \a column.-
1636-
1637 \sa setColumnMinimumWidth()-
1638*/-
1639int QGridLayout::columnMinimumWidth(int column) const-
1640{-
1641 Q_D(const QGridLayout);-
1642 return d->colSpacing(column);
never executed: return d->colSpacing(column);
0
1643}-
1644-
1645/*!-
1646 \reimp-
1647*/-
1648Qt::Orientations QGridLayout::expandingDirections() const-
1649{-
1650 Q_D(const QGridLayout);-
1651 return d->expandingDirections(horizontalSpacing(), verticalSpacing());
never executed: return d->expandingDirections(horizontalSpacing(), verticalSpacing());
0
1652}-
1653-
1654/*!-
1655 Sets the grid's origin corner, i.e. position (0, 0), to \a corner.-
1656*/-
1657void QGridLayout::setOriginCorner(Qt::Corner corner)-
1658{-
1659 Q_D(QGridLayout);-
1660 d->setReversed(corner == Qt::BottomLeftCorner || corner == Qt::BottomRightCorner,-
1661 corner == Qt::TopRightCorner || corner == Qt::BottomRightCorner);-
1662}
never executed: end of block
0
1663-
1664/*!-
1665 Returns the corner that's used for the grid's origin, i.e. for-
1666 position (0, 0).-
1667*/-
1668Qt::Corner QGridLayout::originCorner() const-
1669{-
1670 Q_D(const QGridLayout);-
1671 if (d->horReversed()) {
d->horReversed()Description
TRUEnever evaluated
FALSEnever evaluated
0
1672 return d->verReversed() ? Qt::BottomRightCorner : Qt::TopRightCorner;
never executed: return d->verReversed() ? Qt::BottomRightCorner : Qt::TopRightCorner;
d->verReversed()Description
TRUEnever evaluated
FALSEnever evaluated
0
1673 } else {-
1674 return d->verReversed() ? Qt::BottomLeftCorner : Qt::TopLeftCorner;
never executed: return d->verReversed() ? Qt::BottomLeftCorner : Qt::TopLeftCorner;
d->verReversed()Description
TRUEnever evaluated
FALSEnever evaluated
0
1675 }-
1676}-
1677-
1678/*!-
1679 \reimp-
1680*/-
1681void QGridLayout::invalidate()-
1682{-
1683 Q_D(QGridLayout);-
1684 d->setDirty();-
1685 QLayout::invalidate();-
1686}
never executed: end of block
0
1687-
1688QT_END_NAMESPACE-
1689-
1690#include "moc_qgridlayout.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9