QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
42 class GUI_EXPORT QgsLegendInterface : public QObject
43 {
44  Q_OBJECT
45 
46  public:
47 
50 
52  virtual ~QgsLegendInterface();
53 
55  virtual QStringList groups() = 0;
56 
58  virtual QList< GroupLayerInfo > groupLayerRelationship() { return QList< GroupLayerInfo >(); }
59 
63  virtual QList<QgsMapLayer *> selectedLayers( bool inDrawOrder = false ) const = 0;
64 
67  virtual QList< QgsMapLayer * > layers() const = 0;
68 
71  virtual bool groupExists( int groupIndex ) = 0;
72 
75  virtual bool isGroupExpanded( int groupIndex ) = 0;
76 
79  virtual bool isGroupVisible( int groupIndex ) = 0;
80 
83  virtual bool isLayerExpanded( QgsMapLayer * ml ) = 0;
84 
87  virtual bool isLayerVisible( QgsMapLayer * ml ) = 0;
88 
92  virtual void addLegendLayerAction( QAction* action, QString menu, QString id,
93  QgsMapLayer::LayerType type, bool allLayers ) = 0;
94 
99  virtual void addLegendLayerActionForLayer( QAction* action, QgsMapLayer* layer ) = 0;
100 
104  virtual bool removeLegendLayerAction( QAction* action ) = 0;
105 
110  virtual QgsMapLayer* currentLayer() = 0;
111 
115  virtual bool setCurrentLayer( QgsMapLayer *layer ) = 0;
116 
117  signals:
118 
120  void groupIndexChanged( int oldIndex, int newIndex );
121 
122  /* //! emitted when group relations have changed */
123  void groupRelationsChanged( );
124 
125  /* //! emitted when an item (group/layer) is added */
126  void itemAdded( QModelIndex index );
127 
128  /* //! emitted when an item (group/layer) is removed */
129  void itemRemoved( );
130 
132  // the pointer to layer can be null if no layer is selected
134  void currentLayerChanged( QgsMapLayer * layer );
135 
136  public slots:
137 
140  virtual int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent = 0 ) = 0;
141 
144  virtual int addGroup( QString name, bool expand, int parentIndex ) = 0;
145 
147  virtual void removeGroup( int groupIndex ) = 0;
148 
150  virtual void moveLayer( QgsMapLayer * ml, int groupIndex ) = 0;
151 
154  virtual void setGroupExpanded( int groupIndex, bool expand ) = 0;
155 
158  virtual void setLayerExpanded( QgsMapLayer * ml, bool expand ) = 0;
159 
162  virtual void setGroupVisible( int groupIndex, bool visible ) = 0;
163 
166  virtual void setLayerVisible( QgsMapLayer * ml, bool visible ) = 0;
167 
170  virtual void refreshLayerSymbology( QgsMapLayer *ml ) = 0;
171 };
172 
173 #endif