widgets/qtabwidget.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5class QTabWidgetPrivate : public QWidgetPrivate -
6{ -
7 inline QTabWidget* q_func() { return static_cast<QTabWidget *>(q_ptr); } inline const QTabWidget* q_func() const { return static_cast<const QTabWidget *>(q_ptr); } friend class QTabWidget; -
8 -
9public: -
10 QTabWidgetPrivate(); -
11 ~QTabWidgetPrivate(); -
12 void updateTabBarPosition(); -
13 void _q_showTab(int); -
14 void _q_removeTab(int); -
15 void _q_tabMoved(int from, int to); -
16 void init(); -
17 -
18 QTabBar *tabs; -
19 QStackedWidget *stack; -
20 QRect panelRect; -
21 bool dirty; -
22 QTabWidget::TabPosition pos; -
23 QTabWidget::TabShape shape; -
24 int alignment; -
25 QWidget *leftCornerWidget; -
26 QWidget *rightCornerWidget; -
27}; -
28 -
29QTabWidgetPrivate::QTabWidgetPrivate() -
30 : tabs(0), stack(0), dirty(true), -
31 pos(QTabWidget::North), shape(QTabWidget::Rounded), -
32 leftCornerWidget(0), rightCornerWidget(0) -
33{}
executed: }
Execution Count:39
39
34 -
35QTabWidgetPrivate::~QTabWidgetPrivate() -
36{} -
37 -
38void QTabWidgetPrivate::init() -
39{ -
40 QTabWidget * const q = q_func(); -
41 -
42 stack = new QStackedWidget(q); -
43 stack->setObjectName(QLatin1String("qt_tabwidget_stackedwidget")); -
44 stack->setLineWidth(0); -
45 -
46 stack->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::TabWidget)); -
47 -
48 QObject::connect(stack, "2""widgetRemoved(int)", q, "1""_q_removeTab(int)"); -
49 QTabBar *tabBar = new QTabBar(q); -
50 tabBar->setObjectName(QLatin1String("qt_tabwidget_tabbar")); -
51 tabBar->setDrawBase(false); -
52 q->setTabBar(tabBar); -
53 -
54 q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, -
55 QSizePolicy::TabWidget)); -
56 -
57 -
58 -
59 -
60 -
61 q->setFocusPolicy(Qt::TabFocus); -
62 q->setFocusProxy(tabs); -
63 q->setTabPosition(static_cast<QTabWidget::TabPosition> (q->style()->styleHint( -
64 QStyle::SH_TabWidget_DefaultTabPosition, 0, q ))); -
65 -
66}
executed: }
Execution Count:39
39
67 -
68 -
69 -
70 -
71 -
72bool QTabWidget::hasHeightForWidth() const -
73{ -
74 const QTabWidgetPrivate * const d = d_func(); -
75 bool has = d->size_policy.hasHeightForWidth(); -
76 if (!has && d->stack)
partially evaluated: !has
TRUEFALSE
yes
Evaluation Count:77
no
Evaluation Count:0
partially evaluated: d->stack
TRUEFALSE
yes
Evaluation Count:77
no
Evaluation Count:0
0-77
77 has = d->stack->hasHeightForWidth();
executed: has = d->stack->hasHeightForWidth();
Execution Count:77
77
78 return has;
executed: return has;
Execution Count:77
77
79} -
80void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const -
81{ -
82 if (!option)
partially evaluated: !option
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:338
0-338
83 return;
never executed: return;
0
84 -
85 const QTabWidgetPrivate * const d = d_func(); -
86 option->initFrom(this); -
87 -
88 if (documentMode())
partially evaluated: documentMode()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:338
0-338
89 option->lineWidth = 0;
never executed: option->lineWidth = 0;
0
90 else -
91 option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this);
executed: option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this);
Execution Count:338
338
92 -
93 int exth = style()->pixelMetric(QStyle::PM_TabBarBaseHeight, 0, this); -
94 QSize t(0, d->stack->frameWidth()); -
95 if (d->tabs->isVisibleTo(const_cast<QTabWidget *>(this))) {
partially evaluated: d->tabs->isVisibleTo(const_cast<QTabWidget *>(this))
TRUEFALSE
yes
Evaluation Count:338
no
Evaluation Count:0
0-338
96 t = d->tabs->sizeHint(); -
97 if (documentMode()) {
partially evaluated: documentMode()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:338
0-338
98 if (tabPosition() == East || tabPosition() == West) {
never evaluated: tabPosition() == East
never evaluated: tabPosition() == West
0
99 t.setHeight(height()); -
100 } else {
never executed: }
0
101 t.setWidth(width()); -
102 }
never executed: }
0
103 } -
104 }
executed: }
Execution Count:338
338
105 -
106 if (d->rightCornerWidget) {
evaluated: d->rightCornerWidget
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:335
3-335
107 const QSize rightCornerSizeHint = d->rightCornerWidget->sizeHint(); -
108 const QSize bounds(rightCornerSizeHint.width(), t.height() - exth); -
109 option->rightCornerWidgetSize = rightCornerSizeHint.boundedTo(bounds); -
110 } else {
executed: }
Execution Count:3
3
111 option->rightCornerWidgetSize = QSize(0, 0); -
112 }
executed: }
Execution Count:335
335
113 -
114 if (d->leftCornerWidget) {
evaluated: d->leftCornerWidget
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:333
5-333
115 const QSize leftCornerSizeHint = d->leftCornerWidget->sizeHint(); -
116 const QSize bounds(leftCornerSizeHint.width(), t.height() - exth); -
117 option->leftCornerWidgetSize = leftCornerSizeHint.boundedTo(bounds); -
118 } else {
executed: }
Execution Count:5
5
119 option->leftCornerWidgetSize = QSize(0, 0); -
120 }
executed: }
Execution Count:333
333
121 -
122 switch (d->pos) { -
123 case QTabWidget::North: -
124 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedNorth
evaluated: d->shape == QTabWidget::Rounded
TRUEFALSE
yes
Evaluation Count:279
yes
Evaluation Count:2
2-279
125 : QTabBar::TriangularNorth; -
126 break;
executed: break;
Execution Count:281
281
127 case QTabWidget::South: -
128 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedSouth
partially evaluated: d->shape == QTabWidget::Rounded
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
129 : QTabBar::TriangularSouth; -
130 break;
executed: break;
Execution Count:19
19
131 case QTabWidget::West: -
132 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedWest
partially evaluated: d->shape == QTabWidget::Rounded
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
133 : QTabBar::TriangularWest; -
134 break;
executed: break;
Execution Count:19
19
135 case QTabWidget::East: -
136 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedEast
partially evaluated: d->shape == QTabWidget::Rounded
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
137 : QTabBar::TriangularEast; -
138 break;
executed: break;
Execution Count:19
19
139 } -
140 -
141 option->tabBarSize = t; -
142 -
143 if (QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<QStyleOptionTabWidgetFrameV2*>(option)) {
partially evaluated: QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<QStyleOptionTabWidgetFrameV2*>(option)
TRUEFALSE
yes
Evaluation Count:338
no
Evaluation Count:0
0-338
144 QRect tbRect = tabBar()->geometry(); -
145 QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex()); -
146 tabframe->tabBarRect = tbRect; -
147 selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft()); -
148 tabframe->selectedTabRect = selectedTabRect; -
149 }
executed: }
Execution Count:338
338
150}
executed: }
Execution Count:338
338
151 -
152 -
153 -
154 -
155QTabWidget::QTabWidget(QWidget *parent) -
156 : QWidget(*new QTabWidgetPrivate, parent, 0) -
157{ -
158 QTabWidgetPrivate * const d = d_func(); -
159 d->init(); -
160}
executed: }
Execution Count:39
39
161 -
162 -
163 -
164 -
165 -
166QTabWidget::~QTabWidget() -
167{ -
168} -
169int QTabWidget::addTab(QWidget *child, const QString &label) -
170{ -
171 return insertTab(-1, child, label);
executed: return insertTab(-1, child, label);
Execution Count:54
54
172} -
173int QTabWidget::addTab(QWidget *child, const QIcon& icon, const QString &label) -
174{ -
175 return insertTab(-1, child, icon, label);
never executed: return insertTab(-1, child, icon, label);
0
176} -
177int QTabWidget::insertTab(int index, QWidget *w, const QString &label) -
178{ -
179 return insertTab(index, w, QIcon(), label);
executed: return insertTab(index, w, QIcon(), label);
Execution Count:54
54
180} -
181int QTabWidget::insertTab(int index, QWidget *w, const QIcon& icon, const QString &label) -
182{ -
183 QTabWidgetPrivate * const d = d_func(); -
184 if(!w)
evaluated: !w
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:53
1-53
185 return -1;
executed: return -1;
Execution Count:1
1
186 index = d->stack->insertWidget(index, w); -
187 d->tabs->insertTab(index, icon, label); -
188 setUpLayout(); -
189 tabInserted(index); -
190 -
191 return index;
executed: return index;
Execution Count:53
53
192} -
193void QTabWidget::setTabText(int index, const QString &label) -
194{ -
195 QTabWidgetPrivate * const d = d_func(); -
196 d->tabs->setTabText(index, label); -
197 setUpLayout(); -
198}
executed: }
Execution Count:10
10
199 -
200 -
201 -
202 -
203 -
204QString QTabWidget::tabText(int index) const -
205{ -
206 const QTabWidgetPrivate * const d = d_func(); -
207 return d->tabs->tabText(index);
executed: return d->tabs->tabText(index);
Execution Count:4
4
208} -
209 -
210 -
211 -
212 -
213 -
214 -
215void QTabWidget::setTabIcon(int index, const QIcon &icon) -
216{ -
217 QTabWidgetPrivate * const d = d_func(); -
218 d->tabs->setTabIcon(index, icon); -
219 setUpLayout(); -
220}
executed: }
Execution Count:2
2
221 -
222 -
223 -
224 -
225 -
226QIcon QTabWidget::tabIcon(int index) const -
227{ -
228 const QTabWidgetPrivate * const d = d_func(); -
229 return d->tabs->tabIcon(index);
executed: return d->tabs->tabIcon(index);
Execution Count:1
1
230} -
231 -
232 -
233 -
234 -
235 -
236 -
237 -
238bool QTabWidget::isTabEnabled(int index) const -
239{ -
240 const QTabWidgetPrivate * const d = d_func(); -
241 return d->tabs->isTabEnabled(index);
executed: return d->tabs->isTabEnabled(index);
Execution Count:4
4
242} -
243void QTabWidget::setTabEnabled(int index, bool enable) -
244{ -
245 QTabWidgetPrivate * const d = d_func(); -
246 d->tabs->setTabEnabled(index, enable); -
247 if (QWidget *widget = d->stack->widget(index))
evaluated: QWidget *widget = d->stack->widget(index)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1
1-8
248 widget->setEnabled(enable);
executed: widget->setEnabled(enable);
Execution Count:8
8
249}
executed: }
Execution Count:9
9
250void QTabWidget::setCornerWidget(QWidget * widget, Qt::Corner corner) -
251{ -
252 QTabWidgetPrivate * const d = d_func(); -
253 if (widget && widget->parentWidget() != this)
evaluated: widget
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
evaluated: widget->parentWidget() != this
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-4
254 widget->setParent(this);
executed: widget->setParent(this);
Execution Count:1
1
255 -
256 if (corner & Qt::TopRightCorner) {
evaluated: corner & Qt::TopRightCorner
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
257 if (d->rightCornerWidget)
evaluated: d->rightCornerWidget
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
258 d->rightCornerWidget->hide();
executed: d->rightCornerWidget->hide();
Execution Count:2
2
259 d->rightCornerWidget = widget; -
260 } else {
executed: }
Execution Count:4
4
261 if (d->leftCornerWidget)
evaluated: d->leftCornerWidget
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
262 d->leftCornerWidget->hide();
executed: d->leftCornerWidget->hide();
Execution Count:1
1
263 d->leftCornerWidget = widget; -
264 }
executed: }
Execution Count:2
2
265 setUpLayout(); -
266}
executed: }
Execution Count:6
6
267 -
268 -
269 -
270 -
271QWidget * QTabWidget::cornerWidget(Qt::Corner corner) const -
272{ -
273 const QTabWidgetPrivate * const d = d_func(); -
274 if (corner & Qt::TopRightCorner)
evaluated: corner & Qt::TopRightCorner
TRUEFALSE
yes
Evaluation Count:907
yes
Evaluation Count:906
906-907
275 return d->rightCornerWidget;
executed: return d->rightCornerWidget;
Execution Count:907
907
276 return d->leftCornerWidget;
executed: return d->leftCornerWidget;
Execution Count:906
906
277} -
278 -
279 -
280 -
281 -
282 -
283 -
284 -
285void QTabWidget::removeTab(int index) -
286{ -
287 QTabWidgetPrivate * const d = d_func(); -
288 if (QWidget *w = d->stack->widget(index))
evaluated: QWidget *w = d->stack->widget(index)
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:1
1-20
289 d->stack->removeWidget(w);
executed: d->stack->removeWidget(w);
Execution Count:20
20
290}
executed: }
Execution Count:21
21
291QWidget * QTabWidget::currentWidget() const -
292{ -
293 const QTabWidgetPrivate * const d = d_func(); -
294 return d->stack->currentWidget();
executed: return d->stack->currentWidget();
Execution Count:29
29
295} -
296 -
297 -
298 -
299 -
300 -
301 -
302 -
303void QTabWidget::setCurrentWidget(QWidget *widget) -
304{ -
305 const QTabWidgetPrivate * const d = d_func(); -
306 d->tabs->setCurrentIndex(indexOf(widget)); -
307}
executed: }
Execution Count:9
9
308int QTabWidget::currentIndex() const -
309{ -
310 const QTabWidgetPrivate * const d = d_func(); -
311 return d->tabs->currentIndex();
executed: return d->tabs->currentIndex();
Execution Count:65
65
312} -
313 -
314void QTabWidget::setCurrentIndex(int index) -
315{ -
316 QTabWidgetPrivate * const d = d_func(); -
317 d->tabs->setCurrentIndex(index); -
318}
executed: }
Execution Count:30
30
319 -
320 -
321 -
322 -
323 -
324 -
325int QTabWidget::indexOf(QWidget* w) const -
326{ -
327 const QTabWidgetPrivate * const d = d_func(); -
328 return d->stack->indexOf(w);
executed: return d->stack->indexOf(w);
Execution Count:18
18
329} -
330 -
331 -
332 -
333 -
334 -
335void QTabWidget::resizeEvent(QResizeEvent *e) -
336{ -
337 QWidget::resizeEvent(e); -
338 setUpLayout(); -
339}
executed: }
Execution Count:21
21
340void QTabWidget::setTabBar(QTabBar* tb) -
341{ -
342 QTabWidgetPrivate * const d = d_func(); -
343 qt_noop(); -
344 -
345 if (tb->parentWidget() != this) {
partially evaluated: tb->parentWidget() != this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:39
0-39
346 tb->setParent(this); -
347 tb->show(); -
348 }
never executed: }
0
349 delete d->tabs; -
350 d->tabs = tb; -
351 setFocusProxy(d->tabs); -
352 connect(d->tabs, "2""currentChanged(int)", -
353 this, "1""_q_showTab(int)"); -
354 connect(d->tabs, "2""tabMoved(int,int)", -
355 this, "1""_q_tabMoved(int,int)"); -
356 if (d->tabs->tabsClosable())
partially evaluated: d->tabs->tabsClosable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:39
0-39
357 connect(d->tabs, "2""tabCloseRequested(int)", 0
358 this, "2""tabCloseRequested(int)");
never executed: connect(d->tabs, "2""tabCloseRequested(int)", this, "2""tabCloseRequested(int)");
0
359 tb->setExpanding(!documentMode()); -
360 setUpLayout(); -
361}
executed: }
Execution Count:39
39
362 -
363 -
364 -
365 -
366 -
367 -
368 -
369QTabBar* QTabWidget::tabBar() const -
370{ -
371 const QTabWidgetPrivate * const d = d_func(); -
372 return d->tabs;
executed: return d->tabs;
Execution Count:1015
1015
373} -
374 -
375 -
376 -
377 -
378 -
379 -
380void QTabWidgetPrivate::_q_showTab(int index) -
381{ -
382 QTabWidget * const q = q_func(); -
383 if (index < stack->count() && index >= 0)
partially evaluated: index < stack->count()
TRUEFALSE
yes
Evaluation Count:80
no
Evaluation Count:0
evaluated: index >= 0
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:12
0-80
384 stack->setCurrentIndex(index);
executed: stack->setCurrentIndex(index);
Execution Count:68
68
385 q->currentChanged(index); -
386}
executed: }
Execution Count:80
80
387 -
388void QTabWidgetPrivate::_q_removeTab(int index) -
389{ -
390 QTabWidget * const q = q_func(); -
391 tabs->removeTab(index); -
392 q->setUpLayout(); -
393 q->tabRemoved(index); -
394}
executed: }
Execution Count:22
22
395 -
396void QTabWidgetPrivate::_q_tabMoved(int from, int to) -
397{ -
398 stack->blockSignals(true); -
399 QWidget *w = stack->widget(from); -
400 stack->removeWidget(w); -
401 stack->insertWidget(to, w); -
402 stack->blockSignals(false); -
403}
never executed: }
0
404 -
405 -
406 -
407 -
408 -
409 -
410void QTabWidget::setUpLayout(bool onlyCheck) -
411{ -
412 QTabWidgetPrivate * const d = d_func(); -
413 if (onlyCheck && !d->dirty)
partially evaluated: onlyCheck
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:197
never evaluated: !d->dirty
0-197
414 return;
never executed: return;
0
415 -
416 QStyleOptionTabWidgetFrameV2 option; -
417 initStyleOption(&option); -
418 -
419 -
420 d->setLayoutItemMargins(QStyle::SE_TabWidgetLayoutItem, &option); -
421 -
422 if (!isVisible()) {
evaluated: !isVisible()
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:53
53-144
423 d->dirty = true; -
424 return;
executed: return;
Execution Count:144
144
425 } -
426 -
427 QRect tabRect = style()->subElementRect(QStyle::SE_TabWidgetTabBar, &option, this); -
428 d->panelRect = style()->subElementRect(QStyle::SE_TabWidgetTabPane, &option, this); -
429 QRect contentsRect = style()->subElementRect(QStyle::SE_TabWidgetTabContents, &option, this); -
430 QRect leftCornerRect = style()->subElementRect(QStyle::SE_TabWidgetLeftCorner, &option, this); -
431 QRect rightCornerRect = style()->subElementRect(QStyle::SE_TabWidgetRightCorner, &option, this); -
432 -
433 d->tabs->setGeometry(tabRect); -
434 d->stack->setGeometry(contentsRect); -
435 if (d->leftCornerWidget)
partially evaluated: d->leftCornerWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:53
0-53
436 d->leftCornerWidget->setGeometry(leftCornerRect);
never executed: d->leftCornerWidget->setGeometry(leftCornerRect);
0
437 if (d->rightCornerWidget)
partially evaluated: d->rightCornerWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:53
0-53
438 d->rightCornerWidget->setGeometry(rightCornerRect);
never executed: d->rightCornerWidget->setGeometry(rightCornerRect);
0
439 -
440 if (!onlyCheck)
partially evaluated: !onlyCheck
TRUEFALSE
yes
Evaluation Count:53
no
Evaluation Count:0
0-53
441 update();
executed: update();
Execution Count:53
53
442 updateGeometry(); -
443}
executed: }
Execution Count:53
53
444 -
445 -
446 -
447 -
448static inline QSize basicSize( -
449 bool horizontal, const QSize &lc, const QSize &rc, const QSize &s, const QSize &t) -
450{ -
451 return horizontal 103
452 ? QSize(qMax(s.width(), t.width() + rc.width() + lc.width()), 103
453 s.height() + (qMax(rc.height(), qMax(lc.height(), t.height())))) 103
454 : QSize(s.width() + (qMax(rc.width(), qMax(lc.width(), t.width()))), 103
455 qMax(s.height(), t.height() + rc.height() + lc.height()));
executed: return horizontal ? QSize(qMax(s.width(), t.width() + rc.width() + lc.width()), s.height() + (qMax(rc.height(), qMax(lc.height(), t.height())))) : QSize(s.width() + (qMax(rc.width(), qMax(lc.width(), t.width()))), qMax(s.height(), t.height() + rc.height() + lc.height()));
Execution Count:103
103
456} -
457 -
458 -
459 -
460 -
461QSize QTabWidget::sizeHint() const -
462{ -
463 const QTabWidgetPrivate * const d = d_func(); -
464 QSize lc(0, 0), rc(0, 0); -
465 QStyleOptionTabWidgetFrameV2 opt; -
466 initStyleOption(&opt); -
467 opt.state = QStyle::State_None; -
468 -
469 if (d->leftCornerWidget)
partially evaluated: d->leftCornerWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41
0-41
470 lc = d->leftCornerWidget->sizeHint();
never executed: lc = d->leftCornerWidget->sizeHint();
0
471 if(d->rightCornerWidget)
partially evaluated: d->rightCornerWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41
0-41
472 rc = d->rightCornerWidget->sizeHint();
never executed: rc = d->rightCornerWidget->sizeHint();
0
473 if (!d->dirty) {
partially evaluated: !d->dirty
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41
0-41
474 QTabWidget *that = (QTabWidget*)this; -
475 that->setUpLayout(true); -
476 }
never executed: }
0
477 QSize s(d->stack->sizeHint()); -
478 QSize t(d->tabs->sizeHint()); -
479 if(usesScrollButtons())
partially evaluated: usesScrollButtons()
TRUEFALSE
yes
Evaluation Count:41
no
Evaluation Count:0
0-41
480 t = t.boundedTo(QSize(200,200));
executed: t = t.boundedTo(QSize(200,200));
Execution Count:41
41
481 else -
482 t = t.boundedTo(QApplication::desktop()->size());
never executed: t = t.boundedTo(QApplication::desktop()->size());
0
483 -
484 QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t); -
485 -
486 return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) 41
487 .expandedTo(QApplication::globalStrut());
executed: return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) .expandedTo(QApplication::globalStrut());
Execution Count:41
41
488} -
489 -
490 -
491 -
492 -
493 -
494 -
495 -
496QSize QTabWidget::minimumSizeHint() const -
497{ -
498 const QTabWidgetPrivate * const d = d_func(); -
499 QSize lc(0, 0), rc(0, 0); -
500 -
501 if(d->leftCornerWidget)
partially evaluated: d->leftCornerWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38
0-38
502 lc = d->leftCornerWidget->minimumSizeHint();
never executed: lc = d->leftCornerWidget->minimumSizeHint();
0
503 if(d->rightCornerWidget)
partially evaluated: d->rightCornerWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38
0-38
504 rc = d->rightCornerWidget->minimumSizeHint();
never executed: rc = d->rightCornerWidget->minimumSizeHint();
0
505 if (!d->dirty) {
partially evaluated: !d->dirty
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38
0-38
506 QTabWidget *that = (QTabWidget*)this; -
507 that->setUpLayout(true); -
508 }
never executed: }
0
509 QSize s(d->stack->minimumSizeHint()); -
510 QSize t(d->tabs->minimumSizeHint()); -
511 -
512 QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t); -
513 -
514 QStyleOptionTabWidgetFrameV2 opt; -
515 initStyleOption(&opt); -
516 opt.palette = palette(); -
517 opt.state = QStyle::State_None; -
518 return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) 38
519 .expandedTo(QApplication::globalStrut());
executed: return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) .expandedTo(QApplication::globalStrut());
Execution Count:38
38
520} -
521 -
522 -
523 -
524 -
525int QTabWidget::heightForWidth(int width) const -
526{ -
527 const QTabWidgetPrivate * const d = d_func(); -
528 QStyleOptionTabWidgetFrameV2 opt; -
529 initStyleOption(&opt); -
530 opt.state = QStyle::State_None; -
531 -
532 QSize zero(0,0); -
533 const QSize padding = style()->sizeFromContents(QStyle::CT_TabWidget, &opt, zero, this) -
534 .expandedTo(QApplication::globalStrut()); -
535 -
536 QSize lc(0, 0), rc(0, 0); -
537 if (d->leftCornerWidget)
partially evaluated: d->leftCornerWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
538 lc = d->leftCornerWidget->sizeHint();
never executed: lc = d->leftCornerWidget->sizeHint();
0
539 if(d->rightCornerWidget)
partially evaluated: d->rightCornerWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
540 rc = d->rightCornerWidget->sizeHint();
never executed: rc = d->rightCornerWidget->sizeHint();
0
541 if (!d->dirty) {
partially evaluated: !d->dirty
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
542 QTabWidget *that = (QTabWidget*)this; -
543 that->setUpLayout(true); -
544 }
never executed: }
0
545 QSize t(d->tabs->sizeHint()); -
546 -
547 if(usesScrollButtons())
partially evaluated: usesScrollButtons()
TRUEFALSE
yes
Evaluation Count:24
no
Evaluation Count:0
0-24
548 t = t.boundedTo(QSize(200,200));
executed: t = t.boundedTo(QSize(200,200));
Execution Count:24
24
549 else -
550 t = t.boundedTo(QApplication::desktop()->size());
never executed: t = t.boundedTo(QApplication::desktop()->size());
0
551 -
552 const bool tabIsHorizontal = (d->pos == North || d->pos == South);
evaluated: d->pos == North
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:18
evaluated: d->pos == South
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:12
6-18
553 const int contentsWidth = width - padding.width(); -
554 int stackWidth = contentsWidth; -
555 if (!tabIsHorizontal)
evaluated: !tabIsHorizontal
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:12
12
556 stackWidth -= qMax(t.width(), qMax(lc.width(), rc.width()));
executed: stackWidth -= qMax(t.width(), qMax(lc.width(), rc.width()));
Execution Count:12
12
557 -
558 int stackHeight = d->stack->heightForWidth(stackWidth); -
559 QSize s(stackWidth, stackHeight); -
560 -
561 QSize contentSize = basicSize(tabIsHorizontal, lc, rc, s, t); -
562 return (contentSize + padding).expandedTo(QApplication::globalStrut()).height();
executed: return (contentSize + padding).expandedTo(QApplication::globalStrut()).height();
Execution Count:24
24
563} -
564 -
565 -
566 -
567 -
568 -
569void QTabWidget::showEvent(QShowEvent *) -
570{ -
571 setUpLayout(); -
572}
executed: }
Execution Count:15
15
573 -
574void QTabWidgetPrivate::updateTabBarPosition() -
575{ -
576 QTabWidget * const q = q_func(); -
577 switch (pos) { -
578 case QTabWidget::North: -
579 tabs->setShape(shape == QTabWidget::Rounded ? QTabBar::RoundedNorth -
580 : QTabBar::TriangularNorth); -
581 break;
executed: break;
Execution Count:3
3
582 case QTabWidget::South: -
583 tabs->setShape(shape == QTabWidget::Rounded ? QTabBar::RoundedSouth -
584 : QTabBar::TriangularSouth); -
585 break;
executed: break;
Execution Count:2
2
586 case QTabWidget::West: -
587 tabs->setShape(shape == QTabWidget::Rounded ? QTabBar::RoundedWest -
588 : QTabBar::TriangularWest); -
589 break;
executed: break;
Execution Count:2
2
590 case QTabWidget::East: -
591 tabs->setShape(shape == QTabWidget::Rounded ? QTabBar::RoundedEast -
592 : QTabBar::TriangularEast); -
593 break;
executed: break;
Execution Count:2
2
594 } -
595 q->setUpLayout(); -
596}
executed: }
Execution Count:9
9
597QTabWidget::TabPosition QTabWidget::tabPosition() const -
598{ -
599 const QTabWidgetPrivate * const d = d_func(); -
600 return d->pos;
executed: return d->pos;
Execution Count:4
4
601} -
602 -
603void QTabWidget::setTabPosition(TabPosition pos) -
604{ -
605 QTabWidgetPrivate * const d = d_func(); -
606 if (d->pos == pos)
evaluated: d->pos == pos
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:6
6-41
607 return;
executed: return;
Execution Count:41
41
608 d->pos = pos; -
609 d->updateTabBarPosition(); -
610}
executed: }
Execution Count:6
6
611bool QTabWidget::tabsClosable() const -
612{ -
613 return tabBar()->tabsClosable();
never executed: return tabBar()->tabsClosable();
0
614} -
615 -
616void QTabWidget::setTabsClosable(bool closeable) -
617{ -
618 if (tabsClosable() == closeable)
never evaluated: tabsClosable() == closeable
0
619 return;
never executed: return;
0
620 -
621 tabBar()->setTabsClosable(closeable); -
622 if (closeable)
never evaluated: closeable
0
623 connect(tabBar(), "2""tabCloseRequested(int)", 0
624 this, "2""tabCloseRequested(int)");
never executed: connect(tabBar(), "2""tabCloseRequested(int)", this, "2""tabCloseRequested(int)");
0
625 else -
626 disconnect(tabBar(), "2""tabCloseRequested(int)", 0
627 this, "2""tabCloseRequested(int)");
never executed: disconnect(tabBar(), "2""tabCloseRequested(int)", this, "2""tabCloseRequested(int)");
0
628 setUpLayout(); -
629}
never executed: }
0
630bool QTabWidget::isMovable() const -
631{ -
632 return tabBar()->isMovable();
never executed: return tabBar()->isMovable();
0
633} -
634 -
635void QTabWidget::setMovable(bool movable) -
636{ -
637 tabBar()->setMovable(movable); -
638}
never executed: }
0
639QTabWidget::TabShape QTabWidget::tabShape() const -
640{ -
641 const QTabWidgetPrivate * const d = d_func(); -
642 return d->shape;
executed: return d->shape;
Execution Count:5
5
643} -
644 -
645void QTabWidget::setTabShape(TabShape s) -
646{ -
647 QTabWidgetPrivate * const d = d_func(); -
648 if (d->shape == s)
evaluated: d->shape == s
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-3
649 return;
executed: return;
Execution Count:2
2
650 d->shape = s; -
651 d->updateTabBarPosition(); -
652}
executed: }
Execution Count:3
3
653 -
654 -
655 -
656 -
657bool QTabWidget::event(QEvent *ev) -
658{ -
659 if (ev->type() == QEvent::LayoutRequest)
evaluated: ev->type() == QEvent::LayoutRequest
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:445
19-445
660 setUpLayout();
executed: setUpLayout();
Execution Count:19
19
661 return QWidget::event(ev);
executed: return QWidget::event(ev);
Execution Count:464
464
662} -
663 -
664 -
665 -
666 -
667void QTabWidget::changeEvent(QEvent *ev) -
668{ -
669 if (ev->type() == QEvent::StyleChange
evaluated: ev->type() == QEvent::StyleChange
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
670 -
671 -
672 -
673 ) -
674 setUpLayout();
executed: setUpLayout();
Execution Count:1
1
675 QWidget::changeEvent(ev); -
676}
executed: }
Execution Count:8
8
677 -
678 -
679 -
680 -
681 -
682void QTabWidget::keyPressEvent(QKeyEvent *e) -
683{ -
684 QTabWidgetPrivate * const d = d_func(); -
685 if (((e->key() == Qt::Key_Tab || e->key() == Qt::Key_Backtab) &&
evaluated: e->key() == Qt::Key_Tab
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:16
partially evaluated: e->key() == Qt::Key_Backtab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
686 count() > 1 && e->modifiers() & Qt::ControlModifier)
partially evaluated: count() > 1
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
partially evaluated: e->modifiers() & Qt::ControlModifier
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
687 -
688 -
689 -
690 ) { -
691 int pageCount = d->tabs->count(); -
692 int page = currentIndex(); -
693 int dx = (e->key() == Qt::Key_Backtab || e->modifiers() & Qt::ShiftModifier) ? -1 : 1;
partially evaluated: e->key() == Qt::Key_Backtab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
evaluated: e->modifiers() & Qt::ShiftModifier
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:6
0-11
694 -
695 -
696 -
697 -
698 for (int pass = 0; pass < pageCount; ++pass) {
evaluated: pass < pageCount
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1
1-15
699 page+=dx; -
700 if (page < 0
evaluated: page < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:13
2-13
701 -
702 -
703 -
704 ) { -
705 page = count() - 1; -
706 } else if (page >= pageCount
executed: }
Execution Count:2
evaluated: page >= pageCount
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:10
2-10
707 -
708 -
709 -
710 ) { -
711 page = 0; -
712 }
executed: }
Execution Count:3
3
713 if (d->tabs->isTabEnabled(page)) {
evaluated: d->tabs->isTabEnabled(page)
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:5
5-10
714 setCurrentIndex(page); -
715 break;
executed: break;
Execution Count:10
10
716 } -
717 }
executed: }
Execution Count:5
5
718 if (!QApplication::focusWidget())
partially evaluated: !QApplication::focusWidget()
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
719 d->tabs->setFocus();
executed: d->tabs->setFocus();
Execution Count:11
11
720 } else {
executed: }
Execution Count:11
11
721 e->ignore(); -
722 }
executed: }
Execution Count:16
16
723} -
724 -
725 -
726 -
727 -
728 -
729QWidget *QTabWidget::widget(int index) const -
730{ -
731 const QTabWidgetPrivate * const d = d_func(); -
732 return d->stack->widget(index);
executed: return d->stack->widget(index);
Execution Count:21
21
733} -
734 -
735 -
736 -
737 -
738 -
739 -
740 -
741int QTabWidget::count() const -
742{ -
743 const QTabWidgetPrivate * const d = d_func(); -
744 return d->tabs->count();
executed: return d->tabs->count();
Execution Count:61
61
745} -
746 -
747 -
748 -
749 -
750 -
751 -
752 -
753void QTabWidget::setTabToolTip(int index, const QString & tip) -
754{ -
755 QTabWidgetPrivate * const d = d_func(); -
756 d->tabs->setTabToolTip(index, tip); -
757}
executed: }
Execution Count:2
2
758 -
759 -
760 -
761 -
762 -
763 -
764 -
765QString QTabWidget::tabToolTip(int index) const -
766{ -
767 const QTabWidgetPrivate * const d = d_func(); -
768 return d->tabs->tabToolTip(index);
executed: return d->tabs->tabToolTip(index);
Execution Count:4
4
769} -
770void QTabWidget::setTabWhatsThis(int index, const QString &text) -
771{ -
772 QTabWidgetPrivate * const d = d_func(); -
773 d->tabs->setTabWhatsThis(index, text); -
774}
never executed: }
0
775 -
776 -
777 -
778 -
779 -
780 -
781 -
782QString QTabWidget::tabWhatsThis(int index) const -
783{ -
784 const QTabWidgetPrivate * const d = d_func(); -
785 return d->tabs->tabWhatsThis(index);
never executed: return d->tabs->tabWhatsThis(index);
0
786} -
787void QTabWidget::tabInserted(int index) -
788{ -
789 (void)index; -
790}
executed: }
Execution Count:52
52
791 -
792 -
793 -
794 -
795 -
796 -
797 -
798void QTabWidget::tabRemoved(int index) -
799{ -
800 (void)index; -
801}
executed: }
Execution Count:21
21
802 -
803 -
804 -
805 -
806 -
807 -
808void QTabWidget::paintEvent(QPaintEvent *) -
809{ -
810 QTabWidgetPrivate * const d = d_func(); -
811 if (documentMode()) {
partially evaluated: documentMode()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38
0-38
812 QStylePainter p(this, tabBar()); -
813 if (QWidget *w = cornerWidget(Qt::TopLeftCorner)) {
never evaluated: QWidget *w = cornerWidget(Qt::TopLeftCorner)
0
814 QStyleOptionTabBarBaseV2 opt; -
815 QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); -
816 opt.rect.moveLeft(w->x() + opt.rect.x()); -
817 opt.rect.moveTop(w->y() + opt.rect.y()); -
818 p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt); -
819 }
never executed: }
0
820 if (QWidget *w = cornerWidget(Qt::TopRightCorner)) {
never evaluated: QWidget *w = cornerWidget(Qt::TopRightCorner)
0
821 QStyleOptionTabBarBaseV2 opt; -
822 QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); -
823 opt.rect.moveLeft(w->x() + opt.rect.x()); -
824 opt.rect.moveTop(w->y() + opt.rect.y()); -
825 p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt); -
826 }
never executed: }
0
827 return;
never executed: return;
0
828 } -
829 QStylePainter p(this); -
830 -
831 QStyleOptionTabWidgetFrameV2 opt; -
832 initStyleOption(&opt); -
833 opt.rect = d->panelRect; -
834 p.drawPrimitive(QStyle::PE_FrameTabWidget, opt); -
835}
executed: }
Execution Count:38
38
836QSize QTabWidget::iconSize() const -
837{ -
838 return d_func()->tabs->iconSize();
never executed: return d_func()->tabs->iconSize();
0
839} -
840 -
841void QTabWidget::setIconSize(const QSize &size) -
842{ -
843 d_func()->tabs->setIconSize(size); -
844}
never executed: }
0
845Qt::TextElideMode QTabWidget::elideMode() const -
846{ -
847 return d_func()->tabs->elideMode();
never executed: return d_func()->tabs->elideMode();
0
848} -
849 -
850void QTabWidget::setElideMode(Qt::TextElideMode mode) -
851{ -
852 d_func()->tabs->setElideMode(mode); -
853}
never executed: }
0
854bool QTabWidget::usesScrollButtons() const -
855{ -
856 return d_func()->tabs->usesScrollButtons();
executed: return d_func()->tabs->usesScrollButtons();
Execution Count:65
65
857} -
858 -
859void QTabWidget::setUsesScrollButtons(bool useButtons) -
860{ -
861 d_func()->tabs->setUsesScrollButtons(useButtons); -
862}
never executed: }
0
863bool QTabWidget::documentMode() const -
864{ -
865 const QTabWidgetPrivate * const d = d_func(); -
866 return d->tabs->documentMode();
executed: return d->tabs->documentMode();
Execution Count:753
753
867} -
868 -
869void QTabWidget::setDocumentMode(bool enabled) -
870{ -
871 QTabWidgetPrivate * const d = d_func(); -
872 d->tabs->setDocumentMode(enabled); -
873 d->tabs->setExpanding(!enabled); -
874 d->tabs->setDrawBase(enabled); -
875 setUpLayout(); -
876}
never executed: }
0
877 -
878 -
879 -
880 -
881 -
882void QTabWidget::clear() -
883{ -
884 -
885 while (count())
evaluated: count()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
886 removeTab(0);
executed: removeTab(0);
Execution Count:5
5
887}
executed: }
Execution Count:1
1
888 -
889 -
890 -
891 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial