Skip to content

Commit

Permalink
reduce verbosity of QgsDataItem
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennesky committed Aug 27, 2012
1 parent 4b7be2a commit ec6b5a5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 42 deletions.
6 changes: 3 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -2456,7 +2456,7 @@ bool QgisApp::askUserForZipItemLayers( QString path )
return false;

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

// if 1 or 0 child found, exit so a normal item is created by gdal or ogr provider
if ( zipItem->rowCount() <= 1 )
Expand Down Expand Up @@ -2487,7 +2487,7 @@ bool QgisApp::askUserForZipItemLayers( QString path )
{
QgsDataItem *item = zipItem->children()[i];
QgsLayerItem *layerItem = dynamic_cast<QgsLayerItem *>( item );
QgsDebugMsg( QString( "item path=%1 provider=" ).arg( item->path() ).arg( layerItem->providerKey() ) );
QgsDebugMsgLevel( QString( "item path=%1 provider=" ).arg( item->path() ).arg( layerItem->providerKey() ), 2 );
if ( layerItem && layerItem->providerKey() == "gdal" )
{
layers << QString( "%1|%2| |%3" ).arg( i ).arg( item->name() ).arg( "Raster" );
Expand All @@ -2514,7 +2514,7 @@ bool QgisApp::askUserForZipItemLayers( QString path )
// return true so dialog doesn't popup again (#6225) - hopefully this doesn't create other trouble
ok = true;
}

// add childItems
foreach ( QgsDataItem* item, childItems )
{
Expand Down
44 changes: 22 additions & 22 deletions src/core/qgsdataitem.cpp
Expand Up @@ -156,7 +156,7 @@ QgsDataItem::QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, QString n

QgsDataItem::~QgsDataItem()
{
QgsDebugMsg( "mName = " + mName + " mPath = " + mPath );
QgsDebugMsgLevel( "mName = " + mName + " mPath = " + mPath, 2 );
}

void QgsDataItem::emitBeginInsertItems( QgsDataItem* parent, int first, int last )
Expand Down Expand Up @@ -215,7 +215,7 @@ bool QgsDataItem::hasChildren()

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

int i;
if ( type() == Directory )
Expand Down Expand Up @@ -256,7 +256,7 @@ void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
}
void QgsDataItem::deleteChildItem( QgsDataItem * child )
{
QgsDebugMsg( "mName = " + child->mName );
QgsDebugMsgLevel( "mName = " + child->mName, 2 );
int i = mChildren.indexOf( child );
Q_ASSERT( i >= 0 );
emit beginRemoveItems( this, i, i );
Expand All @@ -267,7 +267,7 @@ void QgsDataItem::deleteChildItem( QgsDataItem * child )

QgsDataItem * QgsDataItem::removeChildItem( QgsDataItem * child )
{
QgsDebugMsg( "mName = " + child->mName );
QgsDebugMsgLevel( "mName = " + child->mName, 2 );
int i = mChildren.indexOf( child );
Q_ASSERT( i >= 0 );
emit beginRemoveItems( this, i, i );
Expand All @@ -289,7 +289,7 @@ int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )
{
for ( int i = 0; i < items.size(); i++ )
{
QgsDebugMsg( QString::number( i ) + " : " + items[i]->mPath + " x " + item->mPath );
QgsDebugMsgLevel( QString::number( i ) + " : " + items[i]->mPath + " x " + item->mPath, 2 );
if ( items[i]->equal( item ) )
return i;
}
Expand All @@ -298,7 +298,7 @@ int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )

void QgsDataItem::refresh()
{
QgsDebugMsg( "mPath = " + mPath );
QgsDebugMsgLevel( "mPath = " + mPath, 2 );

QApplication::setOverrideCursor( Qt::WaitCursor );

Expand Down Expand Up @@ -391,10 +391,10 @@ QgsDataCollectionItem::QgsDataCollectionItem( QgsDataItem* parent, QString name,

QgsDataCollectionItem::~QgsDataCollectionItem()
{
QgsDebugMsg( "Entered" );
QgsDebugMsgLevel( "Entered", 2 );
foreach ( QgsDataItem* i, mChildren )
{
QgsDebugMsg( QString( "delete child = 0x%0" ).arg(( qlonglong )i, 8, 16, QLatin1Char( '0' ) ) );
QgsDebugMsgLevel( QString( "delete child = 0x%0" ).arg(( qlonglong )i, 8, 16, QLatin1Char( '0' ) ), 2 );
delete i;
}
}
Expand Down Expand Up @@ -459,7 +459,7 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )
foreach ( QString subdir, entries )
{
QString subdirPath = dir.absoluteFilePath( subdir );
QgsDebugMsg( QString( "creating subdir: %1" ).arg( subdirPath ) );
QgsDebugMsgLevel( QString( "creating subdir: %1" ).arg( subdirPath ), 2 );

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

mZipFileList.clear();

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

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

// foreach( dataItem_t *dataItem, mDataItemPtr )
for ( int i = 0; i < mProviderNames.size(); i++ )
Expand All @@ -909,18 +909,18 @@ QVector<QgsDataItem*> QgsZipItem::createChildren( )
dataItem_t *dataItem = mDataItemPtr[i];
if ( dataItem )
{
QgsDebugMsg( QString( "trying to load item %1 with %2" ).arg( tmpPath ).arg( mProviderNames[i] ) );
QgsDebugMsgLevel( QString( "trying to load item %1 with %2" ).arg( tmpPath ).arg( mProviderNames[i] ), 3 );
QgsDataItem * item = dataItem( tmpPath, this );
if ( item )
{
QgsDebugMsg( "loaded item" );
QgsDebugMsgLevel( "loaded item", 3 );
childPath = tmpPath;
children.append( item );
break;
}
else
{
QgsDebugMsg( "not loaded item" );
QgsDebugMsgLevel( "not loaded item", 3 );
}
}
}
Expand Down Expand Up @@ -965,7 +965,7 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QStrin
QgsZipItem * zipItem = 0;
bool populated = false;

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

// if scanZipBrowser == no: don't read the zip file
if ( scanZipSetting == "no" )
Expand Down Expand Up @@ -1001,18 +1001,18 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QStrin
{
zipItem->populate();
populated = true; // there is no QgsDataItem::isPopulated() function
QgsDebugMsg( QString( "Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->rowCount() ).arg( zipItem->path() ).arg( zipItem->name() ) );
QgsDebugMsgLevel( QString( "Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->rowCount() ).arg( zipItem->path() ).arg( zipItem->name() ), 3 );
}
else
{
QgsDebugMsg( QString( "Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->path() ).arg( zipItem->name() ) );
QgsDebugMsgLevel( QString( "Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->path() ).arg( zipItem->name() ), 3 );
}
}

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

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

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

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

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

// get list of files inside zip file
QgsDebugMsg( QString( "Open file %1 with gdal vsi" ).arg( mVsiPrefix + path() ) );
QgsDebugMsgLevel( QString( "Open file %1 with gdal vsi" ).arg( mVsiPrefix + path() ), 3 );
char **papszSiblingFiles = VSIReadDirRecursive1( QString( mVsiPrefix + path() ).toLocal8Bit().constData() );
if ( papszSiblingFiles )
{
for ( int i = 0; i < CSLCount( papszSiblingFiles ); i++ )
{
tmpPath = papszSiblingFiles[i];
QgsDebugMsg( QString( "Read file %1" ).arg( tmpPath ) );
QgsDebugMsgLevel( QString( "Read file %1" ).arg( tmpPath ), 3 );
// skip directories (files ending with /)
if ( tmpPath.right( 1 ) != "/" )
mZipFileList << tmpPath;
Expand Down
19 changes: 11 additions & 8 deletions src/providers/gdal/qgsgdaldataitems.cpp
Expand Up @@ -137,7 +137,10 @@ QGISEXTERN int dataCapabilities()

QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
{
QgsDebugMsg( "thePath = " + thePath );
if ( thePath.isEmpty() )
return 0;

QgsDebugMsgLevel( "thePath = " + thePath, 2 );

// zip settings + info
QSettings settings;
Expand All @@ -157,8 +160,8 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
info.setFile( thePath );
QString name = info.fileName();

QgsDebugMsg( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name
+ " suffix= " + suffix + " vsiPrefix= " + vsiPrefix );
QgsDebugMsgLevel( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name
+ " suffix= " + suffix + " vsiPrefix= " + vsiPrefix, 3 );

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

// skip *.aux.xml files (GDAL auxilary metadata files)
Expand Down Expand Up @@ -225,15 +228,15 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
CPLErrorReset();
if ( ! GDALIdentifyDriver( thePath.toLocal8Bit().constData(), 0 ) )
{
QgsDebugMsg( "Skipping VRT file because root is not a GDAL VRT" );
QgsDebugMsgLevel( "Skipping VRT file because root is not a GDAL VRT", 2 );
CPLPopErrorHandler();
return 0;
}
CPLPopErrorHandler();
}
// add the item
QStringList sublayers;
QgsDebugMsg( QString( "adding item name=%1 thePath=%2" ).arg( name ).arg( thePath ) );
QgsDebugMsgLevel( QString( "adding item name=%1 thePath=%2" ).arg( name ).arg( thePath ), 2 );
QgsLayerItem * item = new QgsGdalLayerItem( parentItem, name, thePath, thePath, &sublayers );
if ( item )
return item;
Expand All @@ -257,7 +260,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )

GDALClose( hDS );

QgsDebugMsg( "GdalDataset opened " + thePath );
QgsDebugMsgLevel( "GdalDataset opened " + thePath, 2 );

QgsLayerItem * item = new QgsGdalLayerItem( parentItem, name, thePath, thePath,
&sublayers );
Expand Down
18 changes: 9 additions & 9 deletions src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -171,7 +171,7 @@ static QgsOgrLayerItem* dataItemForLayer( QgsDataItem* parentItem, QString name,
break;
}

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

QString layerUri = path;

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

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

return new QgsOgrLayerItem( parentItem, name, path, layerUri, layerType );
}
Expand Down Expand Up @@ -235,7 +235,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
if ( thePath.isEmpty() )
return 0;

QgsDebugMsg( "thePath: " + thePath );
QgsDebugMsgLevel( "thePath: " + thePath, 2 );

// zip settings + info
QSettings settings;
Expand All @@ -255,8 +255,8 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
info.setFile( thePath );
QString name = info.fileName();

QgsDebugMsg( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name
+ " suffix= " + suffix + " vsiPrefix= " + vsiPrefix );
QgsDebugMsgLevel( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name
+ " suffix= " + suffix + " vsiPrefix= " + vsiPrefix, 3 );

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

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

int numLayers = OGR_DS_GetLayerCount( hDataSource );

QgsDataItem* item = 0;

if ( numLayers == 1 )
{
QgsDebugMsg( QString( "using name = %1" ).arg( name ) );
QgsDebugMsgLevel( QString( "using name = %1" ).arg( name ), 2 );
item = dataItemForLayer( parentItem, name, thePath, hDataSource, 0 );
}
else if ( numLayers > 1 )
{
QgsDebugMsg( QString( "using name = %1" ).arg( name ) );
QgsDebugMsgLevel( QString( "using name = %1" ).arg( name ), 2 );
item = new QgsOgrDataCollectionItem( parentItem, name, thePath );
}

Expand Down

0 comments on commit ec6b5a5

Please sign in to comment.