Skip to content
Permalink
Browse files

Fix clazy qstring-arg warnings

Avoid chained QString::arg() calls and instead use the multi-arg
overload to save memory allocations
  • Loading branch information
nyalldawson committed Oct 22, 2016
1 parent f267215 commit fae8071a1e3aa0b624a245da4ab9cca58f60b358
@@ -442,10 +442,10 @@ bool QgsProjectBookmarksTableModel::setData( const QModelIndex& index, const QVa
switch ( index.column() )
{
case 1:
QgsProject::instance()->writeEntry( "Bookmarks", QString( "/Row-%1/Name" ).arg( index.row() ), value.value<QString>() );
QgsProject::instance()->writeEntry( "Bookmarks", QString( "/Row-%1/Name" ).arg( index.row() ), value.toString() );
return true;
case 2:
QgsProject::instance()->writeEntry( "Bookmarks", QString( "/Row-%1/Project" ).arg( index.row() ), value.value<QString>() );
QgsProject::instance()->writeEntry( "Bookmarks", QString( "/Row-%1/Project" ).arg( index.row() ), value.toString() );
return true;
case 3:
QgsProject::instance()->writeEntry( "Bookmarks", QString( "/Row-%1/MinX" ).arg( index.row() ), value.toDouble() );
@@ -387,7 +387,7 @@ QgsGmlStreamingParser::QgsGmlStreamingParser( const QList<LayerProperties>& laye
if ( alreadyFoundGeometry )
{
QgsDebugMsg( QString( "Will ignore geometry field %1 from typename %2" ).
arg( mLayerProperties[i].mGeometryAttribute ).arg( mLayerProperties[i].mName ) );
arg( mLayerProperties[i].mGeometryAttribute, mLayerProperties[i].mName ) );
mLayerProperties[i].mGeometryAttribute.clear();
}
alreadyFoundGeometry = true;
@@ -291,12 +291,12 @@ QVariantList QgsJSONUtils::parseArray( const QString& json, QVariant::Type type
QVariantList result;
if ( error.error != QJsonParseError::NoError )
{
QgsLogger::warning( QString( "Cannot parse json (%1): %2" ).arg( error.errorString() ).arg( json ) );
QgsLogger::warning( QString( "Cannot parse json (%1): %2" ).arg( error.errorString(), json ) );
return result;
}
if ( !jsonDoc.isArray() )
{
QgsLogger::warning( QString( "Cannot parse json (%1) as array: %2" ).arg( error.errorString() ).arg( json ) );
QgsLogger::warning( QString( "Cannot parse json (%1) as array: %2" ).arg( error.errorString(), json ) );
return result;
}
Q_FOREACH ( const QJsonValue cur, jsonDoc.array() )
@@ -237,7 +237,7 @@ bool QgsSQLStatement::doBasicValidationChecks( QString& errorMsgOut ) const
{
if ( !errorMsgOut.isEmpty() )
errorMsgOut += " ";
errorMsgOut += QString( tr( "Table %1 is referenced by column %2, but not selected in FROM / JOIN." ) ).arg( pair.first ).arg( pair.second );
errorMsgOut += QString( tr( "Table %1 is referenced by column %2, but not selected in FROM / JOIN." ) ).arg( pair.first, pair.second );
}
}

@@ -362,7 +362,7 @@ QString QgsStringUtils::insertLinks( const QString& string, bool *foundLinks )
{
protoUrl.prepend( "http://" );
}
QString anchor = QString( "<a href=\"%1\">%2</a>" ).arg( Qt::escape( protoUrl ) ).arg( Qt::escape( url ) );
QString anchor = QString( "<a href=\"%1\">%2</a>" ).arg( Qt::escape( protoUrl ), Qt::escape( url ) );
converted.replace( urlRegEx.pos( 1 ), url.length(), anchor );
offset = urlRegEx.pos( 1 ) + anchor.length();
}
@@ -371,7 +371,7 @@ QString QgsStringUtils::insertLinks( const QString& string, bool *foundLinks )
{
found = true;
QString email = emailRegEx.cap( 1 );
QString anchor = QString( "<a href=\"mailto:%1\">%1</a>" ).arg( Qt::escape( email ) ).arg( Qt::escape( email ) );
QString anchor = QString( "<a href=\"mailto:%1\">%1</a>" ).arg( Qt::escape( email ), Qt::escape( email ) );
converted.replace( emailRegEx.pos( 1 ), email.length(), anchor );
offset = emailRegEx.pos( 1 ) + anchor.length();
}
@@ -281,7 +281,7 @@ void QgsVectorFileWriter::init( QString vectorFileName,
{
if ( fileEncoding.compare( metadata.compulsoryEncoding, Qt::CaseInsensitive ) != 0 )
{
QgsDebugMsg( QString( "forced %1 encoding for %2" ).arg( metadata.compulsoryEncoding ).arg( driverName ) );
QgsDebugMsg( QString( "forced %1 encoding for %2" ).arg( metadata.compulsoryEncoding, driverName ) );
fileEncoding = metadata.compulsoryEncoding;
}

@@ -793,9 +793,9 @@ void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList& f,
int size = f.size() > max ? max : f.size();
QString descriptions;
for ( int i = 0; i < size; i++ )
descriptions += QString( "<li>%1: <i>%2</i></li>" ).arg( f[i] ).arg( d[i] );
descriptions += QString( "<li>%1: <i>%2</i></li>" ).arg( f[i], d[i] );

QString msg = QString( "<b>%1</b><ul>%2</ul>" ).arg( tr( "Invalid fields" ) ).arg( descriptions ) ;
QString msg = QString( "<b>%1</b><ul>%2</ul>" ).arg( tr( "Invalid fields" ), descriptions ) ;

mInvalidConstraintMessage->setText( msg );
mTopMessageWidget->show();
@@ -171,8 +171,8 @@ bool QgsColorButton::event( QEvent *e )
int saturation = this->color().saturation();
QString info = QString( "HEX: %1 \n"
"RGB: %2 \n"
"HSV: %3,%4,%5" ).arg( name )
.arg( QgsSymbolLayerUtils::encodeColor( this->color() ) )
"HSV: %3,%4,%5" ).arg( name,
QgsSymbolLayerUtils::encodeColor( this->color() ) )
.arg( hue ).arg( saturation ).arg( value );
setToolTip( info );
}
@@ -150,7 +150,7 @@ void QgsAfsConnectionItem::deleteConnection()
QgsAfsLayerItem::QgsAfsLayerItem( QgsDataItem* parent, const QString &name, const QString &url, const QString &title, const QString& authid )
: QgsLayerItem( parent, title, parent->path() + "/" + name, QString(), QgsLayerItem::Vector, "arcgisfeatureserver" )
{
mUri = QString( "crs='%1' url='%2'" ).arg( authid ).arg( url );
mUri = QString( "crs='%1' url='%2'" ).arg( authid, url );
setState( Populated );
mIconName = "mIconConnect.png";
}
@@ -118,7 +118,7 @@ QgsAfsProvider::QgsAfsProvider( const QString& uri )
QVariantMap objectIdData = QgsArcGisRestUtils::getObjectIds( mDataSource.param( "url" ), errorTitle, errorMessage );
if ( objectIdData.isEmpty() )
{
appendError( QgsErrorMessage( tr( "getObjectIds failed: %1 - %2" ).arg( errorTitle ).arg( errorMessage ), "AFSProvider" ) );
appendError( QgsErrorMessage( tr( "getObjectIds failed: %1 - %2" ).arg( errorTitle, errorMessage ), "AFSProvider" ) );
return;
}
if ( !objectIdData["objectIdFieldName"].isValid() || !objectIdData["objectIds"].isValid() )
@@ -41,7 +41,7 @@ bool QgsAfsSourceSelect::connectToService( const QgsOwsConnection &connection )
QVariantMap serviceInfoMap = QgsArcGisRestUtils::getServiceInfo( connection.uri().param( "url" ), errorTitle, errorMessage );
if ( serviceInfoMap.isEmpty() )
{
QMessageBox::warning( this, tr( "Error" ), tr( "Failed to retrieve service capabilities:\n%1: %2" ).arg( errorTitle ).arg( errorMessage ) );
QMessageBox::warning( this, tr( "Error" ), tr( "Failed to retrieve service capabilities:\n%1: %2" ).arg( errorTitle, errorMessage ) );
return false;
}

@@ -58,7 +58,7 @@ bool QgsAfsSourceSelect::connectToService( const QgsOwsConnection &connection )
QVariantMap layerData = QgsArcGisRestUtils::getLayerInfo( connection.uri().param( "url" ) + "/" + layerInfoMap["id"].toString(), errorTitle, errorMessage );
if ( layerData.isEmpty() )
{
layerErrors.append( tr( "Layer %1: %2 - %3" ).arg( layerInfoMap["id"].toString() ).arg( errorTitle ).arg( errorMessage ) );
layerErrors.append( tr( "Layer %1: %2 - %3" ).arg( layerInfoMap["id"].toString(), errorTitle, errorMessage ) );
continue;
}
// insert the typenames, titles and abstracts into the tree view
@@ -165,7 +165,7 @@ void QgsAmsConnectionItem::deleteConnection()
QgsAmsLayerItem::QgsAmsLayerItem( QgsDataItem* parent, const QString& name, const QString &url, const QString& id, const QString& title, const QString& authid, const QString& format )
: QgsLayerItem( parent, title, parent->path() + "/" + name, QString(), QgsLayerItem::Raster, "arcgismapserver" )
{
mUri = QString( "crs='%1' format='%2' layer='%3' url='%4'" ).arg( authid ).arg( format ).arg( id ).arg( url );
mUri = QString( "crs='%1' format='%2' layer='%3' url='%4'" ).arg( authid, format, id, url );
setState( Populated );
mIconName = "mIconAms.svg";
}
@@ -222,11 +222,11 @@ static inline QString dumpVariantMap( const QVariantMap& variantMap, const QStri
QVariantMap childMap = variantMap[key].toMap();
if ( childMap.isEmpty() )
{
result += QString( "<tr><td>%1</td><td>%2</td></tr>" ).arg( key ).arg( variantMap[key].toString() );
result += QString( "<tr><td>%1</td><td>%2</td></tr>" ).arg( key, variantMap[key].toString() );
}
else
{
result += QString( "<tr><td>%1</td><td>%2</td></tr>" ).arg( key ).arg( dumpVariantMap( childMap ) );
result += QString( "<tr><td>%1</td><td>%2</td></tr>" ).arg( key, dumpVariantMap( childMap ) );
}
}
result += "</table>";
@@ -400,7 +400,7 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPoint & thePoint, Qgs
QString valueStr;
foreach ( const QString& attribute, attributesMap.keys() )
{
valueStr += QString( "%1 = %2\n" ).arg( attribute ).arg( attributesMap[attribute].toString() );
valueStr += QString( "%1 = %2\n" ).arg( attribute, attributesMap[attribute].toString() );
}
entries.insert( entries.size(), valueStr );
}
@@ -40,7 +40,7 @@ bool QgsAmsSourceSelect::connectToService( const QgsOwsConnection &connection )
QVariantMap serviceInfoMap = QgsArcGisRestUtils::getServiceInfo( connection.uri().param( "url" ), errorTitle, errorMessage );
if ( serviceInfoMap.isEmpty() )
{
QMessageBox::warning( this, tr( "Error" ), tr( "Failed to retrieve service capabilities:\n%1: %2" ).arg( errorTitle ).arg( errorMessage ) );
QMessageBox::warning( this, tr( "Error" ), tr( "Failed to retrieve service capabilities:\n%1: %2" ).arg( errorTitle, errorMessage ) );
return false;
}

@@ -59,7 +59,7 @@ bool QgsAmsSourceSelect::connectToService( const QgsOwsConnection &connection )
QVariantMap layerData = QgsArcGisRestUtils::getLayerInfo( connection.uri().param( "url" ) + "/" + layerInfoMap["id"].toString(), errorTitle, errorMessage );
if ( layerData.isEmpty() )
{
layerErrors.append( QString( "Layer %1: %2 - %3" ).arg( layerInfoMap["id"].toString() ).arg( errorTitle ).arg( errorMessage ) );
layerErrors.append( QString( "Layer %1: %2 - %3" ).arg( layerInfoMap["id"].toString(), errorTitle, errorMessage ) );
continue;
}
// insert the typenames, titles and abstracts into the tree view
@@ -118,7 +118,7 @@ QgsSqlExpressionCompiler::Result QgsDb2ExpressionCompiler::compileNode( const Qg
}

result = "NOT " + result;
QgsDebugMsg( QString( "NOT; result: %1; right: %2" ).arg( resultType( rr ) ).arg( result ) );
QgsDebugMsg( QString( "NOT; result: %1; right: %2" ).arg( resultType( rr ), result ) );
return rr;

case QgsExpression::uoMinus:
@@ -1529,7 +1529,7 @@ QgsVectorLayerImport::ImportError QgsDb2Provider::createEmptyLayer( const QStrin
for ( int i = 0; i < list.size(); ++i )
{
QgsDebugMsg( QString( "i: %1; value: %2; type: %3" )
.arg( i ).arg( list.at( i ).toString().toLatin1().data() ).arg( list.at( i ).typeName() ) );
.arg( i ).arg( list.at( i ).toString().toLatin1().data(), list.at( i ).typeName() ) );
}

}
@@ -1579,7 +1579,7 @@ QStringList QgsGrass::grassObjects( const QgsGrassObject& mapsetObject, QgsGrass
catch ( QgsGrass::Exception &e )
{
// TODO: notify somehow user
QgsDebugMsg( QString( "Cannot run %1: %2" ).arg( cmd ).arg( e.what() ) );
QgsDebugMsg( QString( "Cannot run %1: %2" ).arg( cmd, e.what() ) );
}
}
#endif
@@ -422,7 +422,7 @@ bool QgsWFSProvider::processSQL( const QString& sqlString, QString& errorMsg, QS
concatenatedTypenames ) )
{
errorMsg = tr( "DescribeFeatureType failed for url %1: %2" ).
arg( dataSourceUri() ).arg( describeFeatureType.errorMessage() );
arg( dataSourceUri(), describeFeatureType.errorMessage() );
return false;
}

@@ -434,7 +434,7 @@ bool QgsWFSProvider::processSQL( const QString& sqlString, QString& errorMsg, QS
{
QgsDebugMsg( response );
errorMsg = tr( "DescribeFeatureType failed for url %1: %2" ).
arg( dataSourceUri() ).arg( errorMsg );
arg( dataSourceUri(), errorMsg );
return false;
}

@@ -451,7 +451,7 @@ bool QgsWFSProvider::processSQL( const QString& sqlString, QString& errorMsg, QS
geometryAttribute, fields, geomType, errorMsg ) )
{
errorMsg = tr( "Analysis of DescribeFeatureType response failed for url %1, typeName %2: %3" ).
arg( dataSourceUri() ).arg( typeName ).arg( errorMsg );
arg( dataSourceUri(), typeName, errorMsg );
return false;
}

@@ -1109,7 +1109,7 @@ bool QgsWFSProvider::describeFeatureType( QString& geometryAttribute, QgsFields&
mShared->mURI.typeName() ) )
{
QgsMessageLog::logMessage( tr( "DescribeFeatureType failed for url %1: %2" ).
arg( dataSourceUri() ).arg( describeFeatureType.errorMessage() ), tr( "WFS" ) );
arg( dataSourceUri(), describeFeatureType.errorMessage() ), tr( "WFS" ) );
return false;
}

@@ -1121,7 +1121,7 @@ bool QgsWFSProvider::describeFeatureType( QString& geometryAttribute, QgsFields&
{
QgsDebugMsg( response );
QgsMessageLog::logMessage( tr( "DescribeFeatureType failed for url %1: %2" ).
arg( dataSourceUri() ).arg( errorMsg ), tr( "WFS" ) );
arg( dataSourceUri(), errorMsg ), tr( "WFS" ) );
return false;
}

@@ -1130,7 +1130,7 @@ bool QgsWFSProvider::describeFeatureType( QString& geometryAttribute, QgsFields&
geometryAttribute, fields, geomType, errorMsg ) )
{
QgsMessageLog::logMessage( tr( "Analysis of DescribeFeatureType response failed for url %1: %2" ).
arg( dataSourceUri() ).arg( errorMsg ), tr( "WFS" ) );
arg( dataSourceUri(), errorMsg ), tr( "WFS" ) );
return false;
}

@@ -1449,7 +1449,7 @@ bool QgsWFSProvider::getCapabilities()
if ( !getCapabilities.requestCapabilities( synchronous, forceRefresh ) )
{
QgsMessageLog::logMessage( tr( "GetCapabilities failed for url %1: %2" ).
arg( dataSourceUri() ).arg( getCapabilities.errorMessage() ), tr( "WFS" ) );
arg( dataSourceUri(), getCapabilities.errorMessage() ), tr( "WFS" ) );
return false;
}

@@ -1524,7 +1524,7 @@ bool QgsWFSProvider::getCapabilities()
if ( !foundLayer )
{
QgsMessageLog::logMessage( tr( "Could not find typename %1 in capabilities for url %2" ).
arg( thisLayerName ).arg( dataSourceUri() ), tr( "WFS" ) );
arg( thisLayerName, dataSourceUri() ), tr( "WFS" ) );
}

return foundLayer;
@@ -382,7 +382,7 @@ bool QgsWFSSharedData::createCache()
if ( !ogrWaySuccessful )
{
mCacheTablename = "features";
sql = QString( "CREATE TABLE %1 (%2 INTEGER PRIMARY KEY" ).arg( mCacheTablename ).arg( fidName );
sql = QString( "CREATE TABLE %1 (%2 INTEGER PRIMARY KEY" ).arg( mCacheTablename, fidName );
Q_FOREACH ( QgsField field, cacheFields )
{
QString type( "VARCHAR" );
@@ -421,7 +421,7 @@ bool QgsWFSSharedData::createCache()

// We need an index on the gmlid, since we will check for duplicates, particularly
// useful in the case we do overlapping BBOX requests
sql = QString( "CREATE INDEX idx_%2 ON %1(%2)" ).arg( mCacheTablename ).arg( QgsWFSConstants::FIELD_GMLID );
sql = QString( "CREATE INDEX idx_%2 ON %1(%2)" ).arg( mCacheTablename, QgsWFSConstants::FIELD_GMLID );
rc = sqlite3_exec( db, sql.toUtf8(), nullptr, nullptr, nullptr );
if ( rc != SQLITE_OK )
{
@@ -431,7 +431,7 @@ bool QgsWFSSharedData::createCache()

if ( mDistinctSelect )
{
sql = QString( "CREATE INDEX idx_%2 ON %1(%2)" ).arg( mCacheTablename ).arg( QgsWFSConstants::FIELD_MD5 );
sql = QString( "CREATE INDEX idx_%2 ON %1(%2)" ).arg( mCacheTablename, QgsWFSConstants::FIELD_MD5 );
rc = sqlite3_exec( db, sql.toUtf8(), nullptr, nullptr, nullptr );
if ( rc != SQLITE_OK )
{
@@ -985,7 +985,7 @@ void QgsWFSSharedData::endOfDownload( bool success, int featureCount,

if ( !success && !interrupted )
{
QString errorMsgOut( tr( "Download of features for layer %1 failed or partially failed: %2. You may attempt reloading the layer with F5" ).arg( mURI.typeName() ).arg( errorMsg ) );
QString errorMsgOut( tr( "Download of features for layer %1 failed or partially failed: %2. You may attempt reloading the layer with F5" ).arg( mURI.typeName(), errorMsg ) );
pushError( errorMsgOut );
}

@@ -61,7 +61,7 @@ QString QgsWFSUtils::getCacheDirectory( bool createIfNotExisting )
QMutexLocker locker( &gmMutex );
if ( !QDir( baseDirectory ).exists( processPath ) )
{
QgsDebugMsg( QString( "Creating our cache dir %1/%2" ).arg( baseDirectory ).arg( processPath ) );
QgsDebugMsg( QString( "Creating our cache dir %1/%2" ).arg( baseDirectory, processPath ) );
QDir( baseDirectory ).mkpath( processPath );
}
if ( gmCounter == 0 && gmKeepAliveWorks )
@@ -75,8 +75,7 @@ QgsServerProjectParser* QgsConfigCache::serverConfiguration( const QString& file
}
QgsMessageLog::logMessage(
QString( "QGIS server version %1, project version %2" )
.arg( thisVersion.text() )
.arg( fileVersion.text() ),
.arg( thisVersion.text(), fileVersion.text() ),
"Server", QgsMessageLog::INFO
);
return new QgsServerProjectParser( doc, filePath );
@@ -69,8 +69,8 @@ void TestQgsComposerGroup::dumpUndoStack( const QUndoStack& us, QString prefix )
for ( int i = 0; i < us.count(); ++i )
{
QgsDebugMsg( QString( "%4US %1: %2%3" )
.arg( i ). arg( i >= us.index() ? "-" : "" )
.arg( us.text( i ) ) .arg( prefix ) );
.arg( i ). arg( i >= us.index() ? "-" : "",
us.text( i ), prefix ) );
}
}

0 comments on commit fae8071

Please sign in to comment.
You can’t perform that action at this time.