Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | #include <qapplication.h> | - |
41 | #include "qabstractslider.h" | - |
42 | #include "qevent.h" | - |
43 | #include "qabstractslider_p.h" | - |
44 | #include "qdebug.h" | - |
45 | #ifndef QT_NO_ACCESSIBILITY | - |
46 | #include "qaccessible.h" | - |
47 | #endif | - |
48 | #include <limits.h> | - |
49 | | - |
50 | QT_BEGIN_NAMESPACE | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | | - |
61 | | - |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
67 | | - |
68 | | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
150 | | - |
151 | | - |
152 | | - |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | | - |
178 | | - |
179 | | - |
180 | | - |
181 | | - |
182 | | - |
183 | | - |
184 | | - |
185 | | - |
186 | | - |
187 | | - |
188 | | - |
189 | | - |
190 | | - |
191 | | - |
192 | | - |
193 | | - |
194 | | - |
195 | | - |
196 | | - |
197 | | - |
198 | | - |
199 | | - |
200 | | - |
201 | | - |
202 | | - |
203 | | - |
204 | | - |
205 | | - |
206 | | - |
207 | | - |
208 | | - |
209 | | - |
210 | | - |
211 | | - |
212 | QAbstractSliderPrivate::QAbstractSliderPrivate() | - |
213 | : minimum(0), maximum(99), pageStep(10), value(0), position(0), pressValue(-1), | - |
214 | singleStep(1), singleStepFromItemView(-1), viewMayChangeSingleStep(true), offset_accumulated(0), tracking(true), | - |
215 | blocktracking(false), pressed(false), | - |
216 | invertedAppearance(false), invertedControls(false), | - |
217 | orientation(Qt::Horizontal), repeatAction(QAbstractSlider::SliderNoAction) | - |
218 | #ifdef QT_KEYPAD_NAVIGATION | - |
219 | , isAutoRepeating(false) | - |
220 | , repeatMultiplier(1) | - |
221 | { | - |
222 | firstRepeat.invalidate(); | - |
223 | #else | - |
224 | { | - |
225 | #endif | - |
226 | | - |
227 | } never executed: end of block | 0 |
228 | | - |
229 | QAbstractSliderPrivate::~QAbstractSliderPrivate() | - |
230 | { | - |
231 | } | - |
232 | | - |
233 | | - |
234 | | - |
235 | | - |
236 | | - |
237 | | - |
238 | | - |
239 | | - |
240 | | - |
241 | void QAbstractSlider::setRange(int min, int max) | - |
242 | { | - |
243 | Q_D(QAbstractSlider); | - |
244 | int oldMin = d->minimum; | - |
245 | int oldMax = d->maximum; | - |
246 | d->minimum = min; | - |
247 | d->maximum = qMax(min, max); | - |
248 | if (oldMin != d->minimum || oldMax != d->maximum) { | - |
249 | sliderChange(SliderRangeChange); | - |
250 | emit rangeChanged(d->minimum, d->maximum); | - |
251 | setValue(d->value); | - |
252 | } | - |
253 | } | - |
254 | | - |
255 | | - |
256 | void QAbstractSliderPrivate::setSteps(int single, int page) | - |
257 | { | - |
258 | Q_Q(QAbstractSlider); | - |
259 | singleStep = qAbs(single); | - |
260 | pageStep = qAbs(page); | - |
261 | q->sliderChange(QAbstractSlider::SliderStepsChange); | - |
262 | } | - |
263 | | - |
264 | | - |
265 | | - |
266 | | - |
267 | | - |
268 | | - |
269 | | - |
270 | | - |
271 | | - |
272 | | - |
273 | QAbstractSlider::QAbstractSlider(QWidget *parent) | - |
274 | :QWidget(*new QAbstractSliderPrivate, parent, 0) | - |
275 | { | - |
276 | } | - |
277 | | - |
278 | | - |
279 | QAbstractSlider::QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent) | - |
280 | :QWidget(dd, parent, 0) | - |
281 | { | - |
282 | } | - |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | QAbstractSlider::~QAbstractSlider() | - |
288 | { | - |
289 | } | - |
290 | | - |
291 | | - |
292 | | - |
293 | | - |
294 | | - |
295 | | - |
296 | | - |
297 | | - |
298 | void QAbstractSlider::setOrientation(Qt::Orientation orientation) | - |
299 | { | - |
300 | Q_D(QAbstractSlider); | - |
301 | if (d->orientation == orientation) | - |
302 | return; | - |
303 | | - |
304 | d->orientation = orientation; | - |
305 | if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) { | - |
306 | QSizePolicy sp = sizePolicy(); | - |
307 | sp.transpose(); | - |
308 | setSizePolicy(sp); | - |
309 | setAttribute(Qt::WA_WState_OwnSizePolicy, false); | - |
310 | } | - |
311 | update(); | - |
312 | updateGeometry(); | - |
313 | } | - |
314 | | - |
315 | Qt::Orientation QAbstractSlider::orientation() const | - |
316 | { | - |
317 | Q_D(const QAbstractSlider); | - |
318 | return d->orientation; | - |
319 | } | - |
320 | | - |
321 | | - |
322 | | - |
323 | | - |
324 | | - |
325 | | - |
326 | | - |
327 | | - |
328 | | - |
329 | | - |
330 | | - |
331 | | - |
332 | void QAbstractSlider::setMinimum(int min) | - |
333 | { | - |
334 | Q_D(QAbstractSlider); | - |
335 | setRange(min, qMax(d->maximum, min)); | - |
336 | } | - |
337 | | - |
338 | int QAbstractSlider::minimum() const | - |
339 | { | - |
340 | Q_D(const QAbstractSlider); | - |
341 | return d->minimum; | - |
342 | } | - |
343 | | - |
344 | | - |
345 | | - |
346 | | - |
347 | | - |
348 | | - |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | | - |
354 | | - |
355 | | - |
356 | void QAbstractSlider::setMaximum(int max) | - |
357 | { | - |
358 | Q_D(QAbstractSlider); | - |
359 | setRange(qMin(d->minimum, max), max); | - |
360 | } | - |
361 | | - |
362 | int QAbstractSlider::maximum() const | - |
363 | { | - |
364 | Q_D(const QAbstractSlider); | - |
365 | return d->maximum; | - |
366 | } | - |
367 | | - |
368 | | - |
369 | | - |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | | - |
375 | | - |
376 | | - |
377 | | - |
378 | | - |
379 | | - |
380 | | - |
381 | | - |
382 | | - |
383 | | - |
384 | void QAbstractSlider::setSingleStep(int step) | - |
385 | { | - |
386 | Q_D(QAbstractSlider); | - |
387 | | - |
388 | d->viewMayChangeSingleStep = (step < 0); | - |
389 | if (step < 0 && d->singleStepFromItemView > 0)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
390 | step = d->singleStepFromItemView; never executed: step = d->singleStepFromItemView; | 0 |
391 | | - |
392 | if (step != d->singleStep)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
393 | d->setSteps(step, d->pageStep); never executed: d->setSteps(step, d->pageStep); | 0 |
394 | } never executed: end of block | 0 |
395 | | - |
396 | int QAbstractSlider::singleStep() const | - |
397 | { | - |
398 | Q_D(const QAbstractSlider); | - |
399 | return d->singleStep; | - |
400 | } | - |
401 | | - |
402 | | - |
403 | | - |
404 | | - |
405 | | - |
406 | | - |
407 | | - |
408 | | - |
409 | | - |
410 | | - |
411 | | - |
412 | | - |
413 | void QAbstractSlider::setPageStep(int step) | - |
414 | { | - |
415 | Q_D(QAbstractSlider); | - |
416 | if (step != d->pageStep) | - |
417 | d->setSteps(d->singleStep, step); | - |
418 | } | - |
419 | | - |
420 | int QAbstractSlider::pageStep() const | - |
421 | { | - |
422 | Q_D(const QAbstractSlider); | - |
423 | return d->pageStep; | - |
424 | } | - |
425 | | - |
426 | | - |
427 | | - |
428 | | - |
429 | | - |
430 | | - |
431 | | - |
432 | | - |
433 | | - |
434 | | - |
435 | | - |
436 | | - |
437 | void QAbstractSlider::setTracking(bool enable) | - |
438 | { | - |
439 | Q_D(QAbstractSlider); | - |
440 | d->tracking = enable; | - |
441 | } | - |
442 | | - |
443 | bool QAbstractSlider::hasTracking() const | - |
444 | { | - |
445 | Q_D(const QAbstractSlider); | - |
446 | return d->tracking; | - |
447 | } | - |
448 | | - |
449 | | - |
450 | | - |
451 | | - |
452 | | - |
453 | | - |
454 | | - |
455 | | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | | - |
461 | void QAbstractSlider::setSliderDown(bool down) | - |
462 | { | - |
463 | Q_D(QAbstractSlider); | - |
464 | bool doEmit = d->pressed != down; | - |
465 | | - |
466 | d->pressed = down; | - |
467 | | - |
468 | if (doEmit) { | - |
469 | if (down) | - |
470 | emit sliderPressed(); | - |
471 | else | - |
472 | emit sliderReleased(); | - |
473 | } | - |
474 | | - |
475 | if (!down && d->position != d->value) | - |
476 | triggerAction(SliderMove); | - |
477 | } | - |
478 | | - |
479 | bool QAbstractSlider::isSliderDown() const | - |
480 | { | - |
481 | Q_D(const QAbstractSlider); | - |
482 | return d->pressed; | - |
483 | } | - |
484 | | - |
485 | | - |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | | - |
491 | | - |
492 | void QAbstractSlider::setSliderPosition(int position) | - |
493 | { | - |
494 | Q_D(QAbstractSlider); | - |
495 | position = d->bound(position); | - |
496 | if (position == d->position) | - |
497 | return; | - |
498 | d->position = position; | - |
499 | if (!d->tracking) | - |
500 | update(); | - |
501 | if (d->pressed) | - |
502 | emit sliderMoved(position); | - |
503 | if (d->tracking && !d->blocktracking) | - |
504 | triggerAction(SliderMove); | - |
505 | } | - |
506 | | - |
507 | int QAbstractSlider::sliderPosition() const | - |
508 | { | - |
509 | Q_D(const QAbstractSlider); | - |
510 | return d->position; | - |
511 | } | - |
512 | | - |
513 | | - |
514 | | - |
515 | | - |
516 | | - |
517 | | - |
518 | | - |
519 | | - |
520 | | - |
521 | | - |
522 | | - |
523 | | - |
524 | | - |
525 | int QAbstractSlider::value() const | - |
526 | { | - |
527 | Q_D(const QAbstractSlider); | - |
528 | return d->value; | - |
529 | } | - |
530 | | - |
531 | void QAbstractSlider::setValue(int value) | - |
532 | { | - |
533 | Q_D(QAbstractSlider); | - |
534 | value = d->bound(value); | - |
535 | if (d->value == value && d->position == value) | - |
536 | return; | - |
537 | d->value = value; | - |
538 | if (d->position != value) { | - |
539 | d->position = value; | - |
540 | if (d->pressed) | - |
541 | emit sliderMoved((d->position = value)); | - |
542 | } | - |
543 | #ifndef QT_NO_ACCESSIBILITY | - |
544 | QAccessibleValueChangeEvent event(this, d->value); | - |
545 | QAccessible::updateAccessibility(&event); | - |
546 | #endif | - |
547 | sliderChange(SliderValueChange); | - |
548 | emit valueChanged(value); | - |
549 | } | - |
550 | | - |
551 | | - |
552 | | - |
553 | | - |
554 | | - |
555 | | - |
556 | | - |
557 | | - |
558 | | - |
559 | | - |
560 | | - |
561 | | - |
562 | | - |
563 | | - |
564 | | - |
565 | bool QAbstractSlider::invertedAppearance() const | - |
566 | { | - |
567 | Q_D(const QAbstractSlider); | - |
568 | return d->invertedAppearance; | - |
569 | } | - |
570 | | - |
571 | void QAbstractSlider::setInvertedAppearance(bool invert) | - |
572 | { | - |
573 | Q_D(QAbstractSlider); | - |
574 | d->invertedAppearance = invert; | - |
575 | update(); | - |
576 | } | - |
577 | | - |
578 | | - |
579 | | - |
580 | | - |
581 | | - |
582 | | - |
583 | | - |
584 | | - |
585 | | - |
586 | | - |
587 | | - |
588 | | - |
589 | bool QAbstractSlider::invertedControls() const | - |
590 | { | - |
591 | Q_D(const QAbstractSlider); | - |
592 | return d->invertedControls; | - |
593 | } | - |
594 | | - |
595 | void QAbstractSlider::setInvertedControls(bool invert) | - |
596 | { | - |
597 | Q_D(QAbstractSlider); | - |
598 | d->invertedControls = invert; | - |
599 | } | - |
600 | | - |
601 | | - |
602 | | - |
603 | | - |
604 | | - |
605 | | - |
606 | | - |
607 | | - |
608 | void QAbstractSlider::triggerAction(SliderAction action) | - |
609 | { | - |
610 | Q_D(QAbstractSlider); | - |
611 | d->blocktracking = true; | - |
612 | switch (action) { | - |
613 | case SliderSingleStepAdd: | - |
614 | setSliderPosition(d->overflowSafeAdd(d->effectiveSingleStep())); | - |
615 | break; | - |
616 | case SliderSingleStepSub: | - |
617 | setSliderPosition(d->overflowSafeAdd(-d->effectiveSingleStep())); | - |
618 | break; | - |
619 | case SliderPageStepAdd: | - |
620 | setSliderPosition(d->overflowSafeAdd(d->pageStep)); | - |
621 | break; | - |
622 | case SliderPageStepSub: | - |
623 | setSliderPosition(d->overflowSafeAdd(-d->pageStep)); | - |
624 | break; | - |
625 | case SliderToMinimum: | - |
626 | setSliderPosition(d->minimum); | - |
627 | break; | - |
628 | case SliderToMaximum: | - |
629 | setSliderPosition(d->maximum); | - |
630 | break; | - |
631 | case SliderMove: | - |
632 | case SliderNoAction: | - |
633 | break; | - |
634 | }; | - |
635 | emit actionTriggered(action); | - |
636 | d->blocktracking = false; | - |
637 | setValue(d->position); | - |
638 | } | - |
639 | | - |
640 | | - |
641 | | - |
642 | | - |
643 | | - |
644 | | - |
645 | void QAbstractSlider::setRepeatAction(SliderAction action, int thresholdTime, int repeatTime) | - |
646 | { | - |
647 | Q_D(QAbstractSlider); | - |
648 | if ((d->repeatAction = action) == SliderNoAction) { | - |
649 | d->repeatActionTimer.stop(); | - |
650 | } else { | - |
651 | d->repeatActionTime = repeatTime; | - |
652 | d->repeatActionTimer.start(thresholdTime, this); | - |
653 | } | - |
654 | } | - |
655 | | - |
656 | | - |
657 | | - |
658 | | - |
659 | | - |
660 | QAbstractSlider::SliderAction QAbstractSlider::repeatAction() const | - |
661 | { | - |
662 | Q_D(const QAbstractSlider); | - |
663 | return d->repeatAction; | - |
664 | } | - |
665 | | - |
666 | | - |
667 | | - |
668 | void QAbstractSlider::timerEvent(QTimerEvent *e) | - |
669 | { | - |
670 | Q_D(QAbstractSlider); | - |
671 | if (e->timerId() == d->repeatActionTimer.timerId()) { | - |
672 | if (d->repeatActionTime) { | - |
673 | d->repeatActionTimer.start(d->repeatActionTime, this); | - |
674 | d->repeatActionTime = 0; | - |
675 | } | - |
676 | if (d->repeatAction == SliderPageStepAdd) | - |
677 | d->setAdjustedSliderPosition(d->overflowSafeAdd(d->pageStep)); | - |
678 | else if (d->repeatAction == SliderPageStepSub) | - |
679 | d->setAdjustedSliderPosition(d->overflowSafeAdd(-d->pageStep)); | - |
680 | else | - |
681 | triggerAction(d->repeatAction); | - |
682 | } | - |
683 | } | - |
684 | | - |
685 | | - |
686 | | - |
687 | | - |
688 | | - |
689 | | - |
690 | | - |
691 | | - |
692 | void QAbstractSlider::sliderChange(SliderChange) | - |
693 | { | - |
694 | update(); | - |
695 | } | - |
696 | | - |
697 | bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::KeyboardModifiers modifiers, int delta) | - |
698 | { | - |
699 | Q_Q(QAbstractSlider); | - |
700 | int stepsToScroll = 0; | - |
701 | | - |
702 | if (orientation == Qt::Horizontal) | - |
703 | delta = -delta; | - |
704 | qreal offset = qreal(delta) / 120; | - |
705 | | - |
706 | if ((modifiers & Qt::ControlModifier) || (modifiers & Qt::ShiftModifier)) { | - |
707 | | - |
708 | stepsToScroll = qBound(-pageStep, int(offset * pageStep), pageStep); | - |
709 | offset_accumulated = 0; | - |
710 | } else { | - |
711 | | - |
712 | | - |
713 | | - |
714 | qreal stepsToScrollF = | - |
715 | #ifndef QT_NO_WHEELEVENT | - |
716 | QApplication::wheelScrollLines() * | - |
717 | #endif | - |
718 | offset * effectiveSingleStep(); | - |
719 | | - |
720 | if (offset_accumulated != 0 && (offset / offset_accumulated) < 0) | - |
721 | offset_accumulated = 0; | - |
722 | | - |
723 | offset_accumulated += stepsToScrollF; | - |
724 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - |
725 | | - |
726 | stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep); | - |
727 | #else | - |
728 | | - |
729 | | - |
730 | | - |
731 | stepsToScroll = int(offset_accumulated); | - |
732 | #endif | - |
733 | offset_accumulated -= int(offset_accumulated); | - |
734 | if (stepsToScroll == 0) { | - |
735 | | - |
736 | | - |
737 | const float effective_offset = invertedControls ? -offset_accumulated : offset_accumulated; | - |
738 | if (effective_offset > 0.f && value < maximum) | - |
739 | return true; | - |
740 | if (effective_offset < 0.f && value > minimum) | - |
741 | return true; | - |
742 | offset_accumulated = 0; | - |
743 | return false; | - |
744 | } | - |
745 | } | - |
746 | | - |
747 | if (invertedControls) | - |
748 | stepsToScroll = -stepsToScroll; | - |
749 | | - |
750 | int prevValue = value; | - |
751 | position = bound(overflowSafeAdd(stepsToScroll)); | - |
752 | q->triggerAction(QAbstractSlider::SliderMove); | - |
753 | | - |
754 | if (prevValue == value) { | - |
755 | offset_accumulated = 0; | - |
756 | return false; | - |
757 | } | - |
758 | return true; | - |
759 | } | - |
760 | | - |
761 | | - |
762 | | - |
763 | | - |
764 | #ifndef QT_NO_WHEELEVENT | - |
765 | void QAbstractSlider::wheelEvent(QWheelEvent * e) | - |
766 | { | - |
767 | Q_D(QAbstractSlider); | - |
768 | e->ignore(); | - |
769 | int delta = e->delta(); | - |
770 | if (e->inverted())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
771 | delta = -delta; never executed: delta = -delta; | 0 |
772 | if (d->scrollByDelta(e->orientation(), e->modifiers(), delta))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
773 | e->accept(); never executed: e->accept(); | 0 |
774 | } never executed: end of block | 0 |
775 | | - |
776 | #endif | - |
777 | | - |
778 | | - |
779 | | - |
780 | | - |
781 | void QAbstractSlider::keyPressEvent(QKeyEvent *ev) | - |
782 | { | - |
783 | Q_D(QAbstractSlider); | - |
784 | SliderAction action = SliderNoAction; | - |
785 | #ifdef QT_KEYPAD_NAVIGATION | - |
786 | if (ev->isAutoRepeat()) { | - |
787 | if (!d->firstRepeat.isValid()) | - |
788 | d->firstRepeat.start(); | - |
789 | else if (1 == d->repeatMultiplier) { | - |
790 | | - |
791 | | - |
792 | const int repeatMSecs = d->firstRepeat.elapsed(); | - |
793 | | - |
794 | | - |
795 | | - |
796 | | - |
797 | const qreal currentTimeElapse = (qreal(maximum()) / singleStep()) * repeatMSecs; | - |
798 | | - |
799 | | - |
800 | | - |
801 | | - |
802 | | - |
803 | | - |
804 | const int SliderRepeatElapse = 2500; | - |
805 | | - |
806 | d->repeatMultiplier = currentTimeElapse / SliderRepeatElapse; | - |
807 | } | - |
808 | | - |
809 | } | - |
810 | else if (d->firstRepeat.isValid()) { | - |
811 | d->firstRepeat.invalidate(); | - |
812 | d->repeatMultiplier = 1; | - |
813 | } | - |
814 | | - |
815 | #endif | - |
816 | | - |
817 | switch (ev->key()) { | - |
818 | #ifdef QT_KEYPAD_NAVIGATION | - |
819 | case Qt::Key_Select: | - |
820 | if (QApplication::keypadNavigationEnabled()) | - |
821 | setEditFocus(!hasEditFocus()); | - |
822 | else | - |
823 | ev->ignore(); | - |
824 | break; | - |
825 | case Qt::Key_Back: | - |
826 | if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { | - |
827 | setValue(d->origValue); | - |
828 | setEditFocus(false); | - |
829 | } else | - |
830 | ev->ignore(); | - |
831 | break; | - |
832 | #endif | - |
833 | | - |
834 | | - |
835 | case Qt::Key_Left: | - |
836 | #ifdef QT_KEYPAD_NAVIGATION | - |
837 | | - |
838 | | - |
839 | | - |
840 | if (QApplication::keypadNavigationEnabled() | - |
841 | && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder | - |
842 | || d->orientation == Qt::Vertical | - |
843 | || !hasEditFocus() | - |
844 | && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) { | - |
845 | ev->ignore(); | - |
846 | return; | - |
847 | } | - |
848 | if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical) | - |
849 | action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; | - |
850 | else | - |
851 | #endif | - |
852 | if (isRightToLeft()) | - |
853 | action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; | - |
854 | else | - |
855 | action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; | - |
856 | break; | - |
857 | case Qt::Key_Right: | - |
858 | #ifdef QT_KEYPAD_NAVIGATION | - |
859 | | - |
860 | if (QApplication::keypadNavigationEnabled() | - |
861 | && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder | - |
862 | || d->orientation == Qt::Vertical | - |
863 | || !hasEditFocus() | - |
864 | && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) { | - |
865 | ev->ignore(); | - |
866 | return; | - |
867 | } | - |
868 | if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical) | - |
869 | action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; | - |
870 | else | - |
871 | #endif | - |
872 | if (isRightToLeft()) | - |
873 | action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; | - |
874 | else | - |
875 | action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; | - |
876 | break; | - |
877 | case Qt::Key_Up: | - |
878 | #ifdef QT_KEYPAD_NAVIGATION | - |
879 | | - |
880 | | - |
881 | if (QApplication::keypadNavigationEnabled() | - |
882 | && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder | - |
883 | || d->orientation == Qt::Horizontal | - |
884 | || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) { | - |
885 | ev->ignore(); | - |
886 | break; | - |
887 | } | - |
888 | #endif | - |
889 | action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; | - |
890 | break; | - |
891 | case Qt::Key_Down: | - |
892 | #ifdef QT_KEYPAD_NAVIGATION | - |
893 | | - |
894 | if (QApplication::keypadNavigationEnabled() | - |
895 | && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder | - |
896 | || d->orientation == Qt::Horizontal | - |
897 | || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) { | - |
898 | ev->ignore(); | - |
899 | break; | - |
900 | } | - |
901 | #endif | - |
902 | action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; | - |
903 | break; | - |
904 | case Qt::Key_PageUp: | - |
905 | action = d->invertedControls ? SliderPageStepSub : SliderPageStepAdd; | - |
906 | break; | - |
907 | case Qt::Key_PageDown: | - |
908 | action = d->invertedControls ? SliderPageStepAdd : SliderPageStepSub; | - |
909 | break; | - |
910 | case Qt::Key_Home: | - |
911 | action = SliderToMinimum; | - |
912 | break; | - |
913 | case Qt::Key_End: | - |
914 | action = SliderToMaximum; | - |
915 | break; | - |
916 | default: | - |
917 | ev->ignore(); | - |
918 | break; | - |
919 | } | - |
920 | if (action) | - |
921 | triggerAction(action); | - |
922 | } | - |
923 | | - |
924 | | - |
925 | | - |
926 | | - |
927 | void QAbstractSlider::changeEvent(QEvent *ev) | - |
928 | { | - |
929 | Q_D(QAbstractSlider); | - |
930 | switch (ev->type()) { | - |
931 | case QEvent::EnabledChange: | - |
932 | if (!isEnabled()) { | - |
933 | d->repeatActionTimer.stop(); | - |
934 | setSliderDown(false); | - |
935 | } | - |
936 | | - |
937 | default: | - |
938 | QWidget::changeEvent(ev); | - |
939 | } | - |
940 | } | - |
941 | | - |
942 | | - |
943 | | - |
944 | | - |
945 | bool QAbstractSlider::event(QEvent *e) | - |
946 | { | - |
947 | #ifdef QT_KEYPAD_NAVIGATION | - |
948 | Q_D(QAbstractSlider); | - |
949 | switch (e->type()) { | - |
950 | case QEvent::FocusIn: | - |
951 | d->origValue = d->value; | - |
952 | break; | - |
953 | default: | - |
954 | break; | - |
955 | } | - |
956 | #endif | - |
957 | | - |
958 | return QWidget::event(e); | - |
959 | } | - |
960 | | - |
961 | | - |
962 | | - |
963 | | - |
964 | | - |
965 | | - |
966 | void QAbstractSliderPrivate::itemviewChangeSingleStep(int step) | - |
967 | { | - |
968 | singleStepFromItemView = step; | - |
969 | if (viewMayChangeSingleStep && singleStep != step)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
970 | setSteps(step, pageStep never executed: setSteps(step, pageStep); );never executed: setSteps(step, pageStep); | 0 |
971 | } never executed: end of block | 0 |
972 | | - |
973 | QT_END_NAMESPACE | - |
974 | | - |
975 | #include "moc_qabstractslider.cpp" | - |
| | |