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 | - | |||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | option->icon = tab.icon; | - | ||||||||||||||||||||||||
83 | option->iconSize = q->iconSize(); | - | ||||||||||||||||||||||||
84 | - | |||||||||||||||||||||||||
85 | option->leftButtonSize = tab.leftWidget
| 0 | ||||||||||||||||||||||||
86 | option->rightButtonSize = tab.rightWidget
| 0 | ||||||||||||||||||||||||
87 | option->documentMode = documentMode; | - | ||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | if (tabIndex > 0
| 0 | ||||||||||||||||||||||||
90 | option->selectedPosition = QStyleOptionTab::PreviousIsSelected; never executed: option->selectedPosition = QStyleOptionTab::PreviousIsSelected; | 0 | ||||||||||||||||||||||||
91 | else if (tabIndex + 1 < totalTabs
| 0 | ||||||||||||||||||||||||
92 | option->selectedPosition = QStyleOptionTab::NextIsSelected; never executed: option->selectedPosition = QStyleOptionTab::NextIsSelected; | 0 | ||||||||||||||||||||||||
93 | else | - | ||||||||||||||||||||||||
94 | option->selectedPosition = QStyleOptionTab::NotAdjacent; never executed: option->selectedPosition = QStyleOptionTab::NotAdjacent; | 0 | ||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||
96 | const bool paintBeginning = (
| 0 | ||||||||||||||||||||||||
97 | const bool paintEnd = (
| 0 | ||||||||||||||||||||||||
98 | if (paintBeginning
| 0 | ||||||||||||||||||||||||
99 | if (paintEnd
| 0 | ||||||||||||||||||||||||
100 | option->position = QStyleOptionTab::OnlyOneTab; never executed: option->position = QStyleOptionTab::OnlyOneTab; | 0 | ||||||||||||||||||||||||
101 | else | - | ||||||||||||||||||||||||
102 | option->position = QStyleOptionTab::Beginning; never executed: option->position = QStyleOptionTab::Beginning; | 0 | ||||||||||||||||||||||||
103 | } else if (paintEnd
| 0 | ||||||||||||||||||||||||
104 | option->position = QStyleOptionTab::End; | - | ||||||||||||||||||||||||
105 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
106 | option->position = QStyleOptionTab::Middle; | - | ||||||||||||||||||||||||
107 | } never executed: end of block | 0 | ||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | - | |||||||||||||||||||||||||
110 | if (const
| 0 | ||||||||||||||||||||||||
111 | option->features |= QStyleOptionTab::HasFrame; | - | ||||||||||||||||||||||||
112 | if (tw->cornerWidget(Qt::TopLeftCorner)
| 0 | ||||||||||||||||||||||||
113 | option->cornerWidgets |= QStyleOptionTab::LeftCornerWidget; never executed: option->cornerWidgets |= QStyleOptionTab::LeftCornerWidget; | 0 | ||||||||||||||||||||||||
114 | if (tw->cornerWidget(Qt::TopRightCorner)
| 0 | ||||||||||||||||||||||||
115 | option->cornerWidgets |= QStyleOptionTab::RightCornerWidget; never executed: option->cornerWidgets |= QStyleOptionTab::RightCornerWidget; | 0 | ||||||||||||||||||||||||
116 | } never executed: end of block | 0 | ||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||
118 | } never executed: end of block | 0 | ||||||||||||||||||||||||
119 | void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const | - | ||||||||||||||||||||||||
120 | { | - | ||||||||||||||||||||||||
121 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
122 | d->initBasicStyleOption(option, tabIndex); | - | ||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||
124 | QRect textRect = style()->subElementRect(QStyle::SE_TabBarTabText, option, this); | - | ||||||||||||||||||||||||
125 | option->text = fontMetrics().elidedText(option->text, d->elideMode, textRect.width(), | - | ||||||||||||||||||||||||
126 | Qt::TextShowMnemonic); | - | ||||||||||||||||||||||||
127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
128 | void QTabBarPrivate::init() | - | ||||||||||||||||||||||||
129 | { | - | ||||||||||||||||||||||||
130 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
131 | leftB = new QToolButton(q); | - | ||||||||||||||||||||||||
132 | leftB->setAutoRepeat(true); | - | ||||||||||||||||||||||||
133 | QObject::connect(leftB, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "396"), q, qFlagLocation("1""_q_scrollTabs()" "\0" __FILE__ ":" "396")); | - | ||||||||||||||||||||||||
134 | leftB->hide(); | - | ||||||||||||||||||||||||
135 | rightB = new QToolButton(q); | - | ||||||||||||||||||||||||
136 | rightB->setAutoRepeat(true); | - | ||||||||||||||||||||||||
137 | QObject::connect(rightB, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "400"), q, qFlagLocation("1""_q_scrollTabs()" "\0" __FILE__ ":" "400")); | - | ||||||||||||||||||||||||
138 | rightB->hide(); | - | ||||||||||||||||||||||||
139 | - | |||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | - | |||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | - | |||||||||||||||||||||||||
146 | q->setFocusPolicy(Qt::TabFocus); | - | ||||||||||||||||||||||||
147 | - | |||||||||||||||||||||||||
148 | - | |||||||||||||||||||||||||
149 | leftB->setAccessibleName(QTabBar::tr("Scroll Left")); | - | ||||||||||||||||||||||||
150 | rightB->setAccessibleName(QTabBar::tr("Scroll Right")); | - | ||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||
152 | q->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); | - | ||||||||||||||||||||||||
153 | elideMode = Qt::TextElideMode(q->style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, q)); | - | ||||||||||||||||||||||||
154 | useScrollButtons = !q->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, q); | - | ||||||||||||||||||||||||
155 | } never executed: end of block | 0 | ||||||||||||||||||||||||
156 | - | |||||||||||||||||||||||||
157 | QTabBarPrivate::Tab *QTabBarPrivate::at(int index) | - | ||||||||||||||||||||||||
158 | { | - | ||||||||||||||||||||||||
159 | return never executed: validIndex(index)?&tabList[index]:0;return validIndex(index)?&tabList[index]:0; never executed: return validIndex(index)?&tabList[index]:0; | 0 | ||||||||||||||||||||||||
160 | } | - | ||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||
162 | const QTabBarPrivate::Tab *QTabBarPrivate::at(int index) const | - | ||||||||||||||||||||||||
163 | { | - | ||||||||||||||||||||||||
164 | return never executed: validIndex(index)?&tabList[index]:0;return validIndex(index)?&tabList[index]:0; never executed: return validIndex(index)?&tabList[index]:0; | 0 | ||||||||||||||||||||||||
165 | } | - | ||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||
167 | int QTabBarPrivate::indexAtPos(const QPoint &p) const | - | ||||||||||||||||||||||||
168 | { | - | ||||||||||||||||||||||||
169 | const QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
170 | if (q->tabRect(currentIndex).contains(p)
| 0 | ||||||||||||||||||||||||
171 | return never executed: currentIndex;return currentIndex; never executed: return currentIndex; | 0 | ||||||||||||||||||||||||
172 | for (int i = 0; i < tabList.count()
| 0 | ||||||||||||||||||||||||
173 | if (tabList.at(i).enabled
| 0 | ||||||||||||||||||||||||
174 | return never executed: i;return i; never executed: return i; | 0 | ||||||||||||||||||||||||
175 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
176 | } | - | ||||||||||||||||||||||||
177 | - | |||||||||||||||||||||||||
178 | void QTabBarPrivate::layoutTabs() | - | ||||||||||||||||||||||||
179 | { | - | ||||||||||||||||||||||||
180 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
181 | layoutDirty = false; | - | ||||||||||||||||||||||||
182 | QSize size = q->size(); | - | ||||||||||||||||||||||||
183 | int last, available; | - | ||||||||||||||||||||||||
184 | int maxExtent; | - | ||||||||||||||||||||||||
185 | int i; | - | ||||||||||||||||||||||||
186 | bool vertTabs = verticalTabs(shape); | - | ||||||||||||||||||||||||
187 | int tabChainIndex = 0; | - | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, 0, q)); | - | ||||||||||||||||||||||||
190 | QVector<QLayoutStruct> tabChain(tabList.count() + 2); | - | ||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||
194 | tabChain[tabChainIndex].init(); | - | ||||||||||||||||||||||||
195 | tabChain[tabChainIndex].expansive = (
| 0 | ||||||||||||||||||||||||
196 | && (
| 0 | ||||||||||||||||||||||||
197 | tabChain[tabChainIndex].empty = true; | - | ||||||||||||||||||||||||
198 | ++tabChainIndex; | - | ||||||||||||||||||||||||
199 | if (!vertTabs
| 0 | ||||||||||||||||||||||||
200 | int minx = 0; | - | ||||||||||||||||||||||||
201 | int x = 0; | - | ||||||||||||||||||||||||
202 | int maxHeight = 0; | - | ||||||||||||||||||||||||
203 | for (i = 0; i < tabList.count()
| 0 | ||||||||||||||||||||||||
204 | QSize sz = q->tabSizeHint(i); | - | ||||||||||||||||||||||||
205 | tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height()); | - | ||||||||||||||||||||||||
206 | x += sz.width(); | - | ||||||||||||||||||||||||
207 | maxHeight = qMax(maxHeight, sz.height()); | - | ||||||||||||||||||||||||
208 | sz = q->minimumTabSizeHint(i); | - | ||||||||||||||||||||||||
209 | tabList[i].minRect = QRect(minx, 0, sz.width(), sz.height()); | - | ||||||||||||||||||||||||
210 | minx += sz.width(); | - | ||||||||||||||||||||||||
211 | tabChain[tabChainIndex].init(); | - | ||||||||||||||||||||||||
212 | tabChain[tabChainIndex].sizeHint = tabList.at(i).maxRect.width(); | - | ||||||||||||||||||||||||
213 | tabChain[tabChainIndex].minimumSize = sz.width(); | - | ||||||||||||||||||||||||
214 | tabChain[tabChainIndex].empty = false; | - | ||||||||||||||||||||||||
215 | tabChain[tabChainIndex].expansive = true; | - | ||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||
217 | if (!expanding
| 0 | ||||||||||||||||||||||||
218 | tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint; never executed: tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint; | 0 | ||||||||||||||||||||||||
219 | } never executed: end of block | 0 | ||||||||||||||||||||||||
220 | - | |||||||||||||||||||||||||
221 | last = minx; | - | ||||||||||||||||||||||||
222 | available = size.width(); | - | ||||||||||||||||||||||||
223 | maxExtent = maxHeight; | - | ||||||||||||||||||||||||
224 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
225 | int miny = 0; | - | ||||||||||||||||||||||||
226 | int y = 0; | - | ||||||||||||||||||||||||
227 | int maxWidth = 0; | - | ||||||||||||||||||||||||
228 | for (i = 0; i < tabList.count()
| 0 | ||||||||||||||||||||||||
229 | QSize sz = q->tabSizeHint(i); | - | ||||||||||||||||||||||||
230 | tabList[i].maxRect = QRect(0, y, sz.width(), sz.height()); | - | ||||||||||||||||||||||||
231 | y += sz.height(); | - | ||||||||||||||||||||||||
232 | maxWidth = qMax(maxWidth, sz.width()); | - | ||||||||||||||||||||||||
233 | sz = q->minimumTabSizeHint(i); | - | ||||||||||||||||||||||||
234 | tabList[i].minRect = QRect(0, miny, sz.width(), sz.height()); | - | ||||||||||||||||||||||||
235 | miny += sz.height(); | - | ||||||||||||||||||||||||
236 | tabChain[tabChainIndex].init(); | - | ||||||||||||||||||||||||
237 | tabChain[tabChainIndex].sizeHint = tabList.at(i).maxRect.height(); | - | ||||||||||||||||||||||||
238 | tabChain[tabChainIndex].minimumSize = sz.height(); | - | ||||||||||||||||||||||||
239 | tabChain[tabChainIndex].empty = false; | - | ||||||||||||||||||||||||
240 | tabChain[tabChainIndex].expansive = true; | - | ||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||
242 | if (!expanding
| 0 | ||||||||||||||||||||||||
243 | tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint; never executed: tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint; | 0 | ||||||||||||||||||||||||
244 | } never executed: end of block | 0 | ||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | last = miny; | - | ||||||||||||||||||||||||
247 | available = size.height(); | - | ||||||||||||||||||||||||
248 | maxExtent = maxWidth; | - | ||||||||||||||||||||||||
249 | } never executed: end of block | 0 | ||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | ((!(tabChainIndex == tabChain.count() - 1)) ? qt_assert("tabChainIndex == tabChain.count() - 1",__FILE__,523) : qt_noop()); | - | ||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||
253 | tabChain[tabChainIndex].init(); | - | ||||||||||||||||||||||||
254 | tabChain[tabChainIndex].expansive = (
| 0 | ||||||||||||||||||||||||
255 | && (
| 0 | ||||||||||||||||||||||||
256 | tabChain[tabChainIndex].empty = true; | - | ||||||||||||||||||||||||
257 | - | |||||||||||||||||||||||||
258 | - | |||||||||||||||||||||||||
259 | qGeomCalc(tabChain, 0, tabChain.count(), 0, qMax(available, last), 0); | - | ||||||||||||||||||||||||
260 | - | |||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||
262 | for (i = 0; i < tabList.count()
| 0 | ||||||||||||||||||||||||
263 | const QLayoutStruct &lstruct = tabChain.at(i + 1); | - | ||||||||||||||||||||||||
264 | if (!vertTabs
| 0 | ||||||||||||||||||||||||
265 | tabList[i].rect.setRect(lstruct.pos, 0, lstruct.size, maxExtent); never executed: tabList[i].rect.setRect(lstruct.pos, 0, lstruct.size, maxExtent); | 0 | ||||||||||||||||||||||||
266 | else | - | ||||||||||||||||||||||||
267 | tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size); never executed: tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size); | 0 | ||||||||||||||||||||||||
268 | } | - | ||||||||||||||||||||||||
269 | - | |||||||||||||||||||||||||
270 | if (useScrollButtons
| 0 | ||||||||||||||||||||||||
271 | const QRect scrollRect = normalizedScrollRect(0); | - | ||||||||||||||||||||||||
272 | scrollOffset = -scrollRect.left(); | - | ||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
275 | QStyleOption opt; | - | ||||||||||||||||||||||||
276 | opt.init(q); | - | ||||||||||||||||||||||||
277 | QRect scrollButtonLeftRect = q->style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, q); | - | ||||||||||||||||||||||||
278 | QRect scrollButtonRightRect = q->style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, q); | - | ||||||||||||||||||||||||
279 | int scrollButtonWidth = q->style()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, &opt, q); | - | ||||||||||||||||||||||||
280 | - | |||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||
282 | - | |||||||||||||||||||||||||
283 | - | |||||||||||||||||||||||||
284 | if (vertTabs
| 0 | ||||||||||||||||||||||||
285 | scrollButtonLeftRect.setHeight(scrollButtonWidth); | - | ||||||||||||||||||||||||
286 | scrollButtonRightRect.setY(scrollButtonRightRect.bottom() + 1 - scrollButtonWidth); | - | ||||||||||||||||||||||||
287 | scrollButtonRightRect.setHeight(scrollButtonWidth); | - | ||||||||||||||||||||||||
288 | leftB->setArrowType(Qt::UpArrow); | - | ||||||||||||||||||||||||
289 | rightB->setArrowType(Qt::DownArrow); | - | ||||||||||||||||||||||||
290 | } never executed: else if (q->layoutDirection() == Qt::RightToLeftend of block
| 0 | ||||||||||||||||||||||||
291 | scrollButtonRightRect.setWidth(scrollButtonWidth); | - | ||||||||||||||||||||||||
292 | scrollButtonLeftRect.setX(scrollButtonLeftRect.right() + 1 - scrollButtonWidth); | - | ||||||||||||||||||||||||
293 | scrollButtonLeftRect.setWidth(scrollButtonWidth); | - | ||||||||||||||||||||||||
294 | leftB->setArrowType(Qt::RightArrow); | - | ||||||||||||||||||||||||
295 | rightB->setArrowType(Qt::LeftArrow); | - | ||||||||||||||||||||||||
296 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
297 | scrollButtonLeftRect.setWidth(scrollButtonWidth); | - | ||||||||||||||||||||||||
298 | scrollButtonRightRect.setX(scrollButtonRightRect.right() + 1 - scrollButtonWidth); | - | ||||||||||||||||||||||||
299 | scrollButtonRightRect.setWidth(scrollButtonWidth); | - | ||||||||||||||||||||||||
300 | leftB->setArrowType(Qt::LeftArrow); | - | ||||||||||||||||||||||||
301 | rightB->setArrowType(Qt::RightArrow); | - | ||||||||||||||||||||||||
302 | } never executed: end of block | 0 | ||||||||||||||||||||||||
303 | - | |||||||||||||||||||||||||
304 | leftB->setGeometry(scrollButtonLeftRect); | - | ||||||||||||||||||||||||
305 | leftB->setEnabled(false); | - | ||||||||||||||||||||||||
306 | leftB->show(); | - | ||||||||||||||||||||||||
307 | - | |||||||||||||||||||||||||
308 | rightB->setGeometry(scrollButtonRightRect); | - | ||||||||||||||||||||||||
309 | rightB->setEnabled(last - scrollOffset > scrollRect.x() + scrollRect.width()); | - | ||||||||||||||||||||||||
310 | rightB->show(); | - | ||||||||||||||||||||||||
311 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
312 | scrollOffset = 0; | - | ||||||||||||||||||||||||
313 | rightB->hide(); | - | ||||||||||||||||||||||||
314 | leftB->hide(); | - | ||||||||||||||||||||||||
315 | } never executed: end of block | 0 | ||||||||||||||||||||||||
316 | - | |||||||||||||||||||||||||
317 | layoutWidgets(); | - | ||||||||||||||||||||||||
318 | q->tabLayoutChange(); | - | ||||||||||||||||||||||||
319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
320 | - | |||||||||||||||||||||||||
321 | QRect QTabBarPrivate::normalizedScrollRect(int index) | - | ||||||||||||||||||||||||
322 | { | - | ||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||
325 | - | |||||||||||||||||||||||||
326 | - | |||||||||||||||||||||||||
327 | - | |||||||||||||||||||||||||
328 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
329 | QStyleOptionTab opt; | - | ||||||||||||||||||||||||
330 | q->initStyleOption(&opt, currentIndex); | - | ||||||||||||||||||||||||
331 | opt.rect = q->rect(); | - | ||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | QRect scrollButtonLeftRect = q->style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, q); | - | ||||||||||||||||||||||||
334 | QRect scrollButtonRightRect = q->style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, q); | - | ||||||||||||||||||||||||
335 | QRect tearLeftRect = q->style()->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &opt, q); | - | ||||||||||||||||||||||||
336 | QRect tearRightRect = q->style()->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &opt, q); | - | ||||||||||||||||||||||||
337 | - | |||||||||||||||||||||||||
338 | if (verticalTabs(shape)
| 0 | ||||||||||||||||||||||||
339 | int topEdge, bottomEdge; | - | ||||||||||||||||||||||||
340 | bool leftButtonIsOnTop = scrollButtonLeftRect.y() < q->height() / 2; | - | ||||||||||||||||||||||||
341 | bool rightButtonIsOnTop = scrollButtonRightRect.y() < q->height() / 2; | - | ||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||
343 | if (leftButtonIsOnTop
| 0 | ||||||||||||||||||||||||
344 | topEdge = scrollButtonRightRect.bottom() + 1; | - | ||||||||||||||||||||||||
345 | bottomEdge = q->height(); | - | ||||||||||||||||||||||||
346 | } never executed: else if (!leftButtonIsOnTopend of block
| 0 | ||||||||||||||||||||||||
347 | topEdge = 0; | - | ||||||||||||||||||||||||
348 | bottomEdge = scrollButtonLeftRect.top(); | - | ||||||||||||||||||||||||
349 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
350 | topEdge = scrollButtonLeftRect.bottom() + 1; | - | ||||||||||||||||||||||||
351 | bottomEdge = scrollButtonRightRect.top(); | - | ||||||||||||||||||||||||
352 | } never executed: end of block | 0 | ||||||||||||||||||||||||
353 | - | |||||||||||||||||||||||||
354 | bool tearTopVisible = index != 0
| 0 | ||||||||||||||||||||||||
355 | bool tearBottomVisible = index != tabList.size() - 1
| 0 | ||||||||||||||||||||||||
356 | if (tearTopVisible
| 0 | ||||||||||||||||||||||||
357 | topEdge = tearLeftRect.bottom() + 1; never executed: topEdge = tearLeftRect.bottom() + 1; | 0 | ||||||||||||||||||||||||
358 | if (tearBottomVisible
| 0 | ||||||||||||||||||||||||
359 | bottomEdge = tearRightRect.top(); never executed: bottomEdge = tearRightRect.top(); | 0 | ||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||
361 | return never executed: QRect(topEdge, 0, bottomEdge - topEdge, q->height());return QRect(topEdge, 0, bottomEdge - topEdge, q->height()); never executed: return QRect(topEdge, 0, bottomEdge - topEdge, q->height()); | 0 | ||||||||||||||||||||||||
362 | } else { | - | ||||||||||||||||||||||||
363 | if (q->layoutDirection() == Qt::RightToLeft
| 0 | ||||||||||||||||||||||||
364 | scrollButtonLeftRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), scrollButtonLeftRect); | - | ||||||||||||||||||||||||
365 | scrollButtonRightRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), scrollButtonRightRect); | - | ||||||||||||||||||||||||
366 | tearLeftRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), tearLeftRect); | - | ||||||||||||||||||||||||
367 | tearRightRect = QStyle::visualRect(Qt::RightToLeft, q->rect(), tearRightRect); | - | ||||||||||||||||||||||||
368 | } never executed: end of block | 0 | ||||||||||||||||||||||||
369 | - | |||||||||||||||||||||||||
370 | int leftEdge, rightEdge; | - | ||||||||||||||||||||||||
371 | bool leftButtonIsOnLeftSide = scrollButtonLeftRect.x() < q->width() / 2; | - | ||||||||||||||||||||||||
372 | bool rightButtonIsOnLeftSide = scrollButtonRightRect.x() < q->width() / 2; | - | ||||||||||||||||||||||||
373 | - | |||||||||||||||||||||||||
374 | if (leftButtonIsOnLeftSide
| 0 | ||||||||||||||||||||||||
375 | leftEdge = scrollButtonRightRect.right() + 1; | - | ||||||||||||||||||||||||
376 | rightEdge = q->width(); | - | ||||||||||||||||||||||||
377 | } never executed: else if (!leftButtonIsOnLeftSideend of block
| 0 | ||||||||||||||||||||||||
378 | leftEdge = 0; | - | ||||||||||||||||||||||||
379 | rightEdge = scrollButtonLeftRect.left(); | - | ||||||||||||||||||||||||
380 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
381 | leftEdge = scrollButtonLeftRect.right() + 1; | - | ||||||||||||||||||||||||
382 | rightEdge = scrollButtonRightRect.left(); | - | ||||||||||||||||||||||||
383 | } never executed: end of block | 0 | ||||||||||||||||||||||||
384 | - | |||||||||||||||||||||||||
385 | bool tearLeftVisible = index != 0
| 0 | ||||||||||||||||||||||||
386 | bool tearRightVisible = index != tabList.size() - 1
| 0 | ||||||||||||||||||||||||
387 | if (tearLeftVisible
| 0 | ||||||||||||||||||||||||
388 | leftEdge = tearLeftRect.right() + 1; never executed: leftEdge = tearLeftRect.right() + 1; | 0 | ||||||||||||||||||||||||
389 | if (tearRightVisible
| 0 | ||||||||||||||||||||||||
390 | rightEdge = tearRightRect.left(); never executed: rightEdge = tearRightRect.left(); | 0 | ||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | return never executed: QRect(leftEdge, 0, rightEdge - leftEdge, q->height());return QRect(leftEdge, 0, rightEdge - leftEdge, q->height()); never executed: return QRect(leftEdge, 0, rightEdge - leftEdge, q->height()); | 0 | ||||||||||||||||||||||||
393 | } | - | ||||||||||||||||||||||||
394 | } | - | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | void QTabBarPrivate::makeVisible(int index) | - | ||||||||||||||||||||||||
397 | { | - | ||||||||||||||||||||||||
398 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
399 | if (!validIndex(index)
| 0 | ||||||||||||||||||||||||
400 | return; never executed: return; | 0 | ||||||||||||||||||||||||
401 | - | |||||||||||||||||||||||||
402 | const QRect tabRect = tabList.at(index).rect; | - | ||||||||||||||||||||||||
403 | const int oldScrollOffset = scrollOffset; | - | ||||||||||||||||||||||||
404 | const bool horiz = !verticalTabs(shape); | - | ||||||||||||||||||||||||
405 | const int tabStart = horiz
| 0 | ||||||||||||||||||||||||
406 | const int tabEnd = horiz
| 0 | ||||||||||||||||||||||||
407 | const int lastTabEnd = horiz
| 0 | ||||||||||||||||||||||||
408 | const QRect scrollRect = normalizedScrollRect(index); | - | ||||||||||||||||||||||||
409 | const int scrolledTabBarStart = qMax(1, scrollRect.left() + scrollOffset); | - | ||||||||||||||||||||||||
410 | const int scrolledTabBarEnd = qMin(lastTabEnd - 1, scrollRect.right() + scrollOffset); | - | ||||||||||||||||||||||||
411 | - | |||||||||||||||||||||||||
412 | if (tabStart < scrolledTabBarStart
| 0 | ||||||||||||||||||||||||
413 | - | |||||||||||||||||||||||||
414 | scrollOffset = tabStart - scrollRect.left(); | - | ||||||||||||||||||||||||
415 | } never executed: else if (tabEnd > scrolledTabBarEndend of block
| 0 | ||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | scrollOffset = tabEnd - scrollRect.right(); | - | ||||||||||||||||||||||||
418 | } never executed: end of block | 0 | ||||||||||||||||||||||||
419 | - | |||||||||||||||||||||||||
420 | leftB->setEnabled(scrollOffset > -scrollRect.left()); | - | ||||||||||||||||||||||||
421 | rightB->setEnabled(scrollOffset < lastTabEnd - scrollRect.right()); | - | ||||||||||||||||||||||||
422 | - | |||||||||||||||||||||||||
423 | if (oldScrollOffset != scrollOffset
| 0 | ||||||||||||||||||||||||
424 | q->update(); | - | ||||||||||||||||||||||||
425 | layoutWidgets(); | - | ||||||||||||||||||||||||
426 | } never executed: end of block | 0 | ||||||||||||||||||||||||
427 | } never executed: end of block | 0 | ||||||||||||||||||||||||
428 | - | |||||||||||||||||||||||||
429 | void QTabBarPrivate::killSwitchTabTimer() | - | ||||||||||||||||||||||||
430 | { | - | ||||||||||||||||||||||||
431 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
432 | if (switchTabTimerId
| 0 | ||||||||||||||||||||||||
433 | q->killTimer(switchTabTimerId); | - | ||||||||||||||||||||||||
434 | switchTabTimerId = 0; | - | ||||||||||||||||||||||||
435 | } never executed: end of block | 0 | ||||||||||||||||||||||||
436 | switchTabCurrentIndex = -1; | - | ||||||||||||||||||||||||
437 | } never executed: end of block | 0 | ||||||||||||||||||||||||
438 | - | |||||||||||||||||||||||||
439 | void QTabBarPrivate::layoutTab(int index) | - | ||||||||||||||||||||||||
440 | { | - | ||||||||||||||||||||||||
441 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
442 | ((!(index >= 0)) ? qt_assert("index >= 0",__FILE__,714) : qt_noop()); | - | ||||||||||||||||||||||||
443 | - | |||||||||||||||||||||||||
444 | Tab &tab = tabList[index]; | - | ||||||||||||||||||||||||
445 | bool vertical = verticalTabs(shape); | - | ||||||||||||||||||||||||
446 | if (!(tab.leftWidget
| 0 | ||||||||||||||||||||||||
447 | return; never executed: return; | 0 | ||||||||||||||||||||||||
448 | - | |||||||||||||||||||||||||
449 | QStyleOptionTab opt; | - | ||||||||||||||||||||||||
450 | q->initStyleOption(&opt, index); | - | ||||||||||||||||||||||||
451 | if (tab.leftWidget
| 0 | ||||||||||||||||||||||||
452 | QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q); | - | ||||||||||||||||||||||||
453 | QPoint p = rect.topLeft(); | - | ||||||||||||||||||||||||
454 | if ((
| 0 | ||||||||||||||||||||||||
455 | if (vertical
| 0 | ||||||||||||||||||||||||
456 | p.setY(p.y() + tabList[index].dragOffset); never executed: p.setY(p.y() + tabList[index].dragOffset); | 0 | ||||||||||||||||||||||||
457 | else | - | ||||||||||||||||||||||||
458 | p.setX(p.x() + tabList[index].dragOffset); never executed: p.setX(p.x() + tabList[index].dragOffset); | 0 | ||||||||||||||||||||||||
459 | } | - | ||||||||||||||||||||||||
460 | tab.leftWidget->move(p); | - | ||||||||||||||||||||||||
461 | } never executed: end of block | 0 | ||||||||||||||||||||||||
462 | if (tab.rightWidget
| 0 | ||||||||||||||||||||||||
463 | QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabRightButton, &opt, q); | - | ||||||||||||||||||||||||
464 | QPoint p = rect.topLeft(); | - | ||||||||||||||||||||||||
465 | if ((
| 0 | ||||||||||||||||||||||||
466 | if (vertical
| 0 | ||||||||||||||||||||||||
467 | p.setY(p.y() + tab.dragOffset); never executed: p.setY(p.y() + tab.dragOffset); | 0 | ||||||||||||||||||||||||
468 | else | - | ||||||||||||||||||||||||
469 | p.setX(p.x() + tab.dragOffset); never executed: p.setX(p.x() + tab.dragOffset); | 0 | ||||||||||||||||||||||||
470 | } | - | ||||||||||||||||||||||||
471 | tab.rightWidget->move(p); | - | ||||||||||||||||||||||||
472 | } never executed: end of block | 0 | ||||||||||||||||||||||||
473 | } never executed: end of block | 0 | ||||||||||||||||||||||||
474 | - | |||||||||||||||||||||||||
475 | void QTabBarPrivate::layoutWidgets(int start) | - | ||||||||||||||||||||||||
476 | { | - | ||||||||||||||||||||||||
477 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
478 | for (int i = start; i < q->count()
| 0 | ||||||||||||||||||||||||
479 | layoutTab(i); | - | ||||||||||||||||||||||||
480 | } never executed: end of block | 0 | ||||||||||||||||||||||||
481 | } never executed: end of block | 0 | ||||||||||||||||||||||||
482 | - | |||||||||||||||||||||||||
483 | void QTabBarPrivate::autoHideTabs() | - | ||||||||||||||||||||||||
484 | { | - | ||||||||||||||||||||||||
485 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||
487 | if (autoHide
| 0 | ||||||||||||||||||||||||
488 | q->setVisible(q->count() > 1); never executed: q->setVisible(q->count() > 1); | 0 | ||||||||||||||||||||||||
489 | } never executed: end of block | 0 | ||||||||||||||||||||||||
490 | - | |||||||||||||||||||||||||
491 | void QTabBarPrivate::_q_closeTab() | - | ||||||||||||||||||||||||
492 | { | - | ||||||||||||||||||||||||
493 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
494 | QObject *object = q->sender(); | - | ||||||||||||||||||||||||
495 | int tabToClose = -1; | - | ||||||||||||||||||||||||
496 | QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)q->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, q); | - | ||||||||||||||||||||||||
497 | for (int i = 0; i < tabList.count()
| 0 | ||||||||||||||||||||||||
498 | if (closeSide == QTabBar::LeftSide
| 0 | ||||||||||||||||||||||||
499 | if (tabList.at(i).leftWidget == object
| 0 | ||||||||||||||||||||||||
500 | tabToClose = i; | - | ||||||||||||||||||||||||
501 | break; never executed: break; | 0 | ||||||||||||||||||||||||
502 | } | - | ||||||||||||||||||||||||
503 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
504 | if (tabList.at(i).rightWidget == object
| 0 | ||||||||||||||||||||||||
505 | tabToClose = i; | - | ||||||||||||||||||||||||
506 | break; never executed: break; | 0 | ||||||||||||||||||||||||
507 | } | - | ||||||||||||||||||||||||
508 | } never executed: end of block | 0 | ||||||||||||||||||||||||
509 | } | - | ||||||||||||||||||||||||
510 | if (tabToClose != -1
| 0 | ||||||||||||||||||||||||
511 | q->tabCloseRequested(tabToClose); never executed: q->tabCloseRequested(tabToClose); | 0 | ||||||||||||||||||||||||
512 | } never executed: end of block | 0 | ||||||||||||||||||||||||
513 | - | |||||||||||||||||||||||||
514 | void QTabBarPrivate::_q_scrollTabs() | - | ||||||||||||||||||||||||
515 | { | - | ||||||||||||||||||||||||
516 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
517 | const QObject *sender = q->sender(); | - | ||||||||||||||||||||||||
518 | const bool horizontal = !verticalTabs(shape); | - | ||||||||||||||||||||||||
519 | const QRect scrollRect = normalizedScrollRect(); | - | ||||||||||||||||||||||||
520 | int i = -1; | - | ||||||||||||||||||||||||
521 | - | |||||||||||||||||||||||||
522 | if (sender == leftB
| 0 | ||||||||||||||||||||||||
523 | for (i = tabList.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
524 | int start = horizontal
| 0 | ||||||||||||||||||||||||
525 | if (start < scrollRect.left() + scrollOffset
| 0 | ||||||||||||||||||||||||
526 | makeVisible(i); | - | ||||||||||||||||||||||||
527 | return; never executed: return; | 0 | ||||||||||||||||||||||||
528 | } | - | ||||||||||||||||||||||||
529 | } never executed: end of block | 0 | ||||||||||||||||||||||||
530 | } never executed: else if (sender == rightBend of block
| 0 | ||||||||||||||||||||||||
531 | for (i = 0; i < tabList.count()
| 0 | ||||||||||||||||||||||||
532 | int end = horizontal
| 0 | ||||||||||||||||||||||||
533 | if (end > scrollRect.right() + scrollOffset
| 0 | ||||||||||||||||||||||||
534 | makeVisible(i); | - | ||||||||||||||||||||||||
535 | return; never executed: return; | 0 | ||||||||||||||||||||||||
536 | } | - | ||||||||||||||||||||||||
537 | } never executed: end of block | 0 | ||||||||||||||||||||||||
538 | } never executed: end of block | 0 | ||||||||||||||||||||||||
539 | } never executed: end of block | 0 | ||||||||||||||||||||||||
540 | - | |||||||||||||||||||||||||
541 | void QTabBarPrivate::refresh() | - | ||||||||||||||||||||||||
542 | { | - | ||||||||||||||||||||||||
543 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
544 | - | |||||||||||||||||||||||||
545 | - | |||||||||||||||||||||||||
546 | if (pressedIndex != -1
| 0 | ||||||||||||||||||||||||
547 | && movable
| 0 | ||||||||||||||||||||||||
548 | && QApplication::mouseButtons() == Qt::NoButton
| 0 | ||||||||||||||||||||||||
549 | moveTabFinished(pressedIndex); | - | ||||||||||||||||||||||||
550 | if (!validIndex(pressedIndex)
| 0 | ||||||||||||||||||||||||
551 | pressedIndex = -1; never executed: pressedIndex = -1; | 0 | ||||||||||||||||||||||||
552 | } never executed: end of block | 0 | ||||||||||||||||||||||||
553 | - | |||||||||||||||||||||||||
554 | if (!q->isVisible()
| 0 | ||||||||||||||||||||||||
555 | layoutDirty = true; | - | ||||||||||||||||||||||||
556 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
557 | layoutTabs(); | - | ||||||||||||||||||||||||
558 | makeVisible(currentIndex); | - | ||||||||||||||||||||||||
559 | q->update(); | - | ||||||||||||||||||||||||
560 | q->updateGeometry(); | - | ||||||||||||||||||||||||
561 | } never executed: end of block | 0 | ||||||||||||||||||||||||
562 | } | - | ||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | - | |||||||||||||||||||||||||
567 | QTabBar::QTabBar(QWidget* parent) | - | ||||||||||||||||||||||||
568 | :QWidget(*new QTabBarPrivate, parent, 0) | - | ||||||||||||||||||||||||
569 | { | - | ||||||||||||||||||||||||
570 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
571 | d->init(); | - | ||||||||||||||||||||||||
572 | } never executed: end of block | 0 | ||||||||||||||||||||||||
573 | - | |||||||||||||||||||||||||
574 | - | |||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | - | |||||||||||||||||||||||||
577 | - | |||||||||||||||||||||||||
578 | QTabBar::~QTabBar() | - | ||||||||||||||||||||||||
579 | { | - | ||||||||||||||||||||||||
580 | } | - | ||||||||||||||||||||||||
581 | QTabBar::Shape QTabBar::shape() const | - | ||||||||||||||||||||||||
582 | { | - | ||||||||||||||||||||||||
583 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
584 | return never executed: d->shape;return d->shape; never executed: return d->shape; | 0 | ||||||||||||||||||||||||
585 | } | - | ||||||||||||||||||||||||
586 | - | |||||||||||||||||||||||||
587 | void QTabBar::setShape(Shape shape) | - | ||||||||||||||||||||||||
588 | { | - | ||||||||||||||||||||||||
589 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
590 | if (d->shape == shape
| 0 | ||||||||||||||||||||||||
591 | return; never executed: return; | 0 | ||||||||||||||||||||||||
592 | d->shape = shape; | - | ||||||||||||||||||||||||
593 | d->refresh(); | - | ||||||||||||||||||||||||
594 | } never executed: end of block | 0 | ||||||||||||||||||||||||
595 | void QTabBar::setDrawBase(bool drawBase) | - | ||||||||||||||||||||||||
596 | { | - | ||||||||||||||||||||||||
597 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
598 | if (d->drawBase == drawBase
| 0 | ||||||||||||||||||||||||
599 | return; never executed: return; | 0 | ||||||||||||||||||||||||
600 | d->drawBase = drawBase; | - | ||||||||||||||||||||||||
601 | update(); | - | ||||||||||||||||||||||||
602 | } never executed: end of block | 0 | ||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||
604 | bool QTabBar::drawBase() const | - | ||||||||||||||||||||||||
605 | { | - | ||||||||||||||||||||||||
606 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
607 | return never executed: d->drawBase;return d->drawBase; never executed: return d->drawBase; | 0 | ||||||||||||||||||||||||
608 | } | - | ||||||||||||||||||||||||
609 | - | |||||||||||||||||||||||||
610 | - | |||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||
612 | - | |||||||||||||||||||||||||
613 | - | |||||||||||||||||||||||||
614 | int QTabBar::addTab(const QString &text) | - | ||||||||||||||||||||||||
615 | { | - | ||||||||||||||||||||||||
616 | return never executed: insertTab(-1, text);return insertTab(-1, text); never executed: return insertTab(-1, text); | 0 | ||||||||||||||||||||||||
617 | } | - | ||||||||||||||||||||||||
618 | - | |||||||||||||||||||||||||
619 | - | |||||||||||||||||||||||||
620 | - | |||||||||||||||||||||||||
621 | - | |||||||||||||||||||||||||
622 | - | |||||||||||||||||||||||||
623 | - | |||||||||||||||||||||||||
624 | - | |||||||||||||||||||||||||
625 | int QTabBar::addTab(const QIcon& icon, const QString &text) | - | ||||||||||||||||||||||||
626 | { | - | ||||||||||||||||||||||||
627 | return never executed: insertTab(-1, icon, text);return insertTab(-1, icon, text); never executed: return insertTab(-1, icon, text); | 0 | ||||||||||||||||||||||||
628 | } | - | ||||||||||||||||||||||||
629 | - | |||||||||||||||||||||||||
630 | - | |||||||||||||||||||||||||
631 | - | |||||||||||||||||||||||||
632 | - | |||||||||||||||||||||||||
633 | - | |||||||||||||||||||||||||
634 | - | |||||||||||||||||||||||||
635 | int QTabBar::insertTab(int index, const QString &text) | - | ||||||||||||||||||||||||
636 | { | - | ||||||||||||||||||||||||
637 | return never executed: insertTab(index, QIcon(), text);return insertTab(index, QIcon(), text); never executed: return insertTab(index, QIcon(), text); | 0 | ||||||||||||||||||||||||
638 | } | - | ||||||||||||||||||||||||
639 | int QTabBar::insertTab(int index, const QIcon& icon, const QString &text) | - | ||||||||||||||||||||||||
640 | { | - | ||||||||||||||||||||||||
641 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
642 | if (!d->validIndex(index)
| 0 | ||||||||||||||||||||||||
643 | index = d->tabList.count(); | - | ||||||||||||||||||||||||
644 | d->tabList.append(QTabBarPrivate::Tab(icon, text)); | - | ||||||||||||||||||||||||
645 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
646 | d->tabList.insert(index, QTabBarPrivate::Tab(icon, text)); | - | ||||||||||||||||||||||||
647 | } never executed: end of block | 0 | ||||||||||||||||||||||||
648 | - | |||||||||||||||||||||||||
649 | d->tabList[index].shortcutId = grabShortcut(QKeySequence::mnemonic(text)); | - | ||||||||||||||||||||||||
650 | - | |||||||||||||||||||||||||
651 | d->refresh(); | - | ||||||||||||||||||||||||
652 | if (d->tabList.count() == 1
| 0 | ||||||||||||||||||||||||
653 | setCurrentIndex(index); never executed: setCurrentIndex(index); | 0 | ||||||||||||||||||||||||
654 | else if (index <= d->currentIndex
| 0 | ||||||||||||||||||||||||
655 | ++ never executed: d->currentIndex;++d->currentIndex; never executed: ++d->currentIndex; | 0 | ||||||||||||||||||||||||
656 | - | |||||||||||||||||||||||||
657 | if (d->closeButtonOnTabs
| 0 | ||||||||||||||||||||||||
658 | QStyleOptionTab opt; | - | ||||||||||||||||||||||||
659 | initStyleOption(&opt, index); | - | ||||||||||||||||||||||||
660 | ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this); | - | ||||||||||||||||||||||||
661 | QAbstractButton *closeButton = new CloseButton(this); | - | ||||||||||||||||||||||||
662 | connect(closeButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "967"), this, qFlagLocation("1""_q_closeTab()" "\0" __FILE__ ":" "967")); | - | ||||||||||||||||||||||||
663 | setTabButton(index, closeSide, closeButton); | - | ||||||||||||||||||||||||
664 | } never executed: end of block | 0 | ||||||||||||||||||||||||
665 | - | |||||||||||||||||||||||||
666 | for (int i = 0; i < d->tabList.count()
| 0 | ||||||||||||||||||||||||
667 | if (d->tabList[i].lastTab >= index
| 0 | ||||||||||||||||||||||||
668 | ++ never executed: d->tabList[i].lastTab;++d->tabList[i].lastTab; never executed: ++d->tabList[i].lastTab; | 0 | ||||||||||||||||||||||||
669 | } never executed: end of block | 0 | ||||||||||||||||||||||||
670 | - | |||||||||||||||||||||||||
671 | tabInserted(index); | - | ||||||||||||||||||||||||
672 | d->autoHideTabs(); | - | ||||||||||||||||||||||||
673 | return never executed: index;return index; never executed: return index; | 0 | ||||||||||||||||||||||||
674 | } | - | ||||||||||||||||||||||||
675 | - | |||||||||||||||||||||||||
676 | - | |||||||||||||||||||||||||
677 | - | |||||||||||||||||||||||||
678 | - | |||||||||||||||||||||||||
679 | - | |||||||||||||||||||||||||
680 | - | |||||||||||||||||||||||||
681 | - | |||||||||||||||||||||||||
682 | void QTabBar::removeTab(int index) | - | ||||||||||||||||||||||||
683 | { | - | ||||||||||||||||||||||||
684 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
685 | if (d->validIndex(index)
| 0 | ||||||||||||||||||||||||
686 | if (d->dragInProgress
| 0 | ||||||||||||||||||||||||
687 | d->moveTabFinished(d->pressedIndex); never executed: d->moveTabFinished(d->pressedIndex); | 0 | ||||||||||||||||||||||||
688 | - | |||||||||||||||||||||||||
689 | - | |||||||||||||||||||||||||
690 | releaseShortcut(d->tabList.at(index).shortcutId); | - | ||||||||||||||||||||||||
691 | - | |||||||||||||||||||||||||
692 | if (d->tabList[index].leftWidget
| 0 | ||||||||||||||||||||||||
693 | d->tabList[index].leftWidget->hide(); | - | ||||||||||||||||||||||||
694 | d->tabList[index].leftWidget->deleteLater(); | - | ||||||||||||||||||||||||
695 | d->tabList[index].leftWidget = 0; | - | ||||||||||||||||||||||||
696 | } never executed: end of block | 0 | ||||||||||||||||||||||||
697 | if (d->tabList[index].rightWidget
| 0 | ||||||||||||||||||||||||
698 | d->tabList[index].rightWidget->hide(); | - | ||||||||||||||||||||||||
699 | d->tabList[index].rightWidget->deleteLater(); | - | ||||||||||||||||||||||||
700 | d->tabList[index].rightWidget = 0; | - | ||||||||||||||||||||||||
701 | } never executed: end of block | 0 | ||||||||||||||||||||||||
702 | - | |||||||||||||||||||||||||
703 | int newIndex = d->tabList[index].lastTab; | - | ||||||||||||||||||||||||
704 | d->tabList.removeAt(index); | - | ||||||||||||||||||||||||
705 | for (int i = 0; i < d->tabList.count()
| 0 | ||||||||||||||||||||||||
706 | if (d->tabList[i].lastTab == index
| 0 | ||||||||||||||||||||||||
707 | d->tabList[i].lastTab = -1; never executed: d->tabList[i].lastTab = -1; | 0 | ||||||||||||||||||||||||
708 | if (d->tabList[i].lastTab > index
| 0 | ||||||||||||||||||||||||
709 | -- never executed: d->tabList[i].lastTab;--d->tabList[i].lastTab; never executed: --d->tabList[i].lastTab; | 0 | ||||||||||||||||||||||||
710 | } never executed: end of block | 0 | ||||||||||||||||||||||||
711 | if (index == d->currentIndex
| 0 | ||||||||||||||||||||||||
712 | - | |||||||||||||||||||||||||
713 | - | |||||||||||||||||||||||||
714 | - | |||||||||||||||||||||||||
715 | d->currentIndex = -1; | - | ||||||||||||||||||||||||
716 | if (d->tabList.size() > 0
| 0 | ||||||||||||||||||||||||
717 | switch(d->selectionBehaviorOnRemove) { | - | ||||||||||||||||||||||||
718 | case never executed: SelectPreviousTab:case SelectPreviousTab: never executed: case SelectPreviousTab: | 0 | ||||||||||||||||||||||||
719 | if (newIndex > index
| 0 | ||||||||||||||||||||||||
720 | newIndex--; never executed: newIndex--; | 0 | ||||||||||||||||||||||||
721 | if (d->validIndex(newIndex)
| 0 | ||||||||||||||||||||||||
722 | break; never executed: break; | 0 | ||||||||||||||||||||||||
723 | - | |||||||||||||||||||||||||
724 | case never executed: SelectRightTab:case SelectRightTab: never executed: case SelectRightTab: code before this statement never executed: case SelectRightTab: | 0 | ||||||||||||||||||||||||
725 | newIndex = index; | - | ||||||||||||||||||||||||
726 | if (newIndex >= d->tabList.size()
| 0 | ||||||||||||||||||||||||
727 | newIndex = d->tabList.size() - 1; never executed: newIndex = d->tabList.size() - 1; | 0 | ||||||||||||||||||||||||
728 | break; never executed: break; | 0 | ||||||||||||||||||||||||
729 | case never executed: SelectLeftTab:case SelectLeftTab: never executed: case SelectLeftTab: | 0 | ||||||||||||||||||||||||
730 | newIndex = index - 1; | - | ||||||||||||||||||||||||
731 | if (newIndex < 0
| 0 | ||||||||||||||||||||||||
732 | newIndex = 0; never executed: newIndex = 0; | 0 | ||||||||||||||||||||||||
733 | break; never executed: break; | 0 | ||||||||||||||||||||||||
734 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
735 | break; never executed: break; | 0 | ||||||||||||||||||||||||
736 | } | - | ||||||||||||||||||||||||
737 | - | |||||||||||||||||||||||||
738 | if (d->validIndex(newIndex)
| 0 | ||||||||||||||||||||||||
739 | - | |||||||||||||||||||||||||
740 | int bump = d->tabList[newIndex].lastTab; | - | ||||||||||||||||||||||||
741 | setCurrentIndex(newIndex); | - | ||||||||||||||||||||||||
742 | d->tabList[newIndex].lastTab = bump; | - | ||||||||||||||||||||||||
743 | } never executed: end of block | 0 | ||||||||||||||||||||||||
744 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
745 | currentChanged(-1); | - | ||||||||||||||||||||||||
746 | } never executed: end of block | 0 | ||||||||||||||||||||||||
747 | } else if (index < d->currentIndex
| 0 | ||||||||||||||||||||||||
748 | setCurrentIndex(d->currentIndex - 1); | - | ||||||||||||||||||||||||
749 | } never executed: end of block | 0 | ||||||||||||||||||||||||
750 | d->refresh(); | - | ||||||||||||||||||||||||
751 | d->autoHideTabs(); | - | ||||||||||||||||||||||||
752 | tabRemoved(index); | - | ||||||||||||||||||||||||
753 | } never executed: end of block | 0 | ||||||||||||||||||||||||
754 | } never executed: end of block | 0 | ||||||||||||||||||||||||
755 | - | |||||||||||||||||||||||||
756 | - | |||||||||||||||||||||||||
757 | - | |||||||||||||||||||||||||
758 | - | |||||||||||||||||||||||||
759 | - | |||||||||||||||||||||||||
760 | - | |||||||||||||||||||||||||
761 | bool QTabBar::isTabEnabled(int index) const | - | ||||||||||||||||||||||||
762 | { | - | ||||||||||||||||||||||||
763 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
764 | if (const
| 0 | ||||||||||||||||||||||||
765 | return never executed: tab->enabled;return tab->enabled; never executed: return tab->enabled; | 0 | ||||||||||||||||||||||||
766 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
767 | } | - | ||||||||||||||||||||||||
768 | - | |||||||||||||||||||||||||
769 | - | |||||||||||||||||||||||||
770 | - | |||||||||||||||||||||||||
771 | - | |||||||||||||||||||||||||
772 | - | |||||||||||||||||||||||||
773 | void QTabBar::setTabEnabled(int index, bool enabled) | - | ||||||||||||||||||||||||
774 | { | - | ||||||||||||||||||||||||
775 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
776 | if (QTabBarPrivate::Tab *tab = d->at(index)
| 0 | ||||||||||||||||||||||||
777 | tab->enabled = enabled; | - | ||||||||||||||||||||||||
778 | - | |||||||||||||||||||||||||
779 | setShortcutEnabled(tab->shortcutId, enabled); | - | ||||||||||||||||||||||||
780 | - | |||||||||||||||||||||||||
781 | update(); | - | ||||||||||||||||||||||||
782 | if (!enabled
| 0 | ||||||||||||||||||||||||
783 | setCurrentIndex(d->validIndex(index+1)?index+1:0); never executed: setCurrentIndex(d->validIndex(index+1)?index+1:0); | 0 | ||||||||||||||||||||||||
784 | else if (enabled
| 0 | ||||||||||||||||||||||||
785 | setCurrentIndex(index); never executed: setCurrentIndex(index); | 0 | ||||||||||||||||||||||||
786 | } never executed: end of block | 0 | ||||||||||||||||||||||||
787 | } never executed: end of block | 0 | ||||||||||||||||||||||||
788 | - | |||||||||||||||||||||||||
789 | - | |||||||||||||||||||||||||
790 | - | |||||||||||||||||||||||||
791 | - | |||||||||||||||||||||||||
792 | - | |||||||||||||||||||||||||
793 | - | |||||||||||||||||||||||||
794 | QString QTabBar::tabText(int index) const | - | ||||||||||||||||||||||||
795 | { | - | ||||||||||||||||||||||||
796 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
797 | if (const
| 0 | ||||||||||||||||||||||||
798 | return never executed: tab->text;return tab->text; never executed: return tab->text; | 0 | ||||||||||||||||||||||||
799 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
800 | } | - | ||||||||||||||||||||||||
801 | - | |||||||||||||||||||||||||
802 | - | |||||||||||||||||||||||||
803 | - | |||||||||||||||||||||||||
804 | - | |||||||||||||||||||||||||
805 | void QTabBar::setTabText(int index, const QString &text) | - | ||||||||||||||||||||||||
806 | { | - | ||||||||||||||||||||||||
807 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
808 | if (QTabBarPrivate::Tab *tab = d->at(index)
| 0 | ||||||||||||||||||||||||
809 | d->textSizes.remove(tab->text); | - | ||||||||||||||||||||||||
810 | tab->text = text; | - | ||||||||||||||||||||||||
811 | - | |||||||||||||||||||||||||
812 | releaseShortcut(tab->shortcutId); | - | ||||||||||||||||||||||||
813 | tab->shortcutId = grabShortcut(QKeySequence::mnemonic(text)); | - | ||||||||||||||||||||||||
814 | setShortcutEnabled(tab->shortcutId, tab->enabled); | - | ||||||||||||||||||||||||
815 | - | |||||||||||||||||||||||||
816 | d->refresh(); | - | ||||||||||||||||||||||||
817 | } never executed: end of block | 0 | ||||||||||||||||||||||||
818 | } never executed: end of block | 0 | ||||||||||||||||||||||||
819 | - | |||||||||||||||||||||||||
820 | - | |||||||||||||||||||||||||
821 | - | |||||||||||||||||||||||||
822 | - | |||||||||||||||||||||||||
823 | - | |||||||||||||||||||||||||
824 | - | |||||||||||||||||||||||||
825 | - | |||||||||||||||||||||||||
826 | QColor QTabBar::tabTextColor(int index) const | - | ||||||||||||||||||||||||
827 | { | - | ||||||||||||||||||||||||
828 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
829 | if (const
| 0 | ||||||||||||||||||||||||
830 | return never executed: tab->textColor;return tab->textColor; never executed: return tab->textColor; | 0 | ||||||||||||||||||||||||
831 | return never executed: QColor();return QColor(); never executed: return QColor(); | 0 | ||||||||||||||||||||||||
832 | } | - | ||||||||||||||||||||||||
833 | void QTabBar::setTabTextColor(int index, const QColor &color) | - | ||||||||||||||||||||||||
834 | { | - | ||||||||||||||||||||||||
835 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
836 | if (QTabBarPrivate::Tab *tab = d->at(index)
| 0 | ||||||||||||||||||||||||
837 | tab->textColor = color; | - | ||||||||||||||||||||||||
838 | update(tabRect(index)); | - | ||||||||||||||||||||||||
839 | } never executed: end of block | 0 | ||||||||||||||||||||||||
840 | } never executed: end of block | 0 | ||||||||||||||||||||||||
841 | - | |||||||||||||||||||||||||
842 | - | |||||||||||||||||||||||||
843 | - | |||||||||||||||||||||||||
844 | - | |||||||||||||||||||||||||
845 | - | |||||||||||||||||||||||||
846 | QIcon QTabBar::tabIcon(int index) const | - | ||||||||||||||||||||||||
847 | { | - | ||||||||||||||||||||||||
848 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
849 | if (const
| 0 | ||||||||||||||||||||||||
850 | return never executed: tab->icon;return tab->icon; never executed: return tab->icon; | 0 | ||||||||||||||||||||||||
851 | return never executed: QIcon();return QIcon(); never executed: return QIcon(); | 0 | ||||||||||||||||||||||||
852 | } | - | ||||||||||||||||||||||||
853 | - | |||||||||||||||||||||||||
854 | - | |||||||||||||||||||||||||
855 | - | |||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||
857 | void QTabBar::setTabIcon(int index, const QIcon & icon) | - | ||||||||||||||||||||||||
858 | { | - | ||||||||||||||||||||||||
859 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
860 | if (QTabBarPrivate::Tab *tab = d->at(index)
| 0 | ||||||||||||||||||||||||
861 | bool simpleIconChange = (!icon.isNull()
| 0 | ||||||||||||||||||||||||
862 | tab->icon = icon; | - | ||||||||||||||||||||||||
863 | if (simpleIconChange
| 0 | ||||||||||||||||||||||||
864 | update(tabRect(index)); never executed: update(tabRect(index)); | 0 | ||||||||||||||||||||||||
865 | else | - | ||||||||||||||||||||||||
866 | d->refresh(); never executed: d->refresh(); | 0 | ||||||||||||||||||||||||
867 | } | - | ||||||||||||||||||||||||
868 | } never executed: end of block | 0 | ||||||||||||||||||||||||
869 | - | |||||||||||||||||||||||||
870 | - | |||||||||||||||||||||||||
871 | - | |||||||||||||||||||||||||
872 | - | |||||||||||||||||||||||||
873 | - | |||||||||||||||||||||||||
874 | void QTabBar::setTabToolTip(int index, const QString & tip) | - | ||||||||||||||||||||||||
875 | { | - | ||||||||||||||||||||||||
876 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
877 | if (QTabBarPrivate::Tab *tab = d->at(index)
| 0 | ||||||||||||||||||||||||
878 | tab->toolTip = tip; never executed: tab->toolTip = tip; | 0 | ||||||||||||||||||||||||
879 | } never executed: end of block | 0 | ||||||||||||||||||||||||
880 | - | |||||||||||||||||||||||||
881 | - | |||||||||||||||||||||||||
882 | - | |||||||||||||||||||||||||
883 | - | |||||||||||||||||||||||||
884 | - | |||||||||||||||||||||||||
885 | QString QTabBar::tabToolTip(int index) const | - | ||||||||||||||||||||||||
886 | { | - | ||||||||||||||||||||||||
887 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
888 | if (const
| 0 | ||||||||||||||||||||||||
889 | return never executed: tab->toolTip;return tab->toolTip; never executed: return tab->toolTip; | 0 | ||||||||||||||||||||||||
890 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
891 | } | - | ||||||||||||||||||||||||
892 | void QTabBar::setTabWhatsThis(int index, const QString &text) | - | ||||||||||||||||||||||||
893 | { | - | ||||||||||||||||||||||||
894 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
895 | if (QTabBarPrivate::Tab *tab = d->at(index)
| 0 | ||||||||||||||||||||||||
896 | tab->whatsThis = text; never executed: tab->whatsThis = text; | 0 | ||||||||||||||||||||||||
897 | } never executed: end of block | 0 | ||||||||||||||||||||||||
898 | - | |||||||||||||||||||||||||
899 | - | |||||||||||||||||||||||||
900 | - | |||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||
902 | - | |||||||||||||||||||||||||
903 | - | |||||||||||||||||||||||||
904 | - | |||||||||||||||||||||||||
905 | QString QTabBar::tabWhatsThis(int index) const | - | ||||||||||||||||||||||||
906 | { | - | ||||||||||||||||||||||||
907 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
908 | if (const
| 0 | ||||||||||||||||||||||||
909 | return never executed: tab->whatsThis;return tab->whatsThis; never executed: return tab->whatsThis; | 0 | ||||||||||||||||||||||||
910 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
911 | } | - | ||||||||||||||||||||||||
912 | - | |||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||
914 | - | |||||||||||||||||||||||||
915 | - | |||||||||||||||||||||||||
916 | - | |||||||||||||||||||||||||
917 | - | |||||||||||||||||||||||||
918 | void QTabBar::setTabData(int index, const QVariant & data) | - | ||||||||||||||||||||||||
919 | { | - | ||||||||||||||||||||||||
920 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
921 | if (QTabBarPrivate::Tab *tab = d->at(index)
| 0 | ||||||||||||||||||||||||
922 | tab->data = data; never executed: tab->data = data; | 0 | ||||||||||||||||||||||||
923 | } never executed: end of block | 0 | ||||||||||||||||||||||||
924 | - | |||||||||||||||||||||||||
925 | - | |||||||||||||||||||||||||
926 | - | |||||||||||||||||||||||||
927 | - | |||||||||||||||||||||||||
928 | - | |||||||||||||||||||||||||
929 | QVariant QTabBar::tabData(int index) const | - | ||||||||||||||||||||||||
930 | { | - | ||||||||||||||||||||||||
931 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
932 | if (const
| 0 | ||||||||||||||||||||||||
933 | return never executed: tab->data;return tab->data; never executed: return tab->data; | 0 | ||||||||||||||||||||||||
934 | return never executed: QVariant();return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||||||||
935 | } | - | ||||||||||||||||||||||||
936 | - | |||||||||||||||||||||||||
937 | - | |||||||||||||||||||||||||
938 | - | |||||||||||||||||||||||||
939 | - | |||||||||||||||||||||||||
940 | - | |||||||||||||||||||||||||
941 | QRect QTabBar::tabRect(int index) const | - | ||||||||||||||||||||||||
942 | { | - | ||||||||||||||||||||||||
943 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
944 | if (const
| 0 | ||||||||||||||||||||||||
945 | if (d->layoutDirty
| 0 | ||||||||||||||||||||||||
946 | const_cast< never executed: QTabBarPrivate*>(d)->layoutTabs();const_cast<QTabBarPrivate*>(d)->layoutTabs(); never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs(); | 0 | ||||||||||||||||||||||||
947 | QRect r = tab->rect; | - | ||||||||||||||||||||||||
948 | if (verticalTabs(d->shape)
| 0 | ||||||||||||||||||||||||
949 | r.translate(0, -d->scrollOffset); never executed: r.translate(0, -d->scrollOffset); | 0 | ||||||||||||||||||||||||
950 | else | - | ||||||||||||||||||||||||
951 | r.translate(-d->scrollOffset, 0); never executed: r.translate(-d->scrollOffset, 0); | 0 | ||||||||||||||||||||||||
952 | if (!verticalTabs(d->shape)
| 0 | ||||||||||||||||||||||||
953 | r = QStyle::visualRect(layoutDirection(), rect(), r); never executed: r = QStyle::visualRect(layoutDirection(), rect(), r); | 0 | ||||||||||||||||||||||||
954 | return never executed: r;return r; never executed: return r; | 0 | ||||||||||||||||||||||||
955 | } | - | ||||||||||||||||||||||||
956 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
957 | } | - | ||||||||||||||||||||||||
958 | - | |||||||||||||||||||||||||
959 | - | |||||||||||||||||||||||||
960 | - | |||||||||||||||||||||||||
961 | - | |||||||||||||||||||||||||
962 | - | |||||||||||||||||||||||||
963 | - | |||||||||||||||||||||||||
964 | - | |||||||||||||||||||||||||
965 | int QTabBar::tabAt(const QPoint &position) const | - | ||||||||||||||||||||||||
966 | { | - | ||||||||||||||||||||||||
967 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
968 | if (d->validIndex(d->currentIndex)
| 0 | ||||||||||||||||||||||||
969 | && tabRect(d->currentIndex).contains(position)
| 0 | ||||||||||||||||||||||||
970 | return never executed: d->currentIndex;return d->currentIndex; never executed: return d->currentIndex; | 0 | ||||||||||||||||||||||||
971 | } | - | ||||||||||||||||||||||||
972 | const int max = d->tabList.size(); | - | ||||||||||||||||||||||||
973 | for (int i = 0; i < max
| 0 | ||||||||||||||||||||||||
974 | if (tabRect(i).contains(position)
| 0 | ||||||||||||||||||||||||
975 | return never executed: i;return i; never executed: return i; | 0 | ||||||||||||||||||||||||
976 | } | - | ||||||||||||||||||||||||
977 | } never executed: end of block | 0 | ||||||||||||||||||||||||
978 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
979 | } | - | ||||||||||||||||||||||||
980 | int QTabBar::currentIndex() const | - | ||||||||||||||||||||||||
981 | { | - | ||||||||||||||||||||||||
982 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
983 | if (d->validIndex(d->currentIndex)
| 0 | ||||||||||||||||||||||||
984 | return never executed: d->currentIndex;return d->currentIndex; never executed: return d->currentIndex; | 0 | ||||||||||||||||||||||||
985 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
986 | } | - | ||||||||||||||||||||||||
987 | - | |||||||||||||||||||||||||
988 | - | |||||||||||||||||||||||||
989 | void QTabBar::setCurrentIndex(int index) | - | ||||||||||||||||||||||||
990 | { | - | ||||||||||||||||||||||||
991 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
992 | if (d->dragInProgress
| 0 | ||||||||||||||||||||||||
993 | return; never executed: return; | 0 | ||||||||||||||||||||||||
994 | - | |||||||||||||||||||||||||
995 | int oldIndex = d->currentIndex; | - | ||||||||||||||||||||||||
996 | if (d->validIndex(index)
| 0 | ||||||||||||||||||||||||
997 | d->currentIndex = index; | - | ||||||||||||||||||||||||
998 | update(); | - | ||||||||||||||||||||||||
999 | d->makeVisible(index); | - | ||||||||||||||||||||||||
1000 | d->tabList[index].lastTab = oldIndex; | - | ||||||||||||||||||||||||
1001 | if (oldIndex >= 0
| 0 | ||||||||||||||||||||||||
1002 | d->layoutTab(oldIndex); never executed: d->layoutTab(oldIndex); | 0 | ||||||||||||||||||||||||
1003 | d->layoutTab(index); | - | ||||||||||||||||||||||||
1004 | - | |||||||||||||||||||||||||
1005 | if (QAccessible::isActive()
| 0 | ||||||||||||||||||||||||
1006 | if (hasFocus()
| 0 | ||||||||||||||||||||||||
1007 | QAccessibleEvent focusEvent(this, QAccessible::Focus); | - | ||||||||||||||||||||||||
1008 | focusEvent.setChild(index); | - | ||||||||||||||||||||||||
1009 | QAccessible::updateAccessibility(&focusEvent); | - | ||||||||||||||||||||||||
1010 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1011 | QAccessibleEvent selectionEvent(this, QAccessible::Selection); | - | ||||||||||||||||||||||||
1012 | selectionEvent.setChild(index); | - | ||||||||||||||||||||||||
1013 | QAccessible::updateAccessibility(&selectionEvent); | - | ||||||||||||||||||||||||
1014 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1015 | - | |||||||||||||||||||||||||
1016 | currentChanged(index); | - | ||||||||||||||||||||||||
1017 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1018 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1019 | QSize QTabBar::iconSize() const | - | ||||||||||||||||||||||||
1020 | { | - | ||||||||||||||||||||||||
1021 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1022 | if (d->iconSize.isValid()
| 0 | ||||||||||||||||||||||||
1023 | return never executed: d->iconSize;return d->iconSize; never executed: return d->iconSize; | 0 | ||||||||||||||||||||||||
1024 | int iconExtent = style()->pixelMetric(QStyle::PM_TabBarIconSize, 0, this); | - | ||||||||||||||||||||||||
1025 | return never executed: QSize(iconExtent, iconExtent);return QSize(iconExtent, iconExtent); never executed: return QSize(iconExtent, iconExtent); | 0 | ||||||||||||||||||||||||
1026 | - | |||||||||||||||||||||||||
1027 | } | - | ||||||||||||||||||||||||
1028 | - | |||||||||||||||||||||||||
1029 | void QTabBar::setIconSize(const QSize &size) | - | ||||||||||||||||||||||||
1030 | { | - | ||||||||||||||||||||||||
1031 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1032 | d->iconSize = size; | - | ||||||||||||||||||||||||
1033 | d->layoutDirty = true; | - | ||||||||||||||||||||||||
1034 | update(); | - | ||||||||||||||||||||||||
1035 | updateGeometry(); | - | ||||||||||||||||||||||||
1036 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1037 | - | |||||||||||||||||||||||||
1038 | - | |||||||||||||||||||||||||
1039 | - | |||||||||||||||||||||||||
1040 | - | |||||||||||||||||||||||||
1041 | - | |||||||||||||||||||||||||
1042 | - | |||||||||||||||||||||||||
1043 | int QTabBar::count() const | - | ||||||||||||||||||||||||
1044 | { | - | ||||||||||||||||||||||||
1045 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1046 | return never executed: d->tabList.count();return d->tabList.count(); never executed: return d->tabList.count(); | 0 | ||||||||||||||||||||||||
1047 | } | - | ||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||
1049 | - | |||||||||||||||||||||||||
1050 | - | |||||||||||||||||||||||||
1051 | - | |||||||||||||||||||||||||
1052 | QSize QTabBar::sizeHint() const | - | ||||||||||||||||||||||||
1053 | { | - | ||||||||||||||||||||||||
1054 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1055 | if (d->layoutDirty
| 0 | ||||||||||||||||||||||||
1056 | const_cast< never executed: QTabBarPrivate*>(d)->layoutTabs();const_cast<QTabBarPrivate*>(d)->layoutTabs(); never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs(); | 0 | ||||||||||||||||||||||||
1057 | QRect r; | - | ||||||||||||||||||||||||
1058 | for (int i = 0; i < d->tabList.count()
| 0 | ||||||||||||||||||||||||
1059 | r = r.united(d->tabList.at(i).maxRect); never executed: r = r.united(d->tabList.at(i).maxRect); | 0 | ||||||||||||||||||||||||
1060 | QSize sz = QApplication::globalStrut(); | - | ||||||||||||||||||||||||
1061 | return never executed: r.size().expandedTo(sz);return r.size().expandedTo(sz); never executed: return r.size().expandedTo(sz); | 0 | ||||||||||||||||||||||||
1062 | } | - | ||||||||||||||||||||||||
1063 | - | |||||||||||||||||||||||||
1064 | - | |||||||||||||||||||||||||
1065 | - | |||||||||||||||||||||||||
1066 | QSize QTabBar::minimumSizeHint() const | - | ||||||||||||||||||||||||
1067 | { | - | ||||||||||||||||||||||||
1068 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1069 | if (d->layoutDirty
| 0 | ||||||||||||||||||||||||
1070 | const_cast< never executed: QTabBarPrivate*>(d)->layoutTabs();const_cast<QTabBarPrivate*>(d)->layoutTabs(); never executed: const_cast<QTabBarPrivate*>(d)->layoutTabs(); | 0 | ||||||||||||||||||||||||
1071 | if (!d->useScrollButtons
| 0 | ||||||||||||||||||||||||
1072 | QRect r; | - | ||||||||||||||||||||||||
1073 | for (int i = 0; i < d->tabList.count()
| 0 | ||||||||||||||||||||||||
1074 | r = r.united(d->tabList.at(i).minRect); never executed: r = r.united(d->tabList.at(i).minRect); | 0 | ||||||||||||||||||||||||
1075 | return never executed: r.size().expandedTo(QApplication::globalStrut());return r.size().expandedTo(QApplication::globalStrut()); never executed: return r.size().expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||||||||||||||
1076 | } | - | ||||||||||||||||||||||||
1077 | if (verticalTabs(d->shape)
| 0 | ||||||||||||||||||||||||
1078 | 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 | ||||||||||||||||||||||||
1079 | else | - | ||||||||||||||||||||||||
1080 | 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 | ||||||||||||||||||||||||
1081 | } | - | ||||||||||||||||||||||||
1082 | - | |||||||||||||||||||||||||
1083 | - | |||||||||||||||||||||||||
1084 | static QString computeElidedText(Qt::TextElideMode mode, const QString &text) | - | ||||||||||||||||||||||||
1085 | { | - | ||||||||||||||||||||||||
1086 | if (text.length() <= 3
| 0 | ||||||||||||||||||||||||
1087 | return never executed: text;return text; never executed: return text; | 0 | ||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||
1089 | static const QLatin1String Ellipses("..."); | - | ||||||||||||||||||||||||
1090 | QString ret; | - | ||||||||||||||||||||||||
1091 | switch (mode) { | - | ||||||||||||||||||||||||
1092 | case never executed: Qt::ElideRight:case Qt::ElideRight: never executed: case Qt::ElideRight: | 0 | ||||||||||||||||||||||||
1093 | ret = text.leftRef(2) + Ellipses; | - | ||||||||||||||||||||||||
1094 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1095 | case never executed: Qt::ElideMiddle:case Qt::ElideMiddle: never executed: case Qt::ElideMiddle: | 0 | ||||||||||||||||||||||||
1096 | ret = text.leftRef(1) + Ellipses + text.rightRef(1); | - | ||||||||||||||||||||||||
1097 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1098 | case never executed: Qt::ElideLeft:case Qt::ElideLeft: never executed: case Qt::ElideLeft: | 0 | ||||||||||||||||||||||||
1099 | ret = Ellipses + text.rightRef(2); | - | ||||||||||||||||||||||||
1100 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1101 | case never executed: Qt::ElideNone:case Qt::ElideNone: never executed: case Qt::ElideNone: | 0 | ||||||||||||||||||||||||
1102 | ret = text; | - | ||||||||||||||||||||||||
1103 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1104 | } | - | ||||||||||||||||||||||||
1105 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
1106 | } | - | ||||||||||||||||||||||||
1107 | - | |||||||||||||||||||||||||
1108 | - | |||||||||||||||||||||||||
1109 | - | |||||||||||||||||||||||||
1110 | - | |||||||||||||||||||||||||
1111 | - | |||||||||||||||||||||||||
1112 | - | |||||||||||||||||||||||||
1113 | QSize QTabBar::minimumTabSizeHint(int index) const | - | ||||||||||||||||||||||||
1114 | { | - | ||||||||||||||||||||||||
1115 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1116 | QTabBarPrivate::Tab &tab = const_cast<QTabBarPrivate::Tab&>(d->tabList[index]); | - | ||||||||||||||||||||||||
1117 | QString oldText = tab.text; | - | ||||||||||||||||||||||||
1118 | tab.text = computeElidedText(d->elideMode, oldText); | - | ||||||||||||||||||||||||
1119 | QSize size = tabSizeHint(index); | - | ||||||||||||||||||||||||
1120 | tab.text = oldText; | - | ||||||||||||||||||||||||
1121 | return never executed: size;return size; never executed: return size; | 0 | ||||||||||||||||||||||||
1122 | } | - | ||||||||||||||||||||||||
1123 | - | |||||||||||||||||||||||||
1124 | - | |||||||||||||||||||||||||
1125 | - | |||||||||||||||||||||||||
1126 | - | |||||||||||||||||||||||||
1127 | QSize QTabBar::tabSizeHint(int index) const | - | ||||||||||||||||||||||||
1128 | { | - | ||||||||||||||||||||||||
1129 | - | |||||||||||||||||||||||||
1130 | const QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1131 | if (const
| 0 | ||||||||||||||||||||||||
1132 | QStyleOptionTab opt; | - | ||||||||||||||||||||||||
1133 | d->initBasicStyleOption(&opt, index); | - | ||||||||||||||||||||||||
1134 | opt.text = d->tabList.at(index).text; | - | ||||||||||||||||||||||||
1135 | QSize iconSize = tab->icon.isNull()
| 0 | ||||||||||||||||||||||||
1136 | int hframe = style()->pixelMetric(QStyle::PM_TabBarTabHSpace, &opt, this); | - | ||||||||||||||||||||||||
1137 | int vframe = style()->pixelMetric(QStyle::PM_TabBarTabVSpace, &opt, this); | - | ||||||||||||||||||||||||
1138 | const QFontMetrics fm = fontMetrics(); | - | ||||||||||||||||||||||||
1139 | - | |||||||||||||||||||||||||
1140 | int maxWidgetHeight = qMax(opt.leftButtonSize.height(), opt.rightButtonSize.height()); | - | ||||||||||||||||||||||||
1141 | int maxWidgetWidth = qMax(opt.leftButtonSize.width(), opt.rightButtonSize.width()); | - | ||||||||||||||||||||||||
1142 | - | |||||||||||||||||||||||||
1143 | int widgetWidth = 0; | - | ||||||||||||||||||||||||
1144 | int widgetHeight = 0; | - | ||||||||||||||||||||||||
1145 | int padding = 0; | - | ||||||||||||||||||||||||
1146 | if (!opt.leftButtonSize.isEmpty()
| 0 | ||||||||||||||||||||||||
1147 | padding += 4; | - | ||||||||||||||||||||||||
1148 | widgetWidth += opt.leftButtonSize.width(); | - | ||||||||||||||||||||||||
1149 | widgetHeight += opt.leftButtonSize.height(); | - | ||||||||||||||||||||||||
1150 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1151 | if (!opt.rightButtonSize.isEmpty()
| 0 | ||||||||||||||||||||||||
1152 | padding += 4; | - | ||||||||||||||||||||||||
1153 | widgetWidth += opt.rightButtonSize.width(); | - | ||||||||||||||||||||||||
1154 | widgetHeight += opt.rightButtonSize.height(); | - | ||||||||||||||||||||||||
1155 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1156 | if (!opt.icon.isNull()
| 0 | ||||||||||||||||||||||||
1157 | padding += 4; never executed: padding += 4; | 0 | ||||||||||||||||||||||||
1158 | - | |||||||||||||||||||||||||
1159 | QHash<QString, QSize>::iterator it = d->textSizes.find(tab->text); | - | ||||||||||||||||||||||||
1160 | if (it == d->textSizes.end()
| 0 | ||||||||||||||||||||||||
1161 | 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 | ||||||||||||||||||||||||
1162 | const int textWidth = it.value().width(); | - | ||||||||||||||||||||||||
1163 | QSize csz; | - | ||||||||||||||||||||||||
1164 | if (verticalTabs(d->shape)
| 0 | ||||||||||||||||||||||||
1165 | csz = QSize( qMax(maxWidgetWidth, qMax(fm.height(), iconSize.height())) + vframe, | - | ||||||||||||||||||||||||
1166 | textWidth + iconSize.width() + hframe + widgetHeight + padding); | - | ||||||||||||||||||||||||
1167 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1168 | csz = QSize(textWidth + iconSize.width() + hframe + widgetWidth + padding, | - | ||||||||||||||||||||||||
1169 | qMax(maxWidgetHeight, qMax(fm.height(), iconSize.height())) + vframe); | - | ||||||||||||||||||||||||
1170 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1171 | - | |||||||||||||||||||||||||
1172 | QSize retSize = style()->sizeFromContents(QStyle::CT_TabBarTab, &opt, csz, this); | - | ||||||||||||||||||||||||
1173 | return never executed: retSize;return retSize; never executed: return retSize; | 0 | ||||||||||||||||||||||||
1174 | } | - | ||||||||||||||||||||||||
1175 | return never executed: QSize();return QSize(); never executed: return QSize(); | 0 | ||||||||||||||||||||||||
1176 | } | - | ||||||||||||||||||||||||
1177 | - | |||||||||||||||||||||||||
1178 | - | |||||||||||||||||||||||||
1179 | - | |||||||||||||||||||||||||
1180 | - | |||||||||||||||||||||||||
1181 | - | |||||||||||||||||||||||||
1182 | - | |||||||||||||||||||||||||
1183 | - | |||||||||||||||||||||||||
1184 | void QTabBar::tabInserted(int index) | - | ||||||||||||||||||||||||
1185 | { | - | ||||||||||||||||||||||||
1186 | (void)index; | - | ||||||||||||||||||||||||
1187 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1188 | - | |||||||||||||||||||||||||
1189 | - | |||||||||||||||||||||||||
1190 | - | |||||||||||||||||||||||||
1191 | - | |||||||||||||||||||||||||
1192 | - | |||||||||||||||||||||||||
1193 | - | |||||||||||||||||||||||||
1194 | - | |||||||||||||||||||||||||
1195 | void QTabBar::tabRemoved(int index) | - | ||||||||||||||||||||||||
1196 | { | - | ||||||||||||||||||||||||
1197 | (void)index; | - | ||||||||||||||||||||||||
1198 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1199 | - | |||||||||||||||||||||||||
1200 | - | |||||||||||||||||||||||||
1201 | - | |||||||||||||||||||||||||
1202 | - | |||||||||||||||||||||||||
1203 | - | |||||||||||||||||||||||||
1204 | - | |||||||||||||||||||||||||
1205 | void QTabBar::tabLayoutChange() | - | ||||||||||||||||||||||||
1206 | { | - | ||||||||||||||||||||||||
1207 | } | - | ||||||||||||||||||||||||
1208 | - | |||||||||||||||||||||||||
1209 | - | |||||||||||||||||||||||||
1210 | - | |||||||||||||||||||||||||
1211 | - | |||||||||||||||||||||||||
1212 | void QTabBar::showEvent(QShowEvent *) | - | ||||||||||||||||||||||||
1213 | { | - | ||||||||||||||||||||||||
1214 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1215 | if (d->layoutDirty
| 0 | ||||||||||||||||||||||||
1216 | d->refresh(); never executed: d->refresh(); | 0 | ||||||||||||||||||||||||
1217 | if (!d->validIndex(d->currentIndex)
| 0 | ||||||||||||||||||||||||
1218 | setCurrentIndex(0); never executed: setCurrentIndex(0); | 0 | ||||||||||||||||||||||||
1219 | d->updateMacBorderMetrics(); | - | ||||||||||||||||||||||||
1220 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1221 | - | |||||||||||||||||||||||||
1222 | - | |||||||||||||||||||||||||
1223 | - | |||||||||||||||||||||||||
1224 | void QTabBar::hideEvent(QHideEvent *) | - | ||||||||||||||||||||||||
1225 | { | - | ||||||||||||||||||||||||
1226 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1227 | d->updateMacBorderMetrics(); | - | ||||||||||||||||||||||||
1228 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1229 | - | |||||||||||||||||||||||||
1230 | - | |||||||||||||||||||||||||
1231 | - | |||||||||||||||||||||||||
1232 | bool QTabBar::event(QEvent *event) | - | ||||||||||||||||||||||||
1233 | { | - | ||||||||||||||||||||||||
1234 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1235 | if (event->type() == QEvent::HoverMove
| 0 | ||||||||||||||||||||||||
1236 | || event->type() == QEvent::HoverEnter
| 0 | ||||||||||||||||||||||||
1237 | QHoverEvent *he = static_cast<QHoverEvent *>(event); | - | ||||||||||||||||||||||||
1238 | if (!d->hoverRect.contains(he->pos())
| 0 | ||||||||||||||||||||||||
1239 | QRect oldHoverRect = d->hoverRect; | - | ||||||||||||||||||||||||
1240 | for (int i = 0; i < d->tabList.count()
| 0 | ||||||||||||||||||||||||
1241 | QRect area = tabRect(i); | - | ||||||||||||||||||||||||
1242 | if (area.contains(he->pos())
| 0 | ||||||||||||||||||||||||
1243 | d->hoverRect = area; | - | ||||||||||||||||||||||||
1244 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1245 | } | - | ||||||||||||||||||||||||
1246 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1247 | if (he->oldPos() != QPoint(-1, -1)
| 0 | ||||||||||||||||||||||||
1248 | update(oldHoverRect); never executed: update(oldHoverRect); | 0 | ||||||||||||||||||||||||
1249 | update(d->hoverRect); | - | ||||||||||||||||||||||||
1250 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1251 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1252 | } else if (event->type() == QEvent::HoverLeave
| 0 | ||||||||||||||||||||||||
1253 | QRect oldHoverRect = d->hoverRect; | - | ||||||||||||||||||||||||
1254 | d->hoverRect = QRect(); | - | ||||||||||||||||||||||||
1255 | update(oldHoverRect); | - | ||||||||||||||||||||||||
1256 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1257 | - | |||||||||||||||||||||||||
1258 | } else if (event->type() == QEvent::ToolTip
| 0 | ||||||||||||||||||||||||
1259 | if (const
| 0 | ||||||||||||||||||||||||
1260 | if (!tab->toolTip.isEmpty()
| 0 | ||||||||||||||||||||||||
1261 | QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tab->toolTip, this); | - | ||||||||||||||||||||||||
1262 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1263 | } | - | ||||||||||||||||||||||||
1264 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1265 | - | |||||||||||||||||||||||||
1266 | - | |||||||||||||||||||||||||
1267 | } never executed: else if (event->type() == QEvent::QueryWhatsThisend of block
| 0 | ||||||||||||||||||||||||
1268 | const QTabBarPrivate::Tab *tab = d->at(d->indexAtPos(static_cast<QHelpEvent*>(event)->pos())); | - | ||||||||||||||||||||||||
1269 | if (!tab
| 0 | ||||||||||||||||||||||||
1270 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||
1271 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1272 | } else if (event->type() == QEvent::WhatsThis
| 0 | ||||||||||||||||||||||||
1273 | if (const
| 0 | ||||||||||||||||||||||||
1274 | if (!tab->whatsThis.isEmpty()
| 0 | ||||||||||||||||||||||||
1275 | QWhatsThis::showText(static_cast<QHelpEvent*>(event)->globalPos(), | - | ||||||||||||||||||||||||
1276 | tab->whatsThis, this); | - | ||||||||||||||||||||||||
1277 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1278 | } | - | ||||||||||||||||||||||||
1279 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1280 | - | |||||||||||||||||||||||||
1281 | - | |||||||||||||||||||||||||
1282 | } never executed: else if (event->type() == QEvent::Shortcutend of block
| 0 | ||||||||||||||||||||||||
1283 | QShortcutEvent *se = static_cast<QShortcutEvent *>(event); | - | ||||||||||||||||||||||||
1284 | for (int i = 0; i < d->tabList.count()
| 0 | ||||||||||||||||||||||||
1285 | const QTabBarPrivate::Tab *tab = &d->tabList.at(i); | - | ||||||||||||||||||||||||
1286 | if (tab->shortcutId == se->shortcutId()
| 0 | ||||||||||||||||||||||||
1287 | setCurrentIndex(i); | - | ||||||||||||||||||||||||
1288 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1289 | } | - | ||||||||||||||||||||||||
1290 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1291 | - | |||||||||||||||||||||||||
1292 | } never executed: else if (event->type() == QEvent::MouseButtonDblClickend of block
| 0 | ||||||||||||||||||||||||
1293 | const QPoint pos = static_cast<const QMouseEvent *>(event)->pos(); | - | ||||||||||||||||||||||||
1294 | const bool isEventInCornerButtons = (!d->leftB->isHidden()
| 0 | ||||||||||||||||||||||||
1295 | || (!d->rightB->isHidden()
| 0 | ||||||||||||||||||||||||
1296 | if (!isEventInCornerButtons
| 0 | ||||||||||||||||||||||||
1297 | tabBarDoubleClicked(tabAt(pos)); never executed: tabBarDoubleClicked(tabAt(pos)); | 0 | ||||||||||||||||||||||||
1298 | } never executed: else if (event->type() == QEvent::Moveend of block
| 0 | ||||||||||||||||||||||||
1299 | d->updateMacBorderMetrics(); | - | ||||||||||||||||||||||||
1300 | return never executed: QWidget::event(event);return QWidget::event(event); never executed: return QWidget::event(event); | 0 | ||||||||||||||||||||||||
1301 | - | |||||||||||||||||||||||||
1302 | - | |||||||||||||||||||||||||
1303 | } else if (event->type() == QEvent::DragEnter
| 0 | ||||||||||||||||||||||||
1304 | if (d->changeCurrentOnDrag
| 0 | ||||||||||||||||||||||||
1305 | event->accept(); never executed: event->accept(); | 0 | ||||||||||||||||||||||||
1306 | } never executed: else if (event->type() == QEvent::DragMoveend of block
| 0 | ||||||||||||||||||||||||
1307 | if (d->changeCurrentOnDrag
| 0 | ||||||||||||||||||||||||
1308 | const int tabIndex = tabAt(static_cast<QDragMoveEvent *>(event)->pos()); | - | ||||||||||||||||||||||||
1309 | if (isTabEnabled(tabIndex)
| 0 | ||||||||||||||||||||||||
1310 | d->switchTabCurrentIndex = tabIndex; | - | ||||||||||||||||||||||||
1311 | if (d->switchTabTimerId
| 0 | ||||||||||||||||||||||||
1312 | killTimer(d->switchTabTimerId); never executed: killTimer(d->switchTabTimerId); | 0 | ||||||||||||||||||||||||
1313 | d->switchTabTimerId = startTimer(style()->styleHint(QStyle::SH_TabBar_ChangeCurrentDelay)); | - | ||||||||||||||||||||||||
1314 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1315 | event->ignore(); | - | ||||||||||||||||||||||||
1316 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1317 | } never executed: else if (event->type() == QEvent::DragLeaveend of block
| 0 | ||||||||||||||||||||||||
1318 | d->killSwitchTabTimer(); | - | ||||||||||||||||||||||||
1319 | event->ignore(); | - | ||||||||||||||||||||||||
1320 | - | |||||||||||||||||||||||||
1321 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1322 | return never executed: QWidget::event(event);return QWidget::event(event); never executed: return QWidget::event(event); | 0 | ||||||||||||||||||||||||
1323 | } | - | ||||||||||||||||||||||||
1324 | - | |||||||||||||||||||||||||
1325 | - | |||||||||||||||||||||||||
1326 | - | |||||||||||||||||||||||||
1327 | void QTabBar::resizeEvent(QResizeEvent *) | - | ||||||||||||||||||||||||
1328 | { | - | ||||||||||||||||||||||||
1329 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1330 | if (d->layoutDirty
| 0 | ||||||||||||||||||||||||
1331 | updateGeometry(); never executed: updateGeometry(); | 0 | ||||||||||||||||||||||||
1332 | d->layoutTabs(); | - | ||||||||||||||||||||||||
1333 | - | |||||||||||||||||||||||||
1334 | d->makeVisible(d->currentIndex); | - | ||||||||||||||||||||||||
1335 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1336 | - | |||||||||||||||||||||||||
1337 | - | |||||||||||||||||||||||||
1338 | - | |||||||||||||||||||||||||
1339 | void QTabBar::paintEvent(QPaintEvent *) | - | ||||||||||||||||||||||||
1340 | { | - | ||||||||||||||||||||||||
1341 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1342 | - | |||||||||||||||||||||||||
1343 | QStyleOptionTabBarBase optTabBase; | - | ||||||||||||||||||||||||
1344 | QTabBarPrivate::initStyleBaseOption(&optTabBase, this, size()); | - | ||||||||||||||||||||||||
1345 | - | |||||||||||||||||||||||||
1346 | QStylePainter p(this); | - | ||||||||||||||||||||||||
1347 | int selected = -1; | - | ||||||||||||||||||||||||
1348 | int cutLeft = -1; | - | ||||||||||||||||||||||||
1349 | int cutRight = -1; | - | ||||||||||||||||||||||||
1350 | bool vertical = verticalTabs(d->shape); | - | ||||||||||||||||||||||||
1351 | QStyleOptionTab cutTabLeft; | - | ||||||||||||||||||||||||
1352 | QStyleOptionTab cutTabRight; | - | ||||||||||||||||||||||||
1353 | selected = d->currentIndex; | - | ||||||||||||||||||||||||
1354 | if (d->dragInProgress
| 0 | ||||||||||||||||||||||||
1355 | selected = d->pressedIndex; never executed: selected = d->pressedIndex; | 0 | ||||||||||||||||||||||||
1356 | const QRect scrollRect = d->normalizedScrollRect(); | - | ||||||||||||||||||||||||
1357 | - | |||||||||||||||||||||||||
1358 | for (int i = 0; i < d->tabList.count()
| 0 | ||||||||||||||||||||||||
1359 | optTabBase.tabBarRect |= tabRect(i); never executed: optTabBase.tabBarRect |= tabRect(i); | 0 | ||||||||||||||||||||||||
1360 | - | |||||||||||||||||||||||||
1361 | optTabBase.selectedTabRect = tabRect(selected); | - | ||||||||||||||||||||||||
1362 | - | |||||||||||||||||||||||||
1363 | if (d->drawBase
| 0 | ||||||||||||||||||||||||
1364 | p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase); never executed: p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase); | 0 | ||||||||||||||||||||||||
1365 | - | |||||||||||||||||||||||||
1366 | for (int i = 0; i < d->tabList.count()
| 0 | ||||||||||||||||||||||||
1367 | QStyleOptionTab tab; | - | ||||||||||||||||||||||||
1368 | initStyleOption(&tab, i); | - | ||||||||||||||||||||||||
1369 | if (d->paintWithOffsets
| 0 | ||||||||||||||||||||||||
1370 | if (vertical
| 0 | ||||||||||||||||||||||||
1371 | tab.rect.moveTop(tab.rect.y() + d->tabList[i].dragOffset); | - | ||||||||||||||||||||||||
1372 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1373 | tab.rect.moveLeft(tab.rect.x() + d->tabList[i].dragOffset); | - | ||||||||||||||||||||||||
1374 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1375 | } | - | ||||||||||||||||||||||||
1376 | if (!(tab.state & QStyle::State_Enabled)
| 0 | ||||||||||||||||||||||||
1377 | tab.palette.setCurrentColorGroup(QPalette::Disabled); | - | ||||||||||||||||||||||||
1378 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1379 | - | |||||||||||||||||||||||||
1380 | - | |||||||||||||||||||||||||
1381 | - | |||||||||||||||||||||||||
1382 | QRect tabRect = d->tabList[i].rect; | - | ||||||||||||||||||||||||
1383 | int tabStart = vertical
| 0 | ||||||||||||||||||||||||
1384 | int tabEnd = vertical
| 0 | ||||||||||||||||||||||||
1385 | if (tabStart < scrollRect.left() + d->scrollOffset
| 0 | ||||||||||||||||||||||||
1386 | cutLeft = i; | - | ||||||||||||||||||||||||
1387 | cutTabLeft = tab; | - | ||||||||||||||||||||||||
1388 | } never executed: else if (tabEnd > scrollRect.right() + d->scrollOffsetend of block
| 0 | ||||||||||||||||||||||||
1389 | cutRight = i; | - | ||||||||||||||||||||||||
1390 | cutTabRight = tab; | - | ||||||||||||||||||||||||
1391 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1392 | - | |||||||||||||||||||||||||
1393 | - | |||||||||||||||||||||||||
1394 | if ((!vertical
| 0 | ||||||||||||||||||||||||
1395 | || (vertical
| 0 | ||||||||||||||||||||||||
1396 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1397 | - | |||||||||||||||||||||||||
1398 | optTabBase.tabBarRect |= tab.rect; | - | ||||||||||||||||||||||||
1399 | if (i == selected
| 0 | ||||||||||||||||||||||||
1400 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1401 | - | |||||||||||||||||||||||||
1402 | p.drawControl(QStyle::CE_TabBarTab, tab); | - | ||||||||||||||||||||||||
1403 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1404 | - | |||||||||||||||||||||||||
1405 | - | |||||||||||||||||||||||||
1406 | if (selected >= 0
| 0 | ||||||||||||||||||||||||
1407 | QStyleOptionTab tab; | - | ||||||||||||||||||||||||
1408 | initStyleOption(&tab, selected); | - | ||||||||||||||||||||||||
1409 | if (d->paintWithOffsets
| 0 | ||||||||||||||||||||||||
1410 | if (vertical
| 0 | ||||||||||||||||||||||||
1411 | tab.rect.moveTop(tab.rect.y() + d->tabList[selected].dragOffset); never executed: tab.rect.moveTop(tab.rect.y() + d->tabList[selected].dragOffset); | 0 | ||||||||||||||||||||||||
1412 | else | - | ||||||||||||||||||||||||
1413 | tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset); never executed: tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset); | 0 | ||||||||||||||||||||||||
1414 | } | - | ||||||||||||||||||||||||
1415 | if (!d->dragInProgress
| 0 | ||||||||||||||||||||||||
1416 | p.drawControl(QStyle::CE_TabBarTab, tab); never executed: p.drawControl(QStyle::CE_TabBarTab, tab); | 0 | ||||||||||||||||||||||||
1417 | else { | - | ||||||||||||||||||||||||
1418 | int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this); | - | ||||||||||||||||||||||||
1419 | d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); | - | ||||||||||||||||||||||||
1420 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1421 | } | - | ||||||||||||||||||||||||
1422 | - | |||||||||||||||||||||||||
1423 | - | |||||||||||||||||||||||||
1424 | if (d->leftB->isVisible()
| 0 | ||||||||||||||||||||||||
1425 | cutTabLeft.rect = rect(); | - | ||||||||||||||||||||||||
1426 | cutTabLeft.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &cutTabLeft, this); | - | ||||||||||||||||||||||||
1427 | p.drawPrimitive(QStyle::PE_IndicatorTabTearLeft, cutTabLeft); | - | ||||||||||||||||||||||||
1428 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1429 | - | |||||||||||||||||||||||||
1430 | if (d->rightB->isVisible()
| 0 | ||||||||||||||||||||||||
1431 | cutTabRight.rect = rect(); | - | ||||||||||||||||||||||||
1432 | cutTabRight.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &cutTabRight, this); | - | ||||||||||||||||||||||||
1433 | p.drawPrimitive(QStyle::PE_IndicatorTabTearRight, cutTabRight); | - | ||||||||||||||||||||||||
1434 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1435 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1436 | - | |||||||||||||||||||||||||
1437 | - | |||||||||||||||||||||||||
1438 | - | |||||||||||||||||||||||||
1439 | - | |||||||||||||||||||||||||
1440 | int QTabBarPrivate::calculateNewPosition(int from, int to, int index) const | - | ||||||||||||||||||||||||
1441 | { | - | ||||||||||||||||||||||||
1442 | if (index == from
| 0 | ||||||||||||||||||||||||
1443 | return never executed: to;return to; never executed: return to; | 0 | ||||||||||||||||||||||||
1444 | - | |||||||||||||||||||||||||
1445 | int start = qMin(from, to); | - | ||||||||||||||||||||||||
1446 | int end = qMax(from, to); | - | ||||||||||||||||||||||||
1447 | if (index >= start
| 0 | ||||||||||||||||||||||||
1448 | index += (
never executed: index += (from < to) ? -1 : 1; | 0 | ||||||||||||||||||||||||
1449 | return never executed: index;return index; never executed: return index; | 0 | ||||||||||||||||||||||||
1450 | } | - | ||||||||||||||||||||||||
1451 | - | |||||||||||||||||||||||||
1452 | - | |||||||||||||||||||||||||
1453 | - | |||||||||||||||||||||||||
1454 | - | |||||||||||||||||||||||||
1455 | - | |||||||||||||||||||||||||
1456 | - | |||||||||||||||||||||||||
1457 | - | |||||||||||||||||||||||||
1458 | void QTabBar::moveTab(int from, int to) | - | ||||||||||||||||||||||||
1459 | { | - | ||||||||||||||||||||||||
1460 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1461 | if (from == to
| 0 | ||||||||||||||||||||||||
1462 | || !d->validIndex(from)
| 0 | ||||||||||||||||||||||||
1463 | || !d->validIndex(to)
| 0 | ||||||||||||||||||||||||
1464 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1465 | - | |||||||||||||||||||||||||
1466 | bool vertical = verticalTabs(d->shape); | - | ||||||||||||||||||||||||
1467 | int oldPressedPosition = 0; | - | ||||||||||||||||||||||||
1468 | if (d->pressedIndex != -1
| 0 | ||||||||||||||||||||||||
1469 | - | |||||||||||||||||||||||||
1470 | oldPressedPosition = vertical
| 0 | ||||||||||||||||||||||||
1471 | : d->tabList[d->pressedIndex].rect.x(); | - | ||||||||||||||||||||||||
1472 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1473 | - | |||||||||||||||||||||||||
1474 | - | |||||||||||||||||||||||||
1475 | int start = qMin(from, to); | - | ||||||||||||||||||||||||
1476 | int end = qMax(from, to); | - | ||||||||||||||||||||||||
1477 | int width = vertical
| 0 | ||||||||||||||||||||||||
1478 | if (from < to
| 0 | ||||||||||||||||||||||||
1479 | width *= -1; never executed: width *= -1; | 0 | ||||||||||||||||||||||||
1480 | bool rtl = isRightToLeft(); | - | ||||||||||||||||||||||||
1481 | for (int i = start; i <= end
| 0 | ||||||||||||||||||||||||
1482 | if (i == from
| 0 | ||||||||||||||||||||||||
1483 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1484 | if (vertical
| 0 | ||||||||||||||||||||||||
1485 | 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 | ||||||||||||||||||||||||
1486 | else | - | ||||||||||||||||||||||||
1487 | 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 | ||||||||||||||||||||||||
1488 | int direction = -1; | - | ||||||||||||||||||||||||
1489 | if (rtl
| 0 | ||||||||||||||||||||||||
1490 | direction *= -1; never executed: direction *= -1; | 0 | ||||||||||||||||||||||||
1491 | if (d->tabList[i].dragOffset != 0
| 0 | ||||||||||||||||||||||||
1492 | d->tabList[i].dragOffset += (direction * width); never executed: d->tabList[i].dragOffset += (direction * width); | 0 | ||||||||||||||||||||||||
1493 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1494 | - | |||||||||||||||||||||||||
1495 | if (vertical
| 0 | ||||||||||||||||||||||||
1496 | if (from < to
| 0 | ||||||||||||||||||||||||
1497 | 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 | ||||||||||||||||||||||||
1498 | else | - | ||||||||||||||||||||||||
1499 | 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 | ||||||||||||||||||||||||
1500 | } else { | - | ||||||||||||||||||||||||
1501 | if (from < to
| 0 | ||||||||||||||||||||||||
1502 | 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 | ||||||||||||||||||||||||
1503 | else | - | ||||||||||||||||||||||||
1504 | 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 | ||||||||||||||||||||||||
1505 | } | - | ||||||||||||||||||||||||
1506 | - | |||||||||||||||||||||||||
1507 | - | |||||||||||||||||||||||||
1508 | d->tabList.move(from, to); | - | ||||||||||||||||||||||||
1509 | - | |||||||||||||||||||||||||
1510 | - | |||||||||||||||||||||||||
1511 | for (int i = 0; i < d->tabList.count()
| 0 | ||||||||||||||||||||||||
1512 | 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 | ||||||||||||||||||||||||
1513 | - | |||||||||||||||||||||||||
1514 | - | |||||||||||||||||||||||||
1515 | int previousIndex = d->currentIndex; | - | ||||||||||||||||||||||||
1516 | d->currentIndex = d->calculateNewPosition(from, to, d->currentIndex); | - | ||||||||||||||||||||||||
1517 | - | |||||||||||||||||||||||||
1518 | - | |||||||||||||||||||||||||
1519 | if (d->pressedIndex != -1
| 0 | ||||||||||||||||||||||||
1520 | d->pressedIndex = d->calculateNewPosition(from, to, d->pressedIndex); | - | ||||||||||||||||||||||||
1521 | int newPressedPosition = vertical
| 0 | ||||||||||||||||||||||||
1522 | int diff = oldPressedPosition - newPressedPosition; | - | ||||||||||||||||||||||||
1523 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
1524 | diff *= -1; never executed: diff *= -1; | 0 | ||||||||||||||||||||||||
1525 | if (vertical
| 0 | ||||||||||||||||||||||||
1526 | d->dragStartPosition.setY(d->dragStartPosition.y() - diff); never executed: d->dragStartPosition.setY(d->dragStartPosition.y() - diff); | 0 | ||||||||||||||||||||||||
1527 | else | - | ||||||||||||||||||||||||
1528 | d->dragStartPosition.setX(d->dragStartPosition.x() - diff); never executed: d->dragStartPosition.setX(d->dragStartPosition.x() - diff); | 0 | ||||||||||||||||||||||||
1529 | } | - | ||||||||||||||||||||||||
1530 | - | |||||||||||||||||||||||||
1531 | d->layoutWidgets(start); | - | ||||||||||||||||||||||||
1532 | update(); | - | ||||||||||||||||||||||||
1533 | tabMoved(from, to); | - | ||||||||||||||||||||||||
1534 | if (previousIndex != d->currentIndex
| 0 | ||||||||||||||||||||||||
1535 | currentChanged(d->currentIndex); never executed: currentChanged(d->currentIndex); | 0 | ||||||||||||||||||||||||
1536 | tabLayoutChange(); | - | ||||||||||||||||||||||||
1537 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1538 | - | |||||||||||||||||||||||||
1539 | void QTabBarPrivate::slide(int from, int to) | - | ||||||||||||||||||||||||
1540 | { | - | ||||||||||||||||||||||||
1541 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
1542 | if (from == to
| 0 | ||||||||||||||||||||||||
1543 | || !validIndex(from)
| 0 | ||||||||||||||||||||||||
1544 | || !validIndex(to)
| 0 | ||||||||||||||||||||||||
1545 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1546 | bool vertical = verticalTabs(shape); | - | ||||||||||||||||||||||||
1547 | int preLocation = vertical
| 0 | ||||||||||||||||||||||||
1548 | q->setUpdatesEnabled(false); | - | ||||||||||||||||||||||||
1549 | q->moveTab(from, to); | - | ||||||||||||||||||||||||
1550 | q->setUpdatesEnabled(true); | - | ||||||||||||||||||||||||
1551 | int postLocation = vertical
| 0 | ||||||||||||||||||||||||
1552 | int length = postLocation - preLocation; | - | ||||||||||||||||||||||||
1553 | tabList[to].dragOffset -= length; | - | ||||||||||||||||||||||||
1554 | tabList[to].startAnimation(this, 250); | - | ||||||||||||||||||||||||
1555 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1556 | - | |||||||||||||||||||||||||
1557 | void QTabBarPrivate::moveTab(int index, int offset) | - | ||||||||||||||||||||||||
1558 | { | - | ||||||||||||||||||||||||
1559 | if (!validIndex(index)
| 0 | ||||||||||||||||||||||||
1560 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1561 | tabList[index].dragOffset = offset; | - | ||||||||||||||||||||||||
1562 | layoutTab(index); | - | ||||||||||||||||||||||||
1563 | q_func()->update(); | - | ||||||||||||||||||||||||
1564 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1565 | - | |||||||||||||||||||||||||
1566 | - | |||||||||||||||||||||||||
1567 | - | |||||||||||||||||||||||||
1568 | void QTabBar::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1569 | { | - | ||||||||||||||||||||||||
1570 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1571 | - | |||||||||||||||||||||||||
1572 | const QPoint pos = event->pos(); | - | ||||||||||||||||||||||||
1573 | const bool isEventInCornerButtons = (!d->leftB->isHidden()
| 0 | ||||||||||||||||||||||||
1574 | || (!d->rightB->isHidden()
| 0 | ||||||||||||||||||||||||
1575 | if (!isEventInCornerButtons
| 0 | ||||||||||||||||||||||||
1576 | const int index = d->indexAtPos(pos); | - | ||||||||||||||||||||||||
1577 | tabBarClicked(index); | - | ||||||||||||||||||||||||
1578 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1579 | - | |||||||||||||||||||||||||
1580 | if (event->button() != Qt::LeftButton
| 0 | ||||||||||||||||||||||||
1581 | event->ignore(); | - | ||||||||||||||||||||||||
1582 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1583 | } | - | ||||||||||||||||||||||||
1584 | - | |||||||||||||||||||||||||
1585 | if (d->pressedIndex != -1
| 0 | ||||||||||||||||||||||||
1586 | d->moveTabFinished(d->pressedIndex); never executed: d->moveTabFinished(d->pressedIndex); | 0 | ||||||||||||||||||||||||
1587 | - | |||||||||||||||||||||||||
1588 | d->pressedIndex = d->indexAtPos(event->pos()); | - | ||||||||||||||||||||||||
1589 | - | |||||||||||||||||||||||||
1590 | - | |||||||||||||||||||||||||
1591 | - | |||||||||||||||||||||||||
1592 | if (d->validIndex(d->pressedIndex)
| 0 | ||||||||||||||||||||||||
1593 | QStyleOptionTabBarBase optTabBase; | - | ||||||||||||||||||||||||
1594 | optTabBase.init(this); | - | ||||||||||||||||||||||||
1595 | optTabBase.documentMode = d->documentMode; | - | ||||||||||||||||||||||||
1596 | if (event->type() == style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this)
| 0 | ||||||||||||||||||||||||
1597 | setCurrentIndex(d->pressedIndex); never executed: setCurrentIndex(d->pressedIndex); | 0 | ||||||||||||||||||||||||
1598 | else | - | ||||||||||||||||||||||||
1599 | repaint(tabRect(d->pressedIndex)); never executed: repaint(tabRect(d->pressedIndex)); | 0 | ||||||||||||||||||||||||
1600 | if (d->movable
| 0 | ||||||||||||||||||||||||
1601 | d->dragStartPosition = event->pos(); | - | ||||||||||||||||||||||||
1602 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1603 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1604 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1605 | - | |||||||||||||||||||||||||
1606 | - | |||||||||||||||||||||||||
1607 | - | |||||||||||||||||||||||||
1608 | void QTabBar::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1609 | { | - | ||||||||||||||||||||||||
1610 | QTabBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1611 | if (d->movable
| 0 | ||||||||||||||||||||||||
1612 | - | |||||||||||||||||||||||||
1613 | if (d->pressedIndex != -1
| 0 | ||||||||||||||||||||||||
1614 | && event->buttons() == Qt::NoButton
| 0 | ||||||||||||||||||||||||
1615 | d->moveTabFinished(d->pressedIndex); never executed: d->moveTabFinished(d->pressedIndex); | 0 | ||||||||||||||||||||||||
1616 | - | |||||||||||||||||||||||||
1617 | - | |||||||||||||||||||||||||
1618 | if (!d->dragInProgress
| 0 | ||||||||||||||||||||||||
1619 | if ((
| 0 | ||||||||||||||||||||||||
1620 | d->dragInProgress = true; | - | ||||||||||||||||||||||||
1621 | d->setupMovableTab(); | - | ||||||||||||||||||||||||
1622 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1623 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1624 | - | |||||||||||||||||||||||||
1625 | if (event->buttons() == Qt::LeftButton
| 0 | ||||||||||||||||||||||||
1626 | && d->dragInProgress
| 0 | ||||||||||||||||||||||||
1627 | && d->validIndex(d->pressedIndex)
| 0 | ||||||||||||||||||||||||
1628 | bool vertical = verticalTabs(d->shape); | - | ||||||||||||||||||||||||
1629 | int dragDistance; | - | ||||||||||||||||||||||||
1630 | if (vertical
| 0 | ||||||||||||||||||||||||
1631 | dragDistance = (event->pos().y() - d->dragStartPosition.y()); | - | ||||||||||||||||||||||||
1632 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1633 | dragDistance = (event->pos().x() - d->dragStartPosition.x()); | - | ||||||||||||||||||||||||
1634 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1635 | d->tabList[d->pressedIndex].dragOffset = dragDistance; | - | ||||||||||||||||||||||||
1636 | - | |||||||||||||||||||||||||
1637 | QRect startingRect = tabRect(d->pressedIndex); | - | ||||||||||||||||||||||||
1638 | if (vertical
| 0 | ||||||||||||||||||||||||
1639 | startingRect.moveTop(startingRect.y() + dragDistance); never executed: startingRect.moveTop(startingRect.y() + dragDistance); | 0 | ||||||||||||||||||||||||
1640 | else | - | ||||||||||||||||||||||||
1641 | startingRect.moveLeft(startingRect.x() + dragDistance); never executed: startingRect.moveLeft(startingRect.x() + dragDistance); | 0 | ||||||||||||||||||||||||
1642 | - | |||||||||||||||||||||||||
1643 | int overIndex; | - | ||||||||||||||||||||||||
1644 | if (dragDistance < 0
| 0 | ||||||||||||||||||||||||
1645 | overIndex = tabAt(startingRect.topLeft()); never executed: overIndex = tabAt(startingRect.topLeft()); | 0 | ||||||||||||||||||||||||
1646 | else | - | ||||||||||||||||||||||||
1647 | overIndex = tabAt(startingRect.topRight()); never executed: overIndex = tabAt(startingRect.topRight()); | 0 | ||||||||||||||||||||||||
1648 | - | |||||||||||||||||||||||||
1649 | if (overIndex != d->pressedIndex
| 0 | ||||||||||||||||||||||||
1650 | int offset = 1; | - | ||||||||||||||||||||||||
1651 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
1652 | offset *= -1; never executed: offset *= -1; | 0 | ||||||||||||||||||||||||
1653 | if (dragDistance < 0
| 0 | ||||||||||||||||||||||||
1654 | dragDistance *= -1; | - | ||||||||||||||||||||||||
1655 | offset *= -1; | - | ||||||||||||||||||||||||
1656 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1657 | for (int i = d->pressedIndex; | - | ||||||||||||||||||||||||
1658 | offset > 0
| 0 | ||||||||||||||||||||||||
1659 | i += offset) { | - | ||||||||||||||||||||||||
1660 | QRect overIndexRect = tabRect(overIndex); | - | ||||||||||||||||||||||||
1661 | int needsToBeOver = (vertical
| 0 | ||||||||||||||||||||||||
1662 | if (dragDistance > needsToBeOver
| 0 | ||||||||||||||||||||||||
1663 | d->slide(i + offset, d->pressedIndex); never executed: d->slide(i + offset, d->pressedIndex); | 0 | ||||||||||||||||||||||||
1664 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1665 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1666 | - | |||||||||||||||||||||||||
1667 | d->layoutTab(d->pressedIndex); | - | ||||||||||||||||||||||||
1668 | - | |||||||||||||||||||||||||
1669 | update(); | - | ||||||||||||||||||||||||
1670 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1671 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1672 | - | |||||||||||||||||||||||||
1673 | if (event->buttons() != Qt::LeftButton
| 0 | ||||||||||||||||||||||||
1674 | event->ignore(); | - | ||||||||||||||||||||||||
1675 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1676 | } | - | ||||||||||||||||||||||||
1677 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1678 | - | |||||||||||||||||||||||||
1679 | void QTabBarPrivate::setupMovableTab() | - | ||||||||||||||||||||||||
1680 | { | - | ||||||||||||||||||||||||
1681 | QTabBar * const q = q_func(); | - | ||||||||||||||||||||||||
1682 | if (!movingTab
| 0 | ||||||||||||||||||||||||
1683 | movingTab = new QMovableTabWidget(q); never executed: movingTab = new QMovableTabWidget(q); | 0 | ||||||||||||||||||||||||
1684 | - | |||||||||||||||||||||||||
1685 | int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q); | - | ||||||||||||||||||||||||
1686 | QRect grabRect = q->tabRect(pressedIndex); | - | ||||||||||||||||||||||||
1687 | grabRect.adjust(-taboverlap, 0, taboverlap, 0); | - | ||||||||||||||||||||||||
1688 | - | |||||||||||||||||||||||||
1689 | QPixmap grabImage(grabRect.size() * q->devicePixelRatioF()); | - | ||||||||||||||||||||||||
1690 | grabImage.setDevicePixelRatio(q->devicePixelRatioF()); | - | ||||||||||||||||||||||||
1691 | grabImage.fill(Qt::transparent); | - | ||||||||||||||||||||||||
1692 | QStylePainter p(&grabImage, q); | - | ||||||||||||||||||||||||
1693 | p.initFrom(q); | - | ||||||||||||||||||||||||
1694 | - | |||||||||||||||||||||||||
1695 | QStyleOptionTab tab; | - | ||||||||||||||||||||||||
1696 | q->initStyleOption(&tab, pressedIndex); | - | ||||||||||||||||||||||||
1697 | tab.rect.moveTopLeft(QPoint(taboverlap, 0)); | - | ||||||||||||||||||||||||
1698 | p.drawControl(QStyle::CE_TabBarTab, tab); | - | ||||||||||||||||||||||||
1699 | p.end(); | - | ||||||||||||||||||||||||
1700 | - | |||||||||||||||||||||||||
1701 | movingTab->setPixmap(grabImage); | - | ||||||||||||||||||||||||
1702 | movingTab->setGeometry(grabRect); | - | ||||||||||||||||||||||||
1703 | movingTab->raise(); | - | ||||||||||||||||||||||||
1704 | - | |||||||||||||||||||||||||
1705 | - | |||||||||||||||||||||||||
1706 | if (tabList[pressedIndex].leftWidget
| 0 | ||||||||||||||||||||||||
1707 | tabList[pressedIndex].leftWidget->raise(); never executed: tabList[pressedIndex].leftWidget->raise(); | 0 | ||||||||||||||||||||||||
1708 | if (tabList[pressedIndex].rightWidget
| 0 | ||||||||||||||||||||||||
1709 | tabList[pressedIndex].rightWidget->raise(); never executed: tabList[pressedIndex].rightWidget->raise(); | 0 | ||||||||||||||||||||||||
1710 | if (leftB
| 0 | ||||||||||||||||||||||||
1711 | leftB->raise(); never executed: leftB->raise(); | 0 | ||||||||||||||||||||||||
1712 | if (rightB
| 0 | ||||||||||||||||||||||||
1713 | rightB->raise(); never executed: rightB->raise(); | 0 | ||||||||||||||||||||||||
1714 | movingTab->setVisible(true); | - | ||||||||||||||||||||||||
1715 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1716 | - | |||||||||||||||||||||||||
1717 | void QTabBarPrivate::moveTabFinished(int index) | - | ||||||||||||||||||||||||