15#ifndef QGSCONDITIONALSTYLE_H
16#define QGSCONDITIONALSTYLE_H
24#include <QDomDocument>
32using namespace Qt::StringLiterals;
89 void setFieldStyles(
const QString &fieldName,
const QList<QgsConditionalStyle> &styles );
96 QList<QgsConditionalStyle>
fieldStyles(
const QString &fieldName )
const;
128 QHash<QString, QgsConditionalStyles> mFieldStyles;
170 void setName(
const QString &value ) { mName = value; mValid =
true; }
177 void setRule(
const QString &value ) { mRule = value; mValid =
true; }
189 void setTextColor(
const QColor &value ) { mTextColor = value; mValid =
true; }
195 void setFont(
const QFont &value ) { mFont = value; mValid =
true; }
207 QString displayText()
const;
213 QString
name()
const {
return mName; }
219 QPixmap
icon()
const {
return mIcon; }
238 bool validTextColor()
const;
251 bool validBackgroundColor()
const;
257 QFont
font()
const {
return mFont; }
264 QString
rule()
const {
return mRule; }
280 static QList<QgsConditionalStyle> matchingConditionalStyles(
const QList<QgsConditionalStyle> &styles,
const QVariant &value,
QgsExpressionContext &context );
307 bool writeXml( QDomNode &node, QDomDocument &doc,
const QgsReadWriteContext &context )
const;
313 SIP_PYOBJECT __repr__();
316 if ( !sipCpp->name().isEmpty() )
317 str = u
"<QgsConditionalStyle: '%1' (%2)>"_s.arg( sipCpp->name(), sipCpp->rule() );
319 str = u
"<QgsConditionalStyle: %2>"_s.arg( sipCpp->rule() );
320 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
329 std::unique_ptr<QgsSymbol> mSymbol;
void changed()
Emitted when the conditional styles are changed.
bool readXml(const QDomNode &node, const QgsReadWriteContext &context)
Reads the condition styles state from a DOM node.
QgsConditionalStyles rowStyles() const
Returns a list of row styles associated with the layer.
QgsConditionalLayerStyles(QObject *parent=nullptr)
Constructor for QgsConditionalLayerStyles, with the specified parent object.
QgsConditionalStyle constraintFailureStyles(QgsFieldConstraints::ConstraintStrength strength)
Returns a style associated to a constraint failure.
bool writeXml(QDomNode &node, QDomDocument &doc, const QgsReadWriteContext &context) const
Writes the condition styles state to a DOM node.
QList< QgsConditionalStyle > fieldStyles(const QString &fieldName) const
Returns the conditional styles set for the field with matching fieldName.
bool rulesNeedGeometry() const
Returns true if at least one rule needs geometry.
void setFieldStyles(const QString &fieldName, const QList< QgsConditionalStyle > &styles)
Set the conditional styles for a field, with the specified fieldName.
void setRowStyles(const QgsConditionalStyles &styles)
Sets the conditional styles that apply to full rows of data in the attribute table.
Conditional styling for a rule.
QString name() const
The name of the style.
void setName(const QString &value)
Set the name of the style.
QPixmap renderPreview(const QSize &size=QSize()) const
Render a preview icon of the rule, at the specified size.
bool matches(const QVariant &value, QgsExpressionContext &context) const
Check if the rule matches using the given value and feature.
QgsConditionalStyle & operator=(const QgsConditionalStyle &other)
void setTextColor(const QColor &value)
Set the text color for the style.
void setRule(const QString &value)
Set the rule for the style.
void setBackgroundColor(const QColor &value)
Set the background color for the style.
void setFont(const QFont &value)
Set the font for the style.
QColor backgroundColor() const
The background color for style.
QColor textColor() const
The text color set for style.
QString rule() const
The condition rule set for the style.
QFont font() const
The font for the style.
QgsSymbol * symbol() const
The symbol used to generate the icon for the style.
bool isValid() const
isValid Check if this rule is valid.
QPixmap icon() const
The icon set for style generated from the set symbol.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
ConstraintStrength
Strength of constraints.
A container for the context for various read/write operations on objects.
Abstract base class for all rendered symbols.
QList< QgsConditionalStyle > QgsConditionalStyles
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)