2015-08-22 13:42:29 +02:00
|
|
|
/** \class QgsConditionalStyle
|
2015-08-20 23:06:05 +10:00
|
|
|
* \ingroup core
|
|
|
|
* Conditional styling for a rule.
|
|
|
|
*/
|
|
|
|
class QgsConditionalStyle
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsconditionalstyle.h>
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
QgsConditionalStyle();
|
|
|
|
QgsConditionalStyle( QString rule );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check if the rule matches using the given value and feature
|
2015-08-21 06:59:57 +10:00
|
|
|
* @param value The current value being checked. The "value" variable from the context is replaced with this value.
|
|
|
|
* @param context Expression context for evaluating rule expression
|
2015-08-20 23:06:05 +10:00
|
|
|
* @return True of the rule matches against the given feature
|
|
|
|
*/
|
2015-08-21 06:59:57 +10:00
|
|
|
bool matches( QVariant value, QgsExpressionContext& context ) const;
|
2015-08-22 13:42:29 +02:00
|
|
|
|
2015-08-20 23:06:05 +10:00
|
|
|
/**
|
|
|
|
* @brief Render a preview icon of the rule.
|
|
|
|
* @return QPixmap preview of the style
|
|
|
|
*/
|
|
|
|
QPixmap renderPreview();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the rule for the style. Rules should be of QgsExpression syntax.
|
2015-08-22 13:42:29 +02:00
|
|
|
* Special value of \@value is replaced at run time with the check value
|
|
|
|
* @param value The QgsExpression style rule to use for this style
|
2015-08-20 23:06:05 +10:00
|
|
|
*/
|
|
|
|
void setRule( QString value );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the background color for the style
|
|
|
|
* @param value QColor for background color
|
|
|
|
*/
|
|
|
|
void setBackgroundColor( QColor value );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the text color for the style
|
|
|
|
* @param value QColor for text color
|
|
|
|
*/
|
|
|
|
void setTextColor( QColor value );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the font for the the style
|
|
|
|
* @param value QFont to be used for text
|
|
|
|
*/
|
|
|
|
void setFont( QFont value );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the icon for the style. Icons are generated from symbols
|
|
|
|
* @param value QgsSymbolV2 to be used when generating the icon
|
|
|
|
*/
|
|
|
|
void setSymbol( QgsSymbolV2* value );
|
|
|
|
|
|
|
|
/**
|
2015-08-22 13:42:29 +02:00
|
|
|
* @brief The icon set for style generated from the set symbol
|
|
|
|
* @return A QPixmap that was set for the icon using the symbol
|
2015-08-20 23:06:05 +10:00
|
|
|
*/
|
|
|
|
QgsSymbolV2* symbol() const;
|
|
|
|
|
|
|
|
/**
|
2015-08-22 13:42:29 +02:00
|
|
|
* @brief The symbol used to generate the icon for the style
|
|
|
|
* @return The QgsSymbolV2 used for the icon
|
2015-08-20 23:06:05 +10:00
|
|
|
*/
|
|
|
|
QPixmap icon() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The text color set for style
|
|
|
|
* @return QColor for text color
|
|
|
|
*/
|
|
|
|
QColor textColor() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The background color for style
|
|
|
|
* @return QColor for background color
|
|
|
|
*/
|
|
|
|
QColor backgroundColor() const;
|
|
|
|
/**
|
|
|
|
* @brief The font for the style
|
|
|
|
* @return QFont for the style
|
|
|
|
*/
|
|
|
|
QFont font() const;
|
|
|
|
|
|
|
|
/**
|
2015-08-22 13:42:29 +02:00
|
|
|
* @brief The condition rule set for the style. Rule may contain variable \@value
|
2015-08-20 23:06:05 +10:00
|
|
|
* to represent the current value
|
|
|
|
* @return QString of the current set rule
|
|
|
|
*/
|
|
|
|
QString rule() const;
|
2015-08-22 13:42:29 +02:00
|
|
|
|
2015-08-20 23:06:05 +10:00
|
|
|
/**
|
|
|
|
* @brief isValid Check if this rule is valid. A valid rule has one or more properties
|
|
|
|
* set.
|
|
|
|
* @return True if the rule is valid.
|
|
|
|
*/
|
|
|
|
bool isValid() const;
|
|
|
|
|
|
|
|
/** Reads vector conditional style specific state from layer Dom node.
|
|
|
|
*/
|
|
|
|
virtual bool readXml( const QDomNode& node );
|
|
|
|
|
|
|
|
/** Write vector conditional style specific state from layer Dom node.
|
|
|
|
*/
|
|
|
|
virtual bool writeXml( QDomNode & node, QDomDocument & doc );
|
|
|
|
};
|