widgets/qabstractslider.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5QAbstractSliderPrivate::QAbstractSliderPrivate() -
6 : minimum(0), maximum(99), pageStep(10), value(0), position(0), pressValue(-1), -
7 singleStep(1), offset_accumulated(0), tracking(true), -
8 blocktracking(false), pressed(false), -
9 invertedAppearance(false), invertedControls(false), -
10 orientation(Qt::Horizontal), repeatAction(QAbstractSlider::SliderNoAction) -
11 -
12 -
13 -
14 -
15 -
16 -
17{ -
18 -
19 -
20}
executed: }
Execution Count:10240
10240
21 -
22QAbstractSliderPrivate::~QAbstractSliderPrivate() -
23{ -
24} -
25void QAbstractSlider::setRange(int min, int max) -
26{ -
27 QAbstractSliderPrivate * const d = d_func(); -
28 int oldMin = d->minimum; -
29 int oldMax = d->maximum; -
30 d->minimum = min; -
31 d->maximum = qMax(min, max); -
32 if (oldMin != d->minimum || oldMax != d->maximum) {
evaluated: oldMin != d->minimum
TRUEFALSE
yes
Evaluation Count:805
yes
Evaluation Count:48877
evaluated: oldMax != d->maximum
TRUEFALSE
yes
Evaluation Count:12794
yes
Evaluation Count:36083
805-48877
33 sliderChange(SliderRangeChange); -
34 rangeChanged(d->minimum, d->maximum); -
35 setValue(d->value); -
36 }
executed: }
Execution Count:13599
13599
37}
executed: }
Execution Count:49682
49682
38 -
39 -
40void QAbstractSliderPrivate::setSteps(int single, int page) -
41{ -
42 QAbstractSlider * const q = q_func(); -
43 singleStep = qAbs(single); -
44 pageStep = qAbs(page); -
45 q->sliderChange(QAbstractSlider::SliderStepsChange); -
46}
executed: }
Execution Count:7341
7341
47QAbstractSlider::QAbstractSlider(QWidget *parent) -
48 :QWidget(*new QAbstractSliderPrivate, parent, 0) -
49{ -
50}
executed: }
Execution Count:2
2
51 -
52 -
53QAbstractSlider::QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent) -
54 :QWidget(dd, parent, 0) -
55{ -
56}
executed: }
Execution Count:10238
10238
57 -
58 -
59 -
60 -
61QAbstractSlider::~QAbstractSlider() -
62{ -
63} -
64void QAbstractSlider::setOrientation(Qt::Orientation orientation) -
65{ -
66 QAbstractSliderPrivate * const d = d_func(); -
67 if (d->orientation == orientation)
evaluated: d->orientation == orientation
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:28
28-39
68 return;
executed: return;
Execution Count:39
39
69 -
70 d->orientation = orientation; -
71 if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
partially evaluated: !testAttribute(Qt::WA_WState_OwnSizePolicy)
TRUEFALSE
yes
Evaluation Count:28
no
Evaluation Count:0
0-28
72 QSizePolicy sp = sizePolicy(); -
73 sp.transpose(); -
74 setSizePolicy(sp); -
75 setAttribute(Qt::WA_WState_OwnSizePolicy, false); -
76 }
executed: }
Execution Count:28
28
77 update(); -
78 updateGeometry(); -
79}
executed: }
Execution Count:28
28
80 -
81Qt::Orientation QAbstractSlider::orientation() const -
82{ -
83 const QAbstractSliderPrivate * const d = d_func(); -
84 return d->orientation;
executed: return d->orientation;
Execution Count:3934
3934
85} -
86void QAbstractSlider::setMinimum(int min) -
87{ -
88 QAbstractSliderPrivate * const d = d_func(); -
89 setRange(min, qMax(d->maximum, min)); -
90}
executed: }
Execution Count:22
22
91 -
92int QAbstractSlider::minimum() const -
93{ -
94 const QAbstractSliderPrivate * const d = d_func(); -
95 return d->minimum;
executed: return d->minimum;
Execution Count:30871
30871
96} -
97void QAbstractSlider::setMaximum(int max) -
98{ -
99 QAbstractSliderPrivate * const d = d_func(); -
100 setRange(qMin(d->minimum, max), max); -
101}
executed: }
Execution Count:22
22
102 -
103int QAbstractSlider::maximum() const -
104{ -
105 const QAbstractSliderPrivate * const d = d_func(); -
106 return d->maximum;
executed: return d->maximum;
Execution Count:48561
48561
107} -
108void QAbstractSlider::setSingleStep(int step) -
109{ -
110 QAbstractSliderPrivate * const d = d_func(); -
111 if (step != d->singleStep)
evaluated: step != d->singleStep
TRUEFALSE
yes
Evaluation Count:2247
yes
Evaluation Count:22033
2247-22033
112 d->setSteps(step, d->pageStep);
executed: d->setSteps(step, d->pageStep);
Execution Count:2247
2247
113}
executed: }
Execution Count:24280
24280
114 -
115int QAbstractSlider::singleStep() const -
116{ -
117 const QAbstractSliderPrivate * const d = d_func(); -
118 return d->singleStep;
executed: return d->singleStep;
Execution Count:104
104
119} -
120void QAbstractSlider::setPageStep(int step) -
121{ -
122 QAbstractSliderPrivate * const d = d_func(); -
123 if (step != d->pageStep)
evaluated: step != d->pageStep
TRUEFALSE
yes
Evaluation Count:5094
yes
Evaluation Count:19841
5094-19841
124 d->setSteps(d->singleStep, step);
executed: d->setSteps(d->singleStep, step);
Execution Count:5094
5094
125}
executed: }
Execution Count:24935
24935
126 -
127int QAbstractSlider::pageStep() const -
128{ -
129 const QAbstractSliderPrivate * const d = d_func(); -
130 return d->pageStep;
executed: return d->pageStep;
Execution Count:2952
2952
131} -
132void QAbstractSlider::setTracking(bool enable) -
133{ -
134 QAbstractSliderPrivate * const d = d_func(); -
135 d->tracking = enable; -
136}
executed: }
Execution Count:39
39
137 -
138bool QAbstractSlider::hasTracking() const -
139{ -
140 const QAbstractSliderPrivate * const d = d_func(); -
141 return d->tracking;
executed: return d->tracking;
Execution Count:10
10
142} -
143void QAbstractSlider::setSliderDown(bool down) -
144{ -
145 QAbstractSliderPrivate * const d = d_func(); -
146 bool doEmit = d->pressed != down; -
147 -
148 d->pressed = down; -
149 -
150 if (doEmit) {
evaluated: doEmit
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:33
14-33
151 if (down)
evaluated: down
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:6
6-8
152 sliderPressed();
executed: sliderPressed();
Execution Count:8
8
153 else -
154 sliderReleased();
executed: sliderReleased();
Execution Count:6
6
155 } -
156 -
157 if (!down && d->position != d->value)
evaluated: !down
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:8
evaluated: d->position != d->value
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:38
1-39
158 triggerAction(SliderMove);
executed: triggerAction(SliderMove);
Execution Count:1
1
159}
executed: }
Execution Count:47
47
160 -
161bool QAbstractSlider::isSliderDown() const -
162{ -
163 const QAbstractSliderPrivate * const d = d_func(); -
164 return d->pressed;
executed: return d->pressed;
Execution Count:8
8
165} -
166void QAbstractSlider::setSliderPosition(int position) -
167{ -
168 QAbstractSliderPrivate * const d = d_func(); -
169 position = d->bound(position); -
170 if (position == d->position)
evaluated: position == d->position
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:227
25-227
171 return;
executed: return;
Execution Count:25
25
172 d->position = position; -
173 if (!d->tracking)
evaluated: !d->tracking
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:216
11-216
174 update();
executed: update();
Execution Count:11
11
175 if (d->pressed)
evaluated: d->pressed
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:221
6-221
176 sliderMoved(position);
executed: sliderMoved(position);
Execution Count:6
6
177 if (d->tracking && !d->blocktracking)
evaluated: d->tracking
TRUEFALSE
yes
Evaluation Count:216
yes
Evaluation Count:11
evaluated: !d->blocktracking
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:125
11-216
178 triggerAction(SliderMove);
executed: triggerAction(SliderMove);
Execution Count:91
91
179}
executed: }
Execution Count:227
227
180 -
181int QAbstractSlider::sliderPosition() const -
182{ -
183 const QAbstractSliderPrivate * const d = d_func(); -
184 return d->position;
executed: return d->position;
Execution Count:178
178
185} -
186int QAbstractSlider::value() const -
187{ -
188 const QAbstractSliderPrivate * const d = d_func(); -
189 return d->value;
executed: return d->value;
Execution Count:122880
122880
190} -
191 -
192void QAbstractSlider::setValue(int value) -
193{ -
194 QAbstractSliderPrivate * const d = d_func(); -
195 value = d->bound(value); -
196 if (d->value == value && d->position == value)
evaluated: d->value == value
TRUEFALSE
yes
Evaluation Count:19224
yes
Evaluation Count:9513
evaluated: d->position == value
TRUEFALSE
yes
Evaluation Count:19222
yes
Evaluation Count:2
2-19224
197 return;
executed: return;
Execution Count:19222
19222
198 d->value = value; -
199 if (d->position != value) {
evaluated: d->position != value
TRUEFALSE
yes
Evaluation Count:9272
yes
Evaluation Count:243
243-9272
200 d->position = value; -
201 if (d->pressed)
evaluated: d->pressed
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:9268
4-9268
202 sliderMoved((d->position = value));
executed: sliderMoved((d->position = value));
Execution Count:4
4
203 }
executed: }
Execution Count:9272
9272
204 -
205 QAccessibleValueChangeEvent event(this, d->value); -
206 QAccessible::updateAccessibility(&event); -
207 -
208 sliderChange(SliderValueChange); -
209 valueChanged(value); -
210}
executed: }
Execution Count:9515
9515
211bool QAbstractSlider::invertedAppearance() const -
212{ -
213 const QAbstractSliderPrivate * const d = d_func(); -
214 return d->invertedAppearance;
executed: return d->invertedAppearance;
Execution Count:14
14
215} -
216 -
217void QAbstractSlider::setInvertedAppearance(bool invert) -
218{ -
219 QAbstractSliderPrivate * const d = d_func(); -
220 d->invertedAppearance = invert; -
221 update(); -
222}
executed: }
Execution Count:54
54
223bool QAbstractSlider::invertedControls() const -
224{ -
225 const QAbstractSliderPrivate * const d = d_func(); -
226 return d->invertedControls;
executed: return d->invertedControls;
Execution Count:10
10
227} -
228 -
229void QAbstractSlider::setInvertedControls(bool invert) -
230{ -
231 QAbstractSliderPrivate * const d = d_func(); -
232 d->invertedControls = invert; -
233}
executed: }
Execution Count:62
62
234void QAbstractSlider::triggerAction(SliderAction action) -
235{ -
236 QAbstractSliderPrivate * const d = d_func(); -
237 d->blocktracking = true; -
238 switch (action) { -
239 case SliderSingleStepAdd: -
240 setSliderPosition(d->overflowSafeAdd(d->effectiveSingleStep())); -
241 break;
executed: break;
Execution Count:41
41
242 case SliderSingleStepSub: -
243 setSliderPosition(d->overflowSafeAdd(-d->effectiveSingleStep())); -
244 break;
executed: break;
Execution Count:40
40
245 case SliderPageStepAdd: -
246 setSliderPosition(d->overflowSafeAdd(d->pageStep)); -
247 break;
executed: break;
Execution Count:25
25
248 case SliderPageStepSub: -
249 setSliderPosition(d->overflowSafeAdd(-d->pageStep)); -
250 break;
executed: break;
Execution Count:17
17
251 case SliderToMinimum: -
252 setSliderPosition(d->minimum); -
253 break;
executed: break;
Execution Count:9
9
254 case SliderToMaximum: -
255 setSliderPosition(d->maximum); -
256 break;
executed: break;
Execution Count:9
9
257 case SliderMove: -
258 case SliderNoAction: -
259 break;
executed: break;
Execution Count:119
119
260 }; -
261 actionTriggered(action); -
262 d->blocktracking = false; -
263 setValue(d->position); -
264}
executed: }
Execution Count:260
260
265 -
266 -
267 -
268 -
269 -
270 -
271void QAbstractSlider::setRepeatAction(SliderAction action, int thresholdTime, int repeatTime) -
272{ -
273 QAbstractSliderPrivate * const d = d_func(); -
274 if ((d->repeatAction = action) == SliderNoAction) {
evaluated: (d->repeatAction = action) == SliderNoAction
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:5
5-8
275 d->repeatActionTimer.stop(); -
276 } else {
executed: }
Execution Count:8
8
277 d->repeatActionTime = repeatTime; -
278 d->repeatActionTimer.start(thresholdTime, this); -
279 }
executed: }
Execution Count:5
5
280} -
281 -
282 -
283 -
284 -
285 -
286QAbstractSlider::SliderAction QAbstractSlider::repeatAction() const -
287{ -
288 const QAbstractSliderPrivate * const d = d_func(); -
289 return d->repeatAction;
never executed: return d->repeatAction;
0
290} -
291 -
292 -
293 -
294void QAbstractSlider::timerEvent(QTimerEvent *e) -
295{ -
296 QAbstractSliderPrivate * const d = d_func(); -
297 if (e->timerId() == d->repeatActionTimer.timerId()) {
partially evaluated: e->timerId() == d->repeatActionTimer.timerId()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
298 if (d->repeatActionTime) {
evaluated: d->repeatActionTime
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
299 d->repeatActionTimer.start(d->repeatActionTime, this); -
300 d->repeatActionTime = 0; -
301 }
executed: }
Execution Count:1
1
302 if (d->repeatAction == SliderPageStepAdd)
partially evaluated: d->repeatAction == SliderPageStepAdd
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
303 d->setAdjustedSliderPosition(d->overflowSafeAdd(d->pageStep));
executed: d->setAdjustedSliderPosition(d->overflowSafeAdd(d->pageStep));
Execution Count:6
6
304 else if (d->repeatAction == SliderPageStepSub)
never evaluated: d->repeatAction == SliderPageStepSub
0
305 d->setAdjustedSliderPosition(d->overflowSafeAdd(-d->pageStep));
never executed: d->setAdjustedSliderPosition(d->overflowSafeAdd(-d->pageStep));
0
306 else -
307 triggerAction(d->repeatAction);
never executed: triggerAction(d->repeatAction);
0
308 } -
309}
executed: }
Execution Count:6
6
310void QAbstractSlider::sliderChange(SliderChange) -
311{ -
312 update(); -
313}
executed: }
Execution Count:30455
30455
314 -
315bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::KeyboardModifiers modifiers, int delta) -
316{ -
317 QAbstractSlider * const q = q_func(); -
318 int stepsToScroll = 0; -
319 -
320 if (orientation == Qt::Horizontal)
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:13
12-13
321 delta = -delta;
executed: delta = -delta;
Execution Count:12
12
322 qreal offset = qreal(delta) / 120; -
323 -
324 if ((modifiers & Qt::ControlModifier) || (modifiers & Qt::ShiftModifier)) {
evaluated: (modifiers & Qt::ControlModifier)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
evaluated: (modifiers & Qt::ShiftModifier)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:23
1-24
325 -
326 stepsToScroll = qBound(-pageStep, int(offset * pageStep), pageStep); -
327 offset_accumulated = 0; -
328 } else {
executed: }
Execution Count:2
2
329 -
330 -
331 -
332 qreal stepsToScrollF = -
333 -
334 QApplication::wheelScrollLines() * -
335 -
336 offset * effectiveSingleStep(); -
337 -
338 if (offset_accumulated != 0 && (offset / offset_accumulated) < 0)
partially evaluated: offset_accumulated != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
never evaluated: (offset / offset_accumulated) < 0
0-23
339 offset_accumulated = 0;
never executed: offset_accumulated = 0;
0
340 -
341 offset_accumulated += stepsToScrollF; -
342 -
343 -
344 stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep); -
345 -
346 -
347 -
348 -
349 -
350 -
351 offset_accumulated -= int(offset_accumulated); -
352 if (stepsToScroll == 0)
partially evaluated: stepsToScroll == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
353 return false;
never executed: return false;
0
354 }
executed: }
Execution Count:23
23
355 -
356 if (invertedControls)
evaluated: invertedControls
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:14
11-14
357 stepsToScroll = -stepsToScroll;
executed: stepsToScroll = -stepsToScroll;
Execution Count:11
11
358 -
359 int prevValue = value; -
360 position = overflowSafeAdd(stepsToScroll); -
361 q->triggerAction(QAbstractSlider::SliderMove); -
362 -
363 if (prevValue == value) {
evaluated: prevValue == value
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:23
2-23
364 offset_accumulated = 0; -
365 return false;
executed: return false;
Execution Count:2
2
366 } -
367 return true;
executed: return true;
Execution Count:23
23
368} -
369 -
370 -
371 -
372 -
373 -
374void QAbstractSlider::wheelEvent(QWheelEvent * e) -
375{ -
376 QAbstractSliderPrivate * const d = d_func(); -
377 e->ignore(); -
378 int delta = e->delta(); -
379 if (d->scrollByDelta(e->orientation(), e->modifiers(), delta))
partially evaluated: d->scrollByDelta(e->orientation(), e->modifiers(), delta)
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
380 e->accept();
executed: e->accept();
Execution Count:16
16
381}
executed: }
Execution Count:16
16
382 -
383 -
384 -
385 -
386 -
387 -
388void QAbstractSlider::keyPressEvent(QKeyEvent *ev) -
389{ -
390 QAbstractSliderPrivate * const d = d_func(); -
391 SliderAction action = SliderNoAction; -
392 switch (ev->key()) { -
393 case Qt::Key_Left: -
394 if (isRightToLeft())
partially evaluated: isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
395 action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
never evaluated: d->invertedAppearance
never executed: action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
0
396 else -
397 action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
evaluated: !d->invertedAppearance
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
executed: action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
Execution Count:12
6-12
398 break;
executed: break;
Execution Count:12
12
399 case Qt::Key_Right: -
400 if (isRightToLeft())
partially evaluated: isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
401 action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
never evaluated: d->invertedAppearance
never executed: action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
0
402 else -
403 action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
evaluated: !d->invertedAppearance
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
executed: action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
Execution Count:12
6-12
404 break;
executed: break;
Execution Count:12
12
405 case Qt::Key_Up: -
406 action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
evaluated: d->invertedControls
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:12
8-12
407 break;
executed: break;
Execution Count:20
20
408 case Qt::Key_Down: -
409 action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
evaluated: d->invertedControls
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:13
8-13
410 break;
executed: break;
Execution Count:21
21
411 case Qt::Key_PageUp: -
412 action = d->invertedControls ? SliderPageStepSub : SliderPageStepAdd;
evaluated: d->invertedControls
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
413 break;
executed: break;
Execution Count:12
12
414 case Qt::Key_PageDown: -
415 action = d->invertedControls ? SliderPageStepAdd : SliderPageStepSub;
evaluated: d->invertedControls
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
416 break;
executed: break;
Execution Count:12
12
417 case Qt::Key_Home: -
418 action = SliderToMinimum; -
419 break;
executed: break;
Execution Count:8
8
420 case Qt::Key_End: -
421 action = SliderToMaximum; -
422 break;
executed: break;
Execution Count:8
8
423 default: -
424 ev->ignore(); -
425 break;
never executed: break;
0
426 } -
427 if (action)
partially evaluated: action
TRUEFALSE
yes
Evaluation Count:105
no
Evaluation Count:0
0-105
428 triggerAction(action);
executed: triggerAction(action);
Execution Count:105
105
429}
executed: }
Execution Count:105
105
430 -
431 -
432 -
433 -
434void QAbstractSlider::changeEvent(QEvent *ev) -
435{ -
436 QAbstractSliderPrivate * const d = d_func(); -
437 switch (ev->type()) { -
438 case QEvent::EnabledChange: -
439 if (!isEnabled()) {
evaluated: !isEnabled()
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:20
20-23
440 d->repeatActionTimer.stop(); -
441 setSliderDown(false); -
442 }
executed: }
Execution Count:23
23
443 -
444 default:
code before this statement executed: default:
Execution Count:43
43
445 QWidget::changeEvent(ev); -
446 }
executed: }
Execution Count:927
927
447}
executed: }
Execution Count:927
927
448 -
449 -
450 -
451 -
452bool QAbstractSlider::event(QEvent *e) -
453{ -
454 return QWidget::event(e);
executed: return QWidget::event(e);
Execution Count:25885
25885
455} -
456 -
457 -
458 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial