QGIS API Documentation 3.39.0-Master (47f7b3a4989)
Loading...
Searching...
No Matches
qgslegendsymbolitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslegendsymbolitem.h
3 --------------------------------------
4 Date : August 2014
5 Copyright : (C) 2014 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSLEGENDSYMBOLITEM_H
17#define QGSLEGENDSYMBOLITEM_H
18
19#include <memory>
20#include <QString>
21
22#include "qgis.h"
23#include "qgis_core.h"
24
26class QgsSymbol;
27
35class CORE_EXPORT QgsLegendSymbolItem
36{
37 public:
38
43
47 QgsLegendSymbolItem( QgsSymbol *symbol, const QString &label, const QString &ruleKey, bool checkable = false, int scaleMinDenom = -1, int scaleMaxDenom = -1, int level = 0, const QString &parentRuleKey = QString() );
49
51 QgsLegendSymbolItem &operator=( const QgsLegendSymbolItem &other );
52
54 QgsSymbol *symbol() const { return mSymbol; }
56 QString label() const { return mLabel; }
58 QString ruleKey() const { return mKey; }
60 bool isCheckable() const { return mCheckable; }
61
63 QgsSymbol *legacyRuleKey() const { return mOriginalSymbolPointer; }
64
66 bool isScaleOK( double scale ) const;
67
72 int scaleMinDenom() const { return mScaleMinDenom; }
73
78 int scaleMaxDenom() const { return mScaleMaxDenom; }
79
81 int level() const { return mLevel; }
82
87 QString parentRuleKey() const { return mParentKey; }
88
96 void setSymbol( QgsSymbol *s );
97
104 void setDataDefinedSizeLegendSettings( QgsDataDefinedSizeLegend *settings SIP_TRANSFER );
105
109 QgsDataDefinedSizeLegend *dataDefinedSizeLegendSettings() const;
110
117 void setUserData( int key, QVariant &value );
118
125 QVariant userData( int key ) const;
126
127 private:
129 QgsSymbol *mSymbol = nullptr;
131 QString mLabel;
133 QString mKey;
135 bool mCheckable = false;
136
137 QgsSymbol *mOriginalSymbolPointer = nullptr;
138
143 QgsDataDefinedSizeLegend *mDataDefinedSizeLegendSettings = nullptr;
144
145 // additional data that may be used for filtering
146
147 int mScaleMinDenom = -1;
148 int mScaleMaxDenom = -1;
149
151 int mLevel = 0;
153 QString mParentKey;
154
155 QMap< int, QVariant > mUserData;
156};
157
158typedef QList< QgsLegendSymbolItem > QgsLegendSymbolList;
159
160#endif // QGSLEGENDSYMBOLITEM_H
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
QString parentRuleKey() const
Key of the parent legend node.
int level() const
Indentation level that tells how deep the item is in a hierarchy of items. For flat lists level is 0.
int scaleMaxDenom() const
Max scale denominator of the scale range.
int scaleMinDenom() const
Min scale denominator of the scale range.
QgsSymbol * symbol() const
Returns associated symbol. May be nullptr.
QgsLegendSymbolItem()=default
Constructor for QgsLegendSymbolItem.
QString ruleKey() const
Returns unique identifier of the rule for identification of the item within renderer.
bool isCheckable() const
Returns whether the item is user-checkable - whether renderer supports enabling/disabling it.
QString label() const
Returns text label.
QgsSymbol * legacyRuleKey() const
Used for older code that identifies legend entries from symbol pointer within renderer.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:94
#define SIP_TRANSFER
Definition qgis_sip.h:36
QList< QgsLegendSymbolItem > QgsLegendSymbolList