File indexing completed on 2025-02-02 14:20:06
0001 /* 0002 SPDX-FileCopyrightText: 2001, 2002, 2003 Joseph Wenninger <jowenn@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "kmultitabbar.h" 0008 #include "kmultitabbar_p.h" 0009 #include "moc_kmultitabbar.cpp" 0010 #include "moc_kmultitabbar_p.cpp" 0011 0012 #include <QMouseEvent> 0013 #include <QPainter> 0014 #include <QStyle> 0015 #include <QStyleOptionButton> 0016 0017 #include <math.h> 0018 0019 /* 0020 A bit of an overview about what's going on here: 0021 There are two sorts of things that can be in the tab bar: tabs and regular 0022 buttons. The former are managed by KMultiTabBarInternal, the later 0023 by the KMultiTabBar itself. 0024 */ 0025 0026 class KMultiTabBarTabPrivate 0027 { 0028 }; 0029 class KMultiTabBarButtonPrivate 0030 { 0031 }; 0032 0033 class KMultiTabBarPrivate 0034 { 0035 public: 0036 class KMultiTabBarInternal *m_internal; 0037 QBoxLayout *m_l; 0038 QFrame *m_btnTabSep; 0039 QList<KMultiTabBarButton *> m_buttons; 0040 KMultiTabBar::KMultiTabBarPosition m_position; 0041 }; 0042 0043 KMultiTabBarInternal::KMultiTabBarInternal(QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos) 0044 : QFrame(parent) 0045 { 0046 m_position = pos; 0047 if (pos == KMultiTabBar::Left || pos == KMultiTabBar::Right) { 0048 mainLayout = new QVBoxLayout(this); 0049 } else { 0050 mainLayout = new QHBoxLayout(this); 0051 } 0052 mainLayout->setContentsMargins(0, 0, 0, 0); 0053 mainLayout->setSpacing(0); 0054 mainLayout->addStretch(); 0055 setFrameStyle(NoFrame); 0056 setBackgroundRole(QPalette::Window); 0057 } 0058 0059 KMultiTabBarInternal::~KMultiTabBarInternal() 0060 { 0061 qDeleteAll(m_tabs); 0062 m_tabs.clear(); 0063 } 0064 0065 void KMultiTabBarInternal::setStyle(enum KMultiTabBar::KMultiTabBarStyle style) 0066 { 0067 m_style = style; 0068 for (int i = 0; i < m_tabs.count(); i++) { 0069 m_tabs.at(i)->setStyle(m_style); 0070 } 0071 0072 updateGeometry(); 0073 } 0074 0075 void KMultiTabBarInternal::contentsMousePressEvent(QMouseEvent *ev) 0076 { 0077 ev->ignore(); 0078 } 0079 0080 void KMultiTabBarInternal::mousePressEvent(QMouseEvent *ev) 0081 { 0082 ev->ignore(); 0083 } 0084 0085 KMultiTabBarTab *KMultiTabBarInternal::tab(int id) const 0086 { 0087 QListIterator<KMultiTabBarTab *> it(m_tabs); 0088 while (it.hasNext()) { 0089 KMultiTabBarTab *tab = it.next(); 0090 if (tab->id() == id) { 0091 return tab; 0092 } 0093 } 0094 return nullptr; 0095 } 0096 0097 int KMultiTabBarInternal::appendTab(const QIcon &icon, int id, const QString &text) 0098 { 0099 KMultiTabBarTab *tab; 0100 m_tabs.append(tab = new KMultiTabBarTab(icon, text, id, this, m_position, m_style)); 0101 0102 // Insert before the stretch.. 0103 mainLayout->insertWidget(m_tabs.size() - 1, tab); 0104 tab->show(); 0105 return 0; 0106 } 0107 0108 int KMultiTabBarInternal::appendTab(const QPixmap &pic, int id, const QString &text) 0109 { 0110 // reuse icon variant 0111 return appendTab(QIcon(pic), id, text); 0112 } 0113 0114 void KMultiTabBarInternal::removeTab(int id) 0115 { 0116 for (int pos = 0; pos < m_tabs.count(); pos++) { 0117 if (m_tabs.at(pos)->id() == id) { 0118 // remove & delete the tab 0119 delete m_tabs.takeAt(pos); 0120 break; 0121 } 0122 } 0123 } 0124 0125 void KMultiTabBarInternal::setPosition(enum KMultiTabBar::KMultiTabBarPosition pos) 0126 { 0127 m_position = pos; 0128 for (int i = 0; i < m_tabs.count(); i++) { 0129 m_tabs.at(i)->setPosition(m_position); 0130 } 0131 updateGeometry(); 0132 } 0133 0134 // KMultiTabBarButton 0135 /////////////////////////////////////////////////////////////////////////////// 0136 0137 KMultiTabBarButton::KMultiTabBarButton(const QIcon &icon, const QString &text, int id, QWidget *parent) 0138 : QPushButton(icon, text, parent) 0139 , m_id(id) 0140 , d(nullptr) 0141 { 0142 connect(this, &QPushButton::clicked, this, &KMultiTabBarButton::slotClicked); 0143 0144 // we can't see the focus, so don't take focus. #45557 0145 // If keyboard navigation is wanted, then only the bar should take focus, 0146 // and arrows could change the focused button; but generally, tabbars don't take focus anyway. 0147 setFocusPolicy(Qt::NoFocus); 0148 setAttribute(Qt::WA_LayoutUsesWidgetRect); 0149 Q_UNUSED(d); 0150 } 0151 0152 #if KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 72) 0153 KMultiTabBarButton::KMultiTabBarButton(const QPixmap &pic, const QString &text, int id, QWidget *parent) 0154 : QPushButton(QIcon(pic), text, parent) 0155 , m_id(id) 0156 , d(nullptr) 0157 { 0158 connect(this, &QPushButton::clicked, this, &KMultiTabBarButton::slotClicked); 0159 0160 // we can't see the focus, so don't take focus. #45557 0161 // If keyboard navigation is wanted, then only the bar should take focus, 0162 // and arrows could change the focused button; but generally, tabbars don't take focus anyway. 0163 setFocusPolicy(Qt::NoFocus); 0164 setAttribute(Qt::WA_LayoutUsesWidgetRect); 0165 Q_UNUSED(d); 0166 } 0167 #endif 0168 0169 KMultiTabBarButton::~KMultiTabBarButton() 0170 { 0171 } 0172 0173 void KMultiTabBarButton::setText(const QString &text) 0174 { 0175 QPushButton::setText(text); 0176 } 0177 0178 void KMultiTabBarButton::slotClicked() 0179 { 0180 updateGeometry(); 0181 Q_EMIT clicked(m_id); 0182 } 0183 0184 int KMultiTabBarButton::id() const 0185 { 0186 return m_id; 0187 } 0188 0189 void KMultiTabBarButton::hideEvent(QHideEvent *he) 0190 { 0191 QPushButton::hideEvent(he); 0192 KMultiTabBar *tb = dynamic_cast<KMultiTabBar *>(parentWidget()); 0193 if (tb) { 0194 tb->updateSeparator(); 0195 } 0196 } 0197 0198 void KMultiTabBarButton::showEvent(QShowEvent *he) 0199 { 0200 QPushButton::showEvent(he); 0201 KMultiTabBar *tb = dynamic_cast<KMultiTabBar *>(parentWidget()); 0202 if (tb) { 0203 tb->updateSeparator(); 0204 } 0205 } 0206 0207 void KMultiTabBarButton::paintEvent(QPaintEvent *) 0208 { 0209 QStyleOptionButton opt; 0210 opt.initFrom(this); 0211 opt.icon = icon(); 0212 opt.iconSize = iconSize(); 0213 // removes the QStyleOptionButton::HasMenu ButtonFeature 0214 opt.features = QStyleOptionButton::Flat; 0215 QPainter painter(this); 0216 style()->drawControl(QStyle::CE_PushButton, &opt, &painter, this); 0217 } 0218 0219 // KMultiTabBarTab 0220 /////////////////////////////////////////////////////////////////////////////// 0221 0222 KMultiTabBarTab::KMultiTabBarTab(const QIcon &icon, 0223 const QString &text, 0224 int id, 0225 QWidget *parent, 0226 KMultiTabBar::KMultiTabBarPosition pos, 0227 KMultiTabBar::KMultiTabBarStyle style) 0228 : KMultiTabBarButton(icon, text, id, parent) 0229 , m_style(style) 0230 , d(nullptr) 0231 { 0232 m_position = pos; 0233 setToolTip(text); 0234 setCheckable(true); 0235 // shrink down to icon only, but prefer to show text if it's there 0236 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 0237 } 0238 0239 #if KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 72) 0240 KMultiTabBarTab::KMultiTabBarTab(const QPixmap &pic, 0241 const QString &text, 0242 int id, 0243 QWidget *parent, 0244 KMultiTabBar::KMultiTabBarPosition pos, 0245 KMultiTabBar::KMultiTabBarStyle style) 0246 : KMultiTabBarButton(pic, text, id, parent) 0247 , m_style(style) 0248 , d(nullptr) 0249 { 0250 m_position = pos; 0251 setToolTip(text); 0252 setCheckable(true); 0253 // shrink down to icon only, but prefer to show text if it's there 0254 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 0255 } 0256 #endif 0257 0258 KMultiTabBarTab::~KMultiTabBarTab() 0259 { 0260 } 0261 0262 void KMultiTabBarTab::setPosition(KMultiTabBar::KMultiTabBarPosition pos) 0263 { 0264 m_position = pos; 0265 updateGeometry(); 0266 } 0267 0268 void KMultiTabBarTab::setStyle(KMultiTabBar::KMultiTabBarStyle style) 0269 { 0270 m_style = style; 0271 updateGeometry(); 0272 } 0273 0274 #if KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 72) 0275 QPixmap KMultiTabBarTab::iconPixmap() const 0276 { 0277 return icon().pixmap(iconSize()); 0278 } 0279 #endif 0280 0281 void KMultiTabBarTab::initStyleOption(QStyleOptionToolButton *opt) const 0282 { 0283 opt->initFrom(this); 0284 0285 // Setup icon.. 0286 if (!icon().isNull()) { 0287 opt->iconSize = iconSize(); 0288 opt->icon = icon(); 0289 } 0290 0291 // Should we draw text? 0292 if (shouldDrawText()) { 0293 opt->text = text(); 0294 } 0295 0296 opt->state |= QStyle::State_AutoRaise; 0297 if (!isChecked() && !isDown()) { 0298 opt->state |= QStyle::State_Raised; 0299 } 0300 if (isDown()) { 0301 opt->state |= QStyle::State_Sunken; 0302 } 0303 if (isChecked()) { 0304 opt->state |= QStyle::State_On; 0305 } 0306 0307 opt->font = font(); 0308 opt->toolButtonStyle = shouldDrawText() ? Qt::ToolButtonTextBesideIcon : Qt::ToolButtonIconOnly; 0309 opt->subControls = QStyle::SC_ToolButton; 0310 } 0311 0312 QSize KMultiTabBarTab::sizeHint() const 0313 { 0314 return computeSizeHint(shouldDrawText()); 0315 } 0316 0317 QSize KMultiTabBarTab::minimumSizeHint() const 0318 { 0319 return computeSizeHint(false); 0320 } 0321 0322 void KMultiTabBarTab::computeMargins(int *hMargin, int *vMargin) const 0323 { 0324 // Unfortunately, QStyle does not give us enough information to figure out 0325 // where to place things, so we try to reverse-engineer it 0326 QStyleOptionToolButton opt; 0327 initStyleOption(&opt); 0328 0329 QSize trialSize = opt.iconSize; 0330 QSize expandSize = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, trialSize, this); 0331 0332 *hMargin = (expandSize.width() - trialSize.width()) / 2; 0333 *vMargin = (expandSize.height() - trialSize.height()) / 2; 0334 } 0335 0336 QSize KMultiTabBarTab::computeSizeHint(bool withText) const 0337 { 0338 // Compute as horizontal first, then flip around if need be. 0339 QStyleOptionToolButton opt; 0340 initStyleOption(&opt); 0341 0342 int hMargin; 0343 int vMargin; 0344 computeMargins(&hMargin, &vMargin); 0345 0346 // Compute interior size, starting from pixmap.. 0347 QSize size = opt.iconSize; 0348 0349 // Always include text height in computation, to avoid resizing the minor direction 0350 // when expanding text.. 0351 QSize textSize = fontMetrics().size(0, text()); 0352 size.setHeight(qMax(size.height(), textSize.height())); 0353 0354 // Pick margins for major/minor direction, depending on orientation 0355 int majorMargin = isVertical() ? vMargin : hMargin; 0356 int minorMargin = isVertical() ? hMargin : vMargin; 0357 0358 size.setWidth(size.width() + 2 * majorMargin); 0359 size.setHeight(size.height() + 2 * minorMargin); 0360 0361 if (withText && !text().isEmpty()) 0362 // Add enough room for the text, and an extra major margin. 0363 { 0364 size.setWidth(size.width() + textSize.width() + majorMargin); 0365 } 0366 0367 // flip time? 0368 if (isVertical()) { 0369 return QSize(size.height(), size.width()); 0370 } else { 0371 return size; 0372 } 0373 } 0374 0375 void KMultiTabBarTab::setState(bool newState) 0376 { 0377 setChecked(newState); 0378 updateGeometry(); 0379 } 0380 0381 #if KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 72) 0382 void KMultiTabBarTab::setIcon(const QString &icon) 0383 { 0384 const QIcon i = QIcon::fromTheme(icon); 0385 setIcon(i); 0386 } 0387 #endif 0388 0389 #if KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 72) 0390 void KMultiTabBarTab::setIcon(const QPixmap &icon) 0391 { 0392 QPushButton::setIcon(icon); 0393 } 0394 #endif 0395 0396 bool KMultiTabBarTab::shouldDrawText() const 0397 { 0398 return (m_style == KMultiTabBar::KDEV3ICON) || isChecked(); 0399 } 0400 0401 bool KMultiTabBarTab::isVertical() const 0402 { 0403 return m_position == KMultiTabBar::Right || m_position == KMultiTabBar::Left; 0404 } 0405 0406 void KMultiTabBarTab::paintEvent(QPaintEvent *) 0407 { 0408 QPainter painter(this); 0409 0410 QStyleOptionToolButton opt; 0411 initStyleOption(&opt); 0412 0413 // Paint bevel.. 0414 if (underMouse() || isChecked()) { 0415 opt.text.clear(); 0416 opt.icon = QIcon(); 0417 style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &painter, this); 0418 } 0419 0420 int hMargin; 0421 int vMargin; 0422 computeMargins(&hMargin, &vMargin); 0423 0424 // We first figure out how much room we have for the text, based on 0425 // icon size and margin, try to fit in by eliding, and perhaps 0426 // give up on drawing the text entirely if we're too short on room 0427 int textRoom = 0; 0428 int iconRoom = 0; 0429 0430 QString t; 0431 if (shouldDrawText()) { 0432 if (isVertical()) { 0433 iconRoom = opt.iconSize.height() + 2 * vMargin; 0434 textRoom = height() - iconRoom - vMargin; 0435 } else { 0436 iconRoom = opt.iconSize.width() + 2 * hMargin; 0437 textRoom = width() - iconRoom - hMargin; 0438 } 0439 0440 t = painter.fontMetrics().elidedText(text(), Qt::ElideRight, textRoom); 0441 0442 // See whether anything is left. Qt will return either 0443 // ... or the ellipsis unicode character, 0x2026 0444 if (t == QLatin1String("...") || t == QChar(0x2026)) { 0445 t.clear(); 0446 } 0447 } 0448 0449 const QIcon::Mode iconMode = (opt.state & QStyle::State_MouseOver) ? QIcon::Active : QIcon::Normal; 0450 const QPixmap iconPixmap = icon().pixmap(opt.iconSize, iconMode, QIcon::On); 0451 0452 // Label time.... Simple case: no text, so just plop down the icon right in the center 0453 // We only do this when the button never draws the text, to avoid jumps in icon position 0454 // when resizing 0455 if (!shouldDrawText()) { 0456 style()->drawItemPixmap(&painter, rect(), Qt::AlignCenter | Qt::AlignVCenter, iconPixmap); 0457 return; 0458 } 0459 0460 // Now where the icon/text goes depends on text direction and tab position 0461 QRect iconArea; 0462 QRect labelArea; 0463 0464 bool bottomIcon = false; 0465 bool rtl = layoutDirection() == Qt::RightToLeft; 0466 if (isVertical()) { 0467 if (m_position == KMultiTabBar::Left && !rtl) { 0468 bottomIcon = true; 0469 } 0470 if (m_position == KMultiTabBar::Right && rtl) { 0471 bottomIcon = true; 0472 } 0473 } 0474 // alignFlags = Qt::AlignLeading | Qt::AlignVCenter; 0475 0476 const int iconXShift = (isChecked() || isDown()) ? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &opt, this) : 0; 0477 const int iconYShift = (isChecked() || isDown()) ? style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &opt, this) : 0; 0478 if (isVertical()) { 0479 if (bottomIcon) { 0480 labelArea = QRect(0, vMargin, width(), textRoom); 0481 iconArea = QRect(0, vMargin + textRoom, width(), iconRoom); 0482 iconArea.translate(iconYShift, -iconXShift); 0483 } else { 0484 labelArea = QRect(0, iconRoom, width(), textRoom); 0485 iconArea = QRect(0, 0, width(), iconRoom); 0486 iconArea.translate(-iconYShift, iconXShift); 0487 } 0488 } else { 0489 // Pretty simple --- depends only on RTL/LTR 0490 if (rtl) { 0491 labelArea = QRect(hMargin, 0, textRoom, height()); 0492 iconArea = QRect(hMargin + textRoom, 0, iconRoom, height()); 0493 } else { 0494 labelArea = QRect(iconRoom, 0, textRoom, height()); 0495 iconArea = QRect(0, 0, iconRoom, height()); 0496 } 0497 iconArea.translate(iconXShift, iconYShift); 0498 } 0499 0500 style()->drawItemPixmap(&painter, iconArea, Qt::AlignCenter | Qt::AlignVCenter, iconPixmap); 0501 0502 if (t.isEmpty()) { 0503 return; 0504 } 0505 0506 QRect labelPaintArea = labelArea; 0507 0508 if (isVertical()) { 0509 // If we're vertical, we paint to a simple 0,0 origin rect, 0510 // and get the transformations to get us in the right place 0511 labelPaintArea = QRect(0, 0, labelArea.height(), labelArea.width()); 0512 0513 QTransform tr; 0514 0515 if (bottomIcon) { 0516 tr.translate(labelArea.x(), labelPaintArea.width() + labelArea.y()); 0517 tr.rotate(-90); 0518 } else { 0519 tr.translate(labelPaintArea.height() + labelArea.x(), labelArea.y()); 0520 tr.rotate(90); 0521 } 0522 painter.setTransform(tr); 0523 } 0524 0525 opt.text = t; 0526 opt.icon = QIcon(); 0527 opt.rect = labelPaintArea; 0528 style()->drawControl(QStyle::CE_ToolButtonLabel, &opt, &painter, this); 0529 } 0530 0531 // KMultiTabBar 0532 /////////////////////////////////////////////////////////////////////////////// 0533 0534 KMultiTabBar::KMultiTabBar(QWidget *parent) 0535 : KMultiTabBar(Left, parent) 0536 { 0537 } 0538 0539 KMultiTabBar::KMultiTabBar(KMultiTabBarPosition pos, QWidget *parent) 0540 : QWidget(parent) 0541 , d(new KMultiTabBarPrivate) 0542 { 0543 if (pos == Left || pos == Right) { 0544 d->m_l = new QVBoxLayout(this); 0545 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding /*, true*/); 0546 } else { 0547 d->m_l = new QHBoxLayout(this); 0548 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed /*, true*/); 0549 } 0550 d->m_l->setContentsMargins(0, 0, 0, 0); 0551 d->m_l->setSpacing(0); 0552 0553 d->m_internal = new KMultiTabBarInternal(this, pos); 0554 setPosition(pos); 0555 setStyle(VSNET); 0556 d->m_l->insertWidget(0, d->m_internal); 0557 d->m_l->insertWidget(0, d->m_btnTabSep = new QFrame(this)); 0558 d->m_btnTabSep->setFixedHeight(4); 0559 d->m_btnTabSep->setFrameStyle(QFrame::Panel | QFrame::Sunken); 0560 d->m_btnTabSep->setLineWidth(2); 0561 d->m_btnTabSep->hide(); 0562 0563 updateGeometry(); 0564 } 0565 0566 KMultiTabBar::~KMultiTabBar() 0567 { 0568 qDeleteAll(d->m_buttons); 0569 d->m_buttons.clear(); 0570 } 0571 0572 int KMultiTabBar::appendButton(const QIcon &icon, int id, QMenu *popup, const QString &) 0573 { 0574 KMultiTabBarButton *btn = new KMultiTabBarButton(icon, QString(), id, this); 0575 // a button with a QMenu can have another size. Make sure the button has always the same size. 0576 btn->setFixedWidth(btn->height()); 0577 btn->setMenu(popup); 0578 d->m_buttons.append(btn); 0579 d->m_l->insertWidget(0, btn); 0580 btn->show(); 0581 d->m_btnTabSep->show(); 0582 return 0; 0583 } 0584 0585 #if KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 13) 0586 int KMultiTabBar::appendButton(const QPixmap &pic, int id, QMenu *popup, const QString &x) 0587 { 0588 // reuse icon variant 0589 return appendButton(QIcon(pic), id, popup, x); 0590 } 0591 #endif 0592 0593 void KMultiTabBar::updateSeparator() 0594 { 0595 bool hideSep = true; 0596 QListIterator<KMultiTabBarButton *> it(d->m_buttons); 0597 while (it.hasNext()) { 0598 if (it.next()->isVisibleTo(this)) { 0599 hideSep = false; 0600 break; 0601 } 0602 } 0603 if (hideSep) { 0604 d->m_btnTabSep->hide(); 0605 } else { 0606 d->m_btnTabSep->show(); 0607 } 0608 } 0609 0610 int KMultiTabBar::appendTab(const QIcon &icon, int id, const QString &text) 0611 { 0612 d->m_internal->appendTab(icon, id, text); 0613 return 0; 0614 } 0615 0616 #if KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 13) 0617 int KMultiTabBar::appendTab(const QPixmap &pic, int id, const QString &text) 0618 { 0619 d->m_internal->appendTab(pic, id, text); 0620 return 0; 0621 } 0622 #endif 0623 0624 KMultiTabBarButton *KMultiTabBar::button(int id) const 0625 { 0626 QListIterator<KMultiTabBarButton *> it(d->m_buttons); 0627 while (it.hasNext()) { 0628 KMultiTabBarButton *button = it.next(); 0629 if (button->id() == id) { 0630 return button; 0631 } 0632 } 0633 0634 return nullptr; 0635 } 0636 0637 KMultiTabBarTab *KMultiTabBar::tab(int id) const 0638 { 0639 return d->m_internal->tab(id); 0640 } 0641 0642 void KMultiTabBar::removeButton(int id) 0643 { 0644 for (int pos = 0; pos < d->m_buttons.count(); pos++) { 0645 if (d->m_buttons.at(pos)->id() == id) { 0646 d->m_buttons.takeAt(pos)->deleteLater(); 0647 break; 0648 } 0649 } 0650 0651 if (d->m_buttons.isEmpty()) { 0652 d->m_btnTabSep->hide(); 0653 } 0654 } 0655 0656 void KMultiTabBar::removeTab(int id) 0657 { 0658 d->m_internal->removeTab(id); 0659 } 0660 0661 void KMultiTabBar::setTab(int id, bool state) 0662 { 0663 KMultiTabBarTab *ttab = tab(id); 0664 if (ttab) { 0665 ttab->setState(state); 0666 } 0667 } 0668 0669 bool KMultiTabBar::isTabRaised(int id) const 0670 { 0671 KMultiTabBarTab *ttab = tab(id); 0672 if (ttab) { 0673 return ttab->isChecked(); 0674 } 0675 0676 return false; 0677 } 0678 0679 void KMultiTabBar::setStyle(KMultiTabBarStyle style) 0680 { 0681 d->m_internal->setStyle(style); 0682 } 0683 0684 KMultiTabBar::KMultiTabBarStyle KMultiTabBar::tabStyle() const 0685 { 0686 return d->m_internal->m_style; 0687 } 0688 0689 void KMultiTabBar::setPosition(KMultiTabBarPosition pos) 0690 { 0691 d->m_position = pos; 0692 d->m_internal->setPosition(pos); 0693 } 0694 0695 KMultiTabBar::KMultiTabBarPosition KMultiTabBar::position() const 0696 { 0697 return d->m_position; 0698 } 0699 0700 void KMultiTabBar::fontChange(const QFont & /* oldFont */) 0701 { 0702 updateGeometry(); 0703 }