Skip to content
Permalink
Browse files
Expose constraints in tooltips
  • Loading branch information
elpaso authored and nyalldawson committed Jul 15, 2021
1 parent 9f2965b commit c2f0a67b3d4b2fe6c5936dd804613d700dc20d68
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/core/browser/qgsfieldsitem.cpp
@@ -148,6 +148,20 @@ QgsFieldItem::QgsFieldItem( QgsDataItem *parent, const QgsField &field )
// Precondition
Q_ASSERT( static_cast<QgsFieldsItem *>( parent ) );
setState( Qgis::BrowserItemState::Populated );
const auto constraints { field.constraints().constraints() };
QStringList constraintsText;
if ( constraints.testFlag( QgsFieldConstraints::Constraint::ConstraintNotNull ) )
{
constraintsText.push_back( tr( "Not Null" ) );
}
if ( constraints.testFlag( QgsFieldConstraints::Constraint::ConstraintUnique ) )
{
constraintsText.push_back( tr( "Unique" ) );
}
if ( ! constraintsText.isEmpty() )
{
setToolTip( QStringLiteral( "<ul><li>%1</li></ul>" ).arg( constraintsText.join( QStringLiteral( "</li><li>" ) ) ) );
}
}

QgsFieldItem::~QgsFieldItem()

0 comments on commit c2f0a67

Please sign in to comment.