[FEATURE]: center map if user clicks into the map (patch 2278 provided by smizuno)

git-svn-id: http://svn.osgeo.org/qgis/trunk@13342 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2010-04-21 19:21:44 +00:00
parent e01984c1eb
commit cb490ae028

View File

@ -17,6 +17,7 @@
#include "qgsmaptoolpan.h"
#include "qgsmapcanvas.h"
#include "qgscursors.h"
#include "qgsmaptopixel.h"
#include <QBitmap>
#include <QCursor>
#include <QMouseEvent>
@ -34,28 +35,29 @@ QgsMapToolPan::QgsMapToolPan( QgsMapCanvas* canvas )
void QgsMapToolPan::canvasMoveEvent( QMouseEvent * e )
{
if ( mDragging && ( e->buttons() & Qt::LeftButton ) )
if (( e->buttons() & Qt::LeftButton ) )
{
mDragging = true;
// move map and other canvas items
mCanvas->panAction( e );
}
}
void QgsMapToolPan::canvasPressEvent( QMouseEvent * e )
void QgsMapToolPan::canvasReleaseEvent( QMouseEvent * e )
{
if ( e->button() == Qt::LeftButton )
{
mDragging = TRUE;
}
}
void QgsMapToolPan::canvasReleaseEvent( QMouseEvent * e )
{
if ( mDragging && e->button() == Qt::LeftButton )
{
mCanvas->panActionEnd( e->pos() );
mDragging = FALSE;
if ( mDragging )
{
mCanvas->panActionEnd( e->pos() );
mDragging = FALSE;
}
else // add pan to mouse cursor
{
// transform the mouse pos to map coordinates
QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( e->x(), e->y() );
mCanvas->setExtent( QgsRectangle( center, center ) );
mCanvas->refresh();
}
}
}