! \reimp */
| 600 | \reimp |
| 601 | */ |
| 602 | void QxtSpanSlider::mouseMoveEvent(QMouseEvent* event) { |
| 603 | if (qxt_d().lowerPressed != QStyle::SC_SliderHandle && qxt_d().upperPressed != QStyle::SC_SliderHandle) { |
| 604 | event->ignore(); |
| 605 | return; |
| 606 | } |
| 607 | |
| 608 | QStyleOptionSlider opt; |
| 609 | qxt_d().initStyleOption(&opt); |
| 610 | const int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this); |
| 611 | int newPosition = qxt_d().pixelPosToRangeValue(qxt_d().pick(event->pos()) - qxt_d().offset); |
| 612 | if (m >= 0) { |
| 613 | const QRect r = rect().adjusted(-m, -m, m, m); |
| 614 | if (!r.contains(event->pos())) |
| 615 | newPosition = qxt_d().position; |
| 616 | } |
| 617 | |
| 618 | // pick the preferred handle on the first movement |
| 619 | if (qxt_d().firstMovement) { |
| 620 | if (qxt_d().lower == qxt_d().upper) { |
| 621 | if (newPosition < lowerValue()) { |
| 622 | qxt_d().swapControls(); |
| 623 | qxt_d().firstMovement = false; |
| 624 | } |
| 625 | } else |
| 626 | qxt_d().firstMovement = false; |
| 627 | } |
| 628 | |
| 629 | if (qxt_d().lowerPressed == QStyle::SC_SliderHandle) { |
| 630 | if (qxt_d().movement == NoCrossing) |
| 631 | newPosition = qMin(newPosition, upperValue()); |
| 632 | else if (qxt_d().movement == NoOverlapping) |
| 633 | newPosition = qMin(newPosition, upperValue() - 1); |
| 634 | |
| 635 | if (qxt_d().movement == FreeMovement && newPosition > qxt_d().upper) { |
| 636 | qxt_d().swapControls(); |
| 637 | setUpperPosition(newPosition); |
| 638 | } else |
| 639 | setLowerPosition(newPosition); |
| 640 | } else if (qxt_d().upperPressed == QStyle::SC_SliderHandle) { |
| 641 | if (qxt_d().movement == NoCrossing) |
| 642 | newPosition = qMax(newPosition, lowerValue()); |
| 643 | else if (qxt_d().movement == NoOverlapping) |
| 644 | newPosition = qMax(newPosition, lowerValue() + 1); |
| 645 | |
| 646 | if (qxt_d().movement == FreeMovement && newPosition < qxt_d().lower) { |
| 647 | qxt_d().swapControls(); |
| 648 | setLowerPosition(newPosition); |
| 649 | } else |
| 650 | setUpperPosition(newPosition); |
| 651 | } |
| 652 | event->accept(); |
| 653 | } |
| 654 | |
| 655 | /*! |
| 656 | \reimp |
nothing calls this directly
no test coverage detected