Skip to content
Permalink
Browse files

Run qstring fixup

  • Loading branch information
nyalldawson committed Jan 12, 2021
1 parent 99ba9b2 commit 499a37c2a1745b7bad5d72fd97b193faba3e54ad
@@ -71,7 +71,7 @@ bool QgsExportLayersInformationAlgorithm::prepareAlgorithm( const QVariantMap &p
{
mCrs = layer->crs();
}
else if ( mCrs.authid() != QStringLiteral( "EPSG:4326" ) )
else if ( mCrs.authid() != QLatin1String( "EPSG:4326" ) )
{
if ( mCrs != layer->crs() )
{
@@ -227,18 +227,18 @@ static QgsInterval datasetRelativetime( const QVariant parameterTimeVariant, Qgs
QDateTime layerReferenceTime = static_cast<QgsMeshLayerTemporalProperties *>( meshLayer->temporalProperties() )->referenceTime();
QString timeType = QgsProcessingParameterMeshDatasetTime::valueAsTimeType( parameterTimeVariant );

if ( timeType == QStringLiteral( "dataset-time-step" ) )
if ( timeType == QLatin1String( "dataset-time-step" ) )
{
QgsMeshDatasetIndex datasetIndex = QgsProcessingParameterMeshDatasetTime::timeValueAsDatasetIndex( parameterTimeVariant );
relativeTime = meshLayer->datasetRelativeTime( datasetIndex );
}
else if ( timeType == QStringLiteral( "defined-date-time" ) )
else if ( timeType == QLatin1String( "defined-date-time" ) )
{
QDateTime dateTime = QgsProcessingParameterMeshDatasetTime::timeValueAsDefinedDateTime( parameterTimeVariant );
if ( dateTime.isValid() )
relativeTime = QgsInterval( layerReferenceTime.secsTo( dateTime ) );
}
else if ( timeType == QStringLiteral( "current-context-time" ) )
else if ( timeType == QLatin1String( "current-context-time" ) )
{
QDateTime dateTime = context.currentTimeRange().begin();
if ( dateTime.isValid() )
@@ -497,7 +497,7 @@ QgsRasterCalculator::Result QgsRasterCalculator::processCalculationGPU( std::uni
}
}

programTemplate = programTemplate.replace( QLatin1String( "##INPUT_NODATA_CHECK##" ), inputNoDataCheck.isEmpty() ? QStringLiteral( "false" ) : inputNoDataCheck.join( QStringLiteral( " || " ) ) );
programTemplate = programTemplate.replace( QLatin1String( "##INPUT_NODATA_CHECK##" ), inputNoDataCheck.isEmpty() ? QStringLiteral( "false" ) : inputNoDataCheck.join( QLatin1String( " || " ) ) );
programTemplate = programTemplate.replace( QLatin1String( "##INPUT_DESC##" ), inputDesc.join( '\n' ) );
programTemplate = programTemplate.replace( QLatin1String( "##INPUT##" ), !inputArgs.isEmpty() ? ( inputArgs.join( ',' ).append( ',' ) ) : QChar( ' ' ) );
programTemplate = programTemplate.replace( QLatin1String( "##EXPRESSION##" ), cExpression );
@@ -36,7 +36,7 @@ QgsFirstRunDialog::QgsFirstRunDialog( QWidget *parent ) : QDialog( parent )
else
{
// Production version shows link.
mWelcomeProdLabel->setText( mWelcomeProdLabel->text().replace( QStringLiteral( "VERSION_TOKEN" ), major.append( minor ) ) );
mWelcomeProdLabel->setText( mWelcomeProdLabel->text().replace( QLatin1String( "VERSION_TOKEN" ), major.append( minor ) ) );
mWelcomeDevLabel->hide();
}

@@ -558,7 +558,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const
esc_regexp.replace( pos + 1, 1, '.' );
pos += 1;
}
esc_regexp.replace( QStringLiteral( "\\\\_" ), QStringLiteral( "_" ) );
esc_regexp.replace( QLatin1String( "\\\\_" ), QLatin1String( "_" ) );

matches = QRegExp( esc_regexp, mOp == boLike || mOp == boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
}
@@ -96,7 +96,7 @@ QgsPointCloudRenderer *QgsPointCloudRendererRegistry::defaultRenderer( const Qgs
const QgsPointCloudAttributeCollection attributes = provider->attributes();

//if red/green/blue attributes are present, then default to a RGB renderer
if ( attributes.indexOf( QStringLiteral( "Red" ) ) >= 0 && attributes.indexOf( QStringLiteral( "Green" ) ) >= 0 && attributes.indexOf( QStringLiteral( "Blue" ) ) >= 0 )
if ( attributes.indexOf( QLatin1String( "Red" ) ) >= 0 && attributes.indexOf( QLatin1String( "Green" ) ) >= 0 && attributes.indexOf( QLatin1String( "Blue" ) ) >= 0 )
{
std::unique_ptr< QgsPointCloudRgbRenderer > renderer = qgis::make_unique< QgsPointCloudRgbRenderer >();

@@ -139,7 +139,7 @@ QgsPointCloudRenderer *QgsPointCloudRendererRegistry::defaultRenderer( const Qgs
}

// otherwise try a classified renderer...
if ( attributes.indexOf( QStringLiteral( "Classification" ) ) >= 0 )
if ( attributes.indexOf( QLatin1String( "Classification" ) ) >= 0 )
{
// are any classifications present?
QVariantList classes = provider->metadataClasses( QStringLiteral( "Classification" ) );
@@ -1348,7 +1348,7 @@ QVariant QgsProcessingModelAlgorithm::toVariant() const
QVariantMap paramDefMap;
for ( const QgsProcessingParameterDefinition *def : mParameters )
{
if ( def->name() == QStringLiteral( "VERBOSE_LOG" ) )
if ( def->name() == QLatin1String( "VERBOSE_LOG" ) )
continue;

paramDefMap.insert( def->name(), def->toVariantMap() );
@@ -77,13 +77,13 @@ QString QgsProcessingParameterMeshDatasetGroups::asPythonString( QgsProcessing::
dt.append( QStringLiteral( "QgsMeshDatasetGroupMetadata.DataOnEdges" ) );
if ( !dt.isEmpty() )
{
code += QStringLiteral( ", dataType=[" );
code += QLatin1String( ", dataType=[" );
code += dt.join( ',' );
code += ']';
}

if ( mFlags & FlagOptional )
code += QStringLiteral( ", optional=True" );
code += QLatin1String( ", optional=True" );
code += ')';
return code;
}
@@ -174,12 +174,12 @@ QString QgsProcessingParameterMeshDatasetTime::valueAsPythonString( const QVaria
const QVariantMap variantTimeDataset = value.toMap();
parts << QStringLiteral( "'type': " ) + QgsProcessingUtils::variantToPythonLiteral( variantTimeDataset.value( QStringLiteral( "type" ) ).toString() );

if ( variantTimeDataset.value( QStringLiteral( "type" ) ) == QStringLiteral( "dataset-time-step" ) )
if ( variantTimeDataset.value( QStringLiteral( "type" ) ) == QLatin1String( "dataset-time-step" ) )
{
QVariantList datasetIndex = variantTimeDataset.value( QStringLiteral( "value" ) ).toList();
parts << QStringLiteral( "'value': " ) + QString( "QgsMeshDatasetIndex(%1,%2)" ).arg( datasetIndex.at( 0 ).toString() ).arg( datasetIndex.at( 1 ).toString() );
}
else if ( variantTimeDataset.value( QStringLiteral( "type" ) ) == QStringLiteral( "defined-date-time" ) )
else if ( variantTimeDataset.value( QStringLiteral( "type" ) ) == QLatin1String( "defined-date-time" ) )
{
parts << QStringLiteral( "'value': " ) + QgsProcessingUtils::variantToPythonLiteral( variantTimeDataset.value( QStringLiteral( "value" ) ) );
}
@@ -202,7 +202,7 @@ QString QgsProcessingParameterMeshDatasetTime::asPythonString( QgsProcessing::Py
code += QStringLiteral( ", datasetGroupParameterName=%1" ).arg( QgsProcessingUtils::stringToPythonLiteral( mDatasetGroupParameterName ) );

if ( mFlags & FlagOptional )
code += QStringLiteral( ", optional=True" );
code += QLatin1String( ", optional=True" );
code += ')';
return code;
}
@@ -242,7 +242,7 @@ QString QgsProcessingParameterMeshDatasetTime::valueAsTimeType( const QVariant &

QgsMeshDatasetIndex QgsProcessingParameterMeshDatasetTime::timeValueAsDatasetIndex( const QVariant &value )
{
if ( !valueIsAcceptable( value, false ) || valueAsTimeType( value ) != QStringLiteral( "dataset-time-step" ) )
if ( !valueIsAcceptable( value, false ) || valueAsTimeType( value ) != QLatin1String( "dataset-time-step" ) )
return QgsMeshDatasetIndex( -1, -1 );

QVariantList list = value.toMap().value( QStringLiteral( "value" ) ).toList();
@@ -251,7 +251,7 @@ QgsMeshDatasetIndex QgsProcessingParameterMeshDatasetTime::timeValueAsDatasetInd

QDateTime QgsProcessingParameterMeshDatasetTime::timeValueAsDefinedDateTime( const QVariant &value )
{
if ( !valueIsAcceptable( value, false ) && valueAsTimeType( value ) != QStringLiteral( "defined-date-time" ) )
if ( !valueIsAcceptable( value, false ) && valueAsTimeType( value ) != QLatin1String( "defined-date-time" ) )
return QDateTime();

return value.toMap().value( QStringLiteral( "value" ) ).toDateTime();
@@ -271,10 +271,10 @@ bool QgsProcessingParameterMeshDatasetTime::valueIsAcceptable( const QVariant &i
QString type = map.value( QStringLiteral( "type" ) ).toString();
QVariant value = map.value( QStringLiteral( "value" ) );

if ( type == QStringLiteral( "static" ) || type == QStringLiteral( "current-context-time" ) )
if ( type == QLatin1String( "static" ) || type == QLatin1String( "current-context-time" ) )
return true;

if ( type == QStringLiteral( "dataset-time-step" ) )
if ( type == QLatin1String( "dataset-time-step" ) )
{
if ( value.type() != QVariant::List )
return false;
@@ -284,7 +284,7 @@ bool QgsProcessingParameterMeshDatasetTime::valueIsAcceptable( const QVariant &i
if ( list.at( 0 ).type() != QVariant::Int || list.at( 1 ).type() != QVariant::Int )
return false;
}
else if ( type == QStringLiteral( "defined-date-time" ) )
else if ( type == QLatin1String( "defined-date-time" ) )
{
if ( value.type() != QVariant::DateTime )
return false;
@@ -26,7 +26,7 @@ QVariantMap QgsArcGisPortalUtils::retrieveUserInfo( const QString &communityUrl,
endPoint.chop( 1 );

if ( user.isEmpty() )
endPoint += QStringLiteral( "/self" );
endPoint += QLatin1String( "/self" );
else
endPoint += QStringLiteral( "/users/" ) + user;

@@ -337,7 +337,7 @@ void QgsProviderRegistry::init()
{
pointCloudFilters.insert( 0, QObject::tr( "All Supported Files" ) + QStringLiteral( " (%1)" ).arg( pointCloudWildcards.join( ' ' ) ) );
pointCloudFilters.insert( 1, QObject::tr( "All Files" ) + QStringLiteral( " (*.*)" ) );
mPointCloudFileFilters = pointCloudFilters.join( QStringLiteral( ";;" ) );
mPointCloudFileFilters = pointCloudFilters.join( QLatin1String( ";;" ) );
}

// load database drivers (only OGR)
@@ -493,21 +493,21 @@ void QgsProcessingMeshDatasetTimeWidget::setValue( const QVariant &value )
QString type = mValue.value( QStringLiteral( "type" ) ).toString();

setEnabled( true );
if ( type == QStringLiteral( "static" ) )
if ( type == QLatin1String( "static" ) )
{
setEnabled( false );
}
else if ( type == QStringLiteral( "dataset-time-step" ) )
else if ( type == QLatin1String( "dataset-time-step" ) )
{
whileBlocking( radioButtonDatasetGroupTimeStep )->setChecked( true );
whileBlocking( comboBoxDatasetTimeStep )->setCurrentIndex( comboBoxDatasetTimeStep->findData( mValue.value( QStringLiteral( "value" ) ) ) );
}
else if ( type == QStringLiteral( "dataset-time-step" ) )
else if ( type == QLatin1String( "dataset-time-step" ) )
{
radioButtonDefinedDateTime->setChecked( true );
whileBlocking( dateTimeEdit )->setDate( mValue.value( QStringLiteral( "value" ) ).toDate() );
}
else if ( type == QStringLiteral( "current-context-time" ) )
else if ( type == QLatin1String( "current-context-time" ) )
{
whileBlocking( radioButtonCurrentCanvasTime )->setChecked( true );
}
@@ -1269,7 +1269,7 @@ QVariantMap QgsDelimitedTextProviderMetadata::decodeUri( const QString &uri ) co
QStringList openOptions;
for ( const auto &item : queryItems.queryItems() )
{
if ( item.first == QStringLiteral( "subset" ) )
if ( item.first == QLatin1String( "subset" ) )
{
subset = item.second;
}
@@ -40,14 +40,14 @@ QString QgsHanaConnectionStringBuilder::toString() const
{
// For more details on how to escape special characters in passwords,
// see https://stackoverflow.com/questions/55150362/maybe-illegal-character-in-odbc-sql-server-connection-string-pwd
QString pwd = QString( mPassword ).replace( '}', QStringLiteral( "}}" ) );
QString pwd = QString( mPassword ).replace( '}', QLatin1String( "}}" ) );
QString ret = QStringLiteral( "DRIVER={%1};SERVERNODE=%2:%3;DATABASENAME=%4;UID=%5;PWD={%6};CHAR_AS_UTF8=1" ).arg(
mDriver, mHost, mPort, mDatabase, mUserName, pwd );
if ( !mSchema.isEmpty() )
ret += QStringLiteral( ";CURRENTSCHEMA=" ) + mSchema;
if ( mSslEnabled )
{
ret += QStringLiteral( ";encrypt=true" );
ret += QLatin1String( ";encrypt=true" );
if ( !mSslCryptoProvider.isEmpty() )
ret += QStringLiteral( ";sslCryptoProvider=" ) + mSslCryptoProvider;
ret += QStringLiteral( ";sslValidateCertificate=" ) + QString( mSslValidateCertificate ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
@@ -213,7 +213,7 @@ bool QgsHanaConnectionItem::handleDrop( const QMimeData *data, const QString &to
QgsMessageOutput *output = QgsMessageOutput::createMessageOutput();
output->setTitle( tr( "Import to HANA database" ) );
output->setMessage( tr( "Failed to import some layers!\n\n" ) +
importResults.join( QStringLiteral( "\n" ) ), QgsMessageOutput::MessageText );
importResults.join( QLatin1Char( '\n' ) ), QgsMessageOutput::MessageText );
output->showMessage();
}

@@ -440,7 +440,7 @@ QString QgsHanaFeatureIterator::buildSqlQuery( const QgsFeatureRequest &request
QgsHanaUtils::quotedIdentifier( mSource->mTableName ) );

if ( !sqlFilter.isEmpty() )
sql += QStringLiteral( " WHERE (%1)" ).arg( sqlFilter.join( QStringLiteral( ") AND (" ) ) );
sql += QStringLiteral( " WHERE (%1)" ).arg( sqlFilter.join( QLatin1String( ") AND (" ) ) );

if ( !orderByParts.isEmpty() )
sql += QStringLiteral( " ORDER BY %1 " ).arg( orderByParts.join( ',' ) );
@@ -210,7 +210,7 @@ QString QgsHanaPrimaryKeyUtils::buildWhereClause( const QgsFields &fields, QgsHa
QList<QString> conditions;
for ( int idx : pkAttrs )
conditions << QStringLiteral( "%1=?" ).arg( QgsHanaUtils::quotedIdentifier( fields[idx].name() ) );
return conditions.join( QStringLiteral( " AND " ) );
return conditions.join( QLatin1String( " AND " ) );
}
case PktUnknown:
return QString();
@@ -253,7 +253,7 @@ QString QgsHanaPrimaryKeyUtils::buildWhereClause( QgsFeatureId featureId, const
const QgsField &field = fields.at( pkAttrs[i] );
conditions << QStringLiteral( "%1=%2" ).arg( QgsHanaUtils::quotedIdentifier( field.name() ), QgsHanaUtils::toConstant( pkValues[i], field.type() ) );
}
return conditions.join( QStringLiteral( " AND " ) );
return conditions.join( QLatin1String( " AND " ) );
}
case PktUnknown:
return QString();
@@ -300,7 +300,7 @@ QString QgsHanaPrimaryKeyUtils::buildWhereClause( const QgsFeatureIds &featureId
return QString();
whereClauses << fidWhereClause;
}
return whereClauses.join( QStringLiteral( " OR " ) ).prepend( '(' ).append( ')' );
return whereClauses.join( QLatin1String( " OR " ) ).prepend( '(' ).append( ')' );
}
case PktUnknown:
return QString();
@@ -572,7 +572,7 @@ bool QgsHanaProvider::addFeatures( QgsFeatureList &flist, Flags flags )
const bool allowBatchInserts = ( flags & QgsFeatureSink::FastInsert );
const QString sql = QStringLiteral( "INSERT INTO %1.%2(%3) VALUES (%4)" ).arg(
QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ),
columnNames.join( QStringLiteral( "," ) ), values.join( QStringLiteral( "," ) ) );
columnNames.join( QLatin1Char( ',' ) ), values.join( QLatin1Char( ',' ) ) );

try
{
@@ -782,7 +782,7 @@ bool QgsHanaProvider::addAttributes( const QList<QgsField> &attributes )
for ( const QgsField &field : attributes )
{
if ( !columnDefs.isEmpty() )
columnDefs += QStringLiteral( "," );
columnDefs += QLatin1Char( ',' );

columnDefs += QgsHanaUtils::quotedIdentifier( field.name() ) + QStringLiteral( " " ) + field.typeName();

@@ -824,7 +824,7 @@ bool QgsHanaProvider::deleteAttributes( const QgsAttributeIds &attributes )
for ( int attrId : attributes )
{
if ( !columnNames.isEmpty() )
columnNames += QStringLiteral( "," );
columnNames += QLatin1Char( ',' );
const QgsField &field = mAttributeFields.at( attrId );
columnNames += QgsHanaUtils::quotedIdentifier( field.name() );
}
@@ -1048,7 +1048,7 @@ bool QgsHanaProvider::changeAttributeValues( const QgsChangedAttributesMap &attr
const QString sql = QStringLiteral( "UPDATE %1.%2 SET %3 WHERE %4" ).arg(
QgsHanaUtils::quotedIdentifier( mSchemaName ),
QgsHanaUtils::quotedIdentifier( mTableName ),
attrs.join( QStringLiteral( "," ) ),
attrs.join( QLatin1Char( ',' ) ),
fidWhereClause );

PreparedStatementRef stmtUpdate = conn->prepareStatement( sql );
@@ -133,7 +133,7 @@ void QgsHanaSourceSelectDelegate::setModelData(
cols << item->text();
}

model->setData( index, cols.isEmpty() ? tr( "Select…" ) : cols.join( QStringLiteral( ", " ) ) );
model->setData( index, cols.isEmpty() ? tr( "Select…" ) : cols.join( QLatin1String( ", " ) ) );
model->setData( index, cols, Qt::UserRole + 2 );
}
}
@@ -30,7 +30,7 @@ namespace
{
QString escaped = val;

escaped.replace( '\\', QStringLiteral( "\\\\" ) );
escaped.replace( '\\', QLatin1String( "\\\\" ) );
escaped.replace( delim, QStringLiteral( "\\%1" ).arg( delim ) );

return escaped;
@@ -79,20 +79,20 @@ QString QgsHanaUtils::connectionInfo( const QgsDataSourceUri &uri )
addItem( "sslTrustStore", uri.param( QStringLiteral( "sslTrustStore" ) ) );
}

return connectionItems.join( QStringLiteral( " " ) );
return connectionItems.join( QLatin1Char( ' ' ) );
}

QString QgsHanaUtils::quotedIdentifier( const QString &str )
{
QString result = str;
result.replace( '"', QStringLiteral( "\"\"" ) );
result.replace( '"', QLatin1String( "\"\"" ) );
return result.prepend( '\"' ).append( '\"' );
}

QString QgsHanaUtils::quotedString( const QString &str )
{
QString result = str;
result.replace( '\'', QStringLiteral( "''" ) );
result.replace( '\'', QLatin1String( "''" ) );
return result.prepend( '\'' ).append( '\'' );
}

@@ -2540,7 +2540,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
// but we need to escape all double quotes and backslashes
list_vals.replaceInStrings( "\\", "\\\\" );
list_vals.replaceInStrings( "\"", "\\\"" );
v = QStringLiteral( "{\"" ) + value.toStringList().join( QStringLiteral( "\",\"" ) ) + QStringLiteral( "\"}" );
v = QStringLiteral( "{\"" ) + value.toStringList().join( QLatin1String( "\",\"" ) ) + QStringLiteral( "\"}" );
}
else if ( value.type() == QVariant::List )
{
@@ -1636,7 +1636,7 @@ QDomElement QgsWFSProvider::createTransactionElement( QDomDocument &doc ) const
QDomElement transactionElem = doc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Transaction" ) );
const QString WfsVersion = mShared->mWFSVersion;
// only 1.1.0 and 1.0.0 are supported
if ( WfsVersion == QStringLiteral( "1.1.0" ) )
if ( WfsVersion == QLatin1String( "1.1.0" ) )
{
transactionElem.setAttribute( QStringLiteral( "version" ), WfsVersion );
}
@@ -1689,7 +1689,7 @@ bool QgsWFSProvider::transactionSuccess( const QDomDocument &serverResponse ) co

const QString WfsVersion = mShared->mWFSVersion;

if ( WfsVersion == QStringLiteral( "1.1.0" ) )
if ( WfsVersion == QLatin1String( "1.1.0" ) )
{
const QDomNodeList transactionSummaryList = documentElem.elementsByTagNameNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "TransactionSummary" ) );
if ( transactionSummaryList.size() < 1 )
@@ -1769,7 +1769,7 @@ QStringList QgsWFSProvider::insertedFeatureIds( const QDomDocument &serverRespon

// Handles WFS 1.1.0
QString insertResultTagName;
if ( mShared->mWFSVersion == QStringLiteral( "1.1.0" ) )
if ( mShared->mWFSVersion == QLatin1String( "1.1.0" ) )
{
insertResultTagName = QStringLiteral( "InsertResults" );
}

0 comments on commit 499a37c

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