qsplitter.cpp

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

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