QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
34 class CORE_EXPORT QgsMapLayerLegend : public QObject
35 {
36  Q_OBJECT
37  public:
38  explicit QgsMapLayerLegend( QObject *parent = 0 );
39 
40  // TODO: type, load/save settings
41 
46  virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) = 0;
47 
48  // TODO: support for layer tree view delegates
49 
51  static QgsMapLayerLegend* defaultVectorLegend( QgsVectorLayer* vl );
52 
54  static QgsMapLayerLegend* defaultRasterLegend( QgsRasterLayer* rl );
55 
57  static QgsMapLayerLegend* defaultPluginLegend( QgsPluginLayer* pl );
58 
59  signals:
61  void itemsChanged();
62 };
63 
64 
70 class CORE_EXPORT QgsMapLayerLegendUtils
71 {
72  public:
73  static void setLegendNodeOrder( QgsLayerTreeLayer* nodeLayer, const QList<int>& order );
74  static QList<int> legendNodeOrder( QgsLayerTreeLayer* nodeLayer );
75  static bool hasLegendNodeOrder( QgsLayerTreeLayer* nodeLayer );
76 
77  static void setLegendNodeUserLabel( QgsLayerTreeLayer* nodeLayer, int originalIndex, const QString& newLabel );
78  static QString legendNodeUserLabel( QgsLayerTreeLayer* nodeLayer, int originalIndex );
79  static bool hasLegendNodeUserLabel( QgsLayerTreeLayer* nodeLayer, int originalIndex );
80 
82  static void applyLayerNodeProperties( QgsLayerTreeLayer* nodeLayer, QList<QgsLayerTreeModelLegendNode*>& nodes );
83 };
84 
85 
86 #include <QHash>
87 
92 {
93  public:
95 
96  virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) override;
97 
98  private:
99  QgsVectorLayer* mLayer;
100 };
101 
102 
107 {
108  public:
110 
111  virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) override;
112 
113  private:
114  QgsRasterLayer* mLayer;
115 };
116 
117 
122 {
123  public:
125 
126  virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) override;
127 
128  private:
129  QgsPluginLayer* mLayer;
130 };
131 
132 #endif // QGSMAPLAYERLEGEND_H