widgets/qsplitter.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 "qsplitter.h" -
43#ifndef QT_NO_SPLITTER -
44 -
45#include "qapplication.h" -
46#include "qcursor.h" -
47#include "qdrawutil.h" -
48#include "qevent.h" -
49#include "qlayout.h" -
50#include "qlist.h" -
51#include "qpainter.h" -
52#include "qrubberband.h" -
53#include "qstyle.h" -
54#include "qstyleoption.h" -
55#include "qtextstream.h" -
56#include "qvarlengtharray.h" -
57#include "qvector.h" -
58#include "private/qlayoutengine_p.h" -
59#include "private/qsplitter_p.h" -
60#include "qtimer.h" -
61#include "qdebug.h" -
62 -
63#include <ctype.h> -
64 -
65QT_BEGIN_NAMESPACE -
66 -
67//#define QSPLITTER_DEBUG -
68 -
69/*! -
70 \class QSplitterHandle -
71 \brief The QSplitterHandle class provides handle functionality for the splitter. -
72 -
73 \ingroup organizers -
74 \inmodule QtWidgets -
75 -
76 QSplitterHandle is typically what people think about when they think about -
77 a splitter. It is the handle that is used to resize the widgets. -
78 -
79 A typical developer using QSplitter will never have to worry about -
80 QSplitterHandle. It is provided for developers who want splitter handles -
81 that provide extra features, such as popup menus. -
82 -
83 The typical way one would create splitter handles is to subclass QSplitter and then -
84 reimplement QSplitter::createHandle() to instantiate the custom splitter -
85 handle. For example, a minimum QSplitter subclass might look like this: -
86 -
87 \snippet splitterhandle/splitter.h 0 -
88 -
89 The \l{QSplitter::}{createHandle()} implementation simply constructs a -
90 custom splitter handle, called \c Splitter in this example: -
91 -
92 \snippet splitterhandle/splitter.cpp 1 -
93 -
94 Information about a given handle can be obtained using functions like -
95 orientation() and opaqueResize(), and is retrieved from its parent splitter. -
96 Details like these can be used to give custom handles different appearances -
97 depending on the splitter's orientation. -
98 -
99 The complexity of a custom handle subclass depends on the tasks that it -
100 needs to perform. A simple subclass might only provide a paintEvent() -
101 implementation: -
102 -
103 \snippet splitterhandle/splitter.cpp 0 -
104 -
105 In this example, a predefined gradient is set up differently depending on -
106 the orientation of the handle. QSplitterHandle provides a reasonable -
107 size hint for the handle, so the subclass does not need to provide a -
108 reimplementation of sizeHint() unless the handle has special size -
109 requirements. -
110 -
111 \sa QSplitter -
112*/ -
113 -
114/*! -
115 Creates a QSplitter handle with the given \a orientation and -
116 \a parent. -
117*/ -
118QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent) -
119 : QWidget(*new QSplitterHandlePrivate, parent, 0) -
120{ -
121 Q_D(QSplitterHandle);
executed (the execution status of this line is deduced): QSplitterHandlePrivate * const d = d_func();
-
122 d->s = parent;
executed (the execution status of this line is deduced): d->s = parent;
-
123 setOrientation(orientation);
executed (the execution status of this line is deduced): setOrientation(orientation);
-
124}
executed: }
Execution Count:862
862
125 -
126/*! -
127 Destructor. -
128*/ -
129QSplitterHandle::~QSplitterHandle() -
130{ -
131} -
132 -
133/*! -
134 Sets the orientation of the splitter handle to \a orientation. -
135 This is usually propagated from the QSplitter. -
136 -
137 \sa QSplitter::setOrientation() -
138*/ -
139void QSplitterHandle::setOrientation(Qt::Orientation orientation) -
140{ -
141 Q_D(QSplitterHandle);
executed (the execution status of this line is deduced): QSplitterHandlePrivate * const d = d_func();
-
142 d->orient = orientation;
executed (the execution status of this line is deduced): d->orient = orientation;
-
143#ifndef QT_NO_CURSOR -
144 setCursor(orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor);
executed (the execution status of this line is deduced): setCursor(orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor);
-
145#endif -
146}
executed: }
Execution Count:880
880
147 -
148/*! -
149 Returns the handle's orientation. This is usually propagated from the QSplitter. -
150 -
151 \sa QSplitter::orientation() -
152*/ -
153Qt::Orientation QSplitterHandle::orientation() const -
154{ -
155 Q_D(const QSplitterHandle);
executed (the execution status of this line is deduced): const QSplitterHandlePrivate * const d = d_func();
-
156 return d->orient;
executed: return d->orient;
Execution Count:50
50
157} -
158 -
159 -
160/*! -
161 Returns true if widgets are resized dynamically (opaquely), otherwise -
162 returns false. This value is controlled by the QSplitter. -
163 -
164 \sa QSplitter::opaqueResize() -
165 -
166*/ -
167bool QSplitterHandle::opaqueResize() const -
168{ -
169 Q_D(const QSplitterHandle);
never executed (the execution status of this line is deduced): const QSplitterHandlePrivate * const d = d_func();
-
170 return d->s->opaqueResize();
never executed: return d->s->opaqueResize();
0
171} -
172 -
173 -
174/*! -
175 Returns the splitter associated with this splitter handle. -
176 -
177 \sa QSplitter::handle() -
178*/ -
179QSplitter *QSplitterHandle::splitter() const -
180{ -
181 return d_func()->s;
never executed: return d_func()->s;
0
182} -
183 -
184/*! -
185 Tells the splitter to move this handle to position \a pos, which is -
186 the distance from the left or top edge of the widget. -
187 -
188 Note that \a pos is also measured from the left (or top) for -
189 right-to-left languages. This function will map \a pos to the -
190 appropriate position before calling QSplitter::moveSplitter(). -
191 -
192 \sa QSplitter::moveSplitter(), closestLegalPosition() -
193*/ -
194void QSplitterHandle::moveSplitter(int pos) -
195{ -
196 Q_D(QSplitterHandle);
never executed (the execution status of this line is deduced): QSplitterHandlePrivate * const d = d_func();
-
197 if (d->s->isRightToLeft() && d->orient == Qt::Horizontal)
never evaluated: d->s->isRightToLeft()
never evaluated: d->orient == Qt::Horizontal
0
198 pos = d->s->contentsRect().width() - pos;
never executed: pos = d->s->contentsRect().width() - pos;
0
199 d->s->moveSplitter(pos, d->s->indexOf(this));
never executed (the execution status of this line is deduced): d->s->moveSplitter(pos, d->s->indexOf(this));
-
200}
never executed: }
0
201 -
202/*! -
203 Returns the closest legal position to \a pos of the splitter -
204 handle. The positions are measured from the left or top edge of -
205 the splitter, even for right-to-left languages. -
206 -
207 \sa QSplitter::closestLegalPosition(), moveSplitter() -
208*/ -
209 -
210int QSplitterHandle::closestLegalPosition(int pos) -
211{ -
212 Q_D(QSplitterHandle);
never executed (the execution status of this line is deduced): QSplitterHandlePrivate * const d = d_func();
-
213 QSplitter *s = d->s;
never executed (the execution status of this line is deduced): QSplitter *s = d->s;
-
214 if (s->isRightToLeft() && d->orient == Qt::Horizontal) {
never evaluated: s->isRightToLeft()
never evaluated: d->orient == Qt::Horizontal
0
215 int w = s->contentsRect().width();
never executed (the execution status of this line is deduced): int w = s->contentsRect().width();
-
216 return w - s->closestLegalPosition(w - pos, s->indexOf(this));
never executed: return w - s->closestLegalPosition(w - pos, s->indexOf(this));
0
217 } -
218 return s->closestLegalPosition(pos, s->indexOf(this));
never executed: return s->closestLegalPosition(pos, s->indexOf(this));
0
219} -
220 -
221/*! -
222 \reimp -
223*/ -
224QSize QSplitterHandle::sizeHint() const -
225{ -
226 Q_D(const QSplitterHandle);
executed (the execution status of this line is deduced): const QSplitterHandlePrivate * const d = d_func();
-
227 int hw = d->s->handleWidth();
executed (the execution status of this line is deduced): int hw = d->s->handleWidth();
-
228 QStyleOption opt(0);
executed (the execution status of this line is deduced): QStyleOption opt(0);
-
229 opt.init(d->s);
executed (the execution status of this line is deduced): opt.init(d->s);
-
230 opt.state = QStyle::State_None;
executed (the execution status of this line is deduced): opt.state = QStyle::State_None;
-
231 return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s)
executed: return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s) .expandedTo(QApplication::globalStrut());
Execution Count:8195
8195
232 .expandedTo(QApplication::globalStrut());
executed: return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s) .expandedTo(QApplication::globalStrut());
Execution Count:8195
8195
233} -
234 -
235/*! -
236 \reimp -
237*/ -
238void QSplitterHandle::resizeEvent(QResizeEvent *event) -
239{ -
240 Q_D(const QSplitterHandle);
executed (the execution status of this line is deduced): const QSplitterHandlePrivate * const d = d_func();
-
241 -
242 // When splitters are only 1 or 0 pixel large we increase the -
243 // actual grab area to five pixels -
244 -
245 // Note that QSplitter uses contentsRect for layouting -
246 // and ensures that handles are drawn on top of widgets -
247 // We simply use the contents margins for draggin and only -
248 // paint the mask area -
249 bool useTinyMode = (d->s->handleWidth() <= 1);
executed (the execution status of this line is deduced): bool useTinyMode = (d->s->handleWidth() <= 1);
-
250 setAttribute(Qt::WA_MouseNoMask, useTinyMode);
executed (the execution status of this line is deduced): setAttribute(Qt::WA_MouseNoMask, useTinyMode);
-
251 if (useTinyMode) {
partially evaluated: useTinyMode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:80
0-80
252 if (orientation() == Qt::Horizontal)
never evaluated: orientation() == Qt::Horizontal
0
253 setContentsMargins(2, 0, 2, 0);
never executed: setContentsMargins(2, 0, 2, 0);
0
254 else -
255 setContentsMargins(0, 2, 0, 2);
never executed: setContentsMargins(0, 2, 0, 2);
0
256 setMask(QRegion(contentsRect()));
never executed (the execution status of this line is deduced): setMask(QRegion(contentsRect()));
-
257 }
never executed: }
0
258 -
259 QWidget::resizeEvent(event);
executed (the execution status of this line is deduced): QWidget::resizeEvent(event);
-
260}
executed: }
Execution Count:80
80
261 -
262/*! -
263 \reimp -
264*/ -
265bool QSplitterHandle::event(QEvent *event) -
266{ -
267 Q_D(QSplitterHandle);
executed (the execution status of this line is deduced): QSplitterHandlePrivate * const d = d_func();
-
268 switch(event->type()) { -
269 case QEvent::HoverEnter: -
270 d->hover = true;
never executed (the execution status of this line is deduced): d->hover = true;
-
271 update();
never executed (the execution status of this line is deduced): update();
-
272 break;
never executed: break;
0
273 case QEvent::HoverLeave: -
274 d->hover = false;
never executed (the execution status of this line is deduced): d->hover = false;
-
275 update();
never executed (the execution status of this line is deduced): update();
-
276 break;
never executed: break;
0
277 default: -
278 break;
executed: break;
Execution Count:3244
3244
279 } -
280 return QWidget::event(event);
executed: return QWidget::event(event);
Execution Count:3244
3244
281} -
282 -
283/*! -
284 \reimp -
285*/ -
286void QSplitterHandle::mouseMoveEvent(QMouseEvent *e) -
287{ -
288 Q_D(QSplitterHandle);
never executed (the execution status of this line is deduced): QSplitterHandlePrivate * const d = d_func();
-
289 if (!(e->buttons() & Qt::LeftButton))
never evaluated: !(e->buttons() & Qt::LeftButton)
0
290 return;
never executed: return;
0
291 int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos()))
never executed (the execution status of this line is deduced): int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos()))
-
292 - d->mouseOffset;
never executed (the execution status of this line is deduced): - d->mouseOffset;
-
293 if (opaqueResize()) {
never evaluated: opaqueResize()
0
294 moveSplitter(pos);
never executed (the execution status of this line is deduced): moveSplitter(pos);
-
295 } else {
never executed: }
0
296 d->s->setRubberBand(closestLegalPosition(pos));
never executed (the execution status of this line is deduced): d->s->setRubberBand(closestLegalPosition(pos));
-
297 }
never executed: }
0
298} -
299 -
300/*! -
301 \reimp -
302*/ -
303void QSplitterHandle::mousePressEvent(QMouseEvent *e) -
304{ -
305 Q_D(QSplitterHandle);
never executed (the execution status of this line is deduced): QSplitterHandlePrivate * const d = d_func();
-
306 if (e->button() == Qt::LeftButton) {
never evaluated: e->button() == Qt::LeftButton
0
307 d->mouseOffset = d->pick(e->pos());
never executed (the execution status of this line is deduced): d->mouseOffset = d->pick(e->pos());
-
308 d->pressed = true;
never executed (the execution status of this line is deduced): d->pressed = true;
-
309 update();
never executed (the execution status of this line is deduced): update();
-
310 }
never executed: }
0
311}
never executed: }
0
312 -
313/*! -
314 \reimp -
315*/ -
316void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e) -
317{ -
318 Q_D(QSplitterHandle);
never executed (the execution status of this line is deduced): QSplitterHandlePrivate * const d = d_func();
-
319 if (!opaqueResize() && e->button() == Qt::LeftButton) {
never evaluated: !opaqueResize()
never evaluated: e->button() == Qt::LeftButton
0
320 int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos()))
never executed (the execution status of this line is deduced): int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos()))
-
321 - d->mouseOffset;
never executed (the execution status of this line is deduced): - d->mouseOffset;
-
322 d->s->setRubberBand(-1);
never executed (the execution status of this line is deduced): d->s->setRubberBand(-1);
-
323 moveSplitter(pos);
never executed (the execution status of this line is deduced): moveSplitter(pos);
-
324 }
never executed: }
0
325 if (e->button() == Qt::LeftButton) {
never evaluated: e->button() == Qt::LeftButton
0
326 d->pressed = false;
never executed (the execution status of this line is deduced): d->pressed = false;
-
327 update();
never executed (the execution status of this line is deduced): update();
-
328 }
never executed: }
0
329}
never executed: }
0
330 -
331/*! -
332 \reimp -
333*/ -
334void QSplitterHandle::paintEvent(QPaintEvent *) -
335{ -
336 Q_D(QSplitterHandle);
executed (the execution status of this line is deduced): QSplitterHandlePrivate * const d = d_func();
-
337 QPainter p(this);
executed (the execution status of this line is deduced): QPainter p(this);
-
338 QStyleOption opt(0);
executed (the execution status of this line is deduced): QStyleOption opt(0);
-
339 opt.rect = contentsRect();
executed (the execution status of this line is deduced): opt.rect = contentsRect();
-
340 opt.palette = palette();
executed (the execution status of this line is deduced): opt.palette = palette();
-
341 if (orientation() == Qt::Horizontal)
evaluated: orientation() == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:2
2-48
342 opt.state = QStyle::State_Horizontal;
executed: opt.state = QStyle::State_Horizontal;
Execution Count:48
48
343 else -
344 opt.state = QStyle::State_None;
executed: opt.state = QStyle::State_None;
Execution Count:2
2
345 if (d->hover)
partially evaluated: d->hover
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
0-50
346 opt.state |= QStyle::State_MouseOver;
never executed: opt.state |= QStyle::State_MouseOver;
0
347 if (d->pressed)
partially evaluated: d->pressed
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
0-50
348 opt.state |= QStyle::State_Sunken;
never executed: opt.state |= QStyle::State_Sunken;
0
349 if (isEnabled())
partially evaluated: isEnabled()
TRUEFALSE
yes
Evaluation Count:50
no
Evaluation Count:0
0-50
350 opt.state |= QStyle::State_Enabled;
executed: opt.state |= QStyle::State_Enabled;
Execution Count:50
50
351 parentWidget()->style()->drawControl(QStyle::CE_Splitter, &opt, &p, d->s);
executed (the execution status of this line is deduced): parentWidget()->style()->drawControl(QStyle::CE_Splitter, &opt, &p, d->s);
-
352}
executed: }
Execution Count:50
50
353 -
354 -
355int QSplitterLayoutStruct::getWidgetSize(Qt::Orientation orient) -
356{ -
357 if (sizer == -1) {
evaluated: sizer == -1
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:2749
21-2749
358 QSize s = widget->sizeHint();
executed (the execution status of this line is deduced): QSize s = widget->sizeHint();
-
359 const int presizer = pick(s, orient);
executed (the execution status of this line is deduced): const int presizer = pick(s, orient);
-
360 const int realsize = pick(widget->size(), orient);
executed (the execution status of this line is deduced): const int realsize = pick(widget->size(), orient);
-
361 if (!s.isValid() || (widget->testAttribute(Qt::WA_Resized) && (realsize > presizer))) {
evaluated: !s.isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:19
evaluated: widget->testAttribute(Qt::WA_Resized)
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:9
partially evaluated: (realsize > presizer)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-19
362 sizer = pick(widget->size(), orient);
executed (the execution status of this line is deduced): sizer = pick(widget->size(), orient);
-
363 } else {
executed: }
Execution Count:2
2
364 sizer = presizer;
executed (the execution status of this line is deduced): sizer = presizer;
-
365 }
executed: }
Execution Count:19
19
366 QSizePolicy p = widget->sizePolicy();
executed (the execution status of this line is deduced): QSizePolicy p = widget->sizePolicy();
-
367 int sf = (orient == Qt::Horizontal) ? p.horizontalStretch() : p.verticalStretch();
evaluated: (orient == Qt::Horizontal)
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:2
2-19
368 if (sf > 1)
partially evaluated: sf > 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
369 sizer *= sf;
never executed: sizer *= sf;
0
370 }
executed: }
Execution Count:21
21
371 return sizer;
executed: return sizer;
Execution Count:2770
2770
372} -
373 -
374int QSplitterLayoutStruct::getHandleSize(Qt::Orientation orient) -
375{ -
376 return pick(handle->sizeHint(), orient);
executed: return pick(handle->sizeHint(), orient);
Execution Count:5585
5585
377} -
378 -
379void QSplitterPrivate::init() -
380{ -
381 Q_Q(QSplitter);
executed (the execution status of this line is deduced): QSplitter * const q = q_func();
-
382 QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Preferred);
executed (the execution status of this line is deduced): QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Preferred);
-
383 if (orient == Qt::Vertical)
evaluated: orient == Qt::Vertical
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:224
15-224
384 sp.transpose();
executed: sp.transpose();
Execution Count:15
15
385 q->setSizePolicy(sp);
executed (the execution status of this line is deduced): q->setSizePolicy(sp);
-
386 q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
-
387}
executed: }
Execution Count:239
239
388 -
389void QSplitterPrivate::recalc(bool update) -
390{ -
391 Q_Q(QSplitter);
executed (the execution status of this line is deduced): QSplitter * const q = q_func();
-
392 int n = list.count();
executed (the execution status of this line is deduced): int n = list.count();
-
393 /* -
394 Splitter handles before the first visible widget or right -
395 before a hidden widget must be hidden. -
396 */ -
397 bool first = true;
executed (the execution status of this line is deduced): bool first = true;
-
398 bool allInvisible = n != 0;
executed (the execution status of this line is deduced): bool allInvisible = n != 0;
-
399 for (int i = 0; i < n ; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:3877
yes
Evaluation Count:1968
1968-3877
400 QSplitterLayoutStruct *s = list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = list.at(i);
-
401 bool widgetHidden = s->widget->isHidden();
executed (the execution status of this line is deduced): bool widgetHidden = s->widget->isHidden();
-
402 if (allInvisible && !widgetHidden && !s->collapsed)
evaluated: allInvisible
TRUEFALSE
yes
Evaluation Count:2052
yes
Evaluation Count:1825
evaluated: !widgetHidden
TRUEFALSE
yes
Evaluation Count:2030
yes
Evaluation Count:22
evaluated: !s->collapsed
TRUEFALSE
yes
Evaluation Count:1909
yes
Evaluation Count:121
22-2052
403 allInvisible = false;
executed: allInvisible = false;
Execution Count:1909
1909
404 s->handle->setHidden(first || widgetHidden);
executed (the execution status of this line is deduced): s->handle->setHidden(first || widgetHidden);
-
405 if (!widgetHidden)
evaluated: !widgetHidden
TRUEFALSE
yes
Evaluation Count:3852
yes
Evaluation Count:25
25-3852
406 first = false;
executed: first = false;
Execution Count:3852
3852
407 }
executed: }
Execution Count:3877
3877
408 -
409 if (allInvisible)
evaluated: allInvisible
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:1939
29-1939
410 for (int i = 0; i < n ; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:17
17-31
411 QSplitterLayoutStruct *s = list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = list.at(i);
-
412 if (!s->widget->isHidden()) {
evaluated: !s->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:19
12-19
413 s->collapsed = false;
executed (the execution status of this line is deduced): s->collapsed = false;
-
414 break;
executed: break;
Execution Count:12
12
415 } -
416 }
executed: }
Execution Count:19
19
417 -
418 int fi = 2 * q->frameWidth();
executed (the execution status of this line is deduced): int fi = 2 * q->frameWidth();
-
419 int maxl = fi;
executed (the execution status of this line is deduced): int maxl = fi;
-
420 int minl = fi;
executed (the execution status of this line is deduced): int minl = fi;
-
421 int maxt = QWIDGETSIZE_MAX;
executed (the execution status of this line is deduced): int maxt = ((1<<24)-1);
-
422 int mint = fi;
executed (the execution status of this line is deduced): int mint = fi;
-
423 /* -
424 calculate min/max sizes for the whole splitter -
425 */ -
426 bool empty = true;
executed (the execution status of this line is deduced): bool empty = true;
-
427 for (int j = 0; j < n; j++) {
evaluated: j < n
TRUEFALSE
yes
Evaluation Count:3877
yes
Evaluation Count:1968
1968-3877
428 QSplitterLayoutStruct *s = list.at(j);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = list.at(j);
-
429 -
430 if (!s->widget->isHidden()) {
evaluated: !s->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:3852
yes
Evaluation Count:25
25-3852
431 empty = false;
executed (the execution status of this line is deduced): empty = false;
-
432 if (!s->handle->isHidden()) {
evaluated: !s->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:1931
yes
Evaluation Count:1921
1921-1931
433 minl += s->getHandleSize(orient);
executed (the execution status of this line is deduced): minl += s->getHandleSize(orient);
-
434 maxl += s->getHandleSize(orient);
executed (the execution status of this line is deduced): maxl += s->getHandleSize(orient);
-
435 }
executed: }
Execution Count:1931
1931
436 -
437 QSize minS = qSmartMinSize(s->widget);
executed (the execution status of this line is deduced): QSize minS = qSmartMinSize(s->widget);
-
438 minl += pick(minS);
executed (the execution status of this line is deduced): minl += pick(minS);
-
439 maxl += pick(s->widget->maximumSize());
executed (the execution status of this line is deduced): maxl += pick(s->widget->maximumSize());
-
440 mint = qMax(mint, trans(minS));
executed (the execution status of this line is deduced): mint = qMax(mint, trans(minS));
-
441 int tm = trans(s->widget->maximumSize());
executed (the execution status of this line is deduced): int tm = trans(s->widget->maximumSize());
-
442 if (tm > 0)
partially evaluated: tm > 0
TRUEFALSE
yes
Evaluation Count:3852
no
Evaluation Count:0
0-3852
443 maxt = qMin(maxt, tm);
executed: maxt = qMin(maxt, tm);
Execution Count:3852
3852
444 }
executed: }
Execution Count:3852
3852
445 }
executed: }
Execution Count:3877
3877
446 -
447 if (empty) {
evaluated: empty
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:1921
47-1921
448 if (qobject_cast<QSplitter *>(parent)) {
partially evaluated: qobject_cast<QSplitter *>(parent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
0-47
449 // nested splitters; be nice -
450 maxl = maxt = 0;
never executed (the execution status of this line is deduced): maxl = maxt = 0;
-
451 } else {
never executed: }
0
452 // QSplitter with no children yet -
453 maxl = QWIDGETSIZE_MAX;
executed (the execution status of this line is deduced): maxl = ((1<<24)-1);
-
454 }
executed: }
Execution Count:47
47
455 } else { -
456 maxl = qMin<int>(maxl, QWIDGETSIZE_MAX);
executed (the execution status of this line is deduced): maxl = qMin<int>(maxl, ((1<<24)-1));
-
457 }
executed: }
Execution Count:1921
1921
458 if (maxt < mint)
partially evaluated: maxt < mint
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1968
0-1968
459 maxt = mint;
never executed: maxt = mint;
0
460 -
461 if (update) {
evaluated: update
TRUEFALSE
yes
Evaluation Count:222
yes
Evaluation Count:1746
222-1746
462 if (orient == Qt::Horizontal) {
evaluated: orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:218
yes
Evaluation Count:4
4-218
463 q->setMaximumSize(maxl, maxt);
executed (the execution status of this line is deduced): q->setMaximumSize(maxl, maxt);
-
464 if (q->isWindow())
evaluated: q->isWindow()
TRUEFALSE
yes
Evaluation Count:82
yes
Evaluation Count:136
82-136
465 q->setMinimumSize(minl,mint);
executed: q->setMinimumSize(minl,mint);
Execution Count:82
82
466 } else {
executed: }
Execution Count:218
218
467 q->setMaximumSize(maxt, maxl);
executed (the execution status of this line is deduced): q->setMaximumSize(maxt, maxl);
-
468 if (q->isWindow())
partially evaluated: q->isWindow()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
469 q->setMinimumSize(mint,minl);
never executed: q->setMinimumSize(mint,minl);
0
470 }
executed: }
Execution Count:4
4
471 doResize();
executed (the execution status of this line is deduced): doResize();
-
472 q->updateGeometry();
executed (the execution status of this line is deduced): q->updateGeometry();
-
473 } else {
executed: }
Execution Count:222
222
474 firstShow = true;
executed (the execution status of this line is deduced): firstShow = true;
-
475 }
executed: }
Execution Count:1746
1746
476} -
477 -
478void QSplitterPrivate::doResize() -
479{ -
480 Q_Q(QSplitter);
executed (the execution status of this line is deduced): QSplitter * const q = q_func();
-
481 QRect r = q->contentsRect();
executed (the execution status of this line is deduced): QRect r = q->contentsRect();
-
482 int n = list.count();
executed (the execution status of this line is deduced): int n = list.count();
-
483 QVector<QLayoutStruct> a(n*2);
executed (the execution status of this line is deduced): QVector<QLayoutStruct> a(n*2);
-
484 int i;
executed (the execution status of this line is deduced): int i;
-
485 -
486 bool noStretchFactorsSet = true;
executed (the execution status of this line is deduced): bool noStretchFactorsSet = true;
-
487 for (i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:3013
yes
Evaluation Count:1006
1006-3013
488 QSizePolicy p = list.at(i)->widget->sizePolicy();
executed (the execution status of this line is deduced): QSizePolicy p = list.at(i)->widget->sizePolicy();
-
489 int sf = orient == Qt::Horizontal ? p.horizontalStretch() : p.verticalStretch();
evaluated: orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:2990
yes
Evaluation Count:23
23-2990
490 if (sf != 0) {
evaluated: sf != 0
TRUEFALSE
yes
Evaluation Count:385
yes
Evaluation Count:2628
385-2628
491 noStretchFactorsSet = false;
executed (the execution status of this line is deduced): noStretchFactorsSet = false;
-
492 break;
executed: break;
Execution Count:385
385
493 } -
494 }
executed: }
Execution Count:2628
2628
495 -
496 int j=0;
executed (the execution status of this line is deduced): int j=0;
-
497 for (i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:3018
yes
Evaluation Count:1391
1391-3018
498 QSplitterLayoutStruct *s = list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = list.at(i);
-
499#ifdef QSPLITTER_DEBUG -
500 qDebug("widget %d hidden: %d collapsed: %d handle hidden: %d", i, s->widget->isHidden(), -
501 s->collapsed, s->handle->isHidden()); -
502#endif -
503 -
504 a[j].init();
executed (the execution status of this line is deduced): a[j].init();
-
505 if (s->handle->isHidden()) {
evaluated: s->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:1355
yes
Evaluation Count:1663
1355-1663
506 a[j].maximumSize = 0;
executed (the execution status of this line is deduced): a[j].maximumSize = 0;
-
507 } else {
executed: }
Execution Count:1355
1355
508 a[j].sizeHint = a[j].minimumSize = a[j].maximumSize = s->getHandleSize(orient);
executed (the execution status of this line is deduced): a[j].sizeHint = a[j].minimumSize = a[j].maximumSize = s->getHandleSize(orient);
-
509 a[j].empty = false;
executed (the execution status of this line is deduced): a[j].empty = false;
-
510 }
executed: }
Execution Count:1663
1663
511 ++j;
executed (the execution status of this line is deduced): ++j;
-
512 -
513 a[j].init();
executed (the execution status of this line is deduced): a[j].init();
-
514 if (s->widget->isHidden() || s->collapsed) {
evaluated: s->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:2992
evaluated: s->collapsed
TRUEFALSE
yes
Evaluation Count:222
yes
Evaluation Count:2770
26-2992
515 a[j].maximumSize = 0;
executed (the execution status of this line is deduced): a[j].maximumSize = 0;
-
516 } else {
executed: }
Execution Count:248
248
517 a[j].minimumSize = pick(qSmartMinSize(s->widget));
executed (the execution status of this line is deduced): a[j].minimumSize = pick(qSmartMinSize(s->widget));
-
518 a[j].maximumSize = pick(s->widget->maximumSize());
executed (the execution status of this line is deduced): a[j].maximumSize = pick(s->widget->maximumSize());
-
519 a[j].empty = false;
executed (the execution status of this line is deduced): a[j].empty = false;
-
520 -
521 bool stretch = noStretchFactorsSet;
executed (the execution status of this line is deduced): bool stretch = noStretchFactorsSet;
-
522 if (!stretch) {
evaluated: !stretch
TRUEFALSE
yes
Evaluation Count:770
yes
Evaluation Count:2000
770-2000
523 QSizePolicy p = s->widget->sizePolicy();
executed (the execution status of this line is deduced): QSizePolicy p = s->widget->sizePolicy();
-
524 int sf = orient == Qt::Horizontal ? p.horizontalStretch() : p.verticalStretch();
evaluated: orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:760
yes
Evaluation Count:10
10-760
525 stretch = (sf != 0);
executed (the execution status of this line is deduced): stretch = (sf != 0);
-
526 }
executed: }
Execution Count:770
770
527 if (stretch) {
evaluated: stretch
TRUEFALSE
yes
Evaluation Count:2385
yes
Evaluation Count:385
385-2385
528 a[j].stretch = s->getWidgetSize(orient);
executed (the execution status of this line is deduced): a[j].stretch = s->getWidgetSize(orient);
-
529 a[j].sizeHint = a[j].minimumSize;
executed (the execution status of this line is deduced): a[j].sizeHint = a[j].minimumSize;
-
530 a[j].expansive = true;
executed (the execution status of this line is deduced): a[j].expansive = true;
-
531 } else {
executed: }
Execution Count:2385
2385
532 a[j].sizeHint = qMax(s->getWidgetSize(orient), a[j].minimumSize);
executed (the execution status of this line is deduced): a[j].sizeHint = qMax(s->getWidgetSize(orient), a[j].minimumSize);
-
533 }
executed: }
Execution Count:385
385
534 } -
535 ++j;
executed (the execution status of this line is deduced): ++j;
-
536 }
executed: }
Execution Count:3018
3018
537 -
538 qGeomCalc(a, 0, n*2, pick(r.topLeft()), pick(r.size()), 0);
executed (the execution status of this line is deduced): qGeomCalc(a, 0, n*2, pick(r.topLeft()), pick(r.size()), 0);
-
539 -
540#ifdef QSPLITTER_DEBUG -
541 for (i = 0; i < n*2; ++i) { -
542 qDebug("%*s%d: stretch %d, sh %d, minS %d, maxS %d, exp %d, emp %d -> %d, %d", -
543 i, "", i, -
544 a[i].stretch, -
545 a[i].sizeHint, -
546 a[i].minimumSize, -
547 a[i].maximumSize, -
548 a[i].expansive, -
549 a[i].empty, -
550 a[i].pos, -
551 a[i].size); -
552 } -
553#endif -
554 -
555 for (i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:3018
yes
Evaluation Count:1391
1391-3018
556 QSplitterLayoutStruct *s = list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = list.at(i);
-
557 setGeo(s, a[i*2+1].pos, a[i*2+1].size, false);
executed (the execution status of this line is deduced): setGeo(s, a[i*2+1].pos, a[i*2+1].size, false);
-
558 }
executed: }
Execution Count:3018
3018
559}
executed: }
Execution Count:1391
1391
560 -
561void QSplitterPrivate::storeSizes() -
562{ -
563 for (int i = 0; i < list.size(); ++i) {
evaluated: i < list.size()
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:10
10-30
564 QSplitterLayoutStruct *sls = list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *sls = list.at(i);
-
565 sls->sizer = pick(sls->rect.size());
executed (the execution status of this line is deduced): sls->sizer = pick(sls->rect.size());
-
566 }
executed: }
Execution Count:30
30
567}
executed: }
Execution Count:10
10
568 -
569void QSplitterPrivate::addContribution(int index, int *min, int *max, bool mayCollapse) const -
570{ -
571 QSplitterLayoutStruct *s = list.at(index);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = list.at(index);
-
572 if (!s->widget->isHidden()) {
partially evaluated: !s->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:28
no
Evaluation Count:0
0-28
573 if (!s->handle->isHidden()) {
evaluated: !s->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:8
8-20
574 *min += s->getHandleSize(orient);
executed (the execution status of this line is deduced): *min += s->getHandleSize(orient);
-
575 *max += s->getHandleSize(orient);
executed (the execution status of this line is deduced): *max += s->getHandleSize(orient);
-
576 }
executed: }
Execution Count:20
20
577 if (mayCollapse || !s->collapsed)
evaluated: mayCollapse
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:12
partially evaluated: !s->collapsed
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-16
578 *min += pick(qSmartMinSize(s->widget));
executed: *min += pick(qSmartMinSize(s->widget));
Execution Count:16
16
579 -
580 *max += pick(s->widget->maximumSize());
executed (the execution status of this line is deduced): *max += pick(s->widget->maximumSize());
-
581 }
executed: }
Execution Count:28
28
582}
executed: }
Execution Count:28
28
583 -
584int QSplitterPrivate::findWidgetJustBeforeOrJustAfter(int index, int delta, int &collapsibleSize) const -
585{ -
586 if (delta < 0)
evaluated: delta < 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:8
8
587 index += delta;
executed: index += delta;
Execution Count:8
8
588 do { -
589 QWidget *w = list.at(index)->widget;
executed (the execution status of this line is deduced): QWidget *w = list.at(index)->widget;
-
590 if (!w->isHidden()) {
partially evaluated: !w->isHidden()
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
591 if (collapsible(list.at(index)))
partially evaluated: collapsible(list.at(index))
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
592 collapsibleSize = pick(qSmartMinSize(w));
executed: collapsibleSize = pick(qSmartMinSize(w));
Execution Count:16
16
593 return index;
executed: return index;
Execution Count:16
16
594 } -
595 index += delta;
never executed (the execution status of this line is deduced): index += delta;
-
596 } while (index >= 0 && index < list.count());
never executed: }
never evaluated: index >= 0
never evaluated: index < list.count()
0
597 -
598 return -1;
never executed: return -1;
0
599} -
600 -
601/* -
602 For the splitter handle with index \a index, \a min and \a max give the range without collapsing any widgets, -
603 and \a farMin and farMax give the range with collapsing included. -
604*/ -
605void QSplitterPrivate::getRange(int index, int *farMin, int *min, int *max, int *farMax) const -
606{ -
607 Q_Q(const QSplitter);
executed (the execution status of this line is deduced): const QSplitter * const q = q_func();
-
608 int n = list.count();
executed (the execution status of this line is deduced): int n = list.count();
-
609 if (index <= 0 || index >= n)
evaluated: index <= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:8
partially evaluated: index >= n
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
610 return;
executed: return;
Execution Count:2
2
611 -
612 int collapsibleSizeBefore = 0;
executed (the execution status of this line is deduced): int collapsibleSizeBefore = 0;
-
613 int idJustBefore = findWidgetJustBeforeOrJustAfter(index, -1, collapsibleSizeBefore);
executed (the execution status of this line is deduced): int idJustBefore = findWidgetJustBeforeOrJustAfter(index, -1, collapsibleSizeBefore);
-
614 -
615 int collapsibleSizeAfter = 0;
executed (the execution status of this line is deduced): int collapsibleSizeAfter = 0;
-
616 int idJustAfter = findWidgetJustBeforeOrJustAfter(index, +1, collapsibleSizeAfter);
executed (the execution status of this line is deduced): int idJustAfter = findWidgetJustBeforeOrJustAfter(index, +1, collapsibleSizeAfter);
-
617 -
618 int minBefore = 0;
executed (the execution status of this line is deduced): int minBefore = 0;
-
619 int minAfter = 0;
executed (the execution status of this line is deduced): int minAfter = 0;
-
620 int maxBefore = 0;
executed (the execution status of this line is deduced): int maxBefore = 0;
-
621 int maxAfter = 0;
executed (the execution status of this line is deduced): int maxAfter = 0;
-
622 int i;
executed (the execution status of this line is deduced): int i;
-
623 -
624 for (i = 0; i < index; ++i)
evaluated: i < index
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:8
8-20
625 addContribution(i, &minBefore, &maxBefore, i == idJustBefore);
executed: addContribution(i, &minBefore, &maxBefore, i == idJustBefore);
Execution Count:20
20
626 for (i = index; i < n; ++i)
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:8
8
627 addContribution(i, &minAfter, &maxAfter, i == idJustAfter);
executed: addContribution(i, &minAfter, &maxAfter, i == idJustAfter);
Execution Count:8
8
628 -
629 QRect r = q->contentsRect();
executed (the execution status of this line is deduced): QRect r = q->contentsRect();
-
630 int farMinVal;
executed (the execution status of this line is deduced): int farMinVal;
-
631 int minVal;
executed (the execution status of this line is deduced): int minVal;
-
632 int maxVal;
executed (the execution status of this line is deduced): int maxVal;
-
633 int farMaxVal;
executed (the execution status of this line is deduced): int farMaxVal;
-
634 -
635 int smartMinBefore = qMax(minBefore, pick(r.size()) - maxAfter);
executed (the execution status of this line is deduced): int smartMinBefore = qMax(minBefore, pick(r.size()) - maxAfter);
-
636 int smartMaxBefore = qMin(maxBefore, pick(r.size()) - minAfter);
executed (the execution status of this line is deduced): int smartMaxBefore = qMin(maxBefore, pick(r.size()) - minAfter);
-
637 -
638 minVal = pick(r.topLeft()) + smartMinBefore;
executed (the execution status of this line is deduced): minVal = pick(r.topLeft()) + smartMinBefore;
-
639 maxVal = pick(r.topLeft()) + smartMaxBefore;
executed (the execution status of this line is deduced): maxVal = pick(r.topLeft()) + smartMaxBefore;
-
640 -
641 farMinVal = minVal;
executed (the execution status of this line is deduced): farMinVal = minVal;
-
642 if (minBefore - collapsibleSizeBefore >= pick(r.size()) - maxAfter)
partially evaluated: minBefore - collapsibleSizeBefore >= pick(r.size()) - maxAfter
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
643 farMinVal -= collapsibleSizeBefore;
executed: farMinVal -= collapsibleSizeBefore;
Execution Count:8
8
644 farMaxVal = maxVal;
executed (the execution status of this line is deduced): farMaxVal = maxVal;
-
645 if (pick(r.size()) - (minAfter - collapsibleSizeAfter) <= maxBefore)
partially evaluated: pick(r.size()) - (minAfter - collapsibleSizeAfter) <= maxBefore
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
646 farMaxVal += collapsibleSizeAfter;
executed: farMaxVal += collapsibleSizeAfter;
Execution Count:8
8
647 -
648 if (farMin)
partially evaluated: farMin
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
649 *farMin = farMinVal;
executed: *farMin = farMinVal;
Execution Count:8
8
650 if (min)
partially evaluated: min
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
651 *min = minVal;
executed: *min = minVal;
Execution Count:8
8
652 if (max)
partially evaluated: max
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
653 *max = maxVal;
executed: *max = maxVal;
Execution Count:8
8
654 if (farMax)
partially evaluated: farMax
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
655 *farMax = farMaxVal;
executed: *farMax = farMaxVal;
Execution Count:8
8
656}
executed: }
Execution Count:8
8
657 -
658int QSplitterPrivate::adjustPos(int pos, int index, int *farMin, int *min, int *max, int *farMax) const -
659{ -
660 const int Threshold = 40;
executed (the execution status of this line is deduced): const int Threshold = 40;
-
661 -
662 getRange(index, farMin, min, max, farMax);
executed (the execution status of this line is deduced): getRange(index, farMin, min, max, farMax);
-
663 -
664 if (pos >= *min) {
evaluated: pos >= *min
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:9
1-9
665 if (pos <= *max) {
partially evaluated: pos <= *max
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
666 return pos;
executed: return pos;
Execution Count:1
1
667 } else { -
668 int delta = pos - *max;
never executed (the execution status of this line is deduced): int delta = pos - *max;
-
669 int width = *farMax - *max;
never executed (the execution status of this line is deduced): int width = *farMax - *max;
-
670 -
671 if (delta > width / 2 && delta >= qMin(Threshold, width)) {
never evaluated: delta > width / 2
never evaluated: delta >= qMin(Threshold, width)
0
672 return *farMax;
never executed: return *farMax;
0
673 } else { -
674 return *max;
never executed: return *max;
0
675 } -
676 } -
677 } else { -
678 int delta = *min - pos;
executed (the execution status of this line is deduced): int delta = *min - pos;
-
679 int width = *min - *farMin;
executed (the execution status of this line is deduced): int width = *min - *farMin;
-
680 -
681 if (delta > width / 2 && delta >= qMin(Threshold, width)) {
partially evaluated: delta > width / 2
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
partially evaluated: delta >= qMin(Threshold, width)
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
682 return *farMin;
executed: return *farMin;
Execution Count:9
9
683 } else { -
684 return *min;
never executed: return *min;
0
685 } -
686 } -
687} -
688 -
689bool QSplitterPrivate::collapsible(QSplitterLayoutStruct *s) const -
690{ -
691 if (s->collapsible != Default) {
evaluated: s->collapsible != Default
TRUEFALSE
yes
Evaluation Count:225
yes
Evaluation Count:46
46-225
692 return (bool)s->collapsible;
executed: return (bool)s->collapsible;
Execution Count:225
225
693 } else { -
694 return childrenCollapsible;
executed: return childrenCollapsible;
Execution Count:46
46
695 } -
696} -
697 -
698void QSplitterPrivate::updateHandles() -
699{ -
700 Q_Q(QSplitter);
executed (the execution status of this line is deduced): QSplitter * const q = q_func();
-
701 recalc(q->isVisible());
executed (the execution status of this line is deduced): recalc(q->isVisible());
-
702}
executed: }
Execution Count:126
126
703 -
704void QSplitterPrivate::setSizes_helper(const QList<int> &sizes, bool clampNegativeSize) -
705{ -
706 int j = 0;
executed (the execution status of this line is deduced): int j = 0;
-
707 -
708 for (int i = 0; i < list.size(); ++i) {
evaluated: i < list.size()
TRUEFALSE
yes
Evaluation Count:2229
yes
Evaluation Count:927
927-2229
709 QSplitterLayoutStruct *s = list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = list.at(i);
-
710 -
711 s->collapsed = false;
executed (the execution status of this line is deduced): s->collapsed = false;
-
712 s->sizer = sizes.value(j++);
executed (the execution status of this line is deduced): s->sizer = sizes.value(j++);
-
713 if (clampNegativeSize && s->sizer < 0)
evaluated: clampNegativeSize
TRUEFALSE
yes
Evaluation Count:1995
yes
Evaluation Count:234
partially evaluated: s->sizer < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1995
0-1995
714 s->sizer = 0;
never executed: s->sizer = 0;
0
715 int smartMinSize = pick(qSmartMinSize(s->widget));
executed (the execution status of this line is deduced): int smartMinSize = pick(qSmartMinSize(s->widget));
-
716 -
717 // Make sure that we reset the collapsed state. -
718 if (s->sizer == 0) {
evaluated: s->sizer == 0
TRUEFALSE
yes
Evaluation Count:225
yes
Evaluation Count:2004
225-2004
719 if (collapsible(s) && smartMinSize > 0) {
evaluated: collapsible(s)
TRUEFALSE
yes
Evaluation Count:175
yes
Evaluation Count:50
partially evaluated: smartMinSize > 0
TRUEFALSE
yes
Evaluation Count:175
no
Evaluation Count:0
0-175
720 s->collapsed = true;
executed (the execution status of this line is deduced): s->collapsed = true;
-
721 } else {
executed: }
Execution Count:175
175
722 s->sizer = smartMinSize;
executed (the execution status of this line is deduced): s->sizer = smartMinSize;
-
723 }
executed: }
Execution Count:50
50
724 } else { -
725 if (s->sizer < smartMinSize)
evaluated: s->sizer < smartMinSize
TRUEFALSE
yes
Evaluation Count:425
yes
Evaluation Count:1579
425-1579
726 s->sizer = smartMinSize;
executed: s->sizer = smartMinSize;
Execution Count:425
425
727 }
executed: }
Execution Count:2004
2004
728 } -
729 doResize();
executed (the execution status of this line is deduced): doResize();
-
730}
executed: }
Execution Count:927
927
731 -
732void QSplitterPrivate::setGeo(QSplitterLayoutStruct *sls, int p, int s, bool allowCollapse) -
733{ -
734 Q_Q(QSplitter);
executed (the execution status of this line is deduced): QSplitter * const q = q_func();
-
735 QWidget *w = sls->widget;
executed (the execution status of this line is deduced): QWidget *w = sls->widget;
-
736 QRect r;
executed (the execution status of this line is deduced): QRect r;
-
737 QRect contents = q->contentsRect();
executed (the execution status of this line is deduced): QRect contents = q->contentsRect();
-
738 if (orient == Qt::Horizontal) {
evaluated: orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:3020
yes
Evaluation Count:28
28-3020
739 r.setRect(p, contents.y(), s, contents.height());
executed (the execution status of this line is deduced): r.setRect(p, contents.y(), s, contents.height());
-
740 } else {
executed: }
Execution Count:3020
3020
741 r.setRect(contents.x(), p, contents.width(), s);
executed (the execution status of this line is deduced): r.setRect(contents.x(), p, contents.width(), s);
-
742 }
executed: }
Execution Count:28
28
743 sls->rect = r;
executed (the execution status of this line is deduced): sls->rect = r;
-
744 -
745 int minSize = pick(qSmartMinSize(w));
executed (the execution status of this line is deduced): int minSize = pick(qSmartMinSize(w));
-
746 -
747 if (orient == Qt::Horizontal && q->isRightToLeft())
evaluated: orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:3020
yes
Evaluation Count:28
partially evaluated: q->isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3020
0-3020
748 r.moveRight(contents.width() - r.left());
never executed: r.moveRight(contents.width() - r.left());
0
749 -
750 if (allowCollapse)
evaluated: allowCollapse
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:3018
30-3018
751 sls->collapsed = s <= 0 && minSize > 0 && !w->isHidden();
executed: sls->collapsed = s <= 0 && minSize > 0 && !w->isHidden();
Execution Count:30
evaluated: s <= 0
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:10
partially evaluated: minSize > 0
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
partially evaluated: !w->isHidden()
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-30
752 -
753 // Hide the child widget, but without calling hide() so that -
754 // the splitter handle is still shown. -
755 if (sls->collapsed)
evaluated: sls->collapsed
TRUEFALSE
yes
Evaluation Count:242
yes
Evaluation Count:2806
242-2806
756 r.moveTopLeft(QPoint(-r.width()-1, -r.height()-1));
executed: r.moveTopLeft(QPoint(-r.width()-1, -r.height()-1));
Execution Count:242
242
757 -
758 w->setGeometry(r);
executed (the execution status of this line is deduced): w->setGeometry(r);
-
759 -
760 if (!sls->handle->isHidden()) {
evaluated: !sls->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:1683
yes
Evaluation Count:1365
1365-1683
761 QSplitterHandle *h = sls->handle;
executed (the execution status of this line is deduced): QSplitterHandle *h = sls->handle;
-
762 QSize hs = h->sizeHint();
executed (the execution status of this line is deduced): QSize hs = h->sizeHint();
-
763 int left, top, right, bottom;
executed (the execution status of this line is deduced): int left, top, right, bottom;
-
764 h->getContentsMargins(&left, &top, &right, &bottom);
executed (the execution status of this line is deduced): h->getContentsMargins(&left, &top, &right, &bottom);
-
765 if (orient==Qt::Horizontal) {
evaluated: orient==Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:1669
yes
Evaluation Count:14
14-1669
766 if (q->isRightToLeft())
partially evaluated: q->isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1669
0-1669
767 p = contents.width() - p + hs.width();
never executed: p = contents.width() - p + hs.width();
0
768 h->setGeometry(p-hs.width() - left, contents.y(), hs.width() + left + right, contents.height());
executed (the execution status of this line is deduced): h->setGeometry(p-hs.width() - left, contents.y(), hs.width() + left + right, contents.height());
-
769 } else {
executed: }
Execution Count:1669
1669
770 h->setGeometry(contents.x(), p-hs.height() - top, contents.width(), hs.height() + top + bottom);
executed (the execution status of this line is deduced): h->setGeometry(contents.x(), p-hs.height() - top, contents.width(), hs.height() + top + bottom);
-
771 }
executed: }
Execution Count:14
14
772 } -
773}
executed: }
Execution Count:3048
3048
774 -
775void QSplitterPrivate::doMove(bool backwards, int hPos, int index, int delta, bool mayCollapse, -
776 int *positions, int *widths) -
777{ -
778 if (index < 0 || index >= list.count())
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:40
evaluated: index >= list.count()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:30
10-40
779 return;
executed: return;
Execution Count:20
20
780 -
781#ifdef QSPLITTER_DEBUG -
782 qDebug() << "QSplitterPrivate::doMove" << backwards << hPos << index << delta << mayCollapse; -
783#endif -
784 -
785 QSplitterLayoutStruct *s = list.at(index);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = list.at(index);
-
786 QWidget *w = s->widget;
executed (the execution status of this line is deduced): QWidget *w = s->widget;
-
787 -
788 int nextId = backwards ? index - delta : index + delta;
evaluated: backwards
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:10
10-20
789 -
790 if (w->isHidden()) {
partially evaluated: w->isHidden()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
791 doMove(backwards, hPos, nextId, delta, collapsible(nextId), positions, widths);
never executed (the execution status of this line is deduced): doMove(backwards, hPos, nextId, delta, collapsible(nextId), positions, widths);
-
792 } else {
never executed: }
0
793 int hs =s->handle->isHidden() ? 0 : s->getHandleSize(orient);
evaluated: s->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:20
10-20
794 -
795 int ws = backwards ? hPos - pick(s->rect.topLeft())
evaluated: backwards
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:10
10-20
796 : pick(s->rect.bottomRight()) - hPos -hs + 1;
executed (the execution status of this line is deduced): : pick(s->rect.bottomRight()) - hPos -hs + 1;
-
797 if (ws > 0 || (!s->collapsed && !mayCollapse)) {
partially evaluated: ws > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
evaluated: !s->collapsed
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:12
evaluated: !mayCollapse
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:8
0-30
798 ws = qMin(ws, pick(w->maximumSize()));
executed (the execution status of this line is deduced): ws = qMin(ws, pick(w->maximumSize()));
-
799 ws = qMax(ws, pick(qSmartMinSize(w)));
executed (the execution status of this line is deduced): ws = qMax(ws, pick(qSmartMinSize(w)));
-
800 } else {
executed: }
Execution Count:10
10
801 ws = 0;
executed (the execution status of this line is deduced): ws = 0;
-
802 }
executed: }
Execution Count:20
20
803 positions[index] = backwards ? hPos - ws : hPos + hs;
evaluated: backwards
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:10
10-20
804 widths[index] = ws;
executed (the execution status of this line is deduced): widths[index] = ws;
-
805 doMove(backwards, backwards ? hPos - ws - hs : hPos + hs + ws, nextId, delta,
executed (the execution status of this line is deduced): doMove(backwards, backwards ? hPos - ws - hs : hPos + hs + ws, nextId, delta,
-
806 collapsible(nextId), positions, widths);
executed (the execution status of this line is deduced): collapsible(nextId), positions, widths);
-
807 }
executed: }
Execution Count:30
30
808 -
809} -
810 -
811QSplitterLayoutStruct *QSplitterPrivate::findWidget(QWidget *w) const -
812{ -
813 for (int i = 0; i < list.size(); ++i) {
evaluated: i < list.size()
TRUEFALSE
yes
Evaluation Count:198
yes
Evaluation Count:392
198-392
814 if (list.at(i)->widget == w)
partially evaluated: list.at(i)->widget == w
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:198
0-198
815 return list.at(i);
never executed: return list.at(i);
0
816 }
executed: }
Execution Count:198
198
817 return 0;
executed: return 0;
Execution Count:392
392
818} -
819 -
820 -
821/*! -
822 \internal -
823*/ -
824void QSplitterPrivate::insertWidget_helper(int index, QWidget *widget, bool show) -
825{ -
826 Q_Q(QSplitter);
executed (the execution status of this line is deduced): QSplitter * const q = q_func();
-
827 QBoolBlocker b(blockChildAdd);
executed (the execution status of this line is deduced): QBoolBlocker b(blockChildAdd);
-
828 bool needShow = show && q->isVisible() &&
evaluated: show
TRUEFALSE
yes
Evaluation Count:860
yes
Evaluation Count:392
evaluated: q->isVisible()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:850
10-860
829 !(widget->isHidden() && widget->testAttribute(Qt::WA_WState_ExplicitShowHide));
partially evaluated: widget->isHidden()
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
partially evaluated: widget->testAttribute(Qt::WA_WState_ExplicitShowHide)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
830 if (widget->parentWidget() != q)
evaluated: widget->parentWidget() != q
TRUEFALSE
yes
Evaluation Count:470
yes
Evaluation Count:782
470-782
831 widget->setParent(q);
executed: widget->setParent(q);
Execution Count:470
470
832 if (needShow)
evaluated: needShow
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1242
10-1242
833 widget->show();
executed: widget->show();
Execution Count:10
10
834 insertWidget(index, widget);
executed (the execution status of this line is deduced): insertWidget(index, widget);
-
835 recalc(q->isVisible());
executed (the execution status of this line is deduced): recalc(q->isVisible());
-
836}
executed: }
Execution Count:1252
1252
837 -
838/* -
839 Inserts the widget \a w at position \a index in the splitter's list of widgets. -
840 -
841 If \a w is already in the splitter, it will be moved to the new position. -
842*/ -
843 -
844QSplitterLayoutStruct *QSplitterPrivate::insertWidget(int index, QWidget *w) -
845{ -
846 Q_Q(QSplitter);
executed (the execution status of this line is deduced): QSplitter * const q = q_func();
-
847 QSplitterLayoutStruct *sls = 0;
executed (the execution status of this line is deduced): QSplitterLayoutStruct *sls = 0;
-
848 int i;
executed (the execution status of this line is deduced): int i;
-
849 int last = list.count();
executed (the execution status of this line is deduced): int last = list.count();
-
850 for (i = 0; i < list.size(); ++i) {
evaluated: i < list.size()
TRUEFALSE
yes
Evaluation Count:1639
yes
Evaluation Count:862
862-1639
851 QSplitterLayoutStruct *s = list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = list.at(i);
-
852 if (s->widget == w) {
evaluated: s->widget == w
TRUEFALSE
yes
Evaluation Count:390
yes
Evaluation Count:1249
390-1249
853 sls = s;
executed (the execution status of this line is deduced): sls = s;
-
854 --last;
executed (the execution status of this line is deduced): --last;
-
855 break;
executed: break;
Execution Count:390
390
856 } -
857 }
executed: }
Execution Count:1249
1249
858 if (index < 0 || index > last)
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1251
evaluated: index > last
TRUEFALSE
yes
Evaluation Count:388
yes
Evaluation Count:863
1-1251
859 index = last;
executed: index = last;
Execution Count:389
389
860 -
861 if (sls) {
evaluated: sls
TRUEFALSE
yes
Evaluation Count:390
yes
Evaluation Count:862
390-862
862 list.move(i,index);
executed (the execution status of this line is deduced): list.move(i,index);
-
863 } else {
executed: }
Execution Count:390
390
864 QSplitterHandle *newHandle = 0;
executed (the execution status of this line is deduced): QSplitterHandle *newHandle = 0;
-
865 sls = new QSplitterLayoutStruct;
executed (the execution status of this line is deduced): sls = new QSplitterLayoutStruct;
-
866 QString tmp = QLatin1String("qt_splithandle_");
executed (the execution status of this line is deduced): QString tmp = QLatin1String("qt_splithandle_");
-
867 tmp += w->objectName();
executed (the execution status of this line is deduced): tmp += w->objectName();
-
868 newHandle = q->createHandle();
executed (the execution status of this line is deduced): newHandle = q->createHandle();
-
869 newHandle->setObjectName(tmp);
executed (the execution status of this line is deduced): newHandle->setObjectName(tmp);
-
870 sls->handle = newHandle;
executed (the execution status of this line is deduced): sls->handle = newHandle;
-
871 sls->widget = w;
executed (the execution status of this line is deduced): sls->widget = w;
-
872 w->lower();
executed (the execution status of this line is deduced): w->lower();
-
873 list.insert(index,sls);
executed (the execution status of this line is deduced): list.insert(index,sls);
-
874 -
875 if (newHandle && q->isVisible())
partially evaluated: newHandle
TRUEFALSE
yes
Evaluation Count:862
no
Evaluation Count:0
evaluated: q->isVisible()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:847
0-862
876 newHandle->show(); // will trigger sending of post events
executed: newHandle->show();
Execution Count:15
15
877 -
878 }
executed: }
Execution Count:862
862
879 return sls;
executed: return sls;
Execution Count:1252
1252
880} -
881 -
882/*! -
883 \class QSplitter -
884 \brief The QSplitter class implements a splitter widget. -
885 -
886 \ingroup organizers -
887 \inmodule QtWidgets -
888 -
889 -
890 A splitter lets the user control the size of child widgets by dragging the -
891 boundary between them. Any number of widgets may be controlled by a -
892 single splitter. The typical use of a QSplitter is to create several -
893 widgets and add them using insertWidget() or addWidget(). -
894 -
895 The following example will show a QListView, QTreeView, and -
896 QTextEdit side by side, with two splitter handles: -
897 -
898 \snippet splitter/splitter.cpp 0 -
899 -
900 If a widget is already inside a QSplitter when insertWidget() or -
901 addWidget() is called, it will move to the new position. This can be used -
902 to reorder widgets in the splitter later. You can use indexOf(), -
903 widget(), and count() to get access to the widgets inside the splitter. -
904 -
905 A default QSplitter lays out its children horizontally (side by side); you -
906 can use setOrientation(Qt::Vertical) to lay its -
907 children out vertically. -
908 -
909 By default, all widgets can be as large or as small as the user -
910 wishes, between the \l minimumSizeHint() (or \l minimumSize()) -
911 and \l maximumSize() of the widgets. -
912 -
913 QSplitter resizes its children dynamically by default. If you -
914 would rather have QSplitter resize the children only at the end of -
915 a resize operation, call setOpaqueResize(false). -
916 -
917 The initial distribution of size between the widgets is determined by -
918 multiplying the initial size with the stretch factor. -
919 You can also use setSizes() to set the sizes -
920 of all the widgets. The function sizes() returns the sizes set by the user. -
921 Alternatively, you can save and restore the sizes of the widgets from a -
922 QByteArray using saveState() and restoreState() respectively. -
923 -
924 When you hide() a child, its space will be distributed among the -
925 other children. It will be reinstated when you show() it again. -
926 -
927 \note Adding a QLayout to a QSplitter is not supported (either through -
928 setLayout() or making the QSplitter a parent of the QLayout); use addWidget() -
929 instead (see example above). -
930 -
931 \sa QSplitterHandle, QHBoxLayout, QVBoxLayout, QTabWidget -
932*/ -
933 -
934 -
935/*! -
936 Constructs a horizontal splitter with the \a parent -
937 argument passed on to the QFrame constructor. -
938 -
939 \sa setOrientation() -
940*/ -
941QSplitter::QSplitter(QWidget *parent) -
942 : QFrame(*new QSplitterPrivate, parent) -
943{ -
944 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
945 d->orient = Qt::Horizontal;
executed (the execution status of this line is deduced): d->orient = Qt::Horizontal;
-
946 d->init();
executed (the execution status of this line is deduced): d->init();
-
947}
executed: }
Execution Count:213
213
948 -
949 -
950/*! -
951 Constructs a splitter with the given \a orientation and \a parent. -
952 -
953 \sa setOrientation() -
954*/ -
955QSplitter::QSplitter(Qt::Orientation orientation, QWidget *parent) -
956 : QFrame(*new QSplitterPrivate, parent) -
957{ -
958 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
959 d->orient = orientation;
executed (the execution status of this line is deduced): d->orient = orientation;
-
960 d->init();
executed (the execution status of this line is deduced): d->init();
-
961}
executed: }
Execution Count:26
26
962 -
963 -
964/*! -
965 Destroys the splitter. All children are deleted. -
966*/ -
967 -
968QSplitter::~QSplitter() -
969{ -
970 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
971 delete d->rubberBand;
executed (the execution status of this line is deduced): delete d->rubberBand;
-
972 while (!d->list.isEmpty())
evaluated: !d->list.isEmpty()
TRUEFALSE
yes
Evaluation Count:464
yes
Evaluation Count:223
223-464
973 delete d->list.takeFirst();
executed: delete d->list.takeFirst();
Execution Count:464
464
974}
executed: }
Execution Count:223
223
975 -
976/*! -
977 Updates the splitter's state. You should not need to call this -
978 function. -
979*/ -
980void QSplitter::refresh() -
981{ -
982 Q_D(QSplitter);
never executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
983 d->recalc(true);
never executed (the execution status of this line is deduced): d->recalc(true);
-
984}
never executed: }
0
985 -
986/*! -
987 \property QSplitter::orientation -
988 \brief the orientation of the splitter -
989 -
990 By default, the orientation is horizontal (i.e., the widgets are -
991 laid out side by side). The possible orientations are -
992 Qt::Horizontal and Qt::Vertical. -
993 -
994 \sa QSplitterHandle::orientation() -
995*/ -
996 -
997void QSplitter::setOrientation(Qt::Orientation orientation) -
998{ -
999 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1000 if (d->orient == orientation)
evaluated: d->orient == orientation
TRUEFALSE
yes
Evaluation Count:297
yes
Evaluation Count:9
9-297
1001 return;
executed: return;
Execution Count:297
297
1002 -
1003 if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
partially evaluated: !testAttribute(Qt::WA_WState_OwnSizePolicy)
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
1004 QSizePolicy sp = sizePolicy();
executed (the execution status of this line is deduced): QSizePolicy sp = sizePolicy();
-
1005 sp.transpose();
executed (the execution status of this line is deduced): sp.transpose();
-
1006 setSizePolicy(sp);
executed (the execution status of this line is deduced): setSizePolicy(sp);
-
1007 setAttribute(Qt::WA_WState_OwnSizePolicy, false);
executed (the execution status of this line is deduced): setAttribute(Qt::WA_WState_OwnSizePolicy, false);
-
1008 }
executed: }
Execution Count:9
9
1009 -
1010 d->orient = orientation;
executed (the execution status of this line is deduced): d->orient = orientation;
-
1011 -
1012 for (int i = 0; i < d->list.size(); ++i) {
evaluated: i < d->list.size()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:9
9-18
1013 QSplitterLayoutStruct *s = d->list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = d->list.at(i);
-
1014 s->handle->setOrientation(orientation);
executed (the execution status of this line is deduced): s->handle->setOrientation(orientation);
-
1015 }
executed: }
Execution Count:18
18
1016 d->recalc(isVisible());
executed (the execution status of this line is deduced): d->recalc(isVisible());
-
1017}
executed: }
Execution Count:9
9
1018 -
1019Qt::Orientation QSplitter::orientation() const -
1020{ -
1021 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1022 return d->orient;
executed: return d->orient;
Execution Count:824
824
1023} -
1024 -
1025/*! -
1026 \property QSplitter::childrenCollapsible -
1027 \brief whether child widgets can be resized down to size 0 by the user -
1028 -
1029 By default, children are collapsible. It is possible to enable -
1030 and disable the collapsing of individual children using -
1031 setCollapsible(). -
1032 -
1033 \sa setCollapsible() -
1034*/ -
1035 -
1036void QSplitter::setChildrenCollapsible(bool collapse) -
1037{ -
1038 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1039 d->childrenCollapsible = collapse;
executed (the execution status of this line is deduced): d->childrenCollapsible = collapse;
-
1040}
executed: }
Execution Count:503
503
1041 -
1042bool QSplitter::childrenCollapsible() const -
1043{ -
1044 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1045 return d->childrenCollapsible;
executed: return d->childrenCollapsible;
Execution Count:228
228
1046} -
1047 -
1048/*! -
1049 Sets whether the child widget at \a index is collapsible to \a collapse. -
1050 -
1051 By default, children are collapsible, meaning that the user can -
1052 resize them down to size 0, even if they have a non-zero -
1053 minimumSize() or minimumSizeHint(). This behavior can be changed -
1054 on a per-widget basis by calling this function, or globally for -
1055 all the widgets in the splitter by setting the \l -
1056 childrenCollapsible property. -
1057 -
1058 \sa childrenCollapsible -
1059*/ -
1060 -
1061void QSplitter::setCollapsible(int index, bool collapse) -
1062{ -
1063 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1064 -
1065 if (index < 0 || index >= d->list.size()) {
partially evaluated: index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1125
partially evaluated: index >= d->list.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1125
0-1125
1066 qWarning("QSplitter::setCollapsible: Index %d out of range", index);
never executed (the execution status of this line is deduced): QMessageLogger("widgets/qsplitter.cpp", 1066, __PRETTY_FUNCTION__).warning("QSplitter::setCollapsible: Index %d out of range", index);
-
1067 return;
never executed: return;
0
1068 } -
1069 d->list.at(index)->collapsible = collapse ? 1 : 0;
evaluated: collapse
TRUEFALSE
yes
Evaluation Count:875
yes
Evaluation Count:250
250-875
1070}
executed: }
Execution Count:1125
1125
1071 -
1072/*! -
1073 Returns true if the widget at \a index is collapsible, otherwise returns false. -
1074*/ -
1075bool QSplitter::isCollapsible(int index) const -
1076{ -
1077 Q_D(const QSplitter);
never executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1078 if (index < 0 || index >= d->list.size()) {
never evaluated: index < 0
never evaluated: index >= d->list.size()
0
1079 qWarning("QSplitter::isCollapsible: Index %d out of range", index);
never executed (the execution status of this line is deduced): QMessageLogger("widgets/qsplitter.cpp", 1079, __PRETTY_FUNCTION__).warning("QSplitter::isCollapsible: Index %d out of range", index);
-
1080 return false;
never executed: return false;
0
1081 } -
1082 return d->list.at(index)->collapsible;
never executed: return d->list.at(index)->collapsible;
0
1083} -
1084 -
1085/*! -
1086 \reimp -
1087*/ -
1088void QSplitter::resizeEvent(QResizeEvent *) -
1089{ -
1090 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1091 d->doResize();
executed (the execution status of this line is deduced): d->doResize();
-
1092}
executed: }
Execution Count:125
125
1093 -
1094/*! -
1095 Adds the given \a widget to the splitter's layout after all the other -
1096 items. -
1097 -
1098 If \a widget is already in the splitter, it will be moved to the new position. -
1099 -
1100 \sa insertWidget(), widget(), indexOf() -
1101*/ -
1102void QSplitter::addWidget(QWidget *widget) -
1103{ -
1104 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1105 insertWidget(d->list.count(), widget);
executed (the execution status of this line is deduced): insertWidget(d->list.count(), widget);
-
1106}
executed: }
Execution Count:852
852
1107 -
1108/*! -
1109 Inserts the \a widget specified into the splitter's layout at the -
1110 given \a index. -
1111 -
1112 If \a widget is already in the splitter, it will be moved to the new position. -
1113 -
1114 if \a index is an invalid index, then the widget will be inserted at the end. -
1115 -
1116 \sa addWidget(), indexOf(), widget() -
1117*/ -
1118void QSplitter::insertWidget(int index, QWidget *widget) -
1119{ -
1120 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1121 d->insertWidget_helper(index, widget, true);
executed (the execution status of this line is deduced): d->insertWidget_helper(index, widget, true);
-
1122}
executed: }
Execution Count:860
860
1123 -
1124/*! -
1125 \fn int QSplitter::indexOf(QWidget *widget) const -
1126 -
1127 Returns the index in the splitter's layout of the specified \a widget. This -
1128 also works for handles. -
1129 -
1130 Handles are numbered from 0. There are as many handles as there -
1131 are child widgets, but the handle at position 0 is always hidden. -
1132 -
1133 -
1134 \sa count(), widget() -
1135*/ -
1136int QSplitter::indexOf(QWidget *w) const -
1137{ -
1138 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1139 for (int i = 0; i < d->list.size(); ++i) {
evaluated: i < d->list.size()
TRUEFALSE
yes
Evaluation Count:2733
yes
Evaluation Count:2
2-2733
1140 QSplitterLayoutStruct *s = d->list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = d->list.at(i);
-
1141 if (s->widget == w || s->handle == w)
evaluated: s->widget == w
TRUEFALSE
yes
Evaluation Count:1356
yes
Evaluation Count:1377
partially evaluated: s->handle == w
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1377
0-1377
1142 return i;
executed: return i;
Execution Count:1356
1356
1143 }
executed: }
Execution Count:1377
1377
1144 return -1;
executed: return -1;
Execution Count:2
2
1145} -
1146 -
1147/*! -
1148 Returns a new splitter handle as a child widget of this splitter. -
1149 This function can be reimplemented in subclasses to provide support -
1150 for custom handles. -
1151 -
1152 \sa handle(), indexOf() -
1153*/ -
1154QSplitterHandle *QSplitter::createHandle() -
1155{ -
1156 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1157 return new QSplitterHandle(d->orient, this);
executed: return new QSplitterHandle(d->orient, this);
Execution Count:862
862
1158} -
1159 -
1160/*! -
1161 Returns the handle to the left (or above) for the item in the -
1162 splitter's layout at the given \a index. The handle at index 0 is -
1163 always hidden. -
1164 -
1165 For right-to-left languages such as Arabic and Hebrew, the layout -
1166 of horizontal splitters is reversed. The handle will be to the -
1167 right of the widget at \a index. -
1168 -
1169 \sa count(), widget(), indexOf(), createHandle(), setHandleWidth() -
1170*/ -
1171QSplitterHandle *QSplitter::handle(int index) const -
1172{ -
1173 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1174 if (index < 0 || index >= d->list.size())
partially evaluated: index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
partially evaluated: index >= d->list.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1175 return 0;
never executed: return 0;
0
1176 return d->list.at(index)->handle;
executed: return d->list.at(index)->handle;
Execution Count:7
7
1177} -
1178 -
1179/*! -
1180 Returns the widget at the given \a index in the splitter's layout. -
1181 -
1182 \sa count(), handle(), indexOf(), insertWidget() -
1183*/ -
1184QWidget *QSplitter::widget(int index) const -
1185{ -
1186 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1187 if (index < 0 || index >= d->list.size())
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1379
partially evaluated: index >= d->list.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1379
0-1379
1188 return 0;
executed: return 0;
Execution Count:1
1
1189 return d->list.at(index)->widget;
executed: return d->list.at(index)->widget;
Execution Count:1379
1379
1190} -
1191 -
1192/*! -
1193 Returns the number of widgets contained in the splitter's layout. -
1194 -
1195 \sa widget(), handle() -
1196*/ -
1197int QSplitter::count() const -
1198{ -
1199 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1200 return d->list.count();
executed: return d->list.count();
Execution Count:49
49
1201} -
1202 -
1203/*! -
1204 \reimp -
1205 -
1206 Tells the splitter that the child widget described by \a c has been -
1207 inserted or removed. -
1208 -
1209 This method is also used to handle the situation where a widget is created -
1210 with the splitter as a parent but not explicitly added with insertWidget() -
1211 or addWidget(). This is for compatibility and not the recommended way of -
1212 putting widgets into a splitter in new code. Please use insertWidget() or -
1213 addWidget() in new code. -
1214 -
1215 \sa addWidget(), insertWidget() -
1216*/ -
1217 -
1218void QSplitter::childEvent(QChildEvent *c) -
1219{ -
1220 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1221 if (!c->child()->isWidgetType()) {
evaluated: !c->child()->isWidgetType()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4244
2-4244
1222 if (c->type() == QEvent::ChildAdded && qobject_cast<QLayout *>(c->child()))
evaluated: c->type() == QEvent::ChildAdded
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: qobject_cast<QLayout *>(c->child())
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1223 qWarning("Adding a QLayout to a QSplitter is not supported.");
executed: QMessageLogger("widgets/qsplitter.cpp", 1223, __PRETTY_FUNCTION__).warning("Adding a QLayout to a QSplitter is not supported.");
Execution Count:1
1
1224 return;
executed: return;
Execution Count:2
2
1225 } -
1226 QWidget *w = static_cast<QWidget*>(c->child());
executed (the execution status of this line is deduced): QWidget *w = static_cast<QWidget*>(c->child());
-
1227 if (c->added() && !d->blockChildAdd && !w->isWindow() && !d->findWidget(w)) {
evaluated: c->added()
TRUEFALSE
yes
Evaluation Count:1725
yes
Evaluation Count:2519
evaluated: !d->blockChildAdd
TRUEFALSE
yes
Evaluation Count:392
yes
Evaluation Count:1333
partially evaluated: !w->isWindow()
TRUEFALSE
yes
Evaluation Count:392
no
Evaluation Count:0
partially evaluated: !d->findWidget(w)
TRUEFALSE
yes
Evaluation Count:392
no
Evaluation Count:0
0-2519
1228 d->insertWidget_helper(d->list.count(), w, false);
executed (the execution status of this line is deduced): d->insertWidget_helper(d->list.count(), w, false);
-
1229 } else if (c->polished() && !d->blockChildAdd) {
executed: }
Execution Count:392
evaluated: c->polished()
TRUEFALSE
yes
Evaluation Count:1292
yes
Evaluation Count:2560
evaluated: !d->blockChildAdd
TRUEFALSE
yes
Evaluation Count:436
yes
Evaluation Count:856
392-2560
1230 if (isVisible() && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide)))
evaluated: isVisible()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:428
evaluated: w->isHidden()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
evaluated: w->testAttribute(Qt::WA_WState_ExplicitShowHide)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-428
1231 w->show();
executed: w->show();
Execution Count:7
7
1232 } else if (c->type() == QEvent::ChildRemoved) {
executed: }
Execution Count:436
evaluated: c->type() == QEvent::ChildRemoved
TRUEFALSE
yes
Evaluation Count:1227
yes
Evaluation Count:2189
436-2189
1233 for (int i = 0; i < d->list.size(); ++i) {
evaluated: i < d->list.size()
TRUEFALSE
yes
Evaluation Count:2188
yes
Evaluation Count:846
846-2188
1234 QSplitterLayoutStruct *s = d->list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = d->list.at(i);
-
1235 if (s->widget == w) {
evaluated: s->widget == w
TRUEFALSE
yes
Evaluation Count:381
yes
Evaluation Count:1807
381-1807
1236 d->list.removeAt(i);
executed (the execution status of this line is deduced): d->list.removeAt(i);
-
1237 delete s;
executed (the execution status of this line is deduced): delete s;
-
1238 d->recalc(isVisible());
executed (the execution status of this line is deduced): d->recalc(isVisible());
-
1239 return;
executed: return;
Execution Count:381
381
1240 } -
1241 }
executed: }
Execution Count:1807
1807
1242 }
executed: }
Execution Count:846
846
1243} -
1244 -
1245 -
1246/*! -
1247 Displays a rubber band at position \a pos. If \a pos is negative, the -
1248 rubber band is removed. -
1249*/ -
1250 -
1251void QSplitter::setRubberBand(int pos) -
1252{ -
1253 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1254 if (pos < 0) {
partially evaluated: pos < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1255 if (d->rubberBand)
never evaluated: d->rubberBand
0
1256 d->rubberBand->deleteLater();
never executed: d->rubberBand->deleteLater();
0
1257 return;
never executed: return;
0
1258 } -
1259 QRect r = contentsRect();
executed (the execution status of this line is deduced): QRect r = contentsRect();
-
1260 const int rBord = 3; // customizable?
executed (the execution status of this line is deduced): const int rBord = 3;
-
1261 int hw = handleWidth();
executed (the execution status of this line is deduced): int hw = handleWidth();
-
1262 if (!d->rubberBand) {
partially evaluated: !d->rubberBand
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1263 QBoolBlocker b(d->blockChildAdd);
executed (the execution status of this line is deduced): QBoolBlocker b(d->blockChildAdd);
-
1264 d->rubberBand = new QRubberBand(QRubberBand::Line, this);
executed (the execution status of this line is deduced): d->rubberBand = new QRubberBand(QRubberBand::Line, this);
-
1265 // For accessibility to identify this special widget. -
1266 d->rubberBand->setObjectName(QLatin1String("qt_rubberband"));
executed (the execution status of this line is deduced): d->rubberBand->setObjectName(QLatin1String("qt_rubberband"));
-
1267 }
executed: }
Execution Count:1
1
1268 -
1269 const QRect newGeom = d->orient == Qt::Horizontal ? QRect(QPoint(pos + hw / 2 - rBord, r.y()), QSize(2 * rBord, r.height()))
partially evaluated: d->orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1270 : QRect(QPoint(r.x(), pos + hw / 2 - rBord), QSize(r.width(), 2 * rBord));
executed (the execution status of this line is deduced): : QRect(QPoint(r.x(), pos + hw / 2 - rBord), QSize(r.width(), 2 * rBord));
-
1271 d->rubberBand->setGeometry(newGeom);
executed (the execution status of this line is deduced): d->rubberBand->setGeometry(newGeom);
-
1272 d->rubberBand->show();
executed (the execution status of this line is deduced): d->rubberBand->show();
-
1273}
executed: }
Execution Count:1
1
1274 -
1275/*! -
1276 \reimp -
1277*/ -
1278 -
1279bool QSplitter::event(QEvent *e) -
1280{ -
1281 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1282 switch (e->type()) { -
1283 case QEvent::Hide: -
1284 // Reset firstShow to false here since things can be done to the splitter in between -
1285 if (!d->firstShow)
partially evaluated: !d->firstShow
TRUEFALSE
yes
Evaluation Count:48
no
Evaluation Count:0
0-48
1286 d->firstShow = true;
executed: d->firstShow = true;
Execution Count:48
48
1287 break;
executed: break;
Execution Count:48
48
1288 case QEvent::Show: -
1289 if (!d->firstShow)
partially evaluated: !d->firstShow
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:71
0-71
1290 break;
never executed: break;
0
1291 d->firstShow = false;
executed (the execution status of this line is deduced): d->firstShow = false;
-
1292 // fall through -
1293 case QEvent::HideToParent:
code before this statement executed: case QEvent::HideToParent:
Execution Count:71
71
1294 case QEvent::ShowToParent: -
1295 case QEvent::LayoutRequest: -
1296 d->recalc(isVisible());
executed (the execution status of this line is deduced): d->recalc(isVisible());
-
1297 break;
executed: break;
Execution Count:200
200
1298 default: -
1299 ; -
1300 }
executed: }
Execution Count:5273
5273
1301 return QWidget::event(e);
executed: return QWidget::event(e);
Execution Count:5521
5521
1302} -
1303 -
1304/*! -
1305 \fn QSplitter::splitterMoved(int pos, int index) -
1306 -
1307 This signal is emitted when the splitter handle at a particular \a -
1308 index has been moved to position \a pos. -
1309 -
1310 For right-to-left languages such as Arabic and Hebrew, the layout -
1311 of horizontal splitters is reversed. \a pos is then the -
1312 distance from the right edge of the widget. -
1313 -
1314 \sa moveSplitter() -
1315*/ -
1316 -
1317/*! -
1318 Moves the left or top edge of the splitter handle at \a index as -
1319 close as possible to position \a pos, which is the distance from the -
1320 left or top edge of the widget. -
1321 -
1322 For right-to-left languages such as Arabic and Hebrew, the layout -
1323 of horizontal splitters is reversed. \a pos is then the distance -
1324 from the right edge of the widget. -
1325 -
1326 \sa splitterMoved(), closestLegalPosition(), getRange() -
1327*/ -
1328void QSplitter::moveSplitter(int pos, int index) -
1329{ -
1330 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1331 QSplitterLayoutStruct *s = d->list.at(index);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = d->list.at(index);
-
1332 int farMin;
executed (the execution status of this line is deduced): int farMin;
-
1333 int min;
executed (the execution status of this line is deduced): int min;
-
1334 int max;
executed (the execution status of this line is deduced): int max;
-
1335 int farMax;
executed (the execution status of this line is deduced): int farMax;
-
1336 -
1337#ifdef QSPLITTER_DEBUG -
1338 int debugp = pos; -
1339#endif -
1340 -
1341 pos = d->adjustPos(pos, index, &farMin, &min, &max, &farMax);
executed (the execution status of this line is deduced): pos = d->adjustPos(pos, index, &farMin, &min, &max, &farMax);
-
1342 int oldP = d->pick(s->rect.topLeft());
executed (the execution status of this line is deduced): int oldP = d->pick(s->rect.topLeft());
-
1343#ifdef QSPLITTER_DEBUG -
1344 qDebug() << "QSplitter::moveSplitter" << debugp << index << "adjusted" << pos << "oldP" << oldP; -
1345#endif -
1346 -
1347 QVarLengthArray<int, 32> poss(d->list.count());
executed (the execution status of this line is deduced): QVarLengthArray<int, 32> poss(d->list.count());
-
1348 QVarLengthArray<int, 32> ws(d->list.count());
executed (the execution status of this line is deduced): QVarLengthArray<int, 32> ws(d->list.count());
-
1349 bool upLeft;
executed (the execution status of this line is deduced): bool upLeft;
-
1350 -
1351 d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data());
executed (the execution status of this line is deduced): d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data());
-
1352 d->doMove(true, pos, index - 1, +1, (d->collapsible(index - 1) && (pos < min)), poss.data(), ws.data());
executed (the execution status of this line is deduced): d->doMove(true, pos, index - 1, +1, (d->collapsible(index - 1) && (pos < min)), poss.data(), ws.data());
-
1353 upLeft = (pos < oldP);
executed (the execution status of this line is deduced): upLeft = (pos < oldP);
-
1354 -
1355 int wid, delta, count = d->list.count();
executed (the execution status of this line is deduced): int wid, delta, count = d->list.count();
-
1356 if (upLeft) {
partially evaluated: upLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1357 wid = 0;
never executed (the execution status of this line is deduced): wid = 0;
-
1358 delta = 1;
never executed (the execution status of this line is deduced): delta = 1;
-
1359 } else {
never executed: }
0
1360 wid = count - 1;
executed (the execution status of this line is deduced): wid = count - 1;
-
1361 delta = -1;
executed (the execution status of this line is deduced): delta = -1;
-
1362 }
executed: }
Execution Count:10
10
1363 for (; wid >= 0 && wid < count; wid += delta) {
evaluated: wid >= 0
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:10
partially evaluated: wid < count
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
1364 QSplitterLayoutStruct *sls = d->list.at( wid );
executed (the execution status of this line is deduced): QSplitterLayoutStruct *sls = d->list.at( wid );
-
1365 if (!sls->widget->isHidden())
partially evaluated: !sls->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
1366 d->setGeo(sls, poss[wid], ws[wid], true);
executed: d->setGeo(sls, poss[wid], ws[wid], true);
Execution Count:30
30
1367 }
executed: }
Execution Count:30
30
1368 d->storeSizes();
executed (the execution status of this line is deduced): d->storeSizes();
-
1369 -
1370 emit splitterMoved(pos, index);
executed (the execution status of this line is deduced): splitterMoved(pos, index);
-
1371}
executed: }
Execution Count:10
10
1372 -
1373 -
1374/*! -
1375 Returns the valid range of the splitter at \a index in -
1376 *\a{min} and *\a{max} if \a min and \a max are not 0. -
1377*/ -
1378 -
1379void QSplitter::getRange(int index, int *min, int *max) const -
1380{ -
1381 Q_D(const QSplitter);
never executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1382 d->getRange(index, min, 0, 0, max);
never executed (the execution status of this line is deduced): d->getRange(index, min, 0, 0, max);
-
1383}
never executed: }
0
1384 -
1385 -
1386/*! -
1387 Returns the closest legal position to \a pos of the widget at \a index. -
1388 -
1389 For right-to-left languages such as Arabic and Hebrew, the layout -
1390 of horizontal splitters is reversed. Positions are then measured -
1391 from the right edge of the widget. -
1392 -
1393 \sa getRange() -
1394*/ -
1395 -
1396int QSplitter::closestLegalPosition(int pos, int index) -
1397{ -
1398 Q_D(QSplitter);
never executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1399 int x, i, n, u;
never executed (the execution status of this line is deduced): int x, i, n, u;
-
1400 return d->adjustPos(pos, index, &u, &n, &i, &x);
never executed: return d->adjustPos(pos, index, &u, &n, &i, &x);
0
1401} -
1402 -
1403/*! -
1404 \property QSplitter::opaqueResize -
1405 \brief whether resizing is opaque -
1406 -
1407 Opaque resizing is on by default. -
1408*/ -
1409 -
1410bool QSplitter::opaqueResize() const -
1411{ -
1412 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1413 return d->opaque;
executed: return d->opaque;
Execution Count:230
230
1414} -
1415 -
1416 -
1417void QSplitter::setOpaqueResize(bool on) -
1418{ -
1419 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1420 d->opaque = on;
executed (the execution status of this line is deduced): d->opaque = on;
-
1421}
executed: }
Execution Count:129
129
1422 -
1423 -
1424/*! -
1425 \reimp -
1426*/ -
1427QSize QSplitter::sizeHint() const -
1428{ -
1429 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1430 ensurePolished();
executed (the execution status of this line is deduced): ensurePolished();
-
1431 int l = 0;
executed (the execution status of this line is deduced): int l = 0;
-
1432 int t = 0;
executed (the execution status of this line is deduced): int t = 0;
-
1433 for (int i = 0; i < d->list.size(); ++i) {
evaluated: i < d->list.size()
TRUEFALSE
yes
Evaluation Count:588
yes
Evaluation Count:308
308-588
1434 QWidget *w = d->list.at(i)->widget;
executed (the execution status of this line is deduced): QWidget *w = d->list.at(i)->widget;
-
1435 if (w->isHidden())
evaluated: w->isHidden()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:584
4-584
1436 continue;
executed: continue;
Execution Count:4
4
1437 QSize s = w->sizeHint();
executed (the execution status of this line is deduced): QSize s = w->sizeHint();
-
1438 if (s.isValid()) {
evaluated: s.isValid()
TRUEFALSE
yes
Evaluation Count:562
yes
Evaluation Count:22
22-562
1439 l += d->pick(s);
executed (the execution status of this line is deduced): l += d->pick(s);
-
1440 t = qMax(t, d->trans(s));
executed (the execution status of this line is deduced): t = qMax(t, d->trans(s));
-
1441 }
executed: }
Execution Count:562
562
1442 }
executed: }
Execution Count:584
584
1443 return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
executed: return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
Execution Count:308
308
1444} -
1445 -
1446 -
1447/*! -
1448 \reimp -
1449*/ -
1450 -
1451QSize QSplitter::minimumSizeHint() const -
1452{ -
1453 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1454 ensurePolished();
executed (the execution status of this line is deduced): ensurePolished();
-
1455 int l = 0;
executed (the execution status of this line is deduced): int l = 0;
-
1456 int t = 0;
executed (the execution status of this line is deduced): int t = 0;
-
1457 -
1458 for (int i = 0; i < d->list.size(); ++i) {
evaluated: i < d->list.size()
TRUEFALSE
yes
Evaluation Count:572
yes
Evaluation Count:288
288-572
1459 QSplitterLayoutStruct *s = d->list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = d->list.at(i);
-
1460 if (!s || !s->widget)
partially evaluated: !s
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:572
partially evaluated: !s->widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:572
0-572
1461 continue;
never executed: continue;
0
1462 if (s->widget->isHidden())
evaluated: s->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:568
4-568
1463 continue;
executed: continue;
Execution Count:4
4
1464 QSize widgetSize = qSmartMinSize(s->widget);
executed (the execution status of this line is deduced): QSize widgetSize = qSmartMinSize(s->widget);
-
1465 if (widgetSize.isValid()) {
partially evaluated: widgetSize.isValid()
TRUEFALSE
yes
Evaluation Count:568
no
Evaluation Count:0
0-568
1466 l += d->pick(widgetSize);
executed (the execution status of this line is deduced): l += d->pick(widgetSize);
-
1467 t = qMax(t, d->trans(widgetSize));
executed (the execution status of this line is deduced): t = qMax(t, d->trans(widgetSize));
-
1468 }
executed: }
Execution Count:568
568
1469 if (!s->handle || s->handle->isHidden())
partially evaluated: !s->handle
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:568
evaluated: s->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:285
yes
Evaluation Count:283
0-568
1470 continue;
executed: continue;
Execution Count:285
285
1471 QSize splitterSize = s->handle->sizeHint();
executed (the execution status of this line is deduced): QSize splitterSize = s->handle->sizeHint();
-
1472 if (splitterSize.isValid()) {
partially evaluated: splitterSize.isValid()
TRUEFALSE
yes
Evaluation Count:283
no
Evaluation Count:0
0-283
1473 l += d->pick(splitterSize);
executed (the execution status of this line is deduced): l += d->pick(splitterSize);
-
1474 t = qMax(t, d->trans(splitterSize));
executed (the execution status of this line is deduced): t = qMax(t, d->trans(splitterSize));
-
1475 }
executed: }
Execution Count:283
283
1476 }
executed: }
Execution Count:283
283
1477 return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
executed: return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
Execution Count:288
288
1478} -
1479 -
1480 -
1481/*! -
1482 Returns a list of the size parameters of all the widgets in this splitter. -
1483 -
1484 If the splitter's orientation is horizontal, the list contains the -
1485 widgets width in pixels, from left to right; if the orientation is -
1486 vertical, the list contains the widgets' heights in pixels, -
1487 from top to bottom. -
1488 -
1489 Giving the values to another splitter's setSizes() function will -
1490 produce a splitter with the same layout as this one. -
1491 -
1492 Note that invisible widgets have a size of 0. -
1493 -
1494 \sa setSizes() -
1495*/ -
1496 -
1497QList<int> QSplitter::sizes() const -
1498{ -
1499 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1500 ensurePolished();
executed (the execution status of this line is deduced): ensurePolished();
-
1501 -
1502 QList<int> list;
executed (the execution status of this line is deduced): QList<int> list;
-
1503 for (int i = 0; i < d->list.size(); ++i) {
evaluated: i < d->list.size()
TRUEFALSE
yes
Evaluation Count:1446
yes
Evaluation Count:533
533-1446
1504 QSplitterLayoutStruct *s = d->list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = d->list.at(i);
-
1505 list.append(d->pick(s->rect.size()));
executed (the execution status of this line is deduced): list.append(d->pick(s->rect.size()));
-
1506 }
executed: }
Execution Count:1446
1446
1507 return list;
executed: return list;
Execution Count:533
533
1508} -
1509 -
1510/*! -
1511 Sets the child widgets' respective sizes to the values given in the \a list. -
1512 -
1513 If the splitter is horizontal, the values set the width of each -
1514 widget in pixels, from left to right. If the splitter is vertical, the -
1515 height of each widget is set, from top to bottom. -
1516 -
1517 Extra values in the \a list are ignored. If \a list contains too few -
1518 values, the result is undefined, but the program will still be well-behaved. -
1519 -
1520 The overall size of the splitter widget is not affected. -
1521 Instead, any additional/missing space is distributed amongst the -
1522 widgets according to the relative weight of the sizes. -
1523 -
1524 If you specify a size of 0, the widget will be invisible. The size policies -
1525 of the widgets are preserved. That is, a value smaller than the minimal size -
1526 hint of the respective widget will be replaced by the value of the hint. -
1527 -
1528 \sa sizes() -
1529*/ -
1530 -
1531void QSplitter::setSizes(const QList<int> &list) -
1532{ -
1533 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1534 d->setSizes_helper(list, true);
executed (the execution status of this line is deduced): d->setSizes_helper(list, true);
-
1535}
executed: }
Execution Count:810
810
1536 -
1537/*! -
1538 \property QSplitter::handleWidth -
1539 \brief the width of the splitter handles -
1540 -
1541 By default, this property contains a value that depends on the user's platform -
1542 and style preferences. -
1543 -
1544 If you set handleWidth to 1 or 0, the actual grab area will grow to overlap a -
1545 few pixels of its respective widgets. -
1546*/ -
1547 -
1548int QSplitter::handleWidth() const -
1549{ -
1550 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1551 if (d->handleWidth >= 0) {
evaluated: d->handleWidth >= 0
TRUEFALSE
yes
Evaluation Count:1447
yes
Evaluation Count:7063
1447-7063
1552 return d->handleWidth;
executed: return d->handleWidth;
Execution Count:1447
1447
1553 } else { -
1554 return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this);
executed: return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this);
Execution Count:7063
7063
1555 } -
1556} -
1557 -
1558void QSplitter::setHandleWidth(int width) -
1559{ -
1560 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1561 d->handleWidth = width;
executed (the execution status of this line is deduced): d->handleWidth = width;
-
1562 d->updateHandles();
executed (the execution status of this line is deduced): d->updateHandles();
-
1563}
executed: }
Execution Count:126
126
1564 -
1565/*! -
1566 \reimp -
1567*/ -
1568void QSplitter::changeEvent(QEvent *ev) -
1569{ -
1570 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1571 if(ev->type() == QEvent::StyleChange)
partially evaluated: ev->type() == QEvent::StyleChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
1572 d->updateHandles();
never executed: d->updateHandles();
0
1573 QFrame::changeEvent(ev);
executed (the execution status of this line is deduced): QFrame::changeEvent(ev);
-
1574}
executed: }
Execution Count:42
42
1575 -
1576static const qint32 SplitterMagic = 0xff; -
1577 -
1578/*! -
1579 Saves the state of the splitter's layout. -
1580 -
1581 Typically this is used in conjunction with QSettings to remember the size -
1582 for a future session. A version number is stored as part of the data. -
1583 Here is an example: -
1584 -
1585 \snippet splitter/splitter.cpp 1 -
1586 -
1587 \sa restoreState() -
1588*/ -
1589QByteArray QSplitter::saveState() const -
1590{ -
1591 Q_D(const QSplitter);
executed (the execution status of this line is deduced): const QSplitterPrivate * const d = d_func();
-
1592 int version = 0;
executed (the execution status of this line is deduced): int version = 0;
-
1593 QByteArray data;
executed (the execution status of this line is deduced): QByteArray data;
-
1594 QDataStream stream(&data, QIODevice::WriteOnly);
executed (the execution status of this line is deduced): QDataStream stream(&data, QIODevice::WriteOnly);
-
1595 -
1596 stream << qint32(SplitterMagic);
executed (the execution status of this line is deduced): stream << qint32(SplitterMagic);
-
1597 stream << qint32(version);
executed (the execution status of this line is deduced): stream << qint32(version);
-
1598 QList<int> list;
executed (the execution status of this line is deduced): QList<int> list;
-
1599 for (int i = 0; i < d->list.size(); ++i) {
evaluated: i < d->list.size()
TRUEFALSE
yes
Evaluation Count:402
yes
Evaluation Count:201
201-402
1600 QSplitterLayoutStruct *s = d->list.at(i);
executed (the execution status of this line is deduced): QSplitterLayoutStruct *s = d->list.at(i);
-
1601 list.append(s->sizer);
executed (the execution status of this line is deduced): list.append(s->sizer);
-
1602 }
executed: }
Execution Count:402
402
1603 stream << list;
executed (the execution status of this line is deduced): stream << list;
-
1604 stream << childrenCollapsible();
executed (the execution status of this line is deduced): stream << childrenCollapsible();
-
1605 stream << qint32(handleWidth());
executed (the execution status of this line is deduced): stream << qint32(handleWidth());
-
1606 stream << opaqueResize();
executed (the execution status of this line is deduced): stream << opaqueResize();
-
1607 stream << qint32(orientation());
executed (the execution status of this line is deduced): stream << qint32(orientation());
-
1608 return data;
executed: return data;
Execution Count:201
201
1609} -
1610 -
1611/*! -
1612 Restores the splitter's layout to the \a state specified. -
1613 Returns true if the state is restored; otherwise returns false. -
1614 -
1615 Typically this is used in conjunction with QSettings to restore the size -
1616 from a past session. Here is an example: -
1617 -
1618 Restore the splitter's state: -
1619 -
1620 \snippet splitter/splitter.cpp 2 -
1621 -
1622 A failure to restore the splitter's layout may result from either -
1623 invalid or out-of-date data in the supplied byte array. -
1624 -
1625 \sa saveState() -
1626*/ -
1627bool QSplitter::restoreState(const QByteArray &state) -
1628{ -
1629 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1630 int version = 0;
executed (the execution status of this line is deduced): int version = 0;
-
1631 QByteArray sd = state;
executed (the execution status of this line is deduced): QByteArray sd = state;
-
1632 QDataStream stream(&sd, QIODevice::ReadOnly);
executed (the execution status of this line is deduced): QDataStream stream(&sd, QIODevice::ReadOnly);
-
1633 QList<int> list;
executed (the execution status of this line is deduced): QList<int> list;
-
1634 bool b;
executed (the execution status of this line is deduced): bool b;
-
1635 qint32 i;
executed (the execution status of this line is deduced): qint32 i;
-
1636 qint32 marker;
executed (the execution status of this line is deduced): qint32 marker;
-
1637 qint32 v;
executed (the execution status of this line is deduced): qint32 v;
-
1638 -
1639 stream >> marker;
executed (the execution status of this line is deduced): stream >> marker;
-
1640 stream >> v;
executed (the execution status of this line is deduced): stream >> v;
-
1641 if (marker != SplitterMagic || v != version)
evaluated: marker != SplitterMagic
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:117
partially evaluated: v != version
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:117
0-117
1642 return false;
executed: return false;
Execution Count:9
9
1643 -
1644 stream >> list;
executed (the execution status of this line is deduced): stream >> list;
-
1645 d->setSizes_helper(list, false);
executed (the execution status of this line is deduced): d->setSizes_helper(list, false);
-
1646 -
1647 stream >> b;
executed (the execution status of this line is deduced): stream >> b;
-
1648 setChildrenCollapsible(b);
executed (the execution status of this line is deduced): setChildrenCollapsible(b);
-
1649 -
1650 stream >> i;
executed (the execution status of this line is deduced): stream >> i;
-
1651 setHandleWidth(i);
executed (the execution status of this line is deduced): setHandleWidth(i);
-
1652 -
1653 stream >> b;
executed (the execution status of this line is deduced): stream >> b;
-
1654 setOpaqueResize(b);
executed (the execution status of this line is deduced): setOpaqueResize(b);
-
1655 -
1656 stream >> i;
executed (the execution status of this line is deduced): stream >> i;
-
1657 setOrientation(Qt::Orientation(i));
executed (the execution status of this line is deduced): setOrientation(Qt::Orientation(i));
-
1658 d->doResize();
executed (the execution status of this line is deduced): d->doResize();
-
1659 -
1660 return true;
executed: return true;
Execution Count:117
117
1661} -
1662 -
1663/*! -
1664 Updates the size policy of the widget at position \a index to -
1665 have a stretch factor of \a stretch. -
1666 -
1667 \a stretch is not the effective stretch factor; the effective -
1668 stretch factor is calculated by taking the initial size of the -
1669 widget and multiplying it with \a stretch. -
1670 -
1671 This function is provided for convenience. It is equivalent to -
1672 -
1673 \snippet code/src_gui_widgets_qsplitter.cpp 0 -
1674 -
1675 \sa setSizes(), widget() -
1676*/ -
1677void QSplitter::setStretchFactor(int index, int stretch) -
1678{ -
1679 Q_D(QSplitter);
executed (the execution status of this line is deduced): QSplitterPrivate * const d = d_func();
-
1680 if (index <= -1 || index >= d->list.count())
evaluated: index <= -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:199
partially evaluated: index >= d->list.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:199
0-199
1681 return;
executed: return;
Execution Count:1
1
1682 -
1683 QWidget *widget = d->list.at(index)->widget;
executed (the execution status of this line is deduced): QWidget *widget = d->list.at(index)->widget;
-
1684 QSizePolicy sp = widget->sizePolicy();
executed (the execution status of this line is deduced): QSizePolicy sp = widget->sizePolicy();
-
1685 sp.setHorizontalStretch(stretch);
executed (the execution status of this line is deduced): sp.setHorizontalStretch(stretch);
-
1686 sp.setVerticalStretch(stretch);
executed (the execution status of this line is deduced): sp.setVerticalStretch(stretch);
-
1687 widget->setSizePolicy(sp);
executed (the execution status of this line is deduced): widget->setSizePolicy(sp);
-
1688}
executed: }
Execution Count:199
199
1689 -
1690 -
1691/*! -
1692 \relates QSplitter -
1693 \obsolete -
1694 -
1695 Use \a ts << \a{splitter}.saveState() instead. -
1696*/ -
1697 -
1698QTextStream& operator<<(QTextStream& ts, const QSplitter& splitter) -
1699{ -
1700 ts << splitter.saveState() << endl;
never executed (the execution status of this line is deduced): ts << splitter.saveState() << endl;
-
1701 return ts;
never executed: return ts;
0
1702} -
1703 -
1704/*! -
1705 \relates QSplitter -
1706 \obsolete -
1707 -
1708 Use \a ts >> \a{splitter}.restoreState() instead. -
1709*/ -
1710 -
1711QTextStream& operator>>(QTextStream& ts, QSplitter& splitter) -
1712{ -
1713 QString line = ts.readLine();
never executed (the execution status of this line is deduced): QString line = ts.readLine();
-
1714 line = line.simplified();
never executed (the execution status of this line is deduced): line = line.simplified();
-
1715 line.replace(QLatin1Char(' '), QString());
never executed (the execution status of this line is deduced): line.replace(QLatin1Char(' '), QString());
-
1716 line = line.toUpper();
never executed (the execution status of this line is deduced): line = line.toUpper();
-
1717 -
1718 splitter.restoreState(line.toLatin1());
never executed (the execution status of this line is deduced): splitter.restoreState(line.toLatin1());
-
1719 return ts;
never executed: return ts;
0
1720} -
1721 -
1722QT_END_NAMESPACE -
1723 -
1724#endif // QT_NO_SPLITTER -
1725 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial