QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgslegendinterface.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslegendinterface.h
3  --------------------------------------
4  Date : 19-Nov-2009
5  Copyright : (C) 2009 by Andres Manz
6  Email : manz dot andres at gmail dot com
7 ****************************************************************************/
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSLEGENDINTERFACE_H
18 #define QGSLEGENDINTERFACE_H
19 
20 #include <QObject>
21 #include <QPair>
22 #include <QStringList>
23 #include <QModelIndex>
24 
25 class QgsMapLayer;
26 class QTreeWidgetItem;
27 class QAction;
28 
29 #include "qgsmaplayer.h"
30 
31 //Information about relationship between groups and layers
32 //key: group name (or null strings for single layers without groups)
33 //value: containter with layer ids contained in the group
34 typedef QPair< QString, QList<QString> > GroupLayerInfo;
35 
40 class GUI_EXPORT QgsLegendInterface : public QObject
41 {
42  Q_OBJECT
43 
44  public:
45 
48 
50  virtual ~QgsLegendInterface();
51 
53  virtual QStringList groups() = 0;
54 
56  virtual QList< GroupLayerInfo > groupLayerRelationship() { return QList< GroupLayerInfo >(); }
57 
61  virtual QList<QgsMapLayer *> selectedLayers( bool inDrawOrder = false ) const = 0;
62 
64  virtual QList< QgsMapLayer * > layers() const = 0;
65 
67  virtual bool groupExists( int groupIndex ) = 0;
68 
70  virtual bool isGroupExpanded( int groupIndex ) = 0;
71 
73  virtual bool isGroupVisible( int groupIndex ) = 0;
74 
76  virtual bool isLayerExpanded( QgsMapLayer * ml ) = 0;
77 
79  virtual bool isLayerVisible( QgsMapLayer * ml ) = 0;
80 
83  virtual void addLegendLayerAction( QAction* action, QString menu, QString id,
84  QgsMapLayer::LayerType type, bool allLayers ) = 0;
85 
89  virtual void addLegendLayerActionForLayer( QAction* action, QgsMapLayer* layer ) = 0;
90 
92  virtual bool removeLegendLayerAction( QAction* action ) = 0;
93 
97  virtual QgsMapLayer* currentLayer() = 0;
98 
101  virtual bool setCurrentLayer( QgsMapLayer *layer ) = 0;
102 
103  signals:
104 
106  void groupIndexChanged( int oldIndex, int newIndex );
107 
108  /* //! emitted when group relations have changed */
109  void groupRelationsChanged();
110 
111  /* //! emitted when an item (group/layer) is added */
112  void itemAdded( QModelIndex index );
113 
114  /* //! emitted when an item (group/layer) is removed */
115  void itemRemoved();
116 
118  // the pointer to layer can be null if no layer is selected
119  void currentLayerChanged( QgsMapLayer * layer );
120 
121  public slots:
122 
125  virtual int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent = 0 ) = 0;
126 
129  virtual int addGroup( QString name, bool expand, int parentIndex ) = 0;
130 
132  virtual void removeGroup( int groupIndex ) = 0;
133 
135  virtual void moveLayer( QgsMapLayer * ml, int groupIndex ) = 0;
136 
138  virtual void setGroupExpanded( int groupIndex, bool expand ) = 0;
139 
141  virtual void setLayerExpanded( QgsMapLayer * ml, bool expand ) = 0;
142 
144  virtual void setGroupVisible( int groupIndex, bool visible ) = 0;
145 
147  virtual void setLayerVisible( QgsMapLayer * ml, bool visible ) = 0;
148 
150 
151  virtual void refreshLayerSymbology( QgsMapLayer *ml ) = 0;
152 };
153 
154 #endif
QgsLegendInterface Abstract base class to make QgsLegend available to plugins.
static unsigned index
Base class for all map layer types.
Definition: qgsmaplayer.h:48
LayerType
Layers enum defining the types of layers that can be added to a map.
Definition: qgsmaplayer.h:54
virtual QList< GroupLayerInfo > groupLayerRelationship()
Return the relationship between groups and layers in the legend.
QPair< QString, QList< QString > > GroupLayerInfo