19
19
#include < iostream>
20
20
21
21
#include " qgsmaplayerregistry.h"
22
+ #include " qgslogger.h"
22
23
#include " qgsproject.h"
23
24
24
25
@@ -41,9 +42,7 @@ QgsMapLayerRegistry *QgsMapLayerRegistry::instance()
41
42
42
43
QgsMapLayerRegistry::QgsMapLayerRegistry (QObject *parent, const char *name) : QObject(parent,name)
43
44
{
44
- #ifdef QGISDEBUG
45
- std::cout << " QgsMapLayerRegistry created!" << std::endl;
46
- #endif
45
+ QgsDebugMsg (" QgsMapLayerRegistry created!" );
47
46
// constructor does nothing
48
47
}
49
48
// get the layer count (number of registered layers)
@@ -93,9 +92,7 @@ QgsMapLayer * QgsMapLayerRegistry::mapLayer(QString theLayerId)
93
92
QgsMapLayer *
94
93
QgsMapLayerRegistry::addMapLayer ( QgsMapLayer * theMapLayer, bool theEmitSignal )
95
94
{
96
- #ifdef QGISDEBUG
97
- std::cout << " QgsMapLayerRegistry::addMaplayer - '" << theMapLayer->name ().toLocal8Bit ().data () << " '." << std::endl;
98
- #endif
95
+ QgsDebugMsg (" QgsMapLayerRegistry::addMaplayer - '" + theMapLayer->name ());
99
96
// check the layer is not already registered!
100
97
std::map<QString,QgsMapLayer*>::iterator myIterator = mMapLayers .find (theMapLayer->getLayerID ());
101
98
// if myIterator returns mMapLayers.end() then it does not exist in registry and its safe to add it
@@ -113,10 +110,7 @@ QgsMapLayer *
113
110
}
114
111
else
115
112
{
116
-
117
- #ifdef QGISDEBUG
118
- std::cout << " addMaplayer - " << theMapLayer->name ().toLocal8Bit ().data () << " already registered" << std::endl;
119
- #endif
113
+ QgsDebugMsg (" addMaplayer - " + theMapLayer->name () + " already registered" );
120
114
return 0x0 ;
121
115
}
122
116
} // QgsMapLayerRegistry::addMapLayer
@@ -125,31 +119,21 @@ QgsMapLayer *
125
119
126
120
void QgsMapLayerRegistry::removeMapLayer (QString theLayerId, bool theEmitSignal)
127
121
{
128
- #ifdef QGISDEBUG
129
- std::cout << " QgsMapLayerRegistry::removemaplayer - emitting signal to notify all users of this layer to release it." << std::endl;
130
- #endif
122
+ QgsDebugMsg (" QgsMapLayerRegistry::removemaplayer - emitting signal to notify all users of this layer to release it." );
131
123
if (theEmitSignal)
132
124
emit layerWillBeRemoved (theLayerId);
133
- #ifdef QGISDEBUG
134
- std::cout << " QgsMapLayerRegistry::removemaplayer - deleting map layer." << std::endl;
135
- #endif
125
+ QgsDebugMsg (" QgsMapLayerRegistry::removemaplayer - deleting map layer." );
136
126
delete mMapLayers [theLayerId];
137
- #ifdef QGISDEBUG
138
- std::cout << " QgsMapLayerRegistry::removemaplayer - unregistering map layer." << std::endl;
139
- #endif
127
+ QgsDebugMsg (" QgsMapLayerRegistry::removemaplayer - unregistering map layer." );
140
128
mMapLayers .erase (theLayerId);
141
- #ifdef QGISDEBUG
142
- std::cout << " QgsMapLayerRegistry::removemaplayer - operation complete." << std::endl;
143
- #endif
129
+ QgsDebugMsg (" QgsMapLayerRegistry::removemaplayer - operation complete." );
144
130
// notify the project we've made a change
145
131
QgsProject::instance ()->dirty (true );
146
132
}
147
133
148
134
void QgsMapLayerRegistry::removeAllMapLayers ()
149
135
{
150
- #ifdef QGISDEBUG
151
- std::cout << " QgsMapLayerRegistry::removeAllMapLayers" << std::endl;
152
- #endif
136
+ QgsDebugMsg (" QgsMapLayerRegistry::removeAllMapLayers" );
153
137
154
138
// moved before physically removing the layers
155
139
emit removedAll (); // now let all canvas Observers know to clear
@@ -175,18 +159,13 @@ void QgsMapLayerRegistry::removeAllMapLayers()
175
159
176
160
std::map<QString,QgsMapLayer*> & QgsMapLayerRegistry::mapLayers ()
177
161
{
178
- #ifdef QGISDEBUG
179
- std::cout << " QgsMapLayerRegistry::mapLayers" << std::endl;
180
- #endif
181
-
162
+ QgsDebugMsg (" QgsMapLayerRegistry::mapLayers" );
182
163
return mMapLayers ;
183
164
}
184
165
185
166
186
167
187
168
void QgsMapLayerRegistry::connectNotify ( const char * signal )
188
169
{
189
- #ifdef QGISDEBUG
190
- std::cerr << " QgsMapLayerRegistry connected to " << signal << " \n " ;
191
- #endif
170
+ QgsDebugMsg (" QgsMapLayerRegistry connected to " + QString (signal));
192
171
} // QgsMapLayerRegistry::connectNotify
0 commit comments