Skip to content

Commit

Permalink
Conditional formatting on relation reference widget
Browse files Browse the repository at this point in the history
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 7fa9d41 commit 4d98479
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/core/qgsfeaturefiltermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 4d98479

Please sign in to comment.