4 #include <QApplication>
12 viewport()->installEventFilter(
this);
13 setMouseTracking(
true);
20 scale(factor, factor);
22 QPointF delta_viewport_pos =
m_target_viewport_pos - QPointF(viewport()->width() / 2.0, viewport()->height() / 2.0);
24 centerOn(mapToScene(viewport_center.toPoint()));
41 if (event->type() == QEvent::MouseMove) {
42 QMouseEvent* mouse_event =
static_cast<QMouseEvent*
>(event);
44 if (qAbs(delta.x()) > 5 || qAbs(delta.y()) > 5)
49 }
else if (event->type() == QEvent::Wheel) {
50 QWheelEvent* wheel_event =
static_cast<QWheelEvent*
>(event);
51 if (QApplication::keyboardModifiers() ==
m_modifiers) {
52 if (wheel_event->orientation() == Qt::Vertical) {
53 double angle = wheel_event->angleDelta().y();