Skip to content
Permalink
Browse files

Remove single select tool, merge into Select By Rectangle. Fix #10824

- New tool named Select Feature(s) does both actions one tool
- select(), selectByRectangle() return SelectFeatures action to maintain
  API
  • Loading branch information
NathanW2 committed Jul 7, 2014
1 parent 1088ba7 commit f4a51c43345846694b02058569d48df960e2a0d3
Showing with 41 additions and 63 deletions.
  1. +16 −32 src/app/qgisapp.cpp
  2. +4 −7 src/app/qgisapp.h
  3. +12 −5 src/app/qgsmaptoolselectrectangle.cpp
  4. +2 −2 src/app/qgsmaptoolselectrectangle.h
  5. +7 −17 src/ui/qgisapp.ui
@@ -916,11 +916,10 @@ QgisApp::~QgisApp()
delete mMapTools.mRotateFeature;
delete mMapTools.mRotateLabel;
delete mMapTools.mRotatePointSymbolsTool;
delete mMapTools.mSelect;
delete mMapTools.mSelectFreehand;
delete mMapTools.mSelectPolygon;
delete mMapTools.mSelectRadius;
delete mMapTools.mSelectRectangle;
delete mMapTools.mSelectFeatures;
delete mMapTools.mShowHideLabels;
delete mMapTools.mSimplifyFeature;
delete mMapTools.mSplitFeatures;
@@ -1108,8 +1107,7 @@ void QgisApp::createActions()
connect( mActionPanToSelected, SIGNAL( triggered() ), this, SLOT( panToSelected() ) );
connect( mActionZoomIn, SIGNAL( triggered() ), this, SLOT( zoomIn() ) );
connect( mActionZoomOut, SIGNAL( triggered() ), this, SLOT( zoomOut() ) );
connect( mActionSelect, SIGNAL( triggered() ), this, SLOT( select() ) );
connect( mActionSelectRectangle, SIGNAL( triggered() ), this, SLOT( selectByRectangle() ) );
connect( mActionSelectFeatures, SIGNAL( triggered() ), this, SLOT( selectFeatures() ) );
connect( mActionSelectPolygon, SIGNAL( triggered() ), this, SLOT( selectByPolygon() ) );
connect( mActionSelectFreehand, SIGNAL( triggered() ), this, SLOT( selectByFreehand() ) );
connect( mActionSelectRadius, SIGNAL( triggered() ), this, SLOT( selectByRadius() ) );
@@ -1340,8 +1338,7 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionZoomOut );
mMapToolGroup->addAction( mActionIdentify );
mMapToolGroup->addAction( mActionFeatureAction );
mMapToolGroup->addAction( mActionSelect );
mMapToolGroup->addAction( mActionSelectRectangle );
mMapToolGroup->addAction( mActionSelectFeatures );
mMapToolGroup->addAction( mActionSelectPolygon );
mMapToolGroup->addAction( mActionSelectFreehand );
mMapToolGroup->addAction( mActionSelectRadius );
@@ -1553,15 +1550,15 @@ void QgisApp::createToolBars()
QToolButton *bt = new QToolButton( mAttributesToolBar );
bt->setPopupMode( QToolButton::MenuButtonPopup );
QList<QAction*> selectActions;
selectActions << mActionSelect << mActionSelectRectangle << mActionSelectPolygon
selectActions << mActionSelectFeatures << mActionSelectPolygon
<< mActionSelectFreehand << mActionSelectRadius;
bt->addActions( selectActions );

QAction* defSelectAction = mActionSelect;
QAction* defSelectAction = mActionSelectFeatures;
switch ( settings.value( "/UI/selectTool", 0 ).toInt() )
{
case 0: defSelectAction = mActionSelect; break;
case 1: defSelectAction = mActionSelectRectangle; break;
case 0: defSelectAction = mActionSelectFeatures; break;
case 1: defSelectAction = mActionSelectFeatures; break;
case 2: defSelectAction = mActionSelectRadius; break;
case 3: defSelectAction = mActionSelectPolygon; break;
case 4: defSelectAction = mActionSelectFreehand; break;
@@ -1939,8 +1936,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionZoomActualSize->setIcon( QgsApplication::getThemeIcon( "/mActionZoomActual.svg" ) );
mActionIdentify->setIcon( QgsApplication::getThemeIcon( "/mActionIdentify.svg" ) );
mActionFeatureAction->setIcon( QgsApplication::getThemeIcon( "/mAction.svg" ) );
mActionSelect->setIcon( QgsApplication::getThemeIcon( "/mActionSelect.svg" ) );
mActionSelectRectangle->setIcon( QgsApplication::getThemeIcon( "/mActionSelectRectangle.svg" ) );
mActionSelectFeatures->setIcon( QgsApplication::getThemeIcon( "/mActionSelectRectangle.svg" ) );
mActionSelectPolygon->setIcon( QgsApplication::getThemeIcon( "/mActionSelectPolygon.svg" ) );
mActionSelectFreehand->setIcon( QgsApplication::getThemeIcon( "/mActionSelectFreehand.svg" ) );
mActionSelectRadius->setIcon( QgsApplication::getThemeIcon( "/mActionSelectRadius.svg" ) );
@@ -2148,10 +2144,8 @@ void QgisApp::createCanvasTools()
mMapTools.mSplitFeatures->setAction( mActionSplitFeatures );
mMapTools.mSplitParts = new QgsMapToolSplitParts( mMapCanvas );
mMapTools.mSplitParts->setAction( mActionSplitParts );
mMapTools.mSelect = new QgsMapToolSelect( mMapCanvas );
mMapTools.mSelect->setAction( mActionSelect );
mMapTools.mSelectRectangle = new QgsMapToolSelectRectangle( mMapCanvas );
mMapTools.mSelectRectangle->setAction( mActionSelectRectangle );
mMapTools.mSelectFeatures = new QgsMapToolSelectFeatures( mMapCanvas );
mMapTools.mSelectFeatures->setAction( mActionSelectFeatures );
mMapTools.mSelectPolygon = new QgsMapToolSelectPolygon( mMapCanvas );
mMapTools.mSelectPolygon->setAction( mActionSelectPolygon );
mMapTools.mSelectFreehand = new QgsMapToolSelectFreehand( mMapCanvas );
@@ -5703,14 +5697,9 @@ void QgisApp::addFeature()
mMapCanvas->setMapTool( mMapTools.mAddFeature );
}

void QgisApp::select()
void QgisApp::selectFeatures()
{
mMapCanvas->setMapTool( mMapTools.mSelect );
}

void QgisApp::selectByRectangle()
{
mMapCanvas->setMapTool( mMapTools.mSelectRectangle );
mMapCanvas->setMapTool( mMapTools.mSelectFeatures );
}

void QgisApp::selectByPolygon()
@@ -8800,8 +8789,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )

if ( !layer )
{
mActionSelect->setEnabled( false );
mActionSelectRectangle->setEnabled( false );
mActionSelectFeatures->setEnabled( false );
mActionSelectPolygon->setEnabled( false );
mActionSelectFreehand->setEnabled( false );
mActionSelectRadius->setEnabled( false );
@@ -8902,8 +8890,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionZoomActualSize->setEnabled( false );
mActionLabeling->setEnabled( true );

mActionSelect->setEnabled( true );
mActionSelectRectangle->setEnabled( true );
mActionSelectFeatures->setEnabled( true );
mActionSelectPolygon->setEnabled( true );
mActionSelectFreehand->setEnabled( true );
mActionSelectRadius->setEnabled( true );
@@ -9065,8 +9052,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )

mActionLayerSubsetString->setEnabled( false );
mActionFeatureAction->setEnabled( false );
mActionSelect->setEnabled( false );
mActionSelectRectangle->setEnabled( false );
mActionSelectFeatures->setEnabled( false );
mActionSelectPolygon->setEnabled( false );
mActionSelectFreehand->setEnabled( false );
mActionSelectRadius->setEnabled( false );
@@ -9939,9 +9925,7 @@ void QgisApp::toolButtonActionTriggered( QAction *action )
return;

QSettings settings;
if ( action == mActionSelect )
settings.setValue( "/UI/selectTool", 0 );
else if ( action == mActionSelectRectangle )
if ( action == mActionSelectFeatures )
settings.setValue( "/UI/selectTool", 1 );
else if ( action == mActionSelectRadius )
settings.setValue( "/UI/selectTool", 2 );
@@ -293,8 +293,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionPanToSelected() { return mActionPanToSelected; }
QAction *actionZoomIn() { return mActionZoomIn; }
QAction *actionZoomOut() { return mActionZoomOut; }
QAction *actionSelect() { return mActionSelect; }
QAction *actionSelectRectangle() { return mActionSelectRectangle; }
QAction *actionSelect() { return mActionSelectFeatures; }
QAction *actionSelectRectangle() { return mActionSelectFeatures; }
QAction *actionSelectPolygon() { return mActionSelectPolygon; }
QAction *actionSelectFreehand() { return mActionSelectFreehand; }
QAction *actionSelectRadius() { return mActionSelectRadius; }
@@ -996,11 +996,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! shows the snapping Options
void snappingOptions();

//! activates the selection tool
void select();

//! activates the rectangle selection tool
void selectByRectangle();
void selectFeatures();

//! activates the polygon selection tool
void selectByPolygon();
@@ -1433,7 +1430,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsMapTool* mSplitFeatures;
QgsMapTool* mSplitParts;
QgsMapTool* mSelect;
QgsMapTool* mSelectRectangle;
QgsMapTool* mSelectFeatures;
QgsMapTool* mSelectPolygon;
QgsMapTool* mSelectFreehand;
QgsMapTool* mSelectRadius;
@@ -29,7 +29,7 @@
#include <QRect>


QgsMapToolSelectRectangle::QgsMapToolSelectRectangle( QgsMapCanvas* canvas )
QgsMapToolSelectFeatures::QgsMapToolSelectFeatures( QgsMapCanvas* canvas )
: QgsMapTool( canvas ), mDragging( false )
{
QPixmap mySelectQPixmap = QPixmap(( const char ** ) select_cursor );
@@ -40,7 +40,7 @@ QgsMapToolSelectRectangle::QgsMapToolSelectRectangle( QgsMapCanvas* canvas )
}


void QgsMapToolSelectRectangle::canvasPressEvent( QMouseEvent *e )
void QgsMapToolSelectFeatures::canvasPressEvent( QMouseEvent *e )
{
Q_UNUSED( e );
mSelectRect.setRect( 0, 0, 0, 0 );
@@ -50,7 +50,7 @@ void QgsMapToolSelectRectangle::canvasPressEvent( QMouseEvent *e )
}


void QgsMapToolSelectRectangle::canvasMoveEvent( QMouseEvent *e )
void QgsMapToolSelectFeatures::canvasMoveEvent( QMouseEvent *e )
{
if ( e->buttons() != Qt::LeftButton )
return;
@@ -65,7 +65,7 @@ void QgsMapToolSelectRectangle::canvasMoveEvent( QMouseEvent *e )
}


void QgsMapToolSelectRectangle::canvasReleaseEvent( QMouseEvent *e )
void QgsMapToolSelectFeatures::canvasReleaseEvent( QMouseEvent *e )
{
QgsVectorLayer* vlayer = QgsMapToolSelectUtils::getCurrentVectorLayer( mCanvas );
if ( vlayer == NULL )
@@ -105,7 +105,14 @@ void QgsMapToolSelectRectangle::canvasReleaseEvent( QMouseEvent *e )
QgsMapToolSelectUtils::setRubberBand( mCanvas, mSelectRect, mRubberBand );

QgsGeometry* selectGeom = mRubberBand->asGeometry();
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, e );
if ( !mDragging )
{
bool doDifference = e->modifiers() & Qt::ControlModifier ? true : false;
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, false, doDifference, true );
}
else
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, e );

delete selectGeom;

mRubberBand->reset( QGis::Polygon );
@@ -28,11 +28,11 @@ class QgsGeometry;
class QgsRubberBand;


class APP_EXPORT QgsMapToolSelectRectangle : public QgsMapTool
class APP_EXPORT QgsMapToolSelectFeatures : public QgsMapTool
{
Q_OBJECT
public:
QgsMapToolSelectRectangle( QgsMapCanvas* canvas );
QgsMapToolSelectFeatures( QgsMapCanvas* canvas );

//! Overridden mouse move event
virtual void canvasMoveEvent( QMouseEvent * e );
@@ -17,7 +17,7 @@
<x>0</x>
<y>0</y>
<width>1050</width>
<height>25</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="mProjectMenu">
@@ -63,8 +63,7 @@
<property name="title">
<string>Select</string>
</property>
<addaction name="mActionSelect"/>
<addaction name="mActionSelectRectangle"/>
<addaction name="mActionSelectFeatures"/>
<addaction name="mActionSelectPolygon"/>
<addaction name="mActionSelectFreehand"/>
<addaction name="mActionSelectRadius"/>
@@ -874,19 +873,7 @@
<string>Ctrl+-</string>
</property>
</action>
<action name="mActionSelect">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionSelect.svg</normaloff>:/images/themes/default/mActionSelect.svg</iconset>
</property>
<property name="text">
<string>Select Single Feature</string>
</property>
</action>
<action name="mActionSelectRectangle">
<action name="mActionSelectFeatures">
<property name="checkable">
<bool>true</bool>
</property>
@@ -895,7 +882,10 @@
<normaloff>:/images/themes/default/mActionSelectRectangle.svg</normaloff>:/images/themes/default/mActionSelectRectangle.svg</iconset>
</property>
<property name="text">
<string>Select Features by Rectangle</string>
<string>Select Feature(s)</string>
</property>
<property name="toolTip">
<string>Select Features by area or single click</string>
</property>
</action>
<action name="mActionSelectPolygon">

0 comments on commit f4a51c4

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