Skip to content

Commit 2f60a5f

Browse files
committedAug 25, 2015
[Conditional Styles] Better defaults
Add QgsConditionalLayerStyles to hold row and field styles
1 parent 83115cd commit 2f60a5f

17 files changed

+331
-294
lines changed
 

‎python/core/core.sip

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
%Include qgsfeatureiterator.sip
4343
%Include qgsfeaturerequest.sip
4444
%Include qgsfield.sip
45-
%Include qgsfielduiproperties.sip
4645
%Include qgsgeometryvalidator.sip
4746
%Include qgsgeometrysimplifier.sip
4847
%Include qgshistogram.sip

‎python/core/qgsconditionalstyle.sip

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
typedef QList<QgsConditionalStyle> QgsConditionalStyles;
2+
3+
/**
4+
* @brief The QgsConditionalLayerStyles class holds conditional style information
5+
* for a layer. This includes field styles and full row styles.
6+
*/
7+
class QgsConditionalLayerStyles
8+
{
9+
%TypeHeaderCode
10+
#include <qgsconditionalstyle.h>
11+
%End
12+
public:
13+
QgsConditionalLayerStyles();
14+
15+
QList<QgsConditionalStyle> rowStyles();
16+
17+
/**
18+
* @brief Set the conditional styles that apply to full rows of data in the attribute table.
19+
* Each row will check be checked against each rule.
20+
* @param styles The styles to assign to all the rows
21+
* @note added in QGIS 2.12
22+
*/
23+
void setRowStyles( QList<QgsConditionalStyle> styles );
24+
25+
/**
26+
* @brief Set the conditional styles for the field UI properties.
27+
* @param styles
28+
*/
29+
void setFieldStyles( QString fieldName, QList<QgsConditionalStyle> styles );
30+
31+
/**
32+
* @brief Returns the conditional styles set for the field UI properties
33+
* @return A list of conditional styles that have been set.
34+
*/
35+
QList<QgsConditionalStyle> fieldStyles( QString fieldName );
36+
37+
/** Reads field ui properties specific state from Dom node.
38+
*/
39+
virtual bool readXml( const QDomNode& node );
40+
41+
/** Write field ui properties specific state from Dom node.
42+
*/
43+
virtual bool writeXml( QDomNode & node, QDomDocument & doc ) const;
44+
};
45+
146
/** \class QgsConditionalStyle
247
* \ingroup core
348
* Conditional styling for a rule.
@@ -9,7 +54,9 @@ class QgsConditionalStyle
954
%End
1055
public:
1156
QgsConditionalStyle();
57+
QgsConditionalStyle( const QgsConditionalStyle& other );
1258
QgsConditionalStyle( QString rule );
59+
~QgsConditionalStyle();
1360

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

77-
/**
78-
* @brief The symbol used to generate the icon for the style
79-
* @return The QgsSymbolV2 used for the icon
80-
*/
81-
QgsSymbolV2* symbol() const;
82-
83124
/**
84125
* @brief The icon set for style generated from the set symbol
85126
* @return A QPixmap that was set for the icon using the symbol
86127
*/
87128
QPixmap icon() const;
88129

130+
/**
131+
* @brief The symbol used to generate the icon for the style
132+
* @return The QgsSymbolV2 used for the icon
133+
*/
134+
QgsSymbolV2* symbol() const;
135+
89136
/**
90137
* @brief The text color set for style
91138
* @return QColor for text color
92139
*/
93140
QColor textColor() const;
94141

142+
/**
143+
* @brief Check if the text color is valid for render.
144+
* Valid colors are non invalid QColors and a color with a > 0 alpha
145+
* @return True of the color set for text is valid.
146+
*/
147+
bool validTextColor() const;
148+
95149
/**
96150
* @brief The background color for style
97151
* @return QColor for background color
98152
*/
99153
QColor backgroundColor() const;
154+
155+
/**
156+
* @brief Check if the background color is valid for render.
157+
* Valid colors are non invalid QColors and a color with a > 0 alpha
158+
* @return True of the color set for background is valid.
159+
*/
160+
bool validBackgroundColor() const;
100161
/**
101162
* @brief The font for the style
102163
* @return QFont for the style
@@ -124,7 +185,7 @@ class QgsConditionalStyle
124185
* @return A condtional style that matches the value and feature.
125186
* Check with QgsCondtionalStyle::isValid()
126187
*/
127-
static QList<QgsConditionalStyle> matchingConditionalStyles( QList<QgsConditionalStyle> styles, QVariant value, QgsFeature* feature );
188+
static QList<QgsConditionalStyle> matchingConditionalStyles( QList<QgsConditionalStyle> styles, QVariant value, QgsExpressionContext& context );
128189

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

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

‎python/core/qgsfielduiproperties.sip

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎python/core/qgsvectorlayer.sip

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,22 +1243,13 @@ class QgsVectorLayer : QgsMapLayer
12431243
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
12441244

12451245
/**
1246-
* @brief Return the field properties that have been set for the given field.
1247-
* Field UI properties hold extra UI information for a field that can be used in the UI.
1248-
* @param fieldName The field name to get the field properties for.
1249-
* @return Return the UI properties set for the field. Returns a new QgsFieldUIProperties if
1250-
* none is currently set for the field.
1246+
* @brief Return the conditional styles that are set for this layer. Style information is
1247+
* used to render conditional formatting in the attribute table.
1248+
* @return Return a \class QgsConditionalLayerStyles object holding the conditional attribute
1249+
* style information. Style information is generic and can be used for anything.
12511250
* @note added in QGIS 2.12
12521251
*/
1253-
QgsFieldUIProperties fieldUIProperties( QString fieldName );
1254-
1255-
/**
1256-
* @brief Set the the field UI properties for a given field.
1257-
* @param fieldName The field name.
1258-
* @param props The properties to assign to a field.
1259-
* @note added in QGIS 2.12
1260-
*/
1261-
void setFieldUIProperties( QString fieldName, QgsFieldUIProperties props );
1252+
QgsConditionalLayerStyles *conditionalStyles() const;
12621253

12631254
public slots:
12641255
/**

‎src/browser/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
5858
${CMAKE_CURRENT_SOURCE_DIR}/../core
5959
${CMAKE_CURRENT_SOURCE_DIR}/../core/geometry
6060
${CMAKE_CURRENT_SOURCE_DIR}/../core/raster
61+
${CMAKE_CURRENT_SOURCE_DIR}/../core/symbology-ng
6162
${CMAKE_CURRENT_SOURCE_DIR}/../gui
6263
${CMAKE_CURRENT_SOURCE_DIR}/../gui/attributetable
6364
${CMAKE_CURRENT_SOURCE_DIR}/../gui/editorwidgets

‎src/browser/qgsbrowser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "qgsencodingfiledialog.h"
2727
#include "qgsgenericprojectionselector.h"
2828
#include "qgslogger.h"
29+
#include "qgsconditionalstyle.h"
2930
#include "qgsmaplayerregistry.h"
3031
#include "qgsproviderregistry.h"
3132
#include "qgsvectorlayer.h"

‎src/core/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ SET(QGIS_CORE_SRCS
102102
qgsfeaturerequest.cpp
103103
qgsfeaturestore.cpp
104104
qgsfield.cpp
105-
qgsfielduiproperties.cpp
106105
qgsfontutils.cpp
107106
qgsgeometrycache.cpp
108107
qgsgeometrysimplifier.cpp
@@ -546,7 +545,6 @@ SET(QGIS_CORE_HDRS
546545
qgsfeaturerequest.h
547546
qgsfeaturestore.h
548547
qgsfield.h
549-
qgsfielduiproperties.h
550548
qgsfield_p.h
551549
qgsfontutils.h
552550
qgsgeometrycache.h

0 commit comments

Comments
 (0)
Please sign in to comment.