Skip to content

Commit

Permalink
Moved selection handler from gui lib to app
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 23, 2018
1 parent 4adb762 commit 8c7b632
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 157 deletions.
1 change: 0 additions & 1 deletion python/gui/gui_auto.sip
Expand Up @@ -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
Expand Down
104 changes: 0 additions & 104 deletions python/gui/qgsmaptoolselectionhandler.sip.in

This file was deleted.

2 changes: 2 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -97,6 +97,7 @@ SET(QGIS_APP_SRCS
qgsmaptoolrotatelabel.cpp
qgsmaptoolrotatepointsymbols.cpp
qgsmaptoolselect.cpp
qgsmaptoolselectionhandler.cpp
qgsmaptoolselectutils.cpp
qgsmaptoolsimplify.cpp
qgsmaptoolsplitfeatures.cpp
Expand Down Expand Up @@ -307,6 +308,7 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolrotatelabel.h
qgsmaptoolrotatepointsymbols.h
qgsmaptoolselect.h
qgsmaptoolselectionhandler.h
qgsmaptoolsimplify.h
qgsmaptoolsplitfeatures.h
qgsmaptoolsplitparts.h
Expand Down
7 changes: 0 additions & 7 deletions src/app/qgisapp.cpp
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/app/qgsmaptoolidentifyaction.cpp
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsmaptoolidentifyaction.h
Expand Up @@ -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 );
Expand Down
5 changes: 0 additions & 5 deletions src/app/qgsmaptoolselect.cpp
Expand Up @@ -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 );
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsmaptoolselect.h
Expand Up @@ -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;
Expand Down
Expand Up @@ -19,7 +19,7 @@
#include <QKeyEvent>
#include <QLabel>

#include "qgisinterface.h"
#include "qgisapp.h"
#include "qgsdoublespinbox.h"
#include "qgsmapcanvas.h"
#include "qgsmapmouseevent.h"
Expand Down Expand Up @@ -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 ) )
{
}

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

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

void QgsMapToolSelectionHandler::canvasReleaseEvent( QgsMapMouseEvent *e )
{
switch ( mSelectionMode )
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -438,7 +431,7 @@ void QgsMapToolSelectionHandler::updateRadiusFromEdge( QgsPointXY &radiusEdge )
}
}

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

QgsMapToolSelectionHandler::SelectionMode QgsMapToolSelectionHandler::selectionMode()
QgsMapToolSelectionHandler::SelectionMode QgsMapToolSelectionHandler::selectionMode() const
{
return mSelectionMode;
}
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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

Expand All @@ -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 );

Expand Down Expand Up @@ -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;

Expand All @@ -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
2 changes: 0 additions & 2 deletions src/gui/CMakeLists.txt
Expand Up @@ -302,7 +302,6 @@ SET(QGIS_GUI_SRCS
qgsmaptoolidentify.cpp
qgsmaptoolidentifyfeature.cpp
qgsmaptoolpan.cpp
qgsmaptoolselectionhandler.cpp
qgsmaptoolzoom.cpp
qgsmaplayerconfigwidget.cpp
qgsmenuheader.cpp
Expand Down Expand Up @@ -471,7 +470,6 @@ SET(QGIS_GUI_MOC_HDRS
qgsmaptoolidentify.h
qgsmaptoolidentifyfeature.h
qgsmaptoolpan.h
qgsmaptoolselectionhandler.h
qgsmaptoolzoom.h
qgsmaplayerconfigwidget.h
qgsmenuheader.h
Expand Down

0 comments on commit 8c7b632

Please sign in to comment.