Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make grass plugin/provider less debug heavy
  • Loading branch information
nyalldawson committed Apr 11, 2023
1 parent 9aaf085 commit f1fd152
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 157 deletions.
66 changes: 33 additions & 33 deletions src/plugins/grass/qgsgrassmoduleoptions.cpp
Expand Up @@ -69,7 +69,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
, mXName( xname )
{
//QgsDebugMsgLevel( "called.", 4 );
QgsDebugMsg( QString( "PATH = %1" ).arg( getenv( "PATH" ) ) );
QgsDebugMsgLevel( QString( "PATH = %1" ).arg( getenv( "PATH" ) ), 2 );

//
//Set up dynamic inside a scroll box
Expand Down Expand Up @@ -153,7 +153,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
}

QString optionType = confDomElement.tagName();
QgsDebugMsg( "optionType = " + optionType );
QgsDebugMsgLevel( "optionType = " + optionType, 3 );

if ( confDomElement.attribute( QStringLiteral( "advanced" ), QStringLiteral( "no" ) ) == QLatin1String( "yes" ) )
{
Expand All @@ -165,7 +165,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
}

QString key = confDomElement.attribute( QStringLiteral( "key" ) );
QgsDebugMsg( "key = " + key );
QgsDebugMsgLevel( "key = " + key, 3 );

QDomNode gnode = QgsGrassModuleParam::nodeByKey( descDocElem, key );
if ( gnode.isNull() )
Expand All @@ -187,7 +187,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
QString element = promptElem.attribute( QStringLiteral( "element" ) );
QString age = promptElem.attribute( QStringLiteral( "age" ) );

//QgsDebugMsg("element = " + element + " age = " + age);
//QgsDebugMsgLevel("element = " + element + " age = " + age, 3);
if ( age == QLatin1String( "old" ) && ( element == QLatin1String( "vector" ) || element == QLatin1String( "cell" ) ||
element == QLatin1String( "strds" ) || element == QLatin1String( "stvds" ) ||
element == QLatin1String( "str3ds" ) || element == QLatin1String( "stds" ) )
Expand Down Expand Up @@ -218,7 +218,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
// G_OPT_DB_COLUMN may be also used for new columns (v.in.db) so we check also if there is at least one input vector
// but a vector input may also exist (v.random).
QList<QDomNode> vectorNodes = QgsGrassModuleParam::nodesByType( descDocElem, G_OPT_V_INPUT, QStringLiteral( "old" ) );
QgsDebugMsg( QString( "vectorNodes.size() = %1" ).arg( vectorNodes.size() ) );
QgsDebugMsgLevel( QString( "vectorNodes.size() = %1" ).arg( vectorNodes.size() ), 3 );
if ( !vectorNodes.isEmpty() )
{
mErrors << tr( "Option '%1' should be configured as field" ).arg( so->key() );
Expand Down Expand Up @@ -309,12 +309,12 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
if ( !confDomElement.isNull() )
{
QString optionType = confDomElement.tagName();
QgsDebugMsg( "optionType = " + optionType );
QgsDebugMsgLevel( "optionType = " + optionType, 3 );

if ( optionType == QLatin1String( "flag" ) )
{
QString name = confDomElement.attribute( QStringLiteral( "name" ) ).trimmed();
QgsDebugMsg( "name = " + name );
QgsDebugMsgLevel( "name = " + name, 3 );
mFlagNames.append( name );
}
}
Expand All @@ -338,7 +338,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
}
if ( vectorInputs.size() == 1 )
{
QgsDebugMsg( "One input found, try to connect with column options" );
QgsDebugMsgLevel( "One input found, try to connect with column options", 3 );
QgsGrassModuleInput *vectorInput = vectorInputs[0];
for ( QgsGrassModuleParam *param : mParams )
{
Expand All @@ -347,7 +347,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
{
if ( !moduleField->layerInput() )
{
QgsDebugMsg( "Set " + vectorInput->key() + " as layer input for " + moduleField->key() );
QgsDebugMsgLevel( "Set " + vectorInput->key() + " as layer input for " + moduleField->key(), 3 );
moduleField->setLayerInput( vectorInput );
}
}
Expand Down Expand Up @@ -406,7 +406,7 @@ QStringList QgsGrassModuleStandardOptions::arguments()
// id is not used in fact, was intended for field, but key is used instead
QgsGrassModuleParam *QgsGrassModuleStandardOptions::itemByKey( QString key )
{
QgsDebugMsg( "key = " + key );
QgsDebugMsgLevel( "key = " + key, 3 );

for ( int i = 0; i < mParams.size(); i++ )
{
Expand All @@ -422,7 +422,7 @@ QgsGrassModuleParam *QgsGrassModuleStandardOptions::itemByKey( QString key )

QgsGrassModuleParam *QgsGrassModuleStandardOptions::item( QString id )
{
QgsDebugMsg( "id = " + id );
QgsDebugMsgLevel( "id = " + id, 3 );

for ( int i = 0; i < mParams.size(); i++ )
{
Expand All @@ -447,7 +447,7 @@ QStringList QgsGrassModuleStandardOptions::checkOutput()
if ( !opt )
continue;

QgsDebugMsg( "opt->key() = " + opt->key() );
QgsDebugMsgLevel( "opt->key() = " + opt->key(), 3 );

if ( opt->isOutput() )
{
Expand Down Expand Up @@ -517,16 +517,16 @@ void QgsGrassModuleStandardOptions::freezeOutput( bool freeze )
{
continue;
}
QgsDebugMsg( "opt->key() = " + opt->key() );
QgsDebugMsgLevel( "opt->key() = " + opt->key(), 3 );

if ( opt->outputType() == QgsGrassModuleOption::Vector )
{
QgsDebugMsg( "freeze vector layers" );
QgsDebugMsgLevel( "freeze vector layers", 3 );

QgsGrassObject outputObject = QgsGrass::getDefaultMapsetObject();
outputObject.setName( opt->value() );
outputObject.setType( QgsGrassObject::Vector );
QgsDebugMsg( "outputObject = " + outputObject.toString() );
QgsDebugMsgLevel( "outputObject = " + outputObject.toString(), 3 );

for ( QgsGrassProvider *provider : grassProviders() )
{
Expand All @@ -536,25 +536,25 @@ void QgsGrassModuleStandardOptions::freezeOutput( bool freeze )
{
if ( freeze )
{
QgsDebugMsg( "freeze map " + provider->dataSourceUri() );
QgsDebugMsgLevel( "freeze map " + provider->dataSourceUri(), 3 );
provider->freeze();
}
else
{
QgsDebugMsg( "thaw map " + provider->dataSourceUri() );
QgsDebugMsgLevel( "thaw map " + provider->dataSourceUri(), 3 );
provider->thaw();
}
}
}
}
else if ( opt->outputType() == QgsGrassModuleOption::Raster )
{
QgsDebugMsg( "freeze raster layers" );
QgsDebugMsgLevel( "freeze raster layers", 3 );

QgsGrassObject outputObject = QgsGrass::getDefaultMapsetObject();
outputObject.setName( opt->value() );
outputObject.setType( QgsGrassObject::Raster );
QgsDebugMsg( "outputObject = " + outputObject.toString() );
QgsDebugMsgLevel( "outputObject = " + outputObject.toString(), 3 );

for ( QgsGrassRasterProvider *provider : grassRasterProviders() )
{
Expand All @@ -564,12 +564,12 @@ void QgsGrassModuleStandardOptions::freezeOutput( bool freeze )
{
if ( freeze )
{
QgsDebugMsg( "freeze map " + provider->dataSourceUri() );
QgsDebugMsgLevel( "freeze map " + provider->dataSourceUri(), 3 );
provider->freeze();
}
else
{
QgsDebugMsg( "thaw map " + provider->dataSourceUri() );
QgsDebugMsgLevel( "thaw map " + provider->dataSourceUri(), 3 );
provider->thaw();
}
}
Expand All @@ -589,7 +589,7 @@ QStringList QgsGrassModuleStandardOptions::output( int type )
if ( !opt )
continue;

QgsDebugMsg( "opt->key() = " + opt->key() );
QgsDebugMsgLevel( "opt->key() = " + opt->key(), 3 );

if ( opt->isOutput() )
{
Expand Down Expand Up @@ -618,7 +618,7 @@ bool QgsGrassModuleStandardOptions::hasOutput( int type )
if ( !opt )
continue;

QgsDebugMsg( "opt->key() = " + opt->key() );
QgsDebugMsgLevel( "opt->key() = " + opt->key(), 3 );

if ( opt->isOutput() )
{
Expand Down Expand Up @@ -670,7 +670,7 @@ QStringList QgsGrassModuleStandardOptions::checkRegion()
if ( !item )
continue;

QgsDebugMsg( "currentMap = " + item->currentMap() );
QgsDebugMsgLevel( "currentMap = " + item->currentMap(), 3 );
// The input may be empty, it means input is not used.

if ( item->currentMap().isEmpty() )
Expand Down Expand Up @@ -757,7 +757,7 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, QgsCo
continue;
}

QgsDebugMsg( "currentMap = " + item->currentMap() );
QgsDebugMsgLevel( "currentMap = " + item->currentMap(), 3 );
// The input may be empty, it means input is not used.
if ( item->currentMap().isEmpty() )
{
Expand Down Expand Up @@ -827,7 +827,7 @@ bool QgsGrassModuleStandardOptions::usesRegion()
return true;
}

QgsDebugMsg( "NO usesRegion()" );
QgsDebugMsgLevel( "NO usesRegion()", 2 );
return false;
}

Expand All @@ -838,7 +838,7 @@ bool QgsGrassModuleStandardOptions::getCurrentMapRegion( QgsGrassModuleInput *in
return false;
}

QgsDebugMsg( "currentMap = " + input->currentMap() );
QgsDebugMsgLevel( "currentMap = " + input->currentMap(), 3 );
if ( input->currentMap().isEmpty() )
{
// The input may be empty, it means input is not used.
Expand Down Expand Up @@ -921,7 +921,7 @@ QDomDocument QgsGrassModuleStandardOptions::readInterfaceDescription( const QStr
// of the interface description (see https://github.com/qgis/QGIS/issues/14461)
QTextCodec *codec = nullptr;

QgsDebugMsg( "trying to get encoding name from XML interface description..." );
QgsDebugMsgLevel( "trying to get encoding name from XML interface description...", 3 );

// XXX: getting the encoding using a regular expression works
// until GRASS will use UTF-16 or UTF-32.
Expand All @@ -932,19 +932,19 @@ QDomDocument QgsGrassModuleStandardOptions::readInterfaceDescription( const QStr
if ( reg.indexIn( xmlDeclaration ) != -1 )
{
QByteArray enc = reg.cap( 2 ).toLocal8Bit();
QgsDebugMsg( QString( "found encoding name '%1'" ).arg( QString::fromUtf8( enc ) ) );
QgsDebugMsgLevel( QString( "found encoding name '%1'" ).arg( QString::fromUtf8( enc ) ), 3 );

codec = QTextCodec::codecForName( enc );
if ( !codec )
{
QgsDebugMsg( "unrecognized encoding name. Let's use 'System' codec" );
QgsDebugMsgLevel( "unrecognized encoding name. Let's use 'System' codec", 2 );
codec = QTextCodec::codecForName( "System" );
Q_ASSERT( codec );
}
}
else
{
QgsDebugMsg( "unable to get encoding name from XML content. Will let Qt detects encoding!" );
QgsDebugMsgLevel( "unable to get encoding name from XML content. Will let Qt detects encoding!", 2 );
}

bool ok = false;
Expand All @@ -953,11 +953,11 @@ QDomDocument QgsGrassModuleStandardOptions::readInterfaceDescription( const QStr

if ( codec )
{
QgsDebugMsg( QString( "parsing XML interface description using '%1' codec..." ).arg( QString::fromUtf8( codec->name() ) ) );
QgsDebugMsgLevel( QString( "parsing XML interface description using '%1' codec..." ).arg( QString::fromUtf8( codec->name() ) ), 3 );
ok = gDoc.setContent( codec->toUnicode( baDesc ), false, &err, &line, &column );
if ( !ok )
{
QgsDebugMsg( "parse FAILED. Will let Qt detects encoding" );
QgsDebugMsgLevel( "parse FAILED. Will let Qt detects encoding", 2 );
codec = nullptr;
}
}
Expand Down

0 comments on commit f1fd152

Please sign in to comment.