MCPcopy Create free account
hub / github.com/KDAB/GammaRay / eventFilter

Method eventFilter

plugins/wlcompositorinspector/logview.cpp:551–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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};

Callers

nothing calls this directly

Calls 4

typeMethod · 0.45
valueMethod · 0.45
updateSizeMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected