QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
26 class QgsSymbol;
27 
36 class CORE_EXPORT QgsLegendSymbolItem
37 {
38  public:
39 
43  QgsLegendSymbolItem() = default;
44 
49  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() );
51 
53  QgsLegendSymbolItem &operator=( const QgsLegendSymbolItem &other );
54 
56  QgsSymbol *symbol() const { return mSymbol; }
58  QString label() const { return mLabel; }
60  QString ruleKey() const { return mKey; }
62  bool isCheckable() const { return mCheckable; }
63 
65  QgsSymbol *legacyRuleKey() const { return mOriginalSymbolPointer; }
66 
68  bool isScaleOK( double scale ) const;
69 
74  int scaleMinDenom() const { return mScaleMinDenom; }
75 
80  int scaleMaxDenom() const { return mScaleMaxDenom; }
81 
83  int level() const { return mLevel; }
84 
89  QString parentRuleKey() const { return mParentKey; }
90 
98  void setSymbol( QgsSymbol *s );
99 
107  void setDataDefinedSizeLegendSettings( QgsDataDefinedSizeLegend *settings SIP_TRANSFER );
108 
113  QgsDataDefinedSizeLegend *dataDefinedSizeLegendSettings() const;
114 
115  private:
117  QgsSymbol *mSymbol = nullptr;
119  QString mLabel;
121  QString mKey;
123  bool mCheckable = false;
124 
125  QgsSymbol *mOriginalSymbolPointer = nullptr;
126 
131  QgsDataDefinedSizeLegend *mDataDefinedSizeLegendSettings = nullptr;
132 
133  // additional data that may be used for filtering
134 
135  int mScaleMinDenom = -1;
136  int mScaleMaxDenom = -1;
137 
139  int mLevel = 0;
141  QString mParentKey;
142 };
143 
144 typedef QList< QgsLegendSymbolItem > QgsLegendSymbolList;
145 
146 #endif // QGSLEGENDSYMBOLITEM_H
QgsLegendSymbolItem::scaleMinDenom
int scaleMinDenom() const
Min scale denominator of the scale range.
Definition: qgslegendsymbolitem.h:74
QgsDataDefinedSizeLegend
Definition: qgsdatadefinedsizelegend.h:41
qgis.h
QgsSymbol
Definition: qgssymbol.h:63
QgsLegendSymbolItem::ruleKey
QString ruleKey() const
Returns unique identifier of the rule for identification of the item within renderer.
Definition: qgslegendsymbolitem.h:60
QgsLegendSymbolItem
Definition: qgslegendsymbolitem.h:36
QgsLegendSymbolItem::legacyRuleKey
QgsSymbol * legacyRuleKey() const
Used for older code that identifies legend entries from symbol pointer within renderer.
Definition: qgslegendsymbolitem.h:65
QgsLegendSymbolItem::scaleMaxDenom
int scaleMaxDenom() const
Max scale denominator of the scale range.
Definition: qgslegendsymbolitem.h:80
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsLegendSymbolItem::label
QString label() const
Returns text label.
Definition: qgslegendsymbolitem.h:58
QgsLegendSymbolItem::symbol
QgsSymbol * symbol() const
Returns associated symbol. May be nullptr.
Definition: qgslegendsymbolitem.h:56
QgsLegendSymbolItem::isCheckable
bool isCheckable() const
Returns whether the item is user-checkable - whether renderer supports enabling/disabling it.
Definition: qgslegendsymbolitem.h:62
QgsLegendSymbolItem::level
int level() const
Indentation level that tells how deep the item is in a hierarchy of items. For flat lists level is 0.
Definition: qgslegendsymbolitem.h:83
QgsLegendSymbolList
QList< QgsLegendSymbolItem > QgsLegendSymbolList
Definition: qgslegendsymbolitem.h:144
QgsLegendSymbolItem::parentRuleKey
QString parentRuleKey() const
Key of the parent legend node.
Definition: qgslegendsymbolitem.h:89