qtabbar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtabbar.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9QMovableTabWidget::QMovableTabWidget(QWidget *parent)-
10 : QWidget(parent)-
11{-
12}
never executed: end of block
0
13-
14void QMovableTabWidget::setPixmap(const QPixmap &pixmap)-
15{-
16 m_pixmap = pixmap;-
17 update();-
18}
never executed: end of block
0
19-
20void QMovableTabWidget::paintEvent(QPaintEvent *e)-
21{-
22 (void)e;;-
23 QPainter p(this);-
24 p.drawPixmap(0, 0, m_pixmap);-
25}
never executed: end of block
0
26-
27inline static bool verticalTabs(QTabBar::Shape shape)-
28{-
29 return
never executed: return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast;
shape == QTabBar::RoundedWest
never executed: return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast;
0
30 || shape == QTabBar::RoundedEast
never executed: return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast;
0
31 || shape == QTabBar::TriangularWest
never executed: return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast;
0
32 || shape == QTabBar::TriangularEast;
never executed: return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast;
0
33}-
34-
35void QTabBarPrivate::updateMacBorderMetrics()-
36{-
37}-
38-
39-
40-
41-
42-
43-
44-
45void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex) const-
46{-
47 const QTabBar * const q = q_func();-
48 const int totalTabs = tabList.size();-
49-
50 if (!option
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
|| (tabIndex < 0
tabIndex < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| tabIndex >= totalTabs
tabIndex >= totalTabsDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
51 return;
never executed: return;
0
52-
53 const QTabBarPrivate::Tab &tab = tabList.at(tabIndex);-
54 option->initFrom(q);-
55 option->state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);-
56 option->rect = q->tabRect(tabIndex);-
57 const bool isCurrent = tabIndex == currentIndex;-
58 option->row = 0;-
59 if (tabIndex == pressedIndex
tabIndex == pressedIndexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
60 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
61 if (isCurrent
isCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
62 option->state |= QStyle::State_Selected;
never executed: option->state |= QStyle::State_Selected;
0
63 if (isCurrent
isCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
&& q->hasFocus()
q->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
64 option->state |= QStyle::State_HasFocus;
never executed: option->state |= QStyle::State_HasFocus;
0
65 if (!tab.enabled
!tab.enabledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
66 option->state &= ~QStyle::State_Enabled;
never executed: option->state &= ~QStyle::State_Enabled;
0
67 if (q->isActiveWindow()
q->isActiveWindow()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
68 option->state |= QStyle::State_Active;
never executed: option->state |= QStyle::State_Active;
0
69 if (!dragInProgress
!dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
&& option->rect == hoverRect
option->rect == hoverRectDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
70 option->state |= QStyle::State_MouseOver;
never executed: option->state |= QStyle::State_MouseOver;
0
71 option->shape = shape;-
72 option->text = tab.text;-
73-
74 if (tab.textColor.isValid()
tab.textColor.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
75 option->palette.setColor(q->foregroundRole(), tab.textColor);
never executed: option->palette.setColor(q->foregroundRole(), tab.textColor);
0
76-
77-
78-
79-
80-
81-
82 option->icon = tab.icon;-
83 option->iconSize = q->iconSize();-
84-
85 option->leftButtonSize = tab.leftWidget
tab.leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
? tab.leftWidget->size() : QSize();
0
86 option->rightButtonSize = tab.rightWidget
tab.rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
? tab.rightWidget->size() : QSize();
0
87 option->documentMode = documentMode;-
88-
89 if (tabIndex > 0
tabIndex > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& tabIndex - 1 == currentIndex
tabIndex - 1 == currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
90 option->selectedPosition = QStyleOptionTab::PreviousIsSelected;
never executed: option->selectedPosition = QStyleOptionTab::PreviousIsSelected;
0
91 else if (tabIndex + 1 < totalTabs
tabIndex + 1 < totalTabsDescription
TRUEnever evaluated
FALSEnever evaluated
&& tabIndex + 1 == currentIndex
tabIndex + 1 == currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
92 option->selectedPosition = QStyleOptionTab::NextIsSelected;
never executed: option->selectedPosition = QStyleOptionTab::NextIsSelected;
0
93 else-
94 option->selectedPosition = QStyleOptionTab::NotAdjacent;
never executed: option->selectedPosition = QStyleOptionTab::NotAdjacent;
0
95-
96 const bool paintBeginning = (
(tabIndex == 0)Description
TRUEnever evaluated
FALSEnever evaluated
tabIndex == 0)
(tabIndex == 0)Description
TRUEnever evaluated
FALSEnever evaluated
|| (dragInProgress
dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
&& tabIndex == pressedIndex + 1
tabIndex == pressedIndex + 1Description
TRUEnever evaluated
FALSEnever evaluated
);
0
97 const bool paintEnd = (
(tabIndex == totalTabs - 1)Description
TRUEnever evaluated
FALSEnever evaluated
tabIndex == totalTabs - 1)
(tabIndex == totalTabs - 1)Description
TRUEnever evaluated
FALSEnever evaluated
|| (dragInProgress
dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
&& tabIndex == pressedIndex - 1
tabIndex == pressedIndex - 1Description
TRUEnever evaluated
FALSEnever evaluated
);
0
98 if (paintBeginning
paintBeginningDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
99 if (paintEnd
paintEndDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
100 option->position = QStyleOptionTab::OnlyOneTab;
never executed: option->position = QStyleOptionTab::OnlyOneTab;
0
101 else-
102 option->position = QStyleOptionTab::Beginning;
never executed: option->position = QStyleOptionTab::Beginning;
0
103 } else if (paintEnd
paintEndDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
104 option->position = QStyleOptionTab::End;-
105 }
never executed: end of block
else {
0
106 option->position = QStyleOptionTab::Middle;-
107 }
never executed: end of block
0
108-
109-
110 if (const
const QTabWidg...arentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
QTabWidget *tw = qobject_cast<const QTabWidget *>(q->parentWidget())
const QTabWidg...arentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
111 option->features |= QStyleOptionTab::HasFrame;-
112 if (tw->cornerWidget(Qt::TopLeftCorner)
tw->cornerWidg...TopLeftCorner)Description
TRUEnever evaluated
FALSEnever evaluated
|| tw->cornerWidget(Qt::BottomLeftCorner)
tw->cornerWidg...tomLeftCorner)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
113 option->cornerWidgets |= QStyleOptionTab::LeftCornerWidget;
never executed: option->cornerWidgets |= QStyleOptionTab::LeftCornerWidget;
0
114 if (tw->cornerWidget(Qt::TopRightCorner)
tw->cornerWidg...opRightCorner)Description
TRUEnever evaluated
FALSEnever evaluated
|| tw->cornerWidget(Qt::BottomRightCorner)
tw->cornerWidg...omRightCorner)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
115 option->cornerWidgets |= QStyleOptionTab::RightCornerWidget;
never executed: option->cornerWidgets |= QStyleOptionTab::RightCornerWidget;
0
116 }
never executed: end of block
0
117-
118}
never executed: end of block
0
119void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const-
120{-
121 const QTabBarPrivate * const d = d_func();-
122 d->initBasicStyleOption(option, tabIndex);-
123-
124 QRect textRect = style()->subElementRect(QStyle::SE_TabBarTabText, option, this);-
125 option->text = fontMetrics().elidedText(option->text, d->elideMode, textRect.width(),-
126 Qt::TextShowMnemonic);-
127}
never executed: end of block
0
128void QTabBarPrivate::init()-
129{-
130 QTabBar * const q = q_func();-
131 leftB = new QToolButton(q);-
132 leftB->setAutoRepeat(true);-
133 QObject::connect(leftB, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "396"), q, qFlagLocation("1""_q_scrollTabs()" "\0" __FILE__ ":" "396"));-
134 leftB->hide();-
135 rightB = new QToolButton(q);-
136 rightB->setAutoRepeat(true);-
137 QObject::connect(rightB, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "400"), q, qFlagLocation("1""_q_scrollTabs()" "\0" __FILE__ ":" "400"));-
138 rightB->hide();-
139-
140-
141-
142-
143-
144-
145-
146 q->setFocusPolicy(Qt::TabFocus);-
147-
148-
149 leftB->setAccessibleName(QTabBar::tr("Scroll Left"));-
150 rightB->setAccessibleName(QTabBar::tr("Scroll Right"));-
151-
152 q->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);-
153 elideMode = Qt::TextElideMode(q->style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, q));-
154 useScrollButtons = !q->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, q);-
155}
never executed: end of block
0
156-
157QTabBarPrivate::Tab *QTabBarPrivate::at(int index)-
158{-
159 return
never executed: return validIndex(index)?&tabList[index]:0;
validIndex(index)?&tabList[index]:0;
never executed: return validIndex(index)?&tabList[index]:0;
0
160}-
161-
162const QTabBarPrivate::Tab *QTabBarPrivate::at(int index) const-
163{-
164 return
never executed: return validIndex(index)?&tabList[index]:0;
validIndex(index)?&tabList[index]:0;
never executed: return validIndex(index)?&tabList[index]:0;
0
165}-
166-
167int QTabBarPrivate::indexAtPos(const QPoint &p) const-
168{-
169 const QTabBar * const q = q_func();-
170 if (q->tabRect(currentIndex).contains(p)
q->tabRect(cur...x).contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
171 return
never executed: return currentIndex;
currentIndex;
never executed: return currentIndex;
0
172 for (int i = 0; i < tabList.count()
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
173 if (tabList.at(i).enabled
tabList.at(i).enabledDescription
TRUEnever evaluated
FALSEnever evaluated
&& q->tabRect(i).contains(p)
q->tabRect(i).contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
174 return
never executed: return i;
i;
never executed: return i;
0
175 return
never executed: return -1;
-1;
never executed: return -1;
0
176}-
177-
178void QTabBarPrivate::layoutTabs()-
179{-
180 QTabBar * const q = q_func();-
181 layoutDirty = false;-
182 QSize size = q->size();-
183 int last, available;-
184 int maxExtent;-
185 int i;-
186 bool vertTabs = verticalTabs(shape);-
187 int tabChainIndex = 0;-
188-
189 Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, 0, q));-
190 QVector<QLayoutStruct> tabChain(tabList.count() + 2);-
191-
192-
193-
194 tabChain[tabChainIndex].init();-
195 tabChain[tabChainIndex].expansive = (
(tabAlignment ...Qt::AlignLeft)Description
TRUEnever evaluated
FALSEnever evaluated
tabAlignment != Qt::AlignLeft)
(tabAlignment ...Qt::AlignLeft)Description
TRUEnever evaluated
FALSEnever evaluated
0
196 && (
(tabAlignment ...:AlignJustify)Description
TRUEnever evaluated
FALSEnever evaluated
tabAlignment != Qt::AlignJustify)
(tabAlignment ...:AlignJustify)Description
TRUEnever evaluated
FALSEnever evaluated
;
0
197 tabChain[tabChainIndex].empty = true;-
198 ++tabChainIndex;-
199 if (!vertTabs
!vertTabsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
200 int minx = 0;-
201 int x = 0;-
202 int maxHeight = 0;-
203 for (i = 0; i < tabList.count()
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i, ++tabChainIndex) {
0
204 QSize sz = q->tabSizeHint(i);-
205 tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height());-
206 x += sz.width();-
207 maxHeight = qMax(maxHeight, sz.height());-
208 sz = q->minimumTabSizeHint(i);-
209 tabList[i].minRect = QRect(minx, 0, sz.width(), sz.height());-
210 minx += sz.width();-
211 tabChain[tabChainIndex].init();-
212 tabChain[tabChainIndex].sizeHint = tabList.at(i).maxRect.width();-
213 tabChain[tabChainIndex].minimumSize = sz.width();-
214 tabChain[tabChainIndex].empty = false;-
215 tabChain[tabChainIndex].expansive = true;-
216-
217 if (!expanding
!expandingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
218 tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
never executed: tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
0
219 }
never executed: end of block
0
220-
221 last = minx;-
222 available = size.width();-
223 maxExtent = maxHeight;-
224 }
never executed: end of block
else {
0
225 int miny = 0;-
226 int y = 0;-
227 int maxWidth = 0;-
228 for (i = 0; i < tabList.count()
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i, ++tabChainIndex) {
0
229 QSize sz = q->tabSizeHint(i);-
230 tabList[i].maxRect = QRect(0, y, sz.width(), sz.height());-
231 y += sz.height();-
232 maxWidth = qMax(maxWidth, sz.width());-
233 sz = q->minimumTabSizeHint(i);-
234 tabList[i].minRect = QRect(0, miny, sz.width(), sz.height());-
235 miny += sz.height();-
236 tabChain[tabChainIndex].init();-
237 tabChain[tabChainIndex].sizeHint = tabList.at(i).maxRect.height();-
238 tabChain[tabChainIndex].minimumSize = sz.height();-
239 tabChain[tabChainIndex].empty = false;-
240 tabChain[tabChainIndex].expansive = true;-
241-
242 if (!expanding
!expandingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
243 tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
never executed: tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
0
244 }
never executed: end of block
0
245-
246 last = miny;-
247 available = size.height();-
248 maxExtent = maxWidth;-
249 }
never executed: end of block
0
250-
251 ((!(tabChainIndex == tabChain.count() - 1)) ? qt_assert("tabChainIndex == tabChain.count() - 1",__FILE__,523) : qt_noop());-
252-
253 tabChain[tabChainIndex].init();-
254 tabChain[tabChainIndex].expansive = (
(tabAlignment ...t::AlignRight)Description
TRUEnever evaluated
FALSEnever evaluated
tabAlignment != Qt::AlignRight)
(tabAlignment ...t::AlignRight)Description
TRUEnever evaluated
FALSEnever evaluated
0
255 && (
(tabAlignment ...:AlignJustify)Description
TRUEnever evaluated
FALSEnever evaluated
tabAlignment != Qt::AlignJustify)
(tabAlignment ...:AlignJustify)Description
TRUEnever evaluated
FALSEnever evaluated
;
0
256 tabChain[tabChainIndex].empty = true;-
257-
258-
259 qGeomCalc(tabChain, 0, tabChain.count(), 0, qMax(available, last), 0);-
260-
261-
262 for (i = 0; i < tabList.count()
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
263 const QLayoutStruct &lstruct = tabChain.at(i + 1);-
264 if (!vertTabs
!vertTabsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
265 tabList[i].rect.setRect(lstruct.pos, 0, lstruct.size, maxExtent);
never executed: tabList[i].rect.setRect(lstruct.pos, 0, lstruct.size, maxExtent);
0
266 else-
267 tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size);
never executed: tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size);
0
268 }-
269-
270 if (useScrollButtons
useScrollButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
&& tabList.count()
tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
&& last > available
last > availableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
271 const QRect scrollRect = normalizedScrollRect(0);-
272 scrollOffset = -scrollRect.left();-
273-
274 QTabBar * const q = q_func();-
275 QStyleOption opt;-
276 opt.init(q);-
277 QRect scrollButtonLeftRect = q->style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, q);-
278 QRect scrollButtonRightRect = q->style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, q);-
279 int scrollButtonWidth = q->style()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, &opt, q);-
280-
281-
282-
283-
284 if (vertTabs
vertTabsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
285 scrollButtonLeftRect.setHeight(scrollButtonWidth);-
286 scrollButtonRightRect.setY(scrollButtonRightRect.bottom() + 1 - scrollButtonWidth);-
287 scrollButtonRightRect.setHeight(scrollButtonWidth);-
288 leftB->setArrowType(Qt::UpArrow);-
289 rightB->setArrowType(Qt::DownArrow);-
290 }
never executed: end of block
else if (q->layoutDirection() == Qt::RightToLeft
q->layoutDirec...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
291 scrollButtonRightRect.setWidth(scrollButtonWidth);-
292 scrollButtonLeftRect.setX(scrollButtonLeftRect.right() + 1 - scrollButtonWidth);-
293 scrollButtonLeftRect.setWidth(scrollButtonWidth);-
294 leftB->setArrowType(Qt::RightArrow);-
295 rightB->setArrowType(Qt::LeftArrow);-
296 }
never executed: end of block
else {
0
297 scrollButtonLeftRect.setWidth(scrollButtonWidth);-
298 scrollButtonRightRect.setX(scrollButtonRightRect.right() + 1 - scrollButtonWidth);-
299 scrollButtonRightRect.setWidth(scrollButtonWidth);-
300 leftB->setArrowType(Qt::LeftArrow);-
301 rightB->setArrowType(Qt::RightArrow);-
302 }
never executed: end of block
0
303-
304 leftB->setGeometry(scrollButtonLeftRect);-
305 leftB->setEnabled(false);-
306 leftB->show();-
307-
308 rightB->setGeometry(scrollButtonRightRect);-
309 rightB->setEnabled(last - scrollOffset > scrollRect.x() + scrollRect.width());-
310 rightB->show();-
311 }
never executed: end of block
else {
0
312 scrollOffset = 0;-
313 rightB->hide();-
314 leftB->hide();-
315 }
never executed: end of block
0
316-
317 layoutWidgets();-
318 q->tabLayoutChange();-
319}
never executed: end of block
0
320-
321QRect QTabBarPrivate::normalizedScrollRect(int index)-
322{-
323-
324-
325-
326-
327-
328 QTabBar * const q = q_func();-
329 QStyleOptionTab opt;-
330 q->initStyleOption(&opt, currentIndex);-
331 opt.rect = q->rect();-
332-
333 QRect scrollButtonLeftRect = q->style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, q);-
334 QRect scrollButtonRightRect = q->style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, q);-
335 QRect tearLeftRect = q->style()->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &opt, q);-
336 QRect tearRightRect = q->style()->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &opt, q);-
337-
338 if (verticalTabs(shape)
verticalTabs(shape)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
339 int topEdge, bottomEdge;-
340 bool leftButtonIsOnTop = scrollButtonLeftRect.y() < q->height() / 2;-
341 bool rightButtonIsOnTop = scrollButtonRightRect.y() < q->height() / 2;-
342-
343 if (leftButtonIsOnTop
leftButtonIsOnTopDescription
TRUEnever evaluated
FALSEnever evaluated
&& rightButtonIsOnTop
rightButtonIsOnTopDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
344 topEdge = scrollButtonRightRect.bottom() + 1;-
345 bottomEdge = q->height();-
346 }
never executed: end of block
else if (!leftButtonIsOnTop
!leftButtonIsOnTopDescription
TRUEnever evaluated
FALSEnever evaluated
&& !rightButtonIsOnTop
!rightButtonIsOnTopDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
347 topEdge = 0;-
348 bottomEdge = scrollButtonLeftRect.top();-
349 }
never executed: end of block
else {
0
350 topEdge = scrollButtonLeftRect.bottom() + 1;-
351 bottomEdge = scrollButtonRightRect.top();-
352 }
never executed: end of block
0
353-
354 bool tearTopVisible = index != 0
index != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& topEdge != -scrollOffset
topEdge != -scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
355 bool tearBottomVisible = index != tabList.size() - 1
index != tabList.size() - 1Description
TRUEnever evaluated
FALSEnever evaluated
&& bottomEdge != tabList.constLast().rect.bottom() + 1 - scrollOffset
bottomEdge != ...- scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
356 if (tearTopVisible
tearTopVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
&& !tearLeftRect.isNull()
!tearLeftRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
357 topEdge = tearLeftRect.bottom() + 1;
never executed: topEdge = tearLeftRect.bottom() + 1;
0
358 if (tearBottomVisible
tearBottomVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
&& !tearRightRect.isNull()
!tearRightRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
359 bottomEdge = tearRightRect.top();
never executed: bottomEdge = tearRightRect.top();
0
360-
361 return
never executed: return QRect(topEdge, 0, bottomEdge - topEdge, q->height());
QRect(topEdge, 0, bottomEdge - topEdge, q->height());
never executed: return QRect(topEdge, 0, bottomEdge - topEdge, q->height());
0
362 } else {-
363 if (q->layoutDirection() == Qt::RightToLeft
q->layoutDirec...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
364 scrollButtonLeftRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), scrollButtonLeftRect);-
365 scrollButtonRightRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), scrollButtonRightRect);-
366 tearLeftRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), tearLeftRect);-
367 tearRightRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), tearRightRect);-
368 }
never executed: end of block
0
369-
370 int leftEdge, rightEdge;-
371 bool leftButtonIsOnLeftSide = scrollButtonLeftRect.x() < q->width() / 2;-
372 bool rightButtonIsOnLeftSide = scrollButtonRightRect.x() < q->width() / 2;-
373-
374 if (leftButtonIsOnLeftSide
leftButtonIsOnLeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
&& rightButtonIsOnLeftSide
rightButtonIsOnLeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
375 leftEdge = scrollButtonRightRect.right() + 1;-
376 rightEdge = q->width();-
377 }
never executed: end of block
else if (!leftButtonIsOnLeftSide
!leftButtonIsOnLeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
&& !rightButtonIsOnLeftSide
!rightButtonIsOnLeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
378 leftEdge = 0;-
379 rightEdge = scrollButtonLeftRect.left();-
380 }
never executed: end of block
else {
0
381 leftEdge = scrollButtonLeftRect.right() + 1;-
382 rightEdge = scrollButtonRightRect.left();-
383 }
never executed: end of block
0
384-
385 bool tearLeftVisible = index != 0
index != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& leftEdge != -scrollOffset
leftEdge != -scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
386 bool tearRightVisible = index != tabList.size() - 1
index != tabList.size() - 1Description
TRUEnever evaluated
FALSEnever evaluated
&& rightEdge != tabList.constLast().rect.right() + 1 - scrollOffset
rightEdge != t...- scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
387 if (tearLeftVisible
tearLeftVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
&& !tearLeftRect.isNull()
!tearLeftRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
388 leftEdge = tearLeftRect.right() + 1;
never executed: leftEdge = tearLeftRect.right() + 1;
0
389 if (tearRightVisible
tearRightVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
&& !tearRightRect.isNull()
!tearRightRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
390 rightEdge = tearRightRect.left();
never executed: rightEdge = tearRightRect.left();
0
391-
392 return
never executed: return QRect(leftEdge, 0, rightEdge - leftEdge, q->height());
QRect(leftEdge, 0, rightEdge - leftEdge, q->height());
never executed: return QRect(leftEdge, 0, rightEdge - leftEdge, q->height());
0
393 }-
394}-
395-
396void QTabBarPrivate::makeVisible(int index)-
397{-
398 QTabBar * const q = q_func();-
399 if (!validIndex(index)
!validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
|| leftB->isHidden()
leftB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
400 return;
never executed: return;
0
401-
402 const QRect tabRect = tabList.at(index).rect;-
403 const int oldScrollOffset = scrollOffset;-
404 const bool horiz = !verticalTabs(shape);-
405 const int tabStart = horiz
horizDescription
TRUEnever evaluated
FALSEnever evaluated
? tabRect.left() : tabRect.top();
0
406 const int tabEnd = horiz
horizDescription
TRUEnever evaluated
FALSEnever evaluated
? tabRect.right() : tabRect.bottom();
0
407 const int lastTabEnd = horiz
horizDescription
TRUEnever evaluated
FALSEnever evaluated
? tabList.constLast().rect.right() : tabList.constLast().rect.bottom();
0
408 const QRect scrollRect = normalizedScrollRect(index);-
409 const int scrolledTabBarStart = qMax(1, scrollRect.left() + scrollOffset);-
410 const int scrolledTabBarEnd = qMin(lastTabEnd - 1, scrollRect.right() + scrollOffset);-
411-
412 if (tabStart < scrolledTabBarStart
tabStart < scrolledTabBarStartDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
413-
414 scrollOffset = tabStart - scrollRect.left();-
415 }
never executed: end of block
else if (tabEnd > scrolledTabBarEnd
tabEnd > scrolledTabBarEndDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
416-
417 scrollOffset = tabEnd - scrollRect.right();-
418 }
never executed: end of block
0
419-
420 leftB->setEnabled(scrollOffset > -scrollRect.left());-
421 rightB->setEnabled(scrollOffset < lastTabEnd - scrollRect.right());-
422-
423 if (oldScrollOffset != scrollOffset
oldScrollOffse...= scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
424 q->update();-
425 layoutWidgets();-
426 }
never executed: end of block
0
427}
never executed: end of block
0
428-
429void QTabBarPrivate::killSwitchTabTimer()-
430{-
431 QTabBar * const q = q_func();-
432 if (switchTabTimerId
switchTabTimerIdDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
433 q->killTimer(switchTabTimerId);-
434 switchTabTimerId = 0;-
435 }
never executed: end of block
0
436 switchTabCurrentIndex = -1;-
437}
never executed: end of block
0
438-
439void QTabBarPrivate::layoutTab(int index)-
440{-
441 QTabBar * const q = q_func();-
442 ((!(index >= 0)) ? qt_assert("index >= 0",__FILE__,714) : qt_noop());-
443-
444 Tab &tab = tabList[index];-
445 bool vertical = verticalTabs(shape);-
446 if (!(tab.leftWidget
tab.leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
|| tab.rightWidget
tab.rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
447 return;
never executed: return;
0
448-
449 QStyleOptionTab opt;-
450 q->initStyleOption(&opt, index);-
451 if (tab.leftWidget
tab.leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
452 QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q);-
453 QPoint p = rect.topLeft();-
454 if ((
(index == pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
index == pressedIndex)
(index == pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
|| paintWithOffsets
paintWithOffsetsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
455 if (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
456 p.setY(p.y() + tabList[index].dragOffset);
never executed: p.setY(p.y() + tabList[index].dragOffset);
0
457 else-
458 p.setX(p.x() + tabList[index].dragOffset);
never executed: p.setX(p.x() + tabList[index].dragOffset);
0
459 }-
460 tab.leftWidget->move(p);-
461 }
never executed: end of block
0
462 if (tab.rightWidget
tab.rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
463 QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabRightButton, &opt, q);-
464 QPoint p = rect.topLeft();-
465 if ((
(index == pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
index == pressedIndex)
(index == pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
|| paintWithOffsets
paintWithOffsetsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
466 if (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
467 p.setY(p.y() + tab.dragOffset);
never executed: p.setY(p.y() + tab.dragOffset);
0
468 else-
469 p.setX(p.x() + tab.dragOffset);
never executed: p.setX(p.x() + tab.dragOffset);
0
470 }-
471 tab.rightWidget->move(p);-
472 }
never executed: end of block
0
473}
never executed: end of block
0
474-
475void QTabBarPrivate::layoutWidgets(int start)-
476{-
477 QTabBar * const q = q_func();-
478 for (int i = start; i < q->count()
i < q->count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
479 layoutTab(i);-
480 }
never executed: end of block
0
481}
never executed: end of block
0
482-
483void QTabBarPrivate::autoHideTabs()-
484{-
485 QTabBar * const q = q_func();-
486-
487 if (autoHide
autoHideDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
488 q->setVisible(q->count() > 1);
never executed: q->setVisible(q->count() > 1);
0
489}
never executed: end of block
0
490-
491void QTabBarPrivate::_q_closeTab()-
492{-
493 QTabBar * const q = q_func();-
494 QObject *object = q->sender();-
495 int tabToClose = -1;-
496 QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)q->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, q);-
497 for (int i = 0; i < tabList.count()
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
498 if (closeSide == QTabBar::LeftSide
closeSide == QTabBar::LeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
499 if (tabList.at(i).leftWidget == object
tabList.at(i)....dget == objectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
500 tabToClose = i;-
501 break;
never executed: break;
0
502 }-
503 }
never executed: end of block
else {
0
504 if (tabList.at(i).rightWidget == object
tabList.at(i)....dget == objectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
505 tabToClose = i;-
506 break;
never executed: break;
0
507 }-
508 }
never executed: end of block
0
509 }-
510 if (tabToClose != -1
tabToClose != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
511 q->tabCloseRequested(tabToClose);
never executed: q->tabCloseRequested(tabToClose);
0
512}
never executed: end of block
0
513-
514void QTabBarPrivate::_q_scrollTabs()-
515{-
516 QTabBar * const q = q_func();-
517 const QObject *sender = q->sender();-
518 const bool horizontal = !verticalTabs(shape);-
519 const QRect scrollRect = normalizedScrollRect();-
520 int i = -1;-
521-
522 if (sender == leftB
sender == leftBDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
523 for (i = tabList.count() - 1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
524 int start = horizontal
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
? tabList.at(i).rect.left() : tabList.at(i).rect.top();
0
525 if (start < scrollRect.left() + scrollOffset
start < scroll...+ scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
526 makeVisible(i);-
527 return;
never executed: return;
0
528 }-
529 }
never executed: end of block
0
530 }
never executed: end of block
else if (sender == rightB
sender == rightBDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
531 for (i = 0; i < tabList.count()
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
532 int end = horizontal
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
? tabList.at(i).rect.right() : tabList.at(i).rect.bottom();
0
533 if (end > scrollRect.right() + scrollOffset
end > scrollRe...+ scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
534 makeVisible(i);-
535 return;
never executed: return;
0
536 }-
537 }
never executed: end of block
0
538 }
never executed: end of block
0
539}
never executed: end of block
0
540-
541void QTabBarPrivate::refresh()-
542{-
543 QTabBar * const q = q_func();-
544-
545-
546 if (pressedIndex != -1
pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
547 && movable
movableDescription
TRUEnever evaluated
FALSEnever evaluated
0
548 && QApplication::mouseButtons() == Qt::NoButton
QApplication::...= Qt::NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
549 moveTabFinished(pressedIndex);-
550 if (!validIndex(pressedIndex)
!validIndex(pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
551 pressedIndex = -1;
never executed: pressedIndex = -1;
0
552 }
never executed: end of block
0
553-
554 if (!q->isVisible()
!q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
555 layoutDirty = true;-
556 }
never executed: end of block
else {
0
557 layoutTabs();-
558 makeVisible(currentIndex);-
559 q->update();-
560 q->updateGeometry();-
561 }
never executed: end of block
0
562}-
563-
564-
565-
566-
567QTabBar::QTabBar(QWidget* parent)-
568 :QWidget(*new QTabBarPrivate, parent, 0)-
569{-
570 QTabBarPrivate * const d = d_func();-
571 d->init();-
572}
never executed: end of block
0
573-
574-
575-
576-
577-
578QTabBar::~QTabBar()-
579{-
580}-
581QTabBar::Shape QTabBar::shape() const-
582{-
583 const QTabBarPrivate * const d = d_func();-
584 return
never executed: return d->shape;
d->shape;
never executed: return d->shape;
0
585}-
586-
587void QTabBar::setShape(Shape shape)-
588{-
589 QTabBarPrivate * const d = d_func();-
590 if (d->shape == shape
d->shape == shapeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
591 return;
never executed: return;
0
592 d->shape = shape;-
593 d->refresh();-
594}
never executed: end of block
0
595void QTabBar::setDrawBase(bool drawBase)-
596{-
597 QTabBarPrivate * const d = d_func();-
598 if (d->drawBase == drawBase
d->drawBase == drawBaseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
599 return;
never executed: return;
0
600 d->drawBase = drawBase;-
601 update();-
602}
never executed: end of block
0
603-
604bool QTabBar::drawBase() const-
605{-
606 const QTabBarPrivate * const d = d_func();-
607 return
never executed: return d->drawBase;
d->drawBase;
never executed: return d->drawBase;
0
608}-
609-
610-
611-
612-
613-
614int QTabBar::addTab(const QString &text)-
615{-
616 return
never executed: return insertTab(-1, text);
insertTab(-1, text);
never executed: return insertTab(-1, text);
0
617}-
618-
619-
620-
621-
622-
623-
624-
625int QTabBar::addTab(const QIcon& icon, const QString &text)-
626{-
627 return
never executed: return insertTab(-1, icon, text);
insertTab(-1, icon, text);
never executed: return insertTab(-1, icon, text);
0
628}-
629-
630-
631-
632-
633-
634-
635int QTabBar::insertTab(int index, const QString &text)-
636{-
637 return
never executed: return insertTab(index, QIcon(), text);
insertTab(index, QIcon(), text);
never executed: return insertTab(index, QIcon(), text);
0
638}-
639int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)-
640{-
641 QTabBarPrivate * const d = d_func();-
642 if (!d->validIndex(index)
!d->validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
643 index = d->tabList.count();-
644 d->tabList.append(QTabBarPrivate::Tab(icon, text));-
645 }
never executed: end of block
else {
0
646 d->tabList.insert(index, QTabBarPrivate::Tab(icon, text));-
647 }
never executed: end of block
0
648-
649 d->tabList[index].shortcutId = grabShortcut(QKeySequence::mnemonic(text));-
650-
651 d->refresh();-
652 if (d->tabList.count() == 1
d->tabList.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
653 setCurrentIndex(index);
never executed: setCurrentIndex(index);
0
654 else if (index <= d->currentIndex
index <= d->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
655 ++
never executed: ++d->currentIndex;
d->currentIndex;
never executed: ++d->currentIndex;
0
656-
657 if (d->closeButtonOnTabs
d->closeButtonOnTabsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
658 QStyleOptionTab opt;-
659 initStyleOption(&opt, index);-
660 ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this);-
661 QAbstractButton *closeButton = new CloseButton(this);-
662 connect(closeButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "967"), this, qFlagLocation("1""_q_closeTab()" "\0" __FILE__ ":" "967"));-
663 setTabButton(index, closeSide, closeButton);-
664 }
never executed: end of block
0
665-
666 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
667 if (d->tabList[i].lastTab >= index
d->tabList[i].lastTab >= indexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
668 ++
never executed: ++d->tabList[i].lastTab;
d->tabList[i].lastTab;
never executed: ++d->tabList[i].lastTab;
0
669 }
never executed: end of block
0
670-
671 tabInserted(index);-
672 d->autoHideTabs();-
673 return
never executed: return index;
index;
never executed: return index;
0
674}-
675-
676-
677-
678-
679-
680-
681-
682void QTabBar::removeTab(int index)-
683{-
684 QTabBarPrivate * const d = d_func();-
685 if (d->validIndex(index)
d->validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
686 if (d->dragInProgress
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
687 d->moveTabFinished(d->pressedIndex);
never executed: d->moveTabFinished(d->pressedIndex);
0
688-
689-
690 releaseShortcut(d->tabList.at(index).shortcutId);-
691-
692 if (d->tabList[index].leftWidget
d->tabList[index].leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
693 d->tabList[index].leftWidget->hide();-
694 d->tabList[index].leftWidget->deleteLater();-
695 d->tabList[index].leftWidget = 0;-
696 }
never executed: end of block
0
697 if (d->tabList[index].rightWidget
d->tabList[index].rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
698 d->tabList[index].rightWidget->hide();-
699 d->tabList[index].rightWidget->deleteLater();-
700 d->tabList[index].rightWidget = 0;-
701 }
never executed: end of block
0
702-
703 int newIndex = d->tabList[index].lastTab;-
704 d->tabList.removeAt(index);-
705 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
706 if (d->tabList[i].lastTab == index
d->tabList[i].lastTab == indexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
707 d->tabList[i].lastTab = -1;
never executed: d->tabList[i].lastTab = -1;
0
708 if (d->tabList[i].lastTab > index
d->tabList[i].lastTab > indexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
709 --
never executed: --d->tabList[i].lastTab;
d->tabList[i].lastTab;
never executed: --d->tabList[i].lastTab;
0
710 }
never executed: end of block
0
711 if (index == d->currentIndex
index == d->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
712-
713-
714-
715 d->currentIndex = -1;-
716 if (d->tabList.size() > 0
d->tabList.size() > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
717 switch(d->selectionBehaviorOnRemove) {-
718 case
never executed: case SelectPreviousTab:
SelectPreviousTab:
never executed: case SelectPreviousTab:
0
719 if (newIndex > index
newIndex > indexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
720 newIndex--;
never executed: newIndex--;
0
721 if (d->validIndex(newIndex)
d->validIndex(newIndex)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
722 break;
never executed: break;
0
723-
724 case
never executed: case SelectRightTab:
SelectRightTab:
never executed: case SelectRightTab:
code before this statement never executed: case SelectRightTab:
0
725 newIndex = index;-
726 if (newIndex >= d->tabList.size()
newIndex >= d->tabList.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
727 newIndex = d->tabList.size() - 1;
never executed: newIndex = d->tabList.size() - 1;
0
728 break;
never executed: break;
0
729 case
never executed: case SelectLeftTab:
SelectLeftTab:
never executed: case SelectLeftTab:
0
730 newIndex = index - 1;-
731 if (newIndex < 0
newIndex < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
732 newIndex = 0;
never executed: newIndex = 0;
0
733 break;
never executed: break;
0
734 default
never executed: default:
:
never executed: default:
0
735 break;
never executed: break;
0
736 }-
737-
738 if (d->validIndex(newIndex)
d->validIndex(newIndex)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
739-
740 int bump = d->tabList[newIndex].lastTab;-
741 setCurrentIndex(newIndex);-
742 d->tabList[newIndex].lastTab = bump;-
743 }
never executed: end of block
0
744 }
never executed: end of block
else {
0
745 currentChanged(-1);-
746 }
never executed: end of block
0
747 } else if (index < d->currentIndex
index < d->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
748 setCurrentIndex(d->currentIndex - 1);-
749 }
never executed: end of block
0
750 d->refresh();-
751 d->autoHideTabs();-
752 tabRemoved(index);-
753 }
never executed: end of block
0
754}
never executed: end of block
0
755-
756-
757-
758-
759-
760-
761bool QTabBar::isTabEnabled(int index) const-
762{-
763 const QTabBarPrivate * const d = d_func();-
764 if (const
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(index)
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
765 return
never executed: return tab->enabled;
tab->enabled;
never executed: return tab->enabled;
0
766 return
never executed: return false;
false;
never executed: return false;
0
767}-
768-
769-
770-
771-
772-
773void QTabBar::setTabEnabled(int index, bool enabled)-
774{-
775 QTabBarPrivate * const d = d_func();-
776 if (QTabBarPrivate::Tab *tab = d->at(index)
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
777 tab->enabled = enabled;-
778-
779 setShortcutEnabled(tab->shortcutId, enabled);-
780-
781 update();-
782 if (!enabled
!enabledDescription
TRUEnever evaluated
FALSEnever evaluated
&& index == d->currentIndex
index == d->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
783 setCurrentIndex(d->validIndex(index+1)?index+1:0);
never executed: setCurrentIndex(d->validIndex(index+1)?index+1:0);
0
784 else if (enabled
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->validIndex(d->currentIndex)
!d->validIndex...>currentIndex)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
785 setCurrentIndex(index);
never executed: setCurrentIndex(index);
0
786 }
never executed: end of block
0
787}
never executed: end of block
0
788-
789-
790-
791-
792-
793-
794QString QTabBar::tabText(int index) const-
795{-
796 const QTabBarPrivate * const d = d_func();-
797 if (const
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(index)
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
798 return
never executed: return tab->text;
tab->text;
never executed: return tab->text;
0
799 return
never executed: return QString();
QString();
never executed: return QString();
0
800}-
801-
802-
803-
804-
805void QTabBar::setTabText(int index, const QString &text)-
806{-
807 QTabBarPrivate * const d = d_func();-
808 if (QTabBarPrivate::Tab *tab = d->at(index)
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
809 d->textSizes.remove(tab->text);-
810 tab->text = text;-
811-
812 releaseShortcut(tab->shortcutId);-
813 tab->shortcutId = grabShortcut(QKeySequence::mnemonic(text));-
814 setShortcutEnabled(tab->shortcutId, tab->enabled);-
815-
816 d->refresh();-
817 }
never executed: end of block
0
818}
never executed: end of block
0
819-
820-
821-
822-
823-
824-
825-
826QColor QTabBar::tabTextColor(int index) const-
827{-
828 const QTabBarPrivate * const d = d_func();-
829 if (const
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(index)
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
830 return
never executed: return tab->textColor;
tab->textColor;
never executed: return tab->textColor;
0
831 return
never executed: return QColor();
QColor();
never executed: return QColor();
0
832}-
833void QTabBar::setTabTextColor(int index, const QColor &color)-
834{-
835 QTabBarPrivate * const d = d_func();-
836 if (QTabBarPrivate::Tab *tab = d->at(index)
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
837 tab->textColor = color;-
838 update(tabRect(index));-
839 }
never executed: end of block
0
840}
never executed: end of block
0
841-
842-
843-
844-
845-
846QIcon QTabBar::tabIcon(int index) const-
847{-
848 const QTabBarPrivate * const d = d_func();-
849 if (const
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(index)
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
850 return
never executed: return tab->icon;
tab->icon;
never executed: return tab->icon;
0
851 return
never executed: return QIcon();
QIcon();
never executed: return QIcon();
0
852}-
853-
854-
855-
856-
857void QTabBar::setTabIcon(int index, const QIcon & icon)-
858{-
859 QTabBarPrivate * const d = d_func();-
860 if (QTabBarPrivate::Tab *tab = d->at(index)
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
861 bool simpleIconChange = (!icon.isNull()
!icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
&& !tab->icon.isNull()
!tab->icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
);
0
862 tab->icon = icon;-
863 if (simpleIconChange
simpleIconChangeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
864 update(tabRect(index));
never executed: update(tabRect(index));
0
865 else-
866 d->refresh();
never executed: d->refresh();
0
867 }-
868}
never executed: end of block
0
869-
870-
871-
872-
873-
874void QTabBar::setTabToolTip(int index, const QString & tip)-
875{-
876 QTabBarPrivate * const d = d_func();-
877 if (QTabBarPrivate::Tab *tab = d->at(index)
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
878 tab->toolTip = tip;
never executed: tab->toolTip = tip;
0
879}
never executed: end of block
0
880-
881-
882-
883-
884-
885QString QTabBar::tabToolTip(int index) const-
886{-
887 const QTabBarPrivate * const d = d_func();-
888 if (const
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(index)
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
889 return
never executed: return tab->toolTip;
tab->toolTip;
never executed: return tab->toolTip;
0
890 return
never executed: return QString();
QString();
never executed: return QString();
0
891}-
892void QTabBar::setTabWhatsThis(int index, const QString &text)-
893{-
894 QTabBarPrivate * const d = d_func();-
895 if (QTabBarPrivate::Tab *tab = d->at(index)
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
896 tab->whatsThis = text;
never executed: tab->whatsThis = text;
0
897}
never executed: end of block
0
898-
899-
900-
901-
902-
903-
904-
905QString QTabBar::tabWhatsThis(int index) const-
906{-
907 const QTabBarPrivate * const d = d_func();-
908 if (const
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(index)
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
909 return
never executed: return tab->whatsThis;
tab->whatsThis;
never executed: return tab->whatsThis;
0
910 return
never executed: return QString();
QString();
never executed: return QString();
0
911}-
912-
913-
914-
915-
916-
917-
918void QTabBar::setTabData(int index, const QVariant & data)-
919{-
920 QTabBarPrivate * const d = d_func();-
921 if (QTabBarPrivate::Tab *tab = d->at(index)
QTabBarPrivate...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
922 tab->data = data;
never executed: tab->data = data;
0
923}
never executed: end of block
0
924-
925-
926-
927-
928-
929QVariant QTabBar::tabData(int index) const-
930{-
931 const QTabBarPrivate * const d = d_func();-
932 if (const
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(index)
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
933 return
never executed: return tab->data;
tab->data;
never executed: return tab->data;
0
934 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
935}-
936-
937-
938-
939-
940-
941QRect QTabBar::tabRect(int index) const-
942{-
943 const QTabBarPrivate * const d = d_func();-
944 if (const
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(index)
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
945 if (d->layoutDirty
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
946 const_cast<
never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs();
QTabBarPrivate*>(d)->layoutTabs();
never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs();
0
947 QRect r = tab->rect;-
948 if (verticalTabs(d->shape)
verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
949 r.translate(0, -d->scrollOffset);
never executed: r.translate(0, -d->scrollOffset);
0
950 else-
951 r.translate(-d->scrollOffset, 0);
never executed: r.translate(-d->scrollOffset, 0);
0
952 if (!verticalTabs(d->shape)
!verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
953 r = QStyle::visualRect(layoutDirection(), rect(), r);
never executed: r = QStyle::visualRect(layoutDirection(), rect(), r);
0
954 return
never executed: return r;
r;
never executed: return r;
0
955 }-
956 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
957}-
958-
959-
960-
961-
962-
963-
964-
965int QTabBar::tabAt(const QPoint &position) const-
966{-
967 const QTabBarPrivate * const d = d_func();-
968 if (d->validIndex(d->currentIndex)
d->validIndex(d->currentIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
969 && tabRect(d->currentIndex).contains(position)
tabRect(d->cur...ains(position)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
970 return
never executed: return d->currentIndex;
d->currentIndex;
never executed: return d->currentIndex;
0
971 }-
972 const int max = d->tabList.size();-
973 for (int i = 0; i < max
i < maxDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
974 if (tabRect(i).contains(position)
tabRect(i).contains(position)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
975 return
never executed: return i;
i;
never executed: return i;
0
976 }-
977 }
never executed: end of block
0
978 return
never executed: return -1;
-1;
never executed: return -1;
0
979}-
980int QTabBar::currentIndex() const-
981{-
982 const QTabBarPrivate * const d = d_func();-
983 if (d->validIndex(d->currentIndex)
d->validIndex(d->currentIndex)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
984 return
never executed: return d->currentIndex;
d->currentIndex;
never executed: return d->currentIndex;
0
985 return
never executed: return -1;
-1;
never executed: return -1;
0
986}-
987-
988-
989void QTabBar::setCurrentIndex(int index)-
990{-
991 QTabBarPrivate * const d = d_func();-
992 if (d->dragInProgress
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->pressedIndex != -1
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
993 return;
never executed: return;
0
994-
995 int oldIndex = d->currentIndex;-
996 if (d->validIndex(index)
d->validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
&& d->currentIndex != index
d->currentIndex != indexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
997 d->currentIndex = index;-
998 update();-
999 d->makeVisible(index);-
1000 d->tabList[index].lastTab = oldIndex;-
1001 if (oldIndex >= 0
oldIndex >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& oldIndex < count()
oldIndex < count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1002 d->layoutTab(oldIndex);
never executed: d->layoutTab(oldIndex);
0
1003 d->layoutTab(index);-
1004-
1005 if (QAccessible::isActive()
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1006 if (hasFocus()
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1007 QAccessibleEvent focusEvent(this, QAccessible::Focus);-
1008 focusEvent.setChild(index);-
1009 QAccessible::updateAccessibility(&focusEvent);-
1010 }
never executed: end of block
0
1011 QAccessibleEvent selectionEvent(this, QAccessible::Selection);-
1012 selectionEvent.setChild(index);-
1013 QAccessible::updateAccessibility(&selectionEvent);-
1014 }
never executed: end of block
0
1015-
1016 currentChanged(index);-
1017 }
never executed: end of block
0
1018}
never executed: end of block
0
1019QSize QTabBar::iconSize() const-
1020{-
1021 const QTabBarPrivate * const d = d_func();-
1022 if (d->iconSize.isValid()
d->iconSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1023 return
never executed: return d->iconSize;
d->iconSize;
never executed: return d->iconSize;
0
1024 int iconExtent = style()->pixelMetric(QStyle::PM_TabBarIconSize, 0, this);-
1025 return
never executed: return QSize(iconExtent, iconExtent);
QSize(iconExtent, iconExtent);
never executed: return QSize(iconExtent, iconExtent);
0
1026-
1027}-
1028-
1029void QTabBar::setIconSize(const QSize &size)-
1030{-
1031 QTabBarPrivate * const d = d_func();-
1032 d->iconSize = size;-
1033 d->layoutDirty = true;-
1034 update();-
1035 updateGeometry();-
1036}
never executed: end of block
0
1037-
1038-
1039-
1040-
1041-
1042-
1043int QTabBar::count() const-
1044{-
1045 const QTabBarPrivate * const d = d_func();-
1046 return
never executed: return d->tabList.count();
d->tabList.count();
never executed: return d->tabList.count();
0
1047}-
1048-
1049-
1050-
1051-
1052QSize QTabBar::sizeHint() const-
1053{-
1054 const QTabBarPrivate * const d = d_func();-
1055 if (d->layoutDirty
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1056 const_cast<
never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs();
QTabBarPrivate*>(d)->layoutTabs();
never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs();
0
1057 QRect r;-
1058 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1059 r = r.united(d->tabList.at(i).maxRect);
never executed: r = r.united(d->tabList.at(i).maxRect);
0
1060 QSize sz = QApplication::globalStrut();-
1061 return
never executed: return r.size().expandedTo(sz);
r.size().expandedTo(sz);
never executed: return r.size().expandedTo(sz);
0
1062}-
1063-
1064-
1065-
1066QSize QTabBar::minimumSizeHint() const-
1067{-
1068 const QTabBarPrivate * const d = d_func();-
1069 if (d->layoutDirty
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1070 const_cast<
never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs();
QTabBarPrivate*>(d)->layoutTabs();
never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs();
0
1071 if (!d->useScrollButtons
!d->useScrollButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1072 QRect r;-
1073 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1074 r = r.united(d->tabList.at(i).minRect);
never executed: r = r.united(d->tabList.at(i).minRect);
0
1075 return
never executed: return r.size().expandedTo(QApplication::globalStrut());
r.size().expandedTo(QApplication::globalStrut());
never executed: return r.size().expandedTo(QApplication::globalStrut());
0
1076 }-
1077 if (verticalTabs(d->shape)
verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1078 return
never executed: return QSize(sizeHint().width(), d->rightB->sizeHint().height() * 2 + 75);
QSize(sizeHint().width(), d->rightB->sizeHint().height() * 2 + 75);
never executed: return QSize(sizeHint().width(), d->rightB->sizeHint().height() * 2 + 75);
0
1079 else-
1080 return
never executed: return QSize(d->rightB->sizeHint().width() * 2 + 75, sizeHint().height());
QSize(d->rightB->sizeHint().width() * 2 + 75, sizeHint().height());
never executed: return QSize(d->rightB->sizeHint().width() * 2 + 75, sizeHint().height());
0
1081}-
1082-
1083-
1084static QString computeElidedText(Qt::TextElideMode mode, const QString &text)-
1085{-
1086 if (text.length() <= 3
text.length() <= 3Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1087 return
never executed: return text;
text;
never executed: return text;
0
1088-
1089 static const QLatin1String Ellipses("...");-
1090 QString ret;-
1091 switch (mode) {-
1092 case
never executed: case Qt::ElideRight:
Qt::ElideRight:
never executed: case Qt::ElideRight:
0
1093 ret = text.leftRef(2) + Ellipses;-
1094 break;
never executed: break;
0
1095 case
never executed: case Qt::ElideMiddle:
Qt::ElideMiddle:
never executed: case Qt::ElideMiddle:
0
1096 ret = text.leftRef(1) + Ellipses + text.rightRef(1);-
1097 break;
never executed: break;
0
1098 case
never executed: case Qt::ElideLeft:
Qt::ElideLeft:
never executed: case Qt::ElideLeft:
0
1099 ret = Ellipses + text.rightRef(2);-
1100 break;
never executed: break;
0
1101 case
never executed: case Qt::ElideNone:
Qt::ElideNone:
never executed: case Qt::ElideNone:
0
1102 ret = text;-
1103 break;
never executed: break;
0
1104 }-
1105 return
never executed: return ret;
ret;
never executed: return ret;
0
1106}-
1107-
1108-
1109-
1110-
1111-
1112-
1113QSize QTabBar::minimumTabSizeHint(int index) const-
1114{-
1115 const QTabBarPrivate * const d = d_func();-
1116 QTabBarPrivate::Tab &tab = const_cast<QTabBarPrivate::Tab&>(d->tabList[index]);-
1117 QString oldText = tab.text;-
1118 tab.text = computeElidedText(d->elideMode, oldText);-
1119 QSize size = tabSizeHint(index);-
1120 tab.text = oldText;-
1121 return
never executed: return size;
size;
never executed: return size;
0
1122}-
1123-
1124-
1125-
1126-
1127QSize QTabBar::tabSizeHint(int index) const-
1128{-
1129-
1130 const QTabBarPrivate * const d = d_func();-
1131 if (const
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(index)
const QTabBarP...= d->at(index)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1132 QStyleOptionTab opt;-
1133 d->initBasicStyleOption(&opt, index);-
1134 opt.text = d->tabList.at(index).text;-
1135 QSize iconSize = tab->icon.isNull()
tab->icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
? QSize(0, 0) : opt.iconSize;
0
1136 int hframe = style()->pixelMetric(QStyle::PM_TabBarTabHSpace, &opt, this);-
1137 int vframe = style()->pixelMetric(QStyle::PM_TabBarTabVSpace, &opt, this);-
1138 const QFontMetrics fm = fontMetrics();-
1139-
1140 int maxWidgetHeight = qMax(opt.leftButtonSize.height(), opt.rightButtonSize.height());-
1141 int maxWidgetWidth = qMax(opt.leftButtonSize.width(), opt.rightButtonSize.width());-
1142-
1143 int widgetWidth = 0;-
1144 int widgetHeight = 0;-
1145 int padding = 0;-
1146 if (!opt.leftButtonSize.isEmpty()
!opt.leftButtonSize.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1147 padding += 4;-
1148 widgetWidth += opt.leftButtonSize.width();-
1149 widgetHeight += opt.leftButtonSize.height();-
1150 }
never executed: end of block
0
1151 if (!opt.rightButtonSize.isEmpty()
!opt.rightButtonSize.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1152 padding += 4;-
1153 widgetWidth += opt.rightButtonSize.width();-
1154 widgetHeight += opt.rightButtonSize.height();-
1155 }
never executed: end of block
0
1156 if (!opt.icon.isNull()
!opt.icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1157 padding += 4;
never executed: padding += 4;
0
1158-
1159 QHash<QString, QSize>::iterator it = d->textSizes.find(tab->text);-
1160 if (it == d->textSizes.end()
it == d->textSizes.end()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1161 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
1162 const int textWidth = it.value().width();-
1163 QSize csz;-
1164 if (verticalTabs(d->shape)
verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1165 csz = QSize( qMax(maxWidgetWidth, qMax(fm.height(), iconSize.height())) + vframe,-
1166 textWidth + iconSize.width() + hframe + widgetHeight + padding);-
1167 }
never executed: end of block
else {
0
1168 csz = QSize(textWidth + iconSize.width() + hframe + widgetWidth + padding,-
1169 qMax(maxWidgetHeight, qMax(fm.height(), iconSize.height())) + vframe);-
1170 }
never executed: end of block
0
1171-
1172 QSize retSize = style()->sizeFromContents(QStyle::CT_TabBarTab, &opt, csz, this);-
1173 return
never executed: return retSize;
retSize;
never executed: return retSize;
0
1174 }-
1175 return
never executed: return QSize();
QSize();
never executed: return QSize();
0
1176}-
1177-
1178-
1179-
1180-
1181-
1182-
1183-
1184void QTabBar::tabInserted(int index)-
1185{-
1186 (void)index;-
1187}
never executed: end of block
0
1188-
1189-
1190-
1191-
1192-
1193-
1194-
1195void QTabBar::tabRemoved(int index)-
1196{-
1197 (void)index;-
1198}
never executed: end of block
0
1199-
1200-
1201-
1202-
1203-
1204-
1205void QTabBar::tabLayoutChange()-
1206{-
1207}-
1208-
1209-
1210-
1211-
1212void QTabBar::showEvent(QShowEvent *)-
1213{-
1214 QTabBarPrivate * const d = d_func();-
1215 if (d->layoutDirty
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1216 d->refresh();
never executed: d->refresh();
0
1217 if (!d->validIndex(d->currentIndex)
!d->validIndex...>currentIndex)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1218 setCurrentIndex(0);
never executed: setCurrentIndex(0);
0
1219 d->updateMacBorderMetrics();-
1220}
never executed: end of block
0
1221-
1222-
1223-
1224void QTabBar::hideEvent(QHideEvent *)-
1225{-
1226 QTabBarPrivate * const d = d_func();-
1227 d->updateMacBorderMetrics();-
1228}
never executed: end of block
0
1229-
1230-
1231-
1232bool QTabBar::event(QEvent *event)-
1233{-
1234 QTabBarPrivate * const d = d_func();-
1235 if (event->type() == QEvent::HoverMove
event->type() ...ent::HoverMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1236 || event->type() == QEvent::HoverEnter
event->type() ...nt::HoverEnterDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1237 QHoverEvent *he = static_cast<QHoverEvent *>(event);-
1238 if (!d->hoverRect.contains(he->pos())
!d->hoverRect....ins(he->pos())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1239 QRect oldHoverRect = d->hoverRect;-
1240 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1241 QRect area = tabRect(i);-
1242 if (area.contains(he->pos())
area.contains(he->pos())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1243 d->hoverRect = area;-
1244 break;
never executed: break;
0
1245 }-
1246 }
never executed: end of block
0
1247 if (he->oldPos() != QPoint(-1, -1)
he->oldPos() != QPoint(-1, -1)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1248 update(oldHoverRect);
never executed: update(oldHoverRect);
0
1249 update(d->hoverRect);-
1250 }
never executed: end of block
0
1251 return
never executed: return true;
true;
never executed: return true;
0
1252 } else if (event->type() == QEvent::HoverLeave
event->type() ...nt::HoverLeaveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1253 QRect oldHoverRect = d->hoverRect;-
1254 d->hoverRect = QRect();-
1255 update(oldHoverRect);-
1256 return
never executed: return true;
true;
never executed: return true;
0
1257-
1258 } else if (event->type() == QEvent::ToolTip
event->type() ...Event::ToolTipDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1259 if (const
const QTabBarP...vent)->pos()))Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(tabAt(static_cast<QHelpEvent*>(event)->pos()))
const QTabBarP...vent)->pos()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1260 if (!tab->toolTip.isEmpty()
!tab->toolTip.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1261 QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tab->toolTip, this);-
1262 return
never executed: return true;
true;
never executed: return true;
0
1263 }-
1264 }
never executed: end of block
0
1265-
1266-
1267 }
never executed: end of block
else if (event->type() == QEvent::QueryWhatsThis
event->type() ...QueryWhatsThisDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1268 const QTabBarPrivate::Tab *tab = d->at(d->indexAtPos(static_cast<QHelpEvent*>(event)->pos()));-
1269 if (!tab
!tabDescription
TRUEnever evaluated
FALSEnever evaluated
|| tab->whatsThis.isEmpty()
tab->whatsThis.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1270 event->ignore();
never executed: event->ignore();
0
1271 return
never executed: return true;
true;
never executed: return true;
0
1272 } else if (event->type() == QEvent::WhatsThis
event->type() ...ent::WhatsThisDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1273 if (const
const QTabBarP...vent)->pos()))Description
TRUEnever evaluated
FALSEnever evaluated
QTabBarPrivate::Tab *tab = d->at(d->indexAtPos(static_cast<QHelpEvent*>(event)->pos()))
const QTabBarP...vent)->pos()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1274 if (!tab->whatsThis.isEmpty()
!tab->whatsThis.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1275 QWhatsThis::showText(static_cast<QHelpEvent*>(event)->globalPos(),-
1276 tab->whatsThis, this);-
1277 return
never executed: return true;
true;
never executed: return true;
0
1278 }-
1279 }
never executed: end of block
0
1280-
1281-
1282 }
never executed: end of block
else if (event->type() == QEvent::Shortcut
event->type() ...vent::ShortcutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1283 QShortcutEvent *se = static_cast<QShortcutEvent *>(event);-
1284 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1285 const QTabBarPrivate::Tab *tab = &d->tabList.at(i);-
1286 if (tab->shortcutId == se->shortcutId()
tab->shortcutI...->shortcutId()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1287 setCurrentIndex(i);-
1288 return
never executed: return true;
true;
never executed: return true;
0
1289 }-
1290 }
never executed: end of block
0
1291-
1292 }
never executed: end of block
else if (event->type() == QEvent::MouseButtonDblClick
event->type() ...ButtonDblClickDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1293 const QPoint pos = static_cast<const QMouseEvent *>(event)->pos();-
1294 const bool isEventInCornerButtons = (!d->leftB->isHidden()
!d->leftB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->leftB->geometry().contains(pos)
d->leftB->geom....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1295 || (!d->rightB->isHidden()
!d->rightB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->rightB->geometry().contains(pos)
d->rightB->geo....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1296 if (!isEventInCornerButtons
!isEventInCornerButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1297 tabBarDoubleClicked(tabAt(pos));
never executed: tabBarDoubleClicked(tabAt(pos));
0
1298 }
never executed: end of block
else if (event->type() == QEvent::Move
event->type() == QEvent::MoveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1299 d->updateMacBorderMetrics();-
1300 return
never executed: return QWidget::event(event);
QWidget::event(event);
never executed: return QWidget::event(event);
0
1301-
1302-
1303 } else if (event->type() == QEvent::DragEnter
event->type() ...ent::DragEnterDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1304 if (d->changeCurrentOnDrag
d->changeCurrentOnDragDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1305 event->accept();
never executed: event->accept();
0
1306 }
never executed: end of block
else if (event->type() == QEvent::DragMove
event->type() ...vent::DragMoveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1307 if (d->changeCurrentOnDrag
d->changeCurrentOnDragDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1308 const int tabIndex = tabAt(static_cast<QDragMoveEvent *>(event)->pos());-
1309 if (isTabEnabled(tabIndex)
isTabEnabled(tabIndex)Description
TRUEnever evaluated
FALSEnever evaluated
&& d->switchTabCurrentIndex != tabIndex
d->switchTabCu...ex != tabIndexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1310 d->switchTabCurrentIndex = tabIndex;-
1311 if (d->switchTabTimerId
d->switchTabTimerIdDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1312 killTimer(d->switchTabTimerId);
never executed: killTimer(d->switchTabTimerId);
0
1313 d->switchTabTimerId = startTimer(style()->styleHint(QStyle::SH_TabBar_ChangeCurrentDelay));-
1314 }
never executed: end of block
0
1315 event->ignore();-
1316 }
never executed: end of block
0
1317 }
never executed: end of block
else if (event->type() == QEvent::DragLeave
event->type() ...ent::DragLeaveDescription
TRUEnever evaluated
FALSEnever evaluated
|| event->type() == QEvent::Drop
event->type() == QEvent::DropDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1318 d->killSwitchTabTimer();-
1319 event->ignore();-
1320-
1321 }
never executed: end of block
0
1322 return
never executed: return QWidget::event(event);
QWidget::event(event);
never executed: return QWidget::event(event);
0
1323}-
1324-
1325-
1326-
1327void QTabBar::resizeEvent(QResizeEvent *)-
1328{-
1329 QTabBarPrivate * const d = d_func();-
1330 if (d->layoutDirty
d->layoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1331 updateGeometry();
never executed: updateGeometry();
0
1332 d->layoutTabs();-
1333-
1334 d->makeVisible(d->currentIndex);-
1335}
never executed: end of block
0
1336-
1337-
1338-
1339void QTabBar::paintEvent(QPaintEvent *)-
1340{-
1341 QTabBarPrivate * const d = d_func();-
1342-
1343 QStyleOptionTabBarBase optTabBase;-
1344 QTabBarPrivate::initStyleBaseOption(&optTabBase, this, size());-
1345-
1346 QStylePainter p(this);-
1347 int selected = -1;-
1348 int cutLeft = -1;-
1349 int cutRight = -1;-
1350 bool vertical = verticalTabs(d->shape);-
1351 QStyleOptionTab cutTabLeft;-
1352 QStyleOptionTab cutTabRight;-
1353 selected = d->currentIndex;-
1354 if (d->dragInProgress
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1355 selected = d->pressedIndex;
never executed: selected = d->pressedIndex;
0
1356 const QRect scrollRect = d->normalizedScrollRect();-
1357-
1358 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1359 optTabBase.tabBarRect |= tabRect(i);
never executed: optTabBase.tabBarRect |= tabRect(i);
0
1360-
1361 optTabBase.selectedTabRect = tabRect(selected);-
1362-
1363 if (d->drawBase
d->drawBaseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1364 p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
never executed: p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
0
1365-
1366 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1367 QStyleOptionTab tab;-
1368 initStyleOption(&tab, i);-
1369 if (d->paintWithOffsets
d->paintWithOffsetsDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->tabList[i].dragOffset != 0
d->tabList[i].dragOffset != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1370 if (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1371 tab.rect.moveTop(tab.rect.y() + d->tabList[i].dragOffset);-
1372 }
never executed: end of block
else {
0
1373 tab.rect.moveLeft(tab.rect.x() + d->tabList[i].dragOffset);-
1374 }
never executed: end of block
0
1375 }-
1376 if (!(tab.state & QStyle::State_Enabled)
!(tab.state & ...State_Enabled)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1377 tab.palette.setCurrentColorGroup(QPalette::Disabled);-
1378 }
never executed: end of block
0
1379-
1380-
1381-
1382 QRect tabRect = d->tabList[i].rect;-
1383 int tabStart = vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
? tabRect.top() : tabRect.left();
0
1384 int tabEnd = vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
? tabRect.bottom() : tabRect.right();
0
1385 if (tabStart < scrollRect.left() + d->scrollOffset
tabStart < scr...->scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1386 cutLeft = i;-
1387 cutTabLeft = tab;-
1388 }
never executed: end of block
else if (tabEnd > scrollRect.right() + d->scrollOffset
tabEnd > scrol...->scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1389 cutRight = i;-
1390 cutTabRight = tab;-
1391 }
never executed: end of block
0
1392-
1393-
1394 if ((!vertical
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
&& (tab.rect.right() < 0
tab.rect.right() < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| tab.rect.left() > width()
tab.rect.left() > width()Description
TRUEnever evaluated
FALSEnever evaluated
))
0
1395 || (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
&& (tab.rect.bottom() < 0
tab.rect.bottom() < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| tab.rect.top() > height()
tab.rect.top() > height()Description
TRUEnever evaluated
FALSEnever evaluated
)))
0
1396 continue;
never executed: continue;
0
1397-
1398 optTabBase.tabBarRect |= tab.rect;-
1399 if (i == selected
i == selectedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1400 continue;
never executed: continue;
0
1401-
1402 p.drawControl(QStyle::CE_TabBarTab, tab);-
1403 }
never executed: end of block
0
1404-
1405-
1406 if (selected >= 0
selected >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1407 QStyleOptionTab tab;-
1408 initStyleOption(&tab, selected);-
1409 if (d->paintWithOffsets
d->paintWithOffsetsDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->tabList[selected].dragOffset != 0
d->tabList[sel...ragOffset != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1410 if (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1411 tab.rect.moveTop(tab.rect.y() + d->tabList[selected].dragOffset);
never executed: tab.rect.moveTop(tab.rect.y() + d->tabList[selected].dragOffset);
0
1412 else-
1413 tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset);
never executed: tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset);
0
1414 }-
1415 if (!d->dragInProgress
!d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1416 p.drawControl(QStyle::CE_TabBarTab, tab);
never executed: p.drawControl(QStyle::CE_TabBarTab, tab);
0
1417 else {-
1418 int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this);-
1419 d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0));-
1420 }
never executed: end of block
0
1421 }-
1422-
1423-
1424 if (d->leftB->isVisible()
d->leftB->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
&& cutLeft >= 0
cutLeft >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1425 cutTabLeft.rect = rect();-
1426 cutTabLeft.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &cutTabLeft, this);-
1427 p.drawPrimitive(QStyle::PE_IndicatorTabTearLeft, cutTabLeft);-
1428 }
never executed: end of block
0
1429-
1430 if (d->rightB->isVisible()
d->rightB->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
&& cutRight >= 0
cutRight >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1431 cutTabRight.rect = rect();-
1432 cutTabRight.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &cutTabRight, this);-
1433 p.drawPrimitive(QStyle::PE_IndicatorTabTearRight, cutTabRight);-
1434 }
never executed: end of block
0
1435}
never executed: end of block
0
1436-
1437-
1438-
1439-
1440int QTabBarPrivate::calculateNewPosition(int from, int to, int index) const-
1441{-
1442 if (index == from
index == fromDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1443 return
never executed: return to;
to;
never executed: return to;
0
1444-
1445 int start = qMin(from, to);-
1446 int end = qMax(from, to);-
1447 if (index >= start
index >= startDescription
TRUEnever evaluated
FALSEnever evaluated
&& index <= end
index <= endDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1448 index += (
(from < to)Description
TRUEnever evaluated
FALSEnever evaluated
from < to)
(from < to)Description
TRUEnever evaluated
FALSEnever evaluated
? -1 : 1;
never executed: index += (from < to) ? -1 : 1;
0
1449 return
never executed: return index;
index;
never executed: return index;
0
1450}-
1451-
1452-
1453-
1454-
1455-
1456-
1457-
1458void QTabBar::moveTab(int from, int to)-
1459{-
1460 QTabBarPrivate * const d = d_func();-
1461 if (from == to
from == toDescription
TRUEnever evaluated
FALSEnever evaluated
0
1462 || !d->validIndex(from)
!d->validIndex(from)Description
TRUEnever evaluated
FALSEnever evaluated
0
1463 || !d->validIndex(to)
!d->validIndex(to)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1464 return;
never executed: return;
0
1465-
1466 bool vertical = verticalTabs(d->shape);-
1467 int oldPressedPosition = 0;-
1468 if (d->pressedIndex != -1
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1469-
1470 oldPressedPosition = vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
? d->tabList[d->pressedIndex].rect.y()
0
1471 : d->tabList[d->pressedIndex].rect.x();-
1472 }
never executed: end of block
0
1473-
1474-
1475 int start = qMin(from, to);-
1476 int end = qMax(from, to);-
1477 int width = vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
? d->tabList[from].rect.height() : d->tabList[from].rect.width();
0
1478 if (from < to
from < toDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1479 width *= -1;
never executed: width *= -1;
0
1480 bool rtl = isRightToLeft();-
1481 for (int i = start; i <= end
i <= endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1482 if (i == from
i == fromDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1483 continue;
never executed: continue;
0
1484 if (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1485 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
1486 else-
1487 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
1488 int direction = -1;-
1489 if (rtl
rtlDescription
TRUEnever evaluated
FALSEnever evaluated
&& !vertical
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1490 direction *= -1;
never executed: direction *= -1;
0
1491 if (d->tabList[i].dragOffset != 0
d->tabList[i].dragOffset != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1492 d->tabList[i].dragOffset += (direction * width);
never executed: d->tabList[i].dragOffset += (direction * width);
0
1493 }
never executed: end of block
0
1494-
1495 if (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1496 if (from < to
from < toDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1497 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
1498 else-
1499 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
1500 } else {-
1501 if (from < to
from < toDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1502 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
1503 else-
1504 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
1505 }-
1506-
1507-
1508 d->tabList.move(from, to);-
1509-
1510-
1511 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1512 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
1513-
1514-
1515 int previousIndex = d->currentIndex;-
1516 d->currentIndex = d->calculateNewPosition(from, to, d->currentIndex);-
1517-
1518-
1519 if (d->pressedIndex != -1
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1520 d->pressedIndex = d->calculateNewPosition(from, to, d->pressedIndex);-
1521 int newPressedPosition = vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
? d->tabList[d->pressedIndex].rect.top() : d->tabList[d->pressedIndex].rect.left();
0
1522 int diff = oldPressedPosition - newPressedPosition;-
1523 if (isRightToLeft()
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
&& !vertical
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1524 diff *= -1;
never executed: diff *= -1;
0
1525 if (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1526 d->dragStartPosition.setY(d->dragStartPosition.y() - diff);
never executed: d->dragStartPosition.setY(d->dragStartPosition.y() - diff);
0
1527 else-
1528 d->dragStartPosition.setX(d->dragStartPosition.x() - diff);
never executed: d->dragStartPosition.setX(d->dragStartPosition.x() - diff);
0
1529 }-
1530-
1531 d->layoutWidgets(start);-
1532 update();-
1533 tabMoved(from, to);-
1534 if (previousIndex != d->currentIndex
previousIndex ...->currentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1535 currentChanged(d->currentIndex);
never executed: currentChanged(d->currentIndex);
0
1536 tabLayoutChange();-
1537}
never executed: end of block
0
1538-
1539void QTabBarPrivate::slide(int from, int to)-
1540{-
1541 QTabBar * const q = q_func();-
1542 if (from == to
from == toDescription
TRUEnever evaluated
FALSEnever evaluated
0
1543 || !validIndex(from)
!validIndex(from)Description
TRUEnever evaluated
FALSEnever evaluated
0
1544 || !validIndex(to)
!validIndex(to)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1545 return;
never executed: return;
0
1546 bool vertical = verticalTabs(shape);-
1547 int preLocation = vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
? q->tabRect(from).y() : q->tabRect(from).x();
0
1548 q->setUpdatesEnabled(false);-
1549 q->moveTab(from, to);-
1550 q->setUpdatesEnabled(true);-
1551 int postLocation = vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
? q->tabRect(to).y() : q->tabRect(to).x();
0
1552 int length = postLocation - preLocation;-
1553 tabList[to].dragOffset -= length;-
1554 tabList[to].startAnimation(this, 250);-
1555}
never executed: end of block
0
1556-
1557void QTabBarPrivate::moveTab(int index, int offset)-
1558{-
1559 if (!validIndex(index)
!validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1560 return;
never executed: return;
0
1561 tabList[index].dragOffset = offset;-
1562 layoutTab(index);-
1563 q_func()->update();-
1564}
never executed: end of block
0
1565-
1566-
1567-
1568void QTabBar::mousePressEvent(QMouseEvent *event)-
1569{-
1570 QTabBarPrivate * const d = d_func();-
1571-
1572 const QPoint pos = event->pos();-
1573 const bool isEventInCornerButtons = (!d->leftB->isHidden()
!d->leftB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->leftB->geometry().contains(pos)
d->leftB->geom....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1574 || (!d->rightB->isHidden()
!d->rightB->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->rightB->geometry().contains(pos)
d->rightB->geo....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1575 if (!isEventInCornerButtons
!isEventInCornerButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1576 const int index = d->indexAtPos(pos);-
1577 tabBarClicked(index);-
1578 }
never executed: end of block
0
1579-
1580 if (event->button() != Qt::LeftButton
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1581 event->ignore();-
1582 return;
never executed: return;
0
1583 }-
1584-
1585 if (d->pressedIndex != -1
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& d->movable
d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1586 d->moveTabFinished(d->pressedIndex);
never executed: d->moveTabFinished(d->pressedIndex);
0
1587-
1588 d->pressedIndex = d->indexAtPos(event->pos());-
1589-
1590-
1591-
1592 if (d->validIndex(d->pressedIndex)
d->validIndex(d->pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1593 QStyleOptionTabBarBase optTabBase;-
1594 optTabBase.init(this);-
1595 optTabBase.documentMode = d->documentMode;-
1596 if (event->type() == style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this)
event->type() ...TabBase, this)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1597 setCurrentIndex(d->pressedIndex);
never executed: setCurrentIndex(d->pressedIndex);
0
1598 else-
1599 repaint(tabRect(d->pressedIndex));
never executed: repaint(tabRect(d->pressedIndex));
0
1600 if (d->movable
d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1601 d->dragStartPosition = event->pos();-
1602 }
never executed: end of block
0
1603 }
never executed: end of block
0
1604}
never executed: end of block
0
1605-
1606-
1607-
1608void QTabBar::mouseMoveEvent(QMouseEvent *event)-
1609{-
1610 QTabBarPrivate * const d = d_func();-
1611 if (d->movable
d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1612-
1613 if (d->pressedIndex != -1
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1614 && event->buttons() == Qt::NoButton
event->buttons...= Qt::NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1615 d->moveTabFinished(d->pressedIndex);
never executed: d->moveTabFinished(d->pressedIndex);
0
1616-
1617-
1618 if (!d->dragInProgress
!d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->pressedIndex != -1
d->pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1619 if ((
(event->pos() ...DragDistance()Description
TRUEnever evaluated
FALSEnever evaluated
event->pos() - d->dragStartPosition).manhattanLength() > QApplication::startDragDistance()
(event->pos() ...DragDistance()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1620 d->dragInProgress = true;-
1621 d->setupMovableTab();-
1622 }
never executed: end of block
0
1623 }
never executed: end of block
0
1624-
1625 if (event->buttons() == Qt::LeftButton
event->buttons...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1626 && d->dragInProgress
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
0
1627 && d->validIndex(d->pressedIndex)
d->validIndex(d->pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1628 bool vertical = verticalTabs(d->shape);-
1629 int dragDistance;-
1630 if (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1631 dragDistance = (event->pos().y() - d->dragStartPosition.y());-
1632 }
never executed: end of block
else {
0
1633 dragDistance = (event->pos().x() - d->dragStartPosition.x());-
1634 }
never executed: end of block
0
1635 d->tabList[d->pressedIndex].dragOffset = dragDistance;-
1636-
1637 QRect startingRect = tabRect(d->pressedIndex);-
1638 if (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1639 startingRect.moveTop(startingRect.y() + dragDistance);
never executed: startingRect.moveTop(startingRect.y() + dragDistance);
0
1640 else-
1641 startingRect.moveLeft(startingRect.x() + dragDistance);
never executed: startingRect.moveLeft(startingRect.x() + dragDistance);
0
1642-
1643 int overIndex;-
1644 if (dragDistance < 0
dragDistance < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1645 overIndex = tabAt(startingRect.topLeft());
never executed: overIndex = tabAt(startingRect.topLeft());
0
1646 else-
1647 overIndex = tabAt(startingRect.topRight());
never executed: overIndex = tabAt(startingRect.topRight());
0
1648-
1649 if (overIndex != d->pressedIndex
overIndex != d->pressedIndexDescription
TRUEnever evaluated
FALSEnever evaluated
&& overIndex != -1
overIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1650 int offset = 1;-
1651 if (isRightToLeft()
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
&& !vertical
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1652 offset *= -1;
never executed: offset *= -1;
0
1653 if (dragDistance < 0
dragDistance < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1654 dragDistance *= -1;-
1655 offset *= -1;-
1656 }
never executed: end of block
0
1657 for (int i = d->pressedIndex;-
1658 offset > 0
offset > 0Description
TRUEnever evaluated
FALSEnever evaluated
? i < overIndex : i > overIndex
offset > 0 ? i... i > overIndexDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
1659 i += offset) {-
1660 QRect overIndexRect = tabRect(overIndex);-
1661 int needsToBeOver = (vertical
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
? overIndexRect.height() : overIndexRect.width()) / 2;
0
1662 if (dragDistance > needsToBeOver
dragDistance > needsToBeOverDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1663 d->slide(i + offset, d->pressedIndex);
never executed: d->slide(i + offset, d->pressedIndex);
0
1664 }
never executed: end of block
0
1665 }
never executed: end of block
0
1666-
1667 d->layoutTab(d->pressedIndex);-
1668-
1669 update();-
1670 }
never executed: end of block
0
1671 }
never executed: end of block
0
1672-
1673 if (event->buttons() != Qt::LeftButton
event->buttons...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1674 event->ignore();-
1675 return;
never executed: return;
0
1676 }-
1677}
never executed: end of block
0
1678-
1679void QTabBarPrivate::setupMovableTab()-
1680{-
1681 QTabBar * const q = q_func();-
1682 if (!movingTab
!movingTabDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1683 movingTab = new QMovableTabWidget(q);
never executed: movingTab = new QMovableTabWidget(q);
0
1684-
1685 int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q);-
1686 QRect grabRect = q->tabRect(pressedIndex);-
1687 grabRect.adjust(-taboverlap, 0, taboverlap, 0);-
1688-
1689 QPixmap grabImage(grabRect.size() * q->devicePixelRatioF());-
1690 grabImage.setDevicePixelRatio(q->devicePixelRatioF());-
1691 grabImage.fill(Qt::transparent);-
1692 QStylePainter p(&grabImage, q);-
1693 p.initFrom(q);-
1694-
1695 QStyleOptionTab tab;-
1696 q->initStyleOption(&tab, pressedIndex);-
1697 tab.rect.moveTopLeft(QPoint(taboverlap, 0));-
1698 p.drawControl(QStyle::CE_TabBarTab, tab);-
1699 p.end();-
1700-
1701 movingTab->setPixmap(grabImage);-
1702 movingTab->setGeometry(grabRect);-
1703 movingTab->raise();-
1704-
1705-
1706 if (tabList[pressedIndex].leftWidget
tabList[presse...ex].leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1707 tabList[pressedIndex].leftWidget->raise();
never executed: tabList[pressedIndex].leftWidget->raise();
0
1708 if (tabList[pressedIndex].rightWidget
tabList[presse...x].rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1709 tabList[pressedIndex].rightWidget->raise();
never executed: tabList[pressedIndex].rightWidget->raise();
0
1710 if (leftB
leftBDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1711 leftB->raise();
never executed: leftB->raise();
0
1712 if (rightB
rightBDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1713 rightB->raise();
never executed: rightB->raise();
0
1714 movingTab->setVisible(true);-
1715}
never executed: end of block
0
1716-
1717void QTabBarPrivate::moveTabFinished(int index)-
1718{-
1719 QTabBar * const q = q_func();-
1720 bool cleanup = (
(pressedIndex == index)Description
TRUEnever evaluated
FALSEnever evaluated
pressedIndex == index)
(pressedIndex == index)Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(pressedIndex == -1)Description
TRUEnever evaluated
FALSEnever evaluated
pressedIndex == -1)
(pressedIndex == -1)Description
TRUEnever evaluated
FALSEnever evaluated
|| !validIndex(index)
!validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
;
0
1721 bool allAnimationsFinished = true;-
1722-
1723 for(int i = 0; allAnimationsFinished
allAnimationsFinishedDescription
TRUEnever evaluated
FALSEnever evaluated
&& i < tabList.count()
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1724 const Tab &t = tabList.at(i);-
1725 if (t.animation
t.animationDescription
TRUEnever evaluated
FALSEnever evaluated
&& t.animation->state() == QAbstractAnimation::Running
t.animation->s...ation::RunningDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1726 allAnimationsFinished = false;
never executed: allAnimationsFinished = false;
0
1727 }
never executed: end of block
0
1728-
1729 if (allAnimationsFinished
allAnimationsFinishedDescription
TRUEnever evaluated
FALSEnever evaluated
&& cleanup
cleanupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1730 if(movingTab
movingTabDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1731 movingTab->setVisible(false);
never executed: movingTab->setVisible(false);
0
1732 for (int i = 0; i < tabList.count()
i < tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1733 tabList[i].dragOffset = 0;-
1734 }
never executed: end of block
0
1735 if (pressedIndex != -1
pressedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& movable
movableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1736 pressedIndex = -1;-
1737 dragInProgress = false;-
1738 dragStartPosition = QPoint();-
1739 }
never executed: end of block
0
1740 layoutWidgets();-
1741 }
never executed: end of block
else {
0
1742 if (!validIndex(index)
!validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1743 return;
never executed: return;
0
1744 tabList[index].dragOffset = 0;-
1745 }
never executed: end of block
0
1746 q->update();-
1747}
never executed: end of block
0
1748-
1749-
1750-
1751void QTabBar::mouseReleaseEvent(QMouseEvent *event)-
1752{-
1753 QTabBarPrivate * const d = d_func();-
1754 if (event->button() != Qt::LeftButton
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1755 event->ignore();-
1756 return;
never executed: return;
0
1757 }-
1758-
1759-
1760-
1761 if (d->movable
d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->dragInProgress
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->validIndex(d->pressedIndex)
d->validIndex(d->pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1762 int length = d->tabList[d->pressedIndex].dragOffset;-
1763 int width = verticalTabs(d->shape)
verticalTabs(d->shape)Description
TRUEnever evaluated
FALSEnever evaluated
0
1764 ? tabRect(d->pressedIndex).height()-
1765 : tabRect(d->pressedIndex).width();-
1766 int duration = qMin(250,-
1767 (qAbs(length) * 250) / width);-
1768 d->tabList[d->pressedIndex].startAnimation(d, duration);-
1769 d->dragInProgress = false;-
1770 d->movingTab->setVisible(false);-
1771 d->dragStartPosition = QPoint();-
1772 }
never executed: end of block
0
1773-
1774 int i = d->indexAtPos(event->pos()) == d->pressedIndex
d->indexAtPos(...->pressedIndexDescription
TRUEnever evaluated
FALSEnever evaluated
? d->pressedIndex : -1;
0
1775 d->pressedIndex = -1;-
1776 QStyleOptionTabBarBase optTabBase;-
1777 optTabBase.initFrom(this);-
1778 optTabBase.documentMode = d->documentMode;-
1779 if (style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this) == QEvent::MouseButtonRelease
style()->style...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1780 setCurrentIndex(i);
never executed: setCurrentIndex(i);
0
1781}
never executed: end of block
0
1782-
1783-
1784-
1785void QTabBar::keyPressEvent(QKeyEvent *event)-
1786{-
1787 QTabBarPrivate * const d = d_func();-
1788 if (event->key() != Qt::Key_Left
event->key() != Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
&& event->key() != Qt::Key_Right
event->key() != Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1789 event->ignore();-
1790 return;
never executed: return;
0
1791 }-
1792 int offset = event->key() == (isRightToLeft()
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::Key_Right : Qt::Key_Left)
event->key() =... Qt::Key_Left)Description
TRUEnever evaluated
FALSEnever evaluated
? -1 : 1;
0
1793 d->setCurrentNextEnabledIndex(offset);-
1794}
never executed: end of block
0
1795-
1796-
1797-
1798-
1799void QTabBar::wheelEvent(QWheelEvent *event)-
1800{-
1801-
1802 QTabBarPrivate * const d = d_func();-
1803 int offset = event->delta() > 0
event->delta() > 0Description
TRUEnever evaluated
FALSEnever evaluated
? -1 : 1;
0
1804 d->setCurrentNextEnabledIndex(offset);-
1805 QWidget::wheelEvent(event);-
1806-
1807-
1808-
1809}
never executed: end of block
0
1810-
1811-
1812void QTabBarPrivate::setCurrentNextEnabledIndex(int offset)-
1813{-
1814 QTabBar * const q = q_func();-
1815 for (int index = currentIndex + offset; validIndex(index)
validIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
; index += offset) {
0
1816 if (tabList.at(index).enabled
tabList.at(index).enabledDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1817 q->setCurrentIndex(index);-
1818 break;
never executed: break;
0
1819 }-
1820 }
never executed: end of block
0
1821}
never executed: end of block
0
1822-
1823-
1824-
1825void QTabBar::changeEvent(QEvent *event)-
1826{-
1827 QTabBarPrivate * const d = d_func();-
1828 switch (event->type()) {-
1829 case
never executed: case QEvent::StyleChange:
QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
1830 if (!d->elideModeSetByUser
!d->elideModeSetByUserDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1831 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
1832 if (!d->useScrollButtonsSetByUser
!d->useScrollButtonsSetByUserDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1833 d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this);
never executed: d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this);
0
1834-
1835 case
never executed: case QEvent::FontChange:
QEvent::FontChange:
never executed: case QEvent::FontChange:
code before this statement never executed: case QEvent::FontChange:
0
1836 d->textSizes.clear();-
1837 d->refresh();-
1838 break;
never executed: break;
0
1839 default
never executed: default:
:
never executed: default:
0
1840 break;
never executed: break;
0
1841 }-
1842-
1843 QWidget::changeEvent(event);-
1844}
never executed: end of block
0
1845-
1846-
1847-
1848-
1849void QTabBar::timerEvent(QTimerEvent *event)-
1850{-
1851 QTabBarPrivate * const d = d_func();-
1852 if (event->timerId() == d->switchTabTimerId
event->timerId...itchTabTimerIdDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1853 killTimer(d->switchTabTimerId);-
1854 d->switchTabTimerId = 0;-
1855 setCurrentIndex(d->switchTabCurrentIndex);-
1856 d->switchTabCurrentIndex = -1;-
1857 }
never executed: end of block
0
1858 QWidget::timerEvent(event);-
1859}
never executed: end of block
0
1860Qt::TextElideMode QTabBar::elideMode() const-
1861{-
1862 const QTabBarPrivate * const d = d_func();-
1863 return
never executed: return d->elideMode;
d->elideMode;
never executed: return d->elideMode;
0
1864}-
1865-
1866void QTabBar::setElideMode(Qt::TextElideMode mode)-
1867{-
1868 QTabBarPrivate * const d = d_func();-
1869 d->elideMode = mode;-
1870 d->elideModeSetByUser = true;-
1871 d->textSizes.clear();-
1872 d->refresh();-
1873}
never executed: end of block
0
1874bool QTabBar::usesScrollButtons() const-
1875{-
1876 return
never executed: return d_func()->useScrollButtons;
d_func()->useScrollButtons;
never executed: return d_func()->useScrollButtons;
0
1877}-
1878-
1879void QTabBar::setUsesScrollButtons(bool useButtons)-
1880{-
1881 QTabBarPrivate * const d = d_func();-
1882 d->useScrollButtonsSetByUser = true;-
1883 if (d->useScrollButtons == useButtons
d->useScrollBu... == useButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1884 return;
never executed: return;
0
1885 d->useScrollButtons = useButtons;-
1886 d->refresh();-
1887}
never executed: end of block
0
1888bool QTabBar::tabsClosable() const-
1889{-
1890 const QTabBarPrivate * const d = d_func();-
1891 return
never executed: return d->closeButtonOnTabs;
d->closeButtonOnTabs;
never executed: return d->closeButtonOnTabs;
0
1892}-
1893-
1894void QTabBar::setTabsClosable(bool closable)-
1895{-
1896 QTabBarPrivate * const d = d_func();-
1897 if (d->closeButtonOnTabs == closable
d->closeButton...bs == closableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1898 return;
never executed: return;
0
1899 d->closeButtonOnTabs = closable;-
1900 ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this);-
1901 if (!closable
!closableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1902 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1903 if (closeSide == LeftSide
closeSide == LeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->tabList[i].leftWidget
d->tabList[i].leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1904 d->tabList[i].leftWidget->deleteLater();-
1905 d->tabList[i].leftWidget = 0;-
1906 }
never executed: end of block
0
1907 if (closeSide == RightSide
closeSide == RightSideDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->tabList[i].rightWidget
d->tabList[i].rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1908 d->tabList[i].rightWidget->deleteLater();-
1909 d->tabList[i].rightWidget = 0;-
1910 }
never executed: end of block
0
1911 }
never executed: end of block
0
1912 }
never executed: end of block
else {
0
1913 bool newButtons = false;-
1914 for (int i = 0; i < d->tabList.count()
i < d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1915 if (tabButton(i, closeSide)
tabButton(i, closeSide)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1916 continue;
never executed: continue;
0
1917 newButtons = true;-
1918 QAbstractButton *closeButton = new CloseButton(this);-
1919 connect(closeButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "2314"), this, qFlagLocation("1""_q_closeTab()" "\0" __FILE__ ":" "2314"));-
1920 setTabButton(i, closeSide, closeButton);-
1921 }
never executed: end of block
0
1922 if (newButtons
newButtonsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1923 d->layoutTabs();
never executed: d->layoutTabs();
0
1924 }
never executed: end of block
0
1925 update();-
1926}
never executed: end of block
0
1927QTabBar::SelectionBehavior QTabBar::selectionBehaviorOnRemove() const-
1928{-
1929 const QTabBarPrivate * const d = d_func();-
1930 return
never executed: return d->selectionBehaviorOnRemove;
d->selectionBehaviorOnRemove;
never executed: return d->selectionBehaviorOnRemove;
0
1931}-
1932-
1933void QTabBar::setSelectionBehaviorOnRemove(QTabBar::SelectionBehavior behavior)-
1934{-
1935 QTabBarPrivate * const d = d_func();-
1936 d->selectionBehaviorOnRemove = behavior;-
1937}
never executed: end of block
0
1938bool QTabBar::expanding() const-
1939{-
1940 const QTabBarPrivate * const d = d_func();-
1941 return
never executed: return d->expanding;
d->expanding;
never executed: return d->expanding;
0
1942}-
1943-
1944void QTabBar::setExpanding(bool enabled)-
1945{-
1946 QTabBarPrivate * const d = d_func();-
1947 if (d->expanding == enabled
d->expanding == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1948 return;
never executed: return;
0
1949 d->expanding = enabled;-
1950 d->layoutTabs();-
1951}
never executed: end of block
0
1952bool QTabBar::isMovable() const-
1953{-
1954 const QTabBarPrivate * const d = d_func();-
1955 return
never executed: return d->movable;
d->movable;
never executed: return d->movable;
0
1956}-
1957-
1958void QTabBar::setMovable(bool movable)-
1959{-
1960 QTabBarPrivate * const d = d_func();-
1961 d->movable = movable;-
1962}
never executed: end of block
0
1963bool QTabBar::documentMode() const-
1964{-
1965 return
never executed: return d_func()->documentMode;
d_func()->documentMode;
never executed: return d_func()->documentMode;
0
1966}-
1967-
1968void QTabBar::setDocumentMode(bool enabled)-
1969{-
1970 QTabBarPrivate * const d = d_func();-
1971-
1972 d->documentMode = enabled;-
1973 d->updateMacBorderMetrics();-
1974}
never executed: end of block
0
1975bool QTabBar::autoHide() const-
1976{-
1977 const QTabBarPrivate * const d = d_func();-
1978 return
never executed: return d->autoHide;
d->autoHide;
never executed: return d->autoHide;
0
1979}-
1980-
1981void QTabBar::setAutoHide(bool hide)-
1982{-
1983 QTabBarPrivate * const d = d_func();-
1984 if (d->autoHide == hide
d->autoHide == hideDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1985 return;
never executed: return;
0
1986-
1987 d->autoHide = hide;-
1988 if (hide
hideDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1989 d->autoHideTabs();
never executed: d->autoHideTabs();
0
1990 else-
1991 setVisible(true);
never executed: setVisible(true);
0
1992}-
1993bool QTabBar::changeCurrentOnDrag() const-
1994{-
1995 const QTabBarPrivate * const d = d_func();-
1996 return
never executed: return d->changeCurrentOnDrag;
d->changeCurrentOnDrag;
never executed: return d->changeCurrentOnDrag;
0
1997}-
1998-
1999void QTabBar::setChangeCurrentOnDrag(bool change)-
2000{-
2001 QTabBarPrivate * const d = d_func();-
2002 d->changeCurrentOnDrag = change;-
2003 if (!change
!changeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2004 d->killSwitchTabTimer();
never executed: d->killSwitchTabTimer();
0
2005}
never executed: end of block
0
2006void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget)-
2007{-
2008 QTabBarPrivate * const d = d_func();-
2009 if (index < 0
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| index >= d->tabList.count()
index >= d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2010 return;
never executed: return;
0
2011 if (widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2012 widget->setParent(this);-
2013-
2014 widget->lower();-
2015 widget->show();-
2016 }
never executed: end of block
0
2017 if (position == LeftSide
position == LeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2018 if (d->tabList[index].leftWidget
d->tabList[index].leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2019 d->tabList[index].leftWidget->hide();
never executed: d->tabList[index].leftWidget->hide();
0
2020 d->tabList[index].leftWidget = widget;-
2021 }
never executed: end of block
else {
0
2022 if (d->tabList[index].rightWidget
d->tabList[index].rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2023 d->tabList[index].rightWidget->hide();
never executed: d->tabList[index].rightWidget->hide();
0
2024 d->tabList[index].rightWidget = widget;-
2025 }
never executed: end of block
0
2026 d->layoutTabs();-
2027 d->refresh();-
2028 update();-
2029}
never executed: end of block
0
2030-
2031-
2032-
2033-
2034-
2035QWidget *QTabBar::tabButton(int index, ButtonPosition position) const-
2036{-
2037 const QTabBarPrivate * const d = d_func();-
2038 if (index < 0
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| index >= d->tabList.count()
index >= d->tabList.count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2039 return
never executed: return 0;
0;
never executed: return 0;
0
2040 if (position == LeftSide
position == LeftSideDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2041 return
never executed: return d->tabList.at(index).leftWidget;
d->tabList.at(index).leftWidget;
never executed: return d->tabList.at(index).leftWidget;
0
2042 else-
2043 return
never executed: return d->tabList.at(index).rightWidget;
d->tabList.at(index).rightWidget;
never executed: return d->tabList.at(index).rightWidget;
0
2044}-
2045-
2046CloseButton::CloseButton(QWidget *parent)-
2047 : QAbstractButton(parent)-
2048{-
2049 setFocusPolicy(Qt::NoFocus);-
2050-
2051 setCursor(Qt::ArrowCursor);-
2052-
2053-
2054 setToolTip(tr("Close Tab"));-
2055-
2056 resize(sizeHint());-
2057}
never executed: end of block
0
2058-
2059QSize CloseButton::sizeHint() const-
2060{-
2061 ensurePolished();-
2062 int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this);-
2063 int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, this);-
2064 return
never executed: return QSize(width, height);
QSize(width, height);
never executed: return QSize(width, height);
0
2065}-
2066-
2067void CloseButton::enterEvent(QEvent *event)-
2068{-
2069 if (isEnabled()
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2070 update();
never executed: update();
0
2071 QAbstractButton::enterEvent(event);-
2072}
never executed: end of block
0
2073-
2074void CloseButton::leaveEvent(QEvent *event)-
2075{-
2076 if (isEnabled()
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2077 update();
never executed: update();
0
2078 QAbstractButton::leaveEvent(event);-
2079}
never executed: end of block
0
2080-
2081void CloseButton::paintEvent(QPaintEvent *)-
2082{-
2083 QPainter p(this);-
2084 QStyleOption opt;-
2085 opt.init(this);-
2086 opt.state |= QStyle::State_AutoRaise;-
2087 if (isEnabled()
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
&& underMouse()
underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
&& !isChecked()
!isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
&& !isDown()
!isDown()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2088 opt.state |= QStyle::State_Raised;
never executed: opt.state |= QStyle::State_Raised;
0
2089 if (isChecked()
isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2090 opt.state |= QStyle::State_On;
never executed: opt.state |= QStyle::State_On;
0
2091 if (isDown()
isDown()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2092 opt.state |= QStyle::State_Sunken;
never executed: opt.state |= QStyle::State_Sunken;
0
2093-
2094 if (const
const QTabBar ...r *>(parent())Description
TRUEnever evaluated
FALSEnever evaluated
QTabBar *tb = qobject_cast<const QTabBar *>(parent())
const QTabBar ...r *>(parent())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2095 int index = tb->currentIndex();-
2096 QTabBar::ButtonPosition position = (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb);-
2097 if (tb->tabButton(index, position) == this
tb->tabButton(...ition) == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2098 opt.state |= QStyle::State_Selected;
never executed: opt.state |= QStyle::State_Selected;
0
2099 }
never executed: end of block
0
2100-
2101 style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this);-
2102}
never executed: end of block
0
2103-
2104-
2105void QTabBarPrivate::Tab::TabBarAnimation::updateCurrentValue(const QVariant &current)-
2106{-
2107 priv->moveTab(priv->tabList.indexOf(*tab), current.toInt());-
2108}
never executed: end of block
0
2109-
2110void QTabBarPrivate::Tab::TabBarAnimation::updateState(QAbstractAnimation::State, QAbstractAnimation::State newState)-
2111{-
2112 if (newState == Stopped
newState == StoppedDescription
TRUEnever evaluated
FALSEnever evaluated
) priv->moveTabFinished(priv->tabList.indexOf(*tab));
never executed: priv->moveTabFinished(priv->tabList.indexOf(*tab));
0
2113}
never executed: end of block
0
2114-
2115-
2116-
2117-
2118-
2119-
2120-
Switch to Source codePreprocessed file

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