|
Quantum GIS API Documentation
master-ce49b66
|
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 class QAction; 00028 00029 #include "qgsmaplayer.h" 00030 00031 //Information about relationship between groups and layers 00032 //key: group name (or null strings for single layers without groups) 00033 //value: containter with layer ids contained in the group 00034 typedef QPair< QString, QList<QString> > GroupLayerInfo; 00035 00042 class GUI_EXPORT QgsLegendInterface : public QObject 00043 { 00044 Q_OBJECT 00045 00046 public: 00047 00049 QgsLegendInterface(); 00050 00052 virtual ~QgsLegendInterface(); 00053 00055 virtual QStringList groups() = 0; 00056 00058 virtual QList< GroupLayerInfo > groupLayerRelationship() { return QList< GroupLayerInfo >(); } 00059 00063 virtual QList<QgsMapLayer *> selectedLayers( bool inDrawOrder = false ) const = 0; 00064 00067 virtual QList< QgsMapLayer * > layers() const = 0; 00068 00071 virtual bool groupExists( int groupIndex ) = 0; 00072 00075 virtual bool isGroupExpanded( int groupIndex ) = 0; 00076 00079 virtual bool isGroupVisible( int groupIndex ) = 0; 00080 00083 virtual bool isLayerExpanded( QgsMapLayer * ml ) = 0; 00084 00087 virtual bool isLayerVisible( QgsMapLayer * ml ) = 0; 00088 00092 virtual void addLegendLayerAction( QAction* action, QString menu, QString id, 00093 QgsMapLayer::LayerType type, bool allLayers ) = 0; 00094 00099 virtual void addLegendLayerActionForLayer( QAction* action, QgsMapLayer* layer ) = 0; 00100 00104 virtual bool removeLegendLayerAction( QAction* action ) = 0; 00105 00110 virtual QgsMapLayer* currentLayer() = 0; 00111 00115 virtual bool setCurrentLayer( QgsMapLayer *layer ) = 0; 00116 00117 signals: 00118 00120 void groupIndexChanged( int oldIndex, int newIndex ); 00121 00122 /* //! emitted when group relations have changed */ 00123 void groupRelationsChanged( ); 00124 00125 /* //! emitted when an item (group/layer) is added */ 00126 void itemAdded( QModelIndex index ); 00127 00128 /* //! emitted when an item (group/layer) is removed */ 00129 void itemRemoved( ); 00130 00132 // the pointer to layer can be null if no layer is selected 00134 void currentLayerChanged( QgsMapLayer * layer ); 00135 00136 public slots: 00137 00140 virtual int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent = 0 ) = 0; 00141 00144 virtual int addGroup( QString name, bool expand, int parentIndex ) = 0; 00145 00147 virtual void removeGroup( int groupIndex ) = 0; 00148 00150 virtual void moveLayer( QgsMapLayer * ml, int groupIndex ) = 0; 00151 00154 virtual void setGroupExpanded( int groupIndex, bool expand ) = 0; 00155 00158 virtual void setLayerExpanded( QgsMapLayer * ml, bool expand ) = 0; 00159 00162 virtual void setGroupVisible( int groupIndex, bool visible ) = 0; 00163 00166 virtual void setLayerVisible( QgsMapLayer * ml, bool visible ) = 0; 00167 00170 virtual void refreshLayerSymbology( QgsMapLayer *ml ) = 0; 00171 }; 00172 00173 #endif