Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add more options for filtering legend elements
This introduces two new options to filter legend elements: - filter by expression: a boolean expression can be set. Only symbols of features that make the expression evaluated to true will be kept in the legend - filter by polygon: only symbols of features that are inside the given polygon will be part of the legend. The polygon filtering is used in particular for a new option in the composer legend that allows to filter out anything that is not included in the current atlas polygon.
- Loading branch information
Showing
with
991 additions
and 116 deletions.
- +3 −0 python/core/composer/qgsatlascomposition.sip
- +10 −0 python/core/composer/qgscomposerlegend.sip
- +15 −0 python/core/layertree/qgslayertreemodel.sip
- +7 −0 python/core/layertree/qgslayertreeutils.sip
- +1 −0 python/gui/gui.sip
- +50 −0 python/gui/qgslegendfilterbutton.sip
- +86 −15 src/app/composer/qgscomposerlegendwidget.cpp
- +7 −1 src/app/composer/qgscomposerlegendwidget.h
- +51 −26 src/app/qgisapp.cpp
- +6 −3 src/app/qgisapp.h
- +35 −13 src/core/composer/qgsatlascomposition.cpp
- +7 −1 src/core/composer/qgsatlascomposition.h
- +88 −10 src/core/composer/qgscomposerlegend.cpp
- +31 −0 src/core/composer/qgscomposerlegend.h
- +37 −9 src/core/layertree/qgslayertreemodel.cpp
- +21 −3 src/core/layertree/qgslayertreemodel.h
- +1 −1 src/core/layertree/qgslayertreemodellegendnode.cpp
- +27 −0 src/core/layertree/qgslayertreeutils.cpp
- +8 −0 src/core/layertree/qgslayertreeutils.h
- +1 −1 src/core/qgslegendrenderer.cpp
- +84 −14 src/core/qgsmaphittest.cpp
- +24 −1 src/core/qgsmaphittest.h
- +2 −0 src/gui/CMakeLists.txt
- +128 −0 src/gui/qgslegendfilterbutton.cpp
- +85 −0 src/gui/qgslegendfilterbutton.h
- +33 −10 src/ui/composer/qgscomposerlegendwidgetbase.ui
- +75 −0 tests/src/core/testqgslegendrenderer.cpp
- +68 −8 tests/src/python/test_qgsatlascomposition.py
- BIN tests/testdata/control_images/expected_atlas_legend/expected_atlas_legend.png
- BIN tests/testdata/control_images/expected_atlas_legend/expected_atlas_legend_mask.png
- BIN ...ntrol_images/legend/expected_legend_filter_by_expression/expected_legend_filter_by_expression.png
- BIN ..._images/legend/expected_legend_filter_by_expression/expected_legend_filter_by_expression_mask.png
- BIN ...ata/control_images/legend/expected_legend_filter_by_polygon/expected_legend_filter_by_polygon.png
- BIN ...ontrol_images/legend/expected_legend_filter_by_polygon/expected_legend_filter_by_polygon_mask.png
@@ -0,0 +1,50 @@ | ||
/** \ingroup gui | ||
* \class QgsFilterLegendButton | ||
* A tool button that allows to enable or disable legend filter by contents of the map. | ||
* An additional pop down menu allows to define a boolean expression to refine the filtering. | ||
* @note added in 2.14 | ||
*/ | ||
|
||
class QgsLegendFilterButton: public QToolButton | ||
{ | ||
%TypeHeaderCode | ||
#include <qgslegendfilterbutton.h> | ||
%End | ||
|
||
public: | ||
/** | ||
* Construct a new filter legend button | ||
* | ||
* @param parent The parent QWidget | ||
*/ | ||
QgsLegendFilterButton( QWidget* parent = 0 ); | ||
~QgsLegendFilterButton(); | ||
|
||
/** | ||
* Returns the current text used as filter expression | ||
*/ | ||
QString expressionText() const; | ||
|
||
/** | ||
* Sets the current text used as filter expression. | ||
* This will update the menu | ||
*/ | ||
void setExpressionText( const QString& expression ); | ||
|
||
/** | ||
* Returns the current associated vectorLayer | ||
* May be null | ||
*/ | ||
QgsVectorLayer* vectorLayer() const; | ||
/** | ||
* Sets the associated vectorLayer | ||
* May be null | ||
*/ | ||
void setVectorLayer( QgsVectorLayer* layer ); | ||
|
||
signals: | ||
/** | ||
* Emitted when the expression text changes | ||
*/ | ||
void expressionTextChanged(); | ||
}; |
Oops, something went wrong.