Skip to content

Commit ec6b5a5

Browse files
committed
reduce verbosity of QgsDataItem
1 parent 4b7be2a commit ec6b5a5

File tree

4 files changed

+45
-42
lines changed

4 files changed

+45
-42
lines changed

src/app/qgisapp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,7 +2456,7 @@ bool QgisApp::askUserForZipItemLayers( QString path )
24562456
return false;
24572457

24582458
zipItem->populate();
2459-
QgsDebugMsg( QString( "Got zipitem with %1 children" ).arg( zipItem->rowCount() ) );
2459+
QgsDebugMsg( QString( "Path= %1 got zipitem with %2 children" ).arg( path ).arg( zipItem->rowCount() ) );
24602460

24612461
// if 1 or 0 child found, exit so a normal item is created by gdal or ogr provider
24622462
if ( zipItem->rowCount() <= 1 )
@@ -2487,7 +2487,7 @@ bool QgisApp::askUserForZipItemLayers( QString path )
24872487
{
24882488
QgsDataItem *item = zipItem->children()[i];
24892489
QgsLayerItem *layerItem = dynamic_cast<QgsLayerItem *>( item );
2490-
QgsDebugMsg( QString( "item path=%1 provider=" ).arg( item->path() ).arg( layerItem->providerKey() ) );
2490+
QgsDebugMsgLevel( QString( "item path=%1 provider=" ).arg( item->path() ).arg( layerItem->providerKey() ), 2 );
24912491
if ( layerItem && layerItem->providerKey() == "gdal" )
24922492
{
24932493
layers << QString( "%1|%2| |%3" ).arg( i ).arg( item->name() ).arg( "Raster" );
@@ -2514,7 +2514,7 @@ bool QgisApp::askUserForZipItemLayers( QString path )
25142514
// return true so dialog doesn't popup again (#6225) - hopefully this doesn't create other trouble
25152515
ok = true;
25162516
}
2517-
2517+
25182518
// add childItems
25192519
foreach ( QgsDataItem* item, childItems )
25202520
{

src/core/qgsdataitem.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ QgsDataItem::QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, QString n
156156

157157
QgsDataItem::~QgsDataItem()
158158
{
159-
QgsDebugMsg( "mName = " + mName + " mPath = " + mPath );
159+
QgsDebugMsgLevel( "mName = " + mName + " mPath = " + mPath, 2 );
160160
}
161161

162162
void QgsDataItem::emitBeginInsertItems( QgsDataItem* parent, int first, int last )
@@ -215,7 +215,7 @@ bool QgsDataItem::hasChildren()
215215

216216
void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
217217
{
218-
QgsDebugMsg( QString( "add child #%1 - %2 - %3" ).arg( mChildren.size() ).arg( child->mName ).arg( child->mType ) );
218+
QgsDebugMsg( QString( "path = %1 add child #%2 - %3 - %4" ).arg( mPath ).arg( mChildren.size() ).arg( child->mName ).arg( child->mType ) );
219219

220220
int i;
221221
if ( type() == Directory )
@@ -256,7 +256,7 @@ void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
256256
}
257257
void QgsDataItem::deleteChildItem( QgsDataItem * child )
258258
{
259-
QgsDebugMsg( "mName = " + child->mName );
259+
QgsDebugMsgLevel( "mName = " + child->mName, 2 );
260260
int i = mChildren.indexOf( child );
261261
Q_ASSERT( i >= 0 );
262262
emit beginRemoveItems( this, i, i );
@@ -267,7 +267,7 @@ void QgsDataItem::deleteChildItem( QgsDataItem * child )
267267

268268
QgsDataItem * QgsDataItem::removeChildItem( QgsDataItem * child )
269269
{
270-
QgsDebugMsg( "mName = " + child->mName );
270+
QgsDebugMsgLevel( "mName = " + child->mName, 2 );
271271
int i = mChildren.indexOf( child );
272272
Q_ASSERT( i >= 0 );
273273
emit beginRemoveItems( this, i, i );
@@ -289,7 +289,7 @@ int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )
289289
{
290290
for ( int i = 0; i < items.size(); i++ )
291291
{
292-
QgsDebugMsg( QString::number( i ) + " : " + items[i]->mPath + " x " + item->mPath );
292+
QgsDebugMsgLevel( QString::number( i ) + " : " + items[i]->mPath + " x " + item->mPath, 2 );
293293
if ( items[i]->equal( item ) )
294294
return i;
295295
}
@@ -298,7 +298,7 @@ int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )
298298

299299
void QgsDataItem::refresh()
300300
{
301-
QgsDebugMsg( "mPath = " + mPath );
301+
QgsDebugMsgLevel( "mPath = " + mPath, 2 );
302302

303303
QApplication::setOverrideCursor( Qt::WaitCursor );
304304

@@ -391,10 +391,10 @@ QgsDataCollectionItem::QgsDataCollectionItem( QgsDataItem* parent, QString name,
391391

392392
QgsDataCollectionItem::~QgsDataCollectionItem()
393393
{
394-
QgsDebugMsg( "Entered" );
394+
QgsDebugMsgLevel( "Entered", 2 );
395395
foreach ( QgsDataItem* i, mChildren )
396396
{
397-
QgsDebugMsg( QString( "delete child = 0x%0" ).arg(( qlonglong )i, 8, 16, QLatin1Char( '0' ) ) );
397+
QgsDebugMsgLevel( QString( "delete child = 0x%0" ).arg(( qlonglong )i, 8, 16, QLatin1Char( '0' ) ), 2 );
398398
delete i;
399399
}
400400
}
@@ -459,7 +459,7 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )
459459
foreach ( QString subdir, entries )
460460
{
461461
QString subdirPath = dir.absoluteFilePath( subdir );
462-
QgsDebugMsg( QString( "creating subdir: %1" ).arg( subdirPath ) );
462+
QgsDebugMsgLevel( QString( "creating subdir: %1" ).arg( subdirPath ), 2 );
463463

464464
QgsDirectoryItem *item = new QgsDirectoryItem( this, subdir, subdirPath );
465465
// propagate signals up to top
@@ -862,7 +862,7 @@ QVector<QgsDataItem*> QgsZipItem::createChildren( )
862862

863863
mZipFileList.clear();
864864

865-
QgsDebugMsg( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path() ).arg( name() ).arg( scanZipSetting ).arg( mVsiPrefix ) );
865+
QgsDebugMsgLevel( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path() ).arg( name() ).arg( scanZipSetting ).arg( mVsiPrefix ), 2 );
866866

867867
// if scanZipBrowser == no: skip to the next file
868868
if ( scanZipSetting == "no" )
@@ -886,7 +886,7 @@ QVector<QgsDataItem*> QgsZipItem::createChildren( )
886886
{
887887
QFileInfo info( fileName );
888888
tmpPath = mVsiPrefix + path() + "/" + fileName;
889-
QgsDebugMsg( "tmpPath = " + tmpPath );
889+
QgsDebugMsgLevel( "tmpPath = " + tmpPath, 3 );
890890

891891
// foreach( dataItem_t *dataItem, mDataItemPtr )
892892
for ( int i = 0; i < mProviderNames.size(); i++ )
@@ -909,18 +909,18 @@ QVector<QgsDataItem*> QgsZipItem::createChildren( )
909909
dataItem_t *dataItem = mDataItemPtr[i];
910910
if ( dataItem )
911911
{
912-
QgsDebugMsg( QString( "trying to load item %1 with %2" ).arg( tmpPath ).arg( mProviderNames[i] ) );
912+
QgsDebugMsgLevel( QString( "trying to load item %1 with %2" ).arg( tmpPath ).arg( mProviderNames[i] ), 3 );
913913
QgsDataItem * item = dataItem( tmpPath, this );
914914
if ( item )
915915
{
916-
QgsDebugMsg( "loaded item" );
916+
QgsDebugMsgLevel( "loaded item", 3 );
917917
childPath = tmpPath;
918918
children.append( item );
919919
break;
920920
}
921921
else
922922
{
923-
QgsDebugMsg( "not loaded item" );
923+
QgsDebugMsgLevel( "not loaded item", 3 );
924924
}
925925
}
926926
}
@@ -965,7 +965,7 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QStrin
965965
QgsZipItem * zipItem = 0;
966966
bool populated = false;
967967

968-
QgsDebugMsg( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path ).arg( name ).arg( scanZipSetting ).arg( vsiPrefix ) );
968+
QgsDebugMsgLevel( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path ).arg( name ).arg( scanZipSetting ).arg( vsiPrefix ), 3 );
969969

970970
// if scanZipBrowser == no: don't read the zip file
971971
if ( scanZipSetting == "no" )
@@ -1001,18 +1001,18 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QStrin
10011001
{
10021002
zipItem->populate();
10031003
populated = true; // there is no QgsDataItem::isPopulated() function
1004-
QgsDebugMsg( QString( "Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->rowCount() ).arg( zipItem->path() ).arg( zipItem->name() ) );
1004+
QgsDebugMsgLevel( QString( "Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->rowCount() ).arg( zipItem->path() ).arg( zipItem->name() ), 3 );
10051005
}
10061006
else
10071007
{
1008-
QgsDebugMsg( QString( "Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->path() ).arg( zipItem->name() ) );
1008+
QgsDebugMsgLevel( QString( "Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->path() ).arg( zipItem->name() ), 3 );
10091009
}
10101010
}
10111011

10121012
// only display if has children or if is not populated
10131013
if ( zipItem && ( !populated || zipItem->rowCount() > 1 ) )
10141014
{
1015-
QgsDebugMsg( "returning zipItem" );
1015+
QgsDebugMsgLevel( "returning zipItem", 3 );
10161016
return zipItem;
10171017
}
10181018
// if 1 or 0 child found, create a single data item using the normal path or the full path given by QgsZipItem
@@ -1025,7 +1025,7 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QStrin
10251025
delete zipItem;
10261026
}
10271027

1028-
QgsDebugMsg( QString( "will try to create a normal dataItem from path= %2 or %3" ).arg( path ).arg( vsiPath ) );
1028+
QgsDebugMsgLevel( QString( "will try to create a normal dataItem from path= %2 or %3" ).arg( path ).arg( vsiPath ), 3 );
10291029

10301030
// try to open using registered providers (gdal and ogr)
10311031
for ( int i = 0; i < mProviderNames.size(); i++ )
@@ -1062,7 +1062,7 @@ const QStringList & QgsZipItem::getZipFileList()
10621062
QSettings settings;
10631063
QString scanZipSetting = settings.value( "/qgis/scanZipInBrowser", "basic" ).toString();
10641064

1065-
QgsDebugMsg( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path() ).arg( name() ).arg( scanZipSetting ).arg( mVsiPrefix ) );
1065+
QgsDebugMsgLevel( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path() ).arg( name() ).arg( scanZipSetting ).arg( mVsiPrefix ), 3 );
10661066

10671067
// if scanZipBrowser == no: skip to the next file
10681068
if ( scanZipSetting == "no" )
@@ -1071,14 +1071,14 @@ const QStringList & QgsZipItem::getZipFileList()
10711071
}
10721072

10731073
// get list of files inside zip file
1074-
QgsDebugMsg( QString( "Open file %1 with gdal vsi" ).arg( mVsiPrefix + path() ) );
1074+
QgsDebugMsgLevel( QString( "Open file %1 with gdal vsi" ).arg( mVsiPrefix + path() ), 3 );
10751075
char **papszSiblingFiles = VSIReadDirRecursive1( QString( mVsiPrefix + path() ).toLocal8Bit().constData() );
10761076
if ( papszSiblingFiles )
10771077
{
10781078
for ( int i = 0; i < CSLCount( papszSiblingFiles ); i++ )
10791079
{
10801080
tmpPath = papszSiblingFiles[i];
1081-
QgsDebugMsg( QString( "Read file %1" ).arg( tmpPath ) );
1081+
QgsDebugMsgLevel( QString( "Read file %1" ).arg( tmpPath ), 3 );
10821082
// skip directories (files ending with /)
10831083
if ( tmpPath.right( 1 ) != "/" )
10841084
mZipFileList << tmpPath;

src/providers/gdal/qgsgdaldataitems.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ QGISEXTERN int dataCapabilities()
137137

138138
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
139139
{
140-
QgsDebugMsg( "thePath = " + thePath );
140+
if ( thePath.isEmpty() )
141+
return 0;
142+
143+
QgsDebugMsgLevel( "thePath = " + thePath, 2 );
141144

142145
// zip settings + info
143146
QSettings settings;
@@ -157,8 +160,8 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
157160
info.setFile( thePath );
158161
QString name = info.fileName();
159162

160-
QgsDebugMsg( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name
161-
+ " suffix= " + suffix + " vsiPrefix= " + vsiPrefix );
163+
QgsDebugMsgLevel( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name
164+
+ " suffix= " + suffix + " vsiPrefix= " + vsiPrefix, 3 );
162165

163166
// allow only normal files or VSIFILE items to continue
164167
if ( !info.isFile() && vsiPrefix == "" )
@@ -168,8 +171,8 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
168171
if ( extensions.isEmpty() )
169172
{
170173
buildSupportedRasterFileFilterAndExtensions( filterString, extensions, wildcards );
171-
QgsDebugMsg( "extensions: " + extensions.join( " " ) );
172-
QgsDebugMsg( "wildcards: " + wildcards.join( " " ) );
174+
QgsDebugMsgLevel( "extensions: " + extensions.join( " " ), 2 );
175+
QgsDebugMsgLevel( "wildcards: " + wildcards.join( " " ), 2 );
173176
}
174177

175178
// skip *.aux.xml files (GDAL auxilary metadata files)
@@ -225,15 +228,15 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
225228
CPLErrorReset();
226229
if ( ! GDALIdentifyDriver( thePath.toLocal8Bit().constData(), 0 ) )
227230
{
228-
QgsDebugMsg( "Skipping VRT file because root is not a GDAL VRT" );
231+
QgsDebugMsgLevel( "Skipping VRT file because root is not a GDAL VRT", 2 );
229232
CPLPopErrorHandler();
230233
return 0;
231234
}
232235
CPLPopErrorHandler();
233236
}
234237
// add the item
235238
QStringList sublayers;
236-
QgsDebugMsg( QString( "adding item name=%1 thePath=%2" ).arg( name ).arg( thePath ) );
239+
QgsDebugMsgLevel( QString( "adding item name=%1 thePath=%2" ).arg( name ).arg( thePath ), 2 );
237240
QgsLayerItem * item = new QgsGdalLayerItem( parentItem, name, thePath, thePath, &sublayers );
238241
if ( item )
239242
return item;
@@ -257,7 +260,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
257260

258261
GDALClose( hDS );
259262

260-
QgsDebugMsg( "GdalDataset opened " + thePath );
263+
QgsDebugMsgLevel( "GdalDataset opened " + thePath, 2 );
261264

262265
QgsLayerItem * item = new QgsGdalLayerItem( parentItem, name, thePath, thePath,
263266
&sublayers );

src/providers/ogr/qgsogrdataitems.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static QgsOgrLayerItem* dataItemForLayer( QgsDataItem* parentItem, QString name,
171171
break;
172172
}
173173

174-
QgsDebugMsg( QString( "ogrType = %1 layertype = %2" ).arg( ogrType ).arg( layerType ) );
174+
QgsDebugMsgLevel( QString( "ogrType = %1 layertype = %2" ).arg( ogrType ).arg( layerType ), 2 );
175175

176176
QString layerUri = path;
177177

@@ -186,7 +186,7 @@ static QgsOgrLayerItem* dataItemForLayer( QgsDataItem* parentItem, QString name,
186186
path += "/" + name;
187187
}
188188

189-
QgsDebugMsg( "OGR layer uri : " + layerUri );
189+
QgsDebugMsgLevel( "OGR layer uri : " + layerUri, 2 );
190190

191191
return new QgsOgrLayerItem( parentItem, name, path, layerUri, layerType );
192192
}
@@ -235,7 +235,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
235235
if ( thePath.isEmpty() )
236236
return 0;
237237

238-
QgsDebugMsg( "thePath: " + thePath );
238+
QgsDebugMsgLevel( "thePath: " + thePath, 2 );
239239

240240
// zip settings + info
241241
QSettings settings;
@@ -255,8 +255,8 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
255255
info.setFile( thePath );
256256
QString name = info.fileName();
257257

258-
QgsDebugMsg( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name
259-
+ " suffix= " + suffix + " vsiPrefix= " + vsiPrefix );
258+
QgsDebugMsgLevel( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name
259+
+ " suffix= " + suffix + " vsiPrefix= " + vsiPrefix, 3 );
260260

261261
// allow only normal files or VSIFILE items to continue
262262
if ( !info.isFile() && vsiPrefix == "" )
@@ -334,7 +334,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
334334
CPLPopErrorHandler();
335335
if ( ! hDataSource )
336336
{
337-
QgsDebugMsg( "Skipping VRT file because root is not a OGR VRT" );
337+
QgsDebugMsgLevel( "Skipping VRT file because root is not a OGR VRT", 2 );
338338
return 0;
339339
}
340340
OGR_DS_Destroy( hDataSource );
@@ -363,20 +363,20 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
363363
}
364364

365365
QString driverName = OGR_Dr_GetName( hDriver );
366-
QgsDebugMsg( "OGR Driver : " + driverName );
366+
QgsDebugMsgLevel( "OGR Driver : " + driverName, 2 );
367367

368368
int numLayers = OGR_DS_GetLayerCount( hDataSource );
369369

370370
QgsDataItem* item = 0;
371371

372372
if ( numLayers == 1 )
373373
{
374-
QgsDebugMsg( QString( "using name = %1" ).arg( name ) );
374+
QgsDebugMsgLevel( QString( "using name = %1" ).arg( name ), 2 );
375375
item = dataItemForLayer( parentItem, name, thePath, hDataSource, 0 );
376376
}
377377
else if ( numLayers > 1 )
378378
{
379-
QgsDebugMsg( QString( "using name = %1" ).arg( name ) );
379+
QgsDebugMsgLevel( QString( "using name = %1" ).arg( name ), 2 );
380380
item = new QgsOgrDataCollectionItem( parentItem, name, thePath );
381381
}
382382

0 commit comments

Comments
 (0)