From f5af506323d7dca44b836a098fc349c280a276b9 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 16 Aug 2022 11:08:17 +1000 Subject: [PATCH] Remove unnecessary touch device check --- src/gui/plot/qgsplotcanvas.cpp | 11 ++++------- src/gui/qgsmapcanvas.cpp | 27 +++++++++++---------------- src/gui/qgsmaptoolpan.cpp | 6 +----- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/gui/plot/qgsplotcanvas.cpp b/src/gui/plot/qgsplotcanvas.cpp index ee27a0bd8d7..f91bd1d1545 100644 --- a/src/gui/plot/qgsplotcanvas.cpp +++ b/src/gui/plot/qgsplotcanvas.cpp @@ -315,15 +315,12 @@ void QgsPlotCanvas::wheelZoom( QWheelEvent * ) bool QgsPlotCanvas::event( QEvent *e ) { - if ( !QTouchDevice::devices().empty() ) + if ( e->type() == QEvent::Gesture ) { - if ( e->type() == QEvent::Gesture ) + // call handler of current map tool + if ( mTool ) { - // call handler of current map tool - if ( mTool ) - { - return mTool->gestureEvent( static_cast( e ) ); - } + return mTool->gestureEvent( static_cast( e ) ); } } diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index b162ef54654..86c10332372 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -77,8 +77,6 @@ email : sherman at mrcc.com #include "qgsreferencedgeometry.h" #include "qgsprojectviewsettings.h" #include "qgsmaplayertemporalproperties.h" -#include "qgsrasterlayertemporalproperties.h" -#include "qgsvectorlayertemporalproperties.h" #include "qgstemporalcontroller.h" #include "qgsruntimeprofiler.h" #include "qgsprojectionselectiondialog.h" @@ -3317,23 +3315,20 @@ void QgsMapCanvas::mapToolDestroyed() bool QgsMapCanvas::event( QEvent *e ) { - if ( !QTouchDevice::devices().empty() ) + if ( e->type() == QEvent::Gesture ) { - if ( e->type() == QEvent::Gesture ) + if ( QTapAndHoldGesture *tapAndHoldGesture = qobject_cast< QTapAndHoldGesture * >( static_cast( e )->gesture( Qt::TapAndHoldGesture ) ) ) { - if ( QTapAndHoldGesture *tapAndHoldGesture = qobject_cast< QTapAndHoldGesture * >( static_cast( e )->gesture( Qt::TapAndHoldGesture ) ) ) - { - QPointF pos = tapAndHoldGesture->position(); - pos = mapFromGlobal( QPoint( pos.x(), pos.y() ) ); - QgsPointXY mapPoint = getCoordinateTransform()->toMapCoordinates( pos.x(), pos.y() ); - emit tapAndHoldGestureOccurred( mapPoint, tapAndHoldGesture ); - } + QPointF pos = tapAndHoldGesture->position(); + pos = mapFromGlobal( QPoint( pos.x(), pos.y() ) ); + QgsPointXY mapPoint = getCoordinateTransform()->toMapCoordinates( pos.x(), pos.y() ); + emit tapAndHoldGestureOccurred( mapPoint, tapAndHoldGesture ); + } - // call handler of current map tool - if ( mMapTool ) - { - return mMapTool->gestureEvent( static_cast( e ) ); - } + // call handler of current map tool + if ( mMapTool ) + { + return mMapTool->gestureEvent( static_cast( e ) ); } } diff --git a/src/gui/qgsmaptoolpan.cpp b/src/gui/qgsmaptoolpan.cpp index 9187cdc1c2a..803a66c7624 100644 --- a/src/gui/qgsmaptoolpan.cpp +++ b/src/gui/qgsmaptoolpan.cpp @@ -20,7 +20,6 @@ #include "qgsmaptopixel.h" #include "qgsmapmouseevent.h" #include "qgsproject.h" -#include "qgslogger.h" QgsMapToolPan::QgsMapToolPan( QgsMapCanvas *canvas ) @@ -116,7 +115,7 @@ void QgsMapToolPan::canvasReleaseEvent( QgsMapMouseEvent *e ) void QgsMapToolPan::canvasDoubleClickEvent( QgsMapMouseEvent *e ) { - if ( !QTouchDevice::devices().isEmpty() && !mPinching ) + if ( !mPinching ) { mCanvas->zoomWithCenter( e->x(), e->y(), true ); } @@ -124,9 +123,6 @@ void QgsMapToolPan::canvasDoubleClickEvent( QgsMapMouseEvent *e ) bool QgsMapToolPan::gestureEvent( QGestureEvent *event ) { - if ( QTouchDevice::devices().isEmpty() ) - return true; // no touch support - if ( QGesture *gesture = event->gesture( Qt::PinchGesture ) ) { mPinching = true;