Skip to content
Permalink
Browse files

[Conditional Styles] Better defaults

Add QgsConditionalLayerStyles to hold row and field styles
  • Loading branch information
NathanW2 committed Aug 25, 2015
1 parent 83115cd commit 2f60a5f85c1e107a8047127bb1a8e7d617f7c2a5
@@ -42,7 +42,6 @@
%Include qgsfeatureiterator.sip
%Include qgsfeaturerequest.sip
%Include qgsfield.sip
%Include qgsfielduiproperties.sip
%Include qgsgeometryvalidator.sip
%Include qgsgeometrysimplifier.sip
%Include qgshistogram.sip
@@ -1,3 +1,48 @@
typedef QList<QgsConditionalStyle> QgsConditionalStyles;

/**
* @brief The QgsConditionalLayerStyles class holds conditional style information
* for a layer. This includes field styles and full row styles.
*/
class QgsConditionalLayerStyles
{
%TypeHeaderCode
#include <qgsconditionalstyle.h>
%End
public:
QgsConditionalLayerStyles();

QList<QgsConditionalStyle> rowStyles();

/**
* @brief Set the conditional styles that apply to full rows of data in the attribute table.
* Each row will check be checked against each rule.
* @param styles The styles to assign to all the rows
* @note added in QGIS 2.12
*/
void setRowStyles( QList<QgsConditionalStyle> styles );

/**
* @brief Set the conditional styles for the field UI properties.
* @param styles
*/
void setFieldStyles( QString fieldName, QList<QgsConditionalStyle> styles );

/**
* @brief Returns the conditional styles set for the field UI properties
* @return A list of conditional styles that have been set.
*/
QList<QgsConditionalStyle> fieldStyles( QString fieldName );

/** Reads field ui properties specific state from Dom node.
*/
virtual bool readXml( const QDomNode& node );

/** Write field ui properties specific state from Dom node.
*/
virtual bool writeXml( QDomNode & node, QDomDocument & doc ) const;
};

/** \class QgsConditionalStyle
* \ingroup core
* Conditional styling for a rule.
@@ -9,7 +54,9 @@ class QgsConditionalStyle
%End
public:
QgsConditionalStyle();
QgsConditionalStyle( const QgsConditionalStyle& other );
QgsConditionalStyle( QString rule );
~QgsConditionalStyle();

/**
* @brief Check if the rule matches using the given value and feature
@@ -74,29 +121,43 @@ class QgsConditionalStyle
*/
QString name() const;

/**
* @brief The symbol used to generate the icon for the style
* @return The QgsSymbolV2 used for the icon
*/
QgsSymbolV2* symbol() const;

/**
* @brief The icon set for style generated from the set symbol
* @return A QPixmap that was set for the icon using the symbol
*/
QPixmap icon() const;

/**
* @brief The symbol used to generate the icon for the style
* @return The QgsSymbolV2 used for the icon
*/
QgsSymbolV2* symbol() const;

/**
* @brief The text color set for style
* @return QColor for text color
*/
QColor textColor() const;

/**
* @brief Check if the text color is valid for render.
* Valid colors are non invalid QColors and a color with a > 0 alpha
* @return True of the color set for text is valid.
*/
bool validTextColor() const;

/**
* @brief The background color for style
* @return QColor for background color
*/
QColor backgroundColor() const;

/**
* @brief Check if the background color is valid for render.
* Valid colors are non invalid QColors and a color with a > 0 alpha
* @return True of the color set for background is valid.
*/
bool validBackgroundColor() const;
/**
* @brief The font for the style
* @return QFont for the style
@@ -124,7 +185,7 @@ class QgsConditionalStyle
* @return A condtional style that matches the value and feature.
* Check with QgsCondtionalStyle::isValid()
*/
static QList<QgsConditionalStyle> matchingConditionalStyles( QList<QgsConditionalStyle> styles, QVariant value, QgsFeature* feature );
static QList<QgsConditionalStyle> matchingConditionalStyles( QList<QgsConditionalStyle> styles, QVariant value, QgsExpressionContext& context );

/**
* @brief Find and return the matching style for the value and feature.
@@ -133,7 +194,7 @@ class QgsConditionalStyle
* @return A condtional style that matches the value and feature.
* Check with QgsCondtionalStyle::isValid()
*/
static QgsConditionalStyle matchingConditionalStyle( QList<QgsConditionalStyle> styles, QVariant value, QgsFeature* feature );
static QgsConditionalStyle matchingConditionalStyle( QList<QgsConditionalStyle> styles, QVariant value, QgsExpressionContext& context );

/**
* @brief Compress a list of styles into a single style. This can be used to stack the elements of the

This file was deleted.

@@ -1243,22 +1243,13 @@ class QgsVectorLayer : QgsMapLayer
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;

/**
* @brief Return the field properties that have been set for the given field.
* Field UI properties hold extra UI information for a field that can be used in the UI.
* @param fieldName The field name to get the field properties for.
* @return Return the UI properties set for the field. Returns a new QgsFieldUIProperties if
* none is currently set for the field.
* @brief Return the conditional styles that are set for this layer. Style information is
* used to render conditional formatting in the attribute table.
* @return Return a \class QgsConditionalLayerStyles object holding the conditional attribute
* style information. Style information is generic and can be used for anything.
* @note added in QGIS 2.12
*/
QgsFieldUIProperties fieldUIProperties( QString fieldName );

/**
* @brief Set the the field UI properties for a given field.
* @param fieldName The field name.
* @param props The properties to assign to a field.
* @note added in QGIS 2.12
*/
void setFieldUIProperties( QString fieldName, QgsFieldUIProperties props );
QgsConditionalLayerStyles *conditionalStyles() const;

public slots:
/**
@@ -58,6 +58,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../core
${CMAKE_CURRENT_SOURCE_DIR}/../core/geometry
${CMAKE_CURRENT_SOURCE_DIR}/../core/raster
${CMAKE_CURRENT_SOURCE_DIR}/../core/symbology-ng
${CMAKE_CURRENT_SOURCE_DIR}/../gui
${CMAKE_CURRENT_SOURCE_DIR}/../gui/attributetable
${CMAKE_CURRENT_SOURCE_DIR}/../gui/editorwidgets
@@ -26,6 +26,7 @@
#include "qgsencodingfiledialog.h"
#include "qgsgenericprojectionselector.h"
#include "qgslogger.h"
#include "qgsconditionalstyle.h"
#include "qgsmaplayerregistry.h"
#include "qgsproviderregistry.h"
#include "qgsvectorlayer.h"
@@ -102,7 +102,6 @@ SET(QGIS_CORE_SRCS
qgsfeaturerequest.cpp
qgsfeaturestore.cpp
qgsfield.cpp
qgsfielduiproperties.cpp
qgsfontutils.cpp
qgsgeometrycache.cpp
qgsgeometrysimplifier.cpp
@@ -546,7 +545,6 @@ SET(QGIS_CORE_HDRS
qgsfeaturerequest.h
qgsfeaturestore.h
qgsfield.h
qgsfielduiproperties.h
qgsfield_p.h
qgsfontutils.h
qgsgeometrycache.h

0 comments on commit 2f60a5f

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