Skip to content
Permalink
Browse files

Moved selection handler from gui lib to app

  • Loading branch information
wonder-sk committed Apr 23, 2018
1 parent 4adb762 commit 8c7b63257071b0326a44277a448ab16f5fd34f11
@@ -144,7 +144,6 @@
%Include qgsmaptoolidentify.sip
%Include qgsmaptoolidentifyfeature.sip
%Include qgsmaptoolpan.sip
%Include qgsmaptoolselectionhandler.sip
%Include qgsmaptoolzoom.sip
%Include qgsmaplayerconfigwidget.sip
%Include qgsmenuheader.sip

This file was deleted.

@@ -97,6 +97,7 @@ SET(QGIS_APP_SRCS
qgsmaptoolrotatelabel.cpp
qgsmaptoolrotatepointsymbols.cpp
qgsmaptoolselect.cpp
qgsmaptoolselectionhandler.cpp
qgsmaptoolselectutils.cpp
qgsmaptoolsimplify.cpp
qgsmaptoolsplitfeatures.cpp
@@ -307,6 +308,7 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolrotatelabel.h
qgsmaptoolrotatepointsymbols.h
qgsmaptoolselect.h
qgsmaptoolselectionhandler.h
qgsmaptoolsimplify.h
qgsmaptoolsplitfeatures.h
qgsmaptoolsplitparts.h
@@ -1311,13 +1311,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
// should come after fileNewBlank to ensure project is properly set up to receive any data source files
QgsApplication::setFileOpenEventReceiver( this );

// finish initialization of map tools that need access to QGIS interface
mMapTools.mSelectFeatures->setInterface( mQgisInterface );
mMapTools.mSelectPolygon->setInterface( mQgisInterface );
mMapTools.mSelectFreehand->setInterface( mQgisInterface );
mMapTools.mSelectRadius->setInterface( mQgisInterface );
mMapTools.mIdentify->setInterface( mQgisInterface );

#ifdef ANDROID
toggleFullScreen();
#endif
@@ -204,11 +204,6 @@ void QgsMapToolIdentifyAction::deactivate()
QgsMapToolIdentify::deactivate();
}

void QgsMapToolIdentifyAction::setInterface( QgisInterface *iface )
{
mSelectionHandler->setInterface( iface );
}

QgsUnitTypes::DistanceUnit QgsMapToolIdentifyAction::displayDistanceUnits() const
{
return QgsProject::instance()->distanceUnits();
@@ -61,8 +61,6 @@ class APP_EXPORT QgsMapToolIdentifyAction : public QgsMapToolIdentify

void deactivate() override;

void setInterface( QgisInterface *iface );

public slots:
void handleCopyToClipboard( QgsFeatureStore & );
void handleChangedRasterResults( QList<QgsMapToolIdentify::IdentifyResult> &results );
@@ -38,11 +38,6 @@ QgsMapToolSelect::QgsMapToolSelect( QgsMapCanvas *canvas )
setSelectionMode( QgsMapToolSelectionHandler::SelectSimple );
}

void QgsMapToolSelect::setInterface( QgisInterface *iface )
{
mSelectionHandler->setInterface( iface );
}

void QgsMapToolSelect::setSelectionMode( QgsMapToolSelectionHandler::SelectionMode selectionMode )
{
mSelectionHandler->setSelectionMode( selectionMode );
@@ -31,8 +31,6 @@ class APP_EXPORT QgsMapToolSelect : public QgsMapTool

void setSelectionMode( QgsMapToolSelectionHandler::SelectionMode selectionMode );

void setInterface( QgisInterface *iface );

void canvasPressEvent( QgsMapMouseEvent *e ) override;
void canvasMoveEvent( QgsMapMouseEvent *e ) override;
void canvasReleaseEvent( QgsMapMouseEvent *e ) override;
@@ -19,7 +19,7 @@
#include <QKeyEvent>
#include <QLabel>

#include "qgisinterface.h"
#include "qgisapp.h"
#include "qgsdoublespinbox.h"
#include "qgsmapcanvas.h"
#include "qgsmapmouseevent.h"
@@ -102,8 +102,6 @@ QgsMapToolSelectionHandler::QgsMapToolSelectionHandler( QgsMapCanvas *canvas, Qg
, mCanvas( canvas )
, mSelectionMode( selectionMode )
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator >( canvas ) )
, mFillColor( QColor( 254, 178, 76, 63 ) )
, mStrokeColor( QColor( 254, 58, 29, 100 ) )
{
}

@@ -112,11 +110,6 @@ QgsMapToolSelectionHandler::~QgsMapToolSelectionHandler()
cancel();
}

void QgsMapToolSelectionHandler::setInterface( QgisInterface *iface )
{
mQgisInterface = iface;
}

void QgsMapToolSelectionHandler::canvasReleaseEvent( QgsMapMouseEvent *e )
{
switch ( mSelectionMode )
@@ -362,15 +355,15 @@ void QgsMapToolSelectionHandler::initRubberBand()

void QgsMapToolSelectionHandler::createDistanceWidget()
{
if ( !mCanvas || !mQgisInterface )
if ( !mCanvas )
{
return;
}

deleteDistanceWidget();

mDistanceWidget = new QgsDistanceWidget( tr( "Selection radius:" ) );
mQgisInterface->addUserInputWidget( mDistanceWidget );
QgisApp::instance()->addUserInputWidget( mDistanceWidget );
mDistanceWidget->setFocus( Qt::TabFocusReason );

connect( mDistanceWidget, &QgsDistanceWidget::distanceChanged, this, &QgsMapToolSelectionHandler::updateRadiusRubberband );
@@ -438,7 +431,7 @@ void QgsMapToolSelectionHandler::updateRadiusFromEdge( QgsPointXY &radiusEdge )
}
}

QgsGeometry QgsMapToolSelectionHandler::selectedGeometry()
QgsGeometry QgsMapToolSelectionHandler::selectedGeometry() const
{
return mSelectionGeometry;
}
@@ -454,7 +447,7 @@ void QgsMapToolSelectionHandler::setSelectionMode( SelectionMode mode )
mSelectionMode = mode;
}

QgsMapToolSelectionHandler::SelectionMode QgsMapToolSelectionHandler::selectionMode()
QgsMapToolSelectionHandler::SelectionMode QgsMapToolSelectionHandler::selectionMode() const
{
return mSelectionMode;
}
@@ -19,21 +19,17 @@
#include <QObject>
#include <QWidget>

#include "qgis_gui.h"
#include "qgsgeometry.h"

class QHBoxLayout;
class QKeyEvent;

class QgisInterface;
class QgsDoubleSpinBox;
class QgsMapCanvas;
class QgsMapMouseEvent;
class QgsRubberBand;
class QgsSnapIndicator;

#ifndef SIP_RUN

/// @cond private

/**
@@ -75,15 +71,13 @@ class QgsDistanceWidget : public QWidget

/// @endcond

#endif


/**
* \ingroup gui
* \brief Utility class for handling various methods to create geometry for selection in layers.
* \since QGIS 3.2
*/
class GUI_EXPORT QgsMapToolSelectionHandler : public QObject
class QgsMapToolSelectionHandler : public QObject
{
Q_OBJECT

@@ -110,14 +104,11 @@ class GUI_EXPORT QgsMapToolSelectionHandler : public QObject
//! destructor
~QgsMapToolSelectionHandler() override;

//! Configures QGIS interface - used to register selection radius widget
void setInterface( QgisInterface *iface );

//! Returns most recently selected geometry (may be a point or a polygon)
QgsGeometry selectedGeometry();
QgsGeometry selectedGeometry() const;

//! Sets the current selection mode
SelectionMode selectionMode();
SelectionMode selectionMode() const;
//! Returns the current selection mode
void setSelectionMode( SelectionMode mode );

@@ -180,9 +171,6 @@ class GUI_EXPORT QgsMapToolSelectionHandler : public QObject

QgsMapCanvas *mCanvas = nullptr;

//! QGIS interface - used to register selection radius widget
QgisInterface *mQgisInterface = nullptr;

//! the rubberband for selection visualization
std::unique_ptr<QgsRubberBand> mSelectionRubberBand;

@@ -206,8 +194,8 @@ class GUI_EXPORT QgsMapToolSelectionHandler : public QObject
//! Shows current angle value and allows numerical editing
QgsDistanceWidget *mDistanceWidget = nullptr;

QColor mFillColor;
QColor mStrokeColor;
QColor mFillColor = QColor( 254, 178, 76, 63 );
QColor mStrokeColor = QColor( 254, 58, 29, 100 );
};

#endif
@@ -302,7 +302,6 @@ SET(QGIS_GUI_SRCS
qgsmaptoolidentify.cpp
qgsmaptoolidentifyfeature.cpp
qgsmaptoolpan.cpp
qgsmaptoolselectionhandler.cpp
qgsmaptoolzoom.cpp
qgsmaplayerconfigwidget.cpp
qgsmenuheader.cpp
@@ -471,7 +470,6 @@ SET(QGIS_GUI_MOC_HDRS
qgsmaptoolidentify.h
qgsmaptoolidentifyfeature.h
qgsmaptoolpan.h
qgsmaptoolselectionhandler.h
qgsmaptoolzoom.h
qgsmaplayerconfigwidget.h
qgsmenuheader.h

0 comments on commit 8c7b632

Please sign in to comment.
You can’t perform that action at this time.