File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -271,7 +271,10 @@ void QgsIdentifyMenu::addVectorLayer( QgsVectorLayer* layer, const QList<QgsMapT
271
271
if ( !createMenu )
272
272
{
273
273
// case 1
274
- layerAction = new QAction ( layer->name (), this );
274
+ QString featureTitle = results[0 ].mFeature .attribute ( layer->displayField () ).toString ();
275
+ if ( featureTitle.isEmpty () )
276
+ featureTitle = QString ( " %1" ).arg ( results[0 ].mFeature .id () );
277
+ layerAction = new QAction ( QString ( " %1 (%2)" ).arg ( layer->name () ).arg ( featureTitle ), this );
275
278
}
276
279
else
277
280
{
@@ -282,8 +285,20 @@ void QgsIdentifyMenu::addVectorLayer( QgsVectorLayer* layer, const QList<QgsMapT
282
285
}
283
286
else
284
287
{
285
- // case 2
286
- layerMenu = new QMenu ( layer->name (), this );
288
+ // case 2a
289
+ if ( results.count () > 1 )
290
+ {
291
+ layerMenu = new QMenu ( layer->name (), this );
292
+ layerAction = layerMenu->menuAction ();
293
+ }
294
+ // case 2b
295
+ else
296
+ {
297
+ QString featureTitle = results[0 ].mFeature .attribute ( layer->displayField () ).toString ();
298
+ if ( featureTitle.isEmpty () )
299
+ featureTitle = QString ( " %1" ).arg ( results[0 ].mFeature .id () );
300
+ layerMenu = new QMenu ( QString ( " %1 (%2)" ).arg ( layer->name () ).arg ( featureTitle ), this );
301
+ }
287
302
layerAction = layerMenu->menuAction ();
288
303
}
289
304
}
You can’t perform that action at this time.
0 commit comments