Skip to content

Commit

Permalink
Merge pull request #6777 from signedav/fix_conditionalformat
Browse files Browse the repository at this point in the history
Conditional formatting on relation reference widget
  • Loading branch information
m-kuhn authored Apr 12, 2018
2 parents c3fdef9 + 4d98479 commit 6cf1433
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 6cf1433

Please sign in to comment.