Skip to content

Commit

Permalink
Apply non-string parts of patch #2938
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14497 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Nov 3, 2010
1 parent ca8eebe commit 485ae19
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
9 changes: 4 additions & 5 deletions src/app/qgsmaptoolselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@


QgsMapToolSelect::QgsMapToolSelect( QgsMapCanvas* canvas )
: QgsMapTool( canvas )
: QgsMapTool( canvas )
{
mCursor = Qt::ArrowCursor;
}

void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e )
{
QgsVectorLayer* vlayer = QgsMapToolSelectUtils::getCurrentVectorLayer( mCanvas );
if ( vlayer == NULL )
if( vlayer == NULL )
{
return;
}
Expand All @@ -46,9 +46,8 @@ void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e )
QgsMapToolSelectUtils::expandSelectRectangle( selectRect, vlayer, e->pos() );
QgsMapToolSelectUtils::setRubberBand( mCanvas, selectRect, &rubberBand );
QgsGeometry* selectGeom = rubberBand.asGeometry();
bool addSelection = e->modifiers() & Qt::ControlModifier ? true : false;
bool substractSelection = e->modifiers() & Qt::ShiftModifier ? true : false;
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, false, addSelection, substractSelection, true );
bool doDifference = e->modifiers() & Qt::ControlModifier ? true : false;
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, false, doDifference, true );
delete selectGeom;
rubberBand.reset( true );
}
31 changes: 11 additions & 20 deletions src/app/qgsmaptoolselectutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ void QgsMapToolSelectUtils::expandSelectRectangle( QRect& selectRect,
void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
QgsGeometry* selectGeometry,
bool doContains,
bool addSelection,
bool substractSelection,
bool doDifference,
bool singleSelect )
{
if( selectGeometry->type() != QGis::Polygon )
Expand Down Expand Up @@ -124,8 +123,7 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
QgsDebugMsg( "Selection layer: " + vlayer->name() );
QgsDebugMsg( "Selection polygon: " + selectGeomTrans.exportToWkt() );
QgsDebugMsg( "doContains: " + QString( doContains ? "T" : "F" ) );
QgsDebugMsg( "addSelection: " + QString( addSelection ? "T" : "F" ) );
QgsDebugMsg( "substractSelection: " + QString( substractSelection ? "T" : "F" ) );
QgsDebugMsg( "doDifference: " + QString( doDifference ? "T" : "F" ) );

vlayer->select( QgsAttributeList(), selectGeomTrans.boundingBox(), true, true );

Expand Down Expand Up @@ -161,20 +159,10 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
newSelectedFeatures.insert( closestFeatureId );
}

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

QgsFeatureIds layerSelectedFeatures;
if( addSelection )
{
layerSelectedFeatures = vlayer->selectedFeaturesIds();
QgsFeatureIds::const_iterator i = newSelectedFeatures.constEnd();
while( i != newSelectedFeatures.constBegin() )
{
--i;
layerSelectedFeatures.insert( *i );
}
}
else if( substractSelection )
if( doDifference )
{
layerSelectedFeatures = vlayer->selectedFeaturesIds();
QgsFeatureIds::const_iterator i = newSelectedFeatures.constEnd();
Expand All @@ -185,6 +173,10 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
{
layerSelectedFeatures.remove( *i );
}
else
{
layerSelectedFeatures.insert( *i );
}
}
}
else
Expand All @@ -198,8 +190,7 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,

void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas, QgsGeometry* selectGeometry, QMouseEvent * e )
{
bool doContains = e->modifiers() & Qt::AltModifier ? true : false;
bool addSelection = e->modifiers() & Qt::ControlModifier ? true : false;
bool substractSelection = e->modifiers() & Qt::ShiftModifier ? true : false;
setSelectFeatures( canvas, selectGeometry, doContains, addSelection, substractSelection );
bool doContains = e->modifiers() & Qt::ShiftModifier ? true : false;
bool doDifference = e->modifiers() & Qt::ControlModifier ? true : false;
setSelectFeatures( canvas, selectGeometry, doContains, doDifference );
}
9 changes: 3 additions & 6 deletions src/app/qgsmaptoolselectutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@ namespace QgsMapToolSelectUtils
must be in terms of the canvas coordinate system.
@param doContains Features will only be selected if contained within the
selection rubber band.
@param addSelection New selected features will be added to the layer's
currently selected features.
@param substractSelection New selected features will be subtracted from
the layer's currently selected features.
@param doDifference Take the symmetric difference of the the current selected
features and the new features found within the provided selectGeometry.
@param singleSelect Only selects the closest feature to the selectGeometry.
*/
void setSelectFeatures( QgsMapCanvas* canvas,
QgsGeometry* selectGeometry,
bool doContains = true,
bool addSelection = false,
bool substractSelection = false,
bool doDifference = false,
bool singleSelect = false );

/**
Expand Down

0 comments on commit 485ae19

Please sign in to comment.