| 549 | } |
| 550 | |
| 551 | bool eventFilter(QObject *o, QEvent *e) override |
| 552 | { |
| 553 | if (o == &m_view && e->type() == QEvent::Wheel) { |
| 554 | QWheelEvent *we = static_cast<QWheelEvent *>(e); |
| 555 | |
| 556 | qreal pos = we->position().x() * m_view.m_zoom; |
| 557 | auto sb = horizontalScrollBar(); |
| 558 | int sbvalue = horizontalScrollBar()->value(); |
| 559 | |
| 560 | m_view.m_zoom += (1. - qPow(5. / 4., qreal(we->angleDelta().y()) / 150.)) * m_view.m_zoom; |
| 561 | if (m_view.m_zoom < 10) { |
| 562 | m_view.m_zoom = 10; |
| 563 | } |
| 564 | |
| 565 | m_view.updateSize(); |
| 566 | |
| 567 | // keep the point under the mouse still, if possible |
| 568 | pos = pos / m_view.m_zoom; |
| 569 | sb->setValue(sbvalue + (0.5 + pos - we->position().x())); |
| 570 | } |
| 571 | return QScrollArea::eventFilter(o, e); |
| 572 | } |
| 573 | |
| 574 | View m_view; |
| 575 | }; |
nothing calls this directly
no test coverage detected