widgets/qsplitter.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent) -
8 : QWidget(*new QSplitterHandlePrivate, parent, 0) -
9{ -
10 QSplitterHandlePrivate * const d = d_func(); -
11 d->s = parent; -
12 setOrientation(orientation); -
13}
executed: }
Execution Count:862
862
14 -
15 -
16 -
17 -
18QSplitterHandle::~QSplitterHandle() -
19{ -
20} -
21 -
22 -
23 -
24 -
25 -
26 -
27 -
28void QSplitterHandle::setOrientation(Qt::Orientation orientation) -
29{ -
30 QSplitterHandlePrivate * const d = d_func(); -
31 d->orient = orientation; -
32 -
33 setCursor(orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor); -
34 -
35}
executed: }
Execution Count:880
880
36 -
37 -
38 -
39 -
40 -
41 -
42Qt::Orientation QSplitterHandle::orientation() const -
43{ -
44 const QSplitterHandlePrivate * const d = d_func(); -
45 return d->orient;
executed: return d->orient;
Execution Count:50
50
46} -
47bool QSplitterHandle::opaqueResize() const -
48{ -
49 const QSplitterHandlePrivate * const d = d_func(); -
50 return d->s->opaqueResize();
never executed: return d->s->opaqueResize();
0
51} -
52 -
53 -
54 -
55 -
56 -
57 -
58 -
59QSplitter *QSplitterHandle::splitter() const -
60{ -
61 return d_func()->s;
never executed: return d_func()->s;
0
62} -
63void QSplitterHandle::moveSplitter(int pos) -
64{ -
65 QSplitterHandlePrivate * const d = d_func(); -
66 if (d->s->isRightToLeft() && d->orient == Qt::Horizontal)
never evaluated: d->s->isRightToLeft()
never evaluated: d->orient == Qt::Horizontal
0
67 pos = d->s->contentsRect().width() - pos;
never executed: pos = d->s->contentsRect().width() - pos;
0
68 d->s->moveSplitter(pos, d->s->indexOf(this)); -
69}
never executed: }
0
70int QSplitterHandle::closestLegalPosition(int pos) -
71{ -
72 QSplitterHandlePrivate * const d = d_func(); -
73 QSplitter *s = d->s; -
74 if (s->isRightToLeft() && d->orient == Qt::Horizontal) {
never evaluated: s->isRightToLeft()
never evaluated: d->orient == Qt::Horizontal
0
75 int w = s->contentsRect().width(); -
76 return w - s->closestLegalPosition(w - pos, s->indexOf(this));
never executed: return w - s->closestLegalPosition(w - pos, s->indexOf(this));
0
77 } -
78 return s->closestLegalPosition(pos, s->indexOf(this));
never executed: return s->closestLegalPosition(pos, s->indexOf(this));
0
79} -
80 -
81 -
82 -
83 -
84QSize QSplitterHandle::sizeHint() const -
85{ -
86 const QSplitterHandlePrivate * const d = d_func(); -
87 int hw = d->s->handleWidth(); -
88 QStyleOption opt(0); -
89 opt.init(d->s); -
90 opt.state = QStyle::State_None; -
91 return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s) 8195
92 .expandedTo(QApplication::globalStrut());
executed: return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s) .expandedTo(QApplication::globalStrut());
Execution Count:8195
8195
93} -
94 -
95 -
96 -
97 -
98void QSplitterHandle::resizeEvent(QResizeEvent *event) -
99{ -
100 const QSplitterHandlePrivate * const d = d_func(); -
101 bool useTinyMode = (d->s->handleWidth() <= 1); -
102 setAttribute(Qt::WA_MouseNoMask, useTinyMode); -
103 if (useTinyMode) {
partially evaluated: useTinyMode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:80
0-80
104 if (orientation() == Qt::Horizontal)
never evaluated: orientation() == Qt::Horizontal
0
105 setContentsMargins(2, 0, 2, 0);
never executed: setContentsMargins(2, 0, 2, 0);
0
106 else -
107 setContentsMargins(0, 2, 0, 2);
never executed: setContentsMargins(0, 2, 0, 2);
0
108 setMask(QRegion(contentsRect())); -
109 }
never executed: }
0
110 -
111 QWidget::resizeEvent(event); -
112}
executed: }
Execution Count:80
80
113 -
114 -
115 -
116 -
117bool QSplitterHandle::event(QEvent *event) -
118{ -
119 QSplitterHandlePrivate * const d = d_func(); -
120 switch(event->type()) { -
121 case QEvent::HoverEnter: -
122 d->hover = true; -
123 update(); -
124 break;
never executed: break;
0
125 case QEvent::HoverLeave: -
126 d->hover = false; -
127 update(); -
128 break;
never executed: break;
0
129 default: -
130 break;
executed: break;
Execution Count:3244
3244
131 } -
132 return QWidget::event(event);
executed: return QWidget::event(event);
Execution Count:3244
3244
133} -
134 -
135 -
136 -
137 -
138void QSplitterHandle::mouseMoveEvent(QMouseEvent *e) -
139{ -
140 QSplitterHandlePrivate * const d = d_func(); -
141 if (!(e->buttons() & Qt::LeftButton))
never evaluated: !(e->buttons() & Qt::LeftButton)
0
142 return;
never executed: return;
0
143 int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos())) -
144 - d->mouseOffset; -
145 if (opaqueResize()) {
never evaluated: opaqueResize()
0
146 moveSplitter(pos); -
147 } else {
never executed: }
0
148 d->s->setRubberBand(closestLegalPosition(pos)); -
149 }
never executed: }
0
150} -
151 -
152 -
153 -
154 -
155void QSplitterHandle::mousePressEvent(QMouseEvent *e) -
156{ -
157 QSplitterHandlePrivate * const d = d_func(); -
158 if (e->button() == Qt::LeftButton) {
never evaluated: e->button() == Qt::LeftButton
0
159 d->mouseOffset = d->pick(e->pos()); -
160 d->pressed = true; -
161 update(); -
162 }
never executed: }
0
163}
never executed: }
0
164 -
165 -
166 -
167 -
168void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e) -
169{ -
170 QSplitterHandlePrivate * const d = d_func(); -
171 if (!opaqueResize() && e->button() == Qt::LeftButton) {
never evaluated: !opaqueResize()
never evaluated: e->button() == Qt::LeftButton
0
172 int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos())) -
173 - d->mouseOffset; -
174 d->s->setRubberBand(-1); -
175 moveSplitter(pos); -
176 }
never executed: }
0
177 if (e->button() == Qt::LeftButton) {
never evaluated: e->button() == Qt::LeftButton
0
178 d->pressed = false; -
179 update(); -
180 }
never executed: }
0
181}
never executed: }
0
182 -
183 -
184 -
185 -
186void QSplitterHandle::paintEvent(QPaintEvent *) -
187{ -
188 QSplitterHandlePrivate * const d = d_func(); -
189 QPainter p(this); -
190 QStyleOption opt(0); -
191 opt.rect = contentsRect(); -
192 opt.palette = palette(); -
193 if (orientation() == Qt::Horizontal)
evaluated: orientation() == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:2
2-48
194 opt.state = QStyle::State_Horizontal;
executed: opt.state = QStyle::State_Horizontal;
Execution Count:48
48
195 else -
196 opt.state = QStyle::State_None;
executed: opt.state = QStyle::State_None;
Execution Count:2
2
197 if (d->hover)
partially evaluated: d->hover
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
0-50
198 opt.state |= QStyle::State_MouseOver;
never executed: opt.state |= QStyle::State_MouseOver;
0
199 if (d->pressed)
partially evaluated: d->pressed
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
0-50
200 opt.state |= QStyle::State_Sunken;
never executed: opt.state |= QStyle::State_Sunken;
0
201 if (isEnabled())
partially evaluated: isEnabled()
TRUEFALSE
yes
Evaluation Count:50
no
Evaluation Count:0
0-50
202 opt.state |= QStyle::State_Enabled;
executed: opt.state |= QStyle::State_Enabled;
Execution Count:50
50
203 parentWidget()->style()->drawControl(QStyle::CE_Splitter, &opt, &p, d->s); -
204}
executed: }
Execution Count:50
50
205 -
206 -
207int QSplitterLayoutStruct::getWidgetSize(Qt::Orientation orient) -
208{ -
209 if (sizer == -1) {
evaluated: sizer == -1
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:2749
21-2749
210 QSize s = widget->sizeHint(); -
211 const int presizer = pick(s, orient); -
212 const int realsize = pick(widget->size(), orient); -
213 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
214 sizer = pick(widget->size(), orient); -
215 } else {
executed: }
Execution Count:2
2
216 sizer = presizer; -
217 }
executed: }
Execution Count:19
19
218 QSizePolicy p = widget->sizePolicy(); -
219 int sf = (orient == Qt::Horizontal) ? p.horizontalStretch() : p.verticalStretch();
evaluated: (orient == Qt::Horizontal)
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:2
2-19
220 if (sf > 1)
partially evaluated: sf > 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
221 sizer *= sf;
never executed: sizer *= sf;
0
222 }
executed: }
Execution Count:21
21
223 return sizer;
executed: return sizer;
Execution Count:2770
2770
224} -
225 -
226int QSplitterLayoutStruct::getHandleSize(Qt::Orientation orient) -
227{ -
228 return pick(handle->sizeHint(), orient);
executed: return pick(handle->sizeHint(), orient);
Execution Count:5585
5585
229} -
230 -
231void QSplitterPrivate::init() -
232{ -
233 QSplitter * const q = q_func(); -
234 QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Preferred); -
235 if (orient == Qt::Vertical)
evaluated: orient == Qt::Vertical
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:224
15-224
236 sp.transpose();
executed: sp.transpose();
Execution Count:15
15
237 q->setSizePolicy(sp); -
238 q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); -
239}
executed: }
Execution Count:239
239
240 -
241void QSplitterPrivate::recalc(bool update) -
242{ -
243 QSplitter * const q = q_func(); -
244 int n = list.count(); -
245 -
246 -
247 -
248 -
249 bool first = true; -
250 bool allInvisible = n != 0; -
251 for (int i = 0; i < n ; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:3877
yes
Evaluation Count:1968
1968-3877
252 QSplitterLayoutStruct *s = list.at(i); -
253 bool widgetHidden = s->widget->isHidden(); -
254 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
255 allInvisible = false;
executed: allInvisible = false;
Execution Count:1909
1909
256 s->handle->setHidden(first || widgetHidden); -
257 if (!widgetHidden)
evaluated: !widgetHidden
TRUEFALSE
yes
Evaluation Count:3852
yes
Evaluation Count:25
25-3852
258 first = false;
executed: first = false;
Execution Count:3852
3852
259 }
executed: }
Execution Count:3877
3877
260 -
261 if (allInvisible)
evaluated: allInvisible
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:1939
29-1939
262 for (int i = 0; i < n ; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:17
17-31
263 QSplitterLayoutStruct *s = list.at(i); -
264 if (!s->widget->isHidden()) {
evaluated: !s->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:19
12-19
265 s->collapsed = false; -
266 break;
executed: break;
Execution Count:12
12
267 } -
268 }
executed: }
Execution Count:19
19
269 -
270 int fi = 2 * q->frameWidth(); -
271 int maxl = fi; -
272 int minl = fi; -
273 int maxt = ((1<<24)-1); -
274 int mint = fi; -
275 -
276 -
277 -
278 bool empty = true; -
279 for (int j = 0; j < n; j++) {
evaluated: j < n
TRUEFALSE
yes
Evaluation Count:3877
yes
Evaluation Count:1968
1968-3877
280 QSplitterLayoutStruct *s = list.at(j); -
281 -
282 if (!s->widget->isHidden()) {
evaluated: !s->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:3852
yes
Evaluation Count:25
25-3852
283 empty = false; -
284 if (!s->handle->isHidden()) {
evaluated: !s->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:1931
yes
Evaluation Count:1921
1921-1931
285 minl += s->getHandleSize(orient); -
286 maxl += s->getHandleSize(orient); -
287 }
executed: }
Execution Count:1931
1931
288 -
289 QSize minS = qSmartMinSize(s->widget); -
290 minl += pick(minS); -
291 maxl += pick(s->widget->maximumSize()); -
292 mint = qMax(mint, trans(minS)); -
293 int tm = trans(s->widget->maximumSize()); -
294 if (tm > 0)
partially evaluated: tm > 0
TRUEFALSE
yes
Evaluation Count:3852
no
Evaluation Count:0
0-3852
295 maxt = qMin(maxt, tm);
executed: maxt = qMin(maxt, tm);
Execution Count:3852
3852
296 }
executed: }
Execution Count:3852
3852
297 }
executed: }
Execution Count:3877
3877
298 -
299 if (empty) {
evaluated: empty
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:1921
47-1921
300 if (qobject_cast<QSplitter *>(parent)) {
partially evaluated: qobject_cast<QSplitter *>(parent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
0-47
301 -
302 maxl = maxt = 0; -
303 } else {
never executed: }
0
304 -
305 maxl = ((1<<24)-1); -
306 }
executed: }
Execution Count:47
47
307 } else { -
308 maxl = qMin<int>(maxl, ((1<<24)-1)); -
309 }
executed: }
Execution Count:1921
1921
310 if (maxt < mint)
partially evaluated: maxt < mint
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1968
0-1968
311 maxt = mint;
never executed: maxt = mint;
0
312 -
313 if (update) {
evaluated: update
TRUEFALSE
yes
Evaluation Count:222
yes
Evaluation Count:1746
222-1746
314 if (orient == Qt::Horizontal) {
evaluated: orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:218
yes
Evaluation Count:4
4-218
315 q->setMaximumSize(maxl, maxt); -
316 if (q->isWindow())
evaluated: q->isWindow()
TRUEFALSE
yes
Evaluation Count:82
yes
Evaluation Count:136
82-136
317 q->setMinimumSize(minl,mint);
executed: q->setMinimumSize(minl,mint);
Execution Count:82
82
318 } else {
executed: }
Execution Count:218
218
319 q->setMaximumSize(maxt, maxl); -
320 if (q->isWindow())
partially evaluated: q->isWindow()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
321 q->setMinimumSize(mint,minl);
never executed: q->setMinimumSize(mint,minl);
0
322 }
executed: }
Execution Count:4
4
323 doResize(); -
324 q->updateGeometry(); -
325 } else {
executed: }
Execution Count:222
222
326 firstShow = true; -
327 }
executed: }
Execution Count:1746
1746
328} -
329 -
330void QSplitterPrivate::doResize() -
331{ -
332 QSplitter * const q = q_func(); -
333 QRect r = q->contentsRect(); -
334 int n = list.count(); -
335 QVector<QLayoutStruct> a(n*2); -
336 int i; -
337 -
338 bool noStretchFactorsSet = true; -
339 for (i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:3013
yes
Evaluation Count:1006
1006-3013
340 QSizePolicy p = list.at(i)->widget->sizePolicy(); -
341 int sf = orient == Qt::Horizontal ? p.horizontalStretch() : p.verticalStretch();
evaluated: orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:2990
yes
Evaluation Count:23
23-2990
342 if (sf != 0) {
evaluated: sf != 0
TRUEFALSE
yes
Evaluation Count:385
yes
Evaluation Count:2628
385-2628
343 noStretchFactorsSet = false; -
344 break;
executed: break;
Execution Count:385
385
345 } -
346 }
executed: }
Execution Count:2628
2628
347 -
348 int j=0; -
349 for (i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:3018
yes
Evaluation Count:1391
1391-3018
350 QSplitterLayoutStruct *s = list.at(i); -
351 -
352 -
353 -
354 -
355 -
356 a[j].init(); -
357 if (s->handle->isHidden()) {
evaluated: s->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:1355
yes
Evaluation Count:1663
1355-1663
358 a[j].maximumSize = 0; -
359 } else {
executed: }
Execution Count:1355
1355
360 a[j].sizeHint = a[j].minimumSize = a[j].maximumSize = s->getHandleSize(orient); -
361 a[j].empty = false; -
362 }
executed: }
Execution Count:1663
1663
363 ++j; -
364 -
365 a[j].init(); -
366 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
367 a[j].maximumSize = 0; -
368 } else {
executed: }
Execution Count:248
248
369 a[j].minimumSize = pick(qSmartMinSize(s->widget)); -
370 a[j].maximumSize = pick(s->widget->maximumSize()); -
371 a[j].empty = false; -
372 -
373 bool stretch = noStretchFactorsSet; -
374 if (!stretch) {
evaluated: !stretch
TRUEFALSE
yes
Evaluation Count:770
yes
Evaluation Count:2000
770-2000
375 QSizePolicy p = s->widget->sizePolicy(); -
376 int sf = orient == Qt::Horizontal ? p.horizontalStretch() : p.verticalStretch();
evaluated: orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:760
yes
Evaluation Count:10
10-760
377 stretch = (sf != 0); -
378 }
executed: }
Execution Count:770
770
379 if (stretch) {
evaluated: stretch
TRUEFALSE
yes
Evaluation Count:2385
yes
Evaluation Count:385
385-2385
380 a[j].stretch = s->getWidgetSize(orient); -
381 a[j].sizeHint = a[j].minimumSize; -
382 a[j].expansive = true; -
383 } else {
executed: }
Execution Count:2385
2385
384 a[j].sizeHint = qMax(s->getWidgetSize(orient), a[j].minimumSize); -
385 }
executed: }
Execution Count:385
385
386 } -
387 ++j; -
388 }
executed: }
Execution Count:3018
3018
389 -
390 qGeomCalc(a, 0, n*2, pick(r.topLeft()), pick(r.size()), 0); -
391 for (i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:3018
yes
Evaluation Count:1391
1391-3018
392 QSplitterLayoutStruct *s = list.at(i); -
393 setGeo(s, a[i*2+1].pos, a[i*2+1].size, false); -
394 }
executed: }
Execution Count:3018
3018
395}
executed: }
Execution Count:1391
1391
396 -
397void QSplitterPrivate::storeSizes() -
398{ -
399 for (int i = 0; i < list.size(); ++i) {
evaluated: i < list.size()
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:10
10-30
400 QSplitterLayoutStruct *sls = list.at(i); -
401 sls->sizer = pick(sls->rect.size()); -
402 }
executed: }
Execution Count:30
30
403}
executed: }
Execution Count:10
10
404 -
405void QSplitterPrivate::addContribution(int index, int *min, int *max, bool mayCollapse) const -
406{ -
407 QSplitterLayoutStruct *s = list.at(index); -
408 if (!s->widget->isHidden()) {
partially evaluated: !s->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:28
no
Evaluation Count:0
0-28
409 if (!s->handle->isHidden()) {
evaluated: !s->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:8
8-20
410 *min += s->getHandleSize(orient); -
411 *max += s->getHandleSize(orient); -
412 }
executed: }
Execution Count:20
20
413 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
414 *min += pick(qSmartMinSize(s->widget));
executed: *min += pick(qSmartMinSize(s->widget));
Execution Count:16
16
415 -
416 *max += pick(s->widget->maximumSize()); -
417 }
executed: }
Execution Count:28
28
418}
executed: }
Execution Count:28
28
419 -
420int QSplitterPrivate::findWidgetJustBeforeOrJustAfter(int index, int delta, int &collapsibleSize) const -
421{ -
422 if (delta < 0)
evaluated: delta < 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:8
8
423 index += delta;
executed: index += delta;
Execution Count:8
8
424 do { -
425 QWidget *w = list.at(index)->widget; -
426 if (!w->isHidden()) {
partially evaluated: !w->isHidden()
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
427 if (collapsible(list.at(index)))
partially evaluated: collapsible(list.at(index))
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
428 collapsibleSize = pick(qSmartMinSize(w));
executed: collapsibleSize = pick(qSmartMinSize(w));
Execution Count:16
16
429 return index;
executed: return index;
Execution Count:16
16
430 } -
431 index += delta; -
432 } while (index >= 0 && index < list.count());
never evaluated: index >= 0
never evaluated: index < list.count()
never executed: }
0
433 -
434 return -1;
never executed: return -1;
0
435} -
436 -
437 -
438 -
439 -
440 -
441void QSplitterPrivate::getRange(int index, int *farMin, int *min, int *max, int *farMax) const -
442{ -
443 const QSplitter * const q = q_func(); -
444 int n = list.count(); -
445 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
446 return;
executed: return;
Execution Count:2
2
447 -
448 int collapsibleSizeBefore = 0; -
449 int idJustBefore = findWidgetJustBeforeOrJustAfter(index, -1, collapsibleSizeBefore); -
450 -
451 int collapsibleSizeAfter = 0; -
452 int idJustAfter = findWidgetJustBeforeOrJustAfter(index, +1, collapsibleSizeAfter); -
453 -
454 int minBefore = 0; -
455 int minAfter = 0; -
456 int maxBefore = 0; -
457 int maxAfter = 0; -
458 int i; -
459 -
460 for (i = 0; i < index; ++i)
evaluated: i < index
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:8
8-20
461 addContribution(i, &minBefore, &maxBefore, i == idJustBefore);
executed: addContribution(i, &minBefore, &maxBefore, i == idJustBefore);
Execution Count:20
20
462 for (i = index; i < n; ++i)
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:8
8
463 addContribution(i, &minAfter, &maxAfter, i == idJustAfter);
executed: addContribution(i, &minAfter, &maxAfter, i == idJustAfter);
Execution Count:8
8
464 -
465 QRect r = q->contentsRect(); -
466 int farMinVal; -
467 int minVal; -
468 int maxVal; -
469 int farMaxVal; -
470 -
471 int smartMinBefore = qMax(minBefore, pick(r.size()) - maxAfter); -
472 int smartMaxBefore = qMin(maxBefore, pick(r.size()) - minAfter); -
473 -
474 minVal = pick(r.topLeft()) + smartMinBefore; -
475 maxVal = pick(r.topLeft()) + smartMaxBefore; -
476 -
477 farMinVal = minVal; -
478 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
479 farMinVal -= collapsibleSizeBefore;
executed: farMinVal -= collapsibleSizeBefore;
Execution Count:8
8
480 farMaxVal = maxVal; -
481 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
482 farMaxVal += collapsibleSizeAfter;
executed: farMaxVal += collapsibleSizeAfter;
Execution Count:8
8
483 -
484 if (farMin)
partially evaluated: farMin
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
485 *farMin = farMinVal;
executed: *farMin = farMinVal;
Execution Count:8
8
486 if (min)
partially evaluated: min
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
487 *min = minVal;
executed: *min = minVal;
Execution Count:8
8
488 if (max)
partially evaluated: max
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
489 *max = maxVal;
executed: *max = maxVal;
Execution Count:8
8
490 if (farMax)
partially evaluated: farMax
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
491 *farMax = farMaxVal;
executed: *farMax = farMaxVal;
Execution Count:8
8
492}
executed: }
Execution Count:8
8
493 -
494int QSplitterPrivate::adjustPos(int pos, int index, int *farMin, int *min, int *max, int *farMax) const -
495{ -
496 const int Threshold = 40; -
497 -
498 getRange(index, farMin, min, max, farMax); -
499 -
500 if (pos >= *min) {
evaluated: pos >= *min
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:9
1-9
501 if (pos <= *max) {
partially evaluated: pos <= *max
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
502 return pos;
executed: return pos;
Execution Count:1
1
503 } else { -
504 int delta = pos - *max; -
505 int width = *farMax - *max; -
506 -
507 if (delta > width / 2 && delta >= qMin(Threshold, width)) {
never evaluated: delta > width / 2
never evaluated: delta >= qMin(Threshold, width)
0
508 return *farMax;
never executed: return *farMax;
0
509 } else { -
510 return *max;
never executed: return *max;
0
511 } -
512 } -
513 } else { -
514 int delta = *min - pos; -
515 int width = *min - *farMin; -
516 -
517 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
518 return *farMin;
executed: return *farMin;
Execution Count:9
9
519 } else { -
520 return *min;
never executed: return *min;
0
521 } -
522 } -
523} -
524 -
525bool QSplitterPrivate::collapsible(QSplitterLayoutStruct *s) const -
526{ -
527 if (s->collapsible != Default) {
evaluated: s->collapsible != Default
TRUEFALSE
yes
Evaluation Count:225
yes
Evaluation Count:46
46-225
528 return (bool)s->collapsible;
executed: return (bool)s->collapsible;
Execution Count:225
225
529 } else { -
530 return childrenCollapsible;
executed: return childrenCollapsible;
Execution Count:46
46
531 } -
532} -
533 -
534void QSplitterPrivate::updateHandles() -
535{ -
536 QSplitter * const q = q_func(); -
537 recalc(q->isVisible()); -
538}
executed: }
Execution Count:126
126
539 -
540void QSplitterPrivate::setSizes_helper(const QList<int> &sizes, bool clampNegativeSize) -
541{ -
542 int j = 0; -
543 -
544 for (int i = 0; i < list.size(); ++i) {
evaluated: i < list.size()
TRUEFALSE
yes
Evaluation Count:2229
yes
Evaluation Count:927
927-2229
545 QSplitterLayoutStruct *s = list.at(i); -
546 -
547 s->collapsed = false; -
548 s->sizer = sizes.value(j++); -
549 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
550 s->sizer = 0;
never executed: s->sizer = 0;
0
551 int smartMinSize = pick(qSmartMinSize(s->widget)); -
552 -
553 -
554 if (s->sizer == 0) {
evaluated: s->sizer == 0
TRUEFALSE
yes
Evaluation Count:225
yes
Evaluation Count:2004
225-2004
555 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
556 s->collapsed = true; -
557 } else {
executed: }
Execution Count:175
175
558 s->sizer = smartMinSize; -
559 }
executed: }
Execution Count:50
50
560 } else { -
561 if (s->sizer < smartMinSize)
evaluated: s->sizer < smartMinSize
TRUEFALSE
yes
Evaluation Count:425
yes
Evaluation Count:1579
425-1579
562 s->sizer = smartMinSize;
executed: s->sizer = smartMinSize;
Execution Count:425
425
563 }
executed: }
Execution Count:2004
2004
564 } -
565 doResize(); -
566}
executed: }
Execution Count:927
927
567 -
568void QSplitterPrivate::setGeo(QSplitterLayoutStruct *sls, int p, int s, bool allowCollapse) -
569{ -
570 QSplitter * const q = q_func(); -
571 QWidget *w = sls->widget; -
572 QRect r; -
573 QRect contents = q->contentsRect(); -
574 if (orient == Qt::Horizontal) {
evaluated: orient == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:3020
yes
Evaluation Count:28
28-3020
575 r.setRect(p, contents.y(), s, contents.height()); -
576 } else {
executed: }
Execution Count:3020
3020
577 r.setRect(contents.x(), p, contents.width(), s); -
578 }
executed: }
Execution Count:28
28
579 sls->rect = r; -
580 -
581 int minSize = pick(qSmartMinSize(w)); -
582 -
583 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
584 r.moveRight(contents.width() - r.left());
never executed: r.moveRight(contents.width() - r.left());
0
585 -
586 if (allowCollapse)
evaluated: allowCollapse
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:3018
30-3018
587 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
588 -
589 -
590 -
591 if (sls->collapsed)
evaluated: sls->collapsed
TRUEFALSE
yes
Evaluation Count:242
yes
Evaluation Count:2806
242-2806
592 r.moveTopLeft(QPoint(-r.width()-1, -r.height()-1));
executed: r.moveTopLeft(QPoint(-r.width()-1, -r.height()-1));
Execution Count:242
242
593 -
594 w->setGeometry(r); -
595 -
596 if (!sls->handle->isHidden()) {
evaluated: !sls->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:1683
yes
Evaluation Count:1365
1365-1683
597 QSplitterHandle *h = sls->handle; -
598 QSize hs = h->sizeHint(); -
599 int left, top, right, bottom; -
600 h->getContentsMargins(&left, &top, &right, &bottom); -
601 if (orient==Qt::Horizontal) {
evaluated: orient==Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:1669
yes
Evaluation Count:14
14-1669
602 if (q->isRightToLeft())
partially evaluated: q->isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1669
0-1669
603 p = contents.width() - p + hs.width();
never executed: p = contents.width() - p + hs.width();
0
604 h->setGeometry(p-hs.width() - left, contents.y(), hs.width() + left + right, contents.height()); -
605 } else {
executed: }
Execution Count:1669
1669
606 h->setGeometry(contents.x(), p-hs.height() - top, contents.width(), hs.height() + top + bottom); -
607 }
executed: }
Execution Count:14
14
608 } -
609}
executed: }
Execution Count:3048
3048
610 -
611void QSplitterPrivate::doMove(bool backwards, int hPos, int index, int delta, bool mayCollapse, -
612 int *positions, int *widths) -
613{ -
614 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
615 return;
executed: return;
Execution Count:20
20
616 -
617 -
618 -
619 -
620 -
621 QSplitterLayoutStruct *s = list.at(index); -
622 QWidget *w = s->widget; -
623 -
624 int nextId = backwards ? index - delta : index + delta;
evaluated: backwards
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:10
10-20
625 -
626 if (w->isHidden()) {
partially evaluated: w->isHidden()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
627 doMove(backwards, hPos, nextId, delta, collapsible(nextId), positions, widths); -
628 } else {
never executed: }
0
629 int hs =s->handle->isHidden() ? 0 : s->getHandleSize(orient);
evaluated: s->handle->isHidden()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:20
10-20
630 -
631 int ws = backwards ? hPos - pick(s->rect.topLeft())
evaluated: backwards
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:10
10-20
632 : pick(s->rect.bottomRight()) - hPos -hs + 1; -
633 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
634 ws = qMin(ws, pick(w->maximumSize())); -
635 ws = qMax(ws, pick(qSmartMinSize(w))); -
636 } else {
executed: }
Execution Count:10
10
637 ws = 0; -
638 }
executed: }
Execution Count:20
20
639 positions[index] = backwards ? hPos - ws : hPos + hs;
evaluated: backwards
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:10
10-20
640 widths[index] = ws; -
641 doMove(backwards, backwards ? hPos - ws - hs : hPos + hs + ws, nextId, delta, -
642 collapsible(nextId), positions, widths); -
643 }
executed: }
Execution Count:30
30
644 -
645} -
646 -
647QSplitterLayoutStruct *QSplitterPrivate::findWidget(QWidget *w) const -
648{ -
649 for (int i = 0; i < list.size(); ++i) {
evaluated: i < list.size()
TRUEFALSE
yes
Evaluation Count:198
yes
Evaluation Count:392
198-392
650 if (list.at(i)->widget == w)
partially evaluated: list.at(i)->widget == w
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:198
0-198
651 return list.at(i);
never executed: return list.at(i);
0
652 }
executed: }
Execution Count:198
198
653 return 0;
executed: return 0;
Execution Count:392
392
654} -
655 -
656 -
657 -
658 -
659 -
660void QSplitterPrivate::insertWidget_helper(int index, QWidget *widget, bool show) -
661{ -
662 QSplitter * const q = q_func(); -
663 QBoolBlocker b(blockChildAdd); -
664 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
665 !(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
666 if (widget->parentWidget() != q)
evaluated: widget->parentWidget() != q
TRUEFALSE
yes
Evaluation Count:470
yes
Evaluation Count:782
470-782
667 widget->setParent(q);
executed: widget->setParent(q);
Execution Count:470
470
668 if (needShow)
evaluated: needShow
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1242
10-1242
669 widget->show();
executed: widget->show();
Execution Count:10
10
670 insertWidget(index, widget); -
671 recalc(q->isVisible()); -
672}
executed: }
Execution Count:1252
1252
673 -
674 -
675 -
676 -
677 -
678 -
679 -
680QSplitterLayoutStruct *QSplitterPrivate::insertWidget(int index, QWidget *w) -
681{ -
682 QSplitter * const q = q_func(); -
683 QSplitterLayoutStruct *sls = 0; -
684 int i; -
685 int last = list.count(); -
686 for (i = 0; i < list.size(); ++i) {
evaluated: i < list.size()
TRUEFALSE
yes
Evaluation Count:1639
yes
Evaluation Count:862
862-1639
687 QSplitterLayoutStruct *s = list.at(i); -
688 if (s->widget == w) {
evaluated: s->widget == w
TRUEFALSE
yes
Evaluation Count:390
yes
Evaluation Count:1249
390-1249
689 sls = s; -
690 --last; -
691 break;
executed: break;
Execution Count:390
390
692 } -
693 }
executed: }
Execution Count:1249
1249
694 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
695 index = last;
executed: index = last;
Execution Count:389
389
696 -
697 if (sls) {
evaluated: sls
TRUEFALSE
yes
Evaluation Count:390
yes
Evaluation Count:862
390-862
698 list.move(i,index); -
699 } else {
executed: }
Execution Count:390
390
700 QSplitterHandle *newHandle = 0; -
701 sls = new QSplitterLayoutStruct; -
702 QString tmp = QLatin1String("qt_splithandle_"); -
703 tmp += w->objectName(); -
704 newHandle = q->createHandle(); -
705 newHandle->setObjectName(tmp); -
706 sls->handle = newHandle; -
707 sls->widget = w; -
708 w->lower(); -
709 list.insert(index,sls); -
710 -
711 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
712 newHandle->show();
executed: newHandle->show();
Execution Count:15
15
713 -
714 }
executed: }
Execution Count:862
862
715 return sls;
executed: return sls;
Execution Count:1252
1252
716} -
717QSplitter::QSplitter(QWidget *parent) -
718 : QFrame(*new QSplitterPrivate, parent) -
719{ -
720 QSplitterPrivate * const d = d_func(); -
721 d->orient = Qt::Horizontal; -
722 d->init(); -
723}
executed: }
Execution Count:213
213
724 -
725 -
726 -
727 -
728 -
729 -
730 -
731QSplitter::QSplitter(Qt::Orientation orientation, QWidget *parent) -
732 : QFrame(*new QSplitterPrivate, parent) -
733{ -
734 QSplitterPrivate * const d = d_func(); -
735 d->orient = orientation; -
736 d->init(); -
737}
executed: }
Execution Count:26
26
738 -
739 -
740 -
741 -
742 -
743 -
744QSplitter::~QSplitter() -
745{ -
746 QSplitterPrivate * const d = d_func(); -
747 delete d->rubberBand; -
748 while (!d->list.isEmpty())
evaluated: !d->list.isEmpty()
TRUEFALSE
yes
Evaluation Count:464
yes
Evaluation Count:223
223-464
749 delete d->list.takeFirst();
executed: delete d->list.takeFirst();
Execution Count:464
464
750}
executed: }
Execution Count:223
223
751 -
752 -
753 -
754 -
755 -
756void QSplitter::refresh() -
757{ -
758 QSplitterPrivate * const d = d_func(); -
759 d->recalc(true); -
760}
never executed: }
0
761void QSplitter::setOrientation(Qt::Orientation orientation) -
762{ -
763 QSplitterPrivate * const d = d_func(); -
764 if (d->orient == orientation)
evaluated: d->orient == orientation
TRUEFALSE
yes
Evaluation Count:297
yes
Evaluation Count:9
9-297
765 return;
executed: return;
Execution Count:297
297
766 -
767 if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
partially evaluated: !testAttribute(Qt::WA_WState_OwnSizePolicy)
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
768 QSizePolicy sp = sizePolicy(); -
769 sp.transpose(); -
770 setSizePolicy(sp); -
771 setAttribute(Qt::WA_WState_OwnSizePolicy, false); -
772 }
executed: }
Execution Count:9
9
773 -
774 d->orient = orientation; -
775 -
776 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
777 QSplitterLayoutStruct *s = d->list.at(i); -
778 s->handle->setOrientation(orientation); -
779 }
executed: }
Execution Count:18
18
780 d->recalc(isVisible()); -
781}
executed: }
Execution Count:9
9
782 -
783Qt::Orientation QSplitter::orientation() const -
784{ -
785 const QSplitterPrivate * const d = d_func(); -
786 return d->orient;
executed: return d->orient;
Execution Count:824
824
787} -
788void QSplitter::setChildrenCollapsible(bool collapse) -
789{ -
790 QSplitterPrivate * const d = d_func(); -
791 d->childrenCollapsible = collapse; -
792}
executed: }
Execution Count:503
503
793 -
794bool QSplitter::childrenCollapsible() const -
795{ -
796 const QSplitterPrivate * const d = d_func(); -
797 return d->childrenCollapsible;
executed: return d->childrenCollapsible;
Execution Count:228
228
798} -
799void QSplitter::setCollapsible(int index, bool collapse) -
800{ -
801 QSplitterPrivate * const d = d_func(); -
802 -
803 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
804 QMessageLogger("widgets/qsplitter.cpp", 1066, __PRETTY_FUNCTION__).warning("QSplitter::setCollapsible: Index %d out of range", index); -
805 return;
never executed: return;
0
806 } -
807 d->list.at(index)->collapsible = collapse ? 1 : 0;
evaluated: collapse
TRUEFALSE
yes
Evaluation Count:875
yes
Evaluation Count:250
250-875
808}
executed: }
Execution Count:1125
1125
809 -
810 -
811 -
812 -
813bool QSplitter::isCollapsible(int index) const -
814{ -
815 const QSplitterPrivate * const d = d_func(); -
816 if (index < 0 || index >= d->list.size()) {
never evaluated: index < 0
never evaluated: index >= d->list.size()
0
817 QMessageLogger("widgets/qsplitter.cpp", 1079, __PRETTY_FUNCTION__).warning("QSplitter::isCollapsible: Index %d out of range", index); -
818 return false;
never executed: return false;
0
819 } -
820 return d->list.at(index)->collapsible;
never executed: return d->list.at(index)->collapsible;
0
821} -
822 -
823 -
824 -
825 -
826void QSplitter::resizeEvent(QResizeEvent *) -
827{ -
828 QSplitterPrivate * const d = d_func(); -
829 d->doResize(); -
830}
executed: }
Execution Count:125
125
831void QSplitter::addWidget(QWidget *widget) -
832{ -
833 QSplitterPrivate * const d = d_func(); -
834 insertWidget(d->list.count(), widget); -
835}
executed: }
Execution Count:852
852
836void QSplitter::insertWidget(int index, QWidget *widget) -
837{ -
838 QSplitterPrivate * const d = d_func(); -
839 d->insertWidget_helper(index, widget, true); -
840}
executed: }
Execution Count:860
860
841int QSplitter::indexOf(QWidget *w) const -
842{ -
843 const QSplitterPrivate * const d = d_func(); -
844 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
845 QSplitterLayoutStruct *s = d->list.at(i); -
846 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
847 return i;
executed: return i;
Execution Count:1356
1356
848 }
executed: }
Execution Count:1377
1377
849 return -1;
executed: return -1;
Execution Count:2
2
850} -
851QSplitterHandle *QSplitter::createHandle() -
852{ -
853 QSplitterPrivate * const d = d_func(); -
854 return new QSplitterHandle(d->orient, this);
executed: return new QSplitterHandle(d->orient, this);
Execution Count:862
862
855} -
856QSplitterHandle *QSplitter::handle(int index) const -
857{ -
858 const QSplitterPrivate * const d = d_func(); -
859 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
860 return 0;
never executed: return 0;
0
861 return d->list.at(index)->handle;
executed: return d->list.at(index)->handle;
Execution Count:7
7
862} -
863 -
864 -
865 -
866 -
867 -
868 -
869QWidget *QSplitter::widget(int index) const -
870{ -
871 const QSplitterPrivate * const d = d_func(); -
872 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
873 return 0;
executed: return 0;
Execution Count:1
1
874 return d->list.at(index)->widget;
executed: return d->list.at(index)->widget;
Execution Count:1379
1379
875} -
876 -
877 -
878 -
879 -
880 -
881 -
882int QSplitter::count() const -
883{ -
884 const QSplitterPrivate * const d = d_func(); -
885 return d->list.count();
executed: return d->list.count();
Execution Count:49
49
886} -
887void QSplitter::childEvent(QChildEvent *c) -
888{ -
889 QSplitterPrivate * const d = d_func(); -
890 if (!c->child()->isWidgetType()) {
evaluated: !c->child()->isWidgetType()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4244
2-4244
891 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
892 QMessageLogger("widgets/qsplitter.cpp", 1223, __PRETTY_FUNCTION__).warning("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
893 return;
executed: return;
Execution Count:2
2
894 } -
895 QWidget *w = static_cast<QWidget*>(c->child()); -
896 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
897 d->insertWidget_helper(d->list.count(), w, false); -
898 } 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
899 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
900 w->show();
executed: w->show();
Execution Count:7
7
901 } 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
902 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
903 QSplitterLayoutStruct *s = d->list.at(i); -
904 if (s->widget == w) {
evaluated: s->widget == w
TRUEFALSE
yes
Evaluation Count:381
yes
Evaluation Count:1807
381-1807
905 d->list.removeAt(i); -
906 delete s; -
907 d->recalc(isVisible()); -
908 return;
executed: return;
Execution Count:381
381
909 } -
910 }
executed: }
Execution Count:1807
1807
911 }
executed: }
Execution Count:846
846
912} -
913 -
914 -
915 -
916 -
917 -
918 -
919 -
920void QSplitter::setRubberBand(int pos) -
921{ -
922 QSplitterPrivate * const d = d_func(); -
923 if (pos < 0) {
partially evaluated: pos < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
924 if (d->rubberBand)
never evaluated: d->rubberBand
0
925 d->rubberBand->deleteLater();
never executed: d->rubberBand->deleteLater();
0
926 return;
never executed: return;
0
927 } -
928 QRect r = contentsRect(); -
929 const int rBord = 3; -
930 int hw = handleWidth(); -
931 if (!d->rubberBand) {
partially evaluated: !d->rubberBand
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
932 QBoolBlocker b(d->blockChildAdd); -
933 d->rubberBand = new QRubberBand(QRubberBand::Line, this); -
934 -
935 d->rubberBand->setObjectName(QLatin1String("qt_rubberband")); -
936 }
executed: }
Execution Count:1
1
937 -
938 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
939 : QRect(QPoint(r.x(), pos + hw / 2 - rBord), QSize(r.width(), 2 * rBord)); -
940 d->rubberBand->setGeometry(newGeom); -
941 d->rubberBand->show(); -
942}
executed: }
Execution Count:1
1
943 -
944 -
945 -
946 -
947 -
948bool QSplitter::event(QEvent *e) -
949{ -
950 QSplitterPrivate * const d = d_func(); -
951 switch (e->type()) { -
952 case QEvent::Hide: -
953 -
954 if (!d->firstShow)
partially evaluated: !d->firstShow
TRUEFALSE
yes
Evaluation Count:48
no
Evaluation Count:0
0-48
955 d->firstShow = true;
executed: d->firstShow = true;
Execution Count:48
48
956 break;
executed: break;
Execution Count:48
48
957 case QEvent::Show: -
958 if (!d->firstShow)
partially evaluated: !d->firstShow
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:71
0-71
959 break;
never executed: break;
0
960 d->firstShow = false; -
961 -
962 case QEvent::HideToParent:
code before this statement executed: case QEvent::HideToParent:
Execution Count:71
71
963 case QEvent::ShowToParent: -
964 case QEvent::LayoutRequest: -
965 d->recalc(isVisible()); -
966 break;
executed: break;
Execution Count:200
200
967 default: -
968 ; -
969 }
executed: }
Execution Count:5273
5273
970 return QWidget::event(e);
executed: return QWidget::event(e);
Execution Count:5521
5521
971} -
972void QSplitter::moveSplitter(int pos, int index) -
973{ -
974 QSplitterPrivate * const d = d_func(); -
975 QSplitterLayoutStruct *s = d->list.at(index); -
976 int farMin; -
977 int min; -
978 int max; -
979 int farMax; -
980 -
981 -
982 -
983 -
984 -
985 pos = d->adjustPos(pos, index, &farMin, &min, &max, &farMax); -
986 int oldP = d->pick(s->rect.topLeft()); -
987 -
988 -
989 -
990 -
991 QVarLengthArray<int, 32> poss(d->list.count()); -
992 QVarLengthArray<int, 32> ws(d->list.count()); -
993 bool upLeft; -
994 -
995 d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data()); -
996 d->doMove(true, pos, index - 1, +1, (d->collapsible(index - 1) && (pos < min)), poss.data(), ws.data()); -
997 upLeft = (pos < oldP); -
998 -
999 int wid, delta, count = d->list.count(); -
1000 if (upLeft) {
partially evaluated: upLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1001 wid = 0; -
1002 delta = 1; -
1003 } else {
never executed: }
0
1004 wid = count - 1; -
1005 delta = -1; -
1006 }
executed: }
Execution Count:10
10
1007 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
1008 QSplitterLayoutStruct *sls = d->list.at( wid ); -
1009 if (!sls->widget->isHidden())
partially evaluated: !sls->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
1010 d->setGeo(sls, poss[wid], ws[wid], true);
executed: d->setGeo(sls, poss[wid], ws[wid], true);
Execution Count:30
30
1011 }
executed: }
Execution Count:30
30
1012 d->storeSizes(); -
1013 -
1014 splitterMoved(pos, index); -
1015}
executed: }
Execution Count:10
10
1016 -
1017 -
1018 -
1019 -
1020 -
1021 -
1022 -
1023void QSplitter::getRange(int index, int *min, int *max) const -
1024{ -
1025 const QSplitterPrivate * const d = d_func(); -
1026 d->getRange(index, min, 0, 0, max); -
1027}
never executed: }
0
1028int QSplitter::closestLegalPosition(int pos, int index) -
1029{ -
1030 QSplitterPrivate * const d = d_func(); -
1031 int x, i, n, u; -
1032 return d->adjustPos(pos, index, &u, &n, &i, &x);
never executed: return d->adjustPos(pos, index, &u, &n, &i, &x);
0
1033} -
1034bool QSplitter::opaqueResize() const -
1035{ -
1036 const QSplitterPrivate * const d = d_func(); -
1037 return d->opaque;
executed: return d->opaque;
Execution Count:230
230
1038} -
1039 -
1040 -
1041void QSplitter::setOpaqueResize(bool on) -
1042{ -
1043 QSplitterPrivate * const d = d_func(); -
1044 d->opaque = on; -
1045}
executed: }
Execution Count:129
129
1046 -
1047 -
1048 -
1049 -
1050 -
1051QSize QSplitter::sizeHint() const -
1052{ -
1053 const QSplitterPrivate * const d = d_func(); -
1054 ensurePolished(); -
1055 int l = 0; -
1056 int t = 0; -
1057 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
1058 QWidget *w = d->list.at(i)->widget; -
1059 if (w->isHidden())
evaluated: w->isHidden()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:584
4-584
1060 continue;
executed: continue;
Execution Count:4
4
1061 QSize s = w->sizeHint(); -
1062 if (s.isValid()) {
evaluated: s.isValid()
TRUEFALSE
yes
Evaluation Count:562
yes
Evaluation Count:22
22-562
1063 l += d->pick(s); -
1064 t = qMax(t, d->trans(s)); -
1065 }
executed: }
Execution Count:562
562
1066 }
executed: }
Execution Count:584
584
1067 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
1068} -
1069 -
1070 -
1071 -
1072 -
1073 -
1074 -
1075QSize QSplitter::minimumSizeHint() const -
1076{ -
1077 const QSplitterPrivate * const d = d_func(); -
1078 ensurePolished(); -
1079 int l = 0; -
1080 int t = 0; -
1081 -
1082 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
1083 QSplitterLayoutStruct *s = d->list.at(i); -
1084 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
1085 continue;
never executed: continue;
0
1086 if (s->widget->isHidden())
evaluated: s->widget->isHidden()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:568
4-568
1087 continue;
executed: continue;
Execution Count:4
4
1088 QSize widgetSize = qSmartMinSize(s->widget); -
1089 if (widgetSize.isValid()) {
partially evaluated: widgetSize.isValid()
TRUEFALSE
yes
Evaluation Count:568
no
Evaluation Count:0
0-568
1090 l += d->pick(widgetSize); -
1091 t = qMax(t, d->trans(widgetSize)); -
1092 }
executed: }
Execution Count:568
568
1093 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
1094 continue;
executed: continue;
Execution Count:285
285
1095 QSize splitterSize = s->handle->sizeHint(); -
1096 if (splitterSize.isValid()) {
partially evaluated: splitterSize.isValid()
TRUEFALSE
yes
Evaluation Count:283
no
Evaluation Count:0
0-283
1097 l += d->pick(splitterSize); -
1098 t = qMax(t, d->trans(splitterSize)); -
1099 }
executed: }
Execution Count:283
283
1100 }
executed: }
Execution Count:283
283
1101 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
1102} -
1103QList<int> QSplitter::sizes() const -
1104{ -
1105 const QSplitterPrivate * const d = d_func(); -
1106 ensurePolished(); -
1107 -
1108 QList<int> list; -
1109 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
1110 QSplitterLayoutStruct *s = d->list.at(i); -
1111 list.append(d->pick(s->rect.size())); -
1112 }
executed: }
Execution Count:1446
1446
1113 return list;
executed: return list;
Execution Count:533
533
1114} -
1115void QSplitter::setSizes(const QList<int> &list) -
1116{ -
1117 QSplitterPrivate * const d = d_func(); -
1118 d->setSizes_helper(list, true); -
1119}
executed: }
Execution Count:810
810
1120int QSplitter::handleWidth() const -
1121{ -
1122 const QSplitterPrivate * const d = d_func(); -
1123 if (d->handleWidth >= 0) {
evaluated: d->handleWidth >= 0
TRUEFALSE
yes
Evaluation Count:1447
yes
Evaluation Count:7063
1447-7063
1124 return d->handleWidth;
executed: return d->handleWidth;
Execution Count:1447
1447
1125 } else { -
1126 return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this);
executed: return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this);
Execution Count:7063
7063
1127 } -
1128} -
1129 -
1130void QSplitter::setHandleWidth(int width) -
1131{ -
1132 QSplitterPrivate * const d = d_func(); -
1133 d->handleWidth = width; -
1134 d->updateHandles(); -
1135}
executed: }
Execution Count:126
126
1136 -
1137 -
1138 -
1139 -
1140void QSplitter::changeEvent(QEvent *ev) -
1141{ -
1142 QSplitterPrivate * const d = d_func(); -
1143 if(ev->type() == QEvent::StyleChange)
partially evaluated: ev->type() == QEvent::StyleChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
1144 d->updateHandles();
never executed: d->updateHandles();
0
1145 QFrame::changeEvent(ev); -
1146}
executed: }
Execution Count:42
42
1147 -
1148static const qint32 SplitterMagic = 0xff; -
1149QByteArray QSplitter::saveState() const -
1150{ -
1151 const QSplitterPrivate * const d = d_func(); -
1152 int version = 0; -
1153 QByteArray data; -
1154 QDataStream stream(&data, QIODevice::WriteOnly); -
1155 -
1156 stream << qint32(SplitterMagic); -
1157 stream << qint32(version); -
1158 QList<int> list; -
1159 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
1160 QSplitterLayoutStruct *s = d->list.at(i); -
1161 list.append(s->sizer); -
1162 }
executed: }
Execution Count:402
402
1163 stream << list; -
1164 stream << childrenCollapsible(); -
1165 stream << qint32(handleWidth()); -
1166 stream << opaqueResize(); -
1167 stream << qint32(orientation()); -
1168 return data;
executed: return data;
Execution Count:201
201
1169} -
1170bool QSplitter::restoreState(const QByteArray &state) -
1171{ -
1172 QSplitterPrivate * const d = d_func(); -
1173 int version = 0; -
1174 QByteArray sd = state; -
1175 QDataStream stream(&sd, QIODevice::ReadOnly); -
1176 QList<int> list; -
1177 bool b; -
1178 qint32 i; -
1179 qint32 marker; -
1180 qint32 v; -
1181 -
1182 stream >> marker; -
1183 stream >> v; -
1184 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
1185 return false;
executed: return false;
Execution Count:9
9
1186 -
1187 stream >> list; -
1188 d->setSizes_helper(list, false); -
1189 -
1190 stream >> b; -
1191 setChildrenCollapsible(b); -
1192 -
1193 stream >> i; -
1194 setHandleWidth(i); -
1195 -
1196 stream >> b; -
1197 setOpaqueResize(b); -
1198 -
1199 stream >> i; -
1200 setOrientation(Qt::Orientation(i)); -
1201 d->doResize(); -
1202 -
1203 return true;
executed: return true;
Execution Count:117
117
1204} -
1205void QSplitter::setStretchFactor(int index, int stretch) -
1206{ -
1207 QSplitterPrivate * const d = d_func(); -
1208 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
1209 return;
executed: return;
Execution Count:1
1
1210 -
1211 QWidget *widget = d->list.at(index)->widget; -
1212 QSizePolicy sp = widget->sizePolicy(); -
1213 sp.setHorizontalStretch(stretch); -
1214 sp.setVerticalStretch(stretch); -
1215 widget->setSizePolicy(sp); -
1216}
executed: }
Execution Count:199
199
1217QTextStream& operator<<(QTextStream& ts, const QSplitter& splitter) -
1218{ -
1219 ts << splitter.saveState() << endl; -
1220 return ts;
never executed: return ts;
0
1221} -
1222QTextStream& operator>>(QTextStream& ts, QSplitter& splitter) -
1223{ -
1224 QString line = ts.readLine(); -
1225 line = line.simplified(); -
1226 line.replace(QLatin1Char(' '), QString()); -
1227 line = line.toUpper(); -
1228 -
1229 splitter.restoreState(line.toLatin1()); -
1230 return ts;
never executed: return ts;
0
1231} -
1232 -
1233 -
1234 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial