QGIS API Documentation  master-3f58142
src/core/qgsmaplayerregistry.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgsmaplayerregistry.h
00003            Singleton class for keeping track of loaded layers
00004                              -------------------
00005     begin                : Sun June 04 2004
00006     copyright            : (C) 2004 by Tim Sutton
00007     email                : tim@linfiniti.com
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #ifndef QGSMAPLAYERREGISTRY_H
00020 #define QGSMAPLAYERREGISTRY_H
00021 
00022 #include <QMap>
00023 #include <QObject>
00024 #include <QStringList>
00025 class QString;
00026 class QgsMapLayer;
00027 
00032 class CORE_EXPORT QgsMapLayerRegistry : public QObject
00033 {
00034     Q_OBJECT
00035 
00036   public:
00038     static QgsMapLayerRegistry * instance();
00039 
00041     int count();
00042 
00043     ~QgsMapLayerRegistry();
00044 
00046     QgsMapLayer *mapLayer( QString theLayerId );
00047 
00049     QList<QgsMapLayer *> mapLayersByName( QString layerName );
00050 
00052     const QMap<QString, QgsMapLayer*> & mapLayers();
00053 
00073     QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers,
00074                                        bool addToLegend = true );
00075 
00097     QgsMapLayer* addMapLayer( QgsMapLayer * theMapLayer, bool addToLegend = true );
00098 
00112     void removeMapLayers( QStringList theLayerIds );
00113 
00127     void removeMapLayer( const QString& theLayerId );
00128 
00135     void removeAllMapLayers();
00136 
00145     void clearAllLayerCaches();
00146 
00152     void reloadAllLayers();
00153 
00154   signals:
00160     void layersWillBeRemoved( QStringList theLayerIds );
00161 
00169     void layerWillBeRemoved( QString theLayerId );
00170 
00171 
00180     void removeAll();
00181 
00191     void layersAdded( QList<QgsMapLayer *> theMapLayers );
00192 
00200     void layerWasAdded( QgsMapLayer* theMapLayer );
00201 
00212     void legendLayersAdded( QList<QgsMapLayer*> theMapLayers );
00213 
00214   protected:
00216     QgsMapLayerRegistry( QObject * parent = 0 );
00217 
00218   private:
00219 
00220     static QgsMapLayerRegistry* mInstance;
00221 
00222     QMap<QString, QgsMapLayer*> mMapLayers;
00223 
00227     void connectNotify( const char * signal );
00228 
00229 
00230 }; // class QgsMapLayerRegistry
00231 
00232 #endif //QgsMapLayerRegistry_H
00233 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines