Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 /* $Id$ */
17 
18 #ifndef QGSLEGENDINTERFACE_H
19 #define QGSLEGENDINTERFACE_H
20 
21 #include <QObject>
22 #include <QPair>
23 #include <QStringList>
24 
25 class QgsMapLayer;
26 class QTreeWidgetItem;
27 
28 //Information about relationship between groups and layers
29 //key: group name (or null strings for single layers without groups)
30 //value: containter with layer ids contained in the group
31 typedef QPair< QString, QList<QString> > GroupLayerInfo;
32 
39 class GUI_EXPORT QgsLegendInterface : public QObject
40 {
41  Q_OBJECT
42 
43  public:
44 
47 
49  virtual ~QgsLegendInterface();
50 
52  virtual QStringList groups() = 0;
53 
55  virtual QList< GroupLayerInfo > groupLayerRelationship() { return QList< GroupLayerInfo >(); }
56 
59  virtual QList< QgsMapLayer * > layers() const = 0;
60 
63  virtual bool groupExists( int groupIndex ) = 0;
64 
67  virtual bool isGroupExpanded( int groupIndex ) = 0;
68 
71  virtual bool isGroupVisible( int groupIndex ) = 0;
72 
75  virtual bool isLayerVisible( QgsMapLayer * ml ) = 0;
76 
77  signals:
79  void groupIndexChanged( int oldIndex, int newIndex );
80 
81  public slots:
82 
85  virtual int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent = 0 ) = 0;
86 
89  virtual int addGroup( QString name, bool expand, int parentIndex ) = 0;
90 
92  virtual void removeGroup( int groupIndex ) = 0;
93 
95  virtual void moveLayer( QgsMapLayer * ml, int groupIndex ) = 0;
96 
99  virtual void setGroupExpanded( int groupIndex, bool expand ) = 0;
100 
103  virtual void setGroupVisible( int groupIndex, bool visible ) = 0;
104 
107  virtual void setLayerVisible( QgsMapLayer * ml, bool visible ) = 0;
108 
111  virtual void refreshLayerSymbology( QgsMapLayer *ml ) = 0;
112 };
113 
114 #endif