Skip to content

Commit

Permalink
[identify menu] display feature title next to layer title when single…
Browse files Browse the repository at this point in the history
… feature is identified
  • Loading branch information
3nids committed Aug 24, 2015
1 parent 4611465 commit f82b8c6
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/gui/qgsidentifymenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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();
}
}
Expand Down

0 comments on commit f82b8c6

Please sign in to comment.