@@ -791,6 +791,12 @@ void QgisApp::createActions()
791
791
connect ( mActionSelect , SIGNAL ( triggered () ), this , SLOT ( select () ) );
792
792
mActionSelect ->setEnabled ( false );
793
793
794
+ mActionDeselectAll = new QAction ( getThemeIcon ( " mActionDeselectAll.png" ), tr ( " Deselect features from all layers" ), this );
795
+ shortcuts->registerAction ( mActionDeselectAll );
796
+ mActionDeselectAll ->setStatusTip ( tr ( " Deselect features from all layers" ) );
797
+ connect ( mActionDeselectAll , SIGNAL ( triggered () ), this , SLOT ( deselectAll () ) );
798
+ mActionDeselectAll ->setEnabled ( true );
799
+
794
800
mActionIdentify = new QAction ( getThemeIcon ( " mActionIdentify.png" ), tr ( " Identify Features" ), this );
795
801
shortcuts->registerAction ( mActionIdentify , tr ( " Ctrl+Shift+I" , " Click on features to identify them" ) );
796
802
mActionIdentify ->setStatusTip ( tr ( " Click on features to identify them" ) );
@@ -1100,6 +1106,8 @@ void QgisApp::createActionGroups()
1100
1106
mMapToolGroup ->addAction ( mActionIdentify );
1101
1107
mActionSelect ->setCheckable ( true );
1102
1108
mMapToolGroup ->addAction ( mActionSelect );
1109
+ mActionDeselectAll ->setCheckable ( false );
1110
+ mMapToolGroup ->addAction ( mActionDeselectAll );
1103
1111
mActionMeasure ->setCheckable ( true );
1104
1112
mMapToolGroup ->addAction ( mActionMeasure );
1105
1113
mActionMeasureArea ->setCheckable ( true );
@@ -1262,6 +1270,7 @@ void QgisApp::createMenus()
1262
1270
mViewMenu ->addAction ( mActionZoomIn );
1263
1271
mViewMenu ->addAction ( mActionZoomOut );
1264
1272
mViewMenu ->addAction ( mActionSelect );
1273
+ mViewMenu ->addAction ( mActionDeselectAll );
1265
1274
mViewMenu ->addAction ( mActionIdentify );
1266
1275
mViewMenu ->addAction ( mActionMeasure );
1267
1276
mViewMenu ->addAction ( mActionMeasureArea );
@@ -1479,6 +1488,7 @@ void QgisApp::createToolBars()
1479
1488
mAttributesToolBar ->setObjectName ( " Attributes" );
1480
1489
mAttributesToolBar ->addAction ( mActionIdentify );
1481
1490
mAttributesToolBar ->addAction ( mActionSelect );
1491
+ mAttributesToolBar ->addAction ( mActionDeselectAll );
1482
1492
mAttributesToolBar ->addAction ( mActionOpenTable );
1483
1493
mAttributesToolBar ->addAction ( mActionMeasure );
1484
1494
mAttributesToolBar ->addAction ( mActionMeasureArea );
@@ -1722,6 +1732,7 @@ void QgisApp::setTheme( QString theThemeName )
1722
1732
mActionZoomToLayer ->setIcon ( getThemeIcon ( " /mActionZoomToLayer.png" ) );
1723
1733
mActionIdentify ->setIcon ( getThemeIcon ( " /mActionIdentify.png" ) );
1724
1734
mActionSelect ->setIcon ( getThemeIcon ( " /mActionSelect.png" ) );
1735
+ mActionDeselectAll ->setIcon ( getThemeIcon ( " /mActionDeselectAll.png" ) );
1725
1736
mActionOpenTable ->setIcon ( getThemeIcon ( " /mActionOpenTable.png" ) );
1726
1737
mActionMeasure ->setIcon ( getThemeIcon ( " /mActionMeasure.png" ) );
1727
1738
mActionMeasureArea ->setIcon ( getThemeIcon ( " /mActionMeasureArea.png" ) );
@@ -4442,6 +4453,30 @@ void QgisApp::select()
4442
4453
mMapCanvas ->setMapTool ( mMapTools .mSelect );
4443
4454
}
4444
4455
4456
+ void QgisApp::deselectAll ()
4457
+ {
4458
+ if ( !mMapCanvas || mMapCanvas ->isDrawing () )
4459
+ {
4460
+ return ;
4461
+ }
4462
+
4463
+ // Turn off rendering to improve speed.
4464
+ bool renderFlagState = mMapCanvas ->renderFlag ();
4465
+ mMapCanvas ->setRenderFlag ( false );
4466
+
4467
+ QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance ()->mapLayers ();
4468
+ for ( QMap<QString, QgsMapLayer*>::iterator it = layers.begin (); it!=layers.end (); it++ )
4469
+ {
4470
+ QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( it.value () );
4471
+ if ( !vl )
4472
+ continue ;
4473
+
4474
+ vl->removeSelection ();
4475
+ }
4476
+
4477
+ // Turn on rendering (if it was on previously)
4478
+ mMapCanvas ->setRenderFlag ( renderFlagState );
4479
+ }
4445
4480
4446
4481
void QgisApp::addVertex ()
4447
4482
{
0 commit comments