QGIS API Documentation  2.99.0-Master (0a63d1f)
qgsmaplayerlegend.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaplayerlegend.h
3  --------------------------------------
4  Date : July 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 QGSMAPLAYERLEGEND_H
17 #define QGSMAPLAYERLEGEND_H
18 
19 #include <QObject>
20 
21 class QgsLayerTreeLayer;
23 class QgsPluginLayer;
24 class QgsRasterLayer;
25 class QgsVectorLayer;
26 
27 #include "qgis_core.h"
28 
29 
36 class CORE_EXPORT QgsMapLayerLegend : public QObject
37 {
38  Q_OBJECT
39  public:
40  explicit QgsMapLayerLegend( QObject *parent = nullptr );
41 
42  // TODO: type, load/save settings
43 
48  virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) = 0;
49 
50  // TODO: support for layer tree view delegates
51 
53  static QgsMapLayerLegend* defaultVectorLegend( QgsVectorLayer* vl );
54 
56  static QgsMapLayerLegend* defaultRasterLegend( QgsRasterLayer* rl );
57 
59  static QgsMapLayerLegend* defaultPluginLegend( QgsPluginLayer* pl );
60 
61  signals:
63  void itemsChanged();
64 };
65 
66 
72 class CORE_EXPORT QgsMapLayerLegendUtils
73 {
74  public:
75  static void setLegendNodeOrder( QgsLayerTreeLayer* nodeLayer, const QList<int>& order );
76  static QList<int> legendNodeOrder( QgsLayerTreeLayer* nodeLayer );
77  static bool hasLegendNodeOrder( QgsLayerTreeLayer* nodeLayer );
78 
79  static void setLegendNodeUserLabel( QgsLayerTreeLayer* nodeLayer, int originalIndex, const QString& newLabel );
80  static QString legendNodeUserLabel( QgsLayerTreeLayer* nodeLayer, int originalIndex );
81  static bool hasLegendNodeUserLabel( QgsLayerTreeLayer* nodeLayer, int originalIndex );
82 
84  static void applyLayerNodeProperties( QgsLayerTreeLayer* nodeLayer, QList<QgsLayerTreeModelLegendNode*>& nodes );
85 };
86 
87 
88 #include <QHash>
89 
95 {
96  Q_OBJECT
97 
98  public:
100 
101  virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) override;
102 
103  private:
104  QgsVectorLayer* mLayer;
105 };
106 
107 
113 {
114  Q_OBJECT
115 
116  public:
118 
119  virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) override;
120 
121  private:
122  QgsRasterLayer* mLayer;
123 };
124 
125 
131 {
132  Q_OBJECT
133 
134  public:
136 
137  virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) override;
138 
139  private:
140  QgsPluginLayer* mLayer;
141 };
142 
143 #endif // QGSMAPLAYERLEGEND_H
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
Base class for plugin layers.
Default legend implementation for raster layers.
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer...
Miscellaneous utility functions for handling of map layer legend.
Default legend implementation for plugin layers.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
Default legend implementation for vector layers.
Represents a vector layer which manages a vector based data sets.
virtual QList< QgsLayerTreeModelLegendNode * > createLayerTreeModelLegendNodes(QgsLayerTreeLayer *nodeLayer)=0
Return list of legend nodes to be used for a particular layer tree layer node.
Layer tree node points to a map layer.