branch | GCC_SURGE |
changeset 31 | 5daf16870df6 |
parent 30 | 5dc02b23752f |
child 33 | 3e2da88830cd |
27:93b982ccede2 | 31:5daf16870df6 |
---|---|
65 #ifdef Q_WS_MAC |
65 #ifdef Q_WS_MAC |
66 #include <private/qt_mac_p.h> |
66 #include <private/qt_mac_p.h> |
67 #include <private/qt_cocoa_helpers_mac_p.h> |
67 #include <private/qt_cocoa_helpers_mac_p.h> |
68 #endif |
68 #endif |
69 |
69 |
70 #ifndef QT_NO_STYLE_S60 |
|
71 #include "qs60style.h" |
|
72 #endif |
|
73 |
|
70 QT_BEGIN_NAMESPACE |
74 QT_BEGIN_NAMESPACE |
75 |
|
71 |
76 |
72 inline static bool verticalTabs(QTabBar::Shape shape) |
77 inline static bool verticalTabs(QTabBar::Shape shape) |
73 { |
78 { |
74 return shape == QTabBar::RoundedWest |
79 return shape == QTabBar::RoundedWest |
75 || shape == QTabBar::RoundedEast |
80 || shape == QTabBar::RoundedEast |
93 metrics.top = (documentMode && q->isVisible()) ? 1 : 0; |
98 metrics.top = (documentMode && q->isVisible()) ? 1 : 0; |
94 metrics.bottom = 0; |
99 metrics.bottom = 0; |
95 metrics.left = 0; |
100 metrics.left = 0; |
96 metrics.right = 0; |
101 metrics.right = 0; |
97 qt_mac_updateContentBorderMetricts(window, metrics); |
102 qt_mac_updateContentBorderMetricts(window, metrics); |
98 |
103 #if QT_MAC_USE_COCOA |
99 // hide the base line separator if the tabs have docuemnt mode enabled (Cocoa) |
104 // In Cocoa we need to keep track of the drawRect method. |
100 qt_mac_showBaseLineSeparator(window, !documentMode); |
105 // If documentMode is enabled we need to change it, unless |
106 // a toolbar is present. |
|
107 // Notice that all the information is kept in the window, |
|
108 // that's why we get the private widget for it instead of |
|
109 // the private widget for this widget. |
|
110 QWidgetPrivate *privateWidget = qt_widget_private(q->window()); |
|
111 if(privateWidget) |
|
112 privateWidget->changeMethods = documentMode; |
|
113 // Since in Cocoa there is no simple way to remove the baseline, so we just ask the |
|
114 // top level to do the magic for us. |
|
115 privateWidget->syncUnifiedMode(); |
|
116 #endif // QT_MAC_USE_COCOA |
|
101 } |
117 } |
102 #endif |
118 #endif |
103 } |
119 } |
104 |
120 |
105 /*! |
121 /*! |
476 tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size); |
492 tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size); |
477 } |
493 } |
478 |
494 |
479 if (useScrollButtons && tabList.count() && last > available) { |
495 if (useScrollButtons && tabList.count() && last > available) { |
480 int extra = extraWidth(); |
496 int extra = extraWidth(); |
497 #ifndef QT_NO_STYLE_S60 |
|
498 QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()); |
|
499 #endif |
|
481 if (!vertTabs) { |
500 if (!vertTabs) { |
482 Qt::LayoutDirection ld = q->layoutDirection(); |
501 Qt::LayoutDirection ld = q->layoutDirection(); |
483 QRect arrows = QStyle::visualRect(ld, q->rect(), |
502 QRect arrows = QStyle::visualRect(ld, q->rect(), |
484 QRect(available - extra, 0, extra, size.height())); |
503 QRect(available - extra, 0, extra, size.height())); |
485 int buttonOverlap = q->style()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, q); |
504 int buttonOverlap = q->style()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, q); |
486 |
505 |
487 if (ld == Qt::LeftToRight) { |
506 if (ld == Qt::LeftToRight) { |
507 // In S60style, tab scroll buttons are layoutted separately, on the sides of the tabbar. |
|
508 #ifndef QT_NO_STYLE_S60 |
|
509 if (s60Style) { |
|
510 rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height()); |
|
511 leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height()); |
|
512 } else { |
|
513 #endif |
|
488 leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); |
514 leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); |
489 rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), |
515 rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), |
490 extra/2, arrows.height()); |
516 extra/2, arrows.height()); |
517 #ifndef QT_NO_STYLE_S60 |
|
518 } |
|
519 #endif |
|
491 leftB->setArrowType(Qt::LeftArrow); |
520 leftB->setArrowType(Qt::LeftArrow); |
492 rightB->setArrowType(Qt::RightArrow); |
521 rightB->setArrowType(Qt::RightArrow); |
493 } else { |
522 } else { |
523 #ifndef QT_NO_STYLE_S60 |
|
524 if (s60Style) { |
|
525 rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height()); |
|
526 leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height()); |
|
527 } else { |
|
528 #endif |
|
494 rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); |
529 rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); |
495 leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), |
530 leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), |
496 extra/2, arrows.height()); |
531 extra/2, arrows.height()); |
532 #ifndef QT_NO_STYLE_S60 |
|
533 } |
|
534 #endif |
|
497 rightB->setArrowType(Qt::LeftArrow); |
535 rightB->setArrowType(Qt::LeftArrow); |
498 leftB->setArrowType(Qt::RightArrow); |
536 leftB->setArrowType(Qt::RightArrow); |
499 } |
537 } |
500 } else { |
538 } else { |
539 #ifndef QT_NO_STYLE_S60 |
|
540 if (s60Style) { |
|
541 QRect arrows = QRect(0, 0, size.width(), available ); |
|
542 leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra / 2); |
|
543 leftB->setArrowType(Qt::UpArrow); |
|
544 rightB->setGeometry(arrows.left(), arrows.bottom() - extra / 2 + 1, |
|
545 arrows.width(), extra / 2); |
|
546 rightB->setArrowType(Qt::DownArrow); |
|
547 } else { |
|
548 #endif |
|
501 QRect arrows = QRect(0, available - extra, size.width(), extra ); |
549 QRect arrows = QRect(0, available - extra, size.width(), extra ); |
502 leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2); |
550 leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2); |
503 leftB->setArrowType(Qt::UpArrow); |
551 leftB->setArrowType(Qt::UpArrow); |
504 rightB->setGeometry(arrows.left(), arrows.bottom() - extra/2 + 1, |
552 rightB->setGeometry(arrows.left(), arrows.bottom() - extra/2 + 1, |
505 arrows.width(), extra/2); |
553 arrows.width(), extra/2); |
506 rightB->setArrowType(Qt::DownArrow); |
554 rightB->setArrowType(Qt::DownArrow); |
555 #ifndef QT_NO_STYLE_S60 |
|
556 } |
|
557 #endif |
|
507 } |
558 } |
508 leftB->setEnabled(scrollOffset > 0); |
559 leftB->setEnabled(scrollOffset > 0); |
509 rightB->setEnabled(last - scrollOffset >= available - extra); |
560 rightB->setEnabled(last - scrollOffset >= available - extra); |
510 leftB->show(); |
561 leftB->show(); |
511 rightB->show(); |
562 rightB->show(); |
578 } |
629 } |
579 tab.rightWidget->move(p); |
630 tab.rightWidget->move(p); |
580 } |
631 } |
581 } |
632 } |
582 |
633 |
583 void QTabBarPrivate::layoutWidgets(int index) |
634 void QTabBarPrivate::layoutWidgets(int start) |
584 { |
635 { |
585 Q_Q(QTabBar); |
636 Q_Q(QTabBar); |
586 int start = 0; |
637 for (int i = start; i < q->count(); ++i) { |
587 int end = q->count(); |
|
588 if (index != -1) { |
|
589 start = qMax(index, 0); |
|
590 end = qMin(end, start + 1); |
|
591 } |
|
592 for (int i = start; i < end; ++i) { |
|
593 layoutTab(i); |
638 layoutTab(i); |
594 } |
639 } |
595 } |
640 } |
596 |
641 |
597 void QTabBarPrivate::_q_closeTab() |
642 void QTabBarPrivate::_q_closeTab() |
1169 if (d->validIndex(index) && d->currentIndex != index) { |
1214 if (d->validIndex(index) && d->currentIndex != index) { |
1170 d->currentIndex = index; |
1215 d->currentIndex = index; |
1171 update(); |
1216 update(); |
1172 d->makeVisible(index); |
1217 d->makeVisible(index); |
1173 d->tabList[index].lastTab = oldIndex; |
1218 d->tabList[index].lastTab = oldIndex; |
1174 d->layoutWidgets(oldIndex); |
1219 if (oldIndex >= 0 && oldIndex < count()) |
1175 d->layoutWidgets(index); |
1220 d->layoutTab(oldIndex); |
1221 d->layoutTab(index); |
|
1176 #ifdef QT3_SUPPORT |
1222 #ifdef QT3_SUPPORT |
1177 emit selected(index); |
1223 emit selected(index); |
1178 #endif |
1224 #endif |
1179 emit currentChanged(index); |
1225 emit currentChanged(index); |
1180 } |
1226 } |
1945 */ |
1991 */ |
1946 void QTabBar::changeEvent(QEvent *event) |
1992 void QTabBar::changeEvent(QEvent *event) |
1947 { |
1993 { |
1948 Q_D(QTabBar); |
1994 Q_D(QTabBar); |
1949 if (event->type() == QEvent::StyleChange) { |
1995 if (event->type() == QEvent::StyleChange) { |
1950 d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); |
1996 if (!d->elideModeSetByUser) |
1997 d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); |
|
1951 if (!d->useScrollButtonsSetByUser) |
1998 if (!d->useScrollButtonsSetByUser) |
1952 d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); |
1999 d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); |
1953 d->refresh(); |
2000 d->refresh(); |
1954 } else if (event->type() == QEvent::FontChange) { |
2001 } else if (event->type() == QEvent::FontChange) { |
1955 d->refresh(); |
2002 d->refresh(); |
1978 |
2025 |
1979 void QTabBar::setElideMode(Qt::TextElideMode mode) |
2026 void QTabBar::setElideMode(Qt::TextElideMode mode) |
1980 { |
2027 { |
1981 Q_D(QTabBar); |
2028 Q_D(QTabBar); |
1982 d->elideMode = mode; |
2029 d->elideMode = mode; |
2030 d->elideModeSetByUser = true; |
|
1983 d->refresh(); |
2031 d->refresh(); |
1984 } |
2032 } |
1985 |
2033 |
1986 /*! |
2034 /*! |
1987 \property QTabBar::usesScrollButtons |
2035 \property QTabBar::usesScrollButtons |
2194 } |
2242 } |
2195 |
2243 |
2196 void QTabBar::setDocumentMode(bool enabled) |
2244 void QTabBar::setDocumentMode(bool enabled) |
2197 { |
2245 { |
2198 Q_D(QTabBar); |
2246 Q_D(QTabBar); |
2247 |
|
2199 d->documentMode = enabled; |
2248 d->documentMode = enabled; |
2200 d->updateMacBorderMetrics(); |
2249 d->updateMacBorderMetrics(); |
2201 } |
2250 } |
2202 |
2251 |
2203 /*! |
2252 /*! |