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