Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgslegendinterface.h 00003 -------------------------------------- 00004 Date : 19-Nov-2009 00005 Copyright : (C) 2009 by Andres Manz 00006 Email : manz dot andres at gmail dot com 00007 ****************************************************************************/ 00008 /*************************************************************************** 00009 * * 00010 * This program is free software; you can redistribute it and/or modify * 00011 * it under the terms of the GNU General Public License as published by * 00012 * the Free Software Foundation; either version 2 of the License, or * 00013 * (at your option) any later version. * 00014 * * 00015 ***************************************************************************/ 00016 00017 #ifndef QGSLEGENDINTERFACE_H 00018 #define QGSLEGENDINTERFACE_H 00019 00020 #include <QObject> 00021 #include <QPair> 00022 #include <QStringList> 00023 #include <QModelIndex> 00024 00025 class QgsMapLayer; 00026 class QTreeWidgetItem; 00027 00028 //Information about relationship between groups and layers 00029 //key: group name (or null strings for single layers without groups) 00030 //value: containter with layer ids contained in the group 00031 typedef QPair< QString, QList<QString> > GroupLayerInfo; 00032 00039 class GUI_EXPORT QgsLegendInterface : public QObject 00040 { 00041 Q_OBJECT 00042 00043 public: 00044 00046 QgsLegendInterface(); 00047 00049 virtual ~QgsLegendInterface(); 00050 00052 virtual QStringList groups() = 0; 00053 00055 virtual QList< GroupLayerInfo > groupLayerRelationship() { return QList< GroupLayerInfo >(); } 00056 00059 virtual QList< QgsMapLayer * > layers() const = 0; 00060 00063 virtual bool groupExists( int groupIndex ) = 0; 00064 00067 virtual bool isGroupExpanded( int groupIndex ) = 0; 00068 00071 virtual bool isGroupVisible( int groupIndex ) = 0; 00072 00075 virtual bool isLayerVisible( QgsMapLayer * ml ) = 0; 00076 00077 signals: 00078 00080 void groupIndexChanged( int oldIndex, int newIndex ); 00081 00082 /* //! emitted when group relations have changed */ 00083 void groupRelationsChanged( ); 00084 00085 /* //! emitted when an item (group/layer) is added */ 00086 void itemAdded( QModelIndex index ); 00087 00088 /* //! emitted when an item (group/layer) is removed */ 00089 void itemRemoved( ); 00090 00091 public slots: 00092 00095 virtual int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent = 0 ) = 0; 00096 00099 virtual int addGroup( QString name, bool expand, int parentIndex ) = 0; 00100 00102 virtual void removeGroup( int groupIndex ) = 0; 00103 00105 virtual void moveLayer( QgsMapLayer * ml, int groupIndex ) = 0; 00106 00109 virtual void setGroupExpanded( int groupIndex, bool expand ) = 0; 00110 00113 virtual void setGroupVisible( int groupIndex, bool visible ) = 0; 00114 00117 virtual void setLayerVisible( QgsMapLayer * ml, bool visible ) = 0; 00118 00121 virtual void refreshLayerSymbology( QgsMapLayer *ml ) = 0; 00122 }; 00123 00124 #endif