kernel/qboxlayout.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9static bool checkWidget(QLayout *layout, QWidget *widget) -
10{ -
11 if (!widget) {
partially evaluated: !widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15667
0-15667
12 QMessageLogger("kernel/qboxlayout.cpp", 61, __PRETTY_FUNCTION__).warning("QLayout: Cannot add null widget to %s/%s", layout->metaObject()->className(), -
13 layout->objectName().toLocal8Bit().data()); -
14 return false;
never executed: return false;
0
15 } -
16 return true;
executed: return true;
Execution Count:15667
15667
17} -
18 -
19struct QBoxLayoutItem -
20{ -
21 QBoxLayoutItem(QLayoutItem *it, int stretch_ = 0) -
22 : item(it), stretch(stretch_), magic(false) { }
executed: }
Execution Count:18202
18202
23 ~QBoxLayoutItem() { delete item; }
executed: }
Execution Count:16892
16892
24 -
25 int hfw(int w) { -
26 if (item->hasHeightForWidth()) {
evaluated: item->hasHeightForWidth()
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:38
38-92
27 return item->heightForWidth(w);
executed: return item->heightForWidth(w);
Execution Count:92
92
28 } else { -
29 return item->sizeHint().height();
executed: return item->sizeHint().height();
Execution Count:38
38
30 } -
31 } -
32 int mhfw(int w) { -
33 if (item->hasHeightForWidth()) {
evaluated: item->hasHeightForWidth()
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:38
38-92
34 return item->heightForWidth(w);
executed: return item->heightForWidth(w);
Execution Count:92
92
35 } else { -
36 return item->minimumSize().height();
executed: return item->minimumSize().height();
Execution Count:38
38
37 } -
38 } -
39 int hStretch() { -
40 if (stretch == 0 && item->widget()) {
partially evaluated: stretch == 0
TRUEFALSE
yes
Evaluation Count:7941
no
Evaluation Count:0
evaluated: item->widget()
TRUEFALSE
yes
Evaluation Count:7079
yes
Evaluation Count:862
0-7941
41 return item->widget()->sizePolicy().horizontalStretch();
executed: return item->widget()->sizePolicy().horizontalStretch();
Execution Count:7079
7079
42 } else { -
43 return stretch;
executed: return stretch;
Execution Count:862
862
44 } -
45 } -
46 int vStretch() { -
47 if (stretch == 0 && item->widget()) {
partially evaluated: stretch == 0
TRUEFALSE
yes
Evaluation Count:6920
no
Evaluation Count:0
evaluated: item->widget()
TRUEFALSE
yes
Evaluation Count:5141
yes
Evaluation Count:1779
0-6920
48 return item->widget()->sizePolicy().verticalStretch();
executed: return item->widget()->sizePolicy().verticalStretch();
Execution Count:5141
5141
49 } else { -
50 return stretch;
executed: return stretch;
Execution Count:1779
1779
51 } -
52 } -
53 -
54 QLayoutItem *item; -
55 int stretch; -
56 bool magic; -
57}; -
58 -
59class QBoxLayoutPrivate : public QLayoutPrivate -
60{ -
61 inline QBoxLayout* q_func() { return static_cast<QBoxLayout *>(q_ptr); } inline const QBoxLayout* q_func() const { return static_cast<const QBoxLayout *>(q_ptr); } friend class QBoxLayout; -
62public: -
63 QBoxLayoutPrivate() : hfwWidth(-1), dirty(true), spacing(-1) { }
executed: }
Execution Count:12513
12513
64 ~QBoxLayoutPrivate(); -
65 -
66 void setDirty() { -
67 geomArray.clear(); -
68 hfwWidth = -1; -
69 hfwHeight = -1; -
70 dirty = true; -
71 }
executed: }
Execution Count:79457
79457
72 -
73 QList<QBoxLayoutItem *> list; -
74 QVector<QLayoutStruct> geomArray; -
75 int hfwWidth; -
76 int hfwHeight; -
77 int hfwMinHeight; -
78 QSize sizeHint; -
79 QSize minSize; -
80 QSize maxSize; -
81 int leftMargin, topMargin, rightMargin, bottomMargin; -
82 Qt::Orientations expanding; -
83 uint hasHfw : 1; -
84 uint dirty : 1; -
85 QBoxLayout::Direction dir; -
86 int spacing; -
87 -
88 inline void deleteAll() { while (!list.isEmpty()) delete list.takeFirst(); }
executed: delete list.takeFirst();
Execution Count:14850
executed: }
Execution Count:11213
evaluated: !list.isEmpty()
TRUEFALSE
yes
Evaluation Count:14850
yes
Evaluation Count:11213
11213-14850
89 -
90 void setupGeom(); -
91 void calcHfw(int); -
92 -
93 void effectiveMargins(int *left, int *top, int *right, int *bottom) const; -
94}; -
95 -
96QBoxLayoutPrivate::~QBoxLayoutPrivate() -
97{ -
98} -
99 -
100static inline bool horz(QBoxLayout::Direction dir) -
101{ -
102 return dir == QBoxLayout::RightToLeft || dir == QBoxLayout::LeftToRight;
executed: return dir == QBoxLayout::RightToLeft || dir == QBoxLayout::LeftToRight;
Execution Count:44564
44564
103} -
104 -
105 -
106 -
107 -
108 -
109 -
110void QBoxLayoutPrivate::effectiveMargins(int *left, int *top, int *right, int *bottom) const -
111{ -
112 int l = leftMargin; -
113 int t = topMargin; -
114 int r = rightMargin; -
115 int b = bottomMargin; -
116 if (left)
evaluated: left
TRUEFALSE
yes
Evaluation Count:11265
yes
Evaluation Count:17
17-11265
117 *left = l;
executed: *left = l;
Execution Count:11265
11265
118 if (top)
partially evaluated: top
TRUEFALSE
yes
Evaluation Count:11282
no
Evaluation Count:0
0-11282
119 *top = t;
executed: *top = t;
Execution Count:11282
11282
120 if (right)
evaluated: right
TRUEFALSE
yes
Evaluation Count:11265
yes
Evaluation Count:17
17-11265
121 *right = r;
executed: *right = r;
Execution Count:11265
11265
122 if (bottom)
partially evaluated: bottom
TRUEFALSE
yes
Evaluation Count:11282
no
Evaluation Count:0
0-11282
123 *bottom = b;
executed: *bottom = b;
Execution Count:11282
11282
124}
executed: }
Execution Count:11282
11282
125 -
126 -
127 -
128 -
129 -
130 -
131void QBoxLayoutPrivate::setupGeom() -
132{ -
133 if (!dirty)
partially evaluated: !dirty
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6458
0-6458
134 return;
never executed: return;
0
135 -
136 QBoxLayout * const q = q_func(); -
137 int maxw = horz(dir) ? 0 : QLAYOUTSIZE_MAX;
evaluated: horz(dir)
TRUEFALSE
yes
Evaluation Count:2653
yes
Evaluation Count:3805
2653-3805
138 int maxh = horz(dir) ? QLAYOUTSIZE_MAX : 0;
evaluated: horz(dir)
TRUEFALSE
yes
Evaluation Count:2653
yes
Evaluation Count:3805
2653-3805
139 int minw = 0; -
140 int minh = 0; -
141 int hintw = 0; -
142 int hinth = 0; -
143 -
144 bool horexp = false; -
145 bool verexp = false; -
146 -
147 hasHfw = false; -
148 -
149 int n = list.count(); -
150 geomArray.clear(); -
151 QVector<QLayoutStruct> a(n); -
152 -
153 QSizePolicy::ControlTypes controlTypes1; -
154 QSizePolicy::ControlTypes controlTypes2; -
155 int fixedSpacing = q->spacing(); -
156 int previousNonEmptyIndex = -1; -
157 -
158 QStyle *style = 0; -
159 if (fixedSpacing < 0) {
evaluated: fixedSpacing < 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:6453
5-6453
160 if (QWidget *parentWidget = q->parentWidget())
partially evaluated: QWidget *parentWidget = q->parentWidget()
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
161 style = parentWidget->style();
executed: style = parentWidget->style();
Execution Count:5
5
162 }
executed: }
Execution Count:5
5
163 -
164 for (int i = 0; i < n; i++) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:15309
yes
Evaluation Count:6458
6458-15309
165 QBoxLayoutItem *box = list.at(i); -
166 QSize max = box->item->maximumSize(); -
167 QSize min = box->item->minimumSize(); -
168 QSize hint = box->item->sizeHint(); -
169 Qt::Orientations exp = box->item->expandingDirections(); -
170 bool empty = box->item->isEmpty(); -
171 int spacing = 0; -
172 -
173 if (!empty) {
evaluated: !empty
TRUEFALSE
yes
Evaluation Count:10418
yes
Evaluation Count:4891
4891-10418
174 if (fixedSpacing >= 0) {
evaluated: fixedSpacing >= 0
TRUEFALSE
yes
Evaluation Count:10388
yes
Evaluation Count:30
30-10388
175 spacing = (previousNonEmptyIndex >= 0) ? fixedSpacing : 0;
evaluated: (previousNonEmptyIndex >= 0)
TRUEFALSE
yes
Evaluation Count:4268
yes
Evaluation Count:6120
4268-6120
176 } else {
executed: }
Execution Count:10388
10388
177 controlTypes1 = controlTypes2; -
178 controlTypes2 = box->item->controlTypes(); -
179 if (previousNonEmptyIndex >= 0) {
evaluated: previousNonEmptyIndex >= 0
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:5
5-25
180 QSizePolicy::ControlTypes actual1 = controlTypes1; -
181 QSizePolicy::ControlTypes actual2 = controlTypes2; -
182 if (dir == QBoxLayout::RightToLeft || dir == QBoxLayout::BottomToTop)
partially evaluated: dir == QBoxLayout::RightToLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
partially evaluated: dir == QBoxLayout::BottomToTop
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
183 qSwap(actual1, actual2);
never executed: qSwap(actual1, actual2);
0
184 -
185 if (style) {
partially evaluated: style
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
186 spacing = style->combinedLayoutSpacing(actual1, actual2, -
187 horz(dir) ? Qt::Horizontal : Qt::Vertical, -
188 0, q->parentWidget()); -
189 if (spacing < 0)
partially evaluated: spacing < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
190 spacing = 0;
never executed: spacing = 0;
0
191 }
executed: }
Execution Count:25
25
192 }
executed: }
Execution Count:25
25
193 }
executed: }
Execution Count:30
30
194 -
195 if (previousNonEmptyIndex >= 0)
evaluated: previousNonEmptyIndex >= 0
TRUEFALSE
yes
Evaluation Count:4293
yes
Evaluation Count:6125
4293-6125
196 a[previousNonEmptyIndex].spacing = spacing;
executed: a[previousNonEmptyIndex].spacing = spacing;
Execution Count:4293
4293
197 previousNonEmptyIndex = i; -
198 }
executed: }
Execution Count:10418
10418
199 -
200 bool ignore = empty && box->item->widget();
evaluated: empty
TRUEFALSE
yes
Evaluation Count:4891
yes
Evaluation Count:10418
evaluated: box->item->widget()
TRUEFALSE
yes
Evaluation Count:1915
yes
Evaluation Count:2976
1915-10418
201 bool dummy = true; -
202 if (horz(dir)) {
evaluated: horz(dir)
TRUEFALSE
yes
Evaluation Count:8386
yes
Evaluation Count:6923
6923-8386
203 bool expand = (exp & Qt::Horizontal || box->stretch > 0);
evaluated: exp & Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:1207
yes
Evaluation Count:7179
partially evaluated: box->stretch > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7179
0-7179
204 horexp = horexp || expand;
evaluated: horexp
TRUEFALSE
yes
Evaluation Count:3578
yes
Evaluation Count:4808
evaluated: expand
TRUEFALSE
yes
Evaluation Count:959
yes
Evaluation Count:3849
959-4808
205 maxw += spacing + max.width(); -
206 minw += spacing + min.width(); -
207 hintw += spacing + hint.width(); -
208 if (!ignore)
evaluated: !ignore
TRUEFALSE
yes
Evaluation Count:7423
yes
Evaluation Count:963
963-7423
209 qMaxExpCalc(maxh, verexp, dummy, 7423
210 max.height(), exp & Qt::Vertical, box->item->isEmpty());
executed: qMaxExpCalc(maxh, verexp, dummy, max.height(), exp & Qt::Vertical, box->item->isEmpty());
Execution Count:7423
7423
211 minh = qMax(minh, min.height()); -
212 hinth = qMax(hinth, hint.height()); -
213 -
214 a[i].sizeHint = hint.width(); -
215 a[i].maximumSize = max.width(); -
216 a[i].minimumSize = min.width(); -
217 a[i].expansive = expand; -
218 a[i].stretch = box->stretch ? box->stretch : box->hStretch();
evaluated: box->stretch
TRUEFALSE
yes
Evaluation Count:445
yes
Evaluation Count:7941
445-7941
219 } else {
executed: }
Execution Count:8386
8386
220 bool expand = (exp & Qt::Vertical || box->stretch > 0);
evaluated: exp & Qt::Vertical
TRUEFALSE
yes
Evaluation Count:1374
yes
Evaluation Count:5549
partially evaluated: box->stretch > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5549
0-5549
221 verexp = verexp || expand;
evaluated: verexp
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:6835
evaluated: expand
TRUEFALSE
yes
Evaluation Count:1371
yes
Evaluation Count:5464
88-6835
222 maxh += spacing + max.height(); -
223 minh += spacing + min.height(); -
224 hinth += spacing + hint.height(); -
225 if (!ignore)
evaluated: !ignore
TRUEFALSE
yes
Evaluation Count:5971
yes
Evaluation Count:952
952-5971
226 qMaxExpCalc(maxw, horexp, dummy, 5971
227 max.width(), exp & Qt::Horizontal, box->item->isEmpty());
executed: qMaxExpCalc(maxw, horexp, dummy, max.width(), exp & Qt::Horizontal, box->item->isEmpty());
Execution Count:5971
5971
228 minw = qMax(minw, min.width()); -
229 hintw = qMax(hintw, hint.width()); -
230 -
231 a[i].sizeHint = hint.height(); -
232 a[i].maximumSize = max.height(); -
233 a[i].minimumSize = min.height(); -
234 a[i].expansive = expand; -
235 a[i].stretch = box->stretch ? box->stretch : box->vStretch();
evaluated: box->stretch
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:6920
3-6920
236 }
executed: }
Execution Count:6923
6923
237 -
238 a[i].empty = empty; -
239 a[i].spacing = 0; -
240 hasHfw = hasHfw || box->item->hasHeightForWidth();
evaluated: hasHfw
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:15289
evaluated: box->item->hasHeightForWidth()
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:15247
20-15289
241 }
executed: }
Execution Count:15309
15309
242 -
243 geomArray = a; -
244 -
245 expanding = (Qt::Orientations) -
246 ((horexp ? Qt::Horizontal : 0) -
247 | (verexp ? Qt::Vertical : 0)); -
248 -
249 minSize = QSize(minw, minh); -
250 maxSize = QSize(maxw, maxh).expandedTo(minSize); -
251 sizeHint = QSize(hintw, hinth).expandedTo(minSize).boundedTo(maxSize); -
252 -
253 q->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); -
254 int left, top, right, bottom; -
255 effectiveMargins(&left, &top, &right, &bottom); -
256 QSize extra(left + right, top + bottom); -
257 -
258 minSize += extra; -
259 maxSize += extra; -
260 sizeHint += extra; -
261 -
262 dirty = false; -
263}
executed: }
Execution Count:6458
6458
264 -
265 -
266 -
267 -
268void QBoxLayoutPrivate::calcHfw(int w) -
269{ -
270 QVector<QLayoutStruct> &a = geomArray; -
271 int n = a.count(); -
272 int h = 0; -
273 int mh = 0; -
274 -
275 qt_noop(); -
276 -
277 if (horz(dir)) {
partially evaluated: horz(dir)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:92
0-92
278 qGeomCalc(a, 0, n, 0, w); -
279 for (int i = 0; i < n; i++) {
never evaluated: i < n
0
280 QBoxLayoutItem *box = list.at(i); -
281 h = qMax(h, box->hfw(a.at(i).size)); -
282 mh = qMax(mh, box->mhfw(a.at(i).size)); -
283 }
never executed: }
0
284 } else {
never executed: }
0
285 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:130
yes
Evaluation Count:92
92-130
286 QBoxLayoutItem *box = list.at(i); -
287 int spacing = a.at(i).spacing; -
288 h += box->hfw(w); -
289 mh += box->mhfw(w); -
290 h += spacing; -
291 mh += spacing; -
292 }
executed: }
Execution Count:130
130
293 }
executed: }
Execution Count:92
92
294 hfwWidth = w; -
295 hfwHeight = h; -
296 hfwMinHeight = mh; -
297}
executed: }
Execution Count:92
92
298QBoxLayout::QBoxLayout(Direction dir, QWidget *parent) -
299 : QLayout(*new QBoxLayoutPrivate, 0, parent) -
300{ -
301 QBoxLayoutPrivate * const d = d_func(); -
302 d->dir = dir; -
303}
executed: }
Execution Count:12513
12513
304QBoxLayout::~QBoxLayout() -
305{ -
306 QBoxLayoutPrivate * const d = d_func(); -
307 d->deleteAll(); -
308}
executed: }
Execution Count:11213
11213
309int QBoxLayout::spacing() const -
310{ -
311 const QBoxLayoutPrivate * const d = d_func(); -
312 if (d->spacing >=0) {
evaluated: d->spacing >=0
TRUEFALSE
yes
Evaluation Count:4586
yes
Evaluation Count:2240
2240-4586
313 return d->spacing;
executed: return d->spacing;
Execution Count:4586
4586
314 } else { -
315 return qSmartSpacing(this, d->dir == LeftToRight || d->dir == RightToLeft 2240
316 ? QStyle::PM_LayoutHorizontalSpacing 2240
317 : QStyle::PM_LayoutVerticalSpacing);
executed: return qSmartSpacing(this, d->dir == LeftToRight || d->dir == RightToLeft ? QStyle::PM_LayoutHorizontalSpacing : QStyle::PM_LayoutVerticalSpacing);
Execution Count:2240
2240
318 } -
319} -
320 -
321 -
322 -
323 -
324 -
325 -
326 -
327void QBoxLayout::setSpacing(int spacing) -
328{ -
329 QBoxLayoutPrivate * const d = d_func(); -
330 d->spacing = spacing; -
331 invalidate(); -
332}
executed: }
Execution Count:11366
11366
333 -
334 -
335 -
336 -
337QSize QBoxLayout::sizeHint() const -
338{ -
339 const QBoxLayoutPrivate * const d = d_func(); -
340 if (d->dirty)
evaluated: d->dirty
TRUEFALSE
yes
Evaluation Count:2171
yes
Evaluation Count:8493
2171-8493
341 const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
executed: const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
Execution Count:2171
2171
342 return d->sizeHint;
executed: return d->sizeHint;
Execution Count:10664
10664
343} -
344 -
345 -
346 -
347 -
348QSize QBoxLayout::minimumSize() const -
349{ -
350 const QBoxLayoutPrivate * const d = d_func(); -
351 if (d->dirty)
evaluated: d->dirty
TRUEFALSE
yes
Evaluation Count:1635
yes
Evaluation Count:4075
1635-4075
352 const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
executed: const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
Execution Count:1635
1635
353 return d->minSize;
executed: return d->minSize;
Execution Count:5710
5710
354} -
355 -
356 -
357 -
358 -
359QSize QBoxLayout::maximumSize() const -
360{ -
361 const QBoxLayoutPrivate * const d = d_func(); -
362 if (d->dirty)
evaluated: d->dirty
TRUEFALSE
yes
Evaluation Count:1288
yes
Evaluation Count:1123
1123-1288
363 const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
executed: const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
Execution Count:1288
1288
364 -
365 QSize s = d->maxSize.boundedTo(QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX)); -
366 -
367 if (alignment() & Qt::AlignHorizontal_Mask)
evaluated: alignment() & Qt::AlignHorizontal_Mask
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2410
1-2410
368 s.setWidth(QLAYOUTSIZE_MAX);
executed: s.setWidth(QLAYOUTSIZE_MAX);
Execution Count:1
1
369 if (alignment() & Qt::AlignVertical_Mask)
partially evaluated: alignment() & Qt::AlignVertical_Mask
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2411
0-2411
370 s.setHeight(QLAYOUTSIZE_MAX);
never executed: s.setHeight(QLAYOUTSIZE_MAX);
0
371 return s;
executed: return s;
Execution Count:2411
2411
372} -
373 -
374 -
375 -
376 -
377bool QBoxLayout::hasHeightForWidth() const -
378{ -
379 const QBoxLayoutPrivate * const d = d_func(); -
380 if (d->dirty)
evaluated: d->dirty
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:13646
144-13646
381 const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
executed: const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
Execution Count:144
144
382 return d->hasHfw;
executed: return d->hasHfw;
Execution Count:13790
13790
383} -
384 -
385 -
386 -
387 -
388int QBoxLayout::heightForWidth(int w) const -
389{ -
390 const QBoxLayoutPrivate * const d = d_func(); -
391 if (!hasHeightForWidth())
evaluated: !hasHeightForWidth()
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:149
19-149
392 return -1;
executed: return -1;
Execution Count:19
19
393 -
394 int left, top, right, bottom; -
395 d->effectiveMargins(&left, &top, &right, &bottom); -
396 -
397 w -= left + right; -
398 if (w != d->hfwWidth)
evaluated: w != d->hfwWidth
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:57
57-92
399 const_cast<QBoxLayout*>(this)->d_func()->calcHfw(w);
executed: const_cast<QBoxLayout*>(this)->d_func()->calcHfw(w);
Execution Count:92
92
400 -
401 return d->hfwHeight + top + bottom;
executed: return d->hfwHeight + top + bottom;
Execution Count:149
149
402} -
403 -
404 -
405 -
406 -
407int QBoxLayout::minimumHeightForWidth(int w) const -
408{ -
409 const QBoxLayoutPrivate * const d = d_func(); -
410 (void) heightForWidth(w); -
411 int top, bottom; -
412 d->effectiveMargins(0, &top, 0, &bottom); -
413 return d->hasHfw ? (d->hfwMinHeight + top + bottom) : -1;
executed: return d->hasHfw ? (d->hfwMinHeight + top + bottom) : -1;
Execution Count:17
17
414} -
415 -
416 -
417 -
418 -
419void QBoxLayout::invalidate() -
420{ -
421 QBoxLayoutPrivate * const d = d_func(); -
422 d->setDirty(); -
423 QLayout::invalidate(); -
424}
executed: }
Execution Count:79457
79457
425 -
426 -
427 -
428 -
429int QBoxLayout::count() const -
430{ -
431 const QBoxLayoutPrivate * const d = d_func(); -
432 return d->list.count();
executed: return d->list.count();
Execution Count:17150
17150
433} -
434 -
435 -
436 -
437 -
438QLayoutItem *QBoxLayout::itemAt(int index) const -
439{ -
440 const QBoxLayoutPrivate * const d = d_func(); -
441 return index >= 0 && index < d->list.count() ? d->list.at(index)->item : 0;
executed: return index >= 0 && index < d->list.count() ? d->list.at(index)->item : 0;
Execution Count:30797
30797
442} -
443 -
444 -
445 -
446 -
447QLayoutItem *QBoxLayout::takeAt(int index) -
448{ -
449 QBoxLayoutPrivate * const d = d_func(); -
450 if (index < 0 || index >= d->list.count())
partially evaluated: index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2042
partially evaluated: index >= d->list.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2042
0-2042
451 return 0;
never executed: return 0;
0
452 QBoxLayoutItem *b = d->list.takeAt(index); -
453 QLayoutItem *item = b->item; -
454 b->item = 0; -
455 delete b; -
456 -
457 if (QLayout *l = item->layout()) {
evaluated: QLayout *l = item->layout()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2041
1-2041
458 -
459 if (l->parent() == this)
partially evaluated: l->parent() == this
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
460 l->setParent(0);
executed: l->setParent(0);
Execution Count:1
1
461 }
executed: }
Execution Count:1
1
462 -
463 invalidate(); -
464 return item;
executed: return item;
Execution Count:2042
2042
465} -
466 -
467 -
468 -
469 -
470 -
471Qt::Orientations QBoxLayout::expandingDirections() const -
472{ -
473 const QBoxLayoutPrivate * const d = d_func(); -
474 if (d->dirty)
evaluated: d->dirty
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:6020
5-6020
475 const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
executed: const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
Execution Count:5
5
476 return d->expanding;
executed: return d->expanding;
Execution Count:6025
6025
477} -
478 -
479 -
480 -
481 -
482void QBoxLayout::setGeometry(const QRect &r) -
483{ -
484 QBoxLayoutPrivate * const d = d_func(); -
485 if (d->dirty || r != geometry()) {
evaluated: d->dirty
TRUEFALSE
yes
Evaluation Count:1215
yes
Evaluation Count:4877
evaluated: r != geometry()
TRUEFALSE
yes
Evaluation Count:3443
yes
Evaluation Count:1434
1215-4877
486 QRect oldRect = geometry(); -
487 QLayout::setGeometry(r); -
488 if (d->dirty)
evaluated: d->dirty
TRUEFALSE
yes
Evaluation Count:1215
yes
Evaluation Count:3443
1215-3443
489 d->setupGeom();
executed: d->setupGeom();
Execution Count:1215
1215
490 QRect cr = alignment() ? alignmentRect(r) : r;
evaluated: alignment()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4655
3-4655
491 -
492 int left, top, right, bottom; -
493 d->effectiveMargins(&left, &top, &right, &bottom); -
494 QRect s(cr.x() + left, cr.y() + top, -
495 cr.width() - (left + right), -
496 cr.height() - (top + bottom)); -
497 -
498 QVector<QLayoutStruct> a = d->geomArray; -
499 int pos = horz(d->dir) ? s.x() : s.y();
evaluated: horz(d->dir)
TRUEFALSE
yes
Evaluation Count:1880
yes
Evaluation Count:2778
1880-2778
500 int space = horz(d->dir) ? s.width() : s.height();
evaluated: horz(d->dir)
TRUEFALSE
yes
Evaluation Count:1880
yes
Evaluation Count:2778
1880-2778
501 int n = a.count(); -
502 if (d->hasHfw && !horz(d->dir)) {
evaluated: d->hasHfw
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:4624
partially evaluated: !horz(d->dir)
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-4624
503 for (int i = 0; i < n; i++) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:34
34-52
504 QBoxLayoutItem *box = d->list.at(i); -
505 if (box->item->hasHeightForWidth()) {
evaluated: box->item->hasHeightForWidth()
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:18
18-34
506 int width = qBound(box->item->minimumSize().width(), s.width(), box->item->maximumSize().width()); -
507 a[i].sizeHint = a[i].minimumSize = -
508 box->item->heightForWidth(width); -
509 }
executed: }
Execution Count:34
34
510 }
executed: }
Execution Count:52
52
511 }
executed: }
Execution Count:34
34
512 -
513 Direction visualDir = d->dir; -
514 QWidget *parent = parentWidget(); -
515 if (parent && parent->isRightToLeft()) {
partially evaluated: parent
TRUEFALSE
yes
Evaluation Count:4658
no
Evaluation Count:0
evaluated: parent->isRightToLeft()
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:4599
0-4658
516 if (d->dir == LeftToRight)
evaluated: d->dir == LeftToRight
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:23
23-36
517 visualDir = RightToLeft;
executed: visualDir = RightToLeft;
Execution Count:36
36
518 else if (d->dir == RightToLeft)
partially evaluated: d->dir == RightToLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
519 visualDir = LeftToRight;
never executed: visualDir = LeftToRight;
0
520 } -
521 -
522 qGeomCalc(a, 0, n, pos, space); -
523 -
524 bool reverse = (horz(visualDir)
evaluated: horz(visualDir)
TRUEFALSE
yes
Evaluation Count:1880
yes
Evaluation Count:2778
1880-2778
525 ? ((r.right() > oldRect.right()) != (visualDir == RightToLeft)) -
526 : r.bottom() > oldRect.bottom()); -
527 for (int j = 0; j < n; j++) {
evaluated: j < n
TRUEFALSE
yes
Evaluation Count:10794
yes
Evaluation Count:4658
4658-10794
528 int i = reverse ? n-j-1 : j;
evaluated: reverse
TRUEFALSE
yes
Evaluation Count:9640
yes
Evaluation Count:1154
1154-9640
529 QBoxLayoutItem *box = d->list.at(i); -
530 -
531 switch (visualDir) { -
532 case LeftToRight: -
533 box->item->setGeometry(QRect(a.at(i).pos, s.y(), a.at(i).size, s.height())); -
534 break;
executed: break;
Execution Count:6004
6004
535 case RightToLeft: -
536 box->item->setGeometry(QRect(s.left() + s.right() - a.at(i).pos - a.at(i).size + 1, -
537 s.y(), a.at(i).size, s.height())); -
538 break;
executed: break;
Execution Count:184
184
539 case TopToBottom: -
540 box->item->setGeometry(QRect(s.x(), a.at(i).pos, s.width(), a.at(i).size)); -
541 break;
executed: break;
Execution Count:4606
4606
542 case BottomToTop: -
543 box->item->setGeometry(QRect(s.x(), -
544 s.top() + s.bottom() - a.at(i).pos - a.at(i).size + 1, -
545 s.width(), a.at(i).size)); -
546 }
never executed: }
0
547 }
executed: }
Execution Count:10794
10794
548 }
executed: }
Execution Count:4658
4658
549}
executed: }
Execution Count:6092
6092
550 -
551 -
552 -
553 -
554void QBoxLayout::addItem(QLayoutItem *item) -
555{ -
556 QBoxLayoutPrivate * const d = d_func(); -
557 QBoxLayoutItem *it = new QBoxLayoutItem(item); -
558 d->list.append(it); -
559 invalidate(); -
560}
executed: }
Execution Count:219
219
561void QBoxLayout::insertItem(int index, QLayoutItem *item) -
562{ -
563 QBoxLayoutPrivate * const d = d_func(); -
564 if (index < 0)
never evaluated: index < 0
0
565 index = d->list.count();
never executed: index = d->list.count();
0
566 -
567 QBoxLayoutItem *it = new QBoxLayoutItem(item); -
568 d->list.insert(index, it); -
569 invalidate(); -
570}
never executed: }
0
571void QBoxLayout::insertSpacing(int index, int size) -
572{ -
573 QBoxLayoutPrivate * const d = d_func(); -
574 if (index < 0)
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:544
yes
Evaluation Count:339
339-544
575 index = d->list.count();
executed: index = d->list.count();
Execution Count:544
544
576 -
577 QLayoutItem *b; -
578 if (horz(d->dir))
evaluated: horz(d->dir)
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:812
71-812
579 b = QLayoutPrivate::createSpacerItem(this, size, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
executed: b = QLayoutPrivate::createSpacerItem(this, size, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
Execution Count:71
71
580 else -
581 b = QLayoutPrivate::createSpacerItem(this, 0, size, QSizePolicy::Minimum, QSizePolicy::Fixed);
executed: b = QLayoutPrivate::createSpacerItem(this, 0, size, QSizePolicy::Minimum, QSizePolicy::Fixed);
Execution Count:812
812
582 -
583 if (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:883
no
Evaluation Count:0
0-883
584 QBoxLayoutItem *it = new QBoxLayoutItem(b); -
585 it->magic = true; -
586 d->list.insert(index, it); -
587 -
588 } else {
executed: }
Execution Count:883
883
589 delete b; -
590 qt_noop(); -
591 }
never executed: }
0
592 invalidate(); -
593}
executed: }
Execution Count:883
883
594void QBoxLayout::insertStretch(int index, int stretch) -
595{ -
596 QBoxLayoutPrivate * const d = d_func(); -
597 if (index < 0)
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:1241
yes
Evaluation Count:54
54-1241
598 index = d->list.count();
executed: index = d->list.count();
Execution Count:1241
1241
599 -
600 QLayoutItem *b; -
601 if (horz(d->dir))
evaluated: horz(d->dir)
TRUEFALSE
yes
Evaluation Count:687
yes
Evaluation Count:608
608-687
602 b = QLayoutPrivate::createSpacerItem(this, 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
executed: b = QLayoutPrivate::createSpacerItem(this, 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
Execution Count:687
687
603 else -
604 b = QLayoutPrivate::createSpacerItem(this, 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
executed: b = QLayoutPrivate::createSpacerItem(this, 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
Execution Count:608
608
605 -
606 QBoxLayoutItem *it = new QBoxLayoutItem(b, stretch); -
607 it->magic = true; -
608 d->list.insert(index, it); -
609 invalidate(); -
610}
executed: }
Execution Count:1295
1295
611void QBoxLayout::insertSpacerItem(int index, QSpacerItem *spacerItem) -
612{ -
613 QBoxLayoutPrivate * const d = d_func(); -
614 if (index < 0)
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
615 index = d->list.count();
executed: index = d->list.count();
Execution Count:2
2
616 -
617 QBoxLayoutItem *it = new QBoxLayoutItem(spacerItem); -
618 it->magic = true; -
619 d->list.insert(index, it); -
620 invalidate(); -
621}
executed: }
Execution Count:3
3
622void QBoxLayout::insertLayout(int index, QLayout *layout, int stretch) -
623{ -
624 QBoxLayoutPrivate * const d = d_func(); -
625 addChildLayout(layout); -
626 if (index < 0)
partially evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:99
no
Evaluation Count:0
0-99
627 index = d->list.count();
executed: index = d->list.count();
Execution Count:99
99
628 QBoxLayoutItem *it = new QBoxLayoutItem(layout, stretch); -
629 d->list.insert(index, it); -
630 invalidate(); -
631}
executed: }
Execution Count:99
99
632void QBoxLayout::insertWidget(int index, QWidget *widget, int stretch, -
633 Qt::Alignment alignment) -
634{ -
635 QBoxLayoutPrivate * const d = d_func(); -
636 if (!checkWidget(this, widget))
partially evaluated: !checkWidget(this, widget)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15667
0-15667
637 return;
never executed: return;
0
638 addChildWidget(widget); -
639 if (index < 0)
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:15071
yes
Evaluation Count:596
596-15071
640 index = d->list.count();
executed: index = d->list.count();
Execution Count:15071
15071
641 QWidgetItem *b = QLayoutPrivate::createWidgetItem(this, widget); -
642 b->setAlignment(alignment); -
643 -
644 QBoxLayoutItem *it; -
645 if (true){
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:15667
no
Evaluation Count:0
0-15667
646 it = new QBoxLayoutItem(b, stretch); -
647 } else {
executed: }
Execution Count:15667
15667
648 delete b; -
649 qt_noop(); -
650 }
never executed: }
0
651 -
652 if (true){
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:15667
no
Evaluation Count:0
0-15667
653 d->list.insert(index, it); -
654 } else {
executed: }
Execution Count:15667
15667
655 delete it; -
656 qt_noop(); -
657 }
never executed: }
0
658 invalidate(); -
659}
executed: }
Execution Count:15667
15667
660void QBoxLayout::addSpacing(int size) -
661{ -
662 insertSpacing(-1, size); -
663}
executed: }
Execution Count:544
544
664 -
665 -
666 -
667 -
668 -
669 -
670 -
671void QBoxLayout::addStretch(int stretch) -
672{ -
673 insertStretch(-1, stretch); -
674}
executed: }
Execution Count:1241
1241
675void QBoxLayout::addSpacerItem(QSpacerItem *spacerItem) -
676{ -
677 insertSpacerItem(-1, spacerItem); -
678}
executed: }
Execution Count:2
2
679void QBoxLayout::addWidget(QWidget *widget, int stretch, Qt::Alignment alignment) -
680{ -
681 insertWidget(-1, widget, stretch, alignment); -
682}
executed: }
Execution Count:15071
15071
683 -
684 -
685 -
686 -
687 -
688 -
689 -
690void QBoxLayout::addLayout(QLayout *layout, int stretch) -
691{ -
692 insertLayout(-1, layout, stretch); -
693}
executed: }
Execution Count:99
99
694void QBoxLayout::addStrut(int size) -
695{ -
696 QBoxLayoutPrivate * const d = d_func(); -
697 QLayoutItem *b; -
698 if (horz(d->dir))
partially evaluated: horz(d->dir)
TRUEFALSE
yes
Evaluation Count:36
no
Evaluation Count:0
0-36
699 b = QLayoutPrivate::createSpacerItem(this, 0, size, QSizePolicy::Fixed, QSizePolicy::Minimum);
executed: b = QLayoutPrivate::createSpacerItem(this, 0, size, QSizePolicy::Fixed, QSizePolicy::Minimum);
Execution Count:36
36
700 else -
701 b = QLayoutPrivate::createSpacerItem(this, size, 0, QSizePolicy::Minimum, QSizePolicy::Fixed);
never executed: b = QLayoutPrivate::createSpacerItem(this, size, 0, QSizePolicy::Minimum, QSizePolicy::Fixed);
0
702 -
703 QBoxLayoutItem *it = new QBoxLayoutItem(b); -
704 it->magic = true; -
705 d->list.append(it); -
706 invalidate(); -
707}
executed: }
Execution Count:36
36
708bool QBoxLayout::setStretchFactor(QWidget *widget, int stretch) -
709{ -
710 QBoxLayoutPrivate * const d = d_func(); -
711 if (!widget)
never evaluated: !widget
0
712 return false;
never executed: return false;
0
713 for (int i = 0; i < d->list.size(); ++i) {
never evaluated: i < d->list.size()
0
714 QBoxLayoutItem *box = d->list.at(i); -
715 if (box->item->widget() == widget) {
never evaluated: box->item->widget() == widget
0
716 box->stretch = stretch; -
717 invalidate(); -
718 return true;
never executed: return true;
0
719 } -
720 }
never executed: }
0
721 return false;
never executed: return false;
0
722} -
723bool QBoxLayout::setStretchFactor(QLayout *layout, int stretch) -
724{ -
725 QBoxLayoutPrivate * const d = d_func(); -
726 for (int i = 0; i < d->list.size(); ++i) {
never evaluated: i < d->list.size()
0
727 QBoxLayoutItem *box = d->list.at(i); -
728 if (box->item->layout() == layout) {
never evaluated: box->item->layout() == layout
0
729 if (box->stretch != stretch) {
never evaluated: box->stretch != stretch
0
730 box->stretch = stretch; -
731 invalidate(); -
732 }
never executed: }
0
733 return true;
never executed: return true;
0
734 } -
735 }
never executed: }
0
736 return false;
never executed: return false;
0
737} -
738 -
739 -
740 -
741 -
742 -
743 -
744 -
745void QBoxLayout::setStretch(int index, int stretch) -
746{ -
747 QBoxLayoutPrivate * const d = d_func(); -
748 if (index >= 0 && index < d->list.size()) {
never evaluated: index >= 0
never evaluated: index < d->list.size()
0
749 QBoxLayoutItem *box = d->list.at(index); -
750 if (box->stretch != stretch) {
never evaluated: box->stretch != stretch
0
751 box->stretch = stretch; -
752 invalidate(); -
753 }
never executed: }
0
754 }
never executed: }
0
755}
never executed: }
0
756 -
757 -
758 -
759 -
760 -
761 -
762 -
763int QBoxLayout::stretch(int index) const -
764{ -
765 const QBoxLayoutPrivate * const d = d_func(); -
766 if (index >= 0 && index < d->list.size())
never evaluated: index >= 0
never evaluated: index < d->list.size()
0
767 return d->list.at(index)->stretch;
never executed: return d->list.at(index)->stretch;
0
768 return -1;
never executed: return -1;
0
769} -
770 -
771 -
772 -
773 -
774void QBoxLayout::setDirection(Direction direction) -
775{ -
776 QBoxLayoutPrivate * const d = d_func(); -
777 if (d->dir == direction)
never evaluated: d->dir == direction
0
778 return;
never executed: return;
0
779 if (horz(d->dir) != horz(direction)) {
never evaluated: horz(d->dir) != horz(direction)
0
780 -
781 -
782 -
783 -
784 for (int i = 0; i < d->list.size(); ++i) {
never evaluated: i < d->list.size()
0
785 QBoxLayoutItem *box = d->list.at(i); -
786 if (box->magic) {
never evaluated: box->magic
0
787 QSpacerItem *sp = box->item->spacerItem(); -
788 if (sp) {
never evaluated: sp
0
789 if (sp->expandingDirections() == Qt::Orientations(0) ) {
never evaluated: sp->expandingDirections() == Qt::Orientations(0)
0
790 -
791 QSize s = sp->sizeHint(); -
792 sp->changeSize(s.height(), s.width(), -
793 horz(direction) ? QSizePolicy::Fixed:QSizePolicy::Minimum, -
794 horz(direction) ? QSizePolicy::Minimum:QSizePolicy::Fixed); -
795 -
796 } else {
never executed: }
0
797 -
798 if (horz(direction))
never evaluated: horz(direction)
0
799 sp->changeSize(0, 0, QSizePolicy::Expanding, 0
800 QSizePolicy::Minimum);
never executed: sp->changeSize(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
0
801 else -
802 sp->changeSize(0, 0, QSizePolicy::Minimum, 0
803 QSizePolicy::Expanding);
never executed: sp->changeSize(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
0
804 } -
805 } -
806 }
never executed: }
0
807 }
never executed: }
0
808 }
never executed: }
0
809 d->dir = direction; -
810 invalidate(); -
811}
never executed: }
0
812QBoxLayout::Direction QBoxLayout::direction() const -
813{ -
814 const QBoxLayoutPrivate * const d = d_func(); -
815 return d->dir;
never executed: return d->dir;
0
816} -
817QHBoxLayout::QHBoxLayout(QWidget *parent) -
818 : QBoxLayout(LeftToRight, parent) -
819{ -
820}
executed: }
Execution Count:420
420
821 -
822 -
823 -
824 -
825 -
826QHBoxLayout::QHBoxLayout() -
827 : QBoxLayout(LeftToRight) -
828{ -
829}
executed: }
Execution Count:361
361
830QHBoxLayout::~QHBoxLayout() -
831{ -
832} -
833QVBoxLayout::QVBoxLayout(QWidget *parent) -
834 : QBoxLayout(TopToBottom, parent) -
835{ -
836}
executed: }
Execution Count:974
974
837 -
838 -
839 -
840 -
841 -
842 -
843QVBoxLayout::QVBoxLayout() -
844 : QBoxLayout(TopToBottom) -
845{ -
846}
executed: }
Execution Count:217
217
847 -
848 -
849 -
850 -
851 -
852 -
853 -
854QVBoxLayout::~QVBoxLayout() -
855{ -
856} -
857 -
858 -
859 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial