@@ -45,8 +45,6 @@ QgsMapToolIdentify::QgsMapToolIdentify( QgsMapCanvas* canvas )
4545 // set cursor
4646 QPixmap myIdentifyQPixmap = QPixmap (( const char ** ) identify_cursor );
4747 mCursor = QCursor ( myIdentifyQPixmap, 1 , 1 );
48-
49- mResults = new QgsIdentifyResults ( canvas, mCanvas ->window () );
5048}
5149
5250QgsMapToolIdentify::~QgsMapToolIdentify ()
@@ -57,6 +55,14 @@ QgsMapToolIdentify::~QgsMapToolIdentify()
5755 }
5856}
5957
58+ QgsIdentifyResults *QgsMapToolIdentify::results ()
59+ {
60+ if ( !mResults )
61+ mResults = new QgsIdentifyResults ( mCanvas , mCanvas ->window () );
62+
63+ return mResults ;
64+ }
65+
6066void QgsMapToolIdentify::canvasMoveEvent ( QMouseEvent * e )
6167{
6268}
@@ -72,11 +78,7 @@ void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent * e )
7278 return ;
7379 }
7480
75- if ( !mResults )
76- {
77- mResults = new QgsIdentifyResults ( mCanvas , mCanvas ->window () );
78- }
79- mResults ->clear ();
81+ results ()->clear ();
8082
8183 QSettings settings;
8284 int identifyMode = settings.value ( " /Map/identifyMode" , 0 ).toInt ();
@@ -139,38 +141,34 @@ void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent * e )
139141
140142 if ( res )
141143 {
142- mResults ->show ();
143- mResults ->raise ();
144+ results () ->show ();
145+ results () ->raise ();
144146 }
145147 else
146148 {
147149 QSettings mySettings;
148150 bool myDockFlag = mySettings.value ( " /qgis/dockIdentifyResults" , false ).toBool ();
149151 if ( !myDockFlag )
150152 {
151- mResults ->hide ();
153+ results () ->hide ();
152154 }
153155 else
154156 {
155- mResults ->clear ();
157+ results () ->clear ();
156158 }
157159 QMessageBox::information ( 0 , tr ( " Identify results" ), tr ( " No features at this position found." ) );
158160 }
159161}
160162
161163void QgsMapToolIdentify::activate ()
162164{
163- if ( !mResults )
164- {
165- mResults = new QgsIdentifyResults ( mCanvas , mCanvas ->window () );
166- }
167- mResults ->activate ();
165+ results ()->activate ();
168166 QgsMapTool::activate ();
169167}
170168
171169void QgsMapToolIdentify::deactivate ()
172170{
173- mResults ->deactivate ();
171+ results () ->deactivate ();
174172 QgsMapTool::deactivate ();
175173}
176174
@@ -327,7 +325,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
327325
328326 derivedAttributes.insert ( tr ( " feature id" ), fid < 0 ? tr ( " new feature" ) : QString::number ( fid ) );
329327
330- mResults ->addFeature ( layer, fid, displayField, displayValue, attributes, derivedAttributes );
328+ results () ->addFeature ( layer, fid, displayField, displayValue, attributes, derivedAttributes );
331329 }
332330
333331 QgsDebugMsg ( " Feature count on identify: " + QString::number ( featureCount ) );
@@ -388,18 +386,13 @@ bool QgsMapToolIdentify::identifyRasterLayer( QgsRasterLayer *layer, int x, int
388386 if ( res )
389387 {
390388 derivedAttributes.insert ( tr ( " (clicked coordinate)" ), idPoint.toString () );
391- mResults ->addFeature ( layer, -1 , type, " " , attributes, derivedAttributes );
389+ results () ->addFeature ( layer, -1 , type, " " , attributes, derivedAttributes );
392390 }
393391
394392 return res;
395393}
396394
397395
398- void QgsMapToolIdentify::resultsDialogGone ()
399- {
400- mResults = 0 ;
401- }
402-
403396void QgsMapToolIdentify::convertMeasurement ( QgsDistanceArea &calc, double &measure, QGis::UnitType &u, bool isArea )
404397{
405398 // Helper for converting between meters and feet
0 commit comments