QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgslayoutviewtooltemporarymousepan.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutviewtooltemporarymousepan.cpp
3  --------------------------------------
4  Date : July 2017
5  Copyright : (C) 2017 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 
18 #include "qgslayoutview.h"
19 #include <QScrollBar>
20 
22  : QgsLayoutViewTool( view, tr( "Pan" ) )
23 {
24  setCursor( Qt::ClosedHandCursor );
25 }
26 
28 {
29  view()->horizontalScrollBar()->setValue( view()->horizontalScrollBar()->value() - ( event->x() - mLastMousePos.x() ) );
30  view()->verticalScrollBar()->setValue( view()->verticalScrollBar()->value() - ( event->y() - mLastMousePos.y() ) );
31  mLastMousePos = event->pos();
32  view()->viewChanged();
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 }
QgsLayoutViewToolTemporaryMousePan::QgsLayoutViewToolTemporaryMousePan
QgsLayoutViewToolTemporaryMousePan(QgsLayoutView *view)
Constructor for QgsLayoutViewToolTemporaryMousePan.
Definition: qgslayoutviewtooltemporarymousepan.cpp:21
qgslayoutview.h
qgslayoutviewtooltemporarymousepan.h
qgslayoutviewmouseevent.h
QgsLayoutViewTool::view
QgsLayoutView * view() const
Returns the view associated with the tool.
Definition: qgslayoutviewtool.cpp:38
QgsLayoutView::setTool
void setTool(QgsLayoutViewTool *tool)
Sets the tool currently being used in the view.
Definition: qgslayoutview.cpp:134
QgsLayoutView::tool
QgsLayoutViewTool tool
Definition: qgslayoutview.h:64
QgsLayoutView::viewChanged
void viewChanged()
Updates associated rulers and other widgets after view extent or zoom has changed.
Definition: qgslayoutview.cpp:1198
QgsLayoutViewTool
Abstract base class for all layout view tools. Layout view tools are user interactive tools for manip...
Definition: qgslayoutviewtool.h:46
QgsLayoutView
A graphical widget to display and interact with QgsLayouts.
Definition: qgslayoutview.h:49
QgsLayoutViewToolTemporaryMousePan::activate
void activate() override
Called when tool is set as the currently active layout tool.
Definition: qgslayoutviewtooltemporarymousepan.cpp:43
QgsLayoutViewToolTemporaryMousePan::layoutReleaseEvent
void layoutReleaseEvent(QgsLayoutViewMouseEvent *event) override
Mouse release event for overriding.
Definition: qgslayoutviewtooltemporarymousepan.cpp:35
QgsLayoutViewTool::setCursor
void setCursor(const QCursor &cursor)
Sets a user defined cursor for use when the tool is active.
Definition: qgslayoutviewtool.cpp:115
QgsLayoutViewTool::activate
virtual void activate()
Called when tool is set as the currently active layout tool.
Definition: qgslayoutviewtool.cpp:120
QgsLayoutViewMouseEvent
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView.
Definition: qgslayoutviewmouseevent.h:35
QgsLayoutViewToolTemporaryMousePan::layoutMoveEvent
void layoutMoveEvent(QgsLayoutViewMouseEvent *event) override
Mouse move event for overriding.
Definition: qgslayoutviewtooltemporarymousepan.cpp:27