Skip to content

Commit

Permalink
Merge pull request #38578 from elpaso/bugfix-gh38531-update-labels-on…
Browse files Browse the repository at this point in the history
…-dd-forms

Update DD labels on drag&drop forms
  • Loading branch information
elpaso committed Sep 4, 2020
2 parents 1fdf81c + b1757d3 commit 81cf4ee
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -86,6 +86,7 @@ QgsAttributeForm::QgsAttributeForm( QgsVectorLayer *vl, const QgsFeature &featur
connect( this, &QgsAttributeForm::modeChanged, this, &QgsAttributeForm::updateContainersVisibility );

updateContainersVisibility();
updateLabels();

}

Expand Down Expand Up @@ -2047,6 +2048,27 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
else
{
QLabel *mypLabel = new QLabel( widgetInfo.labelText );

// Alias DD overrides
if ( childDef->type() == QgsAttributeEditorElement::AeTypeField )
{
const QgsAttributeEditorField *fieldDef { static_cast<QgsAttributeEditorField *>( childDef ) };
const QgsFields fields = vl->fields();
const int fldIdx = fieldDef->idx();
if ( fldIdx < fields.count() && fldIdx >= 0 )
{
const QString fieldName { fields.at( fldIdx ).name() };
if ( mLayer->editFormConfig().dataDefinedFieldProperties( fieldName ).hasProperty( QgsEditFormConfig::DataDefinedProperty::Alias ) )
{
const QgsProperty property { mLayer->editFormConfig().dataDefinedFieldProperties( fieldName ).property( QgsEditFormConfig::DataDefinedProperty::Alias ) };
if ( property.isActive() && ! property.expressionString().isEmpty() )
{
mLabelDataDefinedProperties[ mypLabel ] = property;
}
}
}
}

mypLabel->setToolTip( widgetInfo.toolTip );
if ( columnCount > 1 && !widgetInfo.labelOnTop )
{
Expand Down

0 comments on commit 81cf4ee

Please sign in to comment.