Skip to content
Permalink
Browse files

Apply non-string parts of patch #2938

git-svn-id: http://svn.osgeo.org/qgis/trunk@14497 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Nov 3, 2010
1 parent ca8eebe commit 485ae1921f78b21471c43f92baa6f5f719ead63f
Showing with 18 additions and 31 deletions.
  1. +4 −5 src/app/qgsmaptoolselect.cpp
  2. +11 −20 src/app/qgsmaptoolselectutils.cpp
  3. +3 −6 src/app/qgsmaptoolselectutils.h
@@ -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;
}
@@ -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 );
}
@@ -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 )
@@ -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 );

@@ -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();
@@ -185,6 +173,10 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
{
layerSelectedFeatures.remove( *i );
}
else
{
layerSelectedFeatures.insert( *i );
}
}
}
else
@@ -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 );
}
@@ -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 );

/**

0 comments on commit 485ae19

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