QGIS API Documentation  3.0.2-Girona (307d082)
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 #include "qgis.h"
21 
22 class QgsLayerTreeLayer;
24 class QgsPluginLayer;
25 class QgsRasterLayer;
26 class QgsVectorLayer;
27 
28 #include "qgis_core.h"
29 
30 
38 class CORE_EXPORT QgsMapLayerLegend : public QObject
39 {
40  Q_OBJECT
41  public:
42 
44  explicit QgsMapLayerLegend( QObject *parent SIP_TRANSFERTHIS = nullptr );
45 
46  // TODO: type, load/save settings
47 
52  virtual QList<QgsLayerTreeModelLegendNode *> createLayerTreeModelLegendNodes( QgsLayerTreeLayer *nodeLayer ) = 0 SIP_FACTORY;
53 
54  // TODO: support for layer tree view delegates
55 
57  static QgsMapLayerLegend *defaultVectorLegend( QgsVectorLayer *vl ) SIP_FACTORY;
58 
60  static QgsMapLayerLegend *defaultRasterLegend( QgsRasterLayer *rl ) SIP_FACTORY;
61 
62  signals:
64  void itemsChanged();
65 };
66 
67 
74 class CORE_EXPORT QgsMapLayerLegendUtils
75 {
76  public:
77  static void setLegendNodeOrder( QgsLayerTreeLayer *nodeLayer, const QList<int> &order );
78  static QList<int> legendNodeOrder( QgsLayerTreeLayer *nodeLayer );
79  static bool hasLegendNodeOrder( QgsLayerTreeLayer *nodeLayer );
80 
81  static void setLegendNodeUserLabel( QgsLayerTreeLayer *nodeLayer, int originalIndex, const QString &newLabel );
82  static QString legendNodeUserLabel( QgsLayerTreeLayer *nodeLayer, int originalIndex );
83  static bool hasLegendNodeUserLabel( QgsLayerTreeLayer *nodeLayer, int originalIndex );
84 
86  static void applyLayerNodeProperties( QgsLayerTreeLayer *nodeLayer, QList<QgsLayerTreeModelLegendNode *> &nodes );
87 };
88 
89 
90 #include <QHash>
91 
98 {
99  Q_OBJECT
100 
101  public:
103 
104  QList<QgsLayerTreeModelLegendNode *> createLayerTreeModelLegendNodes( QgsLayerTreeLayer *nodeLayer ) SIP_FACTORY override;
105 
106  private:
107  QgsVectorLayer *mLayer = nullptr;
108 };
109 
110 
117 {
118  Q_OBJECT
119 
120  public:
122 
123  QList<QgsLayerTreeModelLegendNode *> createLayerTreeModelLegendNodes( QgsLayerTreeLayer *nodeLayer ) SIP_FACTORY override;
124 
125  private:
126  QgsRasterLayer *mLayer = nullptr;
127 };
128 
129 
130 #endif // QGSMAPLAYERLEGEND_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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.
virtual QList< QgsLayerTreeModelLegendNode * > createLayerTreeModelLegendNodes(QgsLayerTreeLayer *nodeLayer)=0
Return list of legend nodes to be used for a particular layer tree layer node.
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer...
Miscellaneous utility functions for handling of map layer legend.
#define SIP_FACTORY
Definition: qgis_sip.h:69
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.
Layer tree node points to a map layer.