The following commit has been merged in the master branch: commit db1c401dd90e0e7ef6c7dc4e76113427dcfa32f1 Author: Giuseppe Sucameli <brush.ty...@gmail.com> Date: Mon Mar 12 08:38:41 2012 +0100
"Run feature action" tool does the action for all the matching features (fix #5126) diff --git a/src/app/qgsmaptoolfeatureaction.cpp b/src/app/qgsmaptoolfeatureaction.cpp index 72e3232..7ab3873 100644 --- a/src/app/qgsmaptoolfeatureaction.cpp +++ b/src/app/qgsmaptoolfeatureaction.cpp @@ -72,6 +72,12 @@ void QgsMapToolFeatureAction::canvasReleaseEvent( QMouseEvent *e ) return; } + if ( !mCanvas->layers().contains( layer ) ) + { + // do not run actions on hidden layers + return; + } + QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer ); if ( vlayer->actions()->size() == 0 ) { @@ -110,7 +116,7 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer *layer, int x, int y ) if ( identifyValue <= 0.0 ) identifyValue = QGis::DEFAULT_IDENTIFY_RADIUS; - QgsFeature feat; + QgsFeatureList featList; // toLayerCoordinates will throw an exception for an 'invalid' point. // For example, if you project a world map onto a globe using EPSG 2163 @@ -130,10 +136,8 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer *layer, int x, int y ) layer->select( layer->pendingAllAttributesList(), r, true, true ); QgsFeature f; - if ( layer->nextFeature( f ) ) - feat = QgsFeature( f ); - else - return false; + while ( layer->nextFeature( f ) ) + featList << QgsFeature( f ); } catch ( QgsCsException & cse ) { @@ -142,15 +146,22 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer *layer, int x, int y ) QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) ); } - int action = layer->actions()->defaultAction(); + if ( featList.size() == 0 ) + return false; - // define custom substitutions: layer id and clicked coords - QMap<QString, QVariant> substitutionMap; - substitutionMap.insert( "$layerid", layer->id() ); - point = toLayerCoordinates( layer, point ); - substitutionMap.insert( "$clickx", point.x() ); - substitutionMap.insert( "$clicky", point.y() ); + foreach ( QgsFeature feat, featList ) + { + int actionIdx = layer->actions()->defaultAction(); + + // define custom substitutions: layer id and clicked coords + QMap<QString, QVariant> substitutionMap; + substitutionMap.insert( "$layerid", layer->id() ); + point = toLayerCoordinates( layer, point ); + substitutionMap.insert( "$clickx", point.x() ); + substitutionMap.insert( "$clicky", point.y() ); + + layer->actions()->doAction( actionIdx, feat, &substitutionMap ); + } - layer->actions()->doAction( action, feat, &substitutionMap ); return true; } -- The Quantum GIS in Debian project _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel