kernel/qlayout.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qlayout.h" -
43 -
44#include "qapplication.h" -
45#include "qlayoutengine_p.h" -
46#include "qmenubar.h" -
47#include "qtoolbar.h" -
48#include "qsizegrip.h" -
49#include "qevent.h" -
50#include "qstyle.h" -
51#include "qvariant.h" -
52#include "qwidget_p.h" -
53#include "qlayout_p.h" -
54#include "qformlayout.h" -
55 -
56QT_BEGIN_NAMESPACE -
57 -
58static int menuBarHeightForWidth(QWidget *menubar, int w) -
59{ -
60 if (menubar && !menubar->isHidden() && !menubar->isWindow()) {
evaluated: menubar
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:24920
evaluated: !menubar->isHidden()
TRUEFALSE
yes
Evaluation Count:158
yes
Evaluation Count:25
partially evaluated: !menubar->isWindow()
TRUEFALSE
yes
Evaluation Count:158
no
Evaluation Count:0
0-24920
61 int result = menubar->heightForWidth(qMax(w, menubar->minimumWidth()));
executed (the execution status of this line is deduced): int result = menubar->heightForWidth(qMax(w, menubar->minimumWidth()));
-
62 if (result != -1)
evaluated: result != -1
TRUEFALSE
yes
Evaluation Count:153
yes
Evaluation Count:5
5-153
63 return result;
executed: return result;
Execution Count:153
153
64 result = menubar->sizeHint()
executed (the execution status of this line is deduced): result = menubar->sizeHint()
-
65 .expandedTo(menubar->minimumSize())
executed (the execution status of this line is deduced): .expandedTo(menubar->minimumSize())
-
66 .expandedTo(menubar->minimumSizeHint())
executed (the execution status of this line is deduced): .expandedTo(menubar->minimumSizeHint())
-
67 .boundedTo(menubar->maximumSize()).height();
executed (the execution status of this line is deduced): .boundedTo(menubar->maximumSize()).height();
-
68 if (result != -1)
partially evaluated: result != -1
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
69 return result;
executed: return result;
Execution Count:5
5
70 }
never executed: }
0
71 return 0;
executed: return 0;
Execution Count:24945
24945
72} -
73 -
74/*! -
75 \class QLayout -
76 \brief The QLayout class is the base class of geometry managers. -
77 -
78 \ingroup geomanagement -
79 \inmodule QtWidgets -
80 -
81 This is an abstract base class inherited by the concrete classes -
82 QBoxLayout, QGridLayout, QFormLayout, and QStackedLayout. -
83 -
84 For users of QLayout subclasses or of QMainWindow there is seldom -
85 any need to use the basic functions provided by QLayout, such as -
86 setSizeConstraint() or setMenuBar(). See \l{Layout Management} -
87 for more information. -
88 -
89 To make your own layout manager, implement the functions -
90 addItem(), sizeHint(), setGeometry(), itemAt() and takeAt(). You -
91 should also implement minimumSize() to ensure your layout isn't -
92 resized to zero size if there is too little space. To support -
93 children whose heights depend on their widths, implement -
94 hasHeightForWidth() and heightForWidth(). See the -
95 \l{layouts/borderlayout}{Border Layout} and -
96 \l{layouts/flowlayout}{Flow Layout} examples for -
97 more information about implementing custom layout managers. -
98 -
99 Geometry management stops when the layout manager is deleted. -
100 -
101 \sa QLayoutItem, {Layout Management}, {Basic Layouts Example}, -
102 {Border Layout Example}, {Flow Layout Example} -
103*/ -
104 -
105 -
106/*! -
107 Constructs a new top-level QLayout, with parent \a parent. -
108 \a parent may not be 0. -
109 -
110 There can be only one top-level layout for a widget. It is -
111 returned by QWidget::layout(). -
112*/ -
113QLayout::QLayout(QWidget *parent) -
114 : QObject(*new QLayoutPrivate, parent) -
115{ -
116 if (!parent)
partially evaluated: !parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:87
0-87
117 return;
never executed: return;
0
118 parent->setLayout(this);
executed (the execution status of this line is deduced): parent->setLayout(this);
-
119}
executed: }
Execution Count:87
87
120 -
121/*! -
122 Constructs a new child QLayout. -
123 -
124 This layout has to be inserted into another layout before geometry -
125 management will work. -
126*/ -
127QLayout::QLayout() -
128 : QObject(*new QLayoutPrivate, 0) -
129{ -
130}
executed: }
Execution Count:1
1
131 -
132 -
133/*! \internal -
134 */ -
135QLayout::QLayout(QLayoutPrivate &dd, QLayout *lay, QWidget *w) -
136 : QObject(dd, lay ? static_cast<QObject*>(lay) : static_cast<QObject*>(w)) -
137{ -
138 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
139 if (lay) {
partially evaluated: lay
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13175
0-13175
140 lay->addItem(this);
never executed (the execution status of this line is deduced): lay->addItem(this);
-
141 } else if (w) {
never executed: }
evaluated: w
TRUEFALSE
yes
Evaluation Count:2279
yes
Evaluation Count:10896
0-10896
142 if (w->layout()) {
partially evaluated: w->layout()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2279
0-2279
143 qWarning("QLayout: Attempting to add QLayout \"%s\" to %s \"%s\", which"
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qlayout.cpp", 143, __PRETTY_FUNCTION__).warning("QLayout: Attempting to add QLayout \"%s\" to %s \"%s\", which"
-
144 " already has a layout",
never executed (the execution status of this line is deduced): " already has a layout",
-
145 qPrintable(QObject::objectName()), w->metaObject()->className(),
never executed (the execution status of this line is deduced): QString(QObject::objectName()).toLocal8Bit().constData(), w->metaObject()->className(),
-
146 w->objectName().toLocal8Bit().data());
never executed (the execution status of this line is deduced): w->objectName().toLocal8Bit().data());
-
147 setParent(0);
never executed (the execution status of this line is deduced): setParent(0);
-
148 } else {
never executed: }
0
149 d->topLevel = true;
executed (the execution status of this line is deduced): d->topLevel = true;
-
150 w->d_func()->layout = this;
executed (the execution status of this line is deduced): w->d_func()->layout = this;
-
151 QT_TRY {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:2279
no
Evaluation Count:0
0-2279
152 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
153 } QT_CATCH(...) {
executed: }
Execution Count:2279
2279
154 w->d_func()->layout = 0;
never executed (the execution status of this line is deduced): w->d_func()->layout = 0;
-
155 QT_RETHROW;
never executed (the execution status of this line is deduced): qt_noop();
-
156 }
never executed: }
0
157 } -
158 } -
159} -
160 -
161QLayoutPrivate::QLayoutPrivate() -
162 : QObjectPrivate(), insideSpacing(-1), userLeftMargin(-1), userTopMargin(-1), userRightMargin(-1), -
163 userBottomMargin(-1), topLevel(false), enabled(true), activated(true), autoNewChild(false), -
164 constraint(QLayout::SetDefaultConstraint), menubar(0) -
165{ -
166}
executed: }
Execution Count:13263
13263
167 -
168void QLayoutPrivate::getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const -
169{ -
170 if (!result)
evaluated: !result
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:32991
9-32991
171 return;
executed: return;
Execution Count:9
9
172 -
173 Q_Q(const QLayout);
executed (the execution status of this line is deduced): const QLayout * const q = q_func();
-
174 if (userMargin >= 0) {
evaluated: userMargin >= 0
TRUEFALSE
yes
Evaluation Count:26476
yes
Evaluation Count:6515
6515-26476
175 *result = userMargin;
executed (the execution status of this line is deduced): *result = userMargin;
-
176 } else if (!topLevel) {
executed: }
Execution Count:26476
evaluated: !topLevel
TRUEFALSE
yes
Evaluation Count:1856
yes
Evaluation Count:4659
1856-26476
177 *result = 0;
executed (the execution status of this line is deduced): *result = 0;
-
178 } else if (QWidget *pw = q->parentWidget()) {
executed: }
Execution Count:1856
partially evaluated: QWidget *pw = q->parentWidget()
TRUEFALSE
yes
Evaluation Count:4659
no
Evaluation Count:0
0-4659
179 *result = pw->style()->pixelMetric(pm, 0, pw);
executed (the execution status of this line is deduced): *result = pw->style()->pixelMetric(pm, 0, pw);
-
180 } else {
executed: }
Execution Count:4659
4659
181 *result = 0;
never executed (the execution status of this line is deduced): *result = 0;
-
182 }
never executed: }
0
183} -
184 -
185// Static item factory functions that allow for hooking things in Designer -
186 -
187QLayoutPrivate::QWidgetItemFactoryMethod QLayoutPrivate::widgetItemFactoryMethod = 0; -
188QLayoutPrivate::QSpacerItemFactoryMethod QLayoutPrivate::spacerItemFactoryMethod = 0; -
189 -
190QWidgetItem *QLayoutPrivate::createWidgetItem(const QLayout *layout, QWidget *widget) -
191{ -
192 if (widgetItemFactoryMethod)
partially evaluated: widgetItemFactoryMethod
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18458
0-18458
193 if (QWidgetItem *wi = (*widgetItemFactoryMethod)(layout, widget))
never evaluated: QWidgetItem *wi = (*widgetItemFactoryMethod)(layout, widget)
0
194 return wi;
never executed: return wi;
0
195 return new QWidgetItemV2(widget);
executed: return new QWidgetItemV2(widget);
Execution Count:18458
18458
196} -
197 -
198QSpacerItem *QLayoutPrivate::createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy) -
199{ -
200 if (spacerItemFactoryMethod)
partially evaluated: spacerItemFactoryMethod
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2214
0-2214
201 if (QSpacerItem *si = (*spacerItemFactoryMethod)(layout, w, h, hPolicy, vPolicy))
never evaluated: QSpacerItem *si = (*spacerItemFactoryMethod)(layout, w, h, hPolicy, vPolicy)
0
202 return si;
never executed: return si;
0
203 return new QSpacerItem(w, h, hPolicy, vPolicy);
executed: return new QSpacerItem(w, h, hPolicy, vPolicy);
Execution Count:2214
2214
204} -
205 -
206 -
207 -
208/*! -
209 \fn void QLayout::addItem(QLayoutItem *item) -
210 -
211 Implemented in subclasses to add an \a item. How it is added is -
212 specific to each subclass. -
213 -
214 This function is not usually called in application code. To add a widget -
215 to a layout, use the addWidget() function; to add a child layout, use the -
216 addLayout() function provided by the relevant QLayout subclass. -
217 -
218 \b{Note:} The ownership of \a item is transferred to the layout, and it's -
219 the layout's responsibility to delete it. -
220 -
221 \sa addWidget(), QBoxLayout::addLayout(), QGridLayout::addLayout() -
222*/ -
223 -
224/*! -
225 Adds widget \a w to this layout in a manner specific to the -
226 layout. This function uses addItem(). -
227*/ -
228void QLayout::addWidget(QWidget *w) -
229{ -
230 addChildWidget(w);
executed (the execution status of this line is deduced): addChildWidget(w);
-
231 addItem(QLayoutPrivate::createWidgetItem(this, w));
executed (the execution status of this line is deduced): addItem(QLayoutPrivate::createWidgetItem(this, w));
-
232}
executed: }
Execution Count:127
127
233 -
234 -
235 -
236/*! -
237 Sets the alignment for widget \a w to \a alignment and returns -
238 true if \a w is found in this layout (not including child -
239 layouts); otherwise returns false. -
240*/ -
241bool QLayout::setAlignment(QWidget *w, Qt::Alignment alignment) -
242{ -
243 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
244 QLayoutItem *item = itemAt(i);
executed (the execution status of this line is deduced): QLayoutItem *item = itemAt(i);
-
245 while (item) {
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
246 if (item->widget() == w) {
partially evaluated: item->widget() == w
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
247 item->setAlignment(alignment);
executed (the execution status of this line is deduced): item->setAlignment(alignment);
-
248 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
249 return true;
executed: return true;
Execution Count:2
2
250 } -
251 ++i;
never executed (the execution status of this line is deduced): ++i;
-
252 item = itemAt(i);
never executed (the execution status of this line is deduced): item = itemAt(i);
-
253 }
never executed: }
0
254 return false;
never executed: return false;
0
255} -
256 -
257/*! -
258 \overload -
259 -
260 Sets the alignment for the layout \a l to \a alignment and -
261 returns true if \a l is found in this layout (not including child -
262 layouts); otherwise returns false. -
263*/ -
264bool QLayout::setAlignment(QLayout *l, Qt::Alignment alignment) -
265{ -
266 int i = 0;
never executed (the execution status of this line is deduced): int i = 0;
-
267 QLayoutItem *item = itemAt(i);
never executed (the execution status of this line is deduced): QLayoutItem *item = itemAt(i);
-
268 while (item) {
never evaluated: item
0
269 if (item->layout() == l) {
never evaluated: item->layout() == l
0
270 item->setAlignment(alignment);
never executed (the execution status of this line is deduced): item->setAlignment(alignment);
-
271 invalidate();
never executed (the execution status of this line is deduced): invalidate();
-
272 return true;
never executed: return true;
0
273 } -
274 ++i;
never executed (the execution status of this line is deduced): ++i;
-
275 item = itemAt(i);
never executed (the execution status of this line is deduced): item = itemAt(i);
-
276 }
never executed: }
0
277 return false;
never executed: return false;
0
278} -
279 -
280/*! -
281 \fn void QLayout::setAlignment(Qt::Alignment alignment) -
282 -
283 Sets the alignment of this item to \a alignment. -
284 -
285 \sa QLayoutItem::setAlignment() -
286*/ -
287 -
288/*! -
289 \property QLayout::margin -
290 \brief the width of the outside border of the layout -
291 \obsolete -
292 -
293 Use setContentsMargins() and getContentsMargins() instead. -
294 -
295 \sa contentsRect(), spacing -
296*/ -
297 -
298/*! -
299 \obsolete -
300*/ -
301int QLayout::margin() const -
302{ -
303 int left, top, right, bottom;
executed (the execution status of this line is deduced): int left, top, right, bottom;
-
304 getContentsMargins(&left, &top, &right, &bottom);
executed (the execution status of this line is deduced): getContentsMargins(&left, &top, &right, &bottom);
-
305 if (left == top && top == right && right == bottom) {
partially evaluated: left == top
TRUEFALSE
yes
Evaluation Count:141
no
Evaluation Count:0
partially evaluated: top == right
TRUEFALSE
yes
Evaluation Count:141
no
Evaluation Count:0
partially evaluated: right == bottom
TRUEFALSE
yes
Evaluation Count:141
no
Evaluation Count:0
0-141
306 return left;
executed: return left;
Execution Count:141
141
307 } else { -
308 return -1;
never executed: return -1;
0
309 } -
310} -
311 -
312/*! -
313 \property QLayout::spacing -
314 \brief the spacing between widgets inside the layout -
315 -
316 If no value is explicitly set, the layout's spacing is inherited -
317 from the parent layout, or from the style settings for the parent -
318 widget. -
319 -
320 For QGridLayout and QFormLayout, it is possible to set different horizontal and -
321 vertical spacings using \l{QGridLayout::}{setHorizontalSpacing()} -
322 and \l{QGridLayout::}{setVerticalSpacing()}. In that case, -
323 spacing() returns -1. -
324 -
325 \sa contentsRect(), getContentsMargins(), QStyle::layoutSpacing(), -
326 QStyle::pixelMetric() -
327*/ -
328 -
329int QLayout::spacing() const -
330{ -
331 if (const QBoxLayout* boxlayout = qobject_cast<const QBoxLayout*>(this)) {
evaluated: const QBoxLayout* boxlayout = qobject_cast<const QBoxLayout*>(this)
TRUEFALSE
yes
Evaluation Count:365
yes
Evaluation Count:406
365-406
332 return boxlayout->spacing();
executed: return boxlayout->spacing();
Execution Count:365
365
333 } else if (const QGridLayout* gridlayout = qobject_cast<const QGridLayout*>(this)) {
evaluated: const QGridLayout* gridlayout = qobject_cast<const QGridLayout*>(this)
TRUEFALSE
yes
Evaluation Count:313
yes
Evaluation Count:93
93-313
334 return gridlayout->spacing();
executed: return gridlayout->spacing();
Execution Count:313
313
335 } else if (const QFormLayout* formlayout = qobject_cast<const QFormLayout*>(this)) {
evaluated: const QFormLayout* formlayout = qobject_cast<const QFormLayout*>(this)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:92
1-92
336 return formlayout->spacing();
executed: return formlayout->spacing();
Execution Count:1
1
337 } else { -
338 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
339 if (d->insideSpacing >=0) {
partially evaluated: d->insideSpacing >=0
TRUEFALSE
yes
Evaluation Count:92
no
Evaluation Count:0
0-92
340 return d->insideSpacing;
executed: return d->insideSpacing;
Execution Count:92
92
341 } else { -
342 // arbitrarily prefer horizontal spacing to vertical spacing -
343 return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
never executed: return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
0
344 } -
345 } -
346} -
347 -
348/*! -
349 \obsolete -
350*/ -
351void QLayout::setMargin(int margin) -
352{ -
353 setContentsMargins(margin, margin, margin, margin);
executed (the execution status of this line is deduced): setContentsMargins(margin, margin, margin, margin);
-
354}
executed: }
Execution Count:10960
10960
355 -
356void QLayout::setSpacing(int spacing) -
357{ -
358 if (QBoxLayout* boxlayout = qobject_cast<QBoxLayout*>(this)) {
partially evaluated: QBoxLayout* boxlayout = qobject_cast<QBoxLayout*>(this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
359 boxlayout->setSpacing(spacing);
never executed (the execution status of this line is deduced): boxlayout->setSpacing(spacing);
-
360 } else if (QGridLayout* gridlayout = qobject_cast<QGridLayout*>(this)) {
never executed: }
partially evaluated: QGridLayout* gridlayout = qobject_cast<QGridLayout*>(this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
361 gridlayout->setSpacing(spacing);
never executed (the execution status of this line is deduced): gridlayout->setSpacing(spacing);
-
362 } else if (QFormLayout* formlayout = qobject_cast<QFormLayout*>(this)) {
never executed: }
partially evaluated: QFormLayout* formlayout = qobject_cast<QFormLayout*>(this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
363 formlayout->setSpacing(spacing);
never executed (the execution status of this line is deduced): formlayout->setSpacing(spacing);
-
364 } else {
never executed: }
0
365 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
366 d->insideSpacing = spacing;
executed (the execution status of this line is deduced): d->insideSpacing = spacing;
-
367 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
368 }
executed: }
Execution Count:16
16
369} -
370 -
371/*! -
372 \since 4.3 -
373 -
374 Sets the \a left, \a top, \a right, and \a bottom margins to use -
375 around the layout. -
376 -
377 By default, QLayout uses the values provided by the style. On -
378 most platforms, the margin is 11 pixels in all directions. -
379 -
380 \sa getContentsMargins(), QStyle::pixelMetric(), -
381 {QStyle::}{PM_LayoutLeftMargin}, -
382 {QStyle::}{PM_LayoutTopMargin}, -
383 {QStyle::}{PM_LayoutRightMargin}, -
384 {QStyle::}{PM_LayoutBottomMargin} -
385*/ -
386void QLayout::setContentsMargins(int left, int top, int right, int bottom) -
387{ -
388 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
389 -
390 if (d->userLeftMargin == left && d->userTopMargin == top &&
evaluated: d->userLeftMargin == left
TRUEFALSE
yes
Evaluation Count:158
yes
Evaluation Count:12162
partially evaluated: d->userTopMargin == top
TRUEFALSE
yes
Evaluation Count:158
no
Evaluation Count:0
0-12162
391 d->userRightMargin == right && d->userBottomMargin == bottom)
partially evaluated: d->userRightMargin == right
TRUEFALSE
yes
Evaluation Count:158
no
Evaluation Count:0
partially evaluated: d->userBottomMargin == bottom
TRUEFALSE
yes
Evaluation Count:158
no
Evaluation Count:0
0-158
392 return;
executed: return;
Execution Count:158
158
393 -
394 d->userLeftMargin = left;
executed (the execution status of this line is deduced): d->userLeftMargin = left;
-
395 d->userTopMargin = top;
executed (the execution status of this line is deduced): d->userTopMargin = top;
-
396 d->userRightMargin = right;
executed (the execution status of this line is deduced): d->userRightMargin = right;
-
397 d->userBottomMargin = bottom;
executed (the execution status of this line is deduced): d->userBottomMargin = bottom;
-
398 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
399}
executed: }
Execution Count:12162
12162
400 -
401/*! -
402 \since 4.6 -
403 -
404 Sets the \a margins to use around the layout. -
405 -
406 By default, QLayout uses the values provided by the style. On -
407 most platforms, the margin is 11 pixels in all directions. -
408 -
409 \sa contentsMargins() -
410*/ -
411void QLayout::setContentsMargins(const QMargins &margins) -
412{ -
413 setContentsMargins(margins.left(), margins.top(), margins.right(), margins.bottom());
never executed (the execution status of this line is deduced): setContentsMargins(margins.left(), margins.top(), margins.right(), margins.bottom());
-
414}
never executed: }
0
415 -
416/*! -
417 \since 4.3 -
418 -
419 Extracts the left, top, right, and bottom margins used around the -
420 layout, and assigns them to *\a left, *\a top, *\a right, and *\a -
421 bottom (unless they are null pointers). -
422 -
423 By default, QLayout uses the values provided by the style. On -
424 most platforms, the margin is 11 pixels in all directions. -
425 -
426 \sa setContentsMargins(), QStyle::pixelMetric(), -
427 {QStyle::}{PM_LayoutLeftMargin}, -
428 {QStyle::}{PM_LayoutTopMargin}, -
429 {QStyle::}{PM_LayoutRightMargin}, -
430 {QStyle::}{PM_LayoutBottomMargin} -
431*/ -
432void QLayout::getContentsMargins(int *left, int *top, int *right, int *bottom) const -
433{ -
434 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
435 d->getMargin(left, d->userLeftMargin, QStyle::PM_LayoutLeftMargin);
executed (the execution status of this line is deduced): d->getMargin(left, d->userLeftMargin, QStyle::PM_LayoutLeftMargin);
-
436 d->getMargin(top, d->userTopMargin, QStyle::PM_LayoutTopMargin);
executed (the execution status of this line is deduced): d->getMargin(top, d->userTopMargin, QStyle::PM_LayoutTopMargin);
-
437 d->getMargin(right, d->userRightMargin, QStyle::PM_LayoutRightMargin);
executed (the execution status of this line is deduced): d->getMargin(right, d->userRightMargin, QStyle::PM_LayoutRightMargin);
-
438 d->getMargin(bottom, d->userBottomMargin, QStyle::PM_LayoutBottomMargin);
executed (the execution status of this line is deduced): d->getMargin(bottom, d->userBottomMargin, QStyle::PM_LayoutBottomMargin);
-
439}
executed: }
Execution Count:8250
8250
440 -
441/*! -
442 \since 4.6 -
443 -
444 Returns the margins used around the layout. -
445 -
446 By default, QLayout uses the values provided by the style. On -
447 most platforms, the margin is 11 pixels in all directions. -
448 -
449 \sa setContentsMargins() -
450*/ -
451QMargins QLayout::contentsMargins() const -
452{ -
453 int left, top, right, bottom;
never executed (the execution status of this line is deduced): int left, top, right, bottom;
-
454 getContentsMargins(&left, &top, &right, &bottom);
never executed (the execution status of this line is deduced): getContentsMargins(&left, &top, &right, &bottom);
-
455 return QMargins(left, top, right, bottom);
never executed: return QMargins(left, top, right, bottom);
0
456} -
457 -
458/*! -
459 \since 4.3 -
460 -
461 Returns the layout's geometry() rectangle, but taking into account the -
462 contents margins. -
463 -
464 \sa setContentsMargins(), getContentsMargins() -
465*/ -
466QRect QLayout::contentsRect() const -
467{ -
468 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
469 int left, top, right, bottom;
executed (the execution status of this line is deduced): int left, top, right, bottom;
-
470 getContentsMargins(&left, &top, &right, &bottom);
executed (the execution status of this line is deduced): getContentsMargins(&left, &top, &right, &bottom);
-
471 return d->rect.adjusted(+left, +top, -right, -bottom);
executed: return d->rect.adjusted(+left, +top, -right, -bottom);
Execution Count:2
2
472} -
473 -
474 -
475/*! -
476 Returns the parent widget of this layout, or 0 if this layout is -
477 not installed on any widget. -
478 -
479 If the layout is a sub-layout, this function returns the parent -
480 widget of the parent layout. -
481 -
482 \sa parent() -
483*/ -
484QWidget *QLayout::parentWidget() const -
485{ -
486 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
487 if (!d->topLevel) {
evaluated: !d->topLevel
TRUEFALSE
yes
Evaluation Count:3662
yes
Evaluation Count:59289
3662-59289
488 if (parent()) {
evaluated: parent()
TRUEFALSE
yes
Evaluation Count:1433
yes
Evaluation Count:2229
1433-2229
489 QLayout *parentLayout = qobject_cast<QLayout*>(parent());
executed (the execution status of this line is deduced): QLayout *parentLayout = qobject_cast<QLayout*>(parent());
-
490 if (!parentLayout) {
evaluated: !parentLayout
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1432
1-1432
491 qWarning("QLayout::parentWidget: A layout can only have another layout as a parent.");
executed (the execution status of this line is deduced): QMessageLogger("kernel/qlayout.cpp", 491, __PRETTY_FUNCTION__).warning("QLayout::parentWidget: A layout can only have another layout as a parent.");
-
492 return 0;
executed: return 0;
Execution Count:1
1
493 } -
494 return parentLayout->parentWidget();
executed: return parentLayout->parentWidget();
Execution Count:1432
1432
495 } else { -
496 return 0;
executed: return 0;
Execution Count:2229
2229
497 } -
498 } else { -
499 Q_ASSERT(parent() && parent()->isWidgetType());
executed (the execution status of this line is deduced): qt_noop();
-
500 return static_cast<QWidget *>(parent());
executed: return static_cast<QWidget *>(parent());
Execution Count:59289
59289
501 } -
502} -
503 -
504/*! -
505 \reimp -
506*/ -
507bool QLayout::isEmpty() const -
508{ -
509 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
510 QLayoutItem *item = itemAt(i);
executed (the execution status of this line is deduced): QLayoutItem *item = itemAt(i);
-
511 while (item) {
evaluated: item
TRUEFALSE
yes
Evaluation Count:6798
yes
Evaluation Count:164
164-6798
512 if (!item->isEmpty())
evaluated: !item->isEmpty()
TRUEFALSE
yes
Evaluation Count:3606
yes
Evaluation Count:3192
3192-3606
513 return false;
executed: return false;
Execution Count:3606
3606
514 ++i;
executed (the execution status of this line is deduced): ++i;
-
515 item = itemAt(i);
executed (the execution status of this line is deduced): item = itemAt(i);
-
516 }
executed: }
Execution Count:3192
3192
517 return true;
executed: return true;
Execution Count:164
164
518} -
519 -
520/*! -
521 \reimp -
522*/ -
523QSizePolicy::ControlTypes QLayout::controlTypes() const -
524{ -
525 if (count() == 0)
evaluated: count() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
526 return QSizePolicy::DefaultType;
executed: return QSizePolicy::DefaultType;
Execution Count:1
1
527 QSizePolicy::ControlTypes types;
executed (the execution status of this line is deduced): QSizePolicy::ControlTypes types;
-
528 for (int i = count() - 1; i >= 0; --i)
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
529 types |= itemAt(i)->controlTypes();
executed: types |= itemAt(i)->controlTypes();
Execution Count:1
1
530 return types;
executed: return types;
Execution Count:1
1
531} -
532 -
533/*! -
534 \reimp -
535*/ -
536void QLayout::setGeometry(const QRect &r) -
537{ -
538 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
539 d->rect = r;
executed (the execution status of this line is deduced): d->rect = r;
-
540}
executed: }
Execution Count:6157
6157
541 -
542/*! -
543 \reimp -
544*/ -
545QRect QLayout::geometry() const -
546{ -
547 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
548 return d->rect;
executed: return d->rect;
Execution Count:10150
10150
549} -
550 -
551/*! -
552 \reimp -
553*/ -
554void QLayout::invalidate() -
555{ -
556 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
557 d->rect = QRect();
executed (the execution status of this line is deduced): d->rect = QRect();
-
558 update();
executed (the execution status of this line is deduced): update();
-
559}
executed: }
Execution Count:105410
105410
560 -
561static bool removeWidgetRecursively(QLayoutItem *li, QWidget *w) -
562{ -
563 QLayout *lay = li->layout();
executed (the execution status of this line is deduced): QLayout *lay = li->layout();
-
564 if (!lay)
evaluated: !lay
TRUEFALSE
yes
Evaluation Count:3689
yes
Evaluation Count:1960
1960-3689
565 return false;
executed: return false;
Execution Count:3689
3689
566 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
567 QLayoutItem *child;
executed (the execution status of this line is deduced): QLayoutItem *child;
-
568 while ((child = lay->itemAt(i))) {
evaluated: (child = lay->itemAt(i))
TRUEFALSE
yes
Evaluation Count:4599
yes
Evaluation Count:1403
1403-4599
569 if (child->widget() == w) {
evaluated: child->widget() == w
TRUEFALSE
yes
Evaluation Count:557
yes
Evaluation Count:4042
557-4042
570 delete lay->takeAt(i);
executed (the execution status of this line is deduced): delete lay->takeAt(i);
-
571 lay->invalidate();
executed (the execution status of this line is deduced): lay->invalidate();
-
572 return true;
executed: return true;
Execution Count:557
557
573 } else if (removeWidgetRecursively(child, w)) {
partially evaluated: removeWidgetRecursively(child, w)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4042
0-4042
574 return true;
never executed: return true;
0
575 } else { -
576 ++i;
executed (the execution status of this line is deduced): ++i;
-
577 }
executed: }
Execution Count:4042
4042
578 } -
579 return false;
executed: return false;
Execution Count:1403
1403
580} -
581 -
582 -
583void QLayoutPrivate::doResize(const QSize &r) -
584{ -
585 Q_Q(QLayout);
executed (the execution status of this line is deduced): QLayout * const q = q_func();
-
586 int mbh = menuBarHeightForWidth(menubar, r.width());
executed (the execution status of this line is deduced): int mbh = menuBarHeightForWidth(menubar, r.width());
-
587 QWidget *mw = q->parentWidget();
executed (the execution status of this line is deduced): QWidget *mw = q->parentWidget();
-
588 QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect) ? mw->rect() : mw->contentsRect();
partially evaluated: mw->testAttribute(Qt::WA_LayoutOnEntireRect)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7232
0-7232
589 rect.setTop(rect.top() + mbh);
executed (the execution status of this line is deduced): rect.setTop(rect.top() + mbh);
-
590 q->setGeometry(rect);
executed (the execution status of this line is deduced): q->setGeometry(rect);
-
591#ifndef QT_NO_MENUBAR -
592 if (menubar)
evaluated: menubar
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:7135
97-7135
593 menubar->setGeometry(0,0,r.width(), mbh);
executed: menubar->setGeometry(0,0,r.width(), mbh);
Execution Count:97
97
594#endif -
595}
executed: }
Execution Count:7232
7232
596 -
597 -
598/*! -
599 \internal -
600 Performs child widget layout when the parent widget is -
601 resized. Also handles removal of widgets. \a e is the -
602 event -
603*/ -
604void QLayout::widgetEvent(QEvent *e) -
605{ -
606 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
607 if (!d->enabled)
partially evaluated: !d->enabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:105401
0-105401
608 return;
never executed: return;
0
609 -
610 switch (e->type()) { -
611 case QEvent::Resize: -
612 if (d->activated) {
evaluated: d->activated
TRUEFALSE
yes
Evaluation Count:3092
yes
Evaluation Count:65
65-3092
613 QResizeEvent *r = (QResizeEvent *)e;
executed (the execution status of this line is deduced): QResizeEvent *r = (QResizeEvent *)e;
-
614 d->doResize(r->size());
executed (the execution status of this line is deduced): d->doResize(r->size());
-
615 } else {
executed: }
Execution Count:3092
3092
616 activate();
executed (the execution status of this line is deduced): activate();
-
617 }
executed: }
Execution Count:65
65
618 break;
executed: break;
Execution Count:3157
3157
619 case QEvent::ChildRemoved: -
620 { -
621 QChildEvent *c = (QChildEvent *)e;
executed (the execution status of this line is deduced): QChildEvent *c = (QChildEvent *)e;
-
622 if (c->child()->isWidgetType()) {
evaluated: c->child()->isWidgetType()
TRUEFALSE
yes
Evaluation Count:697
yes
Evaluation Count:131
131-697
623 QWidget *w = (QWidget *)c->child();
executed (the execution status of this line is deduced): QWidget *w = (QWidget *)c->child();
-
624#ifndef QT_NO_MENUBAR -
625 if (w == d->menubar)
evaluated: w == d->menubar
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:696
1-696
626 d->menubar = 0;
executed: d->menubar = 0;
Execution Count:1
1
627#endif -
628 removeWidgetRecursively(this, w);
executed (the execution status of this line is deduced): removeWidgetRecursively(this, w);
-
629 }
executed: }
Execution Count:697
697
630 } -
631 break;
executed: break;
Execution Count:828
828
632 case QEvent::LayoutRequest: -
633 if (static_cast<QWidget *>(parent())->isVisible())
evaluated: static_cast<QWidget *>(parent())->isVisible()
TRUEFALSE
yes
Evaluation Count:1625
yes
Evaluation Count:2858
1625-2858
634 activate();
executed: activate();
Execution Count:1625
1625
635 break;
executed: break;
Execution Count:4483
4483
636 default: -
637 break;
executed: break;
Execution Count:96933
96933
638 } -
639}
executed: }
Execution Count:105401
105401
640 -
641/*! -
642 \reimp -
643*/ -
644void QLayout::childEvent(QChildEvent *e) -
645{ -
646 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
647 if (!d->enabled)
partially evaluated: !d->enabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:807
0-807
648 return;
never executed: return;
0
649 -
650 if (e->type() == QEvent::ChildRemoved) {
evaluated: e->type() == QEvent::ChildRemoved
TRUEFALSE
yes
Evaluation Count:403
yes
Evaluation Count:404
403-404
651 QChildEvent *c = (QChildEvent*)e;
executed (the execution status of this line is deduced): QChildEvent *c = (QChildEvent*)e;
-
652 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
653 -
654 QLayoutItem *item;
executed (the execution status of this line is deduced): QLayoutItem *item;
-
655 while ((item = itemAt(i))) {
evaluated: (item = itemAt(i))
TRUEFALSE
yes
Evaluation Count:1624
yes
Evaluation Count:331
331-1624
656 if (item == static_cast<QLayout*>(c->child())) {
evaluated: item == static_cast<QLayout*>(c->child())
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:1552
72-1552
657 takeAt(i);
executed (the execution status of this line is deduced): takeAt(i);
-
658 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
659 break;
executed: break;
Execution Count:72
72
660 } else { -
661 ++i;
executed (the execution status of this line is deduced): ++i;
-
662 }
executed: }
Execution Count:1552
1552
663 } -
664 }
executed: }
Execution Count:403
403
665}
executed: }
Execution Count:807
807
666 -
667/*! -
668 \internal -
669 Also takes contentsMargins and menu bar into account. -
670*/ -
671int QLayout::totalHeightForWidth(int w) const -
672{ -
673 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
674 int side=0, top=0;
executed (the execution status of this line is deduced): int side=0, top=0;
-
675 if (d->topLevel) {
partially evaluated: d->topLevel
TRUEFALSE
yes
Evaluation Count:159
no
Evaluation Count:0
0-159
676 QWidget *parent = parentWidget();
executed (the execution status of this line is deduced): QWidget *parent = parentWidget();
-
677 parent->ensurePolished();
executed (the execution status of this line is deduced): parent->ensurePolished();
-
678 QWidgetPrivate *wd = parent->d_func();
executed (the execution status of this line is deduced): QWidgetPrivate *wd = parent->d_func();
-
679 side += wd->leftmargin + wd->rightmargin;
executed (the execution status of this line is deduced): side += wd->leftmargin + wd->rightmargin;
-
680 top += wd->topmargin + wd->bottommargin;
executed (the execution status of this line is deduced): top += wd->topmargin + wd->bottommargin;
-
681 }
executed: }
Execution Count:159
159
682 int h = heightForWidth(w - side) + top;
executed (the execution status of this line is deduced): int h = heightForWidth(w - side) + top;
-
683#ifndef QT_NO_MENUBAR -
684 h += menuBarHeightForWidth(d->menubar, w);
executed (the execution status of this line is deduced): h += menuBarHeightForWidth(d->menubar, w);
-
685#endif -
686 return h;
executed: return h;
Execution Count:159
159
687} -
688 -
689/*! -
690 \internal -
691 Also takes contentsMargins and menu bar into account. -
692*/ -
693QSize QLayout::totalMinimumSize() const -
694{ -
695 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
696 int side=0, top=0;
executed (the execution status of this line is deduced): int side=0, top=0;
-
697 if (d->topLevel) {
partially evaluated: d->topLevel
TRUEFALSE
yes
Evaluation Count:5129
no
Evaluation Count:0
0-5129
698 QWidget *pw = parentWidget();
executed (the execution status of this line is deduced): QWidget *pw = parentWidget();
-
699 pw->ensurePolished();
executed (the execution status of this line is deduced): pw->ensurePolished();
-
700 QWidgetPrivate *wd = pw->d_func();
executed (the execution status of this line is deduced): QWidgetPrivate *wd = pw->d_func();
-
701 side += wd->leftmargin + wd->rightmargin;
executed (the execution status of this line is deduced): side += wd->leftmargin + wd->rightmargin;
-
702 top += wd->topmargin + wd->bottommargin;
executed (the execution status of this line is deduced): top += wd->topmargin + wd->bottommargin;
-
703 }
executed: }
Execution Count:5129
5129
704 -
705 QSize s = minimumSize();
executed (the execution status of this line is deduced): QSize s = minimumSize();
-
706#ifndef QT_NO_MENUBAR -
707 top += menuBarHeightForWidth(d->menubar, s.width() + side);
executed (the execution status of this line is deduced): top += menuBarHeightForWidth(d->menubar, s.width() + side);
-
708#endif -
709 return s + QSize(side, top);
executed: return s + QSize(side, top);
Execution Count:5129
5129
710} -
711 -
712/*! -
713 \internal -
714 Also takes contentsMargins and menu bar into account. -
715*/ -
716QSize QLayout::totalSizeHint() const -
717{ -
718 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
719 int side=0, top=0;
executed (the execution status of this line is deduced): int side=0, top=0;
-
720 if (d->topLevel) {
partially evaluated: d->topLevel
TRUEFALSE
yes
Evaluation Count:10821
no
Evaluation Count:0
0-10821
721 QWidget *pw = parentWidget();
executed (the execution status of this line is deduced): QWidget *pw = parentWidget();
-
722 pw->ensurePolished();
executed (the execution status of this line is deduced): pw->ensurePolished();
-
723 QWidgetPrivate *wd = pw->d_func();
executed (the execution status of this line is deduced): QWidgetPrivate *wd = pw->d_func();
-
724 side += wd->leftmargin + wd->rightmargin;
executed (the execution status of this line is deduced): side += wd->leftmargin + wd->rightmargin;
-
725 top += wd->topmargin + wd->bottommargin;
executed (the execution status of this line is deduced): top += wd->topmargin + wd->bottommargin;
-
726 }
executed: }
Execution Count:10821
10821
727 -
728 QSize s = sizeHint();
executed (the execution status of this line is deduced): QSize s = sizeHint();
-
729 if (hasHeightForWidth())
evaluated: hasHeightForWidth()
TRUEFALSE
yes
Evaluation Count:260
yes
Evaluation Count:10561
260-10561
730 s.setHeight(heightForWidth(s.width() + side));
executed: s.setHeight(heightForWidth(s.width() + side));
Execution Count:260
260
731#ifndef QT_NO_MENUBAR -
732 top += menuBarHeightForWidth(d->menubar, s.width());
executed (the execution status of this line is deduced): top += menuBarHeightForWidth(d->menubar, s.width());
-
733#endif -
734 return s + QSize(side, top);
executed: return s + QSize(side, top);
Execution Count:10821
10821
735} -
736 -
737/*! -
738 \internal -
739 Also takes contentsMargins and menu bar into account. -
740*/ -
741QSize QLayout::totalMaximumSize() const -
742{ -
743 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
744 int side=0, top=0;
executed (the execution status of this line is deduced): int side=0, top=0;
-
745 if (d->topLevel) {
partially evaluated: d->topLevel
TRUEFALSE
yes
Evaluation Count:1762
no
Evaluation Count:0
0-1762
746 QWidget *pw = parentWidget();
executed (the execution status of this line is deduced): QWidget *pw = parentWidget();
-
747 pw->ensurePolished();
executed (the execution status of this line is deduced): pw->ensurePolished();
-
748 QWidgetPrivate *wd = pw->d_func();
executed (the execution status of this line is deduced): QWidgetPrivate *wd = pw->d_func();
-
749 side += wd->leftmargin + wd->rightmargin;
executed (the execution status of this line is deduced): side += wd->leftmargin + wd->rightmargin;
-
750 top += wd->topmargin + wd->bottommargin;
executed (the execution status of this line is deduced): top += wd->topmargin + wd->bottommargin;
-
751 }
executed: }
Execution Count:1762
1762
752 -
753 QSize s = maximumSize();
executed (the execution status of this line is deduced): QSize s = maximumSize();
-
754#ifndef QT_NO_MENUBAR -
755 top += menuBarHeightForWidth(d->menubar, s.width());
executed (the execution status of this line is deduced): top += menuBarHeightForWidth(d->menubar, s.width());
-
756#endif -
757 -
758 if (d->topLevel)
partially evaluated: d->topLevel
TRUEFALSE
yes
Evaluation Count:1762
no
Evaluation Count:0
0-1762
759 s = QSize(qMin(s.width() + side, QLAYOUTSIZE_MAX),
executed: s = QSize(qMin(s.width() + side, QLAYOUTSIZE_MAX), qMin(s.height() + top, QLAYOUTSIZE_MAX));
Execution Count:1762
1762
760 qMin(s.height() + top, QLAYOUTSIZE_MAX));
executed: s = QSize(qMin(s.width() + side, QLAYOUTSIZE_MAX), qMin(s.height() + top, QLAYOUTSIZE_MAX));
Execution Count:1762
1762
761 return s;
executed: return s;
Execution Count:1762
1762
762} -
763 -
764/*! -
765 \internal -
766 Destroys the layout, deleting all child layouts. -
767 Geometry management stops when a top-level layout is deleted. -
768 -
769 The layout classes will probably be fatally confused if you delete -
770 a sublayout. -
771*/ -
772QLayout::~QLayout() -
773{ -
774 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
775 /* -
776 This function may be called during the QObject destructor, -
777 when the parent no longer is a QWidget. -
778 */ -
779 if (d->topLevel && parent() && parent()->isWidgetType() &&
evaluated: d->topLevel
TRUEFALSE
yes
Evaluation Count:11573
yes
Evaluation Count:385
partially evaluated: parent()
TRUEFALSE
yes
Evaluation Count:11573
no
Evaluation Count:0
partially evaluated: parent()->isWidgetType()
TRUEFALSE
yes
Evaluation Count:11573
no
Evaluation Count:0
0-11573
780 ((QWidget*)parent())->layout() == this)
partially evaluated: ((QWidget*)parent())->layout() == this
TRUEFALSE
yes
Evaluation Count:11573
no
Evaluation Count:0
0-11573
781 ((QWidget*)parent())->d_func()->layout = 0;
executed: ((QWidget*)parent())->d_func()->layout = 0;
Execution Count:11573
11573
782}
executed: }
Execution Count:11958
11958
783 -
784 -
785/*! -
786 This function is called from \c addLayout() or \c insertLayout() functions in -
787 subclasses to add layout \a l as a sub-layout. -
788 -
789 The only scenario in which you need to call it directly is if you -
790 implement a custom layout that supports nested layouts. -
791 -
792 \sa QBoxLayout::addLayout(), QBoxLayout::insertLayout(), QGridLayout::addLayout() -
793*/ -
794void QLayout::addChildLayout(QLayout *l) -
795{ -
796 if (l->parent()) {
evaluated: l->parent()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:404
1-404
797 qWarning("QLayout::addChildLayout: layout \"%s\" already has a parent",
executed (the execution status of this line is deduced): QMessageLogger("kernel/qlayout.cpp", 797, __PRETTY_FUNCTION__).warning("QLayout::addChildLayout: layout \"%s\" already has a parent",
-
798 l->objectName().toLocal8Bit().data());
executed (the execution status of this line is deduced): l->objectName().toLocal8Bit().data());
-
799 return;
executed: return;
Execution Count:1
1
800 } -
801 l->setParent(this);
executed (the execution status of this line is deduced): l->setParent(this);
-
802 -
803 if (QWidget *mw = parentWidget()) {
evaluated: QWidget *mw = parentWidget()
TRUEFALSE
yes
Evaluation Count:384
yes
Evaluation Count:20
20-384
804 l->d_func()->reparentChildWidgets(mw);
executed (the execution status of this line is deduced): l->d_func()->reparentChildWidgets(mw);
-
805 }
executed: }
Execution Count:384
384
806 -
807}
executed: }
Execution Count:404
404
808 -
809#ifdef QT_DEBUG -
810static bool layoutDebug() -
811{ -
812 static int checked_env = -1; -
813 if(checked_env == -1) -
814 checked_env = !!qgetenv("QT_LAYOUT_DEBUG").toInt(); -
815 -
816 return checked_env; -
817} -
818#endif -
819 -
820void QLayoutPrivate::reparentChildWidgets(QWidget *mw) -
821{ -
822 Q_Q(QLayout);
executed (the execution status of this line is deduced): QLayout * const q = q_func();
-
823 int n = q->count();
executed (the execution status of this line is deduced): int n = q->count();
-
824 -
825#ifndef QT_NO_MENUBAR -
826 if (menubar && menubar->parentWidget() != mw) {
partially evaluated: menubar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10898
never evaluated: menubar->parentWidget() != mw
0-10898
827 menubar->setParent(mw);
never executed (the execution status of this line is deduced): menubar->setParent(mw);
-
828 }
never executed: }
0
829#endif -
830 bool mwVisible = mw && mw->isVisible();
partially evaluated: mw
TRUEFALSE
yes
Evaluation Count:10898
no
Evaluation Count:0
evaluated: mw->isVisible()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:10896
0-10898
831 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:2344
yes
Evaluation Count:10898
2344-10898
832 QLayoutItem *item = q->itemAt(i);
executed (the execution status of this line is deduced): QLayoutItem *item = q->itemAt(i);
-
833 if (QWidget *w = item->widget()) {
evaluated: QWidget *w = item->widget()
TRUEFALSE
yes
Evaluation Count:2189
yes
Evaluation Count:155
155-2189
834 QWidget *pw = w->parentWidget();
executed (the execution status of this line is deduced): QWidget *pw = w->parentWidget();
-
835#ifdef QT_DEBUG -
836 if (pw && pw != mw && layoutDebug()) { -
837 qWarning("QLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent", -
838 w->metaObject()->className(), w->objectName().toLocal8Bit().data()); -
839 } -
840#endif -
841 bool needShow = mwVisible && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide));
evaluated: mwVisible
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2187
evaluated: w->isHidden()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: w->testAttribute(Qt::WA_WState_ExplicitShowHide)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-2187
842 if (pw != mw)
evaluated: pw != mw
TRUEFALSE
yes
Evaluation Count:235
yes
Evaluation Count:1954
235-1954
843 w->setParent(mw);
executed: w->setParent(mw);
Execution Count:235
235
844 if (needShow)
evaluated: needShow
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2188
1-2188
845 QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection); //show later
executed: QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection);
Execution Count:1
1
846 } else if (QLayout *l = item->layout()) {
executed: }
Execution Count:2189
evaluated: QLayout *l = item->layout()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:153
2-2189
847 l->d_func()->reparentChildWidgets(mw);
executed (the execution status of this line is deduced): l->d_func()->reparentChildWidgets(mw);
-
848 }
executed: }
Execution Count:2
2
849 } -
850}
executed: }
Execution Count:10898
10898
851 -
852/*! -
853 This function is called from \c addWidget() functions in -
854 subclasses to add \a w as a managed widget of a layout. -
855 -
856 If \a w is already managed by a layout, this function will give a warning -
857 and remove \a w from that layout. This function must therefore be -
858 called before adding \a w to the layout's data structure. -
859*/ -
860void QLayout::addChildWidget(QWidget *w) -
861{ -
862 QWidget *mw = parentWidget();
executed (the execution status of this line is deduced): QWidget *mw = parentWidget();
-
863 QWidget *pw = w->parentWidget();
executed (the execution status of this line is deduced): QWidget *pw = w->parentWidget();
-
864 -
865 //Qt::WA_LaidOut is never reset. It only means that the widget at some point has -
866 //been in a layout. -
867 if (pw && w->testAttribute(Qt::WA_LaidOut)) {
evaluated: pw
TRUEFALSE
yes
Evaluation Count:17584
yes
Evaluation Count:1012
evaluated: w->testAttribute(Qt::WA_LaidOut)
TRUEFALSE
yes
Evaluation Count:910
yes
Evaluation Count:16674
910-17584
868 QLayout *l = pw->layout();
executed (the execution status of this line is deduced): QLayout *l = pw->layout();
-
869 if (l && removeWidgetRecursively(l, w)) {
partially evaluated: l
TRUEFALSE
yes
Evaluation Count:910
no
Evaluation Count:0
evaluated: removeWidgetRecursively(l, w)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:907
0-910
870#ifdef QT_DEBUG -
871 if (layoutDebug()) -
872 qWarning("QLayout::addChildWidget: %s \"%s\" is already in a layout; moved to new layout", -
873 w->metaObject()->className(), w->objectName().toLocal8Bit().data()); -
874#endif -
875 }
executed: }
Execution Count:3
3
876 }
executed: }
Execution Count:910
910
877 if (pw && mw && pw != mw) {
evaluated: pw
TRUEFALSE
yes
Evaluation Count:17584
yes
Evaluation Count:1012
evaluated: mw
TRUEFALSE
yes
Evaluation Count:15652
yes
Evaluation Count:1932
evaluated: pw != mw
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:15650
2-17584
878#ifdef QT_DEBUG -
879 if (layoutDebug()) -
880 qWarning("QLayout::addChildWidget: %s \"%s\" in wrong parent; moved to correct parent", -
881 w->metaObject()->className(), w->objectName().toLocal8Bit().data()); -
882#endif -
883 pw = 0;
executed (the execution status of this line is deduced): pw = 0;
-
884 }
executed: }
Execution Count:2
2
885 bool needShow = mw && mw->isVisible() && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide));
evaluated: mw
TRUEFALSE
yes
Evaluation Count:16389
yes
Evaluation Count:2207
evaluated: mw->isVisible()
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:16253
evaluated: w->isHidden()
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:2
evaluated: w->testAttribute(Qt::WA_WState_ExplicitShowHide)
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:78
2-16389
886 if (!pw && mw)
evaluated: !pw
TRUEFALSE
yes
Evaluation Count:1014
yes
Evaluation Count:17582
evaluated: mw
TRUEFALSE
yes
Evaluation Count:739
yes
Evaluation Count:275
275-17582
887 w->setParent(mw);
executed: w->setParent(mw);
Execution Count:739
739
888 w->setAttribute(Qt::WA_LaidOut);
executed (the execution status of this line is deduced): w->setAttribute(Qt::WA_LaidOut);
-
889 if (needShow)
evaluated: needShow
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:18516
80-18516
890 QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection); //show later
executed: QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection);
Execution Count:80
80
891}
executed: }
Execution Count:18596
18596
892 -
893 -
894 -
895 -
896 -
897 -
898 -
899 -
900/*! -
901 Tells the geometry manager to place the menu bar \a widget at the -
902 top of parentWidget(), outside QWidget::contentsMargins(). All -
903 child widgets are placed below the bottom edge of the menu bar. -
904*/ -
905void QLayout::setMenuBar(QWidget *widget) -
906{ -
907 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
908 -
909#ifdef Q_OS_WINCE_WM -
910 if (widget && widget->size().height() > 0) -
911#else -
912 if (widget)
evaluated: widget
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:2
2-19
913#endif -
914 addChildWidget(widget);
executed: addChildWidget(widget);
Execution Count:19
19
915 d->menubar = widget;
executed (the execution status of this line is deduced): d->menubar = widget;
-
916}
executed: }
Execution Count:21
21
917 -
918/*! -
919 Returns the menu bar set for this layout, or 0 if no menu bar is -
920 set. -
921*/ -
922 -
923QWidget *QLayout::menuBar() const -
924{ -
925 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
926 return d->menubar;
executed: return d->menubar;
Execution Count:7547
7547
927} -
928 -
929 -
930/*! -
931 Returns the minimum size of this layout. This is the smallest -
932 size that the layout can have while still respecting the -
933 specifications. -
934 -
935 The returned value doesn't include the space required by -
936 QWidget::setContentsMargins() or menuBar(). -
937 -
938 The default implementation allows unlimited resizing. -
939*/ -
940QSize QLayout::minimumSize() const -
941{ -
942 return QSize(0, 0);
never executed: return QSize(0, 0);
0
943} -
944 -
945/*! -
946 Returns the maximum size of this layout. This is the largest size -
947 that the layout can have while still respecting the -
948 specifications. -
949 -
950 The returned value doesn't include the space required by -
951 QWidget::setContentsMargins() or menuBar(). -
952 -
953 The default implementation allows unlimited resizing. -
954*/ -
955QSize QLayout::maximumSize() const -
956{ -
957 return QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX);
executed: return QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX);
Execution Count:4
4
958} -
959 -
960/*! -
961 Returns whether this layout can make use of more space than -
962 sizeHint(). A value of Qt::Vertical or Qt::Horizontal means that -
963 it wants to grow in only one dimension, whereas Qt::Vertical | -
964 Qt::Horizontal means that it wants to grow in both dimensions. -
965 -
966 The default implementation returns Qt::Horizontal | Qt::Vertical. -
967 Subclasses reimplement it to return a meaningful value based on -
968 their child widgets's \l{QSizePolicy}{size policies}. -
969 -
970 \sa sizeHint() -
971*/ -
972Qt::Orientations QLayout::expandingDirections() const -
973{ -
974 return Qt::Horizontal | Qt::Vertical;
executed: return Qt::Horizontal | Qt::Vertical;
Execution Count:768
768
975} -
976 -
977void QLayout::activateRecursiveHelper(QLayoutItem *item) -
978{ -
979 item->invalidate();
executed (the execution status of this line is deduced): item->invalidate();
-
980 QLayout *layout = item->layout();
executed (the execution status of this line is deduced): QLayout *layout = item->layout();
-
981 if (layout) {
evaluated: layout
TRUEFALSE
yes
Evaluation Count:4902
yes
Evaluation Count:12885
4902-12885
982 QLayoutItem *child;
executed (the execution status of this line is deduced): QLayoutItem *child;
-
983 int i=0;
executed (the execution status of this line is deduced): int i=0;
-
984 while ((child = layout->itemAt(i++)))
evaluated: (child = layout->itemAt(i++))
TRUEFALSE
yes
Evaluation Count:13647
yes
Evaluation Count:4902
4902-13647
985 activateRecursiveHelper(child);
executed: activateRecursiveHelper(child);
Execution Count:13647
13647
986 layout->d_func()->activated = true;
executed (the execution status of this line is deduced): layout->d_func()->activated = true;
-
987 }
executed: }
Execution Count:4902
4902
988}
executed: }
Execution Count:17787
17787
989 -
990/*! -
991 Updates the layout for parentWidget(). -
992 -
993 You should generally not need to call this because it is -
994 automatically called at the most appropriate times. -
995 -
996 \sa activate(), invalidate() -
997*/ -
998 -
999void QLayout::update() -
1000{ -
1001 QLayout *layout = this;
executed (the execution status of this line is deduced): QLayout *layout = this;
-
1002 while (layout && layout->d_func()->activated) {
evaluated: layout
TRUEFALSE
yes
Evaluation Count:106630
yes
Evaluation Count:483
evaluated: layout->d_func()->activated
TRUEFALSE
yes
Evaluation Count:15896
yes
Evaluation Count:90734
483-106630
1003 layout->d_func()->activated = false;
executed (the execution status of this line is deduced): layout->d_func()->activated = false;
-
1004 if (layout->d_func()->topLevel) {
evaluated: layout->d_func()->topLevel
TRUEFALSE
yes
Evaluation Count:14783
yes
Evaluation Count:1113
1113-14783
1005 Q_ASSERT(layout->parent()->isWidgetType());
executed (the execution status of this line is deduced): qt_noop();
-
1006 QWidget *mw = static_cast<QWidget*>(layout->parent());
executed (the execution status of this line is deduced): QWidget *mw = static_cast<QWidget*>(layout->parent());
-
1007 QApplication::postEvent(mw, new QEvent(QEvent::LayoutRequest));
executed (the execution status of this line is deduced): QApplication::postEvent(mw, new QEvent(QEvent::LayoutRequest));
-
1008 break;
executed: break;
Execution Count:14783
14783
1009 } -
1010 layout = static_cast<QLayout*>(layout->parent());
executed (the execution status of this line is deduced): layout = static_cast<QLayout*>(layout->parent());
-
1011 }
executed: }
Execution Count:1113
1113
1012}
executed: }
Execution Count:106000
106000
1013 -
1014/*! -
1015 Redoes the layout for parentWidget() if necessary. -
1016 -
1017 You should generally not need to call this because it is -
1018 automatically called at the most appropriate times. It returns -
1019 true if the layout was redone. -
1020 -
1021 \sa update(), QWidget::updateGeometry() -
1022*/ -
1023bool QLayout::activate() -
1024{ -
1025 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
1026 if (!d->enabled || !parent())
partially evaluated: !d->enabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7332
partially evaluated: !parent()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7332
0-7332
1027 return false;
never executed: return false;
0
1028 if (!d->topLevel)
partially evaluated: !d->topLevel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7332
0-7332
1029 return static_cast<QLayout*>(parent())->activate();
never executed: return static_cast<QLayout*>(parent())->activate();
0
1030 if (d->activated)
evaluated: d->activated
TRUEFALSE
yes
Evaluation Count:3192
yes
Evaluation Count:4140
3192-4140
1031 return false;
executed: return false;
Execution Count:3192
3192
1032 QWidget *mw = static_cast<QWidget*>(parent());
executed (the execution status of this line is deduced): QWidget *mw = static_cast<QWidget*>(parent());
-
1033 if (mw == 0) {
partially evaluated: mw == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4140
0-4140
1034 qWarning("QLayout::activate: %s \"%s\" does not have a main widget",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qlayout.cpp", 1034, __PRETTY_FUNCTION__).warning("QLayout::activate: %s \"%s\" does not have a main widget",
-
1035 QObject::metaObject()->className(), QObject::objectName().toLocal8Bit().data());
never executed (the execution status of this line is deduced): QObject::metaObject()->className(), QObject::objectName().toLocal8Bit().data());
-
1036 return false;
never executed: return false;
0
1037 } -
1038 activateRecursiveHelper(this);
executed (the execution status of this line is deduced): activateRecursiveHelper(this);
-
1039 -
1040 QWidgetPrivate *md = mw->d_func();
executed (the execution status of this line is deduced): QWidgetPrivate *md = mw->d_func();
-
1041 uint explMin = md->extra ? md->extra->explicitMinSize : 0;
evaluated: md->extra
TRUEFALSE
yes
Evaluation Count:2343
yes
Evaluation Count:1797
1797-2343
1042 uint explMax = md->extra ? md->extra->explicitMaxSize : 0;
evaluated: md->extra
TRUEFALSE
yes
Evaluation Count:2343
yes
Evaluation Count:1797
1797-2343
1043 -
1044 switch (d->constraint) { -
1045 case SetFixedSize: -
1046 // will trigger resize -
1047 mw->setFixedSize(totalSizeHint());
executed (the execution status of this line is deduced): mw->setFixedSize(totalSizeHint());
-
1048 break;
executed: break;
Execution Count:14
14
1049 case SetMinimumSize: -
1050 mw->setMinimumSize(totalMinimumSize());
never executed (the execution status of this line is deduced): mw->setMinimumSize(totalMinimumSize());
-
1051 break;
never executed: break;
0
1052 case SetMaximumSize: -
1053 mw->setMaximumSize(totalMaximumSize());
executed (the execution status of this line is deduced): mw->setMaximumSize(totalMaximumSize());
-
1054 break;
executed: break;
Execution Count:1147
1147
1055 case SetMinAndMaxSize: -
1056 mw->setMinimumSize(totalMinimumSize());
executed (the execution status of this line is deduced): mw->setMinimumSize(totalMinimumSize());
-
1057 mw->setMaximumSize(totalMaximumSize());
executed (the execution status of this line is deduced): mw->setMaximumSize(totalMaximumSize());
-
1058 break;
executed: break;
Execution Count:151
151
1059 case SetDefaultConstraint: { -
1060 bool widthSet = explMin & Qt::Horizontal;
executed (the execution status of this line is deduced): bool widthSet = explMin & Qt::Horizontal;
-
1061 bool heightSet = explMin & Qt::Vertical;
executed (the execution status of this line is deduced): bool heightSet = explMin & Qt::Vertical;
-
1062 if (mw->isWindow()) {
evaluated: mw->isWindow()
TRUEFALSE
yes
Evaluation Count:718
yes
Evaluation Count:1367
718-1367
1063 QSize ms = totalMinimumSize();
executed (the execution status of this line is deduced): QSize ms = totalMinimumSize();
-
1064 if (widthSet)
evaluated: widthSet
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:699
19-699
1065 ms.setWidth(mw->minimumSize().width());
executed: ms.setWidth(mw->minimumSize().width());
Execution Count:19
19
1066 if (heightSet)
evaluated: heightSet
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:700
18-700
1067 ms.setHeight(mw->minimumSize().height());
executed: ms.setHeight(mw->minimumSize().height());
Execution Count:18
18
1068 if ((!heightSet || !widthSet) && hasHeightForWidth()) {
evaluated: !heightSet
TRUEFALSE
yes
Evaluation Count:700
yes
Evaluation Count:18
partially evaluated: !widthSet
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
evaluated: hasHeightForWidth()
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:671
0-700
1069 int h = minimumHeightForWidth(ms.width());
executed (the execution status of this line is deduced): int h = minimumHeightForWidth(ms.width());
-
1070 if (h > ms.height()) {
evaluated: h > ms.height()
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:6
6-23
1071 if (!heightSet)
partially evaluated: !heightSet
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-23
1072 ms.setHeight(0);
executed: ms.setHeight(0);
Execution Count:23
23
1073 if (!widthSet)
evaluated: !widthSet
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:1
1-22
1074 ms.setWidth(0);
executed: ms.setWidth(0);
Execution Count:22
22
1075 }
executed: }
Execution Count:23
23
1076 }
executed: }
Execution Count:29
29
1077 mw->setMinimumSize(ms);
executed (the execution status of this line is deduced): mw->setMinimumSize(ms);
-
1078 } else if (!widthSet || !heightSet) {
executed: }
Execution Count:718
evaluated: !widthSet
TRUEFALSE
yes
Evaluation Count:1344
yes
Evaluation Count:23
partially evaluated: !heightSet
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-1344
1079 QSize ms = mw->minimumSize();
executed (the execution status of this line is deduced): QSize ms = mw->minimumSize();
-
1080 if (!widthSet)
partially evaluated: !widthSet
TRUEFALSE
yes
Evaluation Count:1344
no
Evaluation Count:0
0-1344
1081 ms.setWidth(0);
executed: ms.setWidth(0);
Execution Count:1344
1344
1082 if (!heightSet)
evaluated: !heightSet
TRUEFALSE
yes
Evaluation Count:1336
yes
Evaluation Count:8
8-1336
1083 ms.setHeight(0);
executed: ms.setHeight(0);
Execution Count:1336
1336
1084 mw->setMinimumSize(ms);
executed (the execution status of this line is deduced): mw->setMinimumSize(ms);
-
1085 }
executed: }
Execution Count:1344
1344
1086 break;
executed: break;
Execution Count:2085
2085
1087 } -
1088 case SetNoConstraint: -
1089 break;
executed: break;
Execution Count:743
743
1090 } -
1091 -
1092 d->doResize(mw->size());
executed (the execution status of this line is deduced): d->doResize(mw->size());
-
1093 -
1094 if (md->extra) {
evaluated: md->extra
TRUEFALSE
yes
Evaluation Count:3610
yes
Evaluation Count:530
530-3610
1095 md->extra->explicitMinSize = explMin;
executed (the execution status of this line is deduced): md->extra->explicitMinSize = explMin;
-
1096 md->extra->explicitMaxSize = explMax;
executed (the execution status of this line is deduced): md->extra->explicitMaxSize = explMax;
-
1097 }
executed: }
Execution Count:3610
3610
1098 // ideally only if sizeHint() or sizePolicy() has changed -
1099 mw->updateGeometry();
executed (the execution status of this line is deduced): mw->updateGeometry();
-
1100 return true;
executed: return true;
Execution Count:4140
4140
1101} -
1102 -
1103/*! -
1104 \fn QLayoutItem *QLayout::itemAt(int index) const -
1105 -
1106 Must be implemented in subclasses to return the layout item at \a -
1107 index. If there is no such item, the function must return 0. -
1108 Items are numbered consecutively from 0. If an item is deleted, other items will be renumbered. -
1109 -
1110 This function can be used to iterate over a layout. The following -
1111 code will draw a rectangle for each layout item in the layout structure of the widget. -
1112 -
1113 \snippet code/src_gui_kernel_qlayout.cpp 0 -
1114 -
1115 \sa count(), takeAt() -
1116*/ -
1117 -
1118/*! -
1119 \fn QLayoutItem *QLayout::takeAt(int index) -
1120 -
1121 Must be implemented in subclasses to remove the layout item at \a -
1122 index from the layout, and return the item. If there is no such -
1123 item, the function must do nothing and return 0. Items are numbered -
1124 consecutively from 0. If an item is removed, other items will be -
1125 renumbered. -
1126 -
1127 The following code fragment shows a safe way to remove all items -
1128 from a layout: -
1129 -
1130 \snippet code/src_gui_kernel_qlayout.cpp 1 -
1131 -
1132 \sa itemAt(), count() -
1133*/ -
1134 -
1135/*! -
1136 \fn int *QLayout::count() const -
1137 -
1138 Must be implemented in subclasses to return the number of items -
1139 in the layout. -
1140 -
1141 \sa itemAt() -
1142*/ -
1143 -
1144/*! -
1145 Searches for widget \a widget in this layout (not including child -
1146 layouts). -
1147 -
1148 Returns the index of \a widget, or -1 if \a widget is not found. -
1149 -
1150 The default implementation iterates over all items using itemAt() -
1151*/ -
1152int QLayout::indexOf(QWidget *widget) const -
1153{ -
1154 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1155 QLayoutItem *item = itemAt(i);
executed (the execution status of this line is deduced): QLayoutItem *item = itemAt(i);
-
1156 while (item) {
evaluated: item
TRUEFALSE
yes
Evaluation Count:434
yes
Evaluation Count:7
7-434
1157 if (item->widget() == widget)
evaluated: item->widget() == widget
TRUEFALSE
yes
Evaluation Count:324
yes
Evaluation Count:110
110-324
1158 return i;
executed: return i;
Execution Count:324
324
1159 ++i;
executed (the execution status of this line is deduced): ++i;
-
1160 item = itemAt(i);
executed (the execution status of this line is deduced): item = itemAt(i);
-
1161 }
executed: }
Execution Count:110
110
1162 return -1;
executed: return -1;
Execution Count:7
7
1163} -
1164 -
1165/*! -
1166 \enum QLayout::SizeConstraint -
1167 -
1168 The possible values are: -
1169 -
1170 \value SetDefaultConstraint The main widget's minimum size is set -
1171 to minimumSize(), unless the widget already has -
1172 a minimum size. -
1173 -
1174 \value SetFixedSize The main widget's size is set to sizeHint(); it -
1175 cannot be resized at all. -
1176 \value SetMinimumSize The main widget's minimum size is set to -
1177 minimumSize(); it cannot be smaller. -
1178 -
1179 \value SetMaximumSize The main widget's maximum size is set to -
1180 maximumSize(); it cannot be larger. -
1181 -
1182 \value SetMinAndMaxSize The main widget's minimum size is set to -
1183 minimumSize() and its maximum size is set to -
1184 maximumSize(). -
1185 -
1186 \value SetNoConstraint The widget is not constrained. -
1187 -
1188 \sa setSizeConstraint() -
1189*/ -
1190 -
1191/*! -
1192 \property QLayout::sizeConstraint -
1193 \brief the resize mode of the layout -
1194 -
1195 The default mode is \l {QLayout::SetDefaultConstraint} -
1196 {SetDefaultConstraint}. -
1197*/ -
1198void QLayout::setSizeConstraint(SizeConstraint constraint) -
1199{ -
1200 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
1201 if (constraint == d->constraint)
partially evaluated: constraint == d->constraint
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10364
0-10364
1202 return;
never executed: return;
0
1203 -
1204 d->constraint = constraint;
executed (the execution status of this line is deduced): d->constraint = constraint;
-
1205 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
1206}
executed: }
Execution Count:10364
10364
1207 -
1208QLayout::SizeConstraint QLayout::sizeConstraint() const -
1209{ -
1210 Q_D(const QLayout);
never executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
1211 return d->constraint;
never executed: return d->constraint;
0
1212} -
1213 -
1214/*! -
1215 Returns the rectangle that should be covered when the geometry of -
1216 this layout is set to \a r, provided that this layout supports -
1217 setAlignment(). -
1218 -
1219 The result is derived from sizeHint() and expanding(). It is never -
1220 larger than \a r. -
1221*/ -
1222QRect QLayout::alignmentRect(const QRect &r) const -
1223{ -
1224 QSize s = sizeHint();
executed (the execution status of this line is deduced): QSize s = sizeHint();
-
1225 Qt::Alignment a = alignment();
executed (the execution status of this line is deduced): Qt::Alignment a = alignment();
-
1226 -
1227 /* -
1228 This is a hack to obtain the real maximum size, not -
1229 QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX), the value consistently -
1230 returned by QLayoutItems that have an alignment. -
1231 */ -
1232 QLayout *that = const_cast<QLayout *>(this);
executed (the execution status of this line is deduced): QLayout *that = const_cast<QLayout *>(this);
-
1233 that->setAlignment(0);
executed (the execution status of this line is deduced): that->setAlignment(0);
-
1234 QSize ms = that->maximumSize();
executed (the execution status of this line is deduced): QSize ms = that->maximumSize();
-
1235 that->setAlignment(a);
executed (the execution status of this line is deduced): that->setAlignment(a);
-
1236 -
1237 if ((expandingDirections() & Qt::Horizontal) ||
partially evaluated: (expandingDirections() & Qt::Horizontal)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1238 !(a & Qt::AlignHorizontal_Mask)) {
partially evaluated: !(a & Qt::AlignHorizontal_Mask)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1239 s.setWidth(qMin(r.width(), ms.width()));
never executed (the execution status of this line is deduced): s.setWidth(qMin(r.width(), ms.width()));
-
1240 }
never executed: }
0
1241 if ((expandingDirections() & Qt::Vertical) ||
partially evaluated: (expandingDirections() & Qt::Vertical)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1242 !(a & Qt::AlignVertical_Mask)) {
partially evaluated: !(a & Qt::AlignVertical_Mask)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1243 s.setHeight(qMin(r.height(), ms.height()));
executed (the execution status of this line is deduced): s.setHeight(qMin(r.height(), ms.height()));
-
1244 } else if (hasHeightForWidth()) {
executed: }
Execution Count:3
never evaluated: hasHeightForWidth()
0-3
1245 int hfw = heightForWidth(s.width());
never executed (the execution status of this line is deduced): int hfw = heightForWidth(s.width());
-
1246 if (hfw < s.height())
never evaluated: hfw < s.height()
0
1247 s.setHeight(qMin(hfw, ms.height()));
never executed: s.setHeight(qMin(hfw, ms.height()));
0
1248 }
never executed: }
0
1249 -
1250 s = s.boundedTo(r.size());
executed (the execution status of this line is deduced): s = s.boundedTo(r.size());
-
1251 int x = r.x();
executed (the execution status of this line is deduced): int x = r.x();
-
1252 int y = r.y();
executed (the execution status of this line is deduced): int y = r.y();
-
1253 -
1254 if (a & Qt::AlignBottom)
partially evaluated: a & Qt::AlignBottom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1255 y += (r.height() - s.height());
never executed: y += (r.height() - s.height());
0
1256 else if (!(a & Qt::AlignTop))
partially evaluated: !(a & Qt::AlignTop)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1257 y += (r.height() - s.height()) / 2;
executed: y += (r.height() - s.height()) / 2;
Execution Count:3
3
1258 -
1259 QWidget *parent = parentWidget();
never executed (the execution status of this line is deduced): QWidget *parent = parentWidget();
-
1260 a = QStyle::visualAlignment(parent ? parent->layoutDirection() : QApplication::layoutDirection(), a);
never executed (the execution status of this line is deduced): a = QStyle::visualAlignment(parent ? parent->layoutDirection() : QApplication::layoutDirection(), a);
-
1261 if (a & Qt::AlignRight)
partially evaluated: a & Qt::AlignRight
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1262 x += (r.width() - s.width());
executed: x += (r.width() - s.width());
Execution Count:3
3
1263 else if (!(a & Qt::AlignLeft))
never evaluated: !(a & Qt::AlignLeft)
0
1264 x += (r.width() - s.width()) / 2;
never executed: x += (r.width() - s.width()) / 2;
0
1265 -
1266 return QRect(x, y, s.width(), s.height());
executed: return QRect(x, y, s.width(), s.height());
Execution Count:3
3
1267} -
1268 -
1269/*! -
1270 Removes the widget \a widget from the layout. After this call, it -
1271 is the caller's responsibility to give the widget a reasonable -
1272 geometry or to put the widget back into a layout. -
1273 -
1274 \b{Note:} The ownership of \a widget remains the same as -
1275 when it was added. -
1276 -
1277 \sa removeItem(), QWidget::setGeometry(), addWidget() -
1278*/ -
1279void QLayout::removeWidget(QWidget *widget) -
1280{ -
1281 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1282 QLayoutItem *child;
executed (the execution status of this line is deduced): QLayoutItem *child;
-
1283 while ((child = itemAt(i))) {
evaluated: (child = itemAt(i))
TRUEFALSE
yes
Evaluation Count:283
yes
Evaluation Count:110
110-283
1284 if (child->widget() == widget) {
evaluated: child->widget() == widget
TRUEFALSE
yes
Evaluation Count:94
yes
Evaluation Count:189
94-189
1285 delete takeAt(i);
executed (the execution status of this line is deduced): delete takeAt(i);
-
1286 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
1287 } else {
executed: }
Execution Count:94
94
1288 ++i;
executed (the execution status of this line is deduced): ++i;
-
1289 }
executed: }
Execution Count:189
189
1290 } -
1291}
executed: }
Execution Count:110
110
1292 -
1293/*! -
1294 Removes the layout item \a item from the layout. It is the -
1295 caller's responsibility to delete the item. -
1296 -
1297 Notice that \a item can be a layout (since QLayout inherits -
1298 QLayoutItem). -
1299 -
1300 \sa removeWidget(), addItem() -
1301*/ -
1302void QLayout::removeItem(QLayoutItem *item) -
1303{ -
1304 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1305 QLayoutItem *child;
executed (the execution status of this line is deduced): QLayoutItem *child;
-
1306 while ((child = itemAt(i))) {
evaluated: (child = itemAt(i))
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:32
32-53
1307 if (child == item) {
evaluated: child == item
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:21
21-32
1308 takeAt(i);
executed (the execution status of this line is deduced): takeAt(i);
-
1309 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
1310 } else {
executed: }
Execution Count:32
32
1311 ++i;
executed (the execution status of this line is deduced): ++i;
-
1312 }
executed: }
Execution Count:21
21
1313 } -
1314}
executed: }
Execution Count:32
32
1315 -
1316/*! -
1317 Enables this layout if \a enable is true, otherwise disables it. -
1318 -
1319 An enabled layout adjusts dynamically to changes; a disabled -
1320 layout acts as if it did not exist. -
1321 -
1322 By default all layouts are enabled. -
1323 -
1324 \sa isEnabled() -
1325*/ -
1326void QLayout::setEnabled(bool enable) -
1327{ -
1328 Q_D(QLayout);
executed (the execution status of this line is deduced): QLayoutPrivate * const d = d_func();
-
1329 d->enabled = enable;
executed (the execution status of this line is deduced): d->enabled = enable;
-
1330}
executed: }
Execution Count:468
468
1331 -
1332/*! -
1333 Returns true if the layout is enabled; otherwise returns false. -
1334 -
1335 \sa setEnabled() -
1336*/ -
1337bool QLayout::isEnabled() const -
1338{ -
1339 Q_D(const QLayout);
executed (the execution status of this line is deduced): const QLayoutPrivate * const d = d_func();
-
1340 return d->enabled;
executed: return d->enabled;
Execution Count:234
234
1341} -
1342 -
1343/*! -
1344 Returns a size that satisfies all size constraints on \a widget, -
1345 including heightForWidth() and that is as close as possible to \a -
1346 size. -
1347*/ -
1348 -
1349QSize QLayout::closestAcceptableSize(const QWidget *widget, const QSize &size) -
1350{ -
1351 QSize result = size.boundedTo(qSmartMaxSize(widget));
never executed (the execution status of this line is deduced): QSize result = size.boundedTo(qSmartMaxSize(widget));
-
1352 result = result.expandedTo(qSmartMinSize(widget));
never executed (the execution status of this line is deduced): result = result.expandedTo(qSmartMinSize(widget));
-
1353 QLayout *l = widget->layout();
never executed (the execution status of this line is deduced): QLayout *l = widget->layout();
-
1354 if (l && l->hasHeightForWidth() && result.height() < l->minimumHeightForWidth(result.width()) ) {
never evaluated: l
never evaluated: l->hasHeightForWidth()
never evaluated: result.height() < l->minimumHeightForWidth(result.width())
0
1355 QSize current = widget->size();
never executed (the execution status of this line is deduced): QSize current = widget->size();
-
1356 int currentHfw = l->minimumHeightForWidth(current.width());
never executed (the execution status of this line is deduced): int currentHfw = l->minimumHeightForWidth(current.width());
-
1357 int newHfw = l->minimumHeightForWidth(result.width());
never executed (the execution status of this line is deduced): int newHfw = l->minimumHeightForWidth(result.width());
-
1358 if (current.height() < currentHfw || currentHfw == newHfw) {
never evaluated: current.height() < currentHfw
never evaluated: currentHfw == newHfw
0
1359 //handle the constant hfw case and the vertical-only case, as well as the -
1360 // current-size-is-not-correct case -
1361 result.setHeight(newHfw);
never executed (the execution status of this line is deduced): result.setHeight(newHfw);
-
1362 } else {
never executed: }
0
1363 // binary search; assume hfw is decreasing ### -
1364 -
1365 int maxw = qMax(widget->width(),result.width());
never executed (the execution status of this line is deduced): int maxw = qMax(widget->width(),result.width());
-
1366 int maxh = qMax(widget->height(), result.height());
never executed (the execution status of this line is deduced): int maxh = qMax(widget->height(), result.height());
-
1367 int minw = qMin(widget->width(),result.width());
never executed (the execution status of this line is deduced): int minw = qMin(widget->width(),result.width());
-
1368 int minh = qMin(widget->height(), result.height());
never executed (the execution status of this line is deduced): int minh = qMin(widget->height(), result.height());
-
1369 -
1370 int minhfw = l->minimumHeightForWidth(minw);
never executed (the execution status of this line is deduced): int minhfw = l->minimumHeightForWidth(minw);
-
1371 int maxhfw = l->minimumHeightForWidth(maxw);
never executed (the execution status of this line is deduced): int maxhfw = l->minimumHeightForWidth(maxw);
-
1372 while (minw < maxw) {
never evaluated: minw < maxw
0
1373 if (minhfw > maxh) { //assume decreasing
never evaluated: minhfw > maxh
0
1374 minw = maxw - (maxw-minw)/2;
never executed (the execution status of this line is deduced): minw = maxw - (maxw-minw)/2;
-
1375 minhfw = l->minimumHeightForWidth(minw);
never executed (the execution status of this line is deduced): minhfw = l->minimumHeightForWidth(minw);
-
1376 } else if (maxhfw < minh ) { //assume decreasing
never executed: }
never evaluated: maxhfw < minh
0
1377 maxw = minw + (maxw-minw)/2;
never executed (the execution status of this line is deduced): maxw = minw + (maxw-minw)/2;
-
1378 maxhfw = l->minimumHeightForWidth(maxw);
never executed (the execution status of this line is deduced): maxhfw = l->minimumHeightForWidth(maxw);
-
1379 } else {
never executed: }
0
1380 break;
never executed: break;
0
1381 } -
1382 } -
1383 result = result.expandedTo(QSize(minw, minhfw));
never executed (the execution status of this line is deduced): result = result.expandedTo(QSize(minw, minhfw));
-
1384 }
never executed: }
0
1385 } -
1386 return result;
never executed: return result;
0
1387} -
1388 -
1389void QSizePolicy::setControlType(ControlType type) -
1390{ -
1391 /* -
1392 The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10, -
1393 etc. In memory, we pack it onto the available bits (CTSize) in -
1394 setControlType(), and unpack it here. -
1395 -
1396 Example: -
1397 -
1398 0x00000001 maps to 0 -
1399 0x00000002 maps to 1 -
1400 0x00000004 maps to 2 -
1401 0x00000008 maps to 3 -
1402 etc. -
1403 */ -
1404 -
1405 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1406 while (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:293123
no
Evaluation Count:0
0-293123
1407 if (type & (0x1 << i)) {
evaluated: type & (0x1 << i)
TRUEFALSE
yes
Evaluation Count:88373
yes
Evaluation Count:204750
88373-204750
1408 bits.ctype = i;
executed (the execution status of this line is deduced): bits.ctype = i;
-
1409 return;
executed: return;
Execution Count:88373
88373
1410 } -
1411 ++i;
executed (the execution status of this line is deduced): ++i;
-
1412 }
executed: }
Execution Count:204750
204750
1413}
never executed: }
0
1414 -
1415QSizePolicy::ControlType QSizePolicy::controlType() const -
1416{ -
1417 return QSizePolicy::ControlType(1 << bits.ctype);
executed: return QSizePolicy::ControlType(1 << bits.ctype);
Execution Count:26848
26848
1418} -
1419 -
1420#ifndef QT_NO_DATASTREAM -
1421 -
1422/*! -
1423 \relates QSizePolicy -
1424 \since 4.2 -
1425 -
1426 Writes the size \a policy to the data stream \a stream. -
1427 -
1428 \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -
1429*/ -
1430QDataStream &operator<<(QDataStream &stream, const QSizePolicy &policy) -
1431{ -
1432 // The order here is for historical reasons. (compatibility with Qt4) -
1433 quint32 data = (policy.bits.horPolicy | // [0, 3]
executed (the execution status of this line is deduced): quint32 data = (policy.bits.horPolicy |
-
1434 policy.bits.verPolicy << 4 | // [4, 7]
executed (the execution status of this line is deduced): policy.bits.verPolicy << 4 |
-
1435 policy.bits.hfw << 8 | // [8]
executed (the execution status of this line is deduced): policy.bits.hfw << 8 |
-
1436 policy.bits.ctype << 9 | // [9, 13]
executed (the execution status of this line is deduced): policy.bits.ctype << 9 |
-
1437 policy.bits.wfh << 14 | // [14]
executed (the execution status of this line is deduced): policy.bits.wfh << 14 |
-
1438 //policy.bits.padding << 15 | // [15]
executed (the execution status of this line is deduced):
-
1439 policy.bits.verStretch << 16 | // [16, 23]
executed (the execution status of this line is deduced): policy.bits.verStretch << 16 |
-
1440 policy.bits.horStretch << 24); // [24, 31]
executed (the execution status of this line is deduced): policy.bits.horStretch << 24);
-
1441 return stream << data;
executed: return stream << data;
Execution Count:2
2
1442} -
1443 -
1444#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1)) -
1445 -
1446/*! -
1447 \relates QSizePolicy -
1448 \since 4.2 -
1449 -
1450 Reads the size \a policy from the data stream \a stream. -
1451 -
1452 \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -
1453*/ -
1454QDataStream &operator>>(QDataStream &stream, QSizePolicy &policy) -
1455{ -
1456 quint32 data;
executed (the execution status of this line is deduced): quint32 data;
-
1457 stream >> data;
executed (the execution status of this line is deduced): stream >> data;
-
1458 policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4);
executed (the execution status of this line is deduced): policy.bits.horPolicy = ((data >> 0) & ((1 << 4) -1));
-
1459 policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4);
executed (the execution status of this line is deduced): policy.bits.verPolicy = ((data >> 4) & ((1 << 4) -1));
-
1460 policy.bits.hfw = VALUE_OF_BITS(data, 8, 1);
executed (the execution status of this line is deduced): policy.bits.hfw = ((data >> 8) & ((1 << 1) -1));
-
1461 policy.bits.ctype = VALUE_OF_BITS(data, 9, 5);
executed (the execution status of this line is deduced): policy.bits.ctype = ((data >> 9) & ((1 << 5) -1));
-
1462 policy.bits.wfh = VALUE_OF_BITS(data, 14, 1);
executed (the execution status of this line is deduced): policy.bits.wfh = ((data >> 14) & ((1 << 1) -1));
-
1463 policy.bits.padding = 0;
executed (the execution status of this line is deduced): policy.bits.padding = 0;
-
1464 policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8);
executed (the execution status of this line is deduced): policy.bits.verStretch = ((data >> 16) & ((1 << 8) -1));
-
1465 policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8);
executed (the execution status of this line is deduced): policy.bits.horStretch = ((data >> 24) & ((1 << 8) -1));
-
1466 return stream;
executed: return stream;
Execution Count:2
2
1467} -
1468#endif // QT_NO_DATASTREAM -
1469 -
1470QT_END_NAMESPACE -
1471 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial