Skip to content
Permalink
Browse files

Allow fall though of conditional rules

  • Loading branch information
NathanW2 committed Aug 21, 2015
1 parent 76f4f7c commit db563073d6b898683eef0d97f76d307c11111f3f
@@ -83,12 +83,12 @@ bool QgsConditionalStyle::matches( QVariant value, QgsFeature *feature )
QPixmap QgsConditionalStyle::renderPreview()
{
QPixmap pixmap( 64, 32 );
pixmap.fill( Qt::transparent );

QPainter painter( &pixmap );

if ( mBackColor.isValid() )
painter.setBrush( mBackColor );
else
painter.setBrush( QColor( Qt::white ) );

QRect rect = QRect( 0, 0, 64, 32 );
painter.setPen( Qt::NoPen );
@@ -18,6 +18,17 @@ QList<QgsConditionalStyle> QgsFieldUIProperties::getConditionalStyles()
return mStyles;
}

QList<QgsConditionalStyle> QgsFieldUIProperties::matchingConditionalStyles( QVariant value, QgsFeature *feature )
{
QList<QgsConditionalStyle> styles;
foreach ( QgsConditionalStyle style, mStyles )
{
if ( style.matches( value, feature ) )
styles.append( style );
}
return styles;
}

QgsConditionalStyle QgsFieldUIProperties::matchingConditionalStyle( QVariant value, QgsFeature *feature )
{
foreach ( QgsConditionalStyle style, mStyles )
@@ -32,6 +32,15 @@ class CORE_EXPORT QgsFieldUIProperties
*/
QList<QgsConditionalStyle> getConditionalStyles();

/**
* @brief Find and return the matching styles for the value and feature.
* If no match is found a invalid QgsCondtionalStyle is return.
*
* @return A condtional style that matches the value and feature.
* Check with QgsCondtionalStyle::isValid()
*/
QList<QgsConditionalStyle> matchingConditionalStyles( QVariant value, QgsFeature* feature );

/**
* @brief Find and return the matching style for the value and feature.
* If no match is found a invalid QgsCondtionalStyle is return.
@@ -584,7 +584,19 @@ QVariant QgsAttributeTableModel::data( const QModelIndex &index, int role ) cons
}

QgsFieldUIProperties props = layer()->fieldUIProperties( field.name() );
QgsConditionalStyle style = props.matchingConditionalStyle( val, &mFeat );
QList<QgsConditionalStyle> styles = props.matchingConditionalStyles( val, &mFeat );
QgsConditionalStyle style;
foreach ( QgsConditionalStyle s, styles )
{
style.setFont( s.font() );
if ( s.backgroundColor().isValid() && s.backgroundColor().alpha() != 0 )
style.setBackgroundColor( s.backgroundColor() );
if ( s.textColor().isValid() && s.textColor().alpha() != 0 )
style.setTextColor( s.textColor() );
if ( s.symbol() )
style.setSymbol( s.symbol() );
}

if ( style.isValid() )
{
if ( role == Qt::BackgroundColorRole && style.backgroundColor().isValid() )
@@ -22,6 +22,10 @@ QgsFieldConditionalFormatWidget::QgsFieldConditionalFormatWidget( QWidget *paren
connect( mDefaultButtons , SIGNAL( buttonPressed( QAbstractButton* ) ), SLOT( defaultPressed( QAbstractButton* ) ) );
connect( btnChangeIcon , SIGNAL( clicked() ), SLOT( updateIcon() ) );
connect( btnBuildExpression , SIGNAL( clicked() ), SLOT( setExpression() ) );
btnBackgroundColor->setAllowAlpha( true );
btnBackgroundColor->setShowNoColor( true );
btnTextColor->setAllowAlpha( true );
btnTextColor->setShowNoColor( true );
mModel = new QStandardItemModel();
listView->setModel( mModel );
}

0 comments on commit db56307

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