Skip to content

Commit b661903

Browse files
author
mhugent
committed
Reverse alt-key modification to be compatible with the old selection tool
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14476 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b043a5f commit b661903

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/app/qgsmaptoolselectutils.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ email : jpalmer at linz dot govt dot nz
3333
QgsVectorLayer* QgsMapToolSelectUtils::getCurrentVectorLayer( QgsMapCanvas* canvas )
3434
{
3535
QgsVectorLayer* vlayer = NULL;
36-
if ( !canvas->currentLayer()
37-
|| ( vlayer = qobject_cast<QgsVectorLayer *>( canvas->currentLayer() ) ) == NULL )
36+
if( !canvas->currentLayer()
37+
|| ( vlayer = qobject_cast<QgsVectorLayer *>( canvas->currentLayer() ) ) == NULL )
3838
{
3939
QMessageBox::warning( canvas, QObject::tr( "No active vector layer" ),
4040
QObject::tr( "To select features, you must choose a "
@@ -61,7 +61,7 @@ void QgsMapToolSelectUtils::expandSelectRectangle( QRect& selectRect,
6161
QPoint point )
6262
{
6363
int boxSize = 0;
64-
if ( vlayer->geometryType() != QGis::Polygon )
64+
if( vlayer->geometryType() != QGis::Polygon )
6565
{
6666
//if point or line use an artificial bounding box of 10x10 pixels
6767
//to aid the user to click on a feature accurately
@@ -85,12 +85,12 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
8585
bool substractSelection,
8686
bool singleSelect )
8787
{
88-
if ( selectGeometry->type() != QGis::Polygon )
88+
if( selectGeometry->type() != QGis::Polygon )
8989
{
9090
return;
9191
}
9292
QgsVectorLayer* vlayer = QgsMapToolSelectUtils::getCurrentVectorLayer( canvas );
93-
if ( vlayer == NULL )
93+
if( vlayer == NULL )
9494
{
9595
return;
9696
}
@@ -101,14 +101,14 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
101101
// and then click somewhere off the globe, an exception will be thrown.
102102
QgsGeometry selectGeomTrans( *selectGeometry );
103103

104-
if ( canvas->mapRenderer()->hasCrsTransformEnabled() )
104+
if( canvas->mapRenderer()->hasCrsTransformEnabled() )
105105
{
106106
try
107107
{
108108
QgsCoordinateTransform ct( canvas->mapRenderer()->destinationSrs(), vlayer->crs() );
109109
selectGeomTrans.transform( ct );
110110
}
111-
catch ( QgsCsException &cse )
111+
catch( QgsCsException &cse )
112112
{
113113
Q_UNUSED( cse );
114114
// catch exception for 'invalid' point and leave existing selection unchanged
@@ -134,18 +134,18 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
134134
int closestFeatureId = 0;
135135
bool foundSingleFeature = false;
136136
double closestFeatureDist = std::numeric_limits<double>::max();
137-
while ( vlayer->nextFeature( f ) )
137+
while( vlayer->nextFeature( f ) )
138138
{
139139
QgsGeometry* g = f.geometry();
140-
if ( doContains && !selectGeomTrans.contains( g ) )
140+
if( doContains && !selectGeomTrans.contains( g ) )
141141
{
142142
continue;
143143
}
144-
if ( singleSelect )
144+
if( singleSelect )
145145
{
146146
foundSingleFeature = true;
147147
double distance = g->distance( selectGeomTrans );
148-
if ( distance <= closestFeatureDist )
148+
if( distance <= closestFeatureDist )
149149
{
150150
closestFeatureDist = distance;
151151
closestFeatureId = f.id();
@@ -156,32 +156,32 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
156156
newSelectedFeatures.insert( f.id() );
157157
}
158158
}
159-
if ( singleSelect && foundSingleFeature )
159+
if( singleSelect && foundSingleFeature )
160160
{
161161
newSelectedFeatures.insert( closestFeatureId );
162162
}
163163

164164
QgsDebugMsg( "Number of selected features: " + QString::number( newSelectedFeatures.size() ) );
165165

166166
QgsFeatureIds layerSelectedFeatures;
167-
if ( addSelection )
167+
if( addSelection )
168168
{
169169
layerSelectedFeatures = vlayer->selectedFeaturesIds();
170170
QgsFeatureIds::const_iterator i = newSelectedFeatures.constEnd();
171-
while ( i != newSelectedFeatures.constBegin() )
171+
while( i != newSelectedFeatures.constBegin() )
172172
{
173173
--i;
174174
layerSelectedFeatures.insert( *i );
175175
}
176176
}
177-
else if ( substractSelection )
177+
else if( substractSelection )
178178
{
179179
layerSelectedFeatures = vlayer->selectedFeaturesIds();
180180
QgsFeatureIds::const_iterator i = newSelectedFeatures.constEnd();
181-
while ( i != newSelectedFeatures.constBegin() )
181+
while( i != newSelectedFeatures.constBegin() )
182182
{
183183
--i;
184-
if ( layerSelectedFeatures.contains( *i ) )
184+
if( layerSelectedFeatures.contains( *i ) )
185185
{
186186
layerSelectedFeatures.remove( *i );
187187
}
@@ -198,7 +198,7 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
198198

199199
void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas, QgsGeometry* selectGeometry, QMouseEvent * e )
200200
{
201-
bool doContains = e->modifiers() & Qt::AltModifier ? false : true;
201+
bool doContains = e->modifiers() & Qt::AltModifier ? true : false;
202202
bool addSelection = e->modifiers() & Qt::ControlModifier ? true : false;
203203
bool substractSelection = e->modifiers() & Qt::ShiftModifier ? true : false;
204204
setSelectFeatures( canvas, selectGeometry, doContains, addSelection, substractSelection );

0 commit comments

Comments
 (0)