qlayout.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qlayout.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5static int menuBarHeightForWidth(QWidget *menubar, int w)-
6{-
7 if (menubar
menubarDescription
TRUEnever evaluated
FALSEnever evaluated
&& !menubar->isHidden()
!menubar->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& !menubar->isWindow()
!menubar->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
8 int result = menubar->heightForWidth(qMax(w, menubar->minimumWidth()));-
9 if (result == -1
result == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
10 result = menubar->sizeHint().height();
never executed: result = menubar->sizeHint().height();
0
11 const int min = qSmartMinSize(menubar).height();-
12 result = qBound(min, result, menubar->maximumSize().height());-
13 if (result != -1
result != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
14 return
never executed: return result;
result;
never executed: return result;
0
15 }
never executed: end of block
0
16 return
never executed: return 0;
0;
never executed: return 0;
0
17}-
18QLayout::QLayout(QWidget *parent)-
19 : QObject(*new QLayoutPrivate, parent)-
20{-
21 if (!parent
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
22 return;
never executed: return;
0
23 parent->setLayout(this);-
24}
never executed: end of block
0
25-
26-
27-
28-
29-
30-
31-
32QLayout::QLayout()-
33 : QObject(*new QLayoutPrivate, 0)-
34{-
35}
never executed: end of block
0
36-
37-
38-
39-
40QLayout::QLayout(QLayoutPrivate &dd, QLayout *lay, QWidget *w)-
41 : QObject(dd, lay ? static_cast<QObject*>(lay) : static_cast<QObject*>(w))-
42{-
43 QLayoutPrivate * const d = d_func();-
44 if (lay
layDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
45 lay->addItem(this);-
46 }
never executed: end of block
else if (w
wDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
47 if (__builtin_expect(!!(w->layout()), false)
__builtin_expe...out()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
48 QMessageLogger(__FILE__, 139, __PRETTY_FUNCTION__).warning("QLayout: Attempting to add QLayout \"%ls\" to %s \"%ls\", which"-
49 " already has a layout",-
50 static_cast<const wchar_t*>(static_cast<const void*>(QString(QObject::objectName()).utf16())), w->metaObject()->className(),-
51 static_cast<const wchar_t*>(static_cast<const void*>(QString(w->objectName()).utf16())));-
52 setParent(0);-
53 }
never executed: end of block
else {
0
54 d->topLevel = true;-
55 w->d_func()->layout = this;-
56 if (true) {-
57 invalidate();-
58 }
never executed: end of block
else {
dead code: { w->d_func()->layout = 0; qt_noop(); }
-
59 w->d_func()->layout = 0;
dead code: { w->d_func()->layout = 0; qt_noop(); }
-
60 qt_noop();
dead code: { w->d_func()->layout = 0; qt_noop(); }
-
61 }
dead code: { w->d_func()->layout = 0; qt_noop(); }
-
62 }-
63 }-
64}
never executed: end of block
0
65-
66QLayoutPrivate::QLayoutPrivate()-
67 : QObjectPrivate(), insideSpacing(-1), userLeftMargin(-1), userTopMargin(-1), userRightMargin(-1),-
68 userBottomMargin(-1), topLevel(false), enabled(true), activated(true), autoNewChild(false),-
69 constraint(QLayout::SetDefaultConstraint), menubar(0)-
70{-
71}
never executed: end of block
0
72-
73void QLayoutPrivate::getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const-
74{-
75 if (!result
!resultDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
76 return;
never executed: return;
0
77-
78 const QLayout * const q = q_func();-
79 if (userMargin >= 0
userMargin >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
80 *result = userMargin;-
81 }
never executed: end of block
else if (!topLevel
!topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
82 *result = 0;-
83 }
never executed: end of block
else if (QWidget *pw = q->parentWidget()
QWidget *pw = ...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
84 *result = pw->style()->pixelMetric(pm, 0, pw);-
85 }
never executed: end of block
else {
0
86 *result = 0;-
87 }
never executed: end of block
0
88}-
89-
90-
91-
92QLayoutPrivate::QWidgetItemFactoryMethod QLayoutPrivate::widgetItemFactoryMethod = 0;-
93QLayoutPrivate::QSpacerItemFactoryMethod QLayoutPrivate::spacerItemFactoryMethod = 0;-
94-
95QWidgetItem *QLayoutPrivate::createWidgetItem(const QLayout *layout, QWidget *widget)-
96{-
97 if (widgetItemFactoryMethod
widgetItemFactoryMethodDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
98 if (QWidgetItem *wi = (*widgetItemFactoryMethod)(layout, widget)
QWidgetItem *w...ayout, widget)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
99 return
never executed: return wi;
wi;
never executed: return wi;
0
100 return
never executed: return new QWidgetItemV2(widget);
new QWidgetItemV2(widget);
never executed: return new QWidgetItemV2(widget);
0
101}-
102-
103QSpacerItem *QLayoutPrivate::createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy)-
104{-
105 if (spacerItemFactoryMethod
spacerItemFactoryMethodDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
106 if (QSpacerItem *si = (*spacerItemFactoryMethod)(layout, w, h, hPolicy, vPolicy)
QSpacerItem *s...licy, vPolicy)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
107 return
never executed: return si;
si;
never executed: return si;
0
108 return
never executed: return new QSpacerItem(w, h, hPolicy, vPolicy);
new QSpacerItem(w, h, hPolicy, vPolicy);
never executed: return new QSpacerItem(w, h, hPolicy, vPolicy);
0
109}-
110void QLayout::addWidget(QWidget *w)-
111{-
112 addChildWidget(w);-
113 addItem(QLayoutPrivate::createWidgetItem(this, w));-
114}
never executed: end of block
0
115bool QLayout::setAlignment(QWidget *w, Qt::Alignment alignment)-
116{-
117 int i = 0;-
118 QLayoutItem *item = itemAt(i);-
119 while (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
120 if (item->widget() == w
item->widget() == wDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
121 item->setAlignment(alignment);-
122 invalidate();-
123 return
never executed: return true;
true;
never executed: return true;
0
124 }-
125 ++i;-
126 item = itemAt(i);-
127 }
never executed: end of block
0
128 return
never executed: return false;
false;
never executed: return false;
0
129}-
130bool QLayout::setAlignment(QLayout *l, Qt::Alignment alignment)-
131{-
132 int i = 0;-
133 QLayoutItem *item = itemAt(i);-
134 while (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
135 if (item->layout() == l
item->layout() == lDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
136 item->setAlignment(alignment);-
137 invalidate();-
138 return
never executed: return true;
true;
never executed: return true;
0
139 }-
140 ++i;-
141 item = itemAt(i);-
142 }
never executed: end of block
0
143 return
never executed: return false;
false;
never executed: return false;
0
144}-
145int QLayout::margin() const-
146{-
147 int left, top, right, bottom;-
148 getContentsMargins(&left, &top, &right, &bottom);-
149 if (left == top
left == topDescription
TRUEnever evaluated
FALSEnever evaluated
&& top == right
top == rightDescription
TRUEnever evaluated
FALSEnever evaluated
&& right == bottom
right == bottomDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
150 return
never executed: return left;
left;
never executed: return left;
0
151 } else {-
152 return
never executed: return -1;
-1;
never executed: return -1;
0
153 }-
154}-
155int QLayout::spacing() const-
156{-
157 if (const
const QBoxLayo...Layout*>(this)Description
TRUEnever evaluated
FALSEnever evaluated
QBoxLayout* boxlayout = qobject_cast<const QBoxLayout*>(this)
const QBoxLayo...Layout*>(this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
158 return
never executed: return boxlayout->spacing();
boxlayout->spacing();
never executed: return boxlayout->spacing();
0
159 } else if (const
const QGridLay...Layout*>(this)Description
TRUEnever evaluated
FALSEnever evaluated
QGridLayout* gridlayout = qobject_cast<const QGridLayout*>(this)
const QGridLay...Layout*>(this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
160 return
never executed: return gridlayout->spacing();
gridlayout->spacing();
never executed: return gridlayout->spacing();
0
161 } else if (const
const QFormLay...Layout*>(this)Description
TRUEnever evaluated
FALSEnever evaluated
QFormLayout* formlayout = qobject_cast<const QFormLayout*>(this)
const QFormLay...Layout*>(this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
162 return
never executed: return formlayout->spacing();
formlayout->spacing();
never executed: return formlayout->spacing();
0
163 } else {-
164 const QLayoutPrivate * const d = d_func();-
165 if (d->insideSpacing >=0
d->insideSpacing >=0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
166 return
never executed: return d->insideSpacing;
d->insideSpacing;
never executed: return d->insideSpacing;
0
167 } else {-
168-
169 return
never executed: return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
never executed: return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
0
170 }-
171 }-
172}-
173-
174-
175-
176-
177void QLayout::setMargin(int margin)-
178{-
179 setContentsMargins(margin, margin, margin, margin);-
180}
never executed: end of block
0
181-
182void QLayout::setSpacing(int spacing)-
183{-
184 if (QBoxLayout* boxlayout = qobject_cast<QBoxLayout*>(this)
QBoxLayout* bo...Layout*>(this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
185 boxlayout->setSpacing(spacing);-
186 }
never executed: end of block
else if (QGridLayout* gridlayout = qobject_cast<QGridLayout*>(this)
QGridLayout* g...Layout*>(this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
187 gridlayout->setSpacing(spacing);-
188 }
never executed: end of block
else if (QFormLayout* formlayout = qobject_cast<QFormLayout*>(this)
QFormLayout* f...Layout*>(this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
189 formlayout->setSpacing(spacing);-
190 }
never executed: end of block
else {
0
191 QLayoutPrivate * const d = d_func();-
192 d->insideSpacing = spacing;-
193 invalidate();-
194 }
never executed: end of block
0
195}-
196void QLayout::setContentsMargins(int left, int top, int right, int bottom)-
197{-
198 QLayoutPrivate * const d = d_func();-
199-
200 if (d->userLeftMargin == left
d->userLeftMargin == leftDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->userTopMargin == top
d->userTopMargin == topDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
201 d->userRightMargin == right
d->userRightMargin == rightDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->userBottomMargin == bottom
d->userBottomMargin == bottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
202 return;
never executed: return;
0
203-
204 d->userLeftMargin = left;-
205 d->userTopMargin = top;-
206 d->userRightMargin = right;-
207 d->userBottomMargin = bottom;-
208 invalidate();-
209}
never executed: end of block
0
210void QLayout::setContentsMargins(const QMargins &margins)-
211{-
212 setContentsMargins(margins.left(), margins.top(), margins.right(), margins.bottom());-
213}
never executed: end of block
0
214void QLayout::getContentsMargins(int *left, int *top, int *right, int *bottom) const-
215{-
216 const QLayoutPrivate * const d = d_func();-
217 d->getMargin(left, d->userLeftMargin, QStyle::PM_LayoutLeftMargin);-
218 d->getMargin(top, d->userTopMargin, QStyle::PM_LayoutTopMargin);-
219 d->getMargin(right, d->userRightMargin, QStyle::PM_LayoutRightMargin);-
220 d->getMargin(bottom, d->userBottomMargin, QStyle::PM_LayoutBottomMargin);-
221}
never executed: end of block
0
222QMargins QLayout::contentsMargins() const-
223{-
224 int left, top, right, bottom;-
225 getContentsMargins(&left, &top, &right, &bottom);-
226 return
never executed: return QMargins(left, top, right, bottom);
QMargins(left, top, right, bottom);
never executed: return QMargins(left, top, right, bottom);
0
227}-
228QRect QLayout::contentsRect() const-
229{-
230 const QLayoutPrivate * const d = d_func();-
231 int left, top, right, bottom;-
232 getContentsMargins(&left, &top, &right, &bottom);-
233 return
never executed: return d->rect.adjusted(+left, +top, -right, -bottom);
d->rect.adjusted(+left, +top, -right, -bottom);
never executed: return d->rect.adjusted(+left, +top, -right, -bottom);
0
234}-
235QWidget *QLayout::parentWidget() const-
236{-
237 const QLayoutPrivate * const d = d_func();-
238 if (!d->topLevel
!d->topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
239 if (parent()
parent()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
240 QLayout *parentLayout = qobject_cast<QLayout*>(parent());-
241 if (__builtin_expect(!!(!parentLayout), false)
__builtin_expe...ayout), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
242 QMessageLogger(__FILE__, 479, __PRETTY_FUNCTION__).warning("QLayout::parentWidget: A layout can only have another layout as a parent.");-
243 return
never executed: return 0;
0;
never executed: return 0;
0
244 }-
245 return
never executed: return parentLayout->parentWidget();
parentLayout->parentWidget();
never executed: return parentLayout->parentWidget();
0
246 } else {-
247 return
never executed: return 0;
0;
never executed: return 0;
0
248 }-
249 } else {-
250 ((!(parent() && parent()->isWidgetType())) ? qt_assert("parent() && parent()->isWidgetType()",__FILE__,487) : qt_noop());-
251 return
never executed: return static_cast<QWidget *>(parent());
static_cast<QWidget *>(parent());
never executed: return static_cast<QWidget *>(parent());
0
252 }-
253}-
254-
255-
256-
257-
258bool QLayout::isEmpty() const-
259{-
260 int i = 0;-
261 QLayoutItem *item = itemAt(i);-
262 while (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
263 if (!item->isEmpty()
!item->isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
264 return
never executed: return false;
false;
never executed: return false;
0
265 ++i;-
266 item = itemAt(i);-
267 }
never executed: end of block
0
268 return
never executed: return true;
true;
never executed: return true;
0
269}-
270-
271-
272-
273-
274QSizePolicy::ControlTypes QLayout::controlTypes() const-
275{-
276 if (count() == 0
count() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
277 return
never executed: return QSizePolicy::DefaultType;
QSizePolicy::DefaultType;
never executed: return QSizePolicy::DefaultType;
0
278 QSizePolicy::ControlTypes types;-
279 for (int i = count() - 1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i)
0
280 types |= itemAt(i)->controlTypes();
never executed: types |= itemAt(i)->controlTypes();
0
281 return
never executed: return types;
types;
never executed: return types;
0
282}-
283-
284-
285-
286-
287void QLayout::setGeometry(const QRect &r)-
288{-
289 QLayoutPrivate * const d = d_func();-
290 d->rect = r;-
291}
never executed: end of block
0
292-
293-
294-
295-
296QRect QLayout::geometry() const-
297{-
298 const QLayoutPrivate * const d = d_func();-
299 return
never executed: return d->rect;
d->rect;
never executed: return d->rect;
0
300}-
301-
302-
303-
304-
305void QLayout::invalidate()-
306{-
307 QLayoutPrivate * const d = d_func();-
308 d->rect = QRect();-
309 update();-
310}
never executed: end of block
0
311-
312static bool removeWidgetRecursively(QLayoutItem *li, QObject *w)-
313{-
314 QLayout *lay = li->layout();-
315 if (!lay
!layDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
316 return
never executed: return false;
false;
never executed: return false;
0
317 int i = 0;-
318 QLayoutItem *child;-
319 while ((
(child = lay->itemAt(i))Description
TRUEnever evaluated
FALSEnever evaluated
child = lay->itemAt(i))
(child = lay->itemAt(i))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
320 if (child->widget() == w
child->widget() == wDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
321 delete lay->takeAt(i);-
322 lay->invalidate();-
323 return
never executed: return true;
true;
never executed: return true;
0
324 } else if (removeWidgetRecursively(child, w)
removeWidgetRe...vely(child, w)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
325 return
never executed: return true;
true;
never executed: return true;
0
326 } else {-
327 ++i;-
328 }
never executed: end of block
0
329 }-
330 return
never executed: return false;
false;
never executed: return false;
0
331}-
332-
333-
334void QLayoutPrivate::doResize(const QSize &r)-
335{-
336 QLayout * const q = q_func();-
337 int mbh = menuBarHeightForWidth(menubar, r.width());-
338 QWidget *mw = q->parentWidget();-
339 QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect)
mw->testAttrib...tOnEntireRect)Description
TRUEnever evaluated
FALSEnever evaluated
? mw->rect() : mw->contentsRect();
0
340 const int mbTop = rect.top();-
341 rect.setTop(rect.top() + mbh);-
342 q->setGeometry(rect);-
343-
344 if (menubar
menubarDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
345 menubar->setGeometry(rect.left(), mbTop, r.width(), mbh);
never executed: menubar->setGeometry(rect.left(), mbTop, r.width(), mbh);
0
346-
347}
never executed: end of block
0
348void QLayout::widgetEvent(QEvent *e)-
349{-
350 QLayoutPrivate * const d = d_func();-
351 if (!d->enabled
!d->enabledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
352 return;
never executed: return;
0
353-
354 switch (e->type()) {-
355 case
never executed: case QEvent::Resize:
QEvent::Resize:
never executed: case QEvent::Resize:
0
356 if (d->activated
d->activatedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
357 QResizeEvent *r = (QResizeEvent *)e;-
358 d->doResize(r->size());-
359 }
never executed: end of block
else {
0
360 activate();-
361 }
never executed: end of block
0
362 break;
never executed: break;
0
363 case
never executed: case QEvent::ChildRemoved:
QEvent::ChildRemoved:
never executed: case QEvent::ChildRemoved:
0
364 {-
365 QChildEvent *c = (QChildEvent *)e;-
366 if (c->child()->isWidgetType()
c->child()->isWidgetType()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
367-
368 if (c->child() == d->menubar
c->child() == d->menubarDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
369 d->menubar = 0;
never executed: d->menubar = 0;
0
370-
371 removeWidgetRecursively(this, c->child());-
372 }
never executed: end of block
0
373 }-
374 break;
never executed: break;
0
375 case
never executed: case QEvent::LayoutRequest:
QEvent::LayoutRequest:
never executed: case QEvent::LayoutRequest:
0
376 if (static_cast<
static_cast<QW...)->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
QWidget *>(parent())->isVisible()
static_cast<QW...)->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
377 activate();
never executed: activate();
0
378 break;
never executed: break;
0
379 default
never executed: default:
:
never executed: default:
0
380 break;
never executed: break;
0
381 }-
382}-
383-
384-
385-
386-
387void QLayout::childEvent(QChildEvent *e)-
388{-
389 QLayoutPrivate * const d = d_func();-
390 if (!d->enabled
!d->enabledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
391 return;
never executed: return;
0
392-
393 if (e->type() == QEvent::ChildRemoved
e->type() == Q...::ChildRemovedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
394 QChildEvent *c = (QChildEvent*)e;-
395 int i = 0;-
396-
397 QLayoutItem *item;-
398 while ((
(item = itemAt(i))Description
TRUEnever evaluated
FALSEnever evaluated
item = itemAt(i))
(item = itemAt(i))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
399 if (item == static_cast<QLayout*>(c->child())
item == static...*>(c->child())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
400 takeAt(i);-
401 invalidate();-
402 break;
never executed: break;
0
403 } else {-
404 ++i;-
405 }
never executed: end of block
0
406 }-
407 }
never executed: end of block
0
408}
never executed: end of block
0
409-
410-
411-
412-
413-
414int QLayout::totalHeightForWidth(int w) const-
415{-
416 const QLayoutPrivate * const d = d_func();-
417 int side=0, top=0;-
418 if (d->topLevel
d->topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
419 QWidget *parent = parentWidget();-
420 parent->ensurePolished();-
421 QWidgetPrivate *wd = parent->d_func();-
422 side += wd->leftmargin + wd->rightmargin;-
423 top += wd->topmargin + wd->bottommargin;-
424 }
never executed: end of block
0
425 int h = heightForWidth(w - side) + top;-
426-
427 h += menuBarHeightForWidth(d->menubar, w);-
428-
429 return
never executed: return h;
h;
never executed: return h;
0
430}-
431-
432-
433-
434-
435-
436QSize QLayout::totalMinimumSize() const-
437{-
438 const QLayoutPrivate * const d = d_func();-
439 int side=0, top=0;-
440 if (d->topLevel
d->topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
441 QWidget *pw = parentWidget();-
442 pw->ensurePolished();-
443 QWidgetPrivate *wd = pw->d_func();-
444 side += wd->leftmargin + wd->rightmargin;-
445 top += wd->topmargin + wd->bottommargin;-
446 }
never executed: end of block
0
447-
448 QSize s = minimumSize();-
449-
450 top += menuBarHeightForWidth(d->menubar, s.width() + side);-
451-
452 return
never executed: return s + QSize(side, top);
s + QSize(side, top);
never executed: return s + QSize(side, top);
0
453}-
454-
455-
456-
457-
458-
459QSize QLayout::totalSizeHint() const-
460{-
461 const QLayoutPrivate * const d = d_func();-
462 int side=0, top=0;-
463 if (d->topLevel
d->topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
464 QWidget *pw = parentWidget();-
465 pw->ensurePolished();-
466 QWidgetPrivate *wd = pw->d_func();-
467 side += wd->leftmargin + wd->rightmargin;-
468 top += wd->topmargin + wd->bottommargin;-
469 }
never executed: end of block
0
470-
471 QSize s = sizeHint();-
472 if (hasHeightForWidth()
hasHeightForWidth()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
473 s.setHeight(heightForWidth(s.width() + side));
never executed: s.setHeight(heightForWidth(s.width() + side));
0
474-
475 top += menuBarHeightForWidth(d->menubar, s.width());-
476-
477 return
never executed: return s + QSize(side, top);
s + QSize(side, top);
never executed: return s + QSize(side, top);
0
478}-
479-
480-
481-
482-
483-
484QSize QLayout::totalMaximumSize() const-
485{-
486 const QLayoutPrivate * const d = d_func();-
487 int side=0, top=0;-
488 if (d->topLevel
d->topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
489 QWidget *pw = parentWidget();-
490 pw->ensurePolished();-
491 QWidgetPrivate *wd = pw->d_func();-
492 side += wd->leftmargin + wd->rightmargin;-
493 top += wd->topmargin + wd->bottommargin;-
494 }
never executed: end of block
0
495-
496 QSize s = maximumSize();-
497-
498 top += menuBarHeightForWidth(d->menubar, s.width());-
499-
500-
501 if (d->topLevel
d->topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
502 s = QSize(qMin(s.width() + side, QLAYOUTSIZE_MAX),
never executed: s = QSize(qMin(s.width() + side, QLAYOUTSIZE_MAX), qMin(s.height() + top, QLAYOUTSIZE_MAX));
0
503 qMin(s.height() + top, QLAYOUTSIZE_MAX));
never executed: s = QSize(qMin(s.width() + side, QLAYOUTSIZE_MAX), qMin(s.height() + top, QLAYOUTSIZE_MAX));
0
504 return
never executed: return s;
s;
never executed: return s;
0
505}-
506QLayout::~QLayout()-
507{-
508 QLayoutPrivate * const d = d_func();-
509-
510-
511-
512-
513 if (d->topLevel
d->topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
&& parent()
parent()Description
TRUEnever evaluated
FALSEnever evaluated
&& parent()->isWidgetType()
parent()->isWidgetType()Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
514 ((
((QWidget*)par...yout() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
QWidget*)parent())->layout() == this
((QWidget*)par...yout() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
515 ((
never executed: ((QWidget*)parent())->d_func()->layout = 0;
QWidget*)parent())->d_func()->layout = 0;
never executed: ((QWidget*)parent())->d_func()->layout = 0;
0
516}
never executed: end of block
0
517void QLayout::addChildLayout(QLayout *l)-
518{-
519 if (__builtin_expect(!!(l->parent()), false)
__builtin_expe...ent()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
520 QMessageLogger(__FILE__, 785, __PRETTY_FUNCTION__).warning("QLayout::addChildLayout: layout \"%ls\" already has a parent",-
521 static_cast<const wchar_t*>(static_cast<const void*>(QString(l->objectName()).utf16())));-
522 return;
never executed: return;
0
523 }-
524 l->setParent(this);-
525-
526 if (QWidget *mw = parentWidget()
QWidget *mw = parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
527 l->d_func()->reparentChildWidgets(mw);-
528 }
never executed: end of block
0
529-
530}
never executed: end of block
0
531-
532-
533-
534-
535bool QLayout::adoptLayout(QLayout *layout)-
536{-
537 const bool ok = !layout->parent();-
538 addChildLayout(layout);-
539 return
never executed: return ok;
ok;
never executed: return ok;
0
540}-
541-
542-
543static bool layoutDebug()-
544{-
545 static int checked_env = -1;-
546 if(checked_env == -1
checked_env == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
547 checked_env = !!qgetenv("QT_LAYOUT_DEBUG").toInt();
never executed: checked_env = !!qgetenv("QT_LAYOUT_DEBUG").toInt();
0
548-
549 return
never executed: return checked_env;
checked_env;
never executed: return checked_env;
0
550}-
551-
552-
553void QLayoutPrivate::reparentChildWidgets(QWidget *mw)-
554{-
555 QLayout * const q = q_func();-
556 int n = q->count();-
557-
558-
559 if (menubar
menubarDescription
TRUEnever evaluated
FALSEnever evaluated
&& menubar->parentWidget() != mw
menubar->parentWidget() != mwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
560 menubar->setParent(mw);-
561 }
never executed: end of block
0
562-
563 bool mwVisible = mw
mwDescription
TRUEnever evaluated
FALSEnever evaluated
&& mw->isVisible()
mw->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
;
0
564 for (int i = 0; i < n
i < nDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
565 QLayoutItem *item = q->itemAt(i);-
566 if (QWidget *w = item->widget()
QWidget *w = item->widget()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
567 QWidget *pw = w->parentWidget();-
568-
569 if (__builtin_expect(!!(pw && pw != mw && layoutDebug()), false)
__builtin_expe...bug()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
570 QMessageLogger(__FILE__, 835, __PRETTY_FUNCTION__).warning("QLayout::addChildLayout: widget %s \"%ls\" in wrong parent; moved to correct parent",-
571 w->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(w->objectName()).utf16())));-
572 }
never executed: end of block
0
573-
574 bool needShow = mwVisible
mwVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
&& !(w->isHidden()
w->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& w->testAttribute(Qt::WA_WState_ExplicitShowHide)
w->testAttribu...licitShowHide)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
575 if (pw != mw
pw != mwDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
576 w->setParent(mw);
never executed: w->setParent(mw);
0
577 if (needShow
needShowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
578 QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection);
never executed: QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection);
0
579 }
never executed: end of block
else if (QLayout *l = item->layout()
QLayout *l = item->layout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
580 l->d_func()->reparentChildWidgets(mw);-
581 }
never executed: end of block
0
582 }
never executed: end of block
0
583}
never executed: end of block
0
584-
585-
586-
587-
588-
589bool QLayoutPrivate::checkWidget(QWidget *widget) const-
590{-
591 const QLayout * const q = q_func();-
592 if (__builtin_expect(!!(!widget), false)
__builtin_expe...idget), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
593 QMessageLogger(__FILE__, 858, __PRETTY_FUNCTION__).warning("QLayout: Cannot add a null widget to %s/%ls", q->metaObject()->className(),-
594 static_cast<const wchar_t*>(static_cast<const void*>(QString(q->objectName()).utf16())));-
595 return
never executed: return false;
false;
never executed: return false;
0
596 }-
597 if (__builtin_expect(!!(widget == q->parentWidget()), false)
__builtin_expe...get()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
598 QMessageLogger(__FILE__, 863, __PRETTY_FUNCTION__).warning("QLayout: Cannot add parent widget %s/%ls to its child layout %s/%ls",-
599 widget->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(widget->objectName()).utf16())),-
600 q->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(q->objectName()).utf16())));-
601 return
never executed: return false;
false;
never executed: return false;
0
602 }-
603 return
never executed: return true;
true;
never executed: return true;
0
604}-
605-
606-
607-
608-
609-
610bool QLayoutPrivate::checkLayout(QLayout *otherLayout) const-
611{-
612 const QLayout * const q = q_func();-
613 if (__builtin_expect(!!(!otherLayout), false)
__builtin_expe...ayout), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
614 QMessageLogger(__FILE__, 879, __PRETTY_FUNCTION__).warning("QLayout: Cannot add a null layout to %s/%ls",-
615 q->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(q->objectName()).utf16())));-
616 return
never executed: return false;
false;
never executed: return false;
0
617 }-
618 if (__builtin_expect(!!(otherLayout == q), false)
__builtin_expe... == q), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
619 QMessageLogger(__FILE__, 884, __PRETTY_FUNCTION__).warning("QLayout: Cannot add layout %s/%ls to itself",-
620 q->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(q->objectName()).utf16())));-
621 return
never executed: return false;
false;
never executed: return false;
0
622 }-
623 return
never executed: return true;
true;
never executed: return true;
0
624}-
625void QLayout::addChildWidget(QWidget *w)-
626{-
627 QWidget *mw = parentWidget();-
628 QWidget *pw = w->parentWidget();-
629-
630-
631-
632 if (pw
pwDescription
TRUEnever evaluated
FALSEnever evaluated
&& w->testAttribute(Qt::WA_LaidOut)
w->testAttribu...t::WA_LaidOut)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
633 QLayout *l = pw->layout();-
634 if (l
lDescription
TRUEnever evaluated
FALSEnever evaluated
&& removeWidgetRecursively(l, w)
removeWidgetRecursively(l, w)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
635-
636 if (__builtin_expect(!!(layoutDebug()), false)
__builtin_expe...bug()), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
637 QMessageLogger(__FILE__, 911, __PRETTY_FUNCTION__).warning("QLayout::addChildWidget: %s \"%ls\" is already in a layout; moved to new layout",
never executed: QMessageLogger(__FILE__, 911, __PRETTY_FUNCTION__).warning("QLayout::addChildWidget: %s \"%ls\" is already in a layout; moved to new layout", w->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(w->objectName()).utf16())));
0
638 w->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(w->objectName()).utf16())));
never executed: QMessageLogger(__FILE__, 911, __PRETTY_FUNCTION__).warning("QLayout::addChildWidget: %s \"%ls\" is already in a layout; moved to new layout", w->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(w->objectName()).utf16())));
0
639-
640 }
never executed: end of block
0
641 }
never executed: end of block
0
642 if (pw
pwDescription
TRUEnever evaluated
FALSEnever evaluated
&& mw
mwDescription
TRUEnever evaluated
FALSEnever evaluated
&& pw != mw
pw != mwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
643-
644 if (__builtin_expect(!!(layoutDebug()), false)
__builtin_expe...bug()), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
645 QMessageLogger(__FILE__, 919, __PRETTY_FUNCTION__).warning("QLayout::addChildWidget: %s \"%ls\" in wrong parent; moved to correct parent",
never executed: QMessageLogger(__FILE__, 919, __PRETTY_FUNCTION__).warning("QLayout::addChildWidget: %s \"%ls\" in wrong parent; moved to correct parent", w->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(w->objectName()).utf16())));
0
646 w->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(w->objectName()).utf16())));
never executed: QMessageLogger(__FILE__, 919, __PRETTY_FUNCTION__).warning("QLayout::addChildWidget: %s \"%ls\" in wrong parent; moved to correct parent", w->metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(w->objectName()).utf16())));
0
647-
648 pw = 0;-
649 }
never executed: end of block
0
650 bool needShow = mw
mwDescription
TRUEnever evaluated
FALSEnever evaluated
&& mw->isVisible()
mw->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
&& !(w->isHidden()
w->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& w->testAttribute(Qt::WA_WState_ExplicitShowHide)
w->testAttribu...licitShowHide)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
651 if (!pw
!pwDescription
TRUEnever evaluated
FALSEnever evaluated
&& mw
mwDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
652 w->setParent(mw);
never executed: w->setParent(mw);
0
653 w->setAttribute(Qt::WA_LaidOut);-
654 if (needShow
needShowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
655 QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection);
never executed: QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection);
0
656}
never executed: end of block
0
657void QLayout::setMenuBar(QWidget *widget)-
658{-
659 QLayoutPrivate * const d = d_func();-
660-
661-
662-
663-
664 if (widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
665-
666 addChildWidget(widget);
never executed: addChildWidget(widget);
0
667 d->menubar = widget;-
668}
never executed: end of block
0
669-
670-
671-
672-
673-
674-
675QWidget *QLayout::menuBar() const-
676{-
677 const QLayoutPrivate * const d = d_func();-
678 return
never executed: return d->menubar;
d->menubar;
never executed: return d->menubar;
0
679}-
680QSize QLayout::minimumSize() const-
681{-
682 return
never executed: return QSize(0, 0);
QSize(0, 0);
never executed: return QSize(0, 0);
0
683}-
684QSize QLayout::maximumSize() const-
685{-
686 return
never executed: return QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX);
QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX);
never executed: return QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX);
0
687}-
688Qt::Orientations QLayout::expandingDirections() const-
689{-
690 return
never executed: return Qt::Horizontal | Qt::Vertical;
Qt::Horizontal | Qt::Vertical;
never executed: return Qt::Horizontal | Qt::Vertical;
0
691}-
692-
693void QLayout::activateRecursiveHelper(QLayoutItem *item)-
694{-
695 item->invalidate();-
696 QLayout *layout = item->layout();-
697 if (layout
layoutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
698 QLayoutItem *child;-
699 int i=0;-
700 while ((
(child = layout->itemAt(i++))Description
TRUEnever evaluated
FALSEnever evaluated
child = layout->itemAt(i++))
(child = layout->itemAt(i++))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
701 activateRecursiveHelper(child);
never executed: activateRecursiveHelper(child);
0
702 layout->d_func()->activated = true;-
703 }
never executed: end of block
0
704}
never executed: end of block
0
705void QLayout::update()-
706{-
707 QLayout *layout = this;-
708 while (layout
layoutDescription
TRUEnever evaluated
FALSEnever evaluated
&& layout->d_func()->activated
layout->d_func()->activatedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
709 layout->d_func()->activated = false;-
710 if (layout->d_func()->topLevel
layout->d_func()->topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
711 ((!(layout->parent()->isWidgetType())) ? qt_assert("layout->parent()->isWidgetType()",__FILE__,1044) : qt_noop());-
712 QWidget *mw = static_cast<QWidget*>(layout->parent());-
713 QApplication::postEvent(mw, new QEvent(QEvent::LayoutRequest));-
714 break;
never executed: break;
0
715 }-
716 layout = static_cast<QLayout*>(layout->parent());-
717 }
never executed: end of block
0
718}
never executed: end of block
0
719bool QLayout::activate()-
720{-
721 QLayoutPrivate * const d = d_func();-
722 if (!d->enabled
!d->enabledDescription
TRUEnever evaluated
FALSEnever evaluated
|| !parent()
!parent()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
723 return
never executed: return false;
false;
never executed: return false;
0
724 if (!d->topLevel
!d->topLevelDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
725 return
never executed: return static_cast<QLayout*>(parent())->activate();
static_cast<QLayout*>(parent())->activate();
never executed: return static_cast<QLayout*>(parent())->activate();
0
726 if (d->activated
d->activatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
727 return
never executed: return false;
false;
never executed: return false;
0
728 QWidget *mw = static_cast<QWidget*>(parent());-
729 if (__builtin_expect(!!(!mw), false)
__builtin_expe...!(!mw), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
730 QMessageLogger(__FILE__, 1073, __PRETTY_FUNCTION__).warning("QLayout::activate: %s \"%ls\" does not have a main widget",-
731 metaObject()->className(), static_cast<const wchar_t*>(static_cast<const void*>(QString(objectName()).utf16())));-
732 return
never executed: return false;
false;
never executed: return false;
0
733 }-
734 activateRecursiveHelper(this);-
735-
736 QWidgetPrivate *md = mw->d_func();-
737 uint explMin = md->extra
md->extraDescription
TRUEnever evaluated
FALSEnever evaluated
? md->extra->explicitMinSize : 0;
0
738 uint explMax = md->extra
md->extraDescription
TRUEnever evaluated
FALSEnever evaluated
? md->extra->explicitMaxSize : 0;
0
739-
740 switch (d->constraint) {-
741 case
never executed: case SetFixedSize:
SetFixedSize:
never executed: case SetFixedSize:
0
742-
743 mw->setFixedSize(totalSizeHint());-
744 break;
never executed: break;
0
745 case
never executed: case SetMinimumSize:
SetMinimumSize:
never executed: case SetMinimumSize:
0
746 mw->setMinimumSize(totalMinimumSize());-
747 break;
never executed: break;
0
748 case
never executed: case SetMaximumSize:
SetMaximumSize:
never executed: case SetMaximumSize:
0
749 mw->setMaximumSize(totalMaximumSize());-
750 break;
never executed: break;
0
751 case
never executed: case SetMinAndMaxSize:
SetMinAndMaxSize:
never executed: case SetMinAndMaxSize:
0
752 mw->setMinimumSize(totalMinimumSize());-
753 mw->setMaximumSize(totalMaximumSize());-
754 break;
never executed: break;
0
755 case
never executed: case SetDefaultConstraint:
SetDefaultConstraint:
never executed: case SetDefaultConstraint:
{
0
756 bool widthSet = explMin & Qt::Horizontal;-
757 bool heightSet = explMin & Qt::Vertical;-
758 if (mw->isWindow()
mw->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
759 QSize ms = totalMinimumSize();-
760 if (widthSet
widthSetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
761 ms.setWidth(mw->minimumSize().width());
never executed: ms.setWidth(mw->minimumSize().width());
0
762 if (heightSet
heightSetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
763 ms.setHeight(mw->minimumSize().height());
never executed: ms.setHeight(mw->minimumSize().height());
0
764 mw->setMinimumSize(ms);-
765 }
never executed: end of block
else if (!widthSet
!widthSetDescription
TRUEnever evaluated
FALSEnever evaluated
|| !heightSet
!heightSetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
766 QSize ms = mw->minimumSize();-
767 if (!widthSet
!widthSetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
768 ms.setWidth(0);
never executed: ms.setWidth(0);
0
769 if (!heightSet
!heightSetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
770 ms.setHeight(0);
never executed: ms.setHeight(0);
0
771 mw->setMinimumSize(ms);-
772 }
never executed: end of block
0
773 break;
never executed: break;
0
774 }-
775 case
never executed: case SetNoConstraint:
SetNoConstraint:
never executed: case SetNoConstraint:
0
776 break;
never executed: break;
0
777 }-
778-
779 d->doResize(mw->size());-
780-
781 if (md->extra
md->extraDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
782 md->extra->explicitMinSize = explMin;-
783 md->extra->explicitMaxSize = explMax;-
784 }
never executed: end of block
0
785-
786 mw->updateGeometry();-
787 return
never executed: return true;
true;
never executed: return true;
0
788}-
789QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOptions options)-
790{-
791 QLayoutPrivate * const d = d_func();-
792 if (!from
!fromDescription
TRUEnever evaluated
FALSEnever evaluated
|| !to
!toDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
793 return
never executed: return 0;
0;
never executed: return 0;
0
794-
795 int index = -1;-
796 QLayoutItem *item = 0;-
797 for (int u = 0; u < count()
u < count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++u) {
0
798 item = itemAt(u);-
799 if (!item
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
800 continue;
never executed: continue;
0
801-
802 if (item->widget() == from
item->widget() == fromDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
803 index = u;-
804 break;
never executed: break;
0
805 }-
806-
807 if (item->layout()
item->layout()Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(options & Qt:...enRecursively)Description
TRUEnever evaluated
FALSEnever evaluated
options & Qt::FindChildrenRecursively)
(options & Qt:...enRecursively)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
808 QLayoutItem *r = item->layout()->replaceWidget(from, to, options);-
809 if (r
rDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
810 return
never executed: return r;
r;
never executed: return r;
0
811 }
never executed: end of block
0
812 }
never executed: end of block
0
813 if (index == -1
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
814 return
never executed: return 0;
0;
never executed: return 0;
0
815-
816 addChildWidget(to);-
817 QLayoutItem *newitem = new QWidgetItem(to);-
818 newitem->setAlignment(item->alignment());-
819 QLayoutItem *r = d->replaceAt(index, newitem);-
820 if (!r
!rDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
821 delete newitem;
never executed: delete newitem;
0
822 return
never executed: return r;
r;
never executed: return r;
0
823}-
824int QLayout::indexOf(QWidget *widget) const-
825{-
826 int i = 0;-
827 QLayoutItem *item = itemAt(i);-
828 while (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
829 if (item->widget() == widget
item->widget() == widgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
830 return
never executed: return i;
i;
never executed: return i;
0
831 ++i;-
832 item = itemAt(i);-
833 }
never executed: end of block
0
834 return
never executed: return -1;
-1;
never executed: return -1;
0
835}-
836void QLayout::setSizeConstraint(SizeConstraint constraint)-
837{-
838 QLayoutPrivate * const d = d_func();-
839 if (constraint == d->constraint
constraint == d->constraintDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
840 return;
never executed: return;
0
841-
842 d->constraint = constraint;-
843 invalidate();-
844}
never executed: end of block
0
845-
846QLayout::SizeConstraint QLayout::sizeConstraint() const-
847{-
848 const QLayoutPrivate * const d = d_func();-
849 return
never executed: return d->constraint;
d->constraint;
never executed: return d->constraint;
0
850}-
851QRect QLayout::alignmentRect(const QRect &r) const-
852{-
853 QSize s = sizeHint();-
854 Qt::Alignment a = alignment();-
855-
856-
857-
858-
859-
860-
861 QLayout *that = const_cast<QLayout *>(this);-
862 that->setAlignment(0);-
863 QSize ms = that->maximumSize();-
864 that->setAlignment(a);-
865-
866 if ((
(expandingDire...t::Horizontal)Description
TRUEnever evaluated
FALSEnever evaluated
expandingDirections() & Qt::Horizontal)
(expandingDire...t::Horizontal)Description
TRUEnever evaluated
FALSEnever evaluated
||
0
867 !(a & Qt::AlignHorizontal_Mask)
!(a & Qt::Alig...rizontal_Mask)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
868 s.setWidth(qMin(r.width(), ms.width()));-
869 }
never executed: end of block
0
870 if ((
(expandingDire... Qt::Vertical)Description
TRUEnever evaluated
FALSEnever evaluated
expandingDirections() & Qt::Vertical)
(expandingDire... Qt::Vertical)Description
TRUEnever evaluated
FALSEnever evaluated
||
0
871 !(a & Qt::AlignVertical_Mask)
!(a & Qt::AlignVertical_Mask)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
872 s.setHeight(qMin(r.height(), ms.height()));-
873 }
never executed: end of block
else if (hasHeightForWidth()
hasHeightForWidth()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
874 int hfw = heightForWidth(s.width());-
875 if (hfw < s.height()
hfw < s.height()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
876 s.setHeight(qMin(hfw, ms.height()));
never executed: s.setHeight(qMin(hfw, ms.height()));
0
877 }
never executed: end of block
0
878-
879 s = s.boundedTo(r.size());-
880 int x = r.x();-
881 int y = r.y();-
882-
883 if (a & Qt::AlignBottom
a & Qt::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
884 y += (r.height() - s.height());
never executed: y += (r.height() - s.height());
0
885 else if (!(a & Qt::AlignTop)
!(a & Qt::AlignTop)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
886 y += (r.height() - s.height()) / 2;
never executed: y += (r.height() - s.height()) / 2;
0
887-
888 QWidget *parent = parentWidget();-
889 a = QStyle::visualAlignment(parent ? parent->layoutDirection() : QApplication::layoutDirection(), a);-
890 if (a & Qt::AlignRight
a & Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
891 x += (r.width() - s.width());
never executed: x += (r.width() - s.width());
0
892 else if (!(a & Qt::AlignLeft)
!(a & Qt::AlignLeft)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
893 x += (r.width() - s.width()) / 2;
never executed: x += (r.width() - s.width()) / 2;
0
894-
895 return
never executed: return QRect(x, y, s.width(), s.height());
QRect(x, y, s.width(), s.height());
never executed: return QRect(x, y, s.width(), s.height());
0
896}-
897void QLayout::removeWidget(QWidget *widget)-
898{-
899 int i = 0;-
900 QLayoutItem *child;-
901 while ((
(child = itemAt(i))Description
TRUEnever evaluated
FALSEnever evaluated
child = itemAt(i))
(child = itemAt(i))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
902 if (child->widget() == widget
child->widget() == widgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
903 delete takeAt(i);-
904 invalidate();-
905 }
never executed: end of block
else {
0
906 ++i;-
907 }
never executed: end of block
0
908 }-
909}
never executed: end of block
0
910void QLayout::removeItem(QLayoutItem *item)-
911{-
912 int i = 0;-
913 QLayoutItem *child;-
914 while ((
(child = itemAt(i))Description
TRUEnever evaluated
FALSEnever evaluated
child = itemAt(i))
(child = itemAt(i))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
915 if (child == item
child == itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
916 takeAt(i);-
917 invalidate();-
918 }
never executed: end of block
else {
0
919 ++i;-
920 }
never executed: end of block
0
921 }-
922}
never executed: end of block
0
923void QLayout::setEnabled(bool enable)-
924{-
925 QLayoutPrivate * const d = d_func();-
926 d->enabled = enable;-
927}
never executed: end of block
0
928-
929-
930-
931-
932-
933-
934bool QLayout::isEnabled() const-
935{-
936 const QLayoutPrivate * const d = d_func();-
937 return
never executed: return d->enabled;
d->enabled;
never executed: return d->enabled;
0
938}-
939-
940-
941-
942-
943-
944-
945-
946QSize QLayout::closestAcceptableSize(const QWidget *widget, const QSize &size)-
947{-
948 QSize result = size.boundedTo(qSmartMaxSize(widget));-
949 result = result.expandedTo(qSmartMinSize(widget));-
950 QLayout *l = widget->layout();-
951 if (l
lDescription
TRUEnever evaluated
FALSEnever evaluated
&& l->hasHeightForWidth()
l->hasHeightForWidth()Description
TRUEnever evaluated
FALSEnever evaluated
&& result.height() < l->minimumHeightForWidth(result.width())
result.height(...esult.width())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
952 QSize current = widget->size();-
953 int currentHfw = l->minimumHeightForWidth(current.width());-
954 int newHfw = l->minimumHeightForWidth(result.width());-
955 if (current.height() < currentHfw
current.height() < currentHfwDescription
TRUEnever evaluated
FALSEnever evaluated
|| currentHfw == newHfw
currentHfw == newHfwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
956-
957-
958 result.setHeight(newHfw);-
959 }
never executed: end of block
else {
0
960-
961-
962 int maxw = qMax(widget->width(),result.width());-
963 int maxh = qMax(widget->height(), result.height());-
964 int minw = qMin(widget->width(),result.width());-
965 int minh = qMin(widget->height(), result.height());-
966-
967 int minhfw = l->minimumHeightForWidth(minw);-
968 int maxhfw = l->minimumHeightForWidth(maxw);-
969 while (minw < maxw
minw < maxwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
970 if (minhfw > maxh
minhfw > maxhDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
971 minw = maxw - (maxw-minw)/2;-
972 minhfw = l->minimumHeightForWidth(minw);-
973 }
never executed: end of block
else if (maxhfw < minh
maxhfw < minhDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
974 maxw = minw + (maxw-minw)/2;-
975 maxhfw = l->minimumHeightForWidth(maxw);-
976 }
never executed: end of block
else {
0
977 break;
never executed: break;
0
978 }-
979 }-
980 result = result.expandedTo(QSize(minw, minhfw));-
981 }
never executed: end of block
0
982 }-
983 return
never executed: return result;
result;
never executed: return result;
0
984}-
985-
986-
987-
Switch to Source codePreprocessed file

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