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