41
41
#include < QStatusBar>
42
42
#include < QVariant>
43
43
44
- QgsMapToolIdentifyAction::QgsMapToolIdentifyAction ( QgsMapCanvas* canvas )
44
+ QgsMapToolIdentifyAction::QgsMapToolIdentifyAction ( QgsMapCanvas * canvas )
45
45
: QgsMapToolIdentify( canvas )
46
46
{
47
47
// set cursor
48
48
QPixmap myIdentifyQPixmap = QPixmap (( const char ** ) identify_cursor );
49
49
mCursor = QCursor ( myIdentifyQPixmap, 1 , 1 );
50
50
51
- connect ( this , SIGNAL ( changedRasterResults ( QList<RasterResult >& ) ), this , SLOT ( handleChangedRasterResults ( QList<RasterResult >& ) ) );
51
+ connect ( this , SIGNAL ( changedRasterResults ( QList<IdentifyResult >& ) ), this , SLOT ( handleChangedRasterResults ( QList<IdentifyResult >& ) ) );
52
52
}
53
53
54
54
QgsMapToolIdentifyAction::~QgsMapToolIdentifyAction ()
@@ -93,23 +93,18 @@ void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e )
93
93
94
94
connect ( this , SIGNAL ( identifyProgress ( int , int ) ), QgisApp::instance (), SLOT ( showProgress ( int , int ) ) );
95
95
connect ( this , SIGNAL ( identifyMessage ( QString ) ), QgisApp::instance (), SLOT ( showStatusMessage ( QString ) ) );
96
- bool res = QgsMapToolIdentify::identify ( e->x (), e->y () );
96
+ QList<IdentifyResult> results = QgsMapToolIdentify::identify ( e->x (), e->y () );
97
97
disconnect ( this , SIGNAL ( identifyProgress ( int , int ) ), QgisApp::instance (), SLOT ( showProgress ( int , int ) ) );
98
98
disconnect ( this , SIGNAL ( identifyMessage ( QString ) ), QgisApp::instance (), SLOT ( showStatusMessage ( QString ) ) );
99
99
100
100
101
- QList<VectorResult >::const_iterator vresult ;
102
- for ( vresult = results (). mVectorResults . begin (); vresult != results (). mVectorResults . end (); ++vresult )
101
+ QList<IdentifyResult >::const_iterator result ;
102
+ for ( result = results. begin (); result != results. end (); ++result )
103
103
{
104
- resultsDialog ()->addFeature ( vresult->mLayer , vresult->mFeature , vresult->mDerivedAttributes );
105
- }
106
- QList<RasterResult>::const_iterator rresult;
107
- for ( rresult = results ().mRasterResults .begin (); rresult != results ().mRasterResults .end (); ++rresult )
108
- {
109
- resultsDialog ()->addFeature ( rresult->mLayer , rresult->mLabel , rresult->mAttributes , rresult->mDerivedAttributes , rresult->mFields , rresult->mFeature );
104
+ resultsDialog ()->addFeature ( *result );
110
105
}
111
106
112
- if ( res )
107
+ if ( !results. isEmpty () )
113
108
{
114
109
resultsDialog ()->show ();
115
110
}
@@ -129,14 +124,17 @@ void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e )
129
124
}
130
125
}
131
126
132
- void QgsMapToolIdentifyAction::handleChangedRasterResults ( QList<RasterResult>& rasterResults )
127
+ void QgsMapToolIdentifyAction::handleChangedRasterResults ( QList<IdentifyResult> &results )
133
128
{
134
129
// Add new result after raster format change
135
- QgsDebugMsg ( QString ( " %1 raster results" ).arg ( rasterResults .size () ) );
136
- QList<RasterResult >::const_iterator rresult;
137
- for ( rresult = rasterResults .begin (); rresult != rasterResults .end (); ++rresult )
130
+ QgsDebugMsg ( QString ( " %1 raster results" ).arg ( results .size () ) );
131
+ QList<IdentifyResult >::const_iterator rresult;
132
+ for ( rresult = results .begin (); rresult != results .end (); ++rresult )
138
133
{
139
- resultsDialog ()->addFeature ( rresult->mLayer , rresult->mLabel , rresult->mAttributes , rresult->mDerivedAttributes , rresult->mFields , rresult->mFeature );
134
+ if ( rresult->mLayer ->type () == QgsMapLayer::RasterLayer )
135
+ {
136
+ resultsDialog ()->addFeature ( qobject_cast<QgsRasterLayer *>( rresult->mLayer ), rresult->mLabel , rresult->mAttributes , rresult->mDerivedAttributes , rresult->mFields , rresult->mFeature );
137
+ }
140
138
}
141
139
}
142
140
0 commit comments