@@ -120,7 +120,7 @@ QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( int x, i
120
120
QMap< QgsMapLayer*, QList<IdentifyResult> >::const_iterator resultIt = mLayerIdResults .constBegin ();
121
121
for ( ; resultIt != mLayerIdResults .constEnd (); ++resultIt )
122
122
{
123
- QAction* action = new QAction ( resultIt.key ()->name (), 0 );
123
+ QAction* action = new QAction ( QString ( " %1 (%2) " ). arg ( resultIt.key ()->name () ). arg ( resultIt. value (). size () ), 0 );
124
124
action->setData ( resultIt.key ()->id () );
125
125
// add point/line/polygon icon
126
126
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( resultIt.key () );
@@ -145,20 +145,31 @@ QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( int x, i
145
145
{
146
146
action->setIcon ( QgsApplication::getThemeIcon ( " /mIconRaster.png" ) );
147
147
}
148
- QObject:: connect ( action, SIGNAL ( hovered () ), this , SLOT ( handleMenuHover () ) );
148
+ connect ( action, SIGNAL ( hovered () ), this , SLOT ( handleMenuHover () ) );
149
149
layerSelectionMenu.addAction ( action );
150
150
}
151
151
152
+ QAction *action = new QAction ( tr ( " All (%1)" ).arg ( idResult.size () ), 0 );
153
+ connect ( action, SIGNAL ( hovered () ), this , SLOT ( handleMenuHover () ) );
154
+ layerSelectionMenu.addAction ( action );
155
+
152
156
// exec layer selection menu
153
157
QPoint globalPos = mCanvas ->mapToGlobal ( QPoint ( x + 5 , y + 5 ) );
154
158
QAction* selectedAction = layerSelectionMenu.exec ( globalPos );
155
159
if ( selectedAction )
156
160
{
157
- QgsMapLayer* selectedLayer = QgsMapLayerRegistry::instance ()->mapLayer ( selectedAction->data ().toString () );
158
- QMap< QgsMapLayer*, QList<IdentifyResult> >::const_iterator sIt = mLayerIdResults .find ( selectedLayer );
159
- if ( sIt != mLayerIdResults .constEnd () )
161
+ if ( selectedAction->data ().toString ().isEmpty () )
160
162
{
161
- results = sIt .value ();
163
+ results = idResult;
164
+ }
165
+ else
166
+ {
167
+ QgsMapLayer* selectedLayer = QgsMapLayerRegistry::instance ()->mapLayer ( selectedAction->data ().toString () );
168
+ QMap< QgsMapLayer*, QList<IdentifyResult> >::const_iterator sIt = mLayerIdResults .find ( selectedLayer );
169
+ if ( sIt != mLayerIdResults .constEnd () )
170
+ {
171
+ results = sIt .value ();
172
+ }
162
173
}
163
174
}
164
175
@@ -658,6 +669,22 @@ void QgsMapToolIdentify::handleMenuHover()
658
669
}
659
670
}
660
671
}
672
+ else
673
+ {
674
+ for ( QMap< QgsMapLayer*, QList<IdentifyResult> >::const_iterator lIt = mLayerIdResults .constBegin (); lIt != mLayerIdResults .constEnd (); ++lIt )
675
+ {
676
+ const QList<IdentifyResult>& idList = lIt.value ();
677
+ QList<IdentifyResult>::const_iterator idListIt = idList.constBegin ();
678
+ for ( ; idListIt != idList.constEnd (); ++idListIt )
679
+ {
680
+ QgsHighlight *hl = new QgsHighlight ( mCanvas , idListIt->mFeature .geometry (), lIt.key () );
681
+ hl->setColor ( QColor ( 255 , 0 , 0 ) );
682
+ hl->setWidth ( 2 );
683
+ mRubberBands .append ( hl );
684
+ connect ( vl, SIGNAL ( destroyed () ), this , SLOT ( layerDestroyed () ) );
685
+ }
686
+ }
687
+ }
661
688
}
662
689
}
663
690
0 commit comments