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