Skip to content

Commit

Permalink
[Conditional Styles] Better defaults
Browse files Browse the repository at this point in the history
Add QgsConditionalLayerStyles to hold row and field styles
  • Loading branch information
NathanW2 committed Aug 25, 2015
1 parent 83115cd commit 2f60a5f
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 294 deletions.
1 change: 0 additions & 1 deletion python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
77 changes: 69 additions & 8 deletions python/core/qgsconditionalstyle.sip
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
36 changes: 0 additions & 36 deletions python/core/qgsfielduiproperties.sip

This file was deleted.

19 changes: 5 additions & 14 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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:
/**
Expand Down
1 change: 1 addition & 0 deletions src/browser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/browser/qgsbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ SET(QGIS_CORE_SRCS
qgsfeaturerequest.cpp
qgsfeaturestore.cpp
qgsfield.cpp
qgsfielduiproperties.cpp
qgsfontutils.cpp
qgsgeometrycache.cpp
qgsgeometrysimplifier.cpp
Expand Down Expand Up @@ -546,7 +545,6 @@ SET(QGIS_CORE_HDRS
qgsfeaturerequest.h
qgsfeaturestore.h
qgsfield.h
qgsfielduiproperties.h
qgsfield_p.h
qgsfontutils.h
qgsgeometrycache.h
Expand Down
Loading

0 comments on commit 2f60a5f

Please sign in to comment.