mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Compare commits
No commits in common. "40febb8c0e4ecaf54b200b46b1925856ad1b2dde" and "8f9af0d97305338da371f35b347df952c17130df" have entirely different histories.
40febb8c0e
...
8f9af0d973
@ -1,7 +1,6 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <QWheelEvent>
|
||||
#include <QGestureEvent>
|
||||
#include <QApplication>
|
||||
#include <QScrollBar>
|
||||
#include <QClipboard>
|
||||
@ -50,8 +49,6 @@ MapView::MapView(Map *map, POI *poi, QGeoPositionInfoSource *source,
|
||||
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||
setResizeAnchor(QGraphicsView::AnchorViewCenter);
|
||||
setAcceptDrops(false);
|
||||
viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
grabGesture(Qt::PinchGesture);
|
||||
|
||||
_mapScale = new ScaleItem();
|
||||
_mapScale->setZValue(2.0);
|
||||
@ -128,8 +125,6 @@ MapView::MapView(Map *map, POI *poi, QGeoPositionInfoSource *source,
|
||||
_opengl = false;
|
||||
_plot = false;
|
||||
_digitalZoom = 0;
|
||||
_pinchZoom = 0;
|
||||
_wheelDelta = 0;
|
||||
|
||||
_res = _map->resolution(_map->bounds());
|
||||
_scene->setSceneRect(_map->bounds());
|
||||
@ -622,40 +617,19 @@ void MapView::zoom(int zoom, const QPoint &pos, bool shift)
|
||||
}
|
||||
}
|
||||
|
||||
void MapView::pinchGesture(QPinchGesture *gesture)
|
||||
{
|
||||
QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
|
||||
qreal scaleFactor = gesture->totalScaleFactor();
|
||||
|
||||
if (changeFlags & QPinchGesture::ScaleFactorChanged) {
|
||||
int z = 0;
|
||||
|
||||
for (qreal sc = scaleFactor; sc > 1.25; sc *= 0.8)
|
||||
z += 1;
|
||||
for (qreal sc = scaleFactor; sc < 0.8; sc *= 1.25)
|
||||
z -= 1;
|
||||
|
||||
if (_pinchZoom != z) {
|
||||
zoom(z - _pinchZoom, gesture->centerPoint().toPoint(), false);
|
||||
_pinchZoom = z;
|
||||
}
|
||||
}
|
||||
if (gesture->state() == Qt::GestureFinished)
|
||||
_pinchZoom = 0;
|
||||
}
|
||||
|
||||
void MapView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
static int deg8 = 0;
|
||||
bool shift = (event->modifiers() & MODIFIER) ? true : false;
|
||||
// Shift inverts the wheel axis on OS X, so use scrolling in both axes for
|
||||
// the zoom.
|
||||
int delta = event->angleDelta().y()
|
||||
? event->angleDelta().y() : event->angleDelta().x();
|
||||
|
||||
_wheelDelta += delta;
|
||||
if (qAbs(_wheelDelta) < (15 * 8))
|
||||
deg8 += delta;
|
||||
if (qAbs(deg8) < (15 * 8))
|
||||
return;
|
||||
_wheelDelta = _wheelDelta % (15 * 8);
|
||||
deg8 = deg8 % (15 * 8);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
zoom((delta > 0) ? 1 : -1, event->pos(), shift);
|
||||
@ -1212,22 +1186,6 @@ void MapView::leaveEvent(QEvent *event)
|
||||
QGraphicsView::leaveEvent(event);
|
||||
}
|
||||
|
||||
bool MapView::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::Gesture)
|
||||
return gestureEvent(static_cast<QGestureEvent*>(event));
|
||||
|
||||
return QGraphicsView::event(event);
|
||||
}
|
||||
|
||||
bool MapView::gestureEvent(QGestureEvent *event)
|
||||
{
|
||||
if (QGesture *pinch = event->gesture(Qt::PinchGesture))
|
||||
pinchGesture(static_cast<QPinchGesture *>(pinch));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MapView::useOpenGL(bool use)
|
||||
{
|
||||
_opengl = use;
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
class QGeoPositionInfoSource;
|
||||
class QGeoPositionInfo;
|
||||
class QGestureEvent;
|
||||
class QPinchGesture;
|
||||
class Data;
|
||||
class POI;
|
||||
class Map;
|
||||
@ -149,8 +147,6 @@ private:
|
||||
void zoom(int zoom, const QPoint &pos, bool shift);
|
||||
void digitalZoom(int zoom);
|
||||
void updatePOIVisibility();
|
||||
bool gestureEvent(QGestureEvent *event);
|
||||
void pinchGesture(QPinchGesture *gesture);
|
||||
void skipColor() {_palette.nextColor();}
|
||||
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
@ -161,9 +157,8 @@ private:
|
||||
void keyReleaseEvent(QKeyEvent *event);
|
||||
void drawBackground(QPainter *painter, const QRectF &rect);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
bool event(QEvent *event);
|
||||
void scrollContentsBy(int dx, int dy);
|
||||
void leaveEvent(QEvent *event);
|
||||
|
||||
GraphicsScene *_scene;
|
||||
ScaleItem *_mapScale;
|
||||
@ -206,9 +201,6 @@ private:
|
||||
qreal _deviceRatio;
|
||||
qreal _mapRatio;
|
||||
bool _opengl;
|
||||
|
||||
int _pinchZoom;
|
||||
int _wheelDelta;
|
||||
};
|
||||
|
||||
#endif // MAPVIEW_H
|
||||
|
Loading…
Reference in New Issue
Block a user