| 286 | } |
| 287 | |
| 288 | void RangeSlider::wheelEvent(QWheelEvent *e) |
| 289 | { |
| 290 | QStyleOptionSlider opt; |
| 291 | initStyleOption(&opt); |
| 292 | |
| 293 | QRect groove = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this); |
| 294 | |
| 295 | int delta = e->angleDelta().y() / 8 / 15; |
| 296 | int x; |
| 297 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) |
| 298 | x = e->x() - groove.x(); |
| 299 | #else |
| 300 | x = (int)e->position().x() - groove.x(); |
| 301 | #endif |
| 302 | x = style()->sliderValueFromPosition(vmin, vmax, x, groove.width()); |
| 303 | |
| 304 | int h = 0; |
| 305 | if (x < pos0) |
| 306 | h = -1; |
| 307 | else if (x > pos1) |
| 308 | h = +1; |
| 309 | else if (abs(pos0 - x) < abs(pos1 - x)) |
| 310 | h = -1; |
| 311 | else if (abs(pos0 - x) > abs(pos1 - x)) |
| 312 | h = +1; |
| 313 | |
| 314 | if (e->modifiers() & Qt::ControlModifier) |
| 315 | delta *= 50; |
| 316 | |
| 317 | if (h < 0) |
| 318 | { |
| 319 | pos0 += delta; |
| 320 | if (pos0 < vmin) pos0 = vmin; |
| 321 | if (pos0 > pos1) pos0 = pos1; |
| 322 | emit valueChanged(pos0); |
| 323 | } |
| 324 | else |
| 325 | { |
| 326 | pos1 += delta; |
| 327 | if (pos1 > vmax) pos1 = vmax; |
| 328 | if (pos1 < pos0) pos1 = pos0; |
| 329 | emit valueChanged(pos1); |
| 330 | } |
| 331 | |
| 332 | update(); |
| 333 | } |
| 334 | |
| 335 | void RangeSlider::mouseMoveEvent(QMouseEvent *e) |
| 336 | { |
nothing calls this directly
no outgoing calls
no test coverage detected