QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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
17#include "moc_qgslayoutviewtooltemporarymousepan.cpp"
19#include "qgslayoutview.h"
20#include <QScrollBar>
21
23 : QgsLayoutViewTool( 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 view()->viewChanged();
34}
35
37{
38 if ( event->button() == Qt::MiddleButton )
39 {
40 view()->setTool( mPreviousViewTool );
41 }
42}
43
45{
46 mLastMousePos = view()->mapFromGlobal( QCursor::pos() );
47 mPreviousViewTool = view()->tool();
49}
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView.
void layoutReleaseEvent(QgsLayoutViewMouseEvent *event) override
Mouse release event for overriding.
void layoutMoveEvent(QgsLayoutViewMouseEvent *event) override
Mouse move event for overriding.
void activate() override
Called when tool is set as the currently active layout tool.
QgsLayoutViewToolTemporaryMousePan(QgsLayoutView *view)
Constructor for QgsLayoutViewToolTemporaryMousePan.
Abstract base class for all layout view tools.
void setCursor(const QCursor &cursor)
Sets a user defined cursor for use when the tool is active.
QgsLayoutView * view() const
Returns the view associated with the tool.
virtual void activate()
Called when tool is set as the currently active layout tool.
A graphical widget to display and interact with QgsLayouts.
void viewChanged()
Updates associated rulers and other widgets after view extent or zoom has changed.
void setTool(QgsLayoutViewTool *tool)
Sets the tool currently being used in the view.
QgsLayoutViewTool * tool