Skip to content
Permalink
Browse files

Conditional formatting on relation reference widget

in case we have additional display expressions there does use the conditional formatting for the row
and in case there is only one fieldname used in the display expression it does use this as well

Fix: #18521
  • Loading branch information
signedav committed Apr 10, 2018
1 parent d3e18e3 commit 55e83809d37561f4fdc2c2e8f18249658ab71b72
Showing with 5 additions and 10 deletions.
  1. +5 −10 src/core/qgsfeaturefiltermodel.cpp
@@ -448,28 +448,23 @@ QgsConditionalStyle QgsFeatureFilterModel::featureStyle( const QgsFeature &featu
QgsVectorLayer *layer = mSourceLayer;
QgsFeatureId fid = feature.id();
mExpressionContext.setFeature( feature );
QgsConditionalStyle style;

if ( mEntryStylesMap.contains( fid ) )
{
style = mEntryStylesMap.value( fid );
}

auto styles = QgsConditionalStyle::matchingConditionalStyles( layer->conditionalStyles()->rowStyles(), QVariant(), mExpressionContext );

if ( mDisplayExpression.isField() )
if ( mDisplayExpression.referencedColumns().count() == 1 )
{
// Style specific for this field
QString fieldName = *mDisplayExpression.referencedColumns().constBegin();
const auto allStyles = layer->conditionalStyles()->fieldStyles( fieldName );
const auto matchingFieldStyles = QgsConditionalStyle::matchingConditionalStyles( allStyles, feature.attribute( fieldName ), mExpressionContext );

styles += matchingFieldStyles;

style = QgsConditionalStyle::compressStyles( styles );
mEntryStylesMap.insert( fid, style );
}

QgsConditionalStyle style;
style = QgsConditionalStyle::compressStyles( styles );
mEntryStylesMap.insert( fid, style );

return style;
}

0 comments on commit 55e8380

Please sign in to comment.
You can’t perform that action at this time.