Changeset 561 for trunk/src/gui/widgets/qtabbar_p.h
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/widgets/qtabbar_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 59 59 #include <qicon.h> 60 60 #include <qtoolbutton.h> 61 #include <qtimeline.h>62 #include <qhash.h>63 61 #include <qdebug.h> 62 64 63 65 64 #ifndef QT_NO_TABBAR … … 70 69 71 70 QT_BEGIN_NAMESPACE 72 73 71 74 72 class QTabBarPrivate : public QWidgetPrivate … … 77 75 public: 78 76 QTabBarPrivate() 79 :currentIndex(-1), pressedIndex(-1), 80 shape(QTabBar::RoundedNorth), 81 layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false) {} 77 :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false), 78 drawBase(true), scrollOffset(0), useScrollButtonsSetByUser(false) , expanding(true), closeButtonOnTabs(false), 79 selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), 80 dragInProgress(false), documentMode(false), movingTab(0) 81 #ifdef Q_WS_MAC 82 , previousPressedIndex(-1) 83 #endif 84 {} 82 85 83 86 int currentIndex; … … 90 93 struct Tab { 91 94 inline Tab(const QIcon &ico, const QString &txt) 92 : enabled(true) 93 , shortcutId(0) 94 , text(txt) 95 , icon(ico) 96 , leftWidget(0) 97 , rightWidget(0) 98 , lastTab(-1) 99 , timeLine(0) 100 , dragOffset(0) 101 , hidLeft(false) 102 , hidRight(false) 95 : enabled(true) , shortcutId(0), text(txt), icon(ico), 96 leftWidget(0), rightWidget(0), lastTab(-1), dragOffset(0) 97 #ifndef QT_NO_ANIMATION 98 , animation(0) 99 #endif //QT_NO_ANIMATION 103 100 {} 101 104 102 bool enabled; 105 103 int shortcutId; … … 121 119 QWidget *rightWidget; 122 120 int lastTab; 123 124 QTimeLine *timeLine;125 121 int dragOffset; 126 QPixmap animatingCache; 127 bool hidLeft; 128 bool hidRight; 129 130 void makeTimeLine(QWidget *q) { 131 if (timeLine) 132 return; 133 timeLine = new QTimeLine(ANIMATION_DURATION, q); 134 q->connect(timeLine, SIGNAL(frameChanged(int)), q, SLOT(_q_moveTab(int))); 135 q->connect(timeLine, SIGNAL(finished()), q, SLOT(_q_moveTabFinished())); 122 123 #ifndef QT_NO_ANIMATION 124 ~Tab() { delete animation; } 125 struct TabBarAnimation : public QVariantAnimation { 126 TabBarAnimation(Tab *t, QTabBarPrivate *_priv) : tab(t), priv(_priv) 127 { setEasingCurve(QEasingCurve::InOutQuad); } 128 129 void updateCurrentValue(const QVariant ¤t) 130 { priv->moveTab(priv->tabList.indexOf(*tab), current.toInt()); } 131 132 void updateState(State, State newState) 133 { if (newState == Stopped) priv->moveTabFinished(priv->tabList.indexOf(*tab)); } 134 private: 135 //these are needed for the callbacks 136 Tab *tab; 137 QTabBarPrivate *priv; 138 } *animation; 139 140 void startAnimation(QTabBarPrivate *priv, int duration) { 141 if (!animation) 142 animation = new TabBarAnimation(this, priv); 143 animation->setStartValue(dragOffset); 144 animation->setEndValue(0); 145 animation->setDuration(duration); 146 animation->start(); 136 147 } 137 138 void hideWidgets() { 139 if (!hidRight && rightWidget) { 140 hidRight = rightWidget->isVisible(); 141 rightWidget->hide(); 142 } 143 144 if (!hidLeft && leftWidget) { 145 hidLeft = leftWidget->isVisible(); 146 leftWidget->hide(); 147 } 148 } 149 150 void unHideWidgets() { 151 if (leftWidget && hidLeft) 152 leftWidget->show(); 153 hidLeft = false; 154 if (rightWidget && hidRight) 155 rightWidget->show(); 156 hidRight = false; 157 } 158 148 #else 149 void startAnimation(QTabBarPrivate *priv, int duration) 150 { Q_UNUSED(duration); priv->moveTabFinished(priv->tabList.indexOf(*this)); } 151 #endif //QT_NO_ANIMATION 159 152 }; 160 153 QList<Tab> tabList; 161 QHash<QTimeLine*, int> animations;162 154 163 155 int calculateNewPosition(int from, int to, int index) const; … … 172 164 173 165 inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); } 166 174 167 175 168 QSize minimumTabSizeHint(int index); … … 180 173 void _q_scrollTabs(); 181 174 void _q_closeTab(); 182 void _q_moveTab(int); 183 void _q_moveTabFinished(); 184 void _q_moveTabFinished(int offset); 175 void moveTab(int index, int offset); 176 void moveTabFinished(int index); 185 177 QRect hoverRect; 186 178 187 void grabCache(int start, int end, bool unhide);188 179 void refresh(); 189 180 void layoutTabs(); … … 191 182 void layoutTab(int index); 192 183 void updateMacBorderMetrics(); 184 193 185 194 186 void makeVisible(int index); … … 196 188 Qt::TextElideMode elideMode; 197 189 bool useScrollButtons; 190 198 191 199 192 bool expanding; … … 207 200 bool documentMode; 208 201 202 203 204 205 209 206 // shared by tabwidget and qtabbar 210 207 static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
Note:
See TracChangeset
for help on using the changeset viewer.