Skip to content

Commit 15e9e0a

Browse files
committed
[UX] Show feature id in attribute table tooltip
1 parent 4411267 commit 15e9e0a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/gui/attributetable/qgsattributetablemodel.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,10 @@ QVariant QgsAttributeTableModel::headerData( int section, Qt::Orientation orient
517517
}
518518
else if ( section >= 0 && section < mFieldCount )
519519
{
520-
QString attributeName = layer()->attributeAlias( mAttributes[section] );
520+
QString attributeName = layer()->attributeAlias( mAttributes.at( section ) );
521521
if ( attributeName.isEmpty() )
522522
{
523-
QgsField field = layer()->fields().at( mAttributes[section] );
523+
QgsField field = layer()->fields().at( mAttributes.at( section ) );
524524
attributeName = field.name();
525525
}
526526
return QVariant( attributeName );
@@ -530,6 +530,19 @@ QVariant QgsAttributeTableModel::headerData( int section, Qt::Orientation orient
530530
return tr( "extra column" );
531531
}
532532
}
533+
else if ( role == Qt::ToolTipRole )
534+
{
535+
if ( orientation == Qt::Vertical )
536+
{
537+
// TODO show DisplayExpression
538+
return tr( "Feature ID: %1" ).arg( rowToId( section ) );
539+
}
540+
else
541+
{
542+
QgsField field = layer()->fields().at( mAttributes.at( section ) );
543+
return field.name();
544+
}
545+
}
533546
else
534547
{
535548
return QVariant();

0 commit comments

Comments
 (0)