Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | bool QScrollBarPrivate::updateHoverControl(const QPoint &pos) | - |
9 | { | - |
10 | QScrollBar * const q = q_func(); | - |
11 | QRect lastHoverRect = hoverRect; | - |
12 | QStyle::SubControl lastHoverControl = hoverControl; | - |
13 | bool doesHover = q->testAttribute(Qt::WA_Hover); | - |
14 | if (lastHoverControl != newHoverControl(pos) && doesHover) { never evaluated: lastHoverControl != newHoverControl(pos) never evaluated: doesHover | 0 |
15 | q->update(lastHoverRect); | - |
16 | q->update(hoverRect); | - |
17 | return true; never executed: return true; | 0 |
18 | } | - |
19 | return !doesHover; never executed: return !doesHover; | 0 |
20 | } | - |
21 | | - |
22 | QStyle::SubControl QScrollBarPrivate::newHoverControl(const QPoint &pos) | - |
23 | { | - |
24 | QScrollBar * const q = q_func(); | - |
25 | QStyleOptionSlider opt; | - |
26 | q->initStyleOption(&opt); | - |
27 | opt.subControls = QStyle::SC_All; | - |
28 | hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, pos, q); | - |
29 | if (hoverControl == QStyle::SC_None) never evaluated: hoverControl == QStyle::SC_None | 0 |
30 | hoverRect = QRect(); never executed: hoverRect = QRect(); | 0 |
31 | else | - |
32 | hoverRect = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, hoverControl, q); never executed: hoverRect = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, hoverControl, q); | 0 |
33 | return hoverControl; never executed: return hoverControl; | 0 |
34 | } | - |
35 | | - |
36 | void QScrollBarPrivate::setTransient(bool value) | - |
37 | { | - |
38 | QScrollBar * const q = q_func(); | - |
39 | if (transient != value) { partially evaluated: transient != value no Evaluation Count:0 | yes Evaluation Count:790 |
| 0-790 |
40 | transient = value; | - |
41 | if (q->isVisible()) { never evaluated: q->isVisible() | 0 |
42 | if (q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q)) never evaluated: q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q) | 0 |
43 | q->update(); never executed: q->update(); | 0 |
44 | } else if (!transient) { never evaluated: !transient | 0 |
45 | q->show(); | - |
46 | } | 0 |
47 | } | - |
48 | } executed: } Execution Count:790 | 790 |
49 | | - |
50 | void QScrollBarPrivate::flash() | - |
51 | { | - |
52 | QScrollBar * const q = q_func(); | - |
53 | if (!flashed && q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q)) { partially evaluated: !flashed yes Evaluation Count:18026 | no Evaluation Count:0 |
partially evaluated: q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q) no Evaluation Count:0 | yes Evaluation Count:18026 |
| 0-18026 |
54 | flashed = true; | - |
55 | q->show(); | - |
56 | } | 0 |
57 | } executed: } Execution Count:18026 | 18026 |
58 | | - |
59 | void QScrollBarPrivate::activateControl(uint control, int threshold) | - |
60 | { | - |
61 | QAbstractSlider::SliderAction action = QAbstractSlider::SliderNoAction; | - |
62 | switch (control) { | - |
63 | case QStyle::SC_ScrollBarAddPage: | - |
64 | action = QAbstractSlider::SliderPageStepAdd; | - |
65 | break; executed: break; Execution Count:1 | 1 |
66 | case QStyle::SC_ScrollBarSubPage: | - |
67 | action = QAbstractSlider::SliderPageStepSub; | - |
68 | break; | 0 |
69 | case QStyle::SC_ScrollBarAddLine: | - |
70 | action = QAbstractSlider::SliderSingleStepAdd; | - |
71 | break; executed: break; Execution Count:2 | 2 |
72 | case QStyle::SC_ScrollBarSubLine: | - |
73 | action = QAbstractSlider::SliderSingleStepSub; | - |
74 | break; | 0 |
75 | case QStyle::SC_ScrollBarFirst: | - |
76 | action = QAbstractSlider::SliderToMinimum; | - |
77 | break; | 0 |
78 | case QStyle::SC_ScrollBarLast: | - |
79 | action = QAbstractSlider::SliderToMaximum; | - |
80 | break; | 0 |
81 | default: | - |
82 | break; executed: break; Execution Count:1 | 1 |
83 | } | - |
84 | | - |
85 | if (action) { evaluated: action yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
86 | q_func()->setRepeatAction(action, threshold); | - |
87 | q_func()->triggerAction(action); | - |
88 | } executed: } Execution Count:3 | 3 |
89 | } executed: } Execution Count:4 | 4 |
90 | | - |
91 | void QScrollBarPrivate::stopRepeatAction() | - |
92 | { | - |
93 | QScrollBar * const q = q_func(); | - |
94 | QStyle::SubControl tmp = pressedControl; | - |
95 | q->setRepeatAction(QAbstractSlider::SliderNoAction); | - |
96 | pressedControl = QStyle::SC_None; | - |
97 | | - |
98 | if (tmp == QStyle::SC_ScrollBarSlider) evaluated: tmp == QStyle::SC_ScrollBarSlider yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
99 | q->setSliderDown(false); executed: q->setSliderDown(false); Execution Count:1 | 1 |
100 | | - |
101 | QStyleOptionSlider opt; | - |
102 | q->initStyleOption(&opt); | - |
103 | q->repaint(q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, tmp, q)); | - |
104 | } executed: } Execution Count:3 | 3 |
105 | void QScrollBar::initStyleOption(QStyleOptionSlider *option) const | - |
106 | { | - |
107 | if (!option) partially evaluated: !option no Evaluation Count:0 | yes Evaluation Count:99062 |
| 0-99062 |
108 | return; | 0 |
109 | | - |
110 | const QScrollBarPrivate * const d = d_func(); | - |
111 | option->initFrom(this); | - |
112 | option->subControls = QStyle::SC_None; | - |
113 | option->activeSubControls = QStyle::SC_None; | - |
114 | option->orientation = d->orientation; | - |
115 | option->minimum = d->minimum; | - |
116 | option->maximum = d->maximum; | - |
117 | option->sliderPosition = d->position; | - |
118 | option->sliderValue = d->value; | - |
119 | option->singleStep = d->singleStep; | - |
120 | option->pageStep = d->pageStep; | - |
121 | option->upsideDown = d->invertedAppearance; | - |
122 | if (d->orientation == Qt::Horizontal) evaluated: d->orientation == Qt::Horizontal yes Evaluation Count:48967 | yes Evaluation Count:50095 |
| 48967-50095 |
123 | option->state |= QStyle::State_Horizontal; executed: option->state |= QStyle::State_Horizontal; Execution Count:48967 | 48967 |
124 | if ((d->flashed || !d->transient) && style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)) partially evaluated: d->flashed no Evaluation Count:0 | yes Evaluation Count:99062 |
partially evaluated: !d->transient yes Evaluation Count:99062 | no Evaluation Count:0 |
partially evaluated: style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this) no Evaluation Count:0 | yes Evaluation Count:99062 |
| 0-99062 |
125 | option->state |= QStyle::State_On; never executed: option->state |= QStyle::State_On; | 0 |
126 | } executed: } Execution Count:99062 | 99062 |
127 | QScrollBar::QScrollBar(QWidget *parent) | - |
128 | : QAbstractSlider(*new QScrollBarPrivate, parent) | - |
129 | { | - |
130 | d_func()->orientation = Qt::Vertical; | - |
131 | d_func()->init(); | - |
132 | } executed: } Execution Count:17 | 17 |
133 | QScrollBar::QScrollBar(Qt::Orientation orientation, QWidget *parent) | - |
134 | : QAbstractSlider(*new QScrollBarPrivate, parent) | - |
135 | { | - |
136 | d_func()->orientation = orientation; | - |
137 | d_func()->init(); | - |
138 | } executed: } Execution Count:10202 | 10202 |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | QScrollBar::~QScrollBar() | - |
146 | { | - |
147 | } | - |
148 | | - |
149 | void QScrollBarPrivate::init() | - |
150 | { | - |
151 | QScrollBar * const q = q_func(); | - |
152 | invertedControls = true; | - |
153 | pressedControl = hoverControl = QStyle::SC_None; | - |
154 | pointerOutsidePressedControl = false; | - |
155 | transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q); | - |
156 | flashed = false; | - |
157 | q->setFocusPolicy(Qt::NoFocus); | - |
158 | QSizePolicy sp(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::Slider); | - |
159 | if (orientation == Qt::Vertical) evaluated: orientation == Qt::Vertical yes Evaluation Count:5117 | yes Evaluation Count:5102 |
| 5102-5117 |
160 | sp.transpose(); executed: sp.transpose(); Execution Count:5117 | 5117 |
161 | q->setSizePolicy(sp); | - |
162 | q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); | - |
163 | q->setAttribute(Qt::WA_OpaquePaintEvent); | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | } executed: } Execution Count:10219 | 10219 |
171 | | - |
172 | | - |
173 | | - |
174 | void QScrollBar::contextMenuEvent(QContextMenuEvent *event) | - |
175 | { | - |
176 | if (!style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, this)) { never evaluated: !style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, this) | 0 |
177 | QAbstractSlider::contextMenuEvent(event); | - |
178 | return ; | 0 |
179 | } | - |
180 | | - |
181 | | - |
182 | bool horiz = (d_func()->orientation == Qt::Horizontal); | - |
183 | QPointer<QMenu> menu = new QMenu(this); | - |
184 | QAction *actScrollHere = menu->addAction(tr("Scroll here")); | - |
185 | menu->addSeparator(); | - |
186 | QAction *actScrollTop = menu->addAction(horiz ? tr("Left edge") : tr("Top")); | - |
187 | QAction *actScrollBottom = menu->addAction(horiz ? tr("Right edge") : tr("Bottom")); | - |
188 | menu->addSeparator(); | - |
189 | QAction *actPageUp = menu->addAction(horiz ? tr("Page left") : tr("Page up")); | - |
190 | QAction *actPageDn = menu->addAction(horiz ? tr("Page right") : tr("Page down")); | - |
191 | menu->addSeparator(); | - |
192 | QAction *actScrollUp = menu->addAction(horiz ? tr("Scroll left") : tr("Scroll up")); | - |
193 | QAction *actScrollDn = menu->addAction(horiz ? tr("Scroll right") : tr("Scroll down")); | - |
194 | QAction *actionSelected = menu->exec(event->globalPos()); | - |
195 | delete menu; | - |
196 | if (actionSelected == 0) never evaluated: actionSelected == 0 | 0 |
197 | ; | 0 |
198 | else if (actionSelected == actScrollHere) never evaluated: actionSelected == actScrollHere | 0 |
199 | setValue(d_func()->pixelPosToRangeValue(horiz ? event->pos().x() : event->pos().y())); never executed: setValue(d_func()->pixelPosToRangeValue(horiz ? event->pos().x() : event->pos().y())); | 0 |
200 | else if (actionSelected == actScrollTop) never evaluated: actionSelected == actScrollTop | 0 |
201 | triggerAction(QAbstractSlider::SliderToMinimum); never executed: triggerAction(QAbstractSlider::SliderToMinimum); | 0 |
202 | else if (actionSelected == actScrollBottom) never evaluated: actionSelected == actScrollBottom | 0 |
203 | triggerAction(QAbstractSlider::SliderToMaximum); never executed: triggerAction(QAbstractSlider::SliderToMaximum); | 0 |
204 | else if (actionSelected == actPageUp) never evaluated: actionSelected == actPageUp | 0 |
205 | triggerAction(QAbstractSlider::SliderPageStepSub); never executed: triggerAction(QAbstractSlider::SliderPageStepSub); | 0 |
206 | else if (actionSelected == actPageDn) never evaluated: actionSelected == actPageDn | 0 |
207 | triggerAction(QAbstractSlider::SliderPageStepAdd); never executed: triggerAction(QAbstractSlider::SliderPageStepAdd); | 0 |
208 | else if (actionSelected == actScrollUp) never evaluated: actionSelected == actScrollUp | 0 |
209 | triggerAction(QAbstractSlider::SliderSingleStepSub); never executed: triggerAction(QAbstractSlider::SliderSingleStepSub); | 0 |
210 | else if (actionSelected == actScrollDn) never evaluated: actionSelected == actScrollDn | 0 |
211 | triggerAction(QAbstractSlider::SliderSingleStepAdd); never executed: triggerAction(QAbstractSlider::SliderSingleStepAdd); | 0 |
212 | | - |
213 | } | - |
214 | | - |
215 | | - |
216 | | - |
217 | | - |
218 | QSize QScrollBar::sizeHint() const | - |
219 | { | - |
220 | ensurePolished(); | - |
221 | QStyleOptionSlider opt; | - |
222 | initStyleOption(&opt); | - |
223 | | - |
224 | int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent, &opt, this); | - |
225 | int scrollBarSliderMin = style()->pixelMetric(QStyle::PM_ScrollBarSliderMin, &opt, this); | - |
226 | QSize size; | - |
227 | if (opt.orientation == Qt::Horizontal) evaluated: opt.orientation == Qt::Horizontal yes Evaluation Count:47588 | yes Evaluation Count:48376 |
| 47588-48376 |
228 | size = QSize(scrollBarExtent * 2 + scrollBarSliderMin, scrollBarExtent); executed: size = QSize(scrollBarExtent * 2 + scrollBarSliderMin, scrollBarExtent); Execution Count:47588 | 47588 |
229 | else | - |
230 | size = QSize(scrollBarExtent, scrollBarExtent * 2 + scrollBarSliderMin); executed: size = QSize(scrollBarExtent, scrollBarExtent * 2 + scrollBarSliderMin); Execution Count:48376 | 48376 |
231 | | - |
232 | return style()->sizeFromContents(QStyle::CT_ScrollBar, &opt, size, this) | 95964 |
233 | .expandedTo(QApplication::globalStrut()); executed: return style()->sizeFromContents(QStyle::CT_ScrollBar, &opt, size, this) .expandedTo(QApplication::globalStrut()); Execution Count:95964 | 95964 |
234 | } | - |
235 | | - |
236 | | - |
237 | void QScrollBar::sliderChange(SliderChange change) | - |
238 | { | - |
239 | QAbstractSlider::sliderChange(change); | - |
240 | } executed: } Execution Count:30061 | 30061 |
241 | | - |
242 | | - |
243 | | - |
244 | | - |
245 | bool QScrollBar::event(QEvent *event) | - |
246 | { | - |
247 | switch(event->type()) { | - |
248 | case QEvent::HoverEnter: | - |
249 | case QEvent::HoverLeave: | - |
250 | case QEvent::HoverMove: | - |
251 | if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) never evaluated: const QHoverEvent *he = static_cast<const QHoverEvent *>(event) | 0 |
252 | d_func()->updateHoverControl(he->pos()); never executed: d_func()->updateHoverControl(he->pos()); | 0 |
253 | break; | 0 |
254 | case QEvent::StyleChange: | - |
255 | d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)); | - |
256 | break; executed: break; Execution Count:790 | 790 |
257 | default: | - |
258 | break; executed: break; Execution Count:24747 | 24747 |
259 | } | - |
260 | return QAbstractSlider::event(event); executed: return QAbstractSlider::event(event); Execution Count:25537 | 25537 |
261 | } | - |
262 | | - |
263 | | - |
264 | | - |
265 | | - |
266 | | - |
267 | void QScrollBar::wheelEvent(QWheelEvent *event) | - |
268 | { | - |
269 | event->ignore(); | - |
270 | int delta = event->delta(); | - |
271 | | - |
272 | | - |
273 | | - |
274 | | - |
275 | | - |
276 | if (event->orientation() == Qt::Horizontal) evaluated: event->orientation() == Qt::Horizontal yes Evaluation Count:4 | yes Evaluation Count:5 |
| 4-5 |
277 | delta = -delta; executed: delta = -delta; Execution Count:4 | 4 |
278 | QScrollBarPrivate * const d = d_func(); | - |
279 | if (d->scrollByDelta(event->orientation(), event->modifiers(), delta)) evaluated: d->scrollByDelta(event->orientation(), event->modifiers(), delta) yes Evaluation Count:7 | yes Evaluation Count:2 |
| 2-7 |
280 | event->accept(); executed: event->accept(); Execution Count:7 | 7 |
281 | } executed: } Execution Count:9 | 9 |
282 | | - |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | void QScrollBar::paintEvent(QPaintEvent *) | - |
288 | { | - |
289 | QScrollBarPrivate * const d = d_func(); | - |
290 | QPainter p(this); | - |
291 | QStyleOptionSlider opt; | - |
292 | initStyleOption(&opt); | - |
293 | opt.subControls = QStyle::SC_All; | - |
294 | if (d->pressedControl) { evaluated: d->pressedControl yes Evaluation Count:1 | yes Evaluation Count:3081 |
| 1-3081 |
295 | opt.activeSubControls = (QStyle::SubControl)d->pressedControl; | - |
296 | if (!d->pointerOutsidePressedControl) partially evaluated: !d->pointerOutsidePressedControl yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
297 | opt.state |= QStyle::State_Sunken; executed: opt.state |= QStyle::State_Sunken; Execution Count:1 | 1 |
298 | } else { executed: } Execution Count:1 | 1 |
299 | opt.activeSubControls = (QStyle::SubControl)d->hoverControl; | - |
300 | } executed: } Execution Count:3081 | 3081 |
301 | style()->drawComplexControl(QStyle::CC_ScrollBar, &opt, &p, this); | - |
302 | if (d->flashed && style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)) { partially evaluated: d->flashed no Evaluation Count:0 | yes Evaluation Count:3082 |
never evaluated: style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this) | 0-3082 |
303 | d->flashed = false; | - |
304 | update(); | - |
305 | } | 0 |
306 | } executed: } Execution Count:3082 | 3082 |
307 | | - |
308 | | - |
309 | | - |
310 | | - |
311 | void QScrollBar::mousePressEvent(QMouseEvent *e) | - |
312 | { | - |
313 | QScrollBarPrivate * const d = d_func(); | - |
314 | | - |
315 | if (d->repeatActionTimer.isActive()) partially evaluated: d->repeatActionTimer.isActive() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
316 | d->stopRepeatAction(); never executed: d->stopRepeatAction(); | 0 |
317 | | - |
318 | bool midButtonAbsPos = style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition, | - |
319 | 0, this); | - |
320 | QStyleOptionSlider opt; | - |
321 | initStyleOption(&opt); | - |
322 | | - |
323 | if (d->maximum == d->minimum partially evaluated: d->maximum == d->minimum no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
324 | || (e->buttons() & (~e->button())) partially evaluated: (e->buttons() & (~e->button())) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
325 | || !(e->button() == Qt::LeftButton || (midButtonAbsPos && e->button() == Qt::MidButton))) partially evaluated: e->button() == Qt::LeftButton yes Evaluation Count:4 | no Evaluation Count:0 |
never evaluated: midButtonAbsPos never evaluated: e->button() == Qt::MidButton | 0-4 |
326 | return; | 0 |
327 | | - |
328 | d->pressedControl = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->pos(), this); | - |
329 | d->pointerOutsidePressedControl = false; | - |
330 | | - |
331 | QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt, | - |
332 | QStyle::SC_ScrollBarSlider, this); | - |
333 | QPoint click = e->pos(); | - |
334 | QPoint pressValue = click - sr.center() + sr.topLeft(); | - |
335 | d->pressValue = d->orientation == Qt::Horizontal ? d->pixelPosToRangeValue(pressValue.x()) : evaluated: d->orientation == Qt::Horizontal yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
336 | d->pixelPosToRangeValue(pressValue.y()); | - |
337 | if (d->pressedControl == QStyle::SC_ScrollBarSlider) { evaluated: d->pressedControl == QStyle::SC_ScrollBarSlider yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
338 | d->clickOffset = (d_func()->orientation == Qt::Horizontal) ? (click.x()-sr.x()) : (click.y()-sr.y()); partially evaluated: (d_func()->orientation == Qt::Horizontal) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
339 | d->snapBackPosition = d->position; | - |
340 | } executed: } Execution Count:1 | 1 |
341 | | - |
342 | if ((d->pressedControl == QStyle::SC_ScrollBarAddPage evaluated: d->pressedControl == QStyle::SC_ScrollBarAddPage yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
343 | || d->pressedControl == QStyle::SC_ScrollBarSubPage) partially evaluated: d->pressedControl == QStyle::SC_ScrollBarSubPage no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
344 | && ((midButtonAbsPos && e->button() == Qt::MidButton) partially evaluated: midButtonAbsPos no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: e->button() == Qt::MidButton | 0-1 |
345 | || (style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition, &opt, this) partially evaluated: style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition, &opt, this) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
346 | && e->button() == Qt::LeftButton))) { never evaluated: e->button() == Qt::LeftButton | 0 |
347 | int sliderLength = (d_func()->orientation == Qt::Horizontal) ? sr.width() : sr.height(); never evaluated: (d_func()->orientation == Qt::Horizontal) | 0 |
348 | setSliderPosition(d->pixelPosToRangeValue(((d_func()->orientation == Qt::Horizontal) ? e->pos().x() | - |
349 | : e->pos().y()) - sliderLength / 2)); | - |
350 | d->pressedControl = QStyle::SC_ScrollBarSlider; | - |
351 | d->clickOffset = sliderLength / 2; | - |
352 | } | 0 |
353 | const int initialDelay = 500; | - |
354 | d->activateControl(d->pressedControl, initialDelay); | - |
355 | QElapsedTimer time; | - |
356 | time.start(); | - |
357 | repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this)); | - |
358 | if (time.elapsed() >= initialDelay && d->repeatActionTimer.isActive()) { evaluated: time.elapsed() >= initialDelay yes Evaluation Count:1 | yes Evaluation Count:3 |
partially evaluated: d->repeatActionTimer.isActive() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-3 |
359 | | - |
360 | | - |
361 | | - |
362 | | - |
363 | | - |
364 | d->repeatActionTimer.start(50, this); | - |
365 | } executed: } Execution Count:1 | 1 |
366 | if (d->pressedControl == QStyle::SC_ScrollBarSlider) evaluated: d->pressedControl == QStyle::SC_ScrollBarSlider yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
367 | setSliderDown(true); executed: setSliderDown(true); Execution Count:1 | 1 |
368 | } executed: } Execution Count:4 | 4 |
369 | | - |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | void QScrollBar::mouseReleaseEvent(QMouseEvent *e) | - |
375 | { | - |
376 | QScrollBarPrivate * const d = d_func(); | - |
377 | if (!d->pressedControl) evaluated: !d->pressedControl yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
378 | return; executed: return; Execution Count:1 | 1 |
379 | | - |
380 | if (e->buttons() & (~e->button())) partially evaluated: e->buttons() & (~e->button()) no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
381 | return; | 0 |
382 | | - |
383 | d->stopRepeatAction(); | - |
384 | } executed: } Execution Count:3 | 3 |
385 | | - |
386 | | - |
387 | | - |
388 | | - |
389 | | - |
390 | void QScrollBar::mouseMoveEvent(QMouseEvent *e) | - |
391 | { | - |
392 | QScrollBarPrivate * const d = d_func(); | - |
393 | if (!d->pressedControl) never evaluated: !d->pressedControl | 0 |
394 | return; | 0 |
395 | | - |
396 | QStyleOptionSlider opt; | - |
397 | initStyleOption(&opt); | - |
398 | if (!(e->buttons() & Qt::LeftButton never evaluated: e->buttons() & Qt::LeftButton | 0 |
399 | || ((e->buttons() & Qt::MidButton) never evaluated: (e->buttons() & Qt::MidButton) | 0 |
400 | && style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition, &opt, this)))) never evaluated: style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition, &opt, this) | 0 |
401 | return; | 0 |
402 | | - |
403 | if (d->pressedControl == QStyle::SC_ScrollBarSlider) { never evaluated: d->pressedControl == QStyle::SC_ScrollBarSlider | 0 |
404 | QPoint click = e->pos(); | - |
405 | int newPosition = d->pixelPosToRangeValue(((d_func()->orientation == Qt::Horizontal) ? click.x() : click.y()) -d->clickOffset); | - |
406 | int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this); | - |
407 | if (m >= 0) { | 0 |
408 | QRect r = rect(); | - |
409 | r.adjust(-m, -m, m, m); | - |
410 | if (! r.contains(e->pos())) never evaluated: ! r.contains(e->pos()) | 0 |
411 | newPosition = d->snapBackPosition; never executed: newPosition = d->snapBackPosition; | 0 |
412 | } | 0 |
413 | setSliderPosition(newPosition); | - |
414 | } else if (!style()->styleHint(QStyle::SH_ScrollBar_ScrollWhenPointerLeavesControl, &opt, this)) { never evaluated: !style()->styleHint(QStyle::SH_ScrollBar_ScrollWhenPointerLeavesControl, &opt, this) | 0 |
415 | | - |
416 | if (style()->styleHint(QStyle::SH_ScrollBar_RollBetweenButtons, &opt, this) never evaluated: style()->styleHint(QStyle::SH_ScrollBar_RollBetweenButtons, &opt, this) | 0 |
417 | && d->pressedControl & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)) { never evaluated: d->pressedControl & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine) | 0 |
418 | QStyle::SubControl newSc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->pos(), this); | - |
419 | if (newSc == d->pressedControl && !d->pointerOutsidePressedControl) never evaluated: newSc == d->pressedControl never evaluated: !d->pointerOutsidePressedControl | 0 |
420 | return; | 0 |
421 | if (newSc & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)) { never evaluated: newSc & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine) | 0 |
422 | d->pointerOutsidePressedControl = false; | - |
423 | QRect scRect = style()->subControlRect(QStyle::CC_ScrollBar, &opt, newSc, this); | - |
424 | scRect |= style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this); | - |
425 | d->pressedControl = newSc; | - |
426 | d->activateControl(d->pressedControl, 0); | - |
427 | update(scRect); | - |
428 | return; | 0 |
429 | } | - |
430 | } | 0 |
431 | | - |
432 | | - |
433 | | - |
434 | QRect pr = style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this); | - |
435 | if (pr.contains(e->pos()) == d->pointerOutsidePressedControl) { never evaluated: pr.contains(e->pos()) == d->pointerOutsidePressedControl | 0 |
436 | if ((d->pointerOutsidePressedControl = !d->pointerOutsidePressedControl)) { never evaluated: (d->pointerOutsidePressedControl = !d->pointerOutsidePressedControl) | 0 |
437 | d->pointerOutsidePressedControl = true; | - |
438 | setRepeatAction(SliderNoAction); | - |
439 | repaint(pr); | - |
440 | } else { | 0 |
441 | d->activateControl(d->pressedControl); | - |
442 | } | 0 |
443 | } | - |
444 | } | 0 |
445 | } | - |
446 | | - |
447 | | - |
448 | int QScrollBarPrivate::pixelPosToRangeValue(int pos) const | - |
449 | { | - |
450 | const QScrollBar * const q = q_func(); | - |
451 | QStyleOptionSlider opt; | - |
452 | q->initStyleOption(&opt); | - |
453 | QRect gr = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, | - |
454 | QStyle::SC_ScrollBarGroove, q); | - |
455 | QRect sr = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, | - |
456 | QStyle::SC_ScrollBarSlider, q); | - |
457 | int sliderMin, sliderMax, sliderLength; | - |
458 | | - |
459 | if (orientation == Qt::Horizontal) { evaluated: orientation == Qt::Horizontal yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
460 | sliderLength = sr.width(); | - |
461 | sliderMin = gr.x(); | - |
462 | sliderMax = gr.right() - sliderLength + 1; | - |
463 | if (q->layoutDirection() == Qt::RightToLeft) partially evaluated: q->layoutDirection() == Qt::RightToLeft no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
464 | opt.upsideDown = !opt.upsideDown; never executed: opt.upsideDown = !opt.upsideDown; | 0 |
465 | } else { executed: } Execution Count:1 | 1 |
466 | sliderLength = sr.height(); | - |
467 | sliderMin = gr.y(); | - |
468 | sliderMax = gr.bottom() - sliderLength + 1; | - |
469 | } executed: } Execution Count:3 | 3 |
470 | | - |
471 | return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, | 4 |
472 | sliderMax - sliderMin, opt.upsideDown); executed: return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, sliderMax - sliderMin, opt.upsideDown); Execution Count:4 | 4 |
473 | } | - |
474 | | - |
475 | | - |
476 | | - |
477 | void QScrollBar::hideEvent(QHideEvent *) | - |
478 | { | - |
479 | QScrollBarPrivate * const d = d_func(); | - |
480 | if (d->pressedControl) { evaluated: d->pressedControl yes Evaluation Count:1 | yes Evaluation Count:1027 |
| 1-1027 |
481 | d->pressedControl = QStyle::SC_None; | - |
482 | setRepeatAction(SliderNoAction); | - |
483 | } executed: } Execution Count:1 | 1 |
484 | } executed: } Execution Count:1028 | 1028 |
485 | | - |
486 | | - |
487 | | - |
488 | | - |
489 | __attribute__((visibility("default"))) QStyleOptionSlider qt_qscrollbarStyleOption(QScrollBar *scrollbar) | - |
490 | { | - |
491 | QStyleOptionSlider opt; | - |
492 | scrollbar->initStyleOption(&opt); | - |
493 | return opt; executed: return opt; Execution Count:5 | 5 |
494 | } | - |
495 | | - |
496 | | - |
497 | | - |
| | |