QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Member Functions | Static Public Member Functions | List of all members
QgsConditionalStyle Class Reference

Conditional styling for a rule. More...

#include <qgsconditionalstyle.h>

Public Member Functions

 QgsConditionalStyle ()
 
 QgsConditionalStyle (const QgsConditionalStyle &other)
 
 QgsConditionalStyle (const QString &rule)
 
 ~QgsConditionalStyle ()
 
QColor backgroundColor () const
 The background color for style. More...
 
QString displayText () const
 The name of the style. More...
 
QFont font () const
 The font for the style. More...
 
QPixmap icon () const
 The icon set for style generated from the set symbol. More...
 
bool isValid () const
 isValid Check if this rule is valid. More...
 
bool matches (const QVariant &value, QgsExpressionContext &context) const
 Check if the rule matches using the given value and feature. More...
 
QString name () const
 The name of the style. More...
 
bool operator!= (const QgsConditionalStyle &other) const
 
QgsConditionalStyleoperator= (const QgsConditionalStyle &other)
 
bool operator== (const QgsConditionalStyle &other) const
 
bool readXml (const QDomNode &node, const QgsReadWriteContext &context)
 Reads vector conditional style specific state from layer Dom node. More...
 
QPixmap renderPreview (const QSize &size=QSize()) const
 Render a preview icon of the rule, at the specified size. More...
 
QString rule () const
 The condition rule set for the style. More...
 
void setBackgroundColor (const QColor &value)
 Set the background color for the style. More...
 
void setFont (const QFont &value)
 Set the font for the style. More...
 
void setName (const QString &value)
 Set the name of the style. More...
 
void setRule (const QString &value)
 Set the rule for the style. More...
 
void setSymbol (QgsSymbol *value)
 Set the icon for the style. More...
 
void setTextColor (const QColor &value)
 Set the text color for the style. More...
 
QgsSymbolsymbol () const
 The symbol used to generate the icon for the style. More...
 
QColor textColor () const
 The text color set for style. More...
 
bool validBackgroundColor () const
 Check if the background color is valid for render. More...
 
bool validTextColor () const
 Check if the text color is valid for render. More...
 
bool writeXml (QDomNode &node, QDomDocument &doc, const QgsReadWriteContext &context) const
 Write vector conditional style specific state from layer Dom node. More...
 

Static Public Member Functions

static QgsConditionalStyle compressStyles (const QList< QgsConditionalStyle > &styles)
 Compress a list of styles into a single style. More...
 
static QgsConditionalStyle matchingConditionalStyle (const QList< QgsConditionalStyle > &styles, const QVariant &value, QgsExpressionContext &context)
 Find and return the matching style for the value and feature. More...
 
static QList< QgsConditionalStylematchingConditionalStyles (const QList< QgsConditionalStyle > &styles, const QVariant &value, QgsExpressionContext &context)
 Find and return the matching styles for the value and feature. More...
 

Detailed Description

Conditional styling for a rule.

Definition at line 120 of file qgsconditionalstyle.h.

Constructor & Destructor Documentation

◆ QgsConditionalStyle() [1/3]

QgsConditionalStyle::QgsConditionalStyle ( )

Definition at line 139 of file qgsconditionalstyle.cpp.

◆ QgsConditionalStyle() [2/3]

QgsConditionalStyle::QgsConditionalStyle ( const QgsConditionalStyle other)

Definition at line 149 of file qgsconditionalstyle.cpp.

◆ QgsConditionalStyle() [3/3]

QgsConditionalStyle::QgsConditionalStyle ( const QString &  rule)

Definition at line 142 of file qgsconditionalstyle.cpp.

◆ ~QgsConditionalStyle()

QgsConditionalStyle::~QgsConditionalStyle ( )
default

Member Function Documentation

◆ backgroundColor()

QColor QgsConditionalStyle::backgroundColor ( ) const
inline

The background color for style.

Returns
QColor for background color

Definition at line 225 of file qgsconditionalstyle.h.

◆ compressStyles()

QgsConditionalStyle QgsConditionalStyle::compressStyles ( const QList< QgsConditionalStyle > &  styles)
static

Compress a list of styles into a single style.

This can be used to stack the elements of the styles. The font of the last style is used in the output.

Parameters
stylesThe list of styles to compress down
Returns
A single style generated from joining each style property.

Definition at line 276 of file qgsconditionalstyle.cpp.

◆ displayText()

QString QgsConditionalStyle::displayText ( ) const

The name of the style.

Returns
The name of the style. Names are optional so might be empty.

Definition at line 182 of file qgsconditionalstyle.cpp.

◆ font()

QFont QgsConditionalStyle::font ( ) const
inline

The font for the style.

Returns
QFont for the style

Definition at line 238 of file qgsconditionalstyle.h.

◆ icon()

QPixmap QgsConditionalStyle::icon ( ) const
inline

The icon set for style generated from the set symbol.

Returns
A QPixmap that was set for the icon using the symbol

Definition at line 200 of file qgsconditionalstyle.h.

◆ isValid()

bool QgsConditionalStyle::isValid ( ) const
inline

isValid Check if this rule is valid.

A valid rule has one or more properties set.

Returns
true if the rule is valid.

Definition at line 252 of file qgsconditionalstyle.h.

◆ matches()

bool QgsConditionalStyle::matches ( const QVariant &  value,
QgsExpressionContext context 
) const

Check if the rule matches using the given value and feature.

Parameters
valueThe current value being checked. The "value" variable from the context is replaced with this value.
contextExpression context for evaluating rule expression
Returns
true of the rule matches against the given feature

Definition at line 204 of file qgsconditionalstyle.cpp.

◆ matchingConditionalStyle()

QgsConditionalStyle QgsConditionalStyle::matchingConditionalStyle ( const QList< QgsConditionalStyle > &  styles,
const QVariant &  value,
QgsExpressionContext context 
)
static

Find and return the matching style for the value and feature.

If no match is found a invalid QgsConditionalStyle is return.

Returns
A conditional style that matches the value and feature. Check with QgsConditionalStyle::isValid()

Definition at line 265 of file qgsconditionalstyle.cpp.

◆ matchingConditionalStyles()

QList< QgsConditionalStyle > QgsConditionalStyle::matchingConditionalStyles ( const QList< QgsConditionalStyle > &  styles,
const QVariant &  value,
QgsExpressionContext context 
)
static

Find and return the matching styles for the value and feature.

If no match is found a invalid QgsConditionalStyle is return.

Returns
A conditional style that matches the value and feature. Check with QgsConditionalStyle::isValid()

Definition at line 253 of file qgsconditionalstyle.cpp.

◆ name()

QString QgsConditionalStyle::name ( ) const
inline

The name of the style.

Returns
The name of the style. Names are optional so might be empty.

Definition at line 194 of file qgsconditionalstyle.h.

◆ operator!=()

bool QgsConditionalStyle::operator!= ( const QgsConditionalStyle other) const

Definition at line 333 of file qgsconditionalstyle.cpp.

◆ operator=()

QgsConditionalStyle & QgsConditionalStyle::operator= ( const QgsConditionalStyle other)

Definition at line 162 of file qgsconditionalstyle.cpp.

◆ operator==()

bool QgsConditionalStyle::operator== ( const QgsConditionalStyle other) const

Definition at line 321 of file qgsconditionalstyle.cpp.

◆ readXml()

bool QgsConditionalStyle::readXml ( const QDomNode &  node,
const QgsReadWriteContext context 
)

Reads vector conditional style specific state from layer Dom node.

Definition at line 338 of file qgsconditionalstyle.cpp.

◆ renderPreview()

QPixmap QgsConditionalStyle::renderPreview ( const QSize &  size = QSize()) const

Render a preview icon of the rule, at the specified size.

If size is not specified, a default size will be used.

Returns
QPixmap preview of the style

Definition at line 211 of file qgsconditionalstyle.cpp.

◆ rule()

QString QgsConditionalStyle::rule ( ) const
inline

The condition rule set for the style.

Rule may contain variable @value to represent the current value

Returns
QString of the current set rule

Definition at line 245 of file qgsconditionalstyle.h.

◆ setBackgroundColor()

void QgsConditionalStyle::setBackgroundColor ( const QColor &  value)
inline

Set the background color for the style.

Parameters
valueQColor for background color

Definition at line 164 of file qgsconditionalstyle.h.

◆ setFont()

void QgsConditionalStyle::setFont ( const QFont &  value)
inline

Set the font for the style.

Parameters
valueQFont to be used for text

Definition at line 176 of file qgsconditionalstyle.h.

◆ setName()

void QgsConditionalStyle::setName ( const QString &  value)
inline

Set the name of the style.

Names are optional but handy for display

Parameters
valueThe name given to the style

Definition at line 151 of file qgsconditionalstyle.h.

◆ setRule()

void QgsConditionalStyle::setRule ( const QString &  value)
inline

Set the rule for the style.

Rules should be of QgsExpression syntax. Special value of @value is replaced at run time with the check value

Parameters
valueThe QgsExpression style rule to use for this style

Definition at line 158 of file qgsconditionalstyle.h.

◆ setSymbol()

void QgsConditionalStyle::setSymbol ( QgsSymbol value)

Set the icon for the style.

Icons are generated from symbols

Parameters
valueQgsSymbol to be used when generating the icon

Definition at line 190 of file qgsconditionalstyle.cpp.

◆ setTextColor()

void QgsConditionalStyle::setTextColor ( const QColor &  value)
inline

Set the text color for the style.

Parameters
valueQColor for text color

Definition at line 170 of file qgsconditionalstyle.h.

◆ symbol()

QgsSymbol * QgsConditionalStyle::symbol ( ) const
inline

The symbol used to generate the icon for the style.

Returns
The QgsSymbol used for the icon

Definition at line 206 of file qgsconditionalstyle.h.

◆ textColor()

QColor QgsConditionalStyle::textColor ( ) const
inline

The text color set for style.

Returns
QColor for text color

Definition at line 212 of file qgsconditionalstyle.h.

◆ validBackgroundColor()

bool QgsConditionalStyle::validBackgroundColor ( ) const

Check if the background color is valid for render.

Valid colors are non invalid QColors and a color with a > 0 alpha

Returns
true of the color set for background is valid.

Definition at line 243 of file qgsconditionalstyle.cpp.

◆ validTextColor()

bool QgsConditionalStyle::validTextColor ( ) const

Check if the text color is valid for render.

Valid colors are non invalid QColors and a color with a > 0 alpha

Returns
true of the color set for text is valid.

Definition at line 248 of file qgsconditionalstyle.cpp.

◆ writeXml()

bool QgsConditionalStyle::writeXml ( QDomNode &  node,
QDomDocument &  doc,
const QgsReadWriteContext context 
) const

Write vector conditional style specific state from layer Dom node.

Definition at line 295 of file qgsconditionalstyle.cpp.


The documentation for this class was generated from the following files: