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

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