Skip to content

Commit

Permalink
Use tooltips in identify results dialog for values
Browse files Browse the repository at this point in the history
Makes it possible to see full value even when columns are too
narrow to display the value
  • Loading branch information
nyalldawson committed Sep 9, 2016
1 parent f52a9a0 commit 5e2a251
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -494,13 +494,15 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
featItem->addChild( attrItem );

attrItem->setData( 0, Qt::DisplayRole, vlayer->attributeDisplayName( i ) );
attrItem->setToolTip( 0, vlayer->attributeDisplayName( i ) );
attrItem->setData( 0, Qt::UserRole, fields.at( i ).name() );
attrItem->setData( 0, Qt::UserRole + 1, i );

attrItem->setData( 1, Qt::UserRole, value );

value = representValue( vlayer, setup, fields.at( i ).name(), attrs.at( i ) );
attrItem->setSortData( 1, value );
attrItem->setToolTip( 1, value );
bool foundLinks = false;
QString links = QgsStringUtils::insertLinks( value, &foundLinks );
if ( foundLinks )
Expand All @@ -519,7 +521,9 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
if ( fields.at( i ).name() == vlayer->displayField() )
{
featItem->setText( 0, attrItem->text( 0 ) );
featItem->setToolTip( 0, attrItem->text( 0 ) );
featItem->setText( 1, attrItem->text( 1 ) );
featItem->setToolTip( 1, attrItem->text( 1 ) );
featureLabeled = true;
}
}
Expand All @@ -533,7 +537,9 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
<< QgsExpressionContextUtils::layerScope( vlayer );
context.setFeature( f );

featItem->setText( 1, QgsExpression( vlayer->displayExpression() ).evaluate( &context ).toString() );
QString value = QgsExpression( vlayer->displayExpression() ).evaluate( &context ).toString();
featItem->setText( 1, value );
featItem->setToolTip( 1, value );
}

// table
Expand Down Expand Up @@ -1508,6 +1514,7 @@ void QgsIdentifyResultsDialog::attributeValueChanged( QgsFeatureId fid, int idx,

QgsTreeWidgetItem* treeItem = static_cast< QgsTreeWidgetItem* >( item );
treeItem->setSortData( 1, value );
treeItem->setToolTip( 1, value );

bool foundLinks = false;
QString links = QgsStringUtils::insertLinks( value, &foundLinks );
Expand Down

0 comments on commit 5e2a251

Please sign in to comment.