Skip to content
Permalink
Browse files

[FEATURE] remove selections of all layers (fixes #2135)

git-svn-id: http://svn.osgeo.org/qgis/trunk@12224 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 22, 2009
1 parent a1a8aa2 commit ad61532237922c92965b37c596ff4bf3e42c2242
Binary file not shown.
@@ -791,6 +791,12 @@ void QgisApp::createActions()
connect( mActionSelect, SIGNAL( triggered() ), this, SLOT( select() ) );
mActionSelect->setEnabled( false );

mActionDeselectAll = new QAction( getThemeIcon( "mActionDeselectAll.png" ), tr( "Deselect features from all layers" ), this );
shortcuts->registerAction( mActionDeselectAll );
mActionDeselectAll->setStatusTip( tr( "Deselect features from all layers" ) );
connect( mActionDeselectAll, SIGNAL( triggered() ), this, SLOT( deselectAll() ) );
mActionDeselectAll->setEnabled( true );

mActionIdentify = new QAction( getThemeIcon( "mActionIdentify.png" ), tr( "Identify Features" ), this );
shortcuts->registerAction( mActionIdentify, tr( "Ctrl+Shift+I", "Click on features to identify them" ) );
mActionIdentify->setStatusTip( tr( "Click on features to identify them" ) );
@@ -1100,6 +1106,8 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionIdentify );
mActionSelect->setCheckable( true );
mMapToolGroup->addAction( mActionSelect );
mActionDeselectAll->setCheckable( false );
mMapToolGroup->addAction( mActionDeselectAll );
mActionMeasure->setCheckable( true );
mMapToolGroup->addAction( mActionMeasure );
mActionMeasureArea->setCheckable( true );
@@ -1262,6 +1270,7 @@ void QgisApp::createMenus()
mViewMenu->addAction( mActionZoomIn );
mViewMenu->addAction( mActionZoomOut );
mViewMenu->addAction( mActionSelect );
mViewMenu->addAction( mActionDeselectAll );
mViewMenu->addAction( mActionIdentify );
mViewMenu->addAction( mActionMeasure );
mViewMenu->addAction( mActionMeasureArea );
@@ -1479,6 +1488,7 @@ void QgisApp::createToolBars()
mAttributesToolBar->setObjectName( "Attributes" );
mAttributesToolBar->addAction( mActionIdentify );
mAttributesToolBar->addAction( mActionSelect );
mAttributesToolBar->addAction( mActionDeselectAll );
mAttributesToolBar->addAction( mActionOpenTable );
mAttributesToolBar->addAction( mActionMeasure );
mAttributesToolBar->addAction( mActionMeasureArea );
@@ -1722,6 +1732,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionZoomToLayer->setIcon( getThemeIcon( "/mActionZoomToLayer.png" ) );
mActionIdentify->setIcon( getThemeIcon( "/mActionIdentify.png" ) );
mActionSelect->setIcon( getThemeIcon( "/mActionSelect.png" ) );
mActionDeselectAll->setIcon( getThemeIcon( "/mActionDeselectAll.png" ) );
mActionOpenTable->setIcon( getThemeIcon( "/mActionOpenTable.png" ) );
mActionMeasure->setIcon( getThemeIcon( "/mActionMeasure.png" ) );
mActionMeasureArea->setIcon( getThemeIcon( "/mActionMeasureArea.png" ) );
@@ -4442,6 +4453,30 @@ void QgisApp::select()
mMapCanvas->setMapTool( mMapTools.mSelect );
}

void QgisApp::deselectAll()
{
if ( !mMapCanvas || mMapCanvas->isDrawing() )
{
return;
}

// Turn off rendering to improve speed.
bool renderFlagState = mMapCanvas->renderFlag();
mMapCanvas->setRenderFlag( false );

QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
for ( QMap<QString, QgsMapLayer*>::iterator it = layers.begin(); it!=layers.end(); it++ )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( it.value() );
if( !vl )
continue;

vl->removeSelection();
}

// Turn on rendering (if it was on previously)
mMapCanvas->setRenderFlag( renderFlagState );
}

void QgisApp::addVertex()
{
@@ -540,6 +540,10 @@ class QgisApp : public QMainWindow

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

//! deselect features from all layers
void deselectAll();

//! refresh map canvas
void refreshMapCanvas();
//! returns pointer to map legend
@@ -773,6 +777,7 @@ class QgisApp : public QMainWindow
QAction *mActionZoomIn;
QAction *mActionZoomOut;
QAction *mActionSelect;
QAction *mActionDeselectAll;
QAction *mActionIdentify;
QAction *mActionMeasure;
QAction *mActionMeasureArea;
@@ -1130,6 +1130,9 @@ void QgsVectorLayer::invertSelectionInRectangle( QgsRectangle & rect )

void QgsVectorLayer::removeSelection( bool emitSignal )
{
if( mSelectedFeatureIds.size() == 0 )
return;

mSelectedFeatureIds.clear();

if ( emitSignal )

0 comments on commit ad61532

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