OpenCoverage

qboxlayout.cpp

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

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