Skip to content

Commit

Permalink
Use faster QString.arg multistring overload
Browse files Browse the repository at this point in the history
Thanks to Clazy
  • Loading branch information
nyalldawson committed Aug 29, 2017
1 parent 137dc76 commit 82a772f
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/app/dwg/qgsdwgimportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void QgsDwgImportDialog::on_pbImportDrawing_clicked()

QgsVectorLayer *QgsDwgImportDialog::layer( QgsLayerTreeGroup *layerGroup, QString layerFilter, QString table )
{
QgsVectorLayer *l = new QgsVectorLayer( QString( "%1|layername=%2" ).arg( leDatabase->text() ).arg( table ), table, "ogr", false );
QgsVectorLayer *l = new QgsVectorLayer( QString( "%1|layername=%2" ).arg( leDatabase->text(), table ), table, "ogr", false );
l->setSubsetString( QString( "%1space=0 AND block=-1" ).arg( layerFilter ) );

if ( l->featureCount() == 0 )
Expand Down
28 changes: 11 additions & 17 deletions src/app/dwg/qgsdwgimporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ bool QgsDwgImporter::exec( QString sql, bool logError )
if ( logError )
{
LOG( QObject::tr( "SQL statement failed\nDatabase:%1\nSQL:%2\nError:%3" )
.arg( mDatabase )
.arg( sql )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
.arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
}
return false;
}
Expand All @@ -127,9 +125,7 @@ OGRLayerH QgsDwgImporter::query( QString sql )
return layer;

LOG( QObject::tr( "SQL statement failed\nDatabase:%1\nSQL:%2\nError:%3" )
.arg( mDatabase )
.arg( sql )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
.arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );

OGR_DS_ReleaseResultSet( mDs, layer );

Expand All @@ -145,8 +141,7 @@ void QgsDwgImporter::startTransaction()
if ( !mInTransaction )
{
LOG( QObject::tr( "Could not start transaction\nDatabase:%1\nError:%2" )
.arg( mDatabase )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
.arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
}
}

Expand All @@ -157,8 +152,7 @@ void QgsDwgImporter::commitTransaction()
if ( mInTransaction && GDALDatasetCommitTransaction( mDs ) != OGRERR_NONE )
{
LOG( QObject::tr( "Could not commit transaction\nDatabase:%1\nError:%2" )
.arg( mDatabase )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
.arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
}
mInTransaction = false;
}
Expand Down Expand Up @@ -608,7 +602,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa

OGR_F_Destroy( f );

LOG( QObject::tr( "Updating database from %1 [%2]." ).arg( drawing ).arg( fi.lastModified().toString() ) );
LOG( QObject::tr( "Updating database from %1 [%2]." ).arg( drawing, fi.lastModified().toString() ) );

DRW::error result( DRW::BAD_NONE );

Expand Down Expand Up @@ -752,9 +746,9 @@ void QgsDwgImporter::addHeader( const DRW_Header *data )

case DRW_Variant::COORD:
v = QString( "%1,%2,%3" )
.arg( qgsDoubleToString( it->second->content.v->x ) )
.arg( qgsDoubleToString( it->second->content.v->y ) )
.arg( qgsDoubleToString( it->second->content.v->z ) );
.arg( qgsDoubleToString( it->second->content.v->x ),
qgsDoubleToString( it->second->content.v->y ),
qgsDoubleToString( it->second->content.v->z ) );
break;

case DRW_Variant::INVALID:
Expand All @@ -767,9 +761,9 @@ void QgsDwgImporter::addHeader( const DRW_Header *data )
if ( OGR_L_CreateFeature( layer, f ) != OGRERR_NONE )
{
LOG( QObject::tr( "Could not add %3 %1 [%2]" )
.arg( k )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) )
.arg( QObject::tr( "header record" ) )
.arg( k,
QString::fromUtf8( CPLGetLastErrorMsg() ),
QObject::tr( "header record" ) )
);
}

Expand Down
3 changes: 1 addition & 2 deletions src/core/auth/qgsauthmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3060,8 +3060,7 @@ void QgsAuthManager::passwordHelperProcessError()
mPasswordHelperErrorMessage = tr( "There was an error and integration with your %1 system has been disabled. "
"You can re-enable it at any time through the \"Utilities\" menu "
"in the Authentication pane of the options dialog. %2" )
.arg( AUTH_PASSWORD_HELPER_DISPLAY_NAME )
.arg( mPasswordHelperErrorMessage );
.arg( AUTH_PASSWORD_HELPER_DISPLAY_NAME, mPasswordHelperErrorMessage );
}
if ( mPasswordHelperErrorCode != QKeychain::NoError )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsdistancearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool QgsDistanceArea::setEllipsoid( const QString &ellipsoid )
// Also, b = a-(a/invf)
bool QgsDistanceArea::setEllipsoid( double semiMajor, double semiMinor )
{
mEllipsoid = QStringLiteral( "PARAMETER:%1:%2" ).arg( qgsDoubleToString( semiMajor ) ).arg( qgsDoubleToString( semiMinor ) );
mEllipsoid = QStringLiteral( "PARAMETER:%1:%2" ).arg( qgsDoubleToString( semiMajor ), qgsDoubleToString( semiMinor ) );
mSemiMajor = semiMajor;
mSemiMinor = semiMinor;
mInvFlattening = mSemiMajor / ( mSemiMajor - mSemiMinor );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ bool QgsProject::readProjectFile( const QString &filename )
#endif

QString errorString = tr( "Project file read error in file %1: %2 at line %3 column %4" )
.arg( projectFile.fileName() ).arg( errorMsg ).arg( line ).arg( column );
.arg( projectFile.fileName(), errorMsg ).arg( line ).arg( column );

QgsDebugMsg( errorString );

Expand Down
3 changes: 1 addition & 2 deletions src/core/qgsruntimeprofiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ void QgsRuntimeProfiler::end()
name.prepend( mGroupPrefix );
double timing = mProfileTime.elapsed() / 1000.0;
mProfileTimes.append( QPair<QString, double>( name, timing ) );
QString message = QStringLiteral( "PROFILE: %1 - %2" ).arg( name ).arg( timing );
QgsDebugMsg( message );
QgsDebugMsg( QStringLiteral( "PROFILE: %1 - %2" ).arg( name ).arg( timing ) );
}

void QgsRuntimeProfiler::clear()
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerlabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap &
x += fontSize / 2;
y += fontSize;
}
QString resizeSpec = QString( "%1 %2" ).arg( qgsDoubleToString( x, 2 ) ).arg( qgsDoubleToString( y, 2 ) );
QString resizeSpec = QString( "%1 %2" ).arg( qgsDoubleToString( x, 2 ), qgsDoubleToString( y, 2 ) );
QDomElement voMargin = QgsSymbolLayerUtils::createVendorOptionElement( doc, QStringLiteral( "graphic-margin" ), resizeSpec );
textSymbolizerElement.appendChild( voMargin );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgshelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ QUrl QgsHelp::helpUrl( const QString &key )
}
fullPath.replace( QRegularExpression( "(\\$\\$)" ), "$" );

helpPath = QStringLiteral( "%1/%2" ).arg( fullPath ).arg( key );
helpPath = QStringLiteral( "%1/%2" ).arg( fullPath, key );

if ( helpPath.startsWith( QStringLiteral( "http" ) ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmessagebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void QgsMessageBar::pushItem( QgsMessageBarItem *item )

// Log all messages that are sent to the message bar into the message log so the
// user can get them back easier.
QString formattedTitle = QString( "%1 : %2" ).arg( item->title() ).arg( item->text() );
QString formattedTitle = QString( "%1 : %2" ).arg( item->title(), item->text() );
QgsMessageLog::MessageLevel level;
switch ( item->level() )
{
Expand Down
3 changes: 1 addition & 2 deletions src/gui/qgsmessagelogviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ void QgsMessageLogViewer::logMessage( const QString &message, const QString &tag
}

QString prefix = QStringLiteral( "%1\t%2\t" )
.arg( QDateTime::currentDateTime().toString( Qt::ISODate ) )
.arg( levelString );
.arg( QDateTime::currentDateTime().toString( Qt::ISODate ), levelString );
QString cleanedMessage = message;
cleanedMessage = cleanedMessage.prepend( prefix ).replace( '\n', QLatin1String( "\n\t\t\t" ) );
w->appendPlainText( cleanedMessage );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology/qgsstyleexportimportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool QgsStyleExportImportDialog::populateStyles( QgsStyle *style )
QStandardItem *item = new QStandardItem( name );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize(), 15 );
item->setIcon( icon );
item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( name ).arg( tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) );
item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( name, tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) );
// Set font to 10points to show reasonable text
QFont itemFont = item->font();
itemFont.setPointSize( 10 );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology/qgsstylemanagerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void QgsStyleManagerDialog::populateSymbols( const QStringList &symbolNames, boo
item->setIcon( icon );
item->setData( name ); // used to find out original name when user edited the name
item->setCheckable( check );
item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( name ).arg( tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) );
item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( name, tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) );
// add to model
model->appendRow( item );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology/qgssymbolslistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void QgsSymbolsListWidget::populateSymbols( const QStringList &names )
QStandardItem *item = new QStandardItem( names[i] );
item->setData( names[i], Qt::UserRole ); //so we can load symbol with that name
item->setText( names[i] );
item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( names[i] ).arg( tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) );
item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( names[i], tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) );
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
// Set font to 10points to show reasonable text
QFont itemFont = item->font();
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ QgsVectorLayerExporter::ExportError QgsOgrProvider::createEmptyLayer( const QStr
OGR_DS_Destroy( hDS );
if ( errorMessage )
*errorMessage += QObject::tr( "Layer %2 of %1 exists and overwrite flag is false." )
.arg( uri ).arg( layerName );
.arg( uri, layerName );
return QgsVectorLayerExporter::ErrCreateDataSource;
}
OGR_DS_Destroy( hDS );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialitedataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bool QgsSLConnectionItem::handleDrop( const QMimeData *data, Qt::DropAction )
QgsVectorLayer *srcLayer = u.vectorLayer( owner, error );
if ( !srcLayer )
{
importResults.append( tr( "%1: %2" ).arg( u.name ).arg( error ) );
importResults.append( tr( "%1: %2" ).arg( u.name, error ) );
hasError = true;
continue;
}
Expand Down

0 comments on commit 82a772f

Please sign in to comment.