qtabwidget.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtabwidget.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qtabwidget.h"-
35-
36#ifndef QT_NO_TABWIDGET-
37#include "private/qwidget_p.h"-
38#include "private/qtabbar_p.h"-
39#include "qapplication.h"-
40#include "qbitmap.h"-
41#include "qdesktopwidget.h"-
42#include "qevent.h"-
43#include "qlayout.h"-
44#include "qstackedwidget.h"-
45#include "qstyle.h"-
46#include "qstyleoption.h"-
47#include "qstylepainter.h"-
48#include "qtabbar.h"-
49#include "qtoolbutton.h"-
50-
51QT_BEGIN_NAMESPACE-
52-
53/*!-
54 \class QTabWidget-
55 \brief The QTabWidget class provides a stack of tabbed widgets.-
56-
57 \ingroup organizers-
58 \ingroup basicwidgets-
59 \inmodule QtWidgets-
60-
61 A tab widget provides a tab bar (see QTabBar) and a "page area"-
62 that is used to display pages related to each tab. By default, the-
63 tab bar is shown above the page area, but different configurations-
64 are available (see \l{TabPosition}). Each tab is associated with a-
65 different widget (called a page). Only the current page is shown in-
66 the page area; all the other pages are hidden. The user can show a-
67 different page by clicking on its tab or by pressing its-
68 Alt+\e{letter} shortcut if it has one.-
69-
70 The normal way to use QTabWidget is to do the following:-
71 \list 1-
72 \li Create a QTabWidget.-
73 \li Create a QWidget for each of the pages in the tab dialog, but-
74 do not specify parent widgets for them.-
75 \li Insert child widgets into the page widget, using layouts to-
76 position them as normal.-
77 \li Call addTab() or insertTab() to put the page widgets into the-
78 tab widget, giving each tab a suitable label with an optional-
79 keyboard shortcut.-
80 \endlist-
81-
82 The position of the tabs is defined by \l tabPosition, their shape-
83 by \l tabShape.-
84-
85 The signal currentChanged() is emitted when the user selects a-
86 page.-
87-
88 The current page index is available as currentIndex(), the current-
89 page widget with currentWidget(). You can retrieve a pointer to a-
90 page widget with a given index using widget(), and can find the-
91 index position of a widget with indexOf(). Use setCurrentWidget()-
92 or setCurrentIndex() to show a particular page.-
93-
94 You can change a tab's text and icon using setTabText() or-
95 setTabIcon(). A tab and its associated page can be removed with-
96 removeTab().-
97-
98 Each tab is either enabled or disabled at any given time (see-
99 setTabEnabled()). If a tab is enabled, the tab text is drawn-
100 normally and the user can select that tab. If it is disabled, the-
101 tab is drawn in a different way and the user cannot select that-
102 tab. Note that even if a tab is disabled, the page can still be-
103 visible, for example if all of the tabs happen to be disabled.-
104-
105 Tab widgets can be a very good way to split up a complex dialog.-
106 An alternative is to use a QStackedWidget for which you provide some-
107 means of navigating between pages, for example, a QToolBar or a-
108 QListWidget.-
109-
110 Most of the functionality in QTabWidget is provided by a QTabBar-
111 (at the top, providing the tabs) and a QStackedWidget (most of the-
112 area, organizing the individual pages).-
113-
114 \table 100%-
115 \row \li \inlineimage windowsvista-tabwidget.png Screenshot of a Windows Vista style tab widget-
116 \li \inlineimage macintosh-tabwidget.png Screenshot of a Macintosh style tab widget-
117 \li \inlineimage fusion-tabwidget.png Screenshot of a Fusion style tab widget-
118 \row \li A Windows Vista style tab widget.-
119 \li A Macintosh style tab widget.-
120 \li A Fusion style tab widget.-
121 \endtable-
122-
123 \sa QTabBar, QStackedWidget, QToolBox, {Tab Dialog Example}-
124*/-
125-
126/*!-
127 \enum QTabWidget::TabPosition-
128-
129 This enum type defines where QTabWidget draws the tab row:-
130-
131 \value North The tabs are drawn above the pages.-
132 \value South The tabs are drawn below the pages.-
133 \value West The tabs are drawn to the left of the pages.-
134 \value East The tabs are drawn to the right of the pages.-
135*/-
136-
137/*!-
138 \enum QTabWidget::TabShape-
139-
140 This enum type defines the shape of the tabs:-
141 \value Rounded The tabs are drawn with a rounded look. This is the default-
142 shape.-
143 \value Triangular The tabs are drawn with a triangular look.-
144*/-
145-
146/*!-
147 \fn void QTabWidget::currentChanged(int index)-
148-
149 This signal is emitted whenever the current page index changes.-
150 The parameter is the new current page \a index position, or -1-
151 if there isn't a new one (for example, if there are no widgets-
152 in the QTabWidget)-
153-
154 \sa currentWidget(), currentIndex-
155*/-
156-
157/*!-
158 \fn void QTabWidget::tabCloseRequested(int index)-
159 \since 4.5-
160-
161 This signal is emitted when the close button on a tab is clicked.-
162 The \a index is the index that should be removed.-
163-
164 \sa setTabsClosable()-
165*/-
166-
167/*!-
168 \fn void QTabWidget::tabBarClicked(int index)-
169-
170 This signal is emitted when user clicks on a tab at an \a index.-
171-
172 \a index refers to the tab clicked, or -1 if no tab is under the cursor.-
173-
174 \since 5.2-
175*/-
176-
177/*!-
178 \fn void QTabWidget::tabBarDoubleClicked(int index)-
179-
180 This signal is emitted when the user double clicks on a tab at an \a index.-
181-
182 \a index is the index of a clicked tab, or -1 if no tab is under the cursor.-
183-
184 \since 5.2-
185*/-
186-
187class QTabWidgetPrivate : public QWidgetPrivate-
188{-
189 Q_DECLARE_PUBLIC(QTabWidget)-
190-
191public:-
192 QTabWidgetPrivate();-
193 ~QTabWidgetPrivate();-
194 void updateTabBarPosition();-
195 void _q_showTab(int);-
196 void _q_removeTab(int);-
197 void _q_tabMoved(int from, int to);-
198 void init();-
199-
200 QTabBar *tabs;-
201 QStackedWidget *stack;-
202 QRect panelRect;-
203 bool dirty;-
204 QTabWidget::TabPosition pos;-
205 QTabWidget::TabShape shape;-
206 int alignment;-
207 QWidget *leftCornerWidget;-
208 QWidget *rightCornerWidget;-
209};-
210-
211QTabWidgetPrivate::QTabWidgetPrivate()-
212 : tabs(0), stack(0), dirty(true),-
213 pos(QTabWidget::North), shape(QTabWidget::Rounded),-
214 leftCornerWidget(0), rightCornerWidget(0)-
215{}
never executed: end of block
0
216-
217QTabWidgetPrivate::~QTabWidgetPrivate()-
218{}-
219-
220void QTabWidgetPrivate::init()-
221{-
222 Q_Q(QTabWidget);-
223-
224 stack = new QStackedWidget(q);-
225 stack->setObjectName(QLatin1String("qt_tabwidget_stackedwidget"));-
226 stack->setLineWidth(0);-
227 // hack so that QMacStyle::layoutSpacing() can detect tab widget pages-
228 stack->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::TabWidget));-
229-
230 QObject::connect(stack, SIGNAL(widgetRemoved(int)), q, SLOT(_q_removeTab(int)));-
231 QTabBar *tabBar = new QTabBar(q);-
232 tabBar->setObjectName(QLatin1String("qt_tabwidget_tabbar"));-
233 tabBar->setDrawBase(false);-
234 q->setTabBar(tabBar);-
235-
236 q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding,-
237 QSizePolicy::TabWidget));-
238#ifdef QT_KEYPAD_NAVIGATION-
239 if (QApplication::keypadNavigationEnabled())-
240 q->setFocusPolicy(Qt::NoFocus);-
241 else-
242#endif-
243 q->setFocusPolicy(Qt::TabFocus);-
244 q->setFocusProxy(tabs);-
245 q->setTabPosition(static_cast<QTabWidget::TabPosition> (q->style()->styleHint(-
246 QStyle::SH_TabWidget_DefaultTabPosition, 0, q )));-
247-
248}
never executed: end of block
0
249-
250/*!-
251 \reimp-
252*/-
253-
254bool QTabWidget::hasHeightForWidth() const-
255{-
256 Q_D(const QTabWidget);-
257 bool has = d->size_policy.hasHeightForWidth();-
258 if (!has && d->stack)
!hasDescription
TRUEnever evaluated
FALSEnever evaluated
d->stackDescription
TRUEnever evaluated
FALSEnever evaluated
0
259 has = d->stack->hasHeightForWidth();
never executed: has = d->stack->hasHeightForWidth();
0
260 return has;
never executed: return has;
0
261}-
262-
263-
264/*!-
265 Initialize \a option with the values from this QTabWidget. This method is useful-
266 for subclasses when they need a QStyleOptionTabWidgetFrame, but don't want to fill-
267 in all the information themselves.-
268-
269 \sa QStyleOption::initFrom(), QTabBar::initStyleOption()-
270*/-
271void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const-
272{-
273 if (!option)
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
0
274 return;
never executed: return;
0
275-
276 Q_D(const QTabWidget);-
277 option->initFrom(this);-
278-
279 if (documentMode())
documentMode()Description
TRUEnever evaluated
FALSEnever evaluated
0
280 option->lineWidth = 0;
never executed: option->lineWidth = 0;
0
281 else-
282 option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this);
never executed: option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this);
0
283-
284 int exth = style()->pixelMetric(QStyle::PM_TabBarBaseHeight, 0, this);-
285 QSize t(0, d->stack->frameWidth());-
286 if (d->tabs->isVisibleTo(const_cast<QTabWidget *>(this))) {
d->tabs->isVis...dget *>(this))Description
TRUEnever evaluated
FALSEnever evaluated
0
287 t = d->tabs->sizeHint();-
288 if (documentMode()) {
documentMode()Description
TRUEnever evaluated
FALSEnever evaluated
0
289 if (tabPosition() == East || tabPosition() == West) {
tabPosition() == EastDescription
TRUEnever evaluated
FALSEnever evaluated
tabPosition() == WestDescription
TRUEnever evaluated
FALSEnever evaluated
0
290 t.setHeight(height());-
291 } else {
never executed: end of block
0
292 t.setWidth(width());-
293 }
never executed: end of block
0
294 }-
295 }
never executed: end of block
0
296-
297 if (d->rightCornerWidget) {
d->rightCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
298 const QSize rightCornerSizeHint = d->rightCornerWidget->sizeHint();-
299 const QSize bounds(rightCornerSizeHint.width(), t.height() - exth);-
300 option->rightCornerWidgetSize = rightCornerSizeHint.boundedTo(bounds);-
301 } else {
never executed: end of block
0
302 option->rightCornerWidgetSize = QSize(0, 0);-
303 }
never executed: end of block
0
304-
305 if (d->leftCornerWidget) {
d->leftCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
306 const QSize leftCornerSizeHint = d->leftCornerWidget->sizeHint();-
307 const QSize bounds(leftCornerSizeHint.width(), t.height() - exth);-
308 option->leftCornerWidgetSize = leftCornerSizeHint.boundedTo(bounds);-
309 } else {
never executed: end of block
0
310 option->leftCornerWidgetSize = QSize(0, 0);-
311 }
never executed: end of block
0
312-
313 switch (d->pos) {-
314 case QTabWidget::North:
never executed: case QTabWidget::North:
0
315 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedNorth
d->shape == QT...idget::RoundedDescription
TRUEnever evaluated
FALSEnever evaluated
0
316 : QTabBar::TriangularNorth;-
317 break;
never executed: break;
0
318 case QTabWidget::South:
never executed: case QTabWidget::South:
0
319 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedSouth
d->shape == QT...idget::RoundedDescription
TRUEnever evaluated
FALSEnever evaluated
0
320 : QTabBar::TriangularSouth;-
321 break;
never executed: break;
0
322 case QTabWidget::West:
never executed: case QTabWidget::West:
0
323 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedWest
d->shape == QT...idget::RoundedDescription
TRUEnever evaluated
FALSEnever evaluated
0
324 : QTabBar::TriangularWest;-
325 break;
never executed: break;
0
326 case QTabWidget::East:
never executed: case QTabWidget::East:
0
327 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedEast
d->shape == QT...idget::RoundedDescription
TRUEnever evaluated
FALSEnever evaluated
0
328 : QTabBar::TriangularEast;-
329 break;
never executed: break;
0
330 }-
331-
332 option->tabBarSize = t;-
333-
334 QRect tbRect = tabBar()->geometry();-
335 QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex());-
336 option->tabBarRect = tbRect;-
337 selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft());-
338 option->selectedTabRect = selectedTabRect;-
339}
never executed: end of block
0
340-
341/*!-
342 Constructs a tabbed widget with parent \a parent.-
343*/-
344QTabWidget::QTabWidget(QWidget *parent)-
345 : QWidget(*new QTabWidgetPrivate, parent, 0)-
346{-
347 Q_D(QTabWidget);-
348 d->init();-
349}
never executed: end of block
0
350-
351-
352/*!-
353 Destroys the tabbed widget.-
354*/-
355QTabWidget::~QTabWidget()-
356{-
357}-
358-
359/*!-
360 \fn int QTabWidget::addTab(QWidget *page, const QString &label)-
361-
362 Adds a tab with the given \a page and \a label to the tab widget,-
363 and returns the index of the tab in the tab bar.-
364-
365 If the tab's \a label contains an ampersand, the letter following-
366 the ampersand is used as a shortcut for the tab, e.g. if the-
367 label is "Bro\&wse" then Alt+W becomes a shortcut which will-
368 move the focus to this tab.-
369-
370 \note If you call addTab() after show(), the layout system will try-
371 to adjust to the changes in its widgets hierarchy and may cause-
372 flicker. To prevent this, you can set the QWidget::updatesEnabled-
373 property to false prior to changes; remember to set the property-
374 to true when the changes are done, making the widget receive paint-
375 events again.-
376-
377 \sa insertTab()-
378*/-
379int QTabWidget::addTab(QWidget *child, const QString &label)-
380{-
381 return insertTab(-1, child, label);
never executed: return insertTab(-1, child, label);
0
382}-
383-
384-
385/*!-
386 \fn int QTabWidget::addTab(QWidget *page, const QIcon &icon, const QString &label)-
387 \overload-
388-
389 Adds a tab with the given \a page, \a icon, and \a label to the tab-
390 widget, and returns the index of the tab in the tab bar.-
391-
392 This function is the same as addTab(), but with an additional \a-
393 icon.-
394*/-
395int QTabWidget::addTab(QWidget *child, const QIcon& icon, const QString &label)-
396{-
397 return insertTab(-1, child, icon, label);
never executed: return insertTab(-1, child, icon, label);
0
398}-
399-
400-
401/*!-
402 \fn int QTabWidget::insertTab(int index, QWidget *page, const QString &label)-
403-
404 Inserts a tab with the given \a label and \a page into the tab-
405 widget at the specified \a index, and returns the index of the-
406 inserted tab in the tab bar.-
407-
408 The label is displayed in the tab and may vary in appearance depending-
409 on the configuration of the tab widget.-
410-
411 If the tab's \a label contains an ampersand, the letter following-
412 the ampersand is used as a shortcut for the tab, e.g. if the-
413 label is "Bro\&wse" then Alt+W becomes a shortcut which will-
414 move the focus to this tab.-
415-
416 If \a index is out of range, the tab is simply appended.-
417 Otherwise it is inserted at the specified position.-
418-
419 If the QTabWidget was empty before this function is called, the-
420 new page becomes the current page. Inserting a new tab at an index-
421 less than or equal to the current index will increment the current-
422 index, but keep the current page.-
423-
424 \note If you call insertTab() after show(), the layout system will try-
425 to adjust to the changes in its widgets hierarchy and may cause-
426 flicker. To prevent this, you can set the QWidget::updatesEnabled-
427 property to false prior to changes; remember to set the property-
428 to true when the changes are done, making the widget receive paint-
429 events again.-
430-
431 \sa addTab()-
432*/-
433int QTabWidget::insertTab(int index, QWidget *w, const QString &label)-
434{-
435 return insertTab(index, w, QIcon(), label);
never executed: return insertTab(index, w, QIcon(), label);
0
436}-
437-
438-
439/*!-
440 \fn int QTabWidget::insertTab(int index, QWidget *page, const QIcon& icon, const QString &label)-
441 \overload-
442-
443 Inserts a tab with the given \a label, \a page, and \a icon into-
444 the tab widget at the specified \a index, and returns the index of the-
445 inserted tab in the tab bar.-
446-
447 This function is the same as insertTab(), but with an additional-
448 \a icon.-
449*/-
450int QTabWidget::insertTab(int index, QWidget *w, const QIcon& icon, const QString &label)-
451{-
452 Q_D(QTabWidget);-
453 if(!w)
!wDescription
TRUEnever evaluated
FALSEnever evaluated
0
454 return -1;
never executed: return -1;
0
455 index = d->stack->insertWidget(index, w);-
456 d->tabs->insertTab(index, icon, label);-
457 setUpLayout();-
458 tabInserted(index);-
459-
460 return index;
never executed: return index;
0
461}-
462-
463-
464/*!-
465 Defines a new \a label for the page at position \a index's tab.-
466-
467 If the provided text contains an ampersand character ('&'), a-
468 shortcut is automatically created for it. The character that-
469 follows the '&' will be used as the shortcut key. Any previous-
470 shortcut will be overwritten, or cleared if no shortcut is defined-
471 by the text. See the \l {QShortcut#mnemonic}{QShortcut}-
472 documentation for details (to display an actual ampersand, use-
473 '&&').-
474-
475*/-
476void QTabWidget::setTabText(int index, const QString &label)-
477{-
478 Q_D(QTabWidget);-
479 d->tabs->setTabText(index, label);-
480 setUpLayout();-
481}
never executed: end of block
0
482-
483/*!-
484 Returns the label text for the tab on the page at position \a index.-
485*/-
486-
487QString QTabWidget::tabText(int index) const-
488{-
489 Q_D(const QTabWidget);-
490 return d->tabs->tabText(index);
never executed: return d->tabs->tabText(index);
0
491}-
492-
493/*!-
494 \overload-
495-
496 Sets the \a icon for the tab at position \a index.-
497*/-
498void QTabWidget::setTabIcon(int index, const QIcon &icon)-
499{-
500 Q_D(QTabWidget);-
501 d->tabs->setTabIcon(index, icon);-
502 setUpLayout();-
503}
never executed: end of block
0
504-
505/*!-
506 Returns the icon for the tab on the page at position \a index.-
507*/-
508-
509QIcon QTabWidget::tabIcon(int index) const-
510{-
511 Q_D(const QTabWidget);-
512 return d->tabs->tabIcon(index);
never executed: return d->tabs->tabIcon(index);
0
513}-
514-
515/*!-
516 Returns \c true if the page at position \a index is enabled; otherwise returns \c false.-
517-
518 \sa setTabEnabled(), QWidget::isEnabled()-
519*/-
520-
521bool QTabWidget::isTabEnabled(int index) const-
522{-
523 Q_D(const QTabWidget);-
524 return d->tabs->isTabEnabled(index);
never executed: return d->tabs->isTabEnabled(index);
0
525}-
526-
527/*!-
528 If \a enable is true, the page at position \a index is enabled; otherwise the page at position \a index is-
529 disabled. The page's tab is redrawn appropriately.-
530-
531 QTabWidget uses QWidget::setEnabled() internally, rather than-
532 keeping a separate flag.-
533-
534 Note that even a disabled tab/page may be visible. If the page is-
535 visible already, QTabWidget will not hide it; if all the pages are-
536 disabled, QTabWidget will show one of them.-
537-
538 \sa isTabEnabled(), QWidget::setEnabled()-
539*/-
540-
541void QTabWidget::setTabEnabled(int index, bool enable)-
542{-
543 Q_D(QTabWidget);-
544 d->tabs->setTabEnabled(index, enable);-
545 if (QWidget *widget = d->stack->widget(index))
QWidget *widge...>widget(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
546 widget->setEnabled(enable);
never executed: widget->setEnabled(enable);
0
547}
never executed: end of block
0
548-
549/*!-
550 \fn void QTabWidget::setCornerWidget(QWidget *widget, Qt::Corner corner)-
551-
552 Sets the given \a widget to be shown in the specified \a corner of the-
553 tab widget. The geometry of the widget is determined based on the widget's-
554 sizeHint() and the style().-
555-
556 Only the horizontal element of the \a corner will be used.-
557-
558 Passing 0 shows no widget in the corner.-
559-
560 Any previously set corner widget is hidden.-
561-
562 All widgets set here will be deleted by the tab widget when it is-
563 destroyed unless you separately reparent the widget after setting-
564 some other corner widget (or 0).-
565-
566 Note: Corner widgets are designed for \l North and \l South tab positions;-
567 other orientations are known to not work properly.-
568-
569 \sa cornerWidget(), setTabPosition()-
570*/-
571void QTabWidget::setCornerWidget(QWidget * widget, Qt::Corner corner)-
572{-
573 Q_D(QTabWidget);-
574 if (widget && widget->parentWidget() != this)
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
widget->parentWidget() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
575 widget->setParent(this);
never executed: widget->setParent(this);
0
576-
577 if (corner & Qt::TopRightCorner) {
corner & Qt::TopRightCornerDescription
TRUEnever evaluated
FALSEnever evaluated
0
578 if (d->rightCornerWidget)
d->rightCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
579 d->rightCornerWidget->hide();
never executed: d->rightCornerWidget->hide();
0
580 d->rightCornerWidget = widget;-
581 } else {
never executed: end of block
0
582 if (d->leftCornerWidget)
d->leftCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
583 d->leftCornerWidget->hide();
never executed: d->leftCornerWidget->hide();
0
584 d->leftCornerWidget = widget;-
585 }
never executed: end of block
0
586 setUpLayout();-
587}
never executed: end of block
0
588-
589/*!-
590 Returns the widget shown in the \a corner of the tab widget or 0.-
591*/-
592QWidget * QTabWidget::cornerWidget(Qt::Corner corner) const-
593{-
594 Q_D(const QTabWidget);-
595 if (corner & Qt::TopRightCorner)
corner & Qt::TopRightCornerDescription
TRUEnever evaluated
FALSEnever evaluated
0
596 return d->rightCornerWidget;
never executed: return d->rightCornerWidget;
0
597 return d->leftCornerWidget;
never executed: return d->leftCornerWidget;
0
598}-
599-
600/*!-
601 Removes the tab at position \a index from this stack of widgets.-
602 The page widget itself is not deleted.-
603-
604 \sa addTab(), insertTab()-
605*/-
606void QTabWidget::removeTab(int index)-
607{-
608 Q_D(QTabWidget);-
609 if (QWidget *w = d->stack->widget(index))
QWidget *w = d...>widget(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
610 d->stack->removeWidget(w);
never executed: d->stack->removeWidget(w);
0
611}
never executed: end of block
0
612-
613/*!-
614 Returns a pointer to the page currently being displayed by the tab-
615 dialog. The tab dialog does its best to make sure that this value-
616 is never 0 (but if you try hard enough, it can be).-
617-
618 \sa currentIndex(), setCurrentWidget()-
619*/-
620-
621QWidget * QTabWidget::currentWidget() const-
622{-
623 Q_D(const QTabWidget);-
624 return d->stack->currentWidget();
never executed: return d->stack->currentWidget();
0
625}-
626-
627/*!-
628 Makes \a widget the current widget. The \a widget used must be a page in-
629 this tab widget.-
630-
631 \sa addTab(), setCurrentIndex(), currentWidget()-
632 */-
633void QTabWidget::setCurrentWidget(QWidget *widget)-
634{-
635 Q_D(const QTabWidget);-
636 d->tabs->setCurrentIndex(indexOf(widget));-
637}
never executed: end of block
0
638-
639-
640/*!-
641 \property QTabWidget::currentIndex-
642 \brief the index position of the current tab page-
643-
644 The current index is -1 if there is no current widget.-
645-
646 By default, this property contains a value of -1 because there are initially-
647 no tabs in the widget.-
648*/-
649-
650int QTabWidget::currentIndex() const-
651{-
652 Q_D(const QTabWidget);-
653 return d->tabs->currentIndex();
never executed: return d->tabs->currentIndex();
0
654}-
655-
656void QTabWidget::setCurrentIndex(int index)-
657{-
658 Q_D(QTabWidget);-
659 d->tabs->setCurrentIndex(index);-
660}
never executed: end of block
0
661-
662-
663/*!-
664 Returns the index position of the page occupied by the widget \a-
665 w, or -1 if the widget cannot be found.-
666*/-
667int QTabWidget::indexOf(QWidget* w) const-
668{-
669 Q_D(const QTabWidget);-
670 return d->stack->indexOf(w);
never executed: return d->stack->indexOf(w);
0
671}-
672-
673-
674/*!-
675 \reimp-
676*/-
677void QTabWidget::resizeEvent(QResizeEvent *e)-
678{-
679 QWidget::resizeEvent(e);-
680 setUpLayout();-
681}
never executed: end of block
0
682-
683/*!-
684 Replaces the dialog's QTabBar heading with the tab bar \a tb. Note-
685 that this must be called \e before any tabs have been added, or-
686 the behavior is undefined.-
687-
688 \sa tabBar()-
689*/-
690void QTabWidget::setTabBar(QTabBar* tb)-
691{-
692 Q_D(QTabWidget);-
693 Q_ASSERT(tb);-
694-
695 if (tb->parentWidget() != this) {
tb->parentWidget() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
696 tb->setParent(this);-
697 tb->show();-
698 }
never executed: end of block
0
699 delete d->tabs;-
700 d->tabs = tb;-
701 setFocusProxy(d->tabs);-
702 connect(d->tabs, SIGNAL(currentChanged(int)),-
703 this, SLOT(_q_showTab(int)));-
704 connect(d->tabs, SIGNAL(tabMoved(int,int)),-
705 this, SLOT(_q_tabMoved(int,int)));-
706 connect(d->tabs, SIGNAL(tabBarClicked(int)),-
707 this, SIGNAL(tabBarClicked(int)));-
708 connect(d->tabs, SIGNAL(tabBarDoubleClicked(int)),-
709 this, SIGNAL(tabBarDoubleClicked(int)));-
710 if (d->tabs->tabsClosable())
d->tabs->tabsClosable()Description
TRUEnever evaluated
FALSEnever evaluated
0
711 connect(d->tabs, SIGNAL(tabCloseRequested(int)),
never executed: connect(d->tabs, qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "711"), this, qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "712"));
0
712 this, SIGNAL(tabCloseRequested(int)));
never executed: connect(d->tabs, qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "711"), this, qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "712"));
0
713 tb->setExpanding(!documentMode());-
714 setUpLayout();-
715}
never executed: end of block
0
716-
717-
718/*!-
719 Returns the current QTabBar.-
720-
721 \sa setTabBar()-
722*/-
723QTabBar* QTabWidget::tabBar() const-
724{-
725 Q_D(const QTabWidget);-
726 return d->tabs;
never executed: return d->tabs;
0
727}-
728-
729/*!-
730 Ensures that the selected tab's page is visible and appropriately-
731 sized.-
732*/-
733-
734void QTabWidgetPrivate::_q_showTab(int index)-
735{-
736 Q_Q(QTabWidget);-
737 if (index < stack->count() && index >= 0)
index < stack->count()Description
TRUEnever evaluated
FALSEnever evaluated
index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
738 stack->setCurrentIndex(index);
never executed: stack->setCurrentIndex(index);
0
739 emit q->currentChanged(index);-
740}
never executed: end of block
0
741-
742void QTabWidgetPrivate::_q_removeTab(int index)-
743{-
744 Q_Q(QTabWidget);-
745 tabs->removeTab(index);-
746 q->setUpLayout();-
747 q->tabRemoved(index);-
748}
never executed: end of block
0
749-
750void QTabWidgetPrivate::_q_tabMoved(int from, int to)-
751{-
752 const QSignalBlocker blocker(stack);-
753 QWidget *w = stack->widget(from);-
754 stack->removeWidget(w);-
755 stack->insertWidget(to, w);-
756}
never executed: end of block
0
757-
758/*-
759 Set up the layout.-
760 Get subrect from the current style, and set the geometry for the-
761 stack widget, tab bar and corner widgets.-
762*/-
763void QTabWidget::setUpLayout(bool onlyCheck)-
764{-
765 Q_D(QTabWidget);-
766 if (onlyCheck && !d->dirty)
onlyCheckDescription
TRUEnever evaluated
FALSEnever evaluated
!d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
767 return; // nothing to do
never executed: return;
0
768-
769 QStyleOptionTabWidgetFrame option;-
770 initStyleOption(&option);-
771-
772 // this must be done immediately, because QWidgetItem relies on it (even if !isVisible())-
773 d->setLayoutItemMargins(QStyle::SE_TabWidgetLayoutItem, &option);-
774-
775 if (!isVisible()) {
!isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
776 d->dirty = true;-
777 return; // we'll do it later
never executed: return;
0
778 }-
779-
780 QRect tabRect = style()->subElementRect(QStyle::SE_TabWidgetTabBar, &option, this);-
781 d->panelRect = style()->subElementRect(QStyle::SE_TabWidgetTabPane, &option, this);-
782 QRect contentsRect = style()->subElementRect(QStyle::SE_TabWidgetTabContents, &option, this);-
783 QRect leftCornerRect = style()->subElementRect(QStyle::SE_TabWidgetLeftCorner, &option, this);-
784 QRect rightCornerRect = style()->subElementRect(QStyle::SE_TabWidgetRightCorner, &option, this);-
785-
786 d->tabs->setGeometry(tabRect);-
787 d->stack->setGeometry(contentsRect);-
788 if (d->leftCornerWidget)
d->leftCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
789 d->leftCornerWidget->setGeometry(leftCornerRect);
never executed: d->leftCornerWidget->setGeometry(leftCornerRect);
0
790 if (d->rightCornerWidget)
d->rightCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
791 d->rightCornerWidget->setGeometry(rightCornerRect);
never executed: d->rightCornerWidget->setGeometry(rightCornerRect);
0
792-
793 if (!onlyCheck)
!onlyCheckDescription
TRUEnever evaluated
FALSEnever evaluated
0
794 update();
never executed: update();
0
795 updateGeometry();-
796}
never executed: end of block
0
797-
798/*!-
799 \internal-
800*/-
801static inline QSize basicSize(-
802 bool horizontal, const QSize &lc, const QSize &rc, const QSize &s, const QSize &t)-
803{-
804 return 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()));
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
805 ? 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
806 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
807 : 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
808 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
809}-
810-
811/*!-
812 \reimp-
813*/-
814QSize QTabWidget::sizeHint() const-
815{-
816 Q_D(const QTabWidget);-
817 QSize lc(0, 0), rc(0, 0);-
818 QStyleOptionTabWidgetFrame opt;-
819 initStyleOption(&opt);-
820 opt.state = QStyle::State_None;-
821-
822 if (d->leftCornerWidget)
d->leftCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
823 lc = d->leftCornerWidget->sizeHint();
never executed: lc = d->leftCornerWidget->sizeHint();
0
824 if(d->rightCornerWidget)
d->rightCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
825 rc = d->rightCornerWidget->sizeHint();
never executed: rc = d->rightCornerWidget->sizeHint();
0
826 if (!d->dirty) {
!d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
827 QTabWidget *that = const_cast<QTabWidget*>(this);-
828 that->setUpLayout(true);-
829 }
never executed: end of block
0
830 QSize s(d->stack->sizeHint());-
831 QSize t(d->tabs->sizeHint());-
832 if(usesScrollButtons())
usesScrollButtons()Description
TRUEnever evaluated
FALSEnever evaluated
0
833 t = t.boundedTo(QSize(200,200));
never executed: t = t.boundedTo(QSize(200,200));
0
834 else-
835 t = t.boundedTo(QApplication::desktop()->size());
never executed: t = t.boundedTo(QApplication::desktop()->size());
0
836-
837 QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t);-
838-
839 return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this)
never executed: return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) .expandedTo(QApplication::globalStrut());
0
840 .expandedTo(QApplication::globalStrut());
never executed: return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) .expandedTo(QApplication::globalStrut());
0
841}-
842-
843-
844/*!-
845 \reimp-
846-
847 Returns a suitable minimum size for the tab widget.-
848*/-
849QSize QTabWidget::minimumSizeHint() const-
850{-
851 Q_D(const QTabWidget);-
852 QSize lc(0, 0), rc(0, 0);-
853-
854 if(d->leftCornerWidget)
d->leftCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
855 lc = d->leftCornerWidget->minimumSizeHint();
never executed: lc = d->leftCornerWidget->minimumSizeHint();
0
856 if(d->rightCornerWidget)
d->rightCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
857 rc = d->rightCornerWidget->minimumSizeHint();
never executed: rc = d->rightCornerWidget->minimumSizeHint();
0
858 if (!d->dirty) {
!d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
859 QTabWidget *that = const_cast<QTabWidget*>(this);-
860 that->setUpLayout(true);-
861 }
never executed: end of block
0
862 QSize s(d->stack->minimumSizeHint());-
863 QSize t(d->tabs->minimumSizeHint());-
864-
865 QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t);-
866-
867 QStyleOptionTabWidgetFrame opt;-
868 initStyleOption(&opt);-
869 opt.palette = palette();-
870 opt.state = QStyle::State_None;-
871 return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this)
never executed: return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) .expandedTo(QApplication::globalStrut());
0
872 .expandedTo(QApplication::globalStrut());
never executed: return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) .expandedTo(QApplication::globalStrut());
0
873}-
874-
875/*!-
876 \reimp-
877*/-
878int QTabWidget::heightForWidth(int width) const-
879{-
880 Q_D(const QTabWidget);-
881 QStyleOptionTabWidgetFrame opt;-
882 initStyleOption(&opt);-
883 opt.state = QStyle::State_None;-
884-
885 QSize zero(0,0);-
886 const QSize padding = style()->sizeFromContents(QStyle::CT_TabWidget, &opt, zero, this)-
887 .expandedTo(QApplication::globalStrut());-
888-
889 QSize lc(0, 0), rc(0, 0);-
890 if (d->leftCornerWidget)
d->leftCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
891 lc = d->leftCornerWidget->sizeHint();
never executed: lc = d->leftCornerWidget->sizeHint();
0
892 if(d->rightCornerWidget)
d->rightCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
893 rc = d->rightCornerWidget->sizeHint();
never executed: rc = d->rightCornerWidget->sizeHint();
0
894 if (!d->dirty) {
!d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
895 QTabWidget *that = const_cast<QTabWidget*>(this);-
896 that->setUpLayout(true);-
897 }
never executed: end of block
0
898 QSize t(d->tabs->sizeHint());-
899-
900 if(usesScrollButtons())
usesScrollButtons()Description
TRUEnever evaluated
FALSEnever evaluated
0
901 t = t.boundedTo(QSize(200,200));
never executed: t = t.boundedTo(QSize(200,200));
0
902 else-
903 t = t.boundedTo(QApplication::desktop()->size());
never executed: t = t.boundedTo(QApplication::desktop()->size());
0
904-
905 const bool tabIsHorizontal = (d->pos == North || d->pos == South);
d->pos == NorthDescription
TRUEnever evaluated
FALSEnever evaluated
d->pos == SouthDescription
TRUEnever evaluated
FALSEnever evaluated
0
906 const int contentsWidth = width - padding.width();-
907 int stackWidth = contentsWidth;-
908 if (!tabIsHorizontal)
!tabIsHorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
909 stackWidth -= qMax(t.width(), qMax(lc.width(), rc.width()));
never executed: stackWidth -= qMax(t.width(), qMax(lc.width(), rc.width()));
0
910-
911 int stackHeight = d->stack->heightForWidth(stackWidth);-
912 QSize s(stackWidth, stackHeight);-
913-
914 QSize contentSize = basicSize(tabIsHorizontal, lc, rc, s, t);-
915 return (contentSize + padding).expandedTo(QApplication::globalStrut()).height();
never executed: return (contentSize + padding).expandedTo(QApplication::globalStrut()).height();
0
916}-
917-
918-
919/*!-
920 \reimp-
921 */-
922void QTabWidget::showEvent(QShowEvent *)-
923{-
924 setUpLayout();-
925}
never executed: end of block
0
926-
927void QTabWidgetPrivate::updateTabBarPosition()-
928{-
929 Q_Q(QTabWidget);-
930 switch (pos) {-
931 case QTabWidget::North:
never executed: case QTabWidget::North:
0
932 tabs->setShape(shape == QTabWidget::Rounded ? QTabBar::RoundedNorth-
933 : QTabBar::TriangularNorth);-
934 break;
never executed: break;
0
935 case QTabWidget::South:
never executed: case QTabWidget::South:
0
936 tabs->setShape(shape == QTabWidget::Rounded ? QTabBar::RoundedSouth-
937 : QTabBar::TriangularSouth);-
938 break;
never executed: break;
0
939 case QTabWidget::West:
never executed: case QTabWidget::West:
0
940 tabs->setShape(shape == QTabWidget::Rounded ? QTabBar::RoundedWest-
941 : QTabBar::TriangularWest);-
942 break;
never executed: break;
0
943 case QTabWidget::East:
never executed: case QTabWidget::East:
0
944 tabs->setShape(shape == QTabWidget::Rounded ? QTabBar::RoundedEast-
945 : QTabBar::TriangularEast);-
946 break;
never executed: break;
0
947 }-
948 q->setUpLayout();-
949}
never executed: end of block
0
950-
951/*!-
952 \property QTabWidget::tabPosition-
953 \brief the position of the tabs in this tab widget-
954-
955 Possible values for this property are described by the TabPosition-
956 enum.-
957-
958 By default, this property is set to \l North.-
959-
960 \sa TabPosition-
961*/-
962QTabWidget::TabPosition QTabWidget::tabPosition() const-
963{-
964 Q_D(const QTabWidget);-
965 return d->pos;
never executed: return d->pos;
0
966}-
967-
968void QTabWidget::setTabPosition(TabPosition pos)-
969{-
970 Q_D(QTabWidget);-
971 if (d->pos == pos)
d->pos == posDescription
TRUEnever evaluated
FALSEnever evaluated
0
972 return;
never executed: return;
0
973 d->pos = pos;-
974 d->updateTabBarPosition();-
975}
never executed: end of block
0
976-
977/*!-
978 \property QTabWidget::tabsClosable-
979 \brief whether close buttons are automatically added to each tab.-
980-
981 \since 4.5-
982-
983 \sa QTabBar::tabsClosable()-
984*/-
985bool QTabWidget::tabsClosable() const-
986{-
987 return tabBar()->tabsClosable();
never executed: return tabBar()->tabsClosable();
0
988}-
989-
990void QTabWidget::setTabsClosable(bool closeable)-
991{-
992 if (tabsClosable() == closeable)
tabsClosable() == closeableDescription
TRUEnever evaluated
FALSEnever evaluated
0
993 return;
never executed: return;
0
994-
995 tabBar()->setTabsClosable(closeable);-
996 if (closeable)
closeableDescription
TRUEnever evaluated
FALSEnever evaluated
0
997 connect(tabBar(), SIGNAL(tabCloseRequested(int)),
never executed: connect(tabBar(), qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "997"), this, qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "998"));
0
998 this, SIGNAL(tabCloseRequested(int)));
never executed: connect(tabBar(), qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "997"), this, qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "998"));
0
999 else-
1000 disconnect(tabBar(), SIGNAL(tabCloseRequested(int)),
never executed: disconnect(tabBar(), qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "1000"), this, qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "1001"));
0
1001 this, SIGNAL(tabCloseRequested(int)));
never executed: disconnect(tabBar(), qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "1000"), this, qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "1001"));
0
1002 setUpLayout();-
1003}
never executed: end of block
0
1004-
1005/*!-
1006 \property QTabWidget::movable-
1007 \brief This property holds whether the user can move the tabs-
1008 within the tabbar area.-
1009-
1010 \since 4.5-
1011-
1012 By default, this property is \c false;-
1013*/-
1014-
1015bool QTabWidget::isMovable() const-
1016{-
1017 return tabBar()->isMovable();
never executed: return tabBar()->isMovable();
0
1018}-
1019-
1020void QTabWidget::setMovable(bool movable)-
1021{-
1022 tabBar()->setMovable(movable);-
1023}
never executed: end of block
0
1024-
1025/*!-
1026 \property QTabWidget::tabShape-
1027 \brief the shape of the tabs in this tab widget-
1028-
1029 Possible values for this property are QTabWidget::Rounded-
1030 (default) or QTabWidget::Triangular.-
1031-
1032 \sa TabShape-
1033*/-
1034-
1035QTabWidget::TabShape QTabWidget::tabShape() const-
1036{-
1037 Q_D(const QTabWidget);-
1038 return d->shape;
never executed: return d->shape;
0
1039}-
1040-
1041void QTabWidget::setTabShape(TabShape s)-
1042{-
1043 Q_D(QTabWidget);-
1044 if (d->shape == s)
d->shape == sDescription
TRUEnever evaluated
FALSEnever evaluated
0
1045 return;
never executed: return;
0
1046 d->shape = s;-
1047 d->updateTabBarPosition();-
1048}
never executed: end of block
0
1049-
1050/*!-
1051 \reimp-
1052 */-
1053bool QTabWidget::event(QEvent *ev)-
1054{-
1055 if (ev->type() == QEvent::LayoutRequest)
ev->type() == ...:LayoutRequestDescription
TRUEnever evaluated
FALSEnever evaluated
0
1056 setUpLayout();
never executed: setUpLayout();
0
1057 return QWidget::event(ev);
never executed: return QWidget::event(ev);
0
1058}-
1059-
1060/*!-
1061 \reimp-
1062 */-
1063void QTabWidget::changeEvent(QEvent *ev)-
1064{-
1065 if (ev->type() == QEvent::StyleChange
ev->type() == ...t::StyleChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1066#ifdef Q_OS_MAC-
1067 || ev->type() == QEvent::MacSizeChange-
1068#endif-
1069 )-
1070 setUpLayout();
never executed: setUpLayout();
0
1071 QWidget::changeEvent(ev);-
1072}
never executed: end of block
0
1073-
1074-
1075/*!-
1076 \reimp-
1077 */-
1078void QTabWidget::keyPressEvent(QKeyEvent *e)-
1079{-
1080 Q_D(QTabWidget);-
1081 if (((e->key() == Qt::Key_Tab || e->key() == Qt::Key_Backtab) &&
e->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
e->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
1082 count() > 1 && e->modifiers() & Qt::ControlModifier)
count() > 1Description
TRUEnever evaluated
FALSEnever evaluated
e->modifiers()...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
1083#ifdef QT_KEYPAD_NAVIGATION-
1084 || QApplication::keypadNavigationEnabled() && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right) && count() > 1-
1085#endif-
1086 ) {-
1087 int pageCount = d->tabs->count();-
1088 int page = currentIndex();-
1089 int dx = (e->key() == Qt::Key_Backtab || e->modifiers() & Qt::ShiftModifier) ? -1 : 1;
e->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
e->modifiers()...:ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
1090#ifdef QT_KEYPAD_NAVIGATION-
1091 if (QApplication::keypadNavigationEnabled() && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right))-
1092 dx = e->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1;-
1093#endif-
1094 for (int pass = 0; pass < pageCount; ++pass) {
pass < pageCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1095 page+=dx;-
1096 if (page < 0
page < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1097#ifdef QT_KEYPAD_NAVIGATION-
1098 && !e->isAutoRepeat()-
1099#endif-
1100 ) {-
1101 page = count() - 1;-
1102 } else if (page >= pageCount
never executed: end of block
page >= pageCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1103#ifdef QT_KEYPAD_NAVIGATION-
1104 && !e->isAutoRepeat()-
1105#endif-
1106 ) {-
1107 page = 0;-
1108 }
never executed: end of block
0
1109 if (d->tabs->isTabEnabled(page)) {
d->tabs->isTabEnabled(page)Description
TRUEnever evaluated
FALSEnever evaluated
0
1110 setCurrentIndex(page);-
1111 break;
never executed: break;
0
1112 }-
1113 }
never executed: end of block
0
1114 if (!QApplication::focusWidget())
!QApplication::focusWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1115 d->tabs->setFocus();
never executed: d->tabs->setFocus();
0
1116 } else {
never executed: end of block
0
1117 e->ignore();-
1118 }
never executed: end of block
0
1119}-
1120-
1121/*!-
1122 Returns the tab page at index position \a index or 0 if the \a-
1123 index is out of range.-
1124*/-
1125QWidget *QTabWidget::widget(int index) const-
1126{-
1127 Q_D(const QTabWidget);-
1128 return d->stack->widget(index);
never executed: return d->stack->widget(index);
0
1129}-
1130-
1131/*!-
1132 \property QTabWidget::count-
1133 \brief the number of tabs in the tab bar-
1134-
1135 By default, this property contains a value of 0.-
1136*/-
1137int QTabWidget::count() const-
1138{-
1139 Q_D(const QTabWidget);-
1140 return d->tabs->count();
never executed: return d->tabs->count();
0
1141}-
1142-
1143#ifndef QT_NO_TOOLTIP-
1144/*!-
1145 Sets the tab tool tip for the page at position \a index to \a tip.-
1146-
1147 \sa tabToolTip()-
1148*/-
1149void QTabWidget::setTabToolTip(int index, const QString & tip)-
1150{-
1151 Q_D(QTabWidget);-
1152 d->tabs->setTabToolTip(index, tip);-
1153}
never executed: end of block
0
1154-
1155/*!-
1156 Returns the tab tool tip for the page at position \a index or-
1157 an empty string if no tool tip has been set.-
1158-
1159 \sa setTabToolTip()-
1160*/-
1161QString QTabWidget::tabToolTip(int index) const-
1162{-
1163 Q_D(const QTabWidget);-
1164 return d->tabs->tabToolTip(index);
never executed: return d->tabs->tabToolTip(index);
0
1165}-
1166#endif // QT_NO_TOOLTIP-
1167-
1168#ifndef QT_NO_WHATSTHIS-
1169/*!-
1170 \since 4.1-
1171-
1172 Sets the What's This help text for the page at position \a index-
1173 to \a text.-
1174*/-
1175void QTabWidget::setTabWhatsThis(int index, const QString &text)-
1176{-
1177 Q_D(QTabWidget);-
1178 d->tabs->setTabWhatsThis(index, text);-
1179}
never executed: end of block
0
1180-
1181/*!-
1182 \since 4.1-
1183-
1184 Returns the What's This help text for the page at position \a index,-
1185 or an empty string if no help text has been set.-
1186*/-
1187QString QTabWidget::tabWhatsThis(int index) const-
1188{-
1189 Q_D(const QTabWidget);-
1190 return d->tabs->tabWhatsThis(index);
never executed: return d->tabs->tabWhatsThis(index);
0
1191}-
1192#endif // QT_NO_WHATSTHIS-
1193-
1194/*!-
1195 This virtual handler is called after a new tab was added or-
1196 inserted at position \a index.-
1197-
1198 \sa tabRemoved()-
1199 */-
1200void QTabWidget::tabInserted(int index)-
1201{-
1202 Q_UNUSED(index)-
1203}
never executed: end of block
0
1204-
1205/*!-
1206 This virtual handler is called after a tab was removed from-
1207 position \a index.-
1208-
1209 \sa tabInserted()-
1210 */-
1211void QTabWidget::tabRemoved(int index)-
1212{-
1213 Q_UNUSED(index)-
1214}
never executed: end of block
0
1215-
1216/*!-
1217 \fn void QTabWidget::paintEvent(QPaintEvent *event)-
1218-
1219 Paints the tab widget's tab bar in response to the paint \a event.-
1220*/-
1221void QTabWidget::paintEvent(QPaintEvent *)-
1222{-
1223 Q_D(QTabWidget);-
1224 if (documentMode()) {
documentMode()Description
TRUEnever evaluated
FALSEnever evaluated
0
1225 QStylePainter p(this, tabBar());-
1226 if (QWidget *w = cornerWidget(Qt::TopLeftCorner)) {
QWidget *w = c...TopLeftCorner)Description
TRUEnever evaluated
FALSEnever evaluated
0
1227 QStyleOptionTabBarBase opt;-
1228 QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size());-
1229 opt.rect.moveLeft(w->x() + opt.rect.x());-
1230 opt.rect.moveTop(w->y() + opt.rect.y());-
1231 p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt);-
1232 }
never executed: end of block
0
1233 if (QWidget *w = cornerWidget(Qt::TopRightCorner)) {
QWidget *w = c...opRightCorner)Description
TRUEnever evaluated
FALSEnever evaluated
0
1234 QStyleOptionTabBarBase opt;-
1235 QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size());-
1236 opt.rect.moveLeft(w->x() + opt.rect.x());-
1237 opt.rect.moveTop(w->y() + opt.rect.y());-
1238 p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt);-
1239 }
never executed: end of block
0
1240 return;
never executed: return;
0
1241 }-
1242 QStylePainter p(this);-
1243-
1244 QStyleOptionTabWidgetFrame opt;-
1245 initStyleOption(&opt);-
1246 opt.rect = d->panelRect;-
1247 p.drawPrimitive(QStyle::PE_FrameTabWidget, opt);-
1248}
never executed: end of block
0
1249-
1250/*!-
1251 \property QTabWidget::iconSize-
1252 \brief The size for icons in the tab bar-
1253 \since 4.2-
1254-
1255 The default value is style-dependent. This is the maximum size-
1256 that the icons will have. Icons are not scaled up if they are of-
1257 smaller size.-
1258-
1259 \sa QTabBar::iconSize-
1260*/-
1261QSize QTabWidget::iconSize() const-
1262{-
1263 return d_func()->tabs->iconSize();
never executed: return d_func()->tabs->iconSize();
0
1264}-
1265-
1266void QTabWidget::setIconSize(const QSize &size)-
1267{-
1268 d_func()->tabs->setIconSize(size);-
1269}
never executed: end of block
0
1270-
1271/*!-
1272 \property QTabWidget::elideMode-
1273 \brief how to elide text in the tab bar-
1274 \since 4.2-
1275-
1276 This property controls how items are elided when there is not-
1277 enough space to show them for a given tab bar size.-
1278-
1279 By default the value is style dependant.-
1280-
1281 \sa QTabBar::elideMode, usesScrollButtons, QStyle::SH_TabBar_ElideMode-
1282*/-
1283Qt::TextElideMode QTabWidget::elideMode() const-
1284{-
1285 return d_func()->tabs->elideMode();
never executed: return d_func()->tabs->elideMode();
0
1286}-
1287-
1288void QTabWidget::setElideMode(Qt::TextElideMode mode)-
1289{-
1290 d_func()->tabs->setElideMode(mode);-
1291}
never executed: end of block
0
1292-
1293/*!-
1294 \property QTabWidget::usesScrollButtons-
1295 \brief Whether or not a tab bar should use buttons to scroll tabs when it-
1296 has many tabs.-
1297 \since 4.2-
1298-
1299 When there are too many tabs in a tab bar for its size, the tab bar can either choose-
1300 to expand its size or to add buttons that allow you to scroll through the tabs.-
1301-
1302 By default the value is style dependant.-
1303-
1304 \sa elideMode, QTabBar::usesScrollButtons, QStyle::SH_TabBar_PreferNoArrows-
1305*/-
1306bool QTabWidget::usesScrollButtons() const-
1307{-
1308 return d_func()->tabs->usesScrollButtons();
never executed: return d_func()->tabs->usesScrollButtons();
0
1309}-
1310-
1311void QTabWidget::setUsesScrollButtons(bool useButtons)-
1312{-
1313 d_func()->tabs->setUsesScrollButtons(useButtons);-
1314}
never executed: end of block
0
1315-
1316/*!-
1317 \property QTabWidget::documentMode-
1318 \brief Whether or not the tab widget is rendered in a mode suitable for document-
1319 pages. This is the same as document mode on \macos.-
1320 \since 4.5-
1321-
1322 When this property is set the tab widget frame is not rendered. This mode is useful-
1323 for showing document-type pages where the page covers most of the tab widget-
1324 area.-
1325-
1326 \sa elideMode, QTabBar::documentMode, QTabBar::usesScrollButtons, QStyle::SH_TabBar_PreferNoArrows-
1327*/-
1328bool QTabWidget::documentMode() const-
1329{-
1330 Q_D(const QTabWidget);-
1331 return d->tabs->documentMode();
never executed: return d->tabs->documentMode();
0
1332}-
1333-
1334void QTabWidget::setDocumentMode(bool enabled)-
1335{-
1336 Q_D(QTabWidget);-
1337 d->tabs->setDocumentMode(enabled);-
1338 d->tabs->setExpanding(!enabled);-
1339 d->tabs->setDrawBase(enabled);-
1340 setUpLayout();-
1341}
never executed: end of block
0
1342-
1343/*!-
1344 \property QTabWidget::tabBarAutoHide-
1345 \brief If true, the tab bar is automatically hidden when it contains less-
1346 than 2 tabs.-
1347 \since 5.4-
1348-
1349 By default, this property is false.-
1350-
1351 \sa QWidget::visible-
1352*/-
1353-
1354bool QTabWidget::tabBarAutoHide() const-
1355{-
1356 Q_D(const QTabWidget);-
1357 return d->tabs->autoHide();
never executed: return d->tabs->autoHide();
0
1358}-
1359-
1360void QTabWidget::setTabBarAutoHide(bool enabled)-
1361{-
1362 Q_D(QTabWidget);-
1363 return d->tabs->setAutoHide(enabled);
never executed: return d->tabs->setAutoHide(enabled);
0
1364}-
1365-
1366/*!-
1367 Removes all the pages, but does not delete them. Calling this function-
1368 is equivalent to calling removeTab() until the tab widget is empty.-
1369*/-
1370void QTabWidget::clear()-
1371{-
1372 // ### optimize by introduce QStackedLayout::clear()-
1373 while (count())
count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1374 removeTab(0);
never executed: removeTab(0);
0
1375}
never executed: end of block
0
1376-
1377QT_END_NAMESPACE-
1378-
1379#include "moc_qtabwidget.cpp"-
1380-
1381#endif //QT_NO_TABWIDGET-
Source codeSwitch to Preprocessed file

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