Skip to content
Permalink
Browse files

Use faster QString.arg multistring overload

Thanks to Clazy
  • Loading branch information
nyalldawson committed Aug 29, 2017
1 parent 137dc76 commit 82a772fd217784847f2e3b493a328d216ebf9dcf
@@ -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 )
@@ -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;
}
@@ -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 );

@@ -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() ) ) );
}
}

@@ -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;
}
@@ -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 );

@@ -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:
@@ -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" ) )
);
}

@@ -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 )
{
@@ -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 );
@@ -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 );

@@ -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()
@@ -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 );
}
@@ -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" ) ) )
{
@@ -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() )
{
@@ -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 );
@@ -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 );
@@ -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 );
}
@@ -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();
@@ -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 );
@@ -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;
}

0 comments on commit 82a772f

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