1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-22 23:04:23 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
9f461c541a Merge 9bb04d7154 into 69951fe248 2024-06-04 23:26:09 +02:00
9bb04d7154 Add middle mouse button drag in the GraphView
Handle middle mouse button in `mouseMoveEvent()` (new) and `mousePressEvent()` methods.

(Removed preprocessor conditions; deprecated QMouseEvent::pos() / QMouseEvent::x() were chosen.)
2024-06-04 11:34:44 +00:00
e09f4d47cd Add middle mouse button drag in the GraphView
Handle middle mouse button in `mouseMoveEvent()` (new) and `mousePressEvent()` methods.
2024-06-04 08:35:27 +00:00
2 changed files with 16 additions and 0 deletions

View File

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

View File

@ -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