Skip to content

Commit fbd10b5

Browse files
author
alexbruy
committed
fix eVis Event Browser and ID tool
git-svn-id: http://svn.osgeo.org/qgis/trunk@15740 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 3c0f834 commit fbd10b5

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ bool eVisGenericEventBrowserGui::initBrowser( )
258258
*/
259259
if ( 0 == mVectorLayer->selectedFeatureCount( ) ) //if nothing is selected select everything
260260
{
261-
QgsRectangle myRect;
262-
mVectorLayer->select( myRect, true );
261+
mVectorLayer->invertSelection();
263262
mFeatureIds = mVectorLayer->selectedFeaturesIds( ).toList( );
264263
}
265264
else //use selected features

src/plugins/evis/idtool/eviseventidtool.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ eVisEventIdTool::eVisEventIdTool( QgsMapCanvas* theCanvas )
6060
*/
6161
void eVisEventIdTool::canvasReleaseEvent( QMouseEvent* theMouseEvent )
6262
{
63-
6463
if ( 0 == mCanvas || 0 == theMouseEvent ) { return; }
6564

6665
//Check to see if there is a layer selected
@@ -90,26 +89,35 @@ void eVisEventIdTool::select( QgsPoint thePoint )
9089
{
9190

9291
if ( 0 == mCanvas ) { return; }
93-
92+
9493
QgsVectorLayer* myLayer = ( QgsVectorLayer* )mCanvas->currentLayer( );
95-
94+
9695
// create the search rectangle. this was modeled after the QgsMapIdentifyTool in core QGIS application
9796
double searchWidth = mCanvas->extent( ).width( ) * (( double )QGis::DEFAULT_IDENTIFY_RADIUS / 100.0 );
98-
97+
9998
QgsRectangle myRectangle;
10099
myRectangle.setXMinimum( thePoint.x( ) - searchWidth );
101100
myRectangle.setXMaximum( thePoint.x( ) + searchWidth );
102101
myRectangle.setYMinimum( thePoint.y( ) - searchWidth );
103102
myRectangle.setYMaximum( thePoint.y( ) + searchWidth );
104-
103+
105104
//Transform rectange to map coordinates
106105
myRectangle = toLayerCoordinates( myLayer, myRectangle );
107106

108107
//Rather than add to the current selection, clear all selected features
109108
myLayer->removeSelection( false );
110109
//select features
111-
myLayer->select( myRectangle, false );
110+
myLayer->select( QgsAttributeList(), myRectangle, true, true );
111+
112+
QgsFeature f;
113+
QgsFeatureIds newSelectedFeatures;
114+
while ( myLayer->nextFeature( f ) )
115+
{
116+
newSelectedFeatures.insert( f.id() );
117+
}
112118

119+
myLayer->setSelectedFeatures( newSelectedFeatures );
120+
113121
//Launch a new event browser to view selected features
114122
mBrowser = new eVisGenericEventBrowserGui( mCanvas, mCanvas, NULL );
115123
mBrowser->setAttribute( Qt::WA_DeleteOnClose );

0 commit comments

Comments
 (0)