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