qtabwidget.cpp

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

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