Quantum GIS API Documentation
1.8
|
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 : [email protected] 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: 00037 00039 static QgsMapLayerRegistry * instance(); 00043 int count(); 00044 00045 ~QgsMapLayerRegistry(); 00046 00048 QgsMapLayer * mapLayer( QString theLayerId ); 00049 00051 QMap<QString, QgsMapLayer*> & mapLayers(); 00052 00066 Q_DECL_DEPRECATED QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true ); 00067 00081 QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers, 00082 bool theEmitSignal = true ); 00083 00084 00095 Q_DECL_DEPRECATED void removeMapLayer( QString theLayerId, bool theEmitSignal = true ); 00096 00107 void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true ); 00108 00109 00115 void removeAllMapLayers(); 00116 00117 /* Clears all layer caches, resetting them to zero and 00118 * freeing up any memory they may have been using. Layer 00119 * caches are used to speed up rendering in certain situations 00120 * see ticket #1974 for more details. 00121 * @note this method was added in QGIS 1.4 00122 */ 00123 void clearAllLayerCaches(); 00124 00127 void reloadAllLayers(); 00128 00129 signals: 00130 00134 void layersWillBeRemoved( QStringList theLayerIds ); 00135 00140 void layerWillBeRemoved( QString theLayerId ); 00141 00145 void layersAdded( QList<QgsMapLayer *> theMapLayers ); 00150 void layerWasAdded( QgsMapLayer * theMapLayer ); 00151 00160 void removedAll(); 00161 00162 protected: 00163 00165 QgsMapLayerRegistry( QObject * parent = 0 ); 00166 00167 private: 00168 00169 static QgsMapLayerRegistry* mInstance; 00170 00171 QMap<QString, QgsMapLayer*> mMapLayers; 00172 00176 void connectNotify( const char * signal ); 00177 00178 00179 }; // class QgsMapLayerRegistry 00180 00181 #endif //QgsMapLayerRegistry_H 00182