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