diff --git a/src/GUI/graphview.cpp b/src/GUI/graphview.cpp index c2039142..08a6b946 100644 --- a/src/GUI/graphview.cpp +++ b/src/GUI/graphview.cpp @@ -342,10 +342,24 @@ void GraphView::resizeEvent(QResizeEvent *e) QGraphicsView::resizeEvent(e); } +void GraphView::mouseMoveEvent(QMouseEvent *e) +{ + if (e->buttons() & Qt::MiddleButton) { + QScrollBar *sb = horizontalScrollBar(); + int x = e->x(); + sb->setSliderPosition(sb->sliderPosition() - (x - _xStartDrag)); + _xStartDrag = x; + } + + QGraphicsView::mouseMoveEvent(e); +} + void GraphView::mousePressEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) newSliderPosition(mapToScene(e->pos())); + else if (e->button() == Qt::MiddleButton) + _xStartDrag = e->x(); QGraphicsView::mousePressEvent(e); } diff --git a/src/GUI/graphview.h b/src/GUI/graphview.h index 21ac3ecd..fc08100d 100644 --- a/src/GUI/graphview.h +++ b/src/GUI/graphview.h @@ -57,6 +57,7 @@ protected: void setUnits(Units units); void resizeEvent(QResizeEvent *e); + void mouseMoveEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *e); void wheelEvent(QWheelEvent *e); void changeEvent(QEvent *e); @@ -122,6 +123,7 @@ private: qreal _minYRange; qreal _zoom; + int _xStartDrag; }; #endif // GRAPHVIEW_H