36   connect( fieldRadio, &QAbstractButton::clicked, 
this, &QgsFieldConditionalFormatWidget::reloadStyles );
    37   connect( rowRadio, &QAbstractButton::clicked, 
this, &QgsFieldConditionalFormatWidget::reloadStyles );
    38   connect( mNewButton, &QAbstractButton::clicked, 
this, &QgsFieldConditionalFormatWidget::addNewRule );
    39   connect( listView, &QAbstractItemView::clicked, 
this, &QgsFieldConditionalFormatWidget::ruleClicked );
    40   mModel = 
new QStandardItemModel( listView );
    41   listView->setModel( mModel );
    43   connect( fieldRadio, &QRadioButton::toggled, mFieldCombo, &QWidget::setEnabled );
    51   mFieldCombo->setLayer( layer );
    52   mFieldCombo->setCurrentIndex( 0 );
    53   fieldChanged( mFieldCombo->currentField() );
    56 void QgsFieldConditionalFormatWidget::ruleClicked( 
const QModelIndex &index )
    58   QList<QgsConditionalStyle> styles = getStyles();
    65   mEditIndex = editIndex;
    66   mEditing = editIndex >= 0;
    67   mPanelHandled = 
false;
    75   if ( fieldRadio->isChecked() && style.
rule().isEmpty() )
    77     ruleWidget->
setRule( QStringLiteral( 
"@value " ) );
    89     QList<QgsConditionalStyle> styles = getStyles();
    92       styles.replace( mEditIndex, ruleWidget->
currentStyle() );
   100     if ( fieldRadio->isChecked() )
   102       fieldName = mFieldCombo->currentField();
   105     if ( rowRadio->isChecked() )
   120     mPanelHandled = 
true;
   127     mPanelHandled = 
true;
   137 QList<QgsConditionalStyle> QgsFieldConditionalFormatWidget::getStyles()
   139   QList<QgsConditionalStyle> styles;
   140   if ( fieldRadio->isChecked() )
   144   if ( rowRadio->isChecked() )
   151 void QgsFieldConditionalFormatWidget::addNewRule()
   167   QList<QgsConditionalStyle> styles;
   170   styles.append( style );
   173   styles.append( style );
   176   styles.append( style );
   179   styles.append( style );
   182   styles.append( style );
   185   styles.append( style );
   189 void QgsFieldConditionalFormatWidget::reloadStyles()
   193   const auto constGetStyles = getStyles();
   195 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)   201   listView->setIconSize( size );
   205     QStandardItem *item = 
new QStandardItem( style.displayText() );
   206     item->setIcon( QIcon( style.renderPreview( size ) ) );
   207     mModel->appendRow( item );
   211 void QgsFieldConditionalFormatWidget::fieldChanged( 
const QString &fieldName )
   213   Q_UNUSED( fieldName )
   217 void QgsFieldConditionalFormatWidget::deleteCurrentRule()
   222   QList<QgsConditionalStyle> styles = getStyles();
   223   styles.removeAt( mEditIndex );
   225   if ( fieldRadio->isChecked() )
   227     fieldName = mFieldCombo->currentField();
   230   if ( rowRadio->isChecked() )
   255   btnBackgroundColor->setColor( QColor() );
   256   btnTextColor->setColor( QColor() );
   257   checkIcon->setChecked( 
false );
   258   btnChangeIcon->setIcon( QIcon() );
   259   btnBackgroundColor->setToNoColor();
   260   btnTextColor->setToNoColor();
   262   mFontBoldBtn->setChecked( 
false );
   263   mFontItalicBtn->setChecked( 
false );
   264   mFontStrikethroughBtn->setChecked( 
false );
   265   mFontUnderlineBtn->setChecked( 
false );
   268   mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
   269   mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
   270   mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
   271   mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
   272   mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
   273   mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
   274   mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
   275   mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
   281   connect( btnBuildExpression, &QAbstractButton::clicked, 
this, &QgsEditConditionalFormatRuleWidget::setExpression );
   282   connect( mPresetsList, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsEditConditionalFormatRuleWidget::presetSet );
   284   btnBackgroundColor->setAllowOpacity( 
true );
   285   btnBackgroundColor->setShowNoColor( 
true );
   286   btnTextColor->setAllowOpacity( 
true );
   287   btnTextColor->setShowNoColor( 
true );
   288   mPresetsModel = 
new QStandardItemModel( mPresetsList );
   289   mPresetsList->setModel( mPresetsModel );
   293   connect( checkIcon, &QCheckBox::toggled, btnChangeIcon, &QWidget::setEnabled );
   303   mRuleEdit->setText( style.
rule() );
   304   mNameEdit->setText( style.
name() );
   305   setFormattingFromStyle( style );
   312   style.
setRule( mRuleEdit->text() );
   313   style.
setName( mNameEdit->text() );
   315   QColor backColor = btnBackgroundColor->color();
   316   QColor fontColor = btnTextColor->color();
   318   QFont font = mFontFamilyCmbBx->currentFont();
   319   font.setBold( mFontBoldBtn->isChecked() );
   320   font.setItalic( mFontItalicBtn->isChecked() );
   321   font.setStrikeOut( mFontStrikethroughBtn->isChecked() );
   322   font.setUnderline( mFontUnderlineBtn->isChecked() );
   326   if ( checkIcon->isChecked() )
   337 void QgsEditConditionalFormatRuleWidget::setExpression()
   344   dlg.setWindowTitle( tr( 
"Conditional Style Rule Expression" ) );
   349     mRuleEdit->setText( expression );
   353 void QgsEditConditionalFormatRuleWidget::presetSet( 
int index )
   355   if ( index == -1 || mPresets.isEmpty() )
   358   const int styleIndex = mPresetsList->currentData( Qt::UserRole + 1 ).toInt();
   360   setFormattingFromStyle( style );
   363 void QgsEditConditionalFormatRuleWidget::setFormattingFromStyle( 
const QgsConditionalStyle &style )
   366   btnTextColor->setColor( style.
textColor() );
   369     btnChangeIcon->setSymbol( style.
symbol()->
clone() );
   370     checkIcon->setChecked( 
true );
   374     checkIcon->setChecked( 
false );
   376   QFont font = style.
font();
   377   mFontBoldBtn->setChecked( font.bold() );
   378   mFontItalicBtn->setChecked( font.italic() );
   379   mFontStrikethroughBtn->setChecked( font.strikeOut() );
   380   mFontUnderlineBtn->setChecked( font.underline() );
   381   mFontFamilyCmbBx->setCurrentFont( font );
   387   mPresetsModel->clear();
   388   QStandardItem *item = 
new QStandardItem( QString() );
   389   mPresetsModel->appendRow( item );
   395       QStandardItem *item = 
new QStandardItem( QStringLiteral( 
"abc - 123" ) );
   399         item->setForeground( style.
textColor() );
   401         item->setIcon( style.
icon() );
   402       item->setFont( style.
font() );
   403       item->setData( i, Qt::UserRole + 1 );
   404       mPresetsModel->appendRow( item );
   405       mPresets.append( style );
   409   mPresetsList->setCurrentIndex( 0 );
   414   mRuleEdit->setText( rule );
   417 bool QgsEditConditionalFormatRuleWidget::isCustomSet()
   419   return ( btnBackgroundColor->color().isValid()
   420            || btnTextColor->color().isValid()
   421            || mFontButtons->checkedId() != -1 );
 QString name() const
The name of the style. 
 
void setName(const QString &value)
Set the name of the style. 
 
Single variable definition for use within a QgsExpressionContextScope. 
 
static const double UI_SCALE_FACTOR
UI scaling factor. 
 
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
 
void setRule(const QString &value)
Set the rule for the style. 
 
QgsExpressionBuilderWidget * expressionBuilder()
The builder widget that is used by the dialog. 
 
bool validBackgroundColor() const
Check if the background color is valid for render. 
 
QPixmap icon() const
The icon set for style generated from the set symbol. 
 
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope. 
 
A marker symbol type, for rendering Point and MultiPoint geometries. 
 
QgsConditionalLayerStyles * conditionalStyles() const
Returns the conditional styles that are set for this layer. 
 
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context. 
 
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type. 
 
Conditional styling for a rule. 
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
bool isValid() const
isValid Check if this rule is valid. 
 
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes. 
 
QColor backgroundColor() const
The background color for style. 
 
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer. 
 
void setBackgroundColor(const QColor &value)
Set the background color for the style. 
 
QList< QgsConditionalStyle > fieldStyles(const QString &fieldName) const
Returns the conditional styles set for the field with matching fieldName. 
 
void setFont(const QFont &value)
Set the font for the style. 
 
QColor textColor() const
The text color set for style. 
 
void setSymbol(QgsSymbol *value)
Set the icon for the style. 
 
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol. 
 
bool validTextColor() const
Check if the text color is valid for render. 
 
QgsSymbol * symbol() const
The symbol used to generate the icon for the style. 
 
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user...
 
QFont font() const
The font for the style. 
 
void setRowStyles(const QgsConditionalStyles &styles)
Sets the conditional styles that apply to full rows of data in the attribute table. 
 
void setFieldStyles(const QString &fieldName, const QList< QgsConditionalStyle > &styles)
Set the conditional styles for a field, with the specified fieldName. 
 
Represents a vector layer which manages a vector based data sets. 
 
QString rule() const
The condition rule set for the style. 
 
A generic dialog for building expression strings. 
 
QgsConditionalStyles rowStyles() const
Returns a list of row styles associated with the layer. 
 
void setTextColor(const QColor &value)
Set the text color for the style.