Skip to content
Permalink
Browse files

[identify menu] display feature title next to layer title when single…

… feature is identified
  • Loading branch information
3nids committed Aug 24, 2015
1 parent 4611465 commit f82b8c6e025fd491e5514c9e29cb2987f302ed96
Showing with 18 additions and 3 deletions.
  1. +18 −3 src/gui/qgsidentifymenu.cpp
@@ -271,7 +271,10 @@ void QgsIdentifyMenu::addVectorLayer( QgsVectorLayer* layer, const QList<QgsMapT
if ( !createMenu )
{
// case 1
layerAction = new QAction( layer->name(), this );
QString featureTitle = results[0].mFeature.attribute( layer->displayField() ).toString();
if ( featureTitle.isEmpty() )
featureTitle = QString( "%1" ).arg( results[0].mFeature.id() );
layerAction = new QAction( QString( "%1 (%2)" ).arg( layer->name() ).arg( featureTitle ), this );
}
else
{
@@ -282,8 +285,20 @@ void QgsIdentifyMenu::addVectorLayer( QgsVectorLayer* layer, const QList<QgsMapT
}
else
{
// case 2
layerMenu = new QMenu( layer->name(), this );
// case 2a
if ( results.count() > 1 )
{
layerMenu = new QMenu( layer->name(), this );
layerAction = layerMenu->menuAction();
}
// case 2b
else
{
QString featureTitle = results[0].mFeature.attribute( layer->displayField() ).toString();
if ( featureTitle.isEmpty() )
featureTitle = QString( "%1" ).arg( results[0].mFeature.id() );
layerMenu = new QMenu( QString( "%1 (%2)" ).arg( layer->name() ).arg( featureTitle ), this );
}
layerAction = layerMenu->menuAction();
}
}

0 comments on commit f82b8c6

Please sign in to comment.
You can’t perform that action at this time.