QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsmodelviewtooltemporarymousepan.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelviewtooltemporarymousepan.cpp
3 --------------------------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17#include "moc_qgsmodelviewtooltemporarymousepan.cpp"
20#include <QScrollBar>
21
23 : QgsModelViewTool( view, tr( "Pan" ) )
24{
25 setCursor( Qt::ClosedHandCursor );
26}
27
29{
30 view()->horizontalScrollBar()->setValue( view()->horizontalScrollBar()->value() - ( event->x() - mLastMousePos.x() ) );
31 view()->verticalScrollBar()->setValue( view()->verticalScrollBar()->value() - ( event->y() - mLastMousePos.y() ) );
32 mLastMousePos = event->pos();
33}
34
36{
37 if ( event->button() == Qt::MiddleButton )
38 {
39 view()->setTool( mPreviousViewTool );
40 }
41}
42
44{
45 mLastMousePos = view()->mapFromGlobal( QCursor::pos() );
46 mPreviousViewTool = view()->tool();
48}
A QgsModelViewMouseEvent is the result of a user interaction with the mouse on a QgsModelGraphicsView...
QgsModelViewToolTemporaryMousePan(QgsModelGraphicsView *view)
Constructor for QgsModelViewToolTemporaryMousePan.
void activate() override
Called when tool is set as the currently active model tool.
void modelReleaseEvent(QgsModelViewMouseEvent *event) override
Mouse release event for overriding.
void modelMoveEvent(QgsModelViewMouseEvent *event) override
Mouse move event for overriding.
Abstract base class for all model designer view tools.
QgsModelGraphicsView * view() const
Returns the view associated with the tool.
void setCursor(const QCursor &cursor)
Sets a user defined cursor for use when the tool is active.
virtual void activate()
Called when tool is set as the currently active model tool.