OpenCoverage

qtabbar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtabbar.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 "private/qlayoutengine_p.h"-
41#include "qabstractitemdelegate.h"-
42#include "qapplication.h"-
43#include "qbitmap.h"-
44#include "qcursor.h"-
45#include "qevent.h"-
46#include "qpainter.h"-
47#include "qstyle.h"-
48#include "qstyleoption.h"-
49#include "qstylepainter.h"-
50#include "qtabwidget.h"-
51#include "qtooltip.h"-
52#include "qwhatsthis.h"-
53#include "private/qtextengine_p.h"-
54#ifndef QT_NO_ACCESSIBILITY-
55#include "qaccessible.h"-
56#endif-
57#ifdef Q_OS_OSX-
58#include <qpa/qplatformnativeinterface.h>-
59#endif-
60-
61#include "qdebug.h"-
62#include "private/qtabbar_p.h"-
63-
64#ifndef QT_NO_TABBAR-
65-
66#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
67#include <private/qt_mac_p.h>-
68#include <private/qt_cocoa_helpers_mac_p.h>-
69#endif-
70-
71QT_BEGIN_NAMESPACE-
72-
73QMovableTabWidget::QMovableTabWidget(QWidget *parent)-
74 : QWidget(parent)-
75{-
76}
never executed: end of block
0
77-
78void QMovableTabWidget::setPixmap(const QPixmap &pixmap)-
79{-
80 m_pixmap = pixmap;-
81 update();-
82}
never executed: end of block
0
83-
84void QMovableTabWidget::paintEvent(QPaintEvent *e)-
85{-
86 Q_UNUSED(e);-
87 QPainter p(this);-
88 p.drawPixmap(0, 0, m_pixmap);-
89}
never executed: end of block
0
90-
91inline static bool verticalTabs(QTabBar::Shape shape)-
92{-
93 return shape == QTabBar::RoundedWest
never executed: return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast;
0
94 || shape == QTabBar::RoundedEast
never executed: return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast;
0
95 || shape == QTabBar::TriangularWest
never executed: return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast;
0
96 || shape == QTabBar::TriangularEast;
never executed: return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast;
0
97}-
98-
99void QTabBarPrivate::updateMacBorderMetrics()-
100{-
101#if defined(Q_OS_OSX)-
102 Q_Q(QTabBar);-
103 // Extend the unified title and toolbar area to cover the tab bar iff-
104 // 1) the tab bar is in document mode-
105 // 2) the tab bar is directly below an "unified" area.-
106 // The extending itself is done in the Cocoa platform plugin and Mac style,-
107 // this function registers geometry and visibility state for the tab bar.-
108-
109 // Calculate geometry-
110 int upper, lower;-
111 if (documentMode) {-
112 QPoint windowPos = q->mapTo(q->window(), QPoint(0,0));-
113 upper = windowPos.y();-
114 int tabStripHeight = q->tabSizeHint(0).height();-
115 int pixelTweak = -3;-
116 lower = upper + tabStripHeight + pixelTweak;-
117 } else {-
118 upper = 0;-
119 lower = 0;-
120 }-
121-
122 QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();-
123 quintptr identifier = reinterpret_cast<quintptr>(q);-
124-
125 // Set geometry-
126 QPlatformNativeInterface::NativeResourceForIntegrationFunction function =-
127 nativeInterface->nativeResourceFunctionForIntegration("registerContentBorderArea");-
128 if (!function)-
129 return; // Not Cocoa platform plugin.-
130 typedef void (*RegisterContentBorderAreaFunction)(QWindow *window, quintptr identifier, int upper, int lower);-
131 (reinterpret_cast<RegisterContentBorderAreaFunction>(function))(q->window()->windowHandle(), identifier, upper, lower);-
132-
133 // Set visibility state-
134 function = nativeInterface->nativeResourceFunctionForIntegration("setContentBorderAreaEnabled");-
135 if (!function)-
136 return;-
137 typedef void (*SetContentBorderAreaEnabledFunction)(QWindow *window, quintptr identifier, bool enable);-
138 (reinterpret_cast<SetContentBorderAreaEnabledFunction>(function))(q->window()->windowHandle(), identifier, q->isVisible());-
139#endif-
140}-
141-
142/*!-
143 \internal-
144 This is basically QTabBar::initStyleOption() but-
145 without the expensive QFontMetrics::elidedText() call.-
146*/-
147-
148void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex) const-
149{-
150 Q_Q(const QTabBar);-
151 const int totalTabs = tabList.size();-
152-
153 if (!option || (tabIndex < 0 || tabIndex >= totalTabs))
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
tabIndex < 0Description
TRUEnever evaluated
FALSEnever evaluated
tabIndex >= totalTabsDescription
TRUEnever evaluated
FALSEnever evaluated
0
154 return;
never executed: return;
0
155-
156 const QTabBarPrivate::Tab &tab = tabList.at(tabIndex);-
157 option->initFrom(q);-
158 option->state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);-
159 option->rect = q->tabRect(tabIndex);-
160 const bool isCurrent = tabIndex == currentIndex;-
161 option->row = 0;-
162 if (tabIndex == pressedIndex)
tabIndex == pressedIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
163 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
164 if (isCurrent)
isCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
0
165 option->state |= QStyle::State_Selected;
never executed: option->state |= QStyle::State_Selected;
0
166 if (isCurrent && q->hasFocus())
isCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
q->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
167 option->state |= QStyle::State_HasFocus;
never executed: option->state |= QStyle::State_HasFocus;
0
168 if (!tab.enabled)
!tab.enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
169 option->state &= ~QStyle::State_Enabled;
never executed: option->state &= ~QStyle::State_Enabled;
0
170 if (q->isActiveWindow())
q->isActiveWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
171 option->state |= QStyle::State_Active;
never executed: option->state |= QStyle::State_Active;
0
172 if (!dragInProgress && option->rect == hoverRect)
!dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
option->rect == hoverRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
173 option->state |= QStyle::State_MouseOver;
never executed: option->state |= QStyle::State_MouseOver;
0
174 option->shape = shape;-
175 option->text = tab.text;-
176-
177 if (tab.textColor.isValid())
tab.textColor.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
178 option->palette.setColor(q->foregroundRole(), tab.textColor);
never executed: option->palette.setColor(q->foregroundRole(), tab.textColor);
0
179#ifdef Q_OS_MACOS-
180 else if (isCurrent && !documentMode-
181 && (QSysInfo::MacintoshVersion < QSysInfo::MV_10_10 || q->isActiveWindow())) {-
182 option->palette.setColor(QPalette::WindowText, Qt::white);-
183 }-
184#endif-
185 option->icon = tab.icon;-
186 option->iconSize = q->iconSize(); // Will get the default value then.-
187-
188 option->leftButtonSize = tab.leftWidget ? tab.leftWidget->size() : QSize();
tab.leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
189 option->rightButtonSize = tab.rightWidget ? tab.rightWidget->size() : QSize();
tab.rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
190 option->documentMode = documentMode;-
191-
192 if (tabIndex > 0 && tabIndex - 1 == currentIndex)
tabIndex > 0Description
TRUEnever evaluated
FALSEnever evaluated
tabIndex - 1 == currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
193 option->selectedPosition = QStyleOptionTab::PreviousIsSelected;
never executed: option->selectedPosition = QStyleOptionTab::PreviousIsSelected;
0
194 else if (tabIndex + 1 < totalTabs && tabIndex + 1 == currentIndex)
tabIndex + 1 < totalTabsDescription
TRUEnever evaluated
FALSEnever evaluated
tabIndex + 1 == currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
195 option->selectedPosition = QStyleOptionTab::NextIsSelected;
never executed: option->selectedPosition = QStyleOptionTab::NextIsSelected;
0
196 else-
197 option->selectedPosition = QStyleOptionTab::NotAdjacent;
never executed: option->selectedPosition = QStyleOptionTab::NotAdjacent;
0
198-
199 const bool paintBeginning = (tabIndex == 0) || (dragInProgress && tabIndex == pressedIndex + 1);
(tabIndex == 0)Description
TRUEnever evaluated
FALSEnever evaluated
dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
tabIndex == pressedIndex + 1Description
TRUEnever evaluated
FALSEnever evaluated
0
200 const bool paintEnd = (tabIndex == totalTabs - 1) || (dragInProgress && tabIndex == pressedIndex - 1);
(tabIndex == totalTabs - 1)Description
TRUEnever evaluated
FALSEnever evaluated
dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
tabIndex == pressedIndex - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
201 if (paintBeginning) {
paintBeginningDescription
TRUEnever evaluated
FALSEnever evaluated
0
202 if (paintEnd)
paintEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
203 option->position = QStyleOptionTab::OnlyOneTab;
never executed: option->position = QStyleOptionTab::OnlyOneTab;
0
204 else-
205 option->position = QStyleOptionTab::Beginning;
never executed: option->position = QStyleOptionTab::Beginning;
0
206 } else if (paintEnd) {
paintEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
207 option->position = QStyleOptionTab::End;-
208 } else {
never executed: end of block
0
209 option->position = QStyleOptionTab::Middle;-
210 }
never executed: end of block
0
211-
212#ifndef QT_NO_TABWIDGET-
213 if (const QTabWidget *tw = qobject_cast<const QTabWidget *>(q->parentWidget())) {
const QTabWidg...arentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
0
214 option->features |= QStyleOptionTab::HasFrame;-
215 if (tw->cornerWidget(Qt::TopLeftCorner) || tw->cornerWidget(Qt::BottomLeftCorner))
tw->cornerWidg...TopLeftCorner)Description
TRUEnever evaluated
FALSEnever evaluated
tw->cornerWidg...tomLeftCorner)Description
TRUEnever evaluated
FALSEnever evaluated
0
216 option->cornerWidgets |= QStyleOptionTab::LeftCornerWidget;
never executed: option->cornerWidgets |= QStyleOptionTab::LeftCornerWidget;
0
217 if (tw->cornerWidget(Qt::TopRightCorner) || tw->cornerWidget(Qt::BottomRightCorner))
tw->cornerWidg...opRightCorner)Description
TRUEnever evaluated
FALSEnever evaluated
tw->cornerWidg...omRightCorner)Description
TRUEnever evaluated
FALSEnever evaluated
0
218 option->cornerWidgets |= QStyleOptionTab::RightCornerWidget;
never executed: option->cornerWidgets |= QStyleOptionTab::RightCornerWidget;
0
219 }
never executed: end of block
0
220#endif-
221}
never executed: end of block
0
222-
223/*!-
224 Initialize \a option with the values from the tab at \a tabIndex. This method-
225 is useful for subclasses when they need a QStyleOptionTab,-
226 but don't want to fill in all the information themselves.-
227-
228 \sa QStyleOption::initFrom(), QTabWidget::initStyleOption()-
229*/-
230void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const-
231{-
232 Q_D(const QTabBar);-
233 d->initBasicStyleOption(option, tabIndex);-
234-
235 QRect textRect = style()->subElementRect(QStyle::SE_TabBarTabText, option, this);-
236 option->text = fontMetrics().elidedText(option->text, d->elideMode, textRect.width(),-
237 Qt::TextShowMnemonic);-
238}
never executed: end of block
0
239-
240/*!-
241 \class QTabBar-
242 \brief The QTabBar class provides a tab bar, e.g. for use in tabbed dialogs.-
243-
244 \ingroup basicwidgets-
245 \inmodule QtWidgets-
246-
247 QTabBar is straightforward to use; it draws the tabs using one of-
248 the predefined \l{QTabBar::Shape}{shapes}, and emits a-
249 signal when a tab is selected. It can be subclassed to tailor the-
250 look and feel. Qt also provides a ready-made \l{QTabWidget}.-
251-
252 Each tab has a tabText(), an optional tabIcon(), an optional-
253 tabToolTip(), optional tabWhatsThis() and optional tabData().-
254 The tabs's attributes can be changed with setTabText(), setTabIcon(),-
255 setTabToolTip(), setTabWhatsThis and setTabData(). Each tabs can be-
256 enabled or disabled individually with setTabEnabled().-
257-
258 Each tab can display text in a distinct color. The current text color-
259 for a tab can be found with the tabTextColor() function. Set the text-
260 color for a particular tab with setTabTextColor().-
261-
262 Tabs are added using addTab(), or inserted at particular positions-
263 using insertTab(). The total number of tabs is given by-
264 count(). Tabs can be removed from the tab bar with-
265 removeTab(). Combining removeTab() and insertTab() allows you to-
266 move tabs to different positions.-
267-
268 The \l shape property defines the tabs' appearance. The choice of-
269 shape is a matter of taste, although tab dialogs (for preferences-
270 and similar) invariably use \l RoundedNorth.-
271 Tab controls in windows other than dialogs almost-
272 always use either \l RoundedSouth or \l TriangularSouth. Many-
273 spreadsheets and other tab controls in which all the pages are-
274 essentially similar use \l TriangularSouth, whereas \l-
275 RoundedSouth is used mostly when the pages are different (e.g. a-
276 multi-page tool palette). The default in QTabBar is \l-
277 RoundedNorth.-
278-
279 The most important part of QTabBar's API is the currentChanged()-
280 signal. This is emitted whenever the current tab changes (even at-
281 startup, when the current tab changes from 'none'). There is also-
282 a slot, setCurrentIndex(), which can be used to select a tab-
283 programmatically. The function currentIndex() returns the index of-
284 the current tab, \l count holds the number of tabs.-
285-
286 QTabBar creates automatic mnemonic keys in the manner of QAbstractButton;-
287 e.g. if a tab's label is "\&Graphics", Alt+G becomes a shortcut-
288 key for switching to that tab.-
289-
290 The following virtual functions may need to be reimplemented in-
291 order to tailor the look and feel or store extra data with each-
292 tab:-
293-
294 \list-
295 \li tabSizeHint() calcuates the size of a tab.-
296 \li tabInserted() notifies that a new tab was added.-
297 \li tabRemoved() notifies that a tab was removed.-
298 \li tabLayoutChange() notifies that the tabs have been re-laid out.-
299 \li paintEvent() paints all tabs.-
300 \endlist-
301-
302 For subclasses, you might also need the tabRect() functions which-
303 returns the visual geometry of a single tab.-
304-
305 \table 100%-
306 \row \li \inlineimage fusion-tabbar.png Screenshot of a Fusion style tab bar-
307 \li A tab bar shown in the Fusion widget style.-
308 \row \li \inlineimage fusion-tabbar-truncated.png Screenshot of a truncated Fusion tab bar-
309 \li A truncated tab bar shown in the Fusion widget style.-
310 \endtable-
311-
312 \sa QTabWidget-
313*/-
314-
315/*!-
316 \enum QTabBar::Shape-
317-
318 This enum type lists the built-in shapes supported by QTabBar. Treat these-
319 as hints as some styles may not render some of the shapes. However,-
320 position should be honored.-
321-
322 \value RoundedNorth The normal rounded look above the pages-
323-
324 \value RoundedSouth The normal rounded look below the pages-
325-
326 \value RoundedWest The normal rounded look on the left side of the pages-
327-
328 \value RoundedEast The normal rounded look on the right side the pages-
329-
330 \value TriangularNorth Triangular tabs above the pages.-
331-
332 \value TriangularSouth Triangular tabs similar to those used in-
333 the Excel spreadsheet, for example-
334-
335 \value TriangularWest Triangular tabs on the left of the pages.-
336-
337 \value TriangularEast Triangular tabs on the right of the pages.-
338*/-
339-
340/*!-
341 \fn void QTabBar::currentChanged(int index)-
342-
343 This signal is emitted when the tab bar's current tab changes. The-
344 new current has the given \a index, or -1 if there isn't a new one-
345 (for example, if there are no tab in the QTabBar)-
346*/-
347-
348/*!-
349 \fn void QTabBar::tabCloseRequested(int index)-
350 \since 4.5-
351-
352 This signal is emitted when the close button on a tab is clicked.-
353 The \a index is the index that should be removed.-
354-
355 \sa setTabsClosable()-
356*/-
357-
358/*!-
359 \fn void QTabBar::tabMoved(int from, int to)-
360 \since 4.5-
361-
362 This signal is emitted when the tab has moved the tab-
363 at index position \a from to index position \a to.-
364-
365 note: QTabWidget will automatically move the page when-
366 this signal is emitted from its tab bar.-
367-
368 \sa moveTab()-
369*/-
370-
371/*!-
372 \fn void QTabBar::tabBarClicked(int index)-
373-
374 This signal is emitted when user clicks on a tab at an \a index.-
375-
376 \a index is the index of a clicked tab, or -1 if no tab is under the cursor.-
377-
378 \since 5.2-
379*/-
380-
381/*!-
382 \fn void QTabBar::tabBarDoubleClicked(int index)-
383-
384 This signal is emitted when the user double clicks on a tab at \a index.-
385-
386 \a index refers to the tab clicked, or -1 if no tab is under the cursor.-
387-
388 \since 5.2-
389*/-
390-
391void QTabBarPrivate::init()-
392{-
393 Q_Q(QTabBar);-
394 leftB = new QToolButton(q);-
395 leftB->setAutoRepeat(true);-
396 QObject::connect(leftB, SIGNAL(clicked()), q, SLOT(_q_scrollTabs()));-
397 leftB->hide();-
398 rightB = new QToolButton(q);-
399 rightB->setAutoRepeat(true);-
400 QObject::connect(rightB, SIGNAL(clicked()), q, SLOT(_q_scrollTabs()));-
401 rightB->hide();-
402#ifdef QT_KEYPAD_NAVIGATION-
403 if (QApplication::keypadNavigationEnabled()) {-
404 leftB->setFocusPolicy(Qt::NoFocus);-
405 rightB->setFocusPolicy(Qt::NoFocus);-
406 q->setFocusPolicy(Qt::NoFocus);-
407 } else-
408#endif-
409 q->setFocusPolicy(Qt::TabFocus);-
410-
411#ifndef QT_NO_ACCESSIBILITY-
412 leftB->setAccessibleName(QTabBar::tr("Scroll Left"));-
413 rightB->setAccessibleName(QTabBar::tr("Scroll Right"));-
414#endif-
415 q->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);-
416 elideMode = Qt::TextElideMode(q->style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, q));-
417 useScrollButtons = !q->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, q);-
418}
never executed: end of block
0
419-
420QTabBarPrivate::Tab *QTabBarPrivate::at(int index)-
421{-
422 return validIndex(index)?&tabList[index]:0;
never executed: return validIndex(index)?&tabList[index]:0;
0
423}-
424-
425const QTabBarPrivate::Tab *QTabBarPrivate::at(int index) const-
426{-
427 return validIndex(index)?&tabList[index]:0;
never executed: return validIndex(index)?&tabList[index]:0;
0
428}-
429-
430int QTabBarPrivate::indexAtPos(const QPoint &p) const-
431{-
432 Q_Q(const QTabBar);-
433 if (q->tabRect(currentIndex).contains(p))
q->tabRect(cur...x).contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
0
434 return currentIndex;
never executed: return currentIndex;
0
435 for (int i = 0; i < tabList.count(); ++i)
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
436 if (tabList.at(i).enabled && q->tabRect(i).contains(p))
tabList.at(i).enabledDescription
TRUEnever evaluated
FALSEnever evaluated
q->tabRect(i).contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
0
437 return i;
never executed: return i;
0
438 return -1;
never executed: return -1;
0
439}-
440-
441void QTabBarPrivate::layoutTabs()-
442{-
443 Q_Q(QTabBar);-
444 layoutDirty = false;-
445 QSize size = q->size();-
446 int last, available;-
447 int maxExtent;-
448 int i;-
449 bool vertTabs = verticalTabs(shape);-
450 int tabChainIndex = 0;-
451-
452 Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, 0, q));-
453 QVector<QLayoutStruct> tabChain(tabList.count() + 2);-
454-
455 // We put an empty item at the front and back and set its expansive attribute-
456 // depending on tabAlignment.-
457 tabChain[tabChainIndex].init();-
458 tabChain[tabChainIndex].expansive = (tabAlignment != Qt::AlignLeft)
(tabAlignment ...Qt::AlignLeft)Description
TRUEnever evaluated
FALSEnever evaluated
0
459 && (tabAlignment != Qt::AlignJustify);
(tabAlignment ...:AlignJustify)Description
TRUEnever evaluated
FALSEnever evaluated
0
460 tabChain[tabChainIndex].empty = true;-
461 ++tabChainIndex;-
462-
463 // We now go through our list of tabs and set the minimum size and the size hint-
464 // This will allow us to elide text if necessary. Since we don't set-
465 // a maximum size, tabs will EXPAND to fill up the empty space.-
466 // Since tab widget is rather *ahem* strict about keeping the geometry of the-
467 // tab bar to its absolute minimum, this won't bleed through, but will show up-
468 // if you use tab bar on its own (a.k.a. not a bug, but a feature).-
469 // Update: if expanding is false, we DO set a maximum size to prevent the tabs-
470 // being wider than necessary.-
471 if (!vertTabs) {
!vertTabsDescription
TRUEnever evaluated
FALSEnever evaluated
0
472 int minx = 0;-
473 int x = 0;-
474 int maxHeight = 0;-
475 for (i = 0; i < tabList.count(); ++i, ++tabChainIndex) {
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
476 QSize sz = q->tabSizeHint(i);-
477 tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height());-
478 x += sz.width();-
479 maxHeight = qMax(maxHeight, sz.height());-
480 sz = q->minimumTabSizeHint(i);-
481 tabList[i].minRect = QRect(minx, 0, sz.width(), sz.height());-
482 minx += sz.width();-
483 tabChain[tabChainIndex].init();-
484 tabChain[tabChainIndex].sizeHint = tabList.at(i).maxRect.width();-
485 tabChain[tabChainIndex].minimumSize = sz.width();-
486 tabChain[tabChainIndex].empty = false;-
487 tabChain[tabChainIndex].expansive = true;-
488-
489 if (!expanding)
!expandingDescription
TRUEnever evaluated
FALSEnever evaluated
0
490 tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
never executed: tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
0
491 }
never executed: end of block
0
492-
493 last = minx;-
494 available = size.width();-
495 maxExtent = maxHeight;-
496 } else {
never executed: end of block
0
497 int miny = 0;-
498 int y = 0;-
499 int maxWidth = 0;-
500 for (i = 0; i < tabList.count(); ++i, ++tabChainIndex) {
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
501 QSize sz = q->tabSizeHint(i);-
502 tabList[i].maxRect = QRect(0, y, sz.width(), sz.height());-
503 y += sz.height();-
504 maxWidth = qMax(maxWidth, sz.width());-
505 sz = q->minimumTabSizeHint(i);-
506 tabList[i].minRect = QRect(0, miny, sz.width(), sz.height());-
507 miny += sz.height();-
508 tabChain[tabChainIndex].init();-
509 tabChain[tabChainIndex].sizeHint = tabList.at(i).maxRect.height();-
510 tabChain[tabChainIndex].minimumSize = sz.height();-
511 tabChain[tabChainIndex].empty = false;-
512 tabChain[tabChainIndex].expansive = true;-
513-
514 if (!expanding)
!expandingDescription
TRUEnever evaluated
FALSEnever evaluated
0
515 tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
never executed: tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
0
516 }
never executed: end of block
0
517-
518 last = miny;-
519 available = size.height();-
520 maxExtent = maxWidth;-
521 }
never executed: end of block
0
522-
523 Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure.-
524 // Mirror our front item.-
525 tabChain[tabChainIndex].init();-
526 tabChain[tabChainIndex].expansive = (tabAlignment != Qt::AlignRight)
(tabAlignment ...t::AlignRight)Description
TRUEnever evaluated
FALSEnever evaluated
0
527 && (tabAlignment != Qt::AlignJustify);
(tabAlignment ...:AlignJustify)Description
TRUEnever evaluated
FALSEnever evaluated
0
528 tabChain[tabChainIndex].empty = true;-
529-
530 // Do the calculation-
531 qGeomCalc(tabChain, 0, tabChain.count(), 0, qMax(available, last), 0);-
532-
533 // Use the results-
534 for (i = 0; i < tabList.count(); ++i) {
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
535 const QLayoutStruct &lstruct = tabChain.at(i + 1);-
536 if (!vertTabs)
!vertTabsDescription
TRUEnever evaluated
FALSEnever evaluated
0
537 tabList[i].rect.setRect(lstruct.pos, 0, lstruct.size, maxExtent);
never executed: tabList[i].rect.setRect(lstruct.pos, 0, lstruct.size, maxExtent);
0
538 else-
539 tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size);
never executed: tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size);
0
540 }-
541-
542 if (useScrollButtons && tabList.count() && last > available) {
useScrollButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
last > availableDescription
TRUEnever evaluated
FALSEnever evaluated
0
543 const QRect scrollRect = normalizedScrollRect(0);-
544 scrollOffset = -scrollRect.left();-
545-
546 Q_Q(QTabBar);-
547 QStyleOption opt;-
548 opt.init(q);-
549 QRect scrollButtonLeftRect = q->style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, q);-
550 QRect scrollButtonRightRect = q->style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, q);-
551 int scrollButtonWidth = q->style()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, &opt, q);-
552-
553 // Normally SE_TabBarScrollLeftButton should have the same width as PM_TabBarScrollButtonWidth.-
554 // But if that is not the case, we set the actual button width to PM_TabBarScrollButtonWidth, and-
555 // use the extra space from SE_TabBarScrollLeftButton as margins towards the tabs.-
556 if (vertTabs) {
vertTabsDescription
TRUEnever evaluated
FALSEnever evaluated
0
557 scrollButtonLeftRect.setHeight(scrollButtonWidth);-
558 scrollButtonRightRect.setY(scrollButtonRightRect.bottom() + 1 - scrollButtonWidth);-
559 scrollButtonRightRect.setHeight(scrollButtonWidth);-
560 leftB->setArrowType(Qt::UpArrow);-
561 rightB->setArrowType(Qt::DownArrow);-
562 } else if (q->layoutDirection() == Qt::RightToLeft) {
never executed: end of block
q->layoutDirec...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
563 scrollButtonRightRect.setWidth(scrollButtonWidth);-
564 scrollButtonLeftRect.setX(scrollButtonLeftRect.right() + 1 - scrollButtonWidth);-
565 scrollButtonLeftRect.setWidth(scrollButtonWidth);-
566 leftB->setArrowType(Qt::RightArrow);-
567 rightB->setArrowType(Qt::LeftArrow);-
568 } else {
never executed: end of block
0
569 scrollButtonLeftRect.setWidth(scrollButtonWidth);-
570 scrollButtonRightRect.setX(scrollButtonRightRect.right() + 1 - scrollButtonWidth);-
571 scrollButtonRightRect.setWidth(scrollButtonWidth);-
572 leftB->setArrowType(Qt::LeftArrow);-
573 rightB->setArrowType(Qt::RightArrow);-
574 }
never executed: end of block
0
575-
576 leftB->setGeometry(scrollButtonLeftRect);-
577 leftB->setEnabled(false);-
578 leftB->show();-
579-
580 rightB->setGeometry(scrollButtonRightRect);-
581 rightB->setEnabled(last - scrollOffset > scrollRect.x() + scrollRect.width());-
582 rightB->show();-
583 } else {
never executed: end of block
0
584 scrollOffset = 0;-
585 rightB->hide();-
586 leftB->hide();-
587 }
never executed: end of block
0
588-
589 layoutWidgets();-
590 q->tabLayoutChange();-
591}
never executed: end of block
0
592-
593QRect QTabBarPrivate::normalizedScrollRect(int index)-
594{-
595 // "Normalized scroll rect" means return the free space on the tab bar-
596 // that doesn't overlap with scroll buttons or tear indicators, and-
597 // always return the rect as horizontal Qt::LeftToRight, even if the-
598 // tab bar itself is in a different orientation.-
599-
600 Q_Q(QTabBar);-
601 QStyleOptionTab opt;-
602 q->initStyleOption(&opt, currentIndex);-
603 opt.rect = q->rect();-
604-
605 QRect scrollButtonLeftRect = q->style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, q);-
606 QRect scrollButtonRightRect = q->style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, q);-
607 QRect tearLeftRect = q->style()->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &opt, q);-
608 QRect tearRightRect = q->style()->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &opt, q);-
609-
610 if (verticalTabs(shape)) {
verticalTabs(shape)Description
TRUEnever evaluated
FALSEnever evaluated
0
611 int topEdge, bottomEdge;-
612 bool leftButtonIsOnTop = scrollButtonLeftRect.y() < q->height() / 2;-
613 bool rightButtonIsOnTop = scrollButtonRightRect.y() < q->height() / 2;-
614-
615 if (leftButtonIsOnTop && rightButtonIsOnTop) {
leftButtonIsOnTopDescription
TRUEnever evaluated
FALSEnever evaluated
rightButtonIsOnTopDescription
TRUEnever evaluated
FALSEnever evaluated
0
616 topEdge = scrollButtonRightRect.bottom() + 1;-
617 bottomEdge = q->height();-
618 } else if (!leftButtonIsOnTop && !rightButtonIsOnTop) {
never executed: end of block
!leftButtonIsOnTopDescription
TRUEnever evaluated
FALSEnever evaluated
!rightButtonIsOnTopDescription
TRUEnever evaluated
FALSEnever evaluated
0
619 topEdge = 0;-
620 bottomEdge = scrollButtonLeftRect.top();-
621 } else {
never executed: end of block
0
622 topEdge = scrollButtonLeftRect.bottom() + 1;-
623 bottomEdge = scrollButtonRightRect.top();-
624 }
never executed: end of block
0
625-
626 bool tearTopVisible = index != 0 && topEdge != -scrollOffset;
index != 0Description
TRUEnever evaluated
FALSEnever evaluated
topEdge != -scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
627 bool tearBottomVisible = index != tabList.size() - 1 && bottomEdge != tabList.constLast().rect.bottom() + 1 - scrollOffset;
index != tabList.size() - 1Description
TRUEnever evaluated
FALSEnever evaluated
bottomEdge != ...- scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
628 if (tearTopVisible && !tearLeftRect.isNull())
tearTopVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
!tearLeftRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
629 topEdge = tearLeftRect.bottom() + 1;
never executed: topEdge = tearLeftRect.bottom() + 1;
0
630 if (tearBottomVisible && !tearRightRect.isNull())
tearBottomVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
!tearRightRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
631 bottomEdge = tearRightRect.top();
never executed: bottomEdge = tearRightRect.top();
0
632-
633 return QRect(topEdge, 0, bottomEdge - topEdge, q->height());
never executed: return QRect(topEdge, 0, bottomEdge - topEdge, q->height());
0
634 } else {-
635 if (q->layoutDirection() == Qt::RightToLeft) {
q->layoutDirec...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
636 scrollButtonLeftRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), scrollButtonLeftRect);-
637 scrollButtonRightRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), scrollButtonRightRect);-
638 tearLeftRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), tearLeftRect);-
639 tearRightRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), tearRightRect);-
640 }
never executed: end of block
0
641-
642 int leftEdge, rightEdge;-
643 bool leftButtonIsOnLeftSide = scrollButtonLeftRect.x() < q->width() / 2;-
644 bool rightButtonIsOnLeftSide = scrollButtonRightRect.x() < q->width() / 2;-
645-
646 if (leftButtonIsOnLeftSide && rightButtonIsOnLeftSide) {
leftButtonIsOnLeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
rightButtonIsOnLeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
0
647 leftEdge = scrollButtonRightRect.right() + 1;-
648 rightEdge = q->width();-
649 } else if (!leftButtonIsOnLeftSide && !rightButtonIsOnLeftSide) {
never executed: end of block
!leftButtonIsOnLeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
!rightButtonIsOnLeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
0
650 leftEdge = 0;-
651 rightEdge = scrollButtonLeftRect.left();-
652 } else {
never executed: end of block
0
653 leftEdge = scrollButtonLeftRect.right() + 1;-
654 rightEdge = scrollButtonRightRect.left();-
655 }
never executed: end of block
0
656-
657 bool tearLeftVisible = index != 0 && leftEdge != -scrollOffset;
index != 0Description
TRUEnever evaluated
FALSEnever evaluated
leftEdge != -scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
658 bool tearRightVisible = index != tabList.size() - 1 && rightEdge != tabList.constLast().rect.right() + 1 - scrollOffset;
index != tabList.size() - 1Description
TRUEnever evaluated
FALSEnever evaluated
rightEdge != t...- scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
659 if (tearLeftVisible && !tearLeftRect.isNull())
tearLeftVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
!tearLeftRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
660 leftEdge = tearLeftRect.right() + 1;
never executed: leftEdge = tearLeftRect.right() + 1;
0
661 if (tearRightVisible && !tearRightRect.isNull())
tearRightVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
!tearRightRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
662 rightEdge = tearRightRect.left();
never executed: rightEdge = tearRightRect.left();
0
663-
664 return QRect(leftEdge, 0, rightEdge - leftEdge, q->height());
never executed: return QRect(leftEdge, 0, rightEdge - leftEdge, q->height());
0
665 }-
666}-
667-
668void QTabBarPrivate::makeVisible(int index)-
669{-
670 Q_Q(QTabBar);-
671 if (!validIndex(index) || leftB->isHidden())
!validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
leftB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
0
672 return;
never executed: return;
0
673-
674 const QRect tabRect = tabList.at(index).rect;-
675 const int oldScrollOffset = scrollOffset;-
676 const bool horiz = !verticalTabs(shape);-
677 const int tabStart = horiz ? tabRect.left() : tabRect.top();
horizDescription
TRUEnever evaluated
FALSEnever evaluated
0
678 const int tabEnd = horiz ? tabRect.right() : tabRect.bottom();
horizDescription
TRUEnever evaluated
FALSEnever evaluated
0
679 const int lastTabEnd = horiz ? tabList.constLast().rect.right() : tabList.constLast().rect.bottom();
horizDescription
TRUEnever evaluated
FALSEnever evaluated
0
680 const QRect scrollRect = normalizedScrollRect(index);-
681 const int scrolledTabBarStart = qMax(1, scrollRect.left() + scrollOffset);-
682 const int scrolledTabBarEnd = qMin(lastTabEnd - 1, scrollRect.right() + scrollOffset);-
683-
684 if (tabStart < scrolledTabBarStart) {
tabStart < scrolledTabBarStartDescription
TRUEnever evaluated
FALSEnever evaluated
0
685 // Tab is outside on the left, so scroll left.-
686 scrollOffset = tabStart - scrollRect.left();-
687 } else if (tabEnd > scrolledTabBarEnd) {
never executed: end of block
tabEnd > scrolledTabBarEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
688 // Tab is outside on the right, so scroll right.-
689 scrollOffset = tabEnd - scrollRect.right();-
690 }
never executed: end of block
0
691-
692 leftB->setEnabled(scrollOffset > -scrollRect.left());-
693 rightB->setEnabled(scrollOffset < lastTabEnd - scrollRect.right());-
694-
695 if (oldScrollOffset != scrollOffset) {
oldScrollOffse...= scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
696 q->update();-
697 layoutWidgets();-
698 }
never executed: end of block
0
699}
never executed: end of block
0
700-
701void QTabBarPrivate::killSwitchTabTimer()-
702{-
703 Q_Q(QTabBar);-
704 if (switchTabTimerId) {
switchTabTimerIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
705 q->killTimer(switchTabTimerId);-
706 switchTabTimerId = 0;-
707 }
never executed: end of block
0
708 switchTabCurrentIndex = -1;-
709}
never executed: end of block
0
710-
711void QTabBarPrivate::layoutTab(int index)-
712{-
713 Q_Q(QTabBar);-
714 Q_ASSERT(index >= 0);-
715-
716 Tab &tab = tabList[index];-
717 bool vertical = verticalTabs(shape);-
718 if (!(tab.leftWidget || tab.rightWidget))
tab.leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
tab.rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
719 return;
never executed: return;
0
720-
721 QStyleOptionTab opt;-
722 q->initStyleOption(&opt, index);-
723 if (tab.leftWidget) {
tab.leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
724 QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q);-
725 QPoint p = rect.topLeft();-
726 if ((index == pressedIndex) || paintWithOffsets) {
(index == pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
paintWithOffsetsDescription
TRUEnever evaluated
FALSEnever evaluated
0
727 if (vertical)
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
728 p.setY(p.y() + tabList[index].dragOffset);
never executed: p.setY(p.y() + tabList[index].dragOffset);
0
729 else-
730 p.setX(p.x() + tabList[index].dragOffset);
never executed: p.setX(p.x() + tabList[index].dragOffset);
0
731 }-
732 tab.leftWidget->move(p);-
733 }
never executed: end of block
0
734 if (tab.rightWidget) {
tab.rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
735 QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabRightButton, &opt, q);-
736 QPoint p = rect.topLeft();-
737 if ((index == pressedIndex) || paintWithOffsets) {
(index == pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
paintWithOffsetsDescription
TRUEnever evaluated
FALSEnever evaluated
0
738 if (vertical)
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
739 p.setY(p.y() + tab.dragOffset);
never executed: p.setY(p.y() + tab.dragOffset);
0
740 else-
741 p.setX(p.x() + tab.dragOffset);
never executed: p.setX(p.x() + tab.dragOffset);
0
742 }-
743 tab.rightWidget->move(p);-
744 }
never executed: end of block
0
745}
never executed: end of block
0
746-
747void QTabBarPrivate::layoutWidgets(int start)-
748{-
749 Q_Q(QTabBar);-
750 for (int i = start; i < q->count(); ++i) {
i < q->count()Description
TRUEnever evaluated
FALSEnever evaluated
0
751 layoutTab(i);-
752 }
never executed: end of block
0
753}
never executed: end of block
0
754-
755void QTabBarPrivate::autoHideTabs()-
756{-
757 Q_Q(QTabBar);-
758-
759 if (autoHide)
autoHideDescription
TRUEnever evaluated
FALSEnever evaluated
0
760 q->setVisible(q->count() > 1);
never executed: q->setVisible(q->count() > 1);
0
761}
never executed: end of block
0
762-
763void QTabBarPrivate::_q_closeTab()-
764{-
765 Q_Q(QTabBar);-
766 QObject *object = q->sender();-
767 int tabToClose = -1;-
768 QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)q->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, q);-
769 for (int i = 0; i < tabList.count(); ++i) {
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
770 if (closeSide == QTabBar::LeftSide) {
closeSide == QTabBar::LeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
0
771 if (tabList.at(i).leftWidget == object) {
tabList.at(i)....dget == objectDescription
TRUEnever evaluated
FALSEnever evaluated
0
772 tabToClose = i;-
773 break;
never executed: break;
0
774 }-
775 } else {
never executed: end of block
0
776 if (tabList.at(i).rightWidget == object) {
tabList.at(i)....dget == objectDescription
TRUEnever evaluated
FALSEnever evaluated
0
777 tabToClose = i;-
778 break;
never executed: break;
0
779 }-
780 }
never executed: end of block
0
781 }-
782 if (tabToClose != -1)
tabToClose != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
783 emit q->tabCloseRequested(tabToClose);
never executed: q->tabCloseRequested(tabToClose);
0
784}
never executed: end of block
0
785-
786void QTabBarPrivate::_q_scrollTabs()-
787{-
788 Q_Q(QTabBar);-
789 const QObject *sender = q->sender();-
790 const bool horizontal = !verticalTabs(shape);-
791 const QRect scrollRect = normalizedScrollRect();-
792 int i = -1;-
793-
794 if (sender == leftB) {
sender == leftBDescription
TRUEnever evaluated
FALSEnever evaluated
0
795 for (i = tabList.count() - 1; i >= 0; --i) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
796 int start = horizontal ? tabList.at(i).rect.left() : tabList.at(i).rect.top();
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
797 if (start < scrollRect.left() + scrollOffset) {
start < scroll...+ scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
798 makeVisible(i);-
799 return;
never executed: return;
0
800 }-
801 }
never executed: end of block
0
802 } else if (sender == rightB) {
never executed: end of block
sender == rightBDescription
TRUEnever evaluated
FALSEnever evaluated
0
803 for (i = 0; i < tabList.count(); ++i) {
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
804 int end = horizontal ? tabList.at(i).rect.right() : tabList.at(i).rect.bottom();
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
805 if (end > scrollRect.right() + scrollOffset) {
end > scrollRe...+ scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
806 makeVisible(i);-
807 return;
never executed: return;
0
808 }-
809 }
never executed: end of block
0
810 }
never executed: end of block
0
811}
never executed: end of block
0
812-
813void QTabBarPrivate::refresh()-
814{-
815 Q_Q(QTabBar);-
816-
817 // be safe in case a subclass is also handling move with the tabs-
818 if (pressedIndex != -1
pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
819 && movable
movableDescription
TRUEnever evaluated
FALSEnever evaluated
0
820 && QApplication::mouseButtons() == Qt::NoButton) {
QApplication::...= Qt::NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
821 moveTabFinished(pressedIndex);-
822 if (!validIndex(pressedIndex))
!validIndex(pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
823 pressedIndex = -1;
never executed: pressedIndex = -1;
0
824 }
never executed: end of block
0
825-
826 if (!q->isVisible()) {
!q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
827 layoutDirty = true;-
828 } else {
never executed: end of block
0
829 layoutTabs();-
830 makeVisible(currentIndex);-
831 q->update();-
832 q->updateGeometry();-
833 }
never executed: end of block
0
834}-
835-
836/*!-
837 Creates a new tab bar with the given \a parent.-
838*/-
839QTabBar::QTabBar(QWidget* parent)-
840 :QWidget(*new QTabBarPrivate, parent, 0)-
841{-
842 Q_D(QTabBar);-
843 d->init();-
844}
never executed: end of block
0
845-
846-
847/*!-
848 Destroys the tab bar.-
849*/-
850QTabBar::~QTabBar()-
851{-
852}-
853-
854/*!-
855 \property QTabBar::shape-
856 \brief the shape of the tabs in the tab bar-
857-
858 Possible values for this property are described by the Shape enum.-
859*/-
860-
861-
862QTabBar::Shape QTabBar::shape() const-
863{-
864 Q_D(const QTabBar);-
865 return d->shape;
never executed: return d->shape;
0
866}-
867-
868void QTabBar::setShape(Shape shape)-
869{-
870 Q_D(QTabBar);-
871 if (d->shape == shape)
d->shape == shapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
872 return;
never executed: return;
0
873 d->shape = shape;-
874 d->refresh();-
875}
never executed: end of block
0
876-
877/*!-
878 \property QTabBar::drawBase-
879 \brief defines whether or not tab bar should draw its base.-
880-
881 If true then QTabBar draws a base in relation to the styles overlab.-
882 Otherwise only the tabs are drawn.-
883-
884 \sa QStyle::pixelMetric(), QStyle::PM_TabBarBaseOverlap, QStyleOptionTabBarBase-
885*/-
886-
887void QTabBar::setDrawBase(bool drawBase)-
888{-
889 Q_D(QTabBar);-
890 if (d->drawBase == drawBase)
d->drawBase == drawBaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
891 return;
never executed: return;
0
892 d->drawBase = drawBase;-
893 update();-
894}
never executed: end of block
0
895-
896bool QTabBar::drawBase() const-
897{-
898 Q_D(const QTabBar);-
899 return d->drawBase;
never executed: return d->drawBase;
0
900}-
901-
902/*!-
903 Adds a new tab with text \a text. Returns the new-
904 tab's index.-
905*/-
906int QTabBar::addTab(const QString &text)-
907{-
908 return insertTab(-1, text);
never executed: return insertTab(-1, text);
0
909}-
910-
911/*!-
912 \overload-
913-
914 Adds a new tab with icon \a icon and text \a-
915 text. Returns the new tab's index.-
916*/-
917int QTabBar::addTab(const QIcon& icon, const QString &text)-
918{-
919 return insertTab(-1, icon, text);
never executed: return insertTab(-1, icon, text);
0
920}-
921-
922/*!-
923 Inserts a new tab with text \a text at position \a index. If \a-
924 index is out of range, the new tab is appened. Returns the new-
925 tab's index.-
926*/-
927int QTabBar::insertTab(int index, const QString &text)-
928{-
929 return insertTab(index, QIcon(), text);
never executed: return insertTab(index, QIcon(), text);
0
930}-
931-
932/*!\overload-
933-
934 Inserts a new tab with icon \a icon and text \a text at position-
935 \a index. If \a index is out of range, the new tab is-
936 appended. Returns the new tab's index.-
937-
938 If the QTabBar was empty before this function is called, the inserted tab-
939 becomes the current tab.-
940-
941 Inserting a new tab at an index less than or equal to the current index-
942 will increment the current index, but keep the current tab.-
943*/-
944int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)-
945{-
946 Q_D(QTabBar);-
947 if (!d->validIndex(index)) {
!d->validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
948 index = d->tabList.count();-
949 d->tabList.append(QTabBarPrivate::Tab(icon, text));-
950 } else {
never executed: end of block
0
951 d->tabList.insert(index, QTabBarPrivate::Tab(icon, text));-
952 }
never executed: end of block
0
953#ifndef QT_NO_SHORTCUT-
954 d->tabList[index].shortcutId = grabShortcut(QKeySequence::mnemonic(text));-
955#endif-
956 d->refresh();-
957 if (d->tabList.count() == 1)
d->tabList.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
958 setCurrentIndex(index);
never executed: setCurrentIndex(index);
0
959 else if (index <= d->currentIndex)
index <= d->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
960 ++d->currentIndex;
never executed: ++d->currentIndex;
0
961-
962 if (d->closeButtonOnTabs) {
d->closeButtonOnTabsDescription
TRUEnever evaluated
FALSEnever evaluated
0
963 QStyleOptionTab opt;-
964 initStyleOption(&opt, index);-
965 ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this);-
966 QAbstractButton *closeButton = new CloseButton(this);-
967 connect(closeButton, SIGNAL(clicked()), this, SLOT(_q_closeTab()));-
968 setTabButton(index, closeSide, closeButton);-
969 }
never executed: end of block
0
970-
971 for (int i = 0; i < d->tabList.count(); ++i) {
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
972 if (d->tabList[i].lastTab >= index)
d->tabList[i].lastTab >= indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
973 ++d->tabList[i].lastTab;
never executed: ++d->tabList[i].lastTab;
0
974 }
never executed: end of block
0
975-
976 tabInserted(index);-
977 d->autoHideTabs();-
978 return index;
never executed: return index;
0
979}-
980-
981-
982/*!-
983 Removes the tab at position \a index.-
984-
985 \sa SelectionBehavior-
986 */-
987void QTabBar::removeTab(int index)-
988{-
989 Q_D(QTabBar);-
990 if (d->validIndex(index)) {
d->validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
991 if (d->dragInProgress)
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
0
992 d->moveTabFinished(d->pressedIndex);
never executed: d->moveTabFinished(d->pressedIndex);
0
993-
994#ifndef QT_NO_SHORTCUT-
995 releaseShortcut(d->tabList.at(index).shortcutId);-
996#endif-
997 if (d->tabList[index].leftWidget) {
d->tabList[index].leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
998 d->tabList[index].leftWidget->hide();-
999 d->tabList[index].leftWidget->deleteLater();-
1000 d->tabList[index].leftWidget = 0;-
1001 }
never executed: end of block
0
1002 if (d->tabList[index].rightWidget) {
d->tabList[index].rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1003 d->tabList[index].rightWidget->hide();-
1004 d->tabList[index].rightWidget->deleteLater();-
1005 d->tabList[index].rightWidget = 0;-
1006 }
never executed: end of block
0
1007-
1008 int newIndex = d->tabList[index].lastTab;-
1009 d->tabList.removeAt(index);-
1010 for (int i = 0; i < d->tabList.count(); ++i) {
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1011 if (d->tabList[i].lastTab == index)
d->tabList[i].lastTab == indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1012 d->tabList[i].lastTab = -1;
never executed: d->tabList[i].lastTab = -1;
0
1013 if (d->tabList[i].lastTab > index)
d->tabList[i].lastTab > indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1014 --d->tabList[i].lastTab;
never executed: --d->tabList[i].lastTab;
0
1015 }
never executed: end of block
0
1016 if (index == d->currentIndex) {
index == d->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1017 // The current tab is going away, in order to make sure-
1018 // we emit that "current has changed", we need to reset this-
1019 // around.-
1020 d->currentIndex = -1;-
1021 if (d->tabList.size() > 0) {
d->tabList.size() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1022 switch(d->selectionBehaviorOnRemove) {-
1023 case SelectPreviousTab:
never executed: case SelectPreviousTab:
0
1024 if (newIndex > index)
newIndex > indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1025 newIndex--;
never executed: newIndex--;
0
1026 if (d->validIndex(newIndex))
d->validIndex(newIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
1027 break;
never executed: break;
0
1028 // else fallthrough-
1029 case SelectRightTab:
code before this statement never executed: case SelectRightTab:
never executed: case SelectRightTab:
0
1030 newIndex = index;-
1031 if (newIndex >= d->tabList.size())
newIndex >= d->tabList.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1032 newIndex = d->tabList.size() - 1;
never executed: newIndex = d->tabList.size() - 1;
0
1033 break;
never executed: break;
0
1034 case SelectLeftTab:
never executed: case SelectLeftTab:
0
1035 newIndex = index - 1;-
1036 if (newIndex < 0)
newIndex < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1037 newIndex = 0;
never executed: newIndex = 0;
0
1038 break;
never executed: break;
0
1039 default:
never executed: default:
0
1040 break;
never executed: break;
0
1041 }-
1042-
1043 if (d->validIndex(newIndex)) {
d->validIndex(newIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
1044 // don't loose newIndex's old through setCurrentIndex-
1045 int bump = d->tabList[newIndex].lastTab;-
1046 setCurrentIndex(newIndex);-
1047 d->tabList[newIndex].lastTab = bump;-
1048 }
never executed: end of block
0
1049 } else {
never executed: end of block
0
1050 emit currentChanged(-1);-
1051 }
never executed: end of block
0
1052 } else if (index < d->currentIndex) {
index < d->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1053 setCurrentIndex(d->currentIndex - 1);-
1054 }
never executed: end of block
0
1055 d->refresh();-
1056 d->autoHideTabs();-
1057 tabRemoved(index);-
1058 }
never executed: end of block
0
1059}
never executed: end of block
0
1060-
1061-
1062/*!-
1063 Returns \c true if the tab at position \a index is enabled; otherwise-
1064 returns \c false.-
1065*/-
1066bool QTabBar::isTabEnabled(int index) const-
1067{-
1068 Q_D(const QTabBar);-
1069 if (const QTabBarPrivate::Tab *tab = d->at(index))
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1070 return tab->enabled;
never executed: return tab->enabled;
0
1071 return false;
never executed: return false;
0
1072}-
1073-
1074/*!-
1075 If \a enabled is true then the tab at position \a index is-
1076 enabled; otherwise the item at position \a index is disabled.-
1077*/-
1078void QTabBar::setTabEnabled(int index, bool enabled)-
1079{-
1080 Q_D(QTabBar);-
1081 if (QTabBarPrivate::Tab *tab = d->at(index)) {
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1082 tab->enabled = enabled;-
1083#ifndef QT_NO_SHORTCUT-
1084 setShortcutEnabled(tab->shortcutId, enabled);-
1085#endif-
1086 update();-
1087 if (!enabled && index == d->currentIndex)
!enabledDescription
TRUEnever evaluated
FALSEnever evaluated
index == d->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1088 setCurrentIndex(d->validIndex(index+1)?index+1:0);
never executed: setCurrentIndex(d->validIndex(index+1)?index+1:0);
0
1089 else if (enabled && !d->validIndex(d->currentIndex))
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
!d->validIndex...>currentIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
1090 setCurrentIndex(index);
never executed: setCurrentIndex(index);
0
1091 }
never executed: end of block
0
1092}
never executed: end of block
0
1093-
1094-
1095/*!-
1096 Returns the text of the tab at position \a index, or an empty-
1097 string if \a index is out of range.-
1098*/-
1099QString QTabBar::tabText(int index) const-
1100{-
1101 Q_D(const QTabBar);-
1102 if (const QTabBarPrivate::Tab *tab = d->at(index))
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1103 return tab->text;
never executed: return tab->text;
0
1104 return QString();
never executed: return QString();
0
1105}-
1106-
1107/*!-
1108 Sets the text of the tab at position \a index to \a text.-
1109*/-
1110void QTabBar::setTabText(int index, const QString &text)-
1111{-
1112 Q_D(QTabBar);-
1113 if (QTabBarPrivate::Tab *tab = d->at(index)) {
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1114 d->textSizes.remove(tab->text);-
1115 tab->text = text;-
1116#ifndef QT_NO_SHORTCUT-
1117 releaseShortcut(tab->shortcutId);-
1118 tab->shortcutId = grabShortcut(QKeySequence::mnemonic(text));-
1119 setShortcutEnabled(tab->shortcutId, tab->enabled);-
1120#endif-
1121 d->refresh();-
1122 }
never executed: end of block
0
1123}
never executed: end of block
0
1124-
1125/*!-
1126 Returns the text color of the tab with the given \a index, or a invalid-
1127 color if \a index is out of range.-
1128-
1129 \sa setTabTextColor()-
1130*/-
1131QColor QTabBar::tabTextColor(int index) const-
1132{-
1133 Q_D(const QTabBar);-
1134 if (const QTabBarPrivate::Tab *tab = d->at(index))
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1135 return tab->textColor;
never executed: return tab->textColor;
0
1136 return QColor();
never executed: return QColor();
0
1137}-
1138-
1139/*!-
1140 Sets the color of the text in the tab with the given \a index to the specified \a color.-
1141-
1142 If an invalid color is specified, the tab will use the QTabBar foreground role instead.-
1143-
1144 \sa tabTextColor()-
1145*/-
1146void QTabBar::setTabTextColor(int index, const QColor &color)-
1147{-
1148 Q_D(QTabBar);-
1149 if (QTabBarPrivate::Tab *tab = d->at(index)) {
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1150 tab->textColor = color;-
1151 update(tabRect(index));-
1152 }
never executed: end of block
0
1153}
never executed: end of block
0
1154-
1155/*!-
1156 Returns the icon of the tab at position \a index, or a null icon-
1157 if \a index is out of range.-
1158*/-
1159QIcon QTabBar::tabIcon(int index) const-
1160{-
1161 Q_D(const QTabBar);-
1162 if (const QTabBarPrivate::Tab *tab = d->at(index))
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1163 return tab->icon;
never executed: return tab->icon;
0
1164 return QIcon();
never executed: return QIcon();
0
1165}-
1166-
1167/*!-
1168 Sets the icon of the tab at position \a index to \a icon.-
1169*/-
1170void QTabBar::setTabIcon(int index, const QIcon & icon)-
1171{-
1172 Q_D(QTabBar);-
1173 if (QTabBarPrivate::Tab *tab = d->at(index)) {
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1174 bool simpleIconChange = (!icon.isNull() && !tab->icon.isNull());
!icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!tab->icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1175 tab->icon = icon;-
1176 if (simpleIconChange)
simpleIconChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1177 update(tabRect(index));
never executed: update(tabRect(index));
0
1178 else-
1179 d->refresh();
never executed: d->refresh();
0
1180 }-
1181}
never executed: end of block
0
1182-
1183#ifndef QT_NO_TOOLTIP-
1184/*!-
1185 Sets the tool tip of the tab at position \a index to \a tip.-
1186*/-
1187void QTabBar::setTabToolTip(int index, const QString & tip)-
1188{-
1189 Q_D(QTabBar);-
1190 if (QTabBarPrivate::Tab *tab = d->at(index))
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1191 tab->toolTip = tip;
never executed: tab->toolTip = tip;
0
1192}
never executed: end of block
0
1193-
1194/*!-
1195 Returns the tool tip of the tab at position \a index, or an empty-
1196 string if \a index is out of range.-
1197*/-
1198QString QTabBar::tabToolTip(int index) const-
1199{-
1200 Q_D(const QTabBar);-
1201 if (const QTabBarPrivate::Tab *tab = d->at(index))
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1202 return tab->toolTip;
never executed: return tab->toolTip;
0
1203 return QString();
never executed: return QString();
0
1204}-
1205#endif // QT_NO_TOOLTIP-
1206-
1207#ifndef QT_NO_WHATSTHIS-
1208/*!-
1209 \since 4.1-
1210-
1211 Sets the What's This help text of the tab at position \a index-
1212 to \a text.-
1213*/-
1214void QTabBar::setTabWhatsThis(int index, const QString &text)-
1215{-
1216 Q_D(QTabBar);-
1217 if (QTabBarPrivate::Tab *tab = d->at(index))
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1218 tab->whatsThis = text;
never executed: tab->whatsThis = text;
0
1219}
never executed: end of block
0
1220-
1221/*!-
1222 \since 4.1-
1223-
1224 Returns the What's This help text of the tab at position \a index,-
1225 or an empty string if \a index is out of range.-
1226*/-
1227QString QTabBar::tabWhatsThis(int index) const-
1228{-
1229 Q_D(const QTabBar);-
1230 if (const QTabBarPrivate::Tab *tab = d->at(index))
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1231 return tab->whatsThis;
never executed: return tab->whatsThis;
0
1232 return QString();
never executed: return QString();
0
1233}-
1234-
1235#endif // QT_NO_WHATSTHIS-
1236-
1237/*!-
1238 Sets the data of the tab at position \a index to \a data.-
1239*/-
1240void QTabBar::setTabData(int index, const QVariant & data)-
1241{-
1242 Q_D(QTabBar);-
1243 if (QTabBarPrivate::Tab *tab = d->at(index))
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1244 tab->data = data;
never executed: tab->data = data;
0
1245}
never executed: end of block
0
1246-
1247/*!-
1248 Returns the data of the tab at position \a index, or a null-
1249 variant if \a index is out of range.-
1250*/-
1251QVariant QTabBar::tabData(int index) const-
1252{-
1253 Q_D(const QTabBar);-
1254 if (const QTabBarPrivate::Tab *tab = d->at(index))
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1255 return tab->data;
never executed: return tab->data;
0
1256 return QVariant();
never executed: return QVariant();
0
1257}-
1258-
1259/*!-
1260 Returns the visual rectangle of the tab at position \a-
1261 index, or a null rectangle if \a index is out of range.-
1262*/-
1263QRect QTabBar::tabRect(int index) const-
1264{-
1265 Q_D(const QTabBar);-
1266 if (const QTabBarPrivate::Tab *tab = d->at(index)) {
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1267 if (d->layoutDirty)
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1268 const_cast<QTabBarPrivate*>(d)->layoutTabs();
never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs();
0
1269 QRect r = tab->rect;-
1270 if (verticalTabs(d->shape))
verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
0
1271 r.translate(0, -d->scrollOffset);
never executed: r.translate(0, -d->scrollOffset);
0
1272 else-
1273 r.translate(-d->scrollOffset, 0);
never executed: r.translate(-d->scrollOffset, 0);
0
1274 if (!verticalTabs(d->shape))
!verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
0
1275 r = QStyle::visualRect(layoutDirection(), rect(), r);
never executed: r = QStyle::visualRect(layoutDirection(), rect(), r);
0
1276 return r;
never executed: return r;
0
1277 }-
1278 return QRect();
never executed: return QRect();
0
1279}-
1280-
1281/*!-
1282 \since 4.3-
1283 Returns the index of the tab that covers \a position or -1 if no-
1284 tab covers \a position;-
1285*/-
1286-
1287int QTabBar::tabAt(const QPoint &position) const-
1288{-
1289 Q_D(const QTabBar);-
1290 if (d->validIndex(d->currentIndex)
d->validIndex(d->currentIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
1291 && tabRect(d->currentIndex).contains(position)) {
tabRect(d->cur...ains(position)Description
TRUEnever evaluated
FALSEnever evaluated
0
1292 return d->currentIndex;
never executed: return d->currentIndex;
0
1293 }-
1294 const int max = d->tabList.size();-
1295 for (int i = 0; i < max; ++i) {
i < maxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1296 if (tabRect(i).contains(position)) {
tabRect(i).contains(position)Description
TRUEnever evaluated
FALSEnever evaluated
0
1297 return i;
never executed: return i;
0
1298 }-
1299 }
never executed: end of block
0
1300 return -1;
never executed: return -1;
0
1301}-
1302-
1303/*!-
1304 \property QTabBar::currentIndex-
1305 \brief the index of the tab bar's visible tab-
1306-
1307 The current index is -1 if there is no current tab.-
1308*/-
1309-
1310int QTabBar::currentIndex() const-
1311{-
1312 Q_D(const QTabBar);-
1313 if (d->validIndex(d->currentIndex))
d->validIndex(d->currentIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
1314 return d->currentIndex;
never executed: return d->currentIndex;
0
1315 return -1;
never executed: return -1;
0
1316}-
1317-
1318-
1319void QTabBar::setCurrentIndex(int index)-
1320{-
1321 Q_D(QTabBar);-
1322 if (d->dragInProgress && d->pressedIndex != -1)
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1323 return;
never executed: return;
0
1324-
1325 int oldIndex = d->currentIndex;-
1326 if (d->validIndex(index) && d->currentIndex != index) {
d->validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
d->currentIndex != indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1327 d->currentIndex = index;-
1328 update();-
1329 d->makeVisible(index);-
1330 d->tabList[index].lastTab = oldIndex;-
1331 if (oldIndex >= 0 && oldIndex < count())
oldIndex >= 0Description
TRUEnever evaluated
FALSEnever evaluated
oldIndex < count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1332 d->layoutTab(oldIndex);
never executed: d->layoutTab(oldIndex);
0
1333 d->layoutTab(index);-
1334#ifndef QT_NO_ACCESSIBILITY-
1335 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1336 if (hasFocus()) {
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
1337 QAccessibleEvent focusEvent(this, QAccessible::Focus);-
1338 focusEvent.setChild(index);-
1339 QAccessible::updateAccessibility(&focusEvent);-
1340 }
never executed: end of block
0
1341 QAccessibleEvent selectionEvent(this, QAccessible::Selection);-
1342 selectionEvent.setChild(index);-
1343 QAccessible::updateAccessibility(&selectionEvent);-
1344 }
never executed: end of block
0
1345#endif-
1346 emit currentChanged(index);-
1347 }
never executed: end of block
0
1348}
never executed: end of block
0
1349-
1350/*!-
1351 \property QTabBar::iconSize-
1352 \brief The size for icons in the tab bar-
1353 \since 4.1-
1354-
1355 The default value is style-dependent. \c iconSize is a maximum-
1356 size; icons that are smaller are not scaled up.-
1357-
1358 \sa QTabWidget::iconSize-
1359*/-
1360QSize QTabBar::iconSize() const-
1361{-
1362 Q_D(const QTabBar);-
1363 if (d->iconSize.isValid())
d->iconSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1364 return d->iconSize;
never executed: return d->iconSize;
0
1365 int iconExtent = style()->pixelMetric(QStyle::PM_TabBarIconSize, 0, this);-
1366 return QSize(iconExtent, iconExtent);
never executed: return QSize(iconExtent, iconExtent);
0
1367-
1368}-
1369-
1370void QTabBar::setIconSize(const QSize &size)-
1371{-
1372 Q_D(QTabBar);-
1373 d->iconSize = size;-
1374 d->layoutDirty = true;-
1375 update();-
1376 updateGeometry();-
1377}
never executed: end of block
0
1378-
1379/*!-
1380 \property QTabBar::count-
1381 \brief the number of tabs in the tab bar-
1382*/-
1383-
1384int QTabBar::count() const-
1385{-
1386 Q_D(const QTabBar);-
1387 return d->tabList.count();
never executed: return d->tabList.count();
0
1388}-
1389-
1390-
1391/*!\reimp-
1392 */-
1393QSize QTabBar::sizeHint() const-
1394{-
1395 Q_D(const QTabBar);-
1396 if (d->layoutDirty)
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1397 const_cast<QTabBarPrivate*>(d)->layoutTabs();
never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs();
0
1398 QRect r;-
1399 for (int i = 0; i < d->tabList.count(); ++i)
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1400 r = r.united(d->tabList.at(i).maxRect);
never executed: r = r.united(d->tabList.at(i).maxRect);
0
1401 QSize sz = QApplication::globalStrut();-
1402 return r.size().expandedTo(sz);
never executed: return r.size().expandedTo(sz);
0
1403}-
1404-
1405/*!\reimp-
1406 */-
1407QSize QTabBar::minimumSizeHint() const-
1408{-
1409 Q_D(const QTabBar);-
1410 if (d->layoutDirty)
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1411 const_cast<QTabBarPrivate*>(d)->layoutTabs();
never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs();
0
1412 if (!d->useScrollButtons) {
!d->useScrollButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1413 QRect r;-
1414 for (int i = 0; i < d->tabList.count(); ++i)
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1415 r = r.united(d->tabList.at(i).minRect);
never executed: r = r.united(d->tabList.at(i).minRect);
0
1416 return r.size().expandedTo(QApplication::globalStrut());
never executed: return r.size().expandedTo(QApplication::globalStrut());
0
1417 }-
1418 if (verticalTabs(d->shape))
verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
0
1419 return QSize(sizeHint().width(), d->rightB->sizeHint().height() * 2 + 75);
never executed: return QSize(sizeHint().width(), d->rightB->sizeHint().height() * 2 + 75);
0
1420 else-
1421 return QSize(d->rightB->sizeHint().width() * 2 + 75, sizeHint().height());
never executed: return QSize(d->rightB->sizeHint().width() * 2 + 75, sizeHint().height());
0
1422}-
1423-
1424// Compute the most-elided possible text, for minimumSizeHint-
1425static QString computeElidedText(Qt::TextElideMode mode, const QString &text)-
1426{-
1427 if (text.length() <= 3)
text.length() <= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
1428 return text;
never executed: return text;
0
1429-
1430 static const QLatin1String Ellipses("...");-
1431 QString ret;-
1432 switch (mode) {-
1433 case Qt::ElideRight:
never executed: case Qt::ElideRight:
0
1434 ret = text.leftRef(2) + Ellipses;-
1435 break;
never executed: break;
0
1436 case Qt::ElideMiddle:
never executed: case Qt::ElideMiddle:
0
1437 ret = text.leftRef(1) + Ellipses + text.rightRef(1);-
1438 break;
never executed: break;
0
1439 case Qt::ElideLeft:
never executed: case Qt::ElideLeft:
0
1440 ret = Ellipses + text.rightRef(2);-
1441 break;
never executed: break;
0
1442 case Qt::ElideNone:
never executed: case Qt::ElideNone:
0
1443 ret = text;-
1444 break;
never executed: break;
0
1445 }-
1446 return ret;
never executed: return ret;
0
1447}-
1448-
1449/*!-
1450 Returns the minimum tab size hint for the tab at position \a index.-
1451 \since Qt 5.0-
1452*/-
1453-
1454QSize QTabBar::minimumTabSizeHint(int index) const-
1455{-
1456 Q_D(const QTabBar);-
1457 QTabBarPrivate::Tab &tab = const_cast<QTabBarPrivate::Tab&>(d->tabList[index]);-
1458 QString oldText = tab.text;-
1459 tab.text = computeElidedText(d->elideMode, oldText);-
1460 QSize size = tabSizeHint(index);-
1461 tab.text = oldText;-
1462 return size;
never executed: return size;
0
1463}-
1464-
1465/*!-
1466 Returns the size hint for the tab at position \a index.-
1467*/-
1468QSize QTabBar::tabSizeHint(int index) const-
1469{-
1470 //Note: this must match with the computations in QCommonStylePrivate::tabLayout-
1471 Q_D(const QTabBar);-
1472 if (const QTabBarPrivate::Tab *tab = d->at(index)) {
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1473 QStyleOptionTab opt;-
1474 d->initBasicStyleOption(&opt, index);-
1475 opt.text = d->tabList.at(index).text;-
1476 QSize iconSize = tab->icon.isNull() ? QSize(0, 0) : opt.iconSize;
tab->icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1477 int hframe = style()->pixelMetric(QStyle::PM_TabBarTabHSpace, &opt, this);-
1478 int vframe = style()->pixelMetric(QStyle::PM_TabBarTabVSpace, &opt, this);-
1479 const QFontMetrics fm = fontMetrics();-
1480-
1481 int maxWidgetHeight = qMax(opt.leftButtonSize.height(), opt.rightButtonSize.height());-
1482 int maxWidgetWidth = qMax(opt.leftButtonSize.width(), opt.rightButtonSize.width());-
1483-
1484 int widgetWidth = 0;-
1485 int widgetHeight = 0;-
1486 int padding = 0;-
1487 if (!opt.leftButtonSize.isEmpty()) {
!opt.leftButtonSize.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1488 padding += 4;-
1489 widgetWidth += opt.leftButtonSize.width();-
1490 widgetHeight += opt.leftButtonSize.height();-
1491 }
never executed: end of block
0
1492 if (!opt.rightButtonSize.isEmpty()) {
!opt.rightButtonSize.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1493 padding += 4;-
1494 widgetWidth += opt.rightButtonSize.width();-
1495 widgetHeight += opt.rightButtonSize.height();-
1496 }
never executed: end of block
0
1497 if (!opt.icon.isNull())
!opt.icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1498 padding += 4;
never executed: padding += 4;
0
1499-
1500 QHash<QString, QSize>::iterator it = d->textSizes.find(tab->text);-
1501 if (it == d->textSizes.end())
it == d->textSizes.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
1502 it = d->textSizes.insert(tab->text, fm.size(Qt::TextShowMnemonic, tab->text));
never executed: it = d->textSizes.insert(tab->text, fm.size(Qt::TextShowMnemonic, tab->text));
0
1503 const int textWidth = it.value().width();-
1504 QSize csz;-
1505 if (verticalTabs(d->shape)) {
verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
0
1506 csz = QSize( qMax(maxWidgetWidth, qMax(fm.height(), iconSize.height())) + vframe,-
1507 textWidth + iconSize.width() + hframe + widgetHeight + padding);-
1508 } else {
never executed: end of block
0
1509 csz = QSize(textWidth + iconSize.width() + hframe + widgetWidth + padding,-
1510 qMax(maxWidgetHeight, qMax(fm.height(), iconSize.height())) + vframe);-
1511 }
never executed: end of block
0
1512-
1513 QSize retSize = style()->sizeFromContents(QStyle::CT_TabBarTab, &opt, csz, this);-
1514 return retSize;
never executed: return retSize;
0
1515 }-
1516 return QSize();
never executed: return QSize();
0
1517}-
1518-
1519/*!-
1520 This virtual handler is called after a new tab was added or-
1521 inserted at position \a index.-
1522-
1523 \sa tabRemoved()-
1524 */-
1525void QTabBar::tabInserted(int index)-
1526{-
1527 Q_UNUSED(index)-
1528}
never executed: end of block
0
1529-
1530/*!-
1531 This virtual handler is called after a tab was removed from-
1532 position \a index.-
1533-
1534 \sa tabInserted()-
1535 */-
1536void QTabBar::tabRemoved(int index)-
1537{-
1538 Q_UNUSED(index)-
1539}
never executed: end of block
0
1540-
1541/*!-
1542 This virtual handler is called whenever the tab layout changes.-
1543-
1544 \sa tabRect()-
1545 */-
1546void QTabBar::tabLayoutChange()-
1547{-
1548}-
1549-
1550-
1551/*!\reimp-
1552 */-
1553void QTabBar::showEvent(QShowEvent *)-
1554{-
1555 Q_D(QTabBar);-
1556 if (d->layoutDirty)
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1557 d->refresh();
never executed: d->refresh();
0
1558 if (!d->validIndex(d->currentIndex))
!d->validIndex...>currentIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
1559 setCurrentIndex(0);
never executed: setCurrentIndex(0);
0
1560 d->updateMacBorderMetrics();-
1561}
never executed: end of block
0
1562-
1563/*!\reimp-
1564 */-
1565void QTabBar::hideEvent(QHideEvent *)-
1566{-
1567 Q_D(QTabBar);-
1568 d->updateMacBorderMetrics();-
1569}
never executed: end of block
0
1570-
1571/*!\reimp-
1572 */-
1573bool QTabBar::event(QEvent *event)-
1574{-
1575 Q_D(QTabBar);-
1576 if (event->type() == QEvent::HoverMove
event->type() ...ent::HoverMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1577 || event->type() == QEvent::HoverEnter) {
event->type() ...nt::HoverEnterDescription
TRUEnever evaluated
FALSEnever evaluated
0
1578 QHoverEvent *he = static_cast<QHoverEvent *>(event);-
1579 if (!d->hoverRect.contains(he->pos())) {
!d->hoverRect....ins(he->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
1580 QRect oldHoverRect = d->hoverRect;-
1581 for (int i = 0; i < d->tabList.count(); ++i) {
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1582 QRect area = tabRect(i);-
1583 if (area.contains(he->pos())) {
area.contains(he->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
1584 d->hoverRect = area;-
1585 break;
never executed: break;
0
1586 }-
1587 }
never executed: end of block
0
1588 if (he->oldPos() != QPoint(-1, -1))
he->oldPos() != QPoint(-1, -1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1589 update(oldHoverRect);
never executed: update(oldHoverRect);
0
1590 update(d->hoverRect);-
1591 }
never executed: end of block
0
1592 return true;
never executed: return true;
0
1593 } else if (event->type() == QEvent::HoverLeave ) {
event->type() ...nt::HoverLeaveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1594 QRect oldHoverRect = d->hoverRect;-
1595 d->hoverRect = QRect();-
1596 update(oldHoverRect);-
1597 return true;
never executed: return true;
0
1598#ifndef QT_NO_TOOLTIP-
1599 } else if (event->type() == QEvent::ToolTip) {
event->type() ...Event::ToolTipDescription
TRUEnever evaluated
FALSEnever evaluated
0
1600 if (const QTabBarPrivate::Tab *tab = d->at(tabAt(static_cast<QHelpEvent*>(event)->pos()))) {
const QTabBarP...vent)->pos()))Description
TRUEnever evaluated
FALSEnever evaluated
0
1601 if (!tab->toolTip.isEmpty()) {
!tab->toolTip.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1602 QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tab->toolTip, this);-
1603 return true;
never executed: return true;
0
1604 }-
1605 }
never executed: end of block
0
1606#endif // QT_NO_TOOLTIP-
1607#ifndef QT_NO_WHATSTHIS-
1608 } else if (event->type() == QEvent::QueryWhatsThis) {
never executed: end of block
event->type() ...QueryWhatsThisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1609 const QTabBarPrivate::Tab *tab = d->at(d->indexAtPos(static_cast<QHelpEvent*>(event)->pos()));-
1610 if (!tab || tab->whatsThis.isEmpty())
!tabDescription
TRUEnever evaluated
FALSEnever evaluated
tab->whatsThis.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1611 event->ignore();
never executed: event->ignore();
0
1612 return true;
never executed: return true;
0
1613 } else if (event->type() == QEvent::WhatsThis) {
event->type() ...ent::WhatsThisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1614 if (const QTabBarPrivate::Tab *tab = d->at(d->indexAtPos(static_cast<QHelpEvent*>(event)->pos()))) {
const QTabBarP...vent)->pos()))Description
TRUEnever evaluated
FALSEnever evaluated
0
1615 if (!tab->whatsThis.isEmpty()) {
!tab->whatsThis.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1616 QWhatsThis::showText(static_cast<QHelpEvent*>(event)->globalPos(),-
1617 tab->whatsThis, this);-
1618 return true;
never executed: return true;
0
1619 }-
1620 }
never executed: end of block
0
1621#endif // QT_NO_WHATSTHIS-
1622#ifndef QT_NO_SHORTCUT-
1623 } else if (event->type() == QEvent::Shortcut) {
never executed: end of block
event->type() ...vent::ShortcutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1624 QShortcutEvent *se = static_cast<QShortcutEvent *>(event);-
1625 for (int i = 0; i < d->tabList.count(); ++i) {
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1626 const QTabBarPrivate::Tab *tab = &d->tabList.at(i);-
1627 if (tab->shortcutId == se->shortcutId()) {
tab->shortcutI...->shortcutId()Description
TRUEnever evaluated
FALSEnever evaluated
0
1628 setCurrentIndex(i);-
1629 return true;
never executed: return true;
0
1630 }-
1631 }
never executed: end of block
0
1632#endif-
1633 } else if (event->type() == QEvent::MouseButtonDblClick) { // ### fixme Qt 6: move to mouseDoubleClickEvent(), here for BC reasons.
never executed: end of block
event->type() ...ButtonDblClickDescription
TRUEnever evaluated
FALSEnever evaluated
0
1634 const QPoint pos = static_cast<const QMouseEvent *>(event)->pos();-
1635 const bool isEventInCornerButtons = (!d->leftB->isHidden() && d->leftB->geometry().contains(pos))
!d->leftB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
d->leftB->geom....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
1636 || (!d->rightB->isHidden() && d->rightB->geometry().contains(pos));
!d->rightB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
d->rightB->geo....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
1637 if (!isEventInCornerButtons)
!isEventInCornerButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1638 emit tabBarDoubleClicked(tabAt(pos));
never executed: tabBarDoubleClicked(tabAt(pos));
0
1639 } else if (event->type() == QEvent::Move) {
never executed: end of block
event->type() == QEvent::MoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1640 d->updateMacBorderMetrics();-
1641 return QWidget::event(event);
never executed: return QWidget::event(event);
0
1642-
1643#ifndef QT_NO_DRAGANDDROP-
1644 } else if (event->type() == QEvent::DragEnter) {
event->type() ...ent::DragEnterDescription
TRUEnever evaluated
FALSEnever evaluated
0
1645 if (d->changeCurrentOnDrag)
d->changeCurrentOnDragDescription
TRUEnever evaluated
FALSEnever evaluated
0
1646 event->accept();
never executed: event->accept();
0
1647 } else if (event->type() == QEvent::DragMove) {
never executed: end of block
event->type() ...vent::DragMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1648 if (d->changeCurrentOnDrag) {
d->changeCurrentOnDragDescription
TRUEnever evaluated
FALSEnever evaluated
0
1649 const int tabIndex = tabAt(static_cast<QDragMoveEvent *>(event)->pos());-
1650 if (isTabEnabled(tabIndex) && d->switchTabCurrentIndex != tabIndex) {
isTabEnabled(tabIndex)Description
TRUEnever evaluated
FALSEnever evaluated
d->switchTabCu...ex != tabIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1651 d->switchTabCurrentIndex = tabIndex;-
1652 if (d->switchTabTimerId)
d->switchTabTimerIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
1653 killTimer(d->switchTabTimerId);
never executed: killTimer(d->switchTabTimerId);
0
1654 d->switchTabTimerId = startTimer(style()->styleHint(QStyle::SH_TabBar_ChangeCurrentDelay));-
1655 }
never executed: end of block
0
1656 event->ignore();-
1657 }
never executed: end of block
0
1658 } else if (event->type() == QEvent::DragLeave || event->type() == QEvent::Drop) {
never executed: end of block
event->type() ...ent::DragLeaveDescription
TRUEnever evaluated
FALSEnever evaluated
event->type() == QEvent::DropDescription
TRUEnever evaluated
FALSEnever evaluated
0
1659 d->killSwitchTabTimer();-
1660 event->ignore();-
1661#endif-
1662 }
never executed: end of block
0
1663 return QWidget::event(event);
never executed: return QWidget::event(event);
0
1664}-
1665-
1666/*!\reimp-
1667 */-
1668void QTabBar::resizeEvent(QResizeEvent *)-
1669{-
1670 Q_D(QTabBar);-
1671 if (d->layoutDirty)
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1672 updateGeometry();
never executed: updateGeometry();
0
1673 d->layoutTabs();-
1674-
1675 d->makeVisible(d->currentIndex);-
1676}
never executed: end of block
0
1677-
1678/*!\reimp-
1679 */-
1680void QTabBar::paintEvent(QPaintEvent *)-
1681{-
1682 Q_D(QTabBar);-
1683-
1684 QStyleOptionTabBarBase optTabBase;-
1685 QTabBarPrivate::initStyleBaseOption(&optTabBase, this, size());-
1686-
1687 QStylePainter p(this);-
1688 int selected = -1;-
1689 int cutLeft = -1;-
1690 int cutRight = -1;-
1691 bool vertical = verticalTabs(d->shape);-
1692 QStyleOptionTab cutTabLeft;-
1693 QStyleOptionTab cutTabRight;-
1694 selected = d->currentIndex;-
1695 if (d->dragInProgress)
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
0
1696 selected = d->pressedIndex;
never executed: selected = d->pressedIndex;
0
1697 const QRect scrollRect = d->normalizedScrollRect();-
1698-
1699 for (int i = 0; i < d->tabList.count(); ++i)
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1700 optTabBase.tabBarRect |= tabRect(i);
never executed: optTabBase.tabBarRect |= tabRect(i);
0
1701-
1702 optTabBase.selectedTabRect = tabRect(selected);-
1703-
1704 if (d->drawBase)
d->drawBaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
1705 p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
never executed: p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
0
1706-
1707 for (int i = 0; i < d->tabList.count(); ++i) {
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1708 QStyleOptionTab tab;-
1709 initStyleOption(&tab, i);-
1710 if (d->paintWithOffsets && d->tabList[i].dragOffset != 0) {
d->paintWithOffsetsDescription
TRUEnever evaluated
FALSEnever evaluated
d->tabList[i].dragOffset != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1711 if (vertical) {
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1712 tab.rect.moveTop(tab.rect.y() + d->tabList[i].dragOffset);-
1713 } else {
never executed: end of block
0
1714 tab.rect.moveLeft(tab.rect.x() + d->tabList[i].dragOffset);-
1715 }
never executed: end of block
0
1716 }-
1717 if (!(tab.state & QStyle::State_Enabled)) {
!(tab.state & ...State_Enabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
1718 tab.palette.setCurrentColorGroup(QPalette::Disabled);-
1719 }
never executed: end of block
0
1720-
1721 // If this tab is partially obscured, make a note of it so that we can pass the information-
1722 // along when we draw the tear.-
1723 QRect tabRect = d->tabList[i].rect;-
1724 int tabStart = vertical ? tabRect.top() : tabRect.left();
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1725 int tabEnd = vertical ? tabRect.bottom() : tabRect.right();
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1726 if (tabStart < scrollRect.left() + d->scrollOffset) {
tabStart < scr...->scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1727 cutLeft = i;-
1728 cutTabLeft = tab;-
1729 } else if (tabEnd > scrollRect.right() + d->scrollOffset) {
never executed: end of block
tabEnd > scrol...->scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1730 cutRight = i;-
1731 cutTabRight = tab;-
1732 }
never executed: end of block
0
1733-
1734 // Don't bother drawing a tab if the entire tab is outside of the visible tab bar.-
1735 if ((!vertical && (tab.rect.right() < 0 || tab.rect.left() > width()))
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
tab.rect.right() < 0Description
TRUEnever evaluated
FALSEnever evaluated
tab.rect.left() > width()Description
TRUEnever evaluated
FALSEnever evaluated
0
1736 || (vertical && (tab.rect.bottom() < 0 || tab.rect.top() > height())))
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
tab.rect.bottom() < 0Description
TRUEnever evaluated
FALSEnever evaluated
tab.rect.top() > height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1737 continue;
never executed: continue;
0
1738-
1739 optTabBase.tabBarRect |= tab.rect;-
1740 if (i == selected)
i == selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1741 continue;
never executed: continue;
0
1742-
1743 p.drawControl(QStyle::CE_TabBarTab, tab);-
1744 }
never executed: end of block
0
1745-
1746 // Draw the selected tab last to get it "on top"-
1747 if (selected >= 0) {
selected >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1748 QStyleOptionTab tab;-
1749 initStyleOption(&tab, selected);-
1750 if (d->paintWithOffsets && d->tabList[selected].dragOffset != 0) {
d->paintWithOffsetsDescription
TRUEnever evaluated
FALSEnever evaluated
d->tabList[sel...ragOffset != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1751 if (vertical)
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1752 tab.rect.moveTop(tab.rect.y() + d->tabList[selected].dragOffset);
never executed: tab.rect.moveTop(tab.rect.y() + d->tabList[selected].dragOffset);
0
1753 else-
1754 tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset);
never executed: tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset);
0
1755 }-
1756 if (!d->dragInProgress)
!d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
0
1757 p.drawControl(QStyle::CE_TabBarTab, tab);
never executed: p.drawControl(QStyle::CE_TabBarTab, tab);
0
1758 else {-
1759 int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this);-
1760 d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0));-
1761 }
never executed: end of block
0
1762 }-
1763-
1764 // Only draw the tear indicator if necessary. Most of the time we don't need too.-
1765 if (d->leftB->isVisible() && cutLeft >= 0) {
d->leftB->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
cutLeft >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1766 cutTabLeft.rect = rect();-
1767 cutTabLeft.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &cutTabLeft, this);-
1768 p.drawPrimitive(QStyle::PE_IndicatorTabTearLeft, cutTabLeft);-
1769 }
never executed: end of block
0
1770-
1771 if (d->rightB->isVisible() && cutRight >= 0) {
d->rightB->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
cutRight >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1772 cutTabRight.rect = rect();-
1773 cutTabRight.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &cutTabRight, this);-
1774 p.drawPrimitive(QStyle::PE_IndicatorTabTearRight, cutTabRight);-
1775 }
never executed: end of block
0
1776}
never executed: end of block
0
1777-
1778/*-
1779 Given that index at position from moved to position to where return where index goes.-
1780 */-
1781int QTabBarPrivate::calculateNewPosition(int from, int to, int index) const-
1782{-
1783 if (index == from)
index == fromDescription
TRUEnever evaluated
FALSEnever evaluated
0
1784 return to;
never executed: return to;
0
1785-
1786 int start = qMin(from, to);-
1787 int end = qMax(from, to);-
1788 if (index >= start && index <= end)
index >= startDescription
TRUEnever evaluated
FALSEnever evaluated
index <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
1789 index += (from < to) ? -1 : 1;
never executed: index += (from < to) ? -1 : 1;
(from < to)Description
TRUEnever evaluated
FALSEnever evaluated
0
1790 return index;
never executed: return index;
0
1791}-
1792-
1793/*!-
1794 Moves the item at index position \a from to index position \a to.-
1795 \since 4.5-
1796-
1797 \sa tabMoved(), tabLayoutChange()-
1798 */-
1799void QTabBar::moveTab(int from, int to)-
1800{-
1801 Q_D(QTabBar);-
1802 if (from == to
from == toDescription
TRUEnever evaluated
FALSEnever evaluated
0
1803 || !d->validIndex(from)
!d->validIndex(from)Description
TRUEnever evaluated
FALSEnever evaluated
0
1804 || !d->validIndex(to))
!d->validIndex(to)Description
TRUEnever evaluated
FALSEnever evaluated
0
1805 return;
never executed: return;
0
1806-
1807 bool vertical = verticalTabs(d->shape);-
1808 int oldPressedPosition = 0;-
1809 if (d->pressedIndex != -1) {
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1810 // Record the position of the pressed tab before reordering the tabs.-
1811 oldPressedPosition = vertical ? d->tabList[d->pressedIndex].rect.y()
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1812 : d->tabList[d->pressedIndex].rect.x();-
1813 }
never executed: end of block
0
1814-
1815 // Update the locations of the tabs first-
1816 int start = qMin(from, to);-
1817 int end = qMax(from, to);-
1818 int width = vertical ? d->tabList[from].rect.height() : d->tabList[from].rect.width();
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1819 if (from < to)
from < toDescription
TRUEnever evaluated
FALSEnever evaluated
0
1820 width *= -1;
never executed: width *= -1;
0
1821 bool rtl = isRightToLeft();-
1822 for (int i = start; i <= end; ++i) {
i <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
1823 if (i == from)
i == fromDescription
TRUEnever evaluated
FALSEnever evaluated
0
1824 continue;
never executed: continue;
0
1825 if (vertical)
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1826 d->tabList[i].rect.moveTop(d->tabList[i].rect.y() + width);
never executed: d->tabList[i].rect.moveTop(d->tabList[i].rect.y() + width);
0
1827 else-
1828 d->tabList[i].rect.moveLeft(d->tabList[i].rect.x() + width);
never executed: d->tabList[i].rect.moveLeft(d->tabList[i].rect.x() + width);
0
1829 int direction = -1;-
1830 if (rtl && !vertical)
rtlDescription
TRUEnever evaluated
FALSEnever evaluated
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1831 direction *= -1;
never executed: direction *= -1;
0
1832 if (d->tabList[i].dragOffset != 0)
d->tabList[i].dragOffset != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1833 d->tabList[i].dragOffset += (direction * width);
never executed: d->tabList[i].dragOffset += (direction * width);
0
1834 }
never executed: end of block
0
1835-
1836 if (vertical) {
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1837 if (from < to)
from < toDescription
TRUEnever evaluated
FALSEnever evaluated
0
1838 d->tabList[from].rect.moveTop(d->tabList[to].rect.bottom() + 1);
never executed: d->tabList[from].rect.moveTop(d->tabList[to].rect.bottom() + 1);
0
1839 else-
1840 d->tabList[from].rect.moveTop(d->tabList[to].rect.top() - width);
never executed: d->tabList[from].rect.moveTop(d->tabList[to].rect.top() - width);
0
1841 } else {-
1842 if (from < to)
from < toDescription
TRUEnever evaluated
FALSEnever evaluated
0
1843 d->tabList[from].rect.moveLeft(d->tabList[to].rect.right() + 1);
never executed: d->tabList[from].rect.moveLeft(d->tabList[to].rect.right() + 1);
0
1844 else-
1845 d->tabList[from].rect.moveLeft(d->tabList[to].rect.left() - width);
never executed: d->tabList[from].rect.moveLeft(d->tabList[to].rect.left() - width);
0
1846 }-
1847-
1848 // Move the actual data structures-
1849 d->tabList.move(from, to);-
1850-
1851 // update lastTab locations-
1852 for (int i = 0; i < d->tabList.count(); ++i)
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1853 d->tabList[i].lastTab = d->calculateNewPosition(from, to, d->tabList[i].lastTab);
never executed: d->tabList[i].lastTab = d->calculateNewPosition(from, to, d->tabList[i].lastTab);
0
1854-
1855 // update external variables-
1856 int previousIndex = d->currentIndex;-
1857 d->currentIndex = d->calculateNewPosition(from, to, d->currentIndex);-
1858-
1859 // If we are in the middle of a drag update the dragStartPosition-
1860 if (d->pressedIndex != -1) {
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1861 d->pressedIndex = d->calculateNewPosition(from, to, d->pressedIndex);-
1862 int newPressedPosition = vertical ? d->tabList[d->pressedIndex].rect.top() : d->tabList[d->pressedIndex].rect.left();
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1863 int diff = oldPressedPosition - newPressedPosition;-
1864 if (isRightToLeft() && !vertical)
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1865 diff *= -1;
never executed: diff *= -1;
0
1866 if (vertical)
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1867 d->dragStartPosition.setY(d->dragStartPosition.y() - diff);
never executed: d->dragStartPosition.setY(d->dragStartPosition.y() - diff);
0
1868 else-
1869 d->dragStartPosition.setX(d->dragStartPosition.x() - diff);
never executed: d->dragStartPosition.setX(d->dragStartPosition.x() - diff);
0
1870 }-
1871-
1872 d->layoutWidgets(start);-
1873 update();-
1874 emit tabMoved(from, to);-
1875 if (previousIndex != d->currentIndex)
previousIndex ...->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1876 emit currentChanged(d->currentIndex);
never executed: currentChanged(d->currentIndex);
0
1877 emit tabLayoutChange();-
1878}
never executed: end of block
0
1879-
1880void QTabBarPrivate::slide(int from, int to)-
1881{-
1882 Q_Q(QTabBar);-
1883 if (from == to
from == toDescription
TRUEnever evaluated
FALSEnever evaluated
0
1884 || !validIndex(from)
!validIndex(from)Description
TRUEnever evaluated
FALSEnever evaluated
0
1885 || !validIndex(to))
!validIndex(to)Description
TRUEnever evaluated
FALSEnever evaluated
0
1886 return;
never executed: return;
0
1887 bool vertical = verticalTabs(shape);-
1888 int preLocation = vertical ? q->tabRect(from).y() : q->tabRect(from).x();
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1889 q->setUpdatesEnabled(false);-
1890 q->moveTab(from, to);-
1891 q->setUpdatesEnabled(true);-
1892 int postLocation = vertical ? q->tabRect(to).y() : q->tabRect(to).x();
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1893 int length = postLocation - preLocation;-
1894 tabList[to].dragOffset -= length;-
1895 tabList[to].startAnimation(this, ANIMATION_DURATION);-
1896}
never executed: end of block
0
1897-
1898void QTabBarPrivate::moveTab(int index, int offset)-
1899{-
1900 if (!validIndex(index))
!validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1901 return;
never executed: return;
0
1902 tabList[index].dragOffset = offset;-
1903 layoutTab(index); // Make buttons follow tab-
1904 q_func()->update();-
1905}
never executed: end of block
0
1906-
1907/*!\reimp-
1908*/-
1909void QTabBar::mousePressEvent(QMouseEvent *event)-
1910{-
1911 Q_D(QTabBar);-
1912-
1913 const QPoint pos = event->pos();-
1914 const bool isEventInCornerButtons = (!d->leftB->isHidden() && d->leftB->geometry().contains(pos))
!d->leftB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
d->leftB->geom....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
1915 || (!d->rightB->isHidden() && d->rightB->geometry().contains(pos));
!d->rightB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
d->rightB->geo....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
1916 if (!isEventInCornerButtons) {
!isEventInCornerButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1917 const int index = d->indexAtPos(pos);-
1918 emit tabBarClicked(index);-
1919 }
never executed: end of block
0
1920-
1921 if (event->button() != Qt::LeftButton) {
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1922 event->ignore();-
1923 return;
never executed: return;
0
1924 }-
1925 // Be safe!-
1926 if (d->pressedIndex != -1 && d->movable)
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1927 d->moveTabFinished(d->pressedIndex);
never executed: d->moveTabFinished(d->pressedIndex);
0
1928-
1929 d->pressedIndex = d->indexAtPos(event->pos());-
1930#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1931 d->previousPressedIndex = d->pressedIndex;-
1932#endif-
1933 if (d->validIndex(d->pressedIndex)) {
d->validIndex(d->pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
1934 QStyleOptionTabBarBase optTabBase;-
1935 optTabBase.init(this);-
1936 optTabBase.documentMode = d->documentMode;-
1937 if (event->type() == style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this))
event->type() ...TabBase, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
1938 setCurrentIndex(d->pressedIndex);
never executed: setCurrentIndex(d->pressedIndex);
0
1939 else-
1940 repaint(tabRect(d->pressedIndex));
never executed: repaint(tabRect(d->pressedIndex));
0
1941 if (d->movable) {
d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1942 d->dragStartPosition = event->pos();-
1943 }
never executed: end of block
0
1944 }
never executed: end of block
0
1945}
never executed: end of block
0
1946-
1947/*!\reimp-
1948 */-
1949void QTabBar::mouseMoveEvent(QMouseEvent *event)-
1950{-
1951 Q_D(QTabBar);-
1952 if (d->movable) {
d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1953 // Be safe!-
1954 if (d->pressedIndex != -1
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1955 && event->buttons() == Qt::NoButton)
event->buttons...= Qt::NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1956 d->moveTabFinished(d->pressedIndex);
never executed: d->moveTabFinished(d->pressedIndex);
0
1957-
1958 // Start drag-
1959 if (!d->dragInProgress && d->pressedIndex != -1) {
!d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1960 if ((event->pos() - d->dragStartPosition).manhattanLength() > QApplication::startDragDistance()) {
(event->pos() ...DragDistance()Description
TRUEnever evaluated
FALSEnever evaluated
0
1961 d->dragInProgress = true;-
1962 d->setupMovableTab();-
1963 }
never executed: end of block
0
1964 }
never executed: end of block
0
1965-
1966 if (event->buttons() == Qt::LeftButton
event->buttons...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1967 && d->dragInProgress
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
0
1968 && d->validIndex(d->pressedIndex)) {
d->validIndex(d->pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
1969 bool vertical = verticalTabs(d->shape);-
1970 int dragDistance;-
1971 if (vertical) {
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1972 dragDistance = (event->pos().y() - d->dragStartPosition.y());-
1973 } else {
never executed: end of block
0
1974 dragDistance = (event->pos().x() - d->dragStartPosition.x());-
1975 }
never executed: end of block
0
1976 d->tabList[d->pressedIndex].dragOffset = dragDistance;-
1977-
1978 QRect startingRect = tabRect(d->pressedIndex);-
1979 if (vertical)
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1980 startingRect.moveTop(startingRect.y() + dragDistance);
never executed: startingRect.moveTop(startingRect.y() + dragDistance);
0
1981 else-
1982 startingRect.moveLeft(startingRect.x() + dragDistance);
never executed: startingRect.moveLeft(startingRect.x() + dragDistance);
0
1983-
1984 int overIndex;-
1985 if (dragDistance < 0)
dragDistance < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1986 overIndex = tabAt(startingRect.topLeft());
never executed: overIndex = tabAt(startingRect.topLeft());
0
1987 else-
1988 overIndex = tabAt(startingRect.topRight());
never executed: overIndex = tabAt(startingRect.topRight());
0
1989-
1990 if (overIndex != d->pressedIndex && overIndex != -1) {
overIndex != d->pressedIndexDescription
TRUEnever evaluated
FALSEnever evaluated
overIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1991 int offset = 1;-
1992 if (isRightToLeft() && !vertical)
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1993 offset *= -1;
never executed: offset *= -1;
0
1994 if (dragDistance < 0) {
dragDistance < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1995 dragDistance *= -1;-
1996 offset *= -1;-
1997 }
never executed: end of block
0
1998 for (int i = d->pressedIndex;-
1999 offset > 0 ? i < overIndex : i > overIndex;
offset > 0 ? i... i > overIndexDescription
TRUEnever evaluated
FALSEnever evaluated
offset > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2000 i += offset) {-
2001 QRect overIndexRect = tabRect(overIndex);-
2002 int needsToBeOver = (vertical ? overIndexRect.height() : overIndexRect.width()) / 2;
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2003 if (dragDistance > needsToBeOver)
dragDistance > needsToBeOverDescription
TRUEnever evaluated
FALSEnever evaluated
0
2004 d->slide(i + offset, d->pressedIndex);
never executed: d->slide(i + offset, d->pressedIndex);
0
2005 }
never executed: end of block
0
2006 }
never executed: end of block
0
2007 // Buttons needs to follow the dragged tab-
2008 d->layoutTab(d->pressedIndex);-
2009-
2010 update();-
2011 }
never executed: end of block
0
2012#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
2013 } else if (!d->documentMode && event->buttons() == Qt::LeftButton && d->previousPressedIndex != -1) {-
2014 int newPressedIndex = d->indexAtPos(event->pos());-
2015 if (d->pressedIndex == -1 && d->previousPressedIndex == newPressedIndex) {-
2016 d->pressedIndex = d->previousPressedIndex;-
2017 update(tabRect(d->pressedIndex));-
2018 } else if(d->pressedIndex != newPressedIndex) {-
2019 d->pressedIndex = -1;-
2020 update(tabRect(d->previousPressedIndex));-
2021 }-
2022#endif-
2023 }
never executed: end of block
0
2024-
2025 if (event->buttons() != Qt::LeftButton) {
event->buttons...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
2026 event->ignore();-
2027 return;
never executed: return;
0
2028 }-
2029}
never executed: end of block
0
2030-
2031void QTabBarPrivate::setupMovableTab()-
2032{-
2033 Q_Q(QTabBar);-
2034 if (!movingTab)
!movingTabDescription
TRUEnever evaluated
FALSEnever evaluated
0
2035 movingTab = new QMovableTabWidget(q);
never executed: movingTab = new QMovableTabWidget(q);
0
2036-
2037 int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q);-
2038 QRect grabRect = q->tabRect(pressedIndex);-
2039 grabRect.adjust(-taboverlap, 0, taboverlap, 0);-
2040-
2041 QPixmap grabImage(grabRect.size() * q->devicePixelRatioF());-
2042 grabImage.setDevicePixelRatio(q->devicePixelRatioF());-
2043 grabImage.fill(Qt::transparent);-
2044 QStylePainter p(&grabImage, q);-
2045 p.initFrom(q);-
2046-
2047 QStyleOptionTab tab;-
2048 q->initStyleOption(&tab, pressedIndex);-
2049 tab.rect.moveTopLeft(QPoint(taboverlap, 0));-
2050 p.drawControl(QStyle::CE_TabBarTab, tab);-
2051 p.end();-
2052-
2053 movingTab->setPixmap(grabImage);-
2054 movingTab->setGeometry(grabRect);-
2055 movingTab->raise();-
2056-
2057 // Re-arrange widget order to avoid overlaps-
2058 if (tabList[pressedIndex].leftWidget)
tabList[presse...ex].leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2059 tabList[pressedIndex].leftWidget->raise();
never executed: tabList[pressedIndex].leftWidget->raise();
0
2060 if (tabList[pressedIndex].rightWidget)
tabList[presse...x].rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2061 tabList[pressedIndex].rightWidget->raise();
never executed: tabList[pressedIndex].rightWidget->raise();
0
2062 if (leftB)
leftBDescription
TRUEnever evaluated
FALSEnever evaluated
0
2063 leftB->raise();
never executed: leftB->raise();
0
2064 if (rightB)
rightBDescription
TRUEnever evaluated
FALSEnever evaluated
0
2065 rightB->raise();
never executed: rightB->raise();
0
2066 movingTab->setVisible(true);-
2067}
never executed: end of block
0
2068-
2069void QTabBarPrivate::moveTabFinished(int index)-
2070{-
2071 Q_Q(QTabBar);-
2072 bool cleanup = (pressedIndex == index) || (pressedIndex == -1) || !validIndex(index);
(pressedIndex == index)Description
TRUEnever evaluated
FALSEnever evaluated
(pressedIndex == -1)Description
TRUEnever evaluated
FALSEnever evaluated
!validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2073 bool allAnimationsFinished = true;-
2074#ifndef QT_NO_ANIMATION-
2075 for(int i = 0; allAnimationsFinished && i < tabList.count(); ++i) {
allAnimationsFinishedDescription
TRUEnever evaluated
FALSEnever evaluated
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2076 const Tab &t = tabList.at(i);-
2077 if (t.animation && t.animation->state() == QAbstractAnimation::Running)
t.animationDescription
TRUEnever evaluated
FALSEnever evaluated
t.animation->s...ation::RunningDescription
TRUEnever evaluated
FALSEnever evaluated
0
2078 allAnimationsFinished = false;
never executed: allAnimationsFinished = false;
0
2079 }
never executed: end of block
0
2080#endif //QT_NO_ANIMATION-
2081 if (allAnimationsFinished && cleanup) {
allAnimationsFinishedDescription
TRUEnever evaluated
FALSEnever evaluated
cleanupDescription
TRUEnever evaluated
FALSEnever evaluated
0
2082 if(movingTab)
movingTabDescription
TRUEnever evaluated
FALSEnever evaluated
0
2083 movingTab->setVisible(false); // We might not get a mouse release
never executed: movingTab->setVisible(false);
0
2084 for (int i = 0; i < tabList.count(); ++i) {
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2085 tabList[i].dragOffset = 0;-
2086 }
never executed: end of block
0
2087 if (pressedIndex != -1 && movable) {
pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
movableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2088 pressedIndex = -1;-
2089 dragInProgress = false;-
2090 dragStartPosition = QPoint();-
2091 }
never executed: end of block
0
2092 layoutWidgets();-
2093 } else {
never executed: end of block
0
2094 if (!validIndex(index))
!validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2095 return;
never executed: return;
0
2096 tabList[index].dragOffset = 0;-
2097 }
never executed: end of block
0
2098 q->update();-
2099}
never executed: end of block
0
2100-
2101/*!\reimp-
2102*/-
2103void QTabBar::mouseReleaseEvent(QMouseEvent *event)-
2104{-
2105 Q_D(QTabBar);-
2106 if (event->button() != Qt::LeftButton) {
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
2107 event->ignore();-
2108 return;
never executed: return;
0
2109 }-
2110#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
2111 d->previousPressedIndex = -1;-
2112#endif-
2113 if (d->movable && d->dragInProgress && d->validIndex(d->pressedIndex)) {
d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
d->validIndex(d->pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
2114 int length = d->tabList[d->pressedIndex].dragOffset;-
2115 int width = verticalTabs(d->shape)
verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
0
2116 ? tabRect(d->pressedIndex).height()-
2117 : tabRect(d->pressedIndex).width();-
2118 int duration = qMin(ANIMATION_DURATION,-
2119 (qAbs(length) * ANIMATION_DURATION) / width);-
2120 d->tabList[d->pressedIndex].startAnimation(d, duration);-
2121 d->dragInProgress = false;-
2122 d->movingTab->setVisible(false);-
2123 d->dragStartPosition = QPoint();-
2124 }
never executed: end of block
0
2125-
2126 int i = d->indexAtPos(event->pos()) == d->pressedIndex ? d->pressedIndex : -1;
d->indexAtPos(...->pressedIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
2127 d->pressedIndex = -1;-
2128 QStyleOptionTabBarBase optTabBase;-
2129 optTabBase.initFrom(this);-
2130 optTabBase.documentMode = d->documentMode;-
2131 if (style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this) == QEvent::MouseButtonRelease)
style()->style...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
2132 setCurrentIndex(i);
never executed: setCurrentIndex(i);
0
2133}
never executed: end of block
0
2134-
2135/*!\reimp-
2136 */-
2137void QTabBar::keyPressEvent(QKeyEvent *event)-
2138{-
2139 Q_D(QTabBar);-
2140 if (event->key() != Qt::Key_Left && event->key() != Qt::Key_Right) {
event->key() != Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
event->key() != Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2141 event->ignore();-
2142 return;
never executed: return;
0
2143 }-
2144 int offset = event->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1;
event->key() =... Qt::Key_Left)Description
TRUEnever evaluated
FALSEnever evaluated
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
2145 d->setCurrentNextEnabledIndex(offset);-
2146}
never executed: end of block
0
2147-
2148/*!\reimp-
2149 */-
2150#ifndef QT_NO_WHEELEVENT-
2151void QTabBar::wheelEvent(QWheelEvent *event)-
2152{-
2153#ifndef Q_OS_MAC-
2154 Q_D(QTabBar);-
2155 int offset = event->delta() > 0 ? -1 : 1;
event->delta() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2156 d->setCurrentNextEnabledIndex(offset);-
2157 QWidget::wheelEvent(event);-
2158#else-
2159 Q_UNUSED(event)-
2160#endif-
2161}
never executed: end of block
0
2162#endif //QT_NO_WHEELEVENT-
2163-
2164void QTabBarPrivate::setCurrentNextEnabledIndex(int offset)-
2165{-
2166 Q_Q(QTabBar);-
2167 for (int index = currentIndex + offset; validIndex(index); index += offset) {
validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2168 if (tabList.at(index).enabled) {
tabList.at(index).enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2169 q->setCurrentIndex(index);-
2170 break;
never executed: break;
0
2171 }-
2172 }
never executed: end of block
0
2173}
never executed: end of block
0
2174-
2175/*!\reimp-
2176 */-
2177void QTabBar::changeEvent(QEvent *event)-
2178{-
2179 Q_D(QTabBar);-
2180 switch (event->type()) {-
2181 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
2182 if (!d->elideModeSetByUser)
!d->elideModeSetByUserDescription
TRUEnever evaluated
FALSEnever evaluated
0
2183 d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this));
never executed: d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this));
0
2184 if (!d->useScrollButtonsSetByUser)
!d->useScrollButtonsSetByUserDescription
TRUEnever evaluated
FALSEnever evaluated
0
2185 d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this);
never executed: d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this);
0
2186 // fallthrough-
2187 case QEvent::FontChange:
code before this statement never executed: case QEvent::FontChange:
never executed: case QEvent::FontChange:
0
2188 d->textSizes.clear();-
2189 d->refresh();-
2190 break;
never executed: break;
0
2191 default:
never executed: default:
0
2192 break;
never executed: break;
0
2193 }-
2194-
2195 QWidget::changeEvent(event);-
2196}
never executed: end of block
0
2197-
2198/*!-
2199 \reimp-
2200*/-
2201void QTabBar::timerEvent(QTimerEvent *event)-
2202{-
2203 Q_D(QTabBar);-
2204 if (event->timerId() == d->switchTabTimerId) {
event->timerId...itchTabTimerIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
2205 killTimer(d->switchTabTimerId);-
2206 d->switchTabTimerId = 0;-
2207 setCurrentIndex(d->switchTabCurrentIndex);-
2208 d->switchTabCurrentIndex = -1;-
2209 }
never executed: end of block
0
2210 QWidget::timerEvent(event);-
2211}
never executed: end of block
0
2212-
2213/*!-
2214 \property QTabBar::elideMode-
2215 \brief how to elide text in the tab bar-
2216 \since 4.2-
2217-
2218 This property controls how items are elided when there is not-
2219 enough space to show them for a given tab bar size.-
2220-
2221 By default the value is style dependent.-
2222-
2223 \sa QTabWidget::elideMode, usesScrollButtons, QStyle::SH_TabBar_ElideMode-
2224*/-
2225-
2226Qt::TextElideMode QTabBar::elideMode() const-
2227{-
2228 Q_D(const QTabBar);-
2229 return d->elideMode;
never executed: return d->elideMode;
0
2230}-
2231-
2232void QTabBar::setElideMode(Qt::TextElideMode mode)-
2233{-
2234 Q_D(QTabBar);-
2235 d->elideMode = mode;-
2236 d->elideModeSetByUser = true;-
2237 d->textSizes.clear();-
2238 d->refresh();-
2239}
never executed: end of block
0
2240-
2241/*!-
2242 \property QTabBar::usesScrollButtons-
2243 \brief Whether or not a tab bar should use buttons to scroll tabs when it-
2244 has many tabs.-
2245 \since 4.2-
2246-
2247 When there are too many tabs in a tab bar for its size, the tab bar can either choose-
2248 to expand its size or to add buttons that allow you to scroll through the tabs.-
2249-
2250 By default the value is style dependant.-
2251-
2252 \sa elideMode, QTabWidget::usesScrollButtons, QStyle::SH_TabBar_PreferNoArrows-
2253*/-
2254bool QTabBar::usesScrollButtons() const-
2255{-
2256 return d_func()->useScrollButtons;
never executed: return d_func()->useScrollButtons;
0
2257}-
2258-
2259void QTabBar::setUsesScrollButtons(bool useButtons)-
2260{-
2261 Q_D(QTabBar);-
2262 d->useScrollButtonsSetByUser = true;-
2263 if (d->useScrollButtons == useButtons)
d->useScrollBu... == useButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2264 return;
never executed: return;
0
2265 d->useScrollButtons = useButtons;-
2266 d->refresh();-
2267}
never executed: end of block
0
2268-
2269/*!-
2270 \property QTabBar::tabsClosable-
2271 \brief Whether or not a tab bar should place close buttons on each tab-
2272 \since 4.5-
2273-
2274 When tabsClosable is set to true a close button will appear on the tab on-
2275 either the left or right hand side depending upon the style. When the button-
2276 is clicked the tab the signal tabCloseRequested will be emitted.-
2277-
2278 By default the value is false.-
2279-
2280 \sa setTabButton(), tabRemoved()-
2281*/-
2282-
2283bool QTabBar::tabsClosable() const-
2284{-
2285 Q_D(const QTabBar);-
2286 return d->closeButtonOnTabs;
never executed: return d->closeButtonOnTabs;
0
2287}-
2288-
2289void QTabBar::setTabsClosable(bool closable)-
2290{-
2291 Q_D(QTabBar);-
2292 if (d->closeButtonOnTabs == closable)
d->closeButton...bs == closableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2293 return;
never executed: return;
0
2294 d->closeButtonOnTabs = closable;-
2295 ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this);-
2296 if (!closable) {
!closableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2297 for (int i = 0; i < d->tabList.count(); ++i) {
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2298 if (closeSide == LeftSide && d->tabList[i].leftWidget) {
closeSide == LeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
d->tabList[i].leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2299 d->tabList[i].leftWidget->deleteLater();-
2300 d->tabList[i].leftWidget = 0;-
2301 }
never executed: end of block
0
2302 if (closeSide == RightSide && d->tabList[i].rightWidget) {
closeSide == RightSideDescription
TRUEnever evaluated
FALSEnever evaluated
d->tabList[i].rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2303 d->tabList[i].rightWidget->deleteLater();-
2304 d->tabList[i].rightWidget = 0;-
2305 }
never executed: end of block
0
2306 }
never executed: end of block
0
2307 } else {
never executed: end of block
0
2308 bool newButtons = false;-
2309 for (int i = 0; i < d->tabList.count(); ++i) {
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2310 if (tabButton(i, closeSide))
tabButton(i, closeSide)Description
TRUEnever evaluated
FALSEnever evaluated
0
2311 continue;
never executed: continue;
0
2312 newButtons = true;-
2313 QAbstractButton *closeButton = new CloseButton(this);-
2314 connect(closeButton, SIGNAL(clicked()), this, SLOT(_q_closeTab()));-
2315 setTabButton(i, closeSide, closeButton);-
2316 }
never executed: end of block
0
2317 if (newButtons)
newButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2318 d->layoutTabs();
never executed: d->layoutTabs();
0
2319 }
never executed: end of block
0
2320 update();-
2321}
never executed: end of block
0
2322-
2323/*!-
2324 \enum QTabBar::ButtonPosition-
2325 \since 4.5-
2326-
2327 This enum type lists the location of the widget on a tab.-
2328-
2329 \value LeftSide Left side of the tab.-
2330-
2331 \value RightSide Right side of the tab.-
2332-
2333*/-
2334-
2335/*!-
2336 \enum QTabBar::SelectionBehavior-
2337 \since 4.5-
2338-
2339 This enum type lists the behavior of QTabBar when a tab is removed-
2340 and the tab being removed is also the current tab.-
2341-
2342 \value SelectLeftTab Select the tab to the left of the one being removed.-
2343-
2344 \value SelectRightTab Select the tab to the right of the one being removed.-
2345-
2346 \value SelectPreviousTab Select the previously selected tab.-
2347-
2348*/-
2349-
2350/*!-
2351 \property QTabBar::selectionBehaviorOnRemove-
2352 \brief What tab should be set as current when removeTab is called if-
2353 the removed tab is also the current tab.-
2354 \since 4.5-
2355-
2356 By default the value is SelectRightTab.-
2357-
2358 \sa removeTab()-
2359*/-
2360-
2361-
2362QTabBar::SelectionBehavior QTabBar::selectionBehaviorOnRemove() const-
2363{-
2364 Q_D(const QTabBar);-
2365 return d->selectionBehaviorOnRemove;
never executed: return d->selectionBehaviorOnRemove;
0
2366}-
2367-
2368void QTabBar::setSelectionBehaviorOnRemove(QTabBar::SelectionBehavior behavior)-
2369{-
2370 Q_D(QTabBar);-
2371 d->selectionBehaviorOnRemove = behavior;-
2372}
never executed: end of block
0
2373-
2374/*!-
2375 \property QTabBar::expanding-
2376 \brief When expanding is true QTabBar will expand the tabs to use the empty space.-
2377 \since 4.5-
2378-
2379 By default the value is true.-
2380-
2381 \sa QTabWidget::documentMode-
2382*/-
2383-
2384bool QTabBar::expanding() const-
2385{-
2386 Q_D(const QTabBar);-
2387 return d->expanding;
never executed: return d->expanding;
0
2388}-
2389-
2390void QTabBar::setExpanding(bool enabled)-
2391{-
2392 Q_D(QTabBar);-
2393 if (d->expanding == enabled)
d->expanding == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2394 return;
never executed: return;
0
2395 d->expanding = enabled;-
2396 d->layoutTabs();-
2397}
never executed: end of block
0
2398-
2399/*!-
2400 \property QTabBar::movable-
2401 \brief This property holds whether the user can move the tabs-
2402 within the tabbar area.-
2403-
2404 \since 4.5-
2405-
2406 By default, this property is \c false;-
2407*/-
2408-
2409bool QTabBar::isMovable() const-
2410{-
2411 Q_D(const QTabBar);-
2412 return d->movable;
never executed: return d->movable;
0
2413}-
2414-
2415void QTabBar::setMovable(bool movable)-
2416{-
2417 Q_D(QTabBar);-
2418 d->movable = movable;-
2419}
never executed: end of block
0
2420-
2421-
2422/*!-
2423 \property QTabBar::documentMode-
2424 \brief Whether or not the tab bar is rendered in a mode suitable for the main window.-
2425 \since 4.5-
2426-
2427 This property is used as a hint for styles to draw the tabs in a different-
2428 way then they would normally look in a tab widget. On \macos this will-
2429 look similar to the tabs in Safari or Leopard's Terminal.app.-
2430-
2431 \sa QTabWidget::documentMode-
2432*/-
2433bool QTabBar::documentMode() const-
2434{-
2435 return d_func()->documentMode;
never executed: return d_func()->documentMode;
0
2436}-
2437-
2438void QTabBar::setDocumentMode(bool enabled)-
2439{-
2440 Q_D(QTabBar);-
2441-
2442 d->documentMode = enabled;-
2443 d->updateMacBorderMetrics();-
2444}
never executed: end of block
0
2445-
2446/*!-
2447 \property QTabBar::autoHide-
2448 \brief If true, the tab bar is automatically hidden when it contains less-
2449 than 2 tabs.-
2450 \since 5.4-
2451-
2452 By default, this property is false.-
2453-
2454 \sa QWidget::visible-
2455*/-
2456-
2457bool QTabBar::autoHide() const-
2458{-
2459 Q_D(const QTabBar);-
2460 return d->autoHide;
never executed: return d->autoHide;
0
2461}-
2462-
2463void QTabBar::setAutoHide(bool hide)-
2464{-
2465 Q_D(QTabBar);-
2466 if (d->autoHide == hide)
d->autoHide == hideDescription
TRUEnever evaluated
FALSEnever evaluated
0
2467 return;
never executed: return;
0
2468-
2469 d->autoHide = hide;-
2470 if (hide)
hideDescription
TRUEnever evaluated
FALSEnever evaluated
0
2471 d->autoHideTabs();
never executed: d->autoHideTabs();
0
2472 else-
2473 setVisible(true);
never executed: setVisible(true);
0
2474}-
2475-
2476/*!-
2477 \property QTabBar::changeCurrentOnDrag-
2478 \brief If true, then the current tab is automatically changed when dragging-
2479 over the tabbar.-
2480 \since 5.4-
2481-
2482 \note You should also set acceptDrops property to true to make this feature-
2483 work.-
2484-
2485 By default, this property is false.-
2486*/-
2487-
2488bool QTabBar::changeCurrentOnDrag() const-
2489{-
2490 Q_D(const QTabBar);-
2491 return d->changeCurrentOnDrag;
never executed: return d->changeCurrentOnDrag;
0
2492}-
2493-
2494void QTabBar::setChangeCurrentOnDrag(bool change)-
2495{-
2496 Q_D(QTabBar);-
2497 d->changeCurrentOnDrag = change;-
2498 if (!change)
!changeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2499 d->killSwitchTabTimer();
never executed: d->killSwitchTabTimer();
0
2500}
never executed: end of block
0
2501-
2502/*!-
2503 Sets \a widget on the tab \a index. The widget is placed-
2504 on the left or right hand side depending upon the \a position.-
2505 \since 4.5-
2506-
2507 Any previously set widget in \a position is hidden.-
2508-
2509 The tab bar will take ownership of the widget and so all widgets set here-
2510 will be deleted by the tab bar when it is destroyed unless you separately-
2511 reparent the widget after setting some other widget (or 0).-
2512-
2513 \sa tabsClosable()-
2514 */-
2515void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget)-
2516{-
2517 Q_D(QTabBar);-
2518 if (index < 0 || index >= d->tabList.count())
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
index >= d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2519 return;
never executed: return;
0
2520 if (widget) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2521 widget->setParent(this);-
2522 // make sure our left and right widgets stay on top-
2523 widget->lower();-
2524 widget->show();-
2525 }
never executed: end of block
0
2526 if (position == LeftSide) {
position == LeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
0
2527 if (d->tabList[index].leftWidget)
d->tabList[index].leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2528 d->tabList[index].leftWidget->hide();
never executed: d->tabList[index].leftWidget->hide();
0
2529 d->tabList[index].leftWidget = widget;-
2530 } else {
never executed: end of block
0
2531 if (d->tabList[index].rightWidget)
d->tabList[index].rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2532 d->tabList[index].rightWidget->hide();
never executed: d->tabList[index].rightWidget->hide();
0
2533 d->tabList[index].rightWidget = widget;-
2534 }
never executed: end of block
0
2535 d->layoutTabs();-
2536 d->refresh();-
2537 update();-
2538}
never executed: end of block
0
2539-
2540/*!-
2541 Returns the widget set a tab \a index and \a position or 0 if-
2542 one is not set.-
2543 */-
2544QWidget *QTabBar::tabButton(int index, ButtonPosition position) const-
2545{-
2546 Q_D(const QTabBar);-
2547 if (index < 0 || index >= d->tabList.count())
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
index >= d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2548 return 0;
never executed: return 0;
0
2549 if (position == LeftSide)
position == LeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
0
2550 return d->tabList.at(index).leftWidget;
never executed: return d->tabList.at(index).leftWidget;
0
2551 else-
2552 return d->tabList.at(index).rightWidget;
never executed: return d->tabList.at(index).rightWidget;
0
2553}-
2554-
2555CloseButton::CloseButton(QWidget *parent)-
2556 : QAbstractButton(parent)-
2557{-
2558 setFocusPolicy(Qt::NoFocus);-
2559#ifndef QT_NO_CURSOR-
2560 setCursor(Qt::ArrowCursor);-
2561#endif-
2562#ifndef QT_NO_TOOLTIP-
2563 setToolTip(tr("Close Tab"));-
2564#endif-
2565 resize(sizeHint());-
2566}
never executed: end of block
0
2567-
2568QSize CloseButton::sizeHint() const-
2569{-
2570 ensurePolished();-
2571 int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this);-
2572 int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, this);-
2573 return QSize(width, height);
never executed: return QSize(width, height);
0
2574}-
2575-
2576void CloseButton::enterEvent(QEvent *event)-
2577{-
2578 if (isEnabled())
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2579 update();
never executed: update();
0
2580 QAbstractButton::enterEvent(event);-
2581}
never executed: end of block
0
2582-
2583void CloseButton::leaveEvent(QEvent *event)-
2584{-
2585 if (isEnabled())
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2586 update();
never executed: update();
0
2587 QAbstractButton::leaveEvent(event);-
2588}
never executed: end of block
0
2589-
2590void CloseButton::paintEvent(QPaintEvent *)-
2591{-
2592 QPainter p(this);-
2593 QStyleOption opt;-
2594 opt.init(this);-
2595 opt.state |= QStyle::State_AutoRaise;-
2596 if (isEnabled() && underMouse() && !isChecked() && !isDown())
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
!isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
!isDown()Description
TRUEnever evaluated
FALSEnever evaluated
0
2597 opt.state |= QStyle::State_Raised;
never executed: opt.state |= QStyle::State_Raised;
0
2598 if (isChecked())
isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
0
2599 opt.state |= QStyle::State_On;
never executed: opt.state |= QStyle::State_On;
0
2600 if (isDown())
isDown()Description
TRUEnever evaluated
FALSEnever evaluated
0
2601 opt.state |= QStyle::State_Sunken;
never executed: opt.state |= QStyle::State_Sunken;
0
2602-
2603 if (const QTabBar *tb = qobject_cast<const QTabBar *>(parent())) {
const QTabBar ...r *>(parent())Description
TRUEnever evaluated
FALSEnever evaluated
0
2604 int index = tb->currentIndex();-
2605 QTabBar::ButtonPosition position = (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb);-
2606 if (tb->tabButton(index, position) == this)
tb->tabButton(...ition) == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2607 opt.state |= QStyle::State_Selected;
never executed: opt.state |= QStyle::State_Selected;
0
2608 }
never executed: end of block
0
2609-
2610 style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this);-
2611}
never executed: end of block
0
2612-
2613#ifndef QT_NO_ANIMATION-
2614void QTabBarPrivate::Tab::TabBarAnimation::updateCurrentValue(const QVariant &current)-
2615{-
2616 priv->moveTab(priv->tabList.indexOf(*tab), current.toInt());-
2617}
never executed: end of block
0
2618-
2619void QTabBarPrivate::Tab::TabBarAnimation::updateState(QAbstractAnimation::State, QAbstractAnimation::State newState)-
2620{-
2621 if (newState == Stopped) priv->moveTabFinished(priv->tabList.indexOf(*tab));
never executed: priv->moveTabFinished(priv->tabList.indexOf(*tab));
newState == StoppedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2622}
never executed: end of block
0
2623#endif-
2624-
2625QT_END_NAMESPACE-
2626-
2627#include "moc_qtabbar.cpp"-
2628-
2629#endif // QT_NO_TABBAR-
2630-
2631#include "moc_qtabbar_p.cpp"-
Source codeSwitch to Preprocessed file

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