" ) + tr( "Keywords" ) + QStringLiteral( " | \n" );
QMapIterator i( mMetadata.keywords() );
if ( i.hasNext() )
{
- myMetadata += QStringLiteral( "\n" );
+ myMetadata += QLatin1String( "\n" );
myMetadata += QLatin1String( "" ) + tr( "Vocabulary" ) + QLatin1String( " | " ) + tr( "Items" ) + QLatin1String( " | \n" );
int j = 1;
while ( i.hasNext() )
@@ -217,7 +217,7 @@ QString QgsLayerMetadataFormatter::identificationSectionHtml() const
QString rowClass;
if ( j % 2 )
rowClass = QStringLiteral( "class=\"odd-row\"" );
- myMetadata += QLatin1String( "" ) + i.key() + QLatin1String( " | " ) + i.value().join( QStringLiteral( ", " ) ) + QLatin1String( " | \n" );
+ myMetadata += QLatin1String( "" ) + i.key() + QLatin1String( " | " ) + i.value().join( QLatin1String( ", " ) ) + QLatin1String( " | \n" );
j++;
}
myMetadata += QLatin1String( " \n" ); // End keywords table
@@ -237,7 +237,7 @@ QString QgsLayerMetadataFormatter::historySectionHtml() const
}
else
{
- myMetadata += QStringLiteral( "\n" );
+ myMetadata += QLatin1String( "\n" );
myMetadata += QLatin1String( "" ) + tr( "ID" ) + QLatin1String( " | " ) + tr( "Action" ) + QLatin1String( " | \n" );
int i = 1;
for ( const QString &history : historyItems )
@@ -263,7 +263,7 @@ QString QgsLayerMetadataFormatter::linksSectionHtml() const
}
else
{
- myMetadata += QStringLiteral( "\n" );
+ myMetadata += QLatin1String( "\n" );
myMetadata += QLatin1String( "" ) + tr( "ID" ) + QLatin1String( " | " ) + tr( "Name" ) + QLatin1String( " | " ) + tr( "Type" ) + QLatin1String( " | " ) + tr( "URL" ) + QLatin1String( " | " ) + tr( "Description" ) + QLatin1String( " | " ) + tr( "Format" ) + QLatin1String( " | " ) + tr( "MIME Type" ) + QLatin1String( " | " ) + tr( "Size" ) + QLatin1String( " | \n" );
int i = 1;
for ( const QgsAbstractMetadataBase::Link &link : links )
diff --git a/src/core/processing/models/qgsprocessingmodelalgorithm.cpp b/src/core/processing/models/qgsprocessingmodelalgorithm.cpp
index a13ec12ec450..eb6a085ee5ba 100644
--- a/src/core/processing/models/qgsprocessingmodelalgorithm.cpp
+++ b/src/core/processing/models/qgsprocessingmodelalgorithm.cpp
@@ -277,7 +277,7 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
}
if ( !broken.empty() )
- throw QgsProcessingException( QCoreApplication::translate( "QgsProcessingModelAlgorithm", "Cannot run model, the following algorithms are not available on this system: %1" ).arg( broken.values().join( QStringLiteral( ", " ) ) ) );
+ throw QgsProcessingException( QCoreApplication::translate( "QgsProcessingModelAlgorithm", "Cannot run model, the following algorithms are not available on this system: %1" ).arg( broken.values().join( QLatin1String( ", " ) ) ) );
QElapsedTimer totalTime;
totalTime.start();
@@ -347,7 +347,7 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
if ( feedback && !skipGenericLogging )
{
feedback->pushInfo( QObject::tr( "Input Parameters:" ) );
- feedback->pushCommandInfo( QStringLiteral( "{ %1 }" ).arg( params.join( QStringLiteral( ", " ) ) ) );
+ feedback->pushCommandInfo( QStringLiteral( "{ %1 }" ).arg( params.join( QLatin1String( ", " ) ) ) );
}
QElapsedTimer childTime;
diff --git a/src/core/processing/models/qgsprocessingmodeloutput.cpp b/src/core/processing/models/qgsprocessingmodeloutput.cpp
index 18bddc85f357..419d6d5331c7 100644
--- a/src/core/processing/models/qgsprocessingmodeloutput.cpp
+++ b/src/core/processing/models/qgsprocessingmodeloutput.cpp
@@ -60,7 +60,7 @@ bool QgsProcessingModelOutput::loadVariant( const QVariantMap &map )
if ( defaultValue.type() == QVariant::Map )
{
QVariantMap defaultMap = defaultValue.toMap();
- if ( defaultMap["class"] == QStringLiteral( "QgsProcessingOutputLayerDefinition" ) )
+ if ( defaultMap["class"] == QLatin1String( "QgsProcessingOutputLayerDefinition" ) )
{
QgsProcessingOutputLayerDefinition value;
value.loadVariant( defaultMap );
diff --git a/src/core/processing/qgsprocessingalgorithm.cpp b/src/core/processing/qgsprocessingalgorithm.cpp
index e3b56b7acd08..550b1bfa5cde 100644
--- a/src/core/processing/qgsprocessingalgorithm.cpp
+++ b/src/core/processing/qgsprocessingalgorithm.cpp
@@ -434,7 +434,7 @@ bool QgsProcessingAlgorithm::hasHtmlOutputs() const
{
for ( const QgsProcessingOutputDefinition *def : mOutputs )
{
- if ( def->type() == QStringLiteral( "outputHtml" ) )
+ if ( def->type() == QLatin1String( "outputHtml" ) )
return true;
}
return false;
@@ -1071,7 +1071,7 @@ void QgsProcessingFeatureBasedAlgorithm::prepareSource( const QVariantMap ¶m
QgsProcessingAlgorithm::VectorProperties QgsProcessingFeatureBasedAlgorithm::sinkProperties( const QString &sink, const QVariantMap ¶meters, QgsProcessingContext &context, const QMap &sourceProperties ) const
{
QgsProcessingAlgorithm::VectorProperties result;
- if ( sink == QStringLiteral( "OUTPUT" ) )
+ if ( sink == QLatin1String( "OUTPUT" ) )
{
if ( sourceProperties.value( QStringLiteral( "INPUT" ) ).availability == QgsProcessingAlgorithm::Available )
{
diff --git a/src/core/processing/qgsprocessingfeedback.cpp b/src/core/processing/qgsprocessingfeedback.cpp
index de92034864ca..696182b4cdf2 100644
--- a/src/core/processing/qgsprocessingfeedback.cpp
+++ b/src/core/processing/qgsprocessingfeedback.cpp
@@ -41,7 +41,7 @@ void QgsProcessingFeedback::reportError( const QString &error, bool )
if ( mLogFeedback )
QgsMessageLog::logMessage( error, tr( "Processing" ), Qgis::Critical );
- mHtmlLog.append( QStringLiteral( "%1 " ).arg( error.toHtmlEscaped() ).replace( '\n', QStringLiteral( " " ) ) );
+ mHtmlLog.append( QStringLiteral( "%1 " ).arg( error.toHtmlEscaped() ).replace( '\n', QLatin1String( " " ) ) );
mTextLog.append( error + '\n' );
}
@@ -50,7 +50,7 @@ void QgsProcessingFeedback::pushInfo( const QString &info )
if ( mLogFeedback )
QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info );
- mHtmlLog.append( info.toHtmlEscaped().replace( '\n', QStringLiteral( " " ) ) + QStringLiteral( " " ) );
+ mHtmlLog.append( info.toHtmlEscaped().replace( '\n', QLatin1String( " " ) ) + QStringLiteral( " " ) );
mTextLog.append( info + '\n' );
}
@@ -59,7 +59,7 @@ void QgsProcessingFeedback::pushCommandInfo( const QString &info )
if ( mLogFeedback )
QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info );
- mHtmlLog.append( QStringLiteral( "%1 " ).arg( info.toHtmlEscaped().replace( '\n', QStringLiteral( " " ) ) ) );
+ mHtmlLog.append( QStringLiteral( "%1 " ).arg( info.toHtmlEscaped().replace( '\n', QLatin1String( " " ) ) ) );
mTextLog.append( info + '\n' );
}
@@ -68,7 +68,7 @@ void QgsProcessingFeedback::pushDebugInfo( const QString &info )
if ( mLogFeedback )
QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info );
- mHtmlLog.append( QStringLiteral( "%1 " ).arg( info.toHtmlEscaped().replace( '\n', QStringLiteral( " " ) ) ) );
+ mHtmlLog.append( QStringLiteral( "%1 " ).arg( info.toHtmlEscaped().replace( '\n', QLatin1String( " " ) ) ) );
mTextLog.append( info + '\n' );
}
@@ -77,7 +77,7 @@ void QgsProcessingFeedback::pushConsoleInfo( const QString &info )
if ( mLogFeedback )
QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info );
- mHtmlLog.append( QStringLiteral( "%1 " ).arg( info.toHtmlEscaped().replace( '\n', QStringLiteral( " " ) ) ) );
+ mHtmlLog.append( QStringLiteral( "%1 " ).arg( info.toHtmlEscaped().replace( '\n', QLatin1String( " " ) ) ) );
mTextLog.append( info + '\n' );
}
diff --git a/src/core/processing/qgsprocessingparameteraggregate.cpp b/src/core/processing/qgsprocessingparameteraggregate.cpp
index 4b303d30e521..c24ab2e3a66d 100644
--- a/src/core/processing/qgsprocessingparameteraggregate.cpp
+++ b/src/core/processing/qgsprocessingparameteraggregate.cpp
@@ -79,7 +79,7 @@ QString QgsProcessingParameterAggregate::asPythonString( QgsProcessing::PythonOu
code += QStringLiteral( ", parentLayerParameterName=%1" ).arg( QgsProcessingUtils::stringToPythonLiteral( mParentLayerParameterName ) );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += ')';
return code;
}
diff --git a/src/core/processing/qgsprocessingparameterfieldmap.cpp b/src/core/processing/qgsprocessingparameterfieldmap.cpp
index 19e550391a73..891777bd1f8f 100644
--- a/src/core/processing/qgsprocessingparameterfieldmap.cpp
+++ b/src/core/processing/qgsprocessingparameterfieldmap.cpp
@@ -77,7 +77,7 @@ QString QgsProcessingParameterFieldMapping::asPythonString( QgsProcessing::Pytho
code += QStringLiteral( ", parentLayerParameterName=%1" ).arg( QgsProcessingUtils::stringToPythonLiteral( mParentLayerParameterName ) );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += ')';
return code;
}
diff --git a/src/core/processing/qgsprocessingparameters.cpp b/src/core/processing/qgsprocessingparameters.cpp
index 92916d968981..4a41171de55f 100644
--- a/src/core/processing/qgsprocessingparameters.cpp
+++ b/src/core/processing/qgsprocessingparameters.cpp
@@ -2169,81 +2169,81 @@ QgsProcessingParameterDefinition *QgsProcessingParameters::parameterFromScriptCo
QString description = descriptionFromName( name );
- if ( type == QStringLiteral( "boolean" ) )
+ if ( type == QLatin1String( "boolean" ) )
return QgsProcessingParameterBoolean::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "crs" ) )
+ else if ( type == QLatin1String( "crs" ) )
return QgsProcessingParameterCrs::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "layer" ) )
+ else if ( type == QLatin1String( "layer" ) )
return QgsProcessingParameterMapLayer::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "extent" ) )
+ else if ( type == QLatin1String( "extent" ) )
return QgsProcessingParameterExtent::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "point" ) )
+ else if ( type == QLatin1String( "point" ) )
return QgsProcessingParameterPoint::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "geometry" ) )
+ else if ( type == QLatin1String( "geometry" ) )
return QgsProcessingParameterGeometry::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "file" ) )
+ else if ( type == QLatin1String( "file" ) )
return QgsProcessingParameterFile::fromScriptCode( name, description, isOptional, definition, QgsProcessingParameterFile::File );
- else if ( type == QStringLiteral( "folder" ) )
+ else if ( type == QLatin1String( "folder" ) )
return QgsProcessingParameterFile::fromScriptCode( name, description, isOptional, definition, QgsProcessingParameterFile::Folder );
- else if ( type == QStringLiteral( "matrix" ) )
+ else if ( type == QLatin1String( "matrix" ) )
return QgsProcessingParameterMatrix::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "multiple" ) )
+ else if ( type == QLatin1String( "multiple" ) )
return QgsProcessingParameterMultipleLayers::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "number" ) )
+ else if ( type == QLatin1String( "number" ) )
return QgsProcessingParameterNumber::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "distance" ) )
+ else if ( type == QLatin1String( "distance" ) )
return QgsProcessingParameterDistance::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "scale" ) )
+ else if ( type == QLatin1String( "scale" ) )
return QgsProcessingParameterScale::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "range" ) )
+ else if ( type == QLatin1String( "range" ) )
return QgsProcessingParameterRange::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "raster" ) )
+ else if ( type == QLatin1String( "raster" ) )
return QgsProcessingParameterRasterLayer::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "enum" ) )
+ else if ( type == QLatin1String( "enum" ) )
return QgsProcessingParameterEnum::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "string" ) )
+ else if ( type == QLatin1String( "string" ) )
return QgsProcessingParameterString::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "authcfg" ) )
+ else if ( type == QLatin1String( "authcfg" ) )
return QgsProcessingParameterAuthConfig::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "expression" ) )
+ else if ( type == QLatin1String( "expression" ) )
return QgsProcessingParameterExpression::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "field" ) )
+ else if ( type == QLatin1String( "field" ) )
return QgsProcessingParameterField::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "vector" ) )
+ else if ( type == QLatin1String( "vector" ) )
return QgsProcessingParameterVectorLayer::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "source" ) )
+ else if ( type == QLatin1String( "source" ) )
return QgsProcessingParameterFeatureSource::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "sink" ) )
+ else if ( type == QLatin1String( "sink" ) )
return QgsProcessingParameterFeatureSink::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "vectordestination" ) )
+ else if ( type == QLatin1String( "vectordestination" ) )
return QgsProcessingParameterVectorDestination::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "rasterdestination" ) )
+ else if ( type == QLatin1String( "rasterdestination" ) )
return QgsProcessingParameterRasterDestination::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "filedestination" ) )
+ else if ( type == QLatin1String( "filedestination" ) )
return QgsProcessingParameterFileDestination::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "folderdestination" ) )
+ else if ( type == QLatin1String( "folderdestination" ) )
return QgsProcessingParameterFolderDestination::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "band" ) )
+ else if ( type == QLatin1String( "band" ) )
return QgsProcessingParameterBand::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "mesh" ) )
+ else if ( type == QLatin1String( "mesh" ) )
return QgsProcessingParameterMeshLayer::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "layout" ) )
+ else if ( type == QLatin1String( "layout" ) )
return QgsProcessingParameterLayout::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "layoutitem" ) )
+ else if ( type == QLatin1String( "layoutitem" ) )
return QgsProcessingParameterLayoutItem::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "color" ) )
+ else if ( type == QLatin1String( "color" ) )
return QgsProcessingParameterColor::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "coordinateoperation" ) )
+ else if ( type == QLatin1String( "coordinateoperation" ) )
return QgsProcessingParameterCoordinateOperation::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "maptheme" ) )
+ else if ( type == QLatin1String( "maptheme" ) )
return QgsProcessingParameterMapTheme::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "datetime" ) )
+ else if ( type == QLatin1String( "datetime" ) )
return QgsProcessingParameterDateTime::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "providerconnection" ) )
+ else if ( type == QLatin1String( "providerconnection" ) )
return QgsProcessingParameterProviderConnection::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "databaseschema" ) )
+ else if ( type == QLatin1String( "databaseschema" ) )
return QgsProcessingParameterDatabaseSchema::fromScriptCode( name, description, isOptional, definition );
- else if ( type == QStringLiteral( "databasetable" ) )
+ else if ( type == QLatin1String( "databasetable" ) )
return QgsProcessingParameterDatabaseTable::fromScriptCode( name, description, isOptional, definition );
return nullptr;
@@ -2324,7 +2324,7 @@ QString QgsProcessingParameterDefinition::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
+ code += QLatin1String( "optional " );
code += type() + ' ';
code += mDefault.toString();
return code.trimmed();
@@ -2341,7 +2341,7 @@ QString QgsProcessingParameterDefinition::asPythonString( const QgsProcessing::P
{
QString code = t->className() + QStringLiteral( "('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
QgsProcessingContext c;
code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
@@ -2422,7 +2422,7 @@ QString QgsProcessingParameterBoolean::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
+ code += QLatin1String( "optional " );
code += type() + ' ';
code += mDefault.toBool() ? QStringLiteral( "true" ) : QStringLiteral( "false" );
return code.trimmed();
@@ -2583,7 +2583,7 @@ QString createAllMapLayerFileFilter()
vectors.removeAll( QObject::tr( "All files (*.*)" ) );
std::sort( vectors.begin(), vectors.end() );
- return QObject::tr( "All files (*.*)" ) + QStringLiteral( ";;" ) + vectors.join( QStringLiteral( ";;" ) );
+ return QObject::tr( "All files (*.*)" ) + QStringLiteral( ";;" ) + vectors.join( QLatin1String( ";;" ) );
}
QString QgsProcessingParameterMapLayer::createFileFilter() const
@@ -2595,35 +2595,35 @@ QString QgsProcessingParameterMapLayer::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "layer " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "layer " );
for ( int type : mDataTypes )
{
switch ( type )
{
case QgsProcessing::TypeVectorAnyGeometry:
- code += QStringLiteral( "hasgeometry " );
+ code += QLatin1String( "hasgeometry " );
break;
case QgsProcessing::TypeVectorPoint:
- code += QStringLiteral( "point " );
+ code += QLatin1String( "point " );
break;
case QgsProcessing::TypeVectorLine:
- code += QStringLiteral( "line " );
+ code += QLatin1String( "line " );
break;
case QgsProcessing::TypeVectorPolygon:
- code += QStringLiteral( "polygon " );
+ code += QLatin1String( "polygon " );
break;
case QgsProcessing::TypeRaster:
- code += QStringLiteral( "raster " );
+ code += QLatin1String( "raster " );
break;
case QgsProcessing::TypeMesh:
- code += QStringLiteral( "mesh " );
+ code += QLatin1String( "mesh " );
break;
}
}
@@ -2688,7 +2688,7 @@ QString QgsProcessingParameterMapLayer::asPythonString( const QgsProcessing::Pyt
{
QString code = QStringLiteral( "QgsProcessingParameterMapLayer('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
QgsProcessingContext c;
code += QStringLiteral( ", defaultValue=%1" ).arg( valueAsPythonString( mDefault, c ) );
@@ -2703,7 +2703,7 @@ QString QgsProcessingParameterMapLayer::asPythonString( const QgsProcessing::Pyt
}
else
{
- code += QStringLiteral( ")" );
+ code += QLatin1Char( ')' );
}
return code;
@@ -3101,7 +3101,7 @@ QString QgsProcessingParameterGeometry::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
+ code += QLatin1String( "optional " );
code += type() + ' ';
for ( int type : mGeomTypes )
@@ -3109,19 +3109,19 @@ QString QgsProcessingParameterGeometry::asScriptCode() const
switch ( static_cast( type ) )
{
case QgsWkbTypes::PointGeometry:
- code += QStringLiteral( "point " );
+ code += QLatin1String( "point " );
break;
case QgsWkbTypes::LineGeometry:
- code += QStringLiteral( "line " );
+ code += QLatin1String( "line " );
break;
case QgsWkbTypes::PolygonGeometry:
- code += QStringLiteral( "polygon " );
+ code += QLatin1String( "polygon " );
break;
default:
- code += QStringLiteral( "unknown" );
+ code += QLatin1String( "unknown" );
break;
}
}
@@ -3138,7 +3138,7 @@ QString QgsProcessingParameterGeometry::asPythonString( const QgsProcessing::Pyt
{
QString code = QStringLiteral( "QgsProcessingParameterGeometry('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
if ( !mGeomTypes.empty() )
{
@@ -3268,7 +3268,7 @@ QString QgsProcessingParameterFile::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
+ code += QLatin1String( "optional " );
code += ( mBehavior == File ? QStringLiteral( "file" ) : QStringLiteral( "folder" ) ) + ' ';
code += mDefault.toString();
return code.trimmed();
@@ -3283,7 +3283,7 @@ QString QgsProcessingParameterFile::asPythonString( const QgsProcessing::PythonO
QString code = QStringLiteral( "QgsProcessingParameterFile('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", behavior=%1" ).arg( mBehavior == File ? QStringLiteral( "QgsProcessingParameterFile.File" ) : QStringLiteral( "QgsProcessingParameterFile.Folder" ) );
if ( !mExtension.isEmpty() )
code += QStringLiteral( ", extension='%1'" ).arg( mExtension );
@@ -3429,7 +3429,7 @@ QString QgsProcessingParameterMatrix::asPythonString( const QgsProcessing::Pytho
{
QString code = QStringLiteral( "QgsProcessingParameterMatrix('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", numberRows=" ).arg( mNumberRows );
code += QStringLiteral( ", hasFixedNumberRows=" ).arg( mFixedNumberRows ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
@@ -3643,19 +3643,19 @@ QString QgsProcessingParameterMultipleLayers::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
+ code += QLatin1String( "optional " );
switch ( mLayerType )
{
case QgsProcessing::TypeRaster:
- code += QStringLiteral( "multiple raster" );
+ code += QLatin1String( "multiple raster" );
break;
case QgsProcessing::TypeFile:
- code += QStringLiteral( "multiple file" );
+ code += QLatin1String( "multiple file" );
break;
default:
- code += QStringLiteral( "multiple vector" );
+ code += QLatin1String( "multiple vector" );
break;
}
code += ' ';
@@ -3688,7 +3688,7 @@ QString QgsProcessingParameterMultipleLayers::asPythonString( const QgsProcessin
{
QString code = QStringLiteral( "QgsProcessingParameterMultipleLayers('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
QString layerType = QStringLiteral( "QgsProcessing.%1" ).arg( QgsProcessing::sourceTypeToString( mLayerType ) );
@@ -3777,11 +3777,11 @@ QgsProcessingParameterMultipleLayers *QgsProcessingParameterMultipleLayers::from
defaultVal = m.captured( 2 );
}
QgsProcessing::SourceType layerType = QgsProcessing::TypeVectorAnyGeometry;
- if ( type == QStringLiteral( "vector" ) )
+ if ( type == QLatin1String( "vector" ) )
layerType = QgsProcessing::TypeVectorAnyGeometry;
- else if ( type == QStringLiteral( "raster" ) )
+ else if ( type == QLatin1String( "raster" ) )
layerType = QgsProcessing::TypeRaster;
- else if ( type == QStringLiteral( "file" ) )
+ else if ( type == QLatin1String( "file" ) )
layerType = QgsProcessing::TypeFile;
return new QgsProcessingParameterMultipleLayers( name, description, layerType, defaultVal.isEmpty() ? QVariant() : defaultVal, isOptional );
}
@@ -3848,7 +3848,7 @@ QString QgsProcessingParameterNumber::toolTip() const
parts << QObject::tr( "Maximum value: %1" ).arg( mMax );
if ( mDefault.isValid() )
parts << QObject::tr( "Default value: %1" ).arg( mDataType == Integer ? mDefault.toInt() : mDefault.toDouble() );
- QString extra = parts.join( QStringLiteral( " " ) );
+ QString extra = parts.join( QLatin1String( " " ) );
if ( !extra.isEmpty() )
text += QStringLiteral( "%1 " ).arg( extra );
return text;
@@ -3862,7 +3862,7 @@ QString QgsProcessingParameterNumber::asPythonString( const QgsProcessing::Pytho
{
QString code = QStringLiteral( "QgsProcessingParameterNumber('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", type=%1" ).arg( mDataType == Integer ? QStringLiteral( "QgsProcessingParameterNumber.Integer" ) : QStringLiteral( "QgsProcessingParameterNumber.Double" ) );
@@ -3929,7 +3929,7 @@ bool QgsProcessingParameterNumber::fromVariantMap( const QVariantMap &map )
QgsProcessingParameterNumber *QgsProcessingParameterNumber::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
{
return new QgsProcessingParameterNumber( name, description, Double, definition.isEmpty() ? QVariant()
- : ( definition.toLower().trimmed() == QStringLiteral( "none" ) ? QVariant() : definition ), isOptional );
+ : ( definition.toLower().trimmed() == QLatin1String( "none" ) ? QVariant() : definition ), isOptional );
}
QgsProcessingParameterRange::QgsProcessingParameterRange( const QString &name, const QString &description, QgsProcessingParameterNumber::Type type, const QVariant &defaultValue, bool optional )
@@ -4013,7 +4013,7 @@ QString QgsProcessingParameterRange::asPythonString( const QgsProcessing::Python
{
QString code = QStringLiteral( "QgsProcessingParameterRange('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", type=%1" ).arg( mDataType == QgsProcessingParameterNumber::Integer ? QStringLiteral( "QgsProcessingParameterNumber.Integer" ) : QStringLiteral( "QgsProcessingParameterNumber.Double" ) );
@@ -4052,7 +4052,7 @@ bool QgsProcessingParameterRange::fromVariantMap( const QVariantMap &map )
QgsProcessingParameterRange *QgsProcessingParameterRange::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
{
return new QgsProcessingParameterRange( name, description, QgsProcessingParameterNumber::Double, definition.isEmpty() ? QVariant()
- : ( definition.toLower().trimmed() == QStringLiteral( "none" ) ? QVariant() : definition ), isOptional );
+ : ( definition.toLower().trimmed() == QLatin1String( "none" ) ? QVariant() : definition ), isOptional );
}
QgsProcessingParameterRasterLayer::QgsProcessingParameterRasterLayer( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
@@ -4234,11 +4234,11 @@ QString QgsProcessingParameterEnum::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "enum " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "enum " );
if ( mAllowMultiple )
- code += QStringLiteral( "multiple " );
+ code += QLatin1String( "multiple " );
code += mOptions.join( ';' ) + ' ';
@@ -4254,7 +4254,7 @@ QString QgsProcessingParameterEnum::asPythonString( const QgsProcessing::PythonO
{
QString code = QStringLiteral( "QgsProcessingParameterEnum('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
QStringList options;
options.reserve( mOptions.size() );
@@ -4359,11 +4359,11 @@ QString QgsProcessingParameterString::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "string " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "string " );
if ( mMultiLine )
- code += QStringLiteral( "long " );
+ code += QLatin1String( "long " );
code += mDefault.toString();
return code.trimmed();
@@ -4377,7 +4377,7 @@ QString QgsProcessingParameterString::asPythonString( const QgsProcessing::Pytho
{
QString code = QStringLiteral( "QgsProcessingParameterString('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", multiLine=%1" ).arg( mMultiLine ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
QgsProcessingContext c;
@@ -4428,7 +4428,7 @@ QgsProcessingParameterString *QgsProcessingParameterString::fromScriptCode( cons
def.chop( 1 );
QVariant defaultValue = def;
- if ( def == QStringLiteral( "None" ) )
+ if ( def == QLatin1String( "None" ) )
defaultValue = QVariant();
return new QgsProcessingParameterString( name, description, defaultValue, multiLine, isOptional );
@@ -4462,8 +4462,8 @@ QString QgsProcessingParameterAuthConfig::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "authcfg " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "authcfg " );
code += mDefault.toString();
return code.trimmed();
@@ -4479,7 +4479,7 @@ QgsProcessingParameterAuthConfig *QgsProcessingParameterAuthConfig::fromScriptCo
def.chop( 1 );
QVariant defaultValue = def;
- if ( def == QStringLiteral( "None" ) )
+ if ( def == QLatin1String( "None" ) )
defaultValue = QVariant();
return new QgsProcessingParameterAuthConfig( name, description, defaultValue, isOptional );
@@ -4530,7 +4530,7 @@ QString QgsProcessingParameterExpression::asPythonString( const QgsProcessing::P
{
QString code = QStringLiteral( "QgsProcessingParameterExpression('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
@@ -4645,7 +4645,7 @@ QString QgsProcessingParameterVectorLayer::asPythonString( const QgsProcessing::
{
QString code = QStringLiteral( "QgsProcessingParameterVectorLayer('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
if ( !mDataTypes.empty() )
{
@@ -4872,21 +4872,21 @@ QString QgsProcessingParameterField::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "field " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "field " );
switch ( mDataType )
{
case Numeric:
- code += QStringLiteral( "numeric " );
+ code += QLatin1String( "numeric " );
break;
case String:
- code += QStringLiteral( "string " );
+ code += QLatin1String( "string " );
break;
case DateTime:
- code += QStringLiteral( "datetime " );
+ code += QLatin1String( "datetime " );
break;
case Any:
@@ -4894,10 +4894,10 @@ QString QgsProcessingParameterField::asScriptCode() const
}
if ( mAllowMultiple )
- code += QStringLiteral( "multiple " );
+ code += QLatin1String( "multiple " );
if ( mDefaultToAllFields )
- code += QStringLiteral( "default_to_all_fields " );
+ code += QLatin1String( "default_to_all_fields " );
code += mParentLayerParameterName + ' ';
@@ -4913,7 +4913,7 @@ QString QgsProcessingParameterField::asPythonString( const QgsProcessing::Python
{
QString code = QStringLiteral( "QgsProcessingParameterField('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
QString dataType;
switch ( mDataType )
@@ -4942,7 +4942,7 @@ QString QgsProcessingParameterField::asPythonString( const QgsProcessing::Python
code += QStringLiteral( ", defaultValue=%1" ).arg( valueAsPythonString( mDefault, c ) );
if ( mDefaultToAllFields )
- code += QStringLiteral( ", defaultToAllFields=True" );
+ code += QLatin1String( ", defaultToAllFields=True" );
code += ')';
@@ -5169,7 +5169,7 @@ QString QgsProcessingParameterFeatureSource::valueAsPythonString( const QVariant
if ( fromVar.flags & QgsProcessingFeatureSourceDefinition::Flag::FlagCreateIndividualOutputPerInputFeature )
flags << QStringLiteral( "QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
if ( !flags.empty() )
- flagString = flags.join( QStringLiteral( " | " ) );
+ flagString = flags.join( QLatin1String( " | " ) );
if ( fromVar.source.propertyType() == QgsProperty::StaticProperty )
{
@@ -5226,23 +5226,23 @@ QString QgsProcessingParameterFeatureSource::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "source " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "source " );
for ( int type : mDataTypes )
{
switch ( type )
{
case QgsProcessing::TypeVectorPoint:
- code += QStringLiteral( "point " );
+ code += QLatin1String( "point " );
break;
case QgsProcessing::TypeVectorLine:
- code += QStringLiteral( "line " );
+ code += QLatin1String( "line " );
break;
case QgsProcessing::TypeVectorPolygon:
- code += QStringLiteral( "polygon " );
+ code += QLatin1String( "polygon " );
break;
}
@@ -5260,7 +5260,7 @@ QString QgsProcessingParameterFeatureSource::asPythonString( const QgsProcessing
{
QString code = QStringLiteral( "QgsProcessingParameterFeatureSource('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
if ( !mDataTypes.empty() )
{
@@ -5418,25 +5418,25 @@ QString QgsProcessingParameterFeatureSink::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "sink " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "sink " );
switch ( mDataType )
{
case QgsProcessing::TypeVectorPoint:
- code += QStringLiteral( "point " );
+ code += QLatin1String( "point " );
break;
case QgsProcessing::TypeVectorLine:
- code += QStringLiteral( "line " );
+ code += QLatin1String( "line " );
break;
case QgsProcessing::TypeVectorPolygon:
- code += QStringLiteral( "polygon " );
+ code += QLatin1String( "polygon " );
break;
case QgsProcessing::TypeVector:
- code += QStringLiteral( "table " );
+ code += QLatin1String( "table " );
break;
default:
@@ -5483,13 +5483,13 @@ QString QgsProcessingParameterFeatureSink::asPythonString( const QgsProcessing::
{
QString code = QStringLiteral( "QgsProcessingParameterFeatureSink('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", type=QgsProcessing.%1" ).arg( QgsProcessing::sourceTypeToString( mDataType ) );
code += QStringLiteral( ", createByDefault=%1" ).arg( createByDefault() ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
if ( mSupportsAppend )
- code += QStringLiteral( ", supportsAppend=True" );
+ code += QLatin1String( ", supportsAppend=True" );
QgsProcessingContext c;
code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
@@ -5507,7 +5507,7 @@ QString QgsProcessingParameterFeatureSink::createFileFilter() const
{
filters << QObject::tr( "%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
}
- return filters.join( QStringLiteral( ";;" ) ) + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
+ return filters.join( QLatin1String( ";;" ) ) + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
}
@@ -5722,7 +5722,7 @@ QString QgsProcessingParameterRasterDestination::createFileFilter() const
{
filters << QObject::tr( "%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
}
- return filters.join( QStringLiteral( ";;" ) ) + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
+ return filters.join( QLatin1String( ";;" ) ) + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
}
QStringList QgsProcessingParameterRasterDestination::supportedOutputRasterLayerExtensions() const
@@ -5853,7 +5853,7 @@ QString QgsProcessingParameterFileDestination::asPythonString( const QgsProcessi
{
QString code = QStringLiteral( "QgsProcessingParameterFileDestination('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", fileFilter=%1" ).arg( QgsProcessingUtils::stringToPythonLiteral( mFileFilter ) );
@@ -5988,7 +5988,7 @@ QString QgsProcessingDestinationParameter::asPythonString( const QgsProcessing::
{
QString code = t->className() + QStringLiteral( "('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
@@ -6120,21 +6120,21 @@ QString QgsProcessingParameterVectorDestination::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "vectorDestination " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "vectorDestination " );
switch ( mDataType )
{
case QgsProcessing::TypeVectorPoint:
- code += QStringLiteral( "point " );
+ code += QLatin1String( "point " );
break;
case QgsProcessing::TypeVectorLine:
- code += QStringLiteral( "line " );
+ code += QLatin1String( "line " );
break;
case QgsProcessing::TypeVectorPolygon:
- code += QStringLiteral( "polygon " );
+ code += QLatin1String( "polygon " );
break;
default:
@@ -6181,7 +6181,7 @@ QString QgsProcessingParameterVectorDestination::asPythonString( const QgsProces
{
QString code = QStringLiteral( "QgsProcessingParameterVectorDestination('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", type=QgsProcessing.%1" ).arg( QgsProcessing::sourceTypeToString( mDataType ) );
@@ -6203,7 +6203,7 @@ QString QgsProcessingParameterVectorDestination::createFileFilter() const
{
filters << QObject::tr( "%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
}
- return filters.join( QStringLiteral( ";;" ) ) + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
+ return filters.join( QLatin1String( ";;" ) ) + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
}
QStringList QgsProcessingParameterVectorDestination::supportedOutputVectorLayerExtensions() const
@@ -6383,11 +6383,11 @@ QString QgsProcessingParameterBand::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "band " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "band " );
if ( mAllowMultiple )
- code += QStringLiteral( "multiple " );
+ code += QLatin1String( "multiple " );
code += mParentLayerParameterName + ' ';
@@ -6411,7 +6411,7 @@ QString QgsProcessingParameterBand::asPythonString( const QgsProcessing::PythonO
{
QString code = QStringLiteral( "QgsProcessingParameterBand('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
code += QStringLiteral( ", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
@@ -6515,7 +6515,7 @@ QString QgsProcessingParameterDistance::asPythonString( const QgsProcessing::Pyt
{
QString code = QStringLiteral( "QgsProcessingParameterDistance('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", parentParameterName='%1'" ).arg( mParentParameterName );
@@ -6586,7 +6586,7 @@ QString QgsProcessingParameterScale::asPythonString( const QgsProcessing::Python
{
QString code = QStringLiteral( "QgsProcessingParameterScale('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
QgsProcessingContext c;
code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
return code;
@@ -6598,7 +6598,7 @@ QString QgsProcessingParameterScale::asPythonString( const QgsProcessing::Python
QgsProcessingParameterScale *QgsProcessingParameterScale::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
{
return new QgsProcessingParameterScale( name, description, definition.isEmpty() ? QVariant()
- : ( definition.toLower().trimmed() == QStringLiteral( "none" ) ? QVariant() : definition ), isOptional );
+ : ( definition.toLower().trimmed() == QLatin1String( "none" ) ? QVariant() : definition ), isOptional );
}
@@ -6631,8 +6631,8 @@ QString QgsProcessingParameterLayout::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "layout " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "layout " );
code += mDefault.toString();
return code.trimmed();
@@ -6646,7 +6646,7 @@ QString QgsProcessingParameterLayout::asPythonString( const QgsProcessing::Pytho
{
QString code = QStringLiteral( "QgsProcessingParameterLayout('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
QgsProcessingContext c;
code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
return code;
@@ -6665,7 +6665,7 @@ QgsProcessingParameterLayout *QgsProcessingParameterLayout::fromScriptCode( cons
def.chop( 1 );
QVariant defaultValue = def;
- if ( def == QStringLiteral( "None" ) )
+ if ( def == QLatin1String( "None" ) )
defaultValue = QVariant();
return new QgsProcessingParameterLayout( name, description, defaultValue, isOptional );
@@ -6705,8 +6705,8 @@ QString QgsProcessingParameterLayoutItem::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "layoutitem " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "layoutitem " );
if ( mItemType >= 0 )
code += QString::number( mItemType ) + ' ';
@@ -6724,7 +6724,7 @@ QString QgsProcessingParameterLayoutItem::asPythonString( QgsProcessing::PythonO
{
QString code = QStringLiteral( "QgsProcessingParameterLayoutItem('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
if ( mItemType >= 0 )
code += QStringLiteral( ", itemType=%1" ).arg( mItemType );
@@ -6849,11 +6849,11 @@ QString QgsProcessingParameterColor::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "color " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "color " );
if ( mAllowOpacity )
- code += QStringLiteral( "withopacity " );
+ code += QLatin1String( "withopacity " );
code += mDefault.toString();
return code.trimmed();
@@ -6867,7 +6867,7 @@ QString QgsProcessingParameterColor::asPythonString( const QgsProcessing::Python
{
QString code = QStringLiteral( "QgsProcessingParameterColor('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
@@ -6944,7 +6944,7 @@ QgsProcessingParameterColor *QgsProcessingParameterColor::fromScriptCode( const
def.chop( 1 );
QVariant defaultValue = def;
- if ( def == QStringLiteral( "None" ) )
+ if ( def == QLatin1String( "None" ) )
defaultValue = QVariant();
return new QgsProcessingParameterColor( name, description, defaultValue, allowOpacity, isOptional );
@@ -6998,8 +6998,8 @@ QString QgsProcessingParameterCoordinateOperation::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "coordinateoperation " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "coordinateoperation " );
code += mDefault.toString();
return code.trimmed();
@@ -7014,7 +7014,7 @@ QString QgsProcessingParameterCoordinateOperation::asPythonString( QgsProcessing
QgsProcessingContext c;
QString code = QStringLiteral( "QgsProcessingParameterCoordinateOperation('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
if ( !mSourceParameterName.isEmpty() )
code += QStringLiteral( ", sourceCrsParameterName=%1" ).arg( valueAsPythonString( mSourceParameterName, c ) );
if ( !mDestParameterName.isEmpty() )
@@ -7072,7 +7072,7 @@ QgsProcessingParameterCoordinateOperation *QgsProcessingParameterCoordinateOpera
def.chop( 1 );
QVariant defaultValue = def;
- if ( def == QStringLiteral( "None" ) )
+ if ( def == QLatin1String( "None" ) )
defaultValue = QVariant();
return new QgsProcessingParameterCoordinateOperation( name, description, defaultValue, QString(), QString(), QVariant(), QVariant(), isOptional );
@@ -7122,8 +7122,8 @@ QString QgsProcessingParameterMapTheme::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "maptheme " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "maptheme " );
code += mDefault.toString();
return code.trimmed();
@@ -7137,7 +7137,7 @@ QString QgsProcessingParameterMapTheme::asPythonString( const QgsProcessing::Pyt
{
QString code = QStringLiteral( "QgsProcessingParameterMapTheme('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
QgsProcessingContext c;
code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
@@ -7172,7 +7172,7 @@ QgsProcessingParameterMapTheme *QgsProcessingParameterMapTheme::fromScriptCode(
QVariant defaultValue = def;
- if ( defaultValue == QStringLiteral( "None" ) || defaultValue.toString().isEmpty() )
+ if ( defaultValue == QLatin1String( "None" ) || defaultValue.toString().isEmpty() )
defaultValue = QVariant();
return new QgsProcessingParameterMapTheme( name, description, defaultValue, isOptional );
@@ -7306,7 +7306,7 @@ QString QgsProcessingParameterDateTime::toolTip() const
if ( mDefault.isValid() )
parts << QObject::tr( "Default value: %1" ).arg( mDataType == DateTime ? mDefault.toDateTime().toString( Qt::ISODate ) :
( mDataType == Date ? mDefault.toDate().toString( Qt::ISODate ) : mDefault.toTime( ).toString() ) );
- QString extra = parts.join( QStringLiteral( " " ) );
+ QString extra = parts.join( QLatin1String( " " ) );
if ( !extra.isEmpty() )
text += QStringLiteral( "%1 " ).arg( extra );
return text;
@@ -7320,7 +7320,7 @@ QString QgsProcessingParameterDateTime::asPythonString( const QgsProcessing::Pyt
{
QString code = QStringLiteral( "QgsProcessingParameterDateTime('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", type=%1" ).arg( mDataType == DateTime ? QStringLiteral( "QgsProcessingParameterDateTime.DateTime" )
: mDataType == Date ? QStringLiteral( "QgsProcessingParameterDateTime.Date" )
@@ -7389,7 +7389,7 @@ bool QgsProcessingParameterDateTime::fromVariantMap( const QVariantMap &map )
QgsProcessingParameterDateTime *QgsProcessingParameterDateTime::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
{
return new QgsProcessingParameterDateTime( name, description, DateTime, definition.isEmpty() ? QVariant()
- : ( definition.toLower().trimmed() == QStringLiteral( "none" ) ? QVariant() : definition ), isOptional );
+ : ( definition.toLower().trimmed() == QLatin1String( "none" ) ? QVariant() : definition ), isOptional );
}
@@ -7438,8 +7438,8 @@ QString QgsProcessingParameterProviderConnection::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "providerconnection " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "providerconnection " );
code += mProviderId + ' ';
code += mDefault.toString();
@@ -7454,7 +7454,7 @@ QString QgsProcessingParameterProviderConnection::asPythonString( const QgsProce
{
QString code = QStringLiteral( "QgsProcessingParameterProviderConnection('%1', '%2', '%3'" ).arg( name(), description(), mProviderId );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
QgsProcessingContext c;
code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
@@ -7503,7 +7503,7 @@ QgsProcessingParameterProviderConnection *QgsProcessingParameterProviderConnecti
QVariant defaultValue = def;
- if ( defaultValue == QStringLiteral( "None" ) || defaultValue.toString().isEmpty() )
+ if ( defaultValue == QLatin1String( "None" ) || defaultValue.toString().isEmpty() )
defaultValue = QVariant();
return new QgsProcessingParameterProviderConnection( name, description, provider, defaultValue, isOptional );
@@ -7554,8 +7554,8 @@ QString QgsProcessingParameterDatabaseSchema::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "databaseschema " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "databaseschema " );
code += mParentConnectionParameterName + ' ';
@@ -7571,7 +7571,7 @@ QString QgsProcessingParameterDatabaseSchema::asPythonString( const QgsProcessin
{
QString code = QStringLiteral( "QgsProcessingParameterDatabaseSchema('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
code += QStringLiteral( ", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
QgsProcessingContext c;
@@ -7687,8 +7687,8 @@ QString QgsProcessingParameterDatabaseTable::asScriptCode() const
{
QString code = QStringLiteral( "##%1=" ).arg( mName );
if ( mFlags & FlagOptional )
- code += QStringLiteral( "optional " );
- code += QStringLiteral( "databasetable " );
+ code += QLatin1String( "optional " );
+ code += QLatin1String( "databasetable " );
code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral( "none" ) : mParentConnectionParameterName ) + ' ';
code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral( "none" ) : mParentSchemaParameterName ) + ' ';
@@ -7705,10 +7705,10 @@ QString QgsProcessingParameterDatabaseTable::asPythonString( const QgsProcessing
{
QString code = QStringLiteral( "QgsProcessingParameterDatabaseTable('%1', '%2'" ).arg( name(), description() );
if ( mFlags & FlagOptional )
- code += QStringLiteral( ", optional=True" );
+ code += QLatin1String( ", optional=True" );
if ( mAllowNewTableNames )
- code += QStringLiteral( ", allowNewTableNames=True" );
+ code += QLatin1String( ", allowNewTableNames=True" );
code += QStringLiteral( ", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
code += QStringLiteral( ", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
diff --git a/src/core/processing/qgsprocessingutils.cpp b/src/core/processing/qgsprocessingutils.cpp
index d24030649425..6198194dd693 100644
--- a/src/core/processing/qgsprocessingutils.cpp
+++ b/src/core/processing/qgsprocessingutils.cpp
@@ -611,12 +611,12 @@ QString QgsProcessingUtils::variantToPythonLiteral( const QVariant &value )
QString QgsProcessingUtils::stringToPythonLiteral( const QString &string )
{
QString s = string;
- s.replace( '\\', QStringLiteral( "\\\\" ) );
- s.replace( '\n', QStringLiteral( "\\n" ) );
- s.replace( '\r', QStringLiteral( "\\r" ) );
- s.replace( '\t', QStringLiteral( "\\t" ) );
- s.replace( '"', QStringLiteral( "\\\"" ) );
- s.replace( '\'', QStringLiteral( "\\\'" ) );
+ s.replace( '\\', QLatin1String( "\\\\" ) );
+ s.replace( '\n', QLatin1String( "\\n" ) );
+ s.replace( '\r', QLatin1String( "\\r" ) );
+ s.replace( '\t', QLatin1String( "\\t" ) );
+ s.replace( '"', QLatin1String( "\\\"" ) );
+ s.replace( '\'', QLatin1String( "\\\'" ) );
s = s.prepend( '\'' ).append( '\'' );
return s;
}
@@ -640,7 +640,7 @@ void QgsProcessingUtils::parseDestinationString( QString &destination, QString &
if ( matched )
{
- if ( providerKey == QStringLiteral( "postgis" ) ) // older processing used "postgis" instead of "postgres"
+ if ( providerKey == QLatin1String( "postgis" ) ) // older processing used "postgis" instead of "postgres"
{
providerKey = QStringLiteral( "postgres" );
}
@@ -908,14 +908,14 @@ QVariant QgsProcessingUtils::generateIteratingDestination( const QVariant &input
}
else if ( res.startsWith( QLatin1String( "memory:" ) ) )
{
- return res + '_' + id.toString();
+ return QString( res + '_' + id.toString() );
}
else
{
// assume a filename type output for now
// TODO - uris?
int lastIndex = res.lastIndexOf( '.' );
- return res.left( lastIndex ) + '_' + id.toString() + res.mid( lastIndex );
+ return QString( res.left( lastIndex ) + '_' + id.toString() + res.mid( lastIndex ) );
}
}
}
@@ -1008,7 +1008,7 @@ QString QgsProcessingUtils::formatHelpMapAsHtml( const QVariantMap &map, const Q
if ( !map.value( QStringLiteral( "ALG_VERSION" ) ).toString().isEmpty() )
s += QObject::tr( "Algorithm version: %1 " ).arg( getText( QStringLiteral( "ALG_VERSION" ) ) );
- s += QStringLiteral( "" );
+ s += QLatin1String( "" );
return s;
}
diff --git a/src/core/providers/gdal/qgsgdaldataitems.cpp b/src/core/providers/gdal/qgsgdaldataitems.cpp
index b73566c80275..f8b8f21dd135 100644
--- a/src/core/providers/gdal/qgsgdaldataitems.cpp
+++ b/src/core/providers/gdal/qgsgdaldataitems.cpp
@@ -263,12 +263,12 @@ QgsDataItem *QgsGdalDataItemProvider::createDataItem( const QString &pathIn, Qgs
#endif
}
- if ( suffix == QStringLiteral( "mbtiles" ) )
+ if ( suffix == QLatin1String( "mbtiles" ) )
{
QgsMbTiles reader( path );
if ( reader.open() )
{
- if ( reader.metadataValue( "format" ) == QStringLiteral( "pbf" ) )
+ if ( reader.metadataValue( "format" ) == QLatin1String( "pbf" ) )
{
// these are vector tiles
QUrlQuery uq;
diff --git a/src/core/providers/gdal/qgsgdalprovider.cpp b/src/core/providers/gdal/qgsgdalprovider.cpp
index d76e1d5c1c2b..1fb090aaa472 100644
--- a/src/core/providers/gdal/qgsgdalprovider.cpp
+++ b/src/core/providers/gdal/qgsgdalprovider.cpp
@@ -214,8 +214,8 @@ QgsGdalProvider::QgsGdalProvider( const QgsGdalProvider &other )
// so make sure to really use a single one.
// The PostGISRaster driver internally uses a per-thread connection cache.
// This can lead to crashes if two datasets created by the same thread are used at the same time.
- bool forceUseSameDataset = ( mDriverName.toUpper() == QStringLiteral( "JP2OPENJPEG" ) ||
- mDriverName == QStringLiteral( "PostGISRaster" ) ||
+ bool forceUseSameDataset = ( mDriverName.toUpper() == QLatin1String( "JP2OPENJPEG" ) ||
+ mDriverName == QLatin1String( "PostGISRaster" ) ||
CSLTestBoolean( CPLGetConfigOption( "QGIS_GDAL_FORCE_USE_SAME_DATASET", "FALSE" ) ) );
if ( forceUseSameDataset )
@@ -588,7 +588,7 @@ QString QgsGdalProvider::htmlMetadata()
QStringList categories = QgsOgrUtils::cStringListToQStringList( GDALcategories );
myMetadata += QgsHtmlUtils::buildBulletList( categories );
}
- myMetadata += QStringLiteral( "" );
+ myMetadata += QLatin1String( "" );
}
// More information
@@ -626,7 +626,7 @@ QString QgsGdalProvider::htmlMetadata()
}
// End more information
- myMetadata += QStringLiteral( "\n" );
+ myMetadata += QLatin1String( "\n" );
// Dimensions
myMetadata += QStringLiteral( "" ) + tr( "Dimensions" ) + QStringLiteral( " | " );
@@ -634,7 +634,7 @@ QString QgsGdalProvider::htmlMetadata()
.arg( GDALGetRasterXSize( mGdalDataset ) )
.arg( GDALGetRasterYSize( mGdalDataset ) )
.arg( GDALGetRasterCount( mGdalDataset ) );
- myMetadata += QStringLiteral( " | \n" );
+ myMetadata += QLatin1String( "\n" );
if ( GDALGetGeoTransform( mGdalDataset, mGeoTransform ) != CE_None )
{
@@ -1302,13 +1302,19 @@ QString QgsGdalProvider::generateBandName( int bandNumber ) const
}
if ( !bandNameValues.isEmpty() )
{
- return tr( "Band" ) + QStringLiteral( " %1: %2" ).arg( bandNumber, 1 + ( int ) std::log10( ( float ) bandCount() ), 10, QChar( '0' ) ).arg( bandNameValues.join( QStringLiteral( " / " ) ) );
+ return tr( "Band" ) + QStringLiteral( " %1: %2" ).arg( bandNumber, 1 + ( int ) std::log10( ( float ) bandCount() ), 10, QChar( '0' ) ).arg( bandNameValues.join( QLatin1String( " / " ) ) );
}
}
}
}
QString generatedBandName = QgsRasterDataProvider::generateBandName( bandNumber );
GDALRasterBandH myGdalBand = getBand( bandNumber );
+ if ( ! myGdalBand )
+ {
+ QgsLogger::warning( QStringLiteral( "Band %1 does not exist." ).arg( bandNumber ) );
+ return QString();
+ }
+
QString gdalBandName( GDALGetDescription( myGdalBand ) );
if ( !gdalBandName.isEmpty() )
{
@@ -2325,7 +2331,7 @@ QVariantMap QgsGdalProviderMetadata::decodeUri( const QString &uri )
if ( path.indexOf( ':' ) != -1 )
{
QStringList parts = path.split( ':' );
- if ( parts[0].toLower() == QStringLiteral( "gpkg" ) )
+ if ( parts[0].toLower() == QLatin1String( "gpkg" ) )
{
parts.removeFirst();
// Handle windows paths - which has an extra colon - and unix paths
@@ -2460,7 +2466,7 @@ void buildSupportedRasterFileFilterAndExtensions( QString &fileFiltersString, QS
// This hacking around that removes '/' is no longer necessary with GDAL 2.3
extensions << QString( ext ).remove( '/' ).remove( '*' ).remove( '.' );
if ( !glob.isEmpty() )
- glob += QLatin1String( " " );
+ glob += QLatin1Char( ' ' );
glob += "*." + QString( ext ).replace( '/', QLatin1String( " *." ) );
}
@@ -2534,7 +2540,7 @@ void buildSupportedRasterFileFilterAndExtensions( QString &fileFiltersString, QS
QStringList filters = fileFiltersString.split( QStringLiteral( ";;" ), Qt::SkipEmptyParts );
#endif
filters.sort();
- fileFiltersString = filters.join( QStringLiteral( ";;" ) ) + ";;";
+ fileFiltersString = filters.join( QLatin1String( ";;" ) ) + ";;";
// VSIFileHandler (see qgsogrprovider.cpp) - second
QgsSettings settings;
@@ -2548,7 +2554,7 @@ void buildSupportedRasterFileFilterAndExtensions( QString &fileFiltersString, QS
QStringList exts;
for ( const QString &ext : qgis::as_const( extensions ) )
exts << QStringLiteral( "*.%1 *.%2" ).arg( ext, ext.toUpper() );
- fileFiltersString.prepend( QObject::tr( "All supported files" ) + QStringLiteral( " (%1);;" ).arg( exts.join( QStringLiteral( " " ) ) ) );
+ fileFiltersString.prepend( QObject::tr( "All supported files" ) + QStringLiteral( " (%1);;" ).arg( exts.join( QLatin1Char( ' ' ) ) ) );
// can't forget the default case - first
fileFiltersString.prepend( QObject::tr( "All files" ) + " (*);;" );
diff --git a/src/core/providers/memory/qgsmemoryfeatureiterator.cpp b/src/core/providers/memory/qgsmemoryfeatureiterator.cpp
index 20b041e866ee..4a0a8a5ec9cf 100644
--- a/src/core/providers/memory/qgsmemoryfeatureiterator.cpp
+++ b/src/core/providers/memory/qgsmemoryfeatureiterator.cpp
@@ -47,7 +47,7 @@ QgsMemoryFeatureIterator::QgsMemoryFeatureIterator( QgsMemoryFeatureSource *sour
if ( !mSource->mSubsetString.isEmpty() )
{
mSubsetExpression = qgis::make_unique< QgsExpression >( mSource->mSubsetString );
- mSubsetExpression->prepare( &mSource->mExpressionContext );
+ mSubsetExpression->prepare( mSource->expressionContext() );
}
if ( !mFilterRect.isNull() && mRequest.flags() & QgsFeatureRequest::ExactIntersect )
@@ -63,7 +63,7 @@ QgsMemoryFeatureIterator::QgsMemoryFeatureIterator( QgsMemoryFeatureSource *sour
{
mUsingFeatureIdList = true;
mFeatureIdList = mSource->mSpatialIndex->intersects( mFilterRect );
- QgsDebugMsg( "Features returned by spatial index: " + QString::number( mFeatureIdList.count() ) );
+ QgsDebugMsgLevel( "Features returned by spatial index: " + QString::number( mFeatureIdList.count() ), 2 );
}
else if ( mRequest.filterType() == QgsFeatureRequest::FilterFid )
{
@@ -138,8 +138,8 @@ bool QgsMemoryFeatureIterator::nextFeatureUsingList( QgsFeature &feature )
if ( hasFeature && mSubsetExpression )
{
- mSource->mExpressionContext.setFeature( candidate );
- if ( !mSubsetExpression->evaluate( &mSource->mExpressionContext ).toBool() )
+ mSource->expressionContext()->setFeature( candidate );
+ if ( !mSubsetExpression->evaluate( mSource->expressionContext() ).toBool() )
hasFeature = false;
}
@@ -198,8 +198,8 @@ bool QgsMemoryFeatureIterator::nextFeatureTraverseAll( QgsFeature &feature )
if ( mSubsetExpression )
{
- mSource->mExpressionContext.setFeature( *mSelectIterator );
- if ( !mSubsetExpression->evaluate( &mSource->mExpressionContext ).toBool() )
+ mSource->expressionContext()->setFeature( *mSelectIterator );
+ if ( !mSubsetExpression->evaluate( mSource->expressionContext() ).toBool() )
hasFeature = false;
}
@@ -257,9 +257,6 @@ QgsMemoryFeatureSource::QgsMemoryFeatureSource( const QgsMemoryProvider *p )
, mSubsetString( p->mSubsetString )
, mCrs( p->mCrs )
{
- mExpressionContext << QgsExpressionContextUtils::globalScope()
- << QgsExpressionContextUtils::projectScope( QgsProject::instance() );
- mExpressionContext.setFields( mFields );
}
QgsFeatureIterator QgsMemoryFeatureSource::getFeatures( const QgsFeatureRequest &request )
@@ -267,4 +264,19 @@ QgsFeatureIterator QgsMemoryFeatureSource::getFeatures( const QgsFeatureRequest
return QgsFeatureIterator( new QgsMemoryFeatureIterator( this, false, request ) );
}
+QgsExpressionContext *QgsMemoryFeatureSource::expressionContext()
+{
+ // lazy construct expression context -- it's not free to calculate, and is only used when
+ // iterating over a memory layer with a subset string set
+ if ( !mExpressionContext )
+ {
+ mExpressionContext = qgis::make_unique< QgsExpressionContext >(
+ QList()
+ << QgsExpressionContextUtils::globalScope()
+ << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) );
+ mExpressionContext->setFields( mFields );
+ }
+ return mExpressionContext.get();
+}
+
///@endcond PRIVATE
diff --git a/src/core/providers/memory/qgsmemoryfeatureiterator.h b/src/core/providers/memory/qgsmemoryfeatureiterator.h
index 1c771dab6edd..404fccec17b4 100644
--- a/src/core/providers/memory/qgsmemoryfeatureiterator.h
+++ b/src/core/providers/memory/qgsmemoryfeatureiterator.h
@@ -38,12 +38,14 @@ class QgsMemoryFeatureSource final: public QgsAbstractFeatureSource
QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) override;
+ QgsExpressionContext *expressionContext();
+
private:
QgsFields mFields;
QgsFeatureMap mFeatures;
std::unique_ptr< QgsSpatialIndex > mSpatialIndex;
QString mSubsetString;
- QgsExpressionContext mExpressionContext;
+ std::unique_ptr< QgsExpressionContext > mExpressionContext;
QgsCoordinateReferenceSystem mCrs;
friend class QgsMemoryFeatureIterator;
diff --git a/src/core/providers/ogr/qgsgeopackageprojectstorage.cpp b/src/core/providers/ogr/qgsgeopackageprojectstorage.cpp
index a33ea6690cb5..7d21ce7319fe 100644
--- a/src/core/providers/ogr/qgsgeopackageprojectstorage.cpp
+++ b/src/core/providers/ogr/qgsgeopackageprojectstorage.cpp
@@ -273,7 +273,7 @@ QString QgsGeoPackageProjectStorage::encodeUri( const QgsGeoPackageProjectUri &g
// Check for windows network shares: github issue #31310
QString database { gpkgUri.database };
- if ( database.startsWith( QStringLiteral( "//" ) ) )
+ if ( database.startsWith( QLatin1String( "//" ) ) )
{
u.setPath( database.replace( '/', '\\' ) );
}
@@ -301,7 +301,7 @@ QgsGeoPackageProjectUri QgsGeoPackageProjectStorage::decodeUri( const QString &u
const QRegularExpression winLocalPath { R"(^[A-Za-z]:)" };
// Check for windows network shares: github issue #31310
const QString path { ( winLocalPath.match( urlAsString ).hasMatch() ||
- urlAsString.startsWith( QStringLiteral( "//" ) ) ) ?
+ urlAsString.startsWith( QLatin1String( "//" ) ) ) ?
urlAsString :
url.path() };
diff --git a/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp b/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp
index 263d93155f45..0cd435f599ad 100644
--- a/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp
+++ b/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp
@@ -268,11 +268,11 @@ QList QgsGeoPackageProviderConne
static const QStringList aspatialTypes = { QStringLiteral( "attributes" ), QStringLiteral( "aspatial" ) };
const QString dataType = row.at( 1 ).toString();
// Table type
- if ( dataType == QStringLiteral( "tiles" ) || dataType == QStringLiteral( "2d-gridded-coverage" ) )
+ if ( dataType == QLatin1String( "tiles" ) || dataType == QLatin1String( "2d-gridded-coverage" ) )
{
property.setFlag( QgsGeoPackageProviderConnection::Raster );
}
- else if ( dataType == QStringLiteral( "features" ) )
+ else if ( dataType == QLatin1String( "features" ) )
{
property.setFlag( QgsGeoPackageProviderConnection::Vector );
property.setGeometryColumn( row.at( 5 ).toString() );
diff --git a/src/core/providers/ogr/qgsogrdataitems.cpp b/src/core/providers/ogr/qgsogrdataitems.cpp
index 9b4ecf01d7b7..1d9d4a265d41 100644
--- a/src/core/providers/ogr/qgsogrdataitems.cpp
+++ b/src/core/providers/ogr/qgsogrdataitems.cpp
@@ -66,11 +66,11 @@ QVector QgsOgrLayerItem::createChildren()
QVector children;
// Geopackage is handled by QgsGeoPackageVectorLayerItem and QgsGeoPackageRasterLayerItem
// Proxy to spatialite provider data items because it implements the connections API
- if ( mDriverName == QStringLiteral( "SQLite" ) )
+ if ( mDriverName == QLatin1String( "SQLite" ) )
{
children.push_back( new QgsFieldsItem( this,
path() + QStringLiteral( "/columns/ " ),
- QStringLiteral( R"(dbname="%1")" ).arg( parent()->path().replace( '"', QStringLiteral( R"(\")" ) ) ),
+ QStringLiteral( R"(dbname="%1")" ).arg( parent()->path().replace( '"', QLatin1String( R"(\")" ) ) ),
QStringLiteral( "spatialite" ), QString(), name() ) );
}
return children;
@@ -372,7 +372,7 @@ QVector QgsOgrDataCollectionItem::createChildren()
GDALDriverH hDriver = GDALGetDatasetDriver( hDataSource.get() );
const QString driverName = QString::fromUtf8( GDALGetDriverShortName( hDriver ) );
- if ( driverName == QStringLiteral( "SQLite" ) )
+ if ( driverName == QLatin1String( "SQLite" ) )
{
skippedLayerNames = QgsSqliteUtils::systemTables();
}
@@ -396,7 +396,7 @@ QVector QgsOgrDataCollectionItem::createChildren()
uniqueNames = false;
break;
}
- if ( ( driverName == QStringLiteral( "SQLite" ) && layerName.contains( QRegularExpression( QStringLiteral( "idx_.*_geometry($|_.*)" ) ) ) )
+ if ( ( driverName == QLatin1String( "SQLite" ) && layerName.contains( QRegularExpression( QStringLiteral( "idx_.*_geometry($|_.*)" ) ) ) )
|| skippedLayerNames.contains( layerName ) )
{
skippedLayers << i;
diff --git a/src/core/providers/ogr/qgsogrdbconnection.cpp b/src/core/providers/ogr/qgsogrdbconnection.cpp
index ff9998854b57..7dd29068ea84 100644
--- a/src/core/providers/ogr/qgsogrdbconnection.cpp
+++ b/src/core/providers/ogr/qgsogrdbconnection.cpp
@@ -57,7 +57,7 @@ void QgsOgrDbConnection::save( )
bool QgsOgrDbConnection::allowProjectsInDatabase()
{
- return mSettingsKey == QStringLiteral( "GPKG" );
+ return mSettingsKey == QLatin1String( "GPKG" );
}
QString QgsOgrDbConnection::fullKey( const QString &settingsKey )
diff --git a/src/core/providers/ogr/qgsogrfeatureiterator.cpp b/src/core/providers/ogr/qgsogrfeatureiterator.cpp
index 2d69538fc10f..d773fccb1052 100644
--- a/src/core/providers/ogr/qgsogrfeatureiterator.cpp
+++ b/src/core/providers/ogr/qgsogrfeatureiterator.cpp
@@ -41,12 +41,22 @@
///@cond PRIVATE
-QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool ownSource, const QgsFeatureRequest &request )
+QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool ownSource, const QgsFeatureRequest &request, QgsTransaction *transaction )
: QgsAbstractFeatureIteratorFromSource( source, ownSource, request )
, mSharedDS( source->mSharedDS )
, mFirstFieldIsFid( source->mFirstFieldIsFid )
, mFieldsWithoutFid( source->mFieldsWithoutFid )
{
+
+ /* When inside a transaction for GPKG/SQLite and fetching fid(s) we might be nested inside an outer fetching loop,
+ * (see GH #39178) so we need to skip all calls that might reset the reading (rewind) to avoid an endless loop in the
+ * outer fetching iterator that uses the same connection.
+ */
+ mAllowResetReading = ! transaction ||
+ ( source->mDriverName != QLatin1String( "GPKG" ) && source->mDriverName != QLatin1String( "SQLite" ) ) ||
+ ( mRequest.filterType() != QgsFeatureRequest::FilterType::FilterFid
+ && mRequest.filterType() != QgsFeatureRequest::FilterType::FilterFids );
+
for ( const auto &id : mRequest.filterFids() )
{
mFilterFids.insert( id );
@@ -85,7 +95,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
return;
}
- if ( !mSource->mSubsetString.isEmpty() )
+ if ( mAllowResetReading && !mSource->mSubsetString.isEmpty() )
{
mOgrLayerOri = mOgrLayer;
mOgrLayer = QgsOgrProviderUtils::setSubsetString( mOgrLayer, mConn->ds, mSource->mEncoding, mSource->mSubsetString );
@@ -165,17 +175,20 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
}
// spatial query to select features
- if ( !mFilterRect.isNull() )
+ if ( mAllowResetReading )
{
- OGR_L_SetSpatialFilterRect( mOgrLayer, mFilterRect.xMinimum(), mFilterRect.yMinimum(), mFilterRect.xMaximum(), mFilterRect.yMaximum() );
- if ( mOgrLayerOri && mOgrLayerOri != mOgrLayer )
- OGR_L_SetSpatialFilterRect( mOgrLayerOri, mFilterRect.xMinimum(), mFilterRect.yMinimum(), mFilterRect.xMaximum(), mFilterRect.yMaximum() );
- }
- else
- {
- OGR_L_SetSpatialFilter( mOgrLayer, nullptr );
- if ( mOgrLayerOri && mOgrLayerOri != mOgrLayer )
- OGR_L_SetSpatialFilter( mOgrLayerOri, nullptr );
+ if ( !mFilterRect.isNull() )
+ {
+ OGR_L_SetSpatialFilterRect( mOgrLayer, mFilterRect.xMinimum(), mFilterRect.yMinimum(), mFilterRect.xMaximum(), mFilterRect.yMaximum() );
+ if ( mOgrLayerOri && mOgrLayerOri != mOgrLayer )
+ OGR_L_SetSpatialFilterRect( mOgrLayerOri, mFilterRect.xMinimum(), mFilterRect.yMinimum(), mFilterRect.xMaximum(), mFilterRect.yMaximum() );
+ }
+ else
+ {
+ OGR_L_SetSpatialFilter( mOgrLayer, nullptr );
+ if ( mOgrLayerOri && mOgrLayerOri != mOgrLayer )
+ OGR_L_SetSpatialFilter( mOgrLayerOri, nullptr );
+ }
}
if ( request.filterType() == QgsFeatureRequest::FilterExpression
@@ -201,33 +214,38 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
QStringLiteral( ") AND (" ) + whereClause +
QStringLiteral( ")" );
}
- if ( OGR_L_SetAttributeFilter( mOgrLayer, mSource->mEncoding->fromUnicode( whereClause ).constData() ) == OGRERR_NONE )
- {
- //if only partial success when compiling expression, we need to double-check results using QGIS' expressions
- mExpressionCompiled = ( result == QgsSqlExpressionCompiler::Complete );
- mCompileStatus = ( mExpressionCompiled ? Compiled : PartiallyCompiled );
- }
- else if ( !mSource->mSubsetString.isEmpty() )
+
+ if ( mAllowResetReading )
{
- // OGR rejected the compiled expression. Make sure we restore the original subset string if set (and do the filtering on QGIS' side)
- OGR_L_SetAttributeFilter( mOgrLayer, mSource->mEncoding->fromUnicode( mSource->mSubsetString ).constData() );
+ if ( OGR_L_SetAttributeFilter( mOgrLayer, mSource->mEncoding->fromUnicode( whereClause ).constData() ) == OGRERR_NONE )
+ {
+ //if only partial success when compiling expression, we need to double-check results using QGIS' expressions
+ mExpressionCompiled = ( result == QgsSqlExpressionCompiler::Complete );
+ mCompileStatus = ( mExpressionCompiled ? Compiled : PartiallyCompiled );
+ }
+ else if ( !mSource->mSubsetString.isEmpty() )
+ {
+ // OGR rejected the compiled expression. Make sure we restore the original subset string if set (and do the filtering on QGIS' side)
+ OGR_L_SetAttributeFilter( mOgrLayer, mSource->mEncoding->fromUnicode( mSource->mSubsetString ).constData() );
+ }
}
+
}
- else if ( mSource->mSubsetString.isEmpty() )
+ else if ( mSource->mSubsetString.isEmpty() && mAllowResetReading )
{
OGR_L_SetAttributeFilter( mOgrLayer, nullptr );
}
delete compiler;
}
- else if ( mSource->mSubsetString.isEmpty() )
+ else if ( mSource->mSubsetString.isEmpty() && mAllowResetReading )
{
OGR_L_SetAttributeFilter( mOgrLayer, nullptr );
}
-
//start with first feature
rewind();
+
}
QgsOgrFeatureIterator::~QgsOgrFeatureIterator()
@@ -249,7 +267,7 @@ bool QgsOgrFeatureIterator::fetchFeatureWithId( QgsFeatureId id, QgsFeature &fea
gdal::ogr_feature_unique_ptr fet;
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
- if ( !QgsOgrProviderUtils::canDriverShareSameDatasetAmongLayers( mSource->mDriverName ) )
+ if ( mAllowResetReading && !QgsOgrProviderUtils::canDriverShareSameDatasetAmongLayers( mSource->mDriverName ) )
{
OGRLayerH nextFeatureBelongingLayer;
bool found = false;
@@ -381,6 +399,10 @@ bool QgsOgrFeatureIterator::fetchFeature( QgsFeature &feature )
void QgsOgrFeatureIterator::resetReading()
{
+ if ( ! mAllowResetReading )
+ {
+ return;
+ }
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
if ( !QgsOgrProviderUtils::canDriverShareSameDatasetAmongLayers( mSource->mDriverName ) )
{
@@ -561,6 +583,7 @@ QgsOgrFeatureSource::QgsOgrFeatureSource( const QgsOgrProvider *p )
{
if ( p->mTransaction )
{
+ mTransaction = p->mTransaction;
mSharedDS = p->mTransaction->sharedDS();
}
for ( int i = ( p->mFirstFieldIsFid ) ? 1 : 0; i < mFields.size(); i++ )
@@ -575,7 +598,7 @@ QgsOgrFeatureSource::~QgsOgrFeatureSource()
QgsFeatureIterator QgsOgrFeatureSource::getFeatures( const QgsFeatureRequest &request )
{
- return QgsFeatureIterator( new QgsOgrFeatureIterator( this, false, request ) );
+ return QgsFeatureIterator( new QgsOgrFeatureIterator( this, false, request, mTransaction ) );
}
///@endcond
diff --git a/src/core/providers/ogr/qgsogrfeatureiterator.h b/src/core/providers/ogr/qgsogrfeatureiterator.h
index 8e58e48e1094..51ca9d304e57 100644
--- a/src/core/providers/ogr/qgsogrfeatureiterator.h
+++ b/src/core/providers/ogr/qgsogrfeatureiterator.h
@@ -56,6 +56,7 @@ class QgsOgrFeatureSource final: public QgsAbstractFeatureSource
QgsCoordinateReferenceSystem mCrs;
QgsWkbTypes::Type mWkbType = QgsWkbTypes::Unknown;
QgsOgrDatasetSharedPtr mSharedDS = nullptr;
+ QgsTransaction *mTransaction = nullptr;
friend class QgsOgrFeatureIterator;
friend class QgsOgrExpressionCompiler;
@@ -64,7 +65,7 @@ class QgsOgrFeatureSource final: public QgsAbstractFeatureSource
class QgsOgrFeatureIterator final: public QgsAbstractFeatureIteratorFromSource
{
public:
- QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool ownSource, const QgsFeatureRequest &request );
+ QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool ownSource, const QgsFeatureRequest &request, QgsTransaction *transaction );
~QgsOgrFeatureIterator() override;
@@ -102,6 +103,11 @@ class QgsOgrFeatureIterator final: public QgsAbstractFeatureIteratorFromSource( featureSource() ), true, request ) );
+ return QgsFeatureIterator( new QgsOgrFeatureIterator( static_cast( featureSource() ), true, request, mTransaction ) );
}
@@ -1441,11 +1441,11 @@ QVariant QgsOgrProvider::defaultValue( int fieldId ) const
return QVariant();
QVariant resultVar = defaultVal;
- if ( defaultVal == QStringLiteral( "CURRENT_TIMESTAMP" ) )
+ if ( defaultVal == QLatin1String( "CURRENT_TIMESTAMP" ) )
resultVar = QDateTime::currentDateTime();
- else if ( defaultVal == QStringLiteral( "CURRENT_DATE" ) )
+ else if ( defaultVal == QLatin1String( "CURRENT_DATE" ) )
resultVar = QDate::currentDate();
- else if ( defaultVal == QStringLiteral( "CURRENT_TIME" ) )
+ else if ( defaultVal == QLatin1String( "CURRENT_TIME" ) )
resultVar = QTime::currentTime();
// Get next sequence value for sqlite in case we are inside a transaction
@@ -2301,6 +2301,22 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_
const bool inTransaction = startTransaction();
+ // Some drivers may need to call ResetReading() after GetFeature(), such
+ // as GPKG in GDAL < 2.3.0 to avoid letting the database in a locked state.
+ // But this is undesirable in general, so don't do this when we know that
+ // we don't need to.
+ bool mayNeedResetReadingAfterGetFeature = true;
+ if ( mGDALDriverName == QLatin1String( "ESRI Shapefile" ) )
+ {
+ mayNeedResetReadingAfterGetFeature = false;
+ }
+#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,3,0)
+ else if ( mGDALDriverName == QLatin1String( "GPKG" ) )
+ {
+ mayNeedResetReadingAfterGetFeature = false;
+ }
+#endif
+
for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
{
QgsFeatureId fid = it.key();
@@ -2315,7 +2331,11 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_
pushError( tr( "Feature %1 for attribute update not found." ).arg( fid ) );
continue;
}
- mOgrLayer->ResetReading(); // needed for SQLite-based to clear iterator
+
+ if ( mayNeedResetReadingAfterGetFeature )
+ {
+ mOgrLayer->ResetReading();
+ }
QgsLocaleNumC l;
@@ -2484,6 +2504,22 @@ bool QgsOgrProvider::changeGeometryValues( const QgsGeometryMap &geometry_map )
const bool inTransaction = startTransaction();
+ // Some drivers may need to call ResetReading() after GetFeature(), such
+ // as GPKG in GDAL < 2.3.0 to avoid letting the database in a locked state.
+ // But this is undesirable in general, so don't do this when we know that
+ // we don't need to.
+ bool mayNeedResetReadingAfterGetFeature = true;
+ if ( mGDALDriverName == QLatin1String( "ESRI Shapefile" ) )
+ {
+ mayNeedResetReadingAfterGetFeature = false;
+ }
+#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,3,0)
+ else if ( mGDALDriverName == QLatin1String( "GPKG" ) )
+ {
+ mayNeedResetReadingAfterGetFeature = false;
+ }
+#endif
+
for ( QgsGeometryMap::const_iterator it = geometry_map.constBegin(); it != geometry_map.constEnd(); ++it )
{
gdal::ogr_feature_unique_ptr theOGRFeature( mOgrLayer->GetFeature( FID_TO_NUMBER( it.key() ) ) );
@@ -2492,7 +2528,11 @@ bool QgsOgrProvider::changeGeometryValues( const QgsGeometryMap &geometry_map )
pushError( tr( "OGR error changing geometry: feature %1 not found" ).arg( it.key() ) );
continue;
}
- mOgrLayer->ResetReading(); // needed for SQLite-based to clear iterator
+
+ if ( mayNeedResetReadingAfterGetFeature )
+ {
+ mOgrLayer->ResetReading(); // needed for SQLite-based to clear iterator, which could let the database in a locked state otherwise
+ }
OGRGeometryH newGeometry = nullptr;
QByteArray wkb = it->asWkb();
@@ -3323,7 +3363,7 @@ QString createFilters( const QString &type )
{
sExtensions << ext;
if ( !glob.isEmpty() )
- glob += QLatin1String( " " );
+ glob += QLatin1Char( ' ' );
glob += "*." + ext;
}
@@ -3356,7 +3396,7 @@ QString createFilters( const QString &type )
QStringList filters = sFileFilters.split( QStringLiteral( ";;" ), Qt::SkipEmptyParts );
#endif
filters.sort();
- sFileFilters = filters.join( QStringLiteral( ";;" ) ) + ";;";
+ sFileFilters = filters.join( QLatin1String( ";;" ) ) + ";;";
QgsDebugMsgLevel( "myFileFilters: " + sFileFilters, 2 );
// VSIFileHandler (.zip and .gz files) - second
@@ -3374,7 +3414,7 @@ QString createFilters( const QString &type )
QStringList exts;
for ( const QString &ext : qgis::as_const( sExtensions ) )
exts << QStringLiteral( "*.%1 *.%2" ).arg( ext, ext.toUpper() );
- sFileFilters.prepend( QObject::tr( "All supported files" ) + QStringLiteral( " (%1);;" ).arg( exts.join( QStringLiteral( " " ) ) ) );
+ sFileFilters.prepend( QObject::tr( "All supported files" ) + QStringLiteral( " (%1);;" ).arg( exts.join( QLatin1Char( ' ' ) ) ) );
// can't forget the default case - first
sFileFilters.prepend( QObject::tr( "All files" ) + " (*);;" );
@@ -3404,15 +3444,15 @@ QString createFilters( const QString &type )
}
if ( type == QLatin1String( "extensions" ) )
{
- return sExtensions.join( QStringLiteral( "|" ) );
+ return sExtensions.join( QLatin1Char( '|' ) );
}
- if ( type == QStringLiteral( "directory_extensions" ) )
+ if ( type == QLatin1String( "directory_extensions" ) )
{
- return sDirectoryExtensions.join( QStringLiteral( "|" ) );
+ return sDirectoryExtensions.join( QLatin1Char( '|' ) );
}
if ( type == QLatin1String( "wildcards" ) )
{
- return sWildcards.join( QStringLiteral( "|" ) );
+ return sWildcards.join( QLatin1Char( '|' ) );
}
else
{
@@ -3433,9 +3473,9 @@ QVariantMap QgsOgrProviderMetadata::decodeUri( const QString &uri )
if ( path.contains( '|' ) )
{
- const QRegularExpression geometryTypeRegex( QStringLiteral( "\\|geometrytype=([a-zA-Z0-9]*)" ) );
- const QRegularExpression layerNameRegex( QStringLiteral( "\\|layername=([^|]*)" ) );
- const QRegularExpression layerIdRegex( QStringLiteral( "\\|layerid=([^|]*)" ) );
+ const QRegularExpression geometryTypeRegex( QStringLiteral( "\\|geometrytype=([a-zA-Z0-9]*)" ), QRegularExpression::PatternOption::CaseInsensitiveOption );
+ const QRegularExpression layerNameRegex( QStringLiteral( "\\|layername=([^|]*)" ), QRegularExpression::PatternOption::CaseInsensitiveOption );
+ const QRegularExpression layerIdRegex( QStringLiteral( "\\|layerid=([^|]*)" ), QRegularExpression::PatternOption::CaseInsensitiveOption );
const QRegularExpression subsetRegex( QStringLiteral( "\\|subset=((?:.*[\r\n]*)*)\\Z" ) );
const QRegularExpression openOptionRegex( QStringLiteral( "\\|option:([^|]*)" ) );
@@ -3542,7 +3582,7 @@ QString QgsOgrProviderMetadata::encodeUri( const QVariantMap &parts )
+ ( !geometryType.isEmpty() ? QStringLiteral( "|geometrytype=%1" ).arg( geometryType ) : QString() );
for ( const QString &openOption : openOptions )
{
- uri += QStringLiteral( "|option:" );
+ uri += QLatin1String( "|option:" );
uri += openOption;
}
if ( !subset.isEmpty() )
@@ -4129,7 +4169,7 @@ QString QgsOgrProviderUtils::connectionPoolId( const QString &dataSourceURI, boo
// Otherwise use the datasourceURI
// Not completely sure about this logic. But at least, for GeoPackage this
// works fine with multi layer datasets.
- QString filePath = dataSourceURI.left( dataSourceURI.indexOf( QLatin1String( "|" ) ) );
+ QString filePath = dataSourceURI.left( dataSourceURI.indexOf( QLatin1Char( '|' ) ) );
QFileInfo fi( filePath );
if ( fi.isFile() )
return filePath;
@@ -5777,7 +5817,7 @@ void QgsOgrProviderUtils::releaseDataset( QgsOgrDataset *&ds )
bool QgsOgrProviderUtils::canDriverShareSameDatasetAmongLayers( const QString &driverName )
{
- return driverName != QStringLiteral( "OSM" );
+ return driverName != QLatin1String( "OSM" );
}
bool QgsOgrProviderUtils::canDriverShareSameDatasetAmongLayers( const QString &driverName,
diff --git a/src/core/qgsabstractcontentcache.h b/src/core/qgsabstractcontentcache.h
index fb2a895af160..726d54a5fbdc 100644
--- a/src/core/qgsabstractcontentcache.h
+++ b/src/core/qgsabstractcontentcache.h
@@ -564,7 +564,7 @@ class CORE_EXPORT QgsAbstractContentCache : public QgsAbstractContentCacheBase
{
entry->mFileModifiedCheckTimeout = mFileModifiedCheckTimeout;
- if ( !entry->path.startsWith( QStringLiteral( "base64:" ) ) )
+ if ( !entry->path.startsWith( QLatin1String( "base64:" ) ) )
{
entry->fileModified = QFileInfo( entry->path ).lastModified();
entry->fileModifiedLastCheckTimer.start();
diff --git a/src/core/qgsaction.h b/src/core/qgsaction.h
index 875fc54729c1..62123502f131 100644
--- a/src/core/qgsaction.h
+++ b/src/core/qgsaction.h
@@ -57,7 +57,7 @@ class CORE_EXPORT QgsAction
* \param description A human readable description string
* \param command The action text. Its interpretation depends on the type
* \param capture If this is set to TRUE, the output will be captured when an action is run
- * \param enabledOnlyWhenEditable if TRUE then action is only enable in editmode
+ * \param enabledOnlyWhenEditable if TRUE then action is only enable in editmode. Not available in Python bindings.
*/
#ifndef SIP_RUN
QgsAction( ActionType type, const QString &description, const QString &command, bool capture = false, bool enabledOnlyWhenEditable = false )
@@ -90,7 +90,7 @@ class CORE_EXPORT QgsAction
* \param shortTitle A short string used to label user interface elements like buttons
* \param actionScopes A set of scopes in which this action will be available
* \param notificationMessage A particular message which reception will trigger the action
- * \param enabledOnlyWhenEditable if TRUE then action is only enable in editmode
+ * \param enabledOnlyWhenEditable if TRUE then action is only enable in editmode. Not available in Python bindings.
*/
#ifndef SIP_RUN
QgsAction( ActionType type, const QString &description, const QString &action, const QString &icon, bool capture, const QString &shortTitle = QString(), const QSet &actionScopes = QSet(), const QString ¬ificationMessage = QString(), bool enabledOnlyWhenEditable = false )
@@ -172,6 +172,13 @@ class CORE_EXPORT QgsAction
//! Returns whether only enabled in editable mode
bool isEnabledOnlyWhenEditable() const { return mIsEnabledOnlyWhenEditable; }
+ /**
+ * Set whether the action is only enabled in editable mode
+ *
+ * \since QGIS 3.16
+ */
+ void setEnabledOnlyWhenEditable( bool enable ) { mIsEnabledOnlyWhenEditable = enable; };
+
//! Checks if the action is runable on the current platform
bool runable() const;
diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp
index 627732f591b5..e3f69ce765fd 100644
--- a/src/core/qgsapplication.cpp
+++ b/src/core/qgsapplication.cpp
@@ -715,20 +715,19 @@ QCursor QgsApplication::getThemeCursor( Cursor cursor )
}
// TODO: add some caching mechanism ?
-QPixmap QgsApplication::getThemePixmap( const QString &name )
+QPixmap QgsApplication::getThemePixmap( const QString &name, const QColor &foreColor, const QColor &backColor, const int size )
{
- QString myPreferredPath = activeThemePath() + QDir::separator() + name;
- QString myDefaultPath = defaultThemePath() + QDir::separator() + name;
- if ( QFile::exists( myPreferredPath ) )
+ const QString preferredPath = activeThemePath() + QDir::separator() + name;
+ const QString defaultPath = defaultThemePath() + QDir::separator() + name;
+ const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
+ if ( foreColor.isValid() || backColor.isValid() )
{
- return QPixmap( myPreferredPath );
- }
- else
- {
- //could still return an empty icon if it
- //doesn't exist in the default theme either!
- return QPixmap( myDefaultPath );
+ bool fitsInCache = false;
+ const QImage image = svgCache()->svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
+ return QPixmap::fromImage( image );
}
+
+ return QPixmap( path );
}
void QgsApplication::setThemeName( const QString &themeName )
@@ -826,7 +825,7 @@ void QgsApplication::setUITheme( const QString &themeName )
{
// Loop all style sheets, find matching name, load it.
QHash themes = QgsApplication::uiThemes();
- if ( themeName == QStringLiteral( "default" ) || !themes.contains( themeName ) )
+ if ( themeName == QLatin1String( "default" ) || !themes.contains( themeName ) )
{
setThemeName( QStringLiteral( "default" ) );
qApp->setStyleSheet( QString() );
@@ -847,7 +846,7 @@ void QgsApplication::setUITheme( const QString &themeName )
}
QString styledata = file.readAll();
- styledata.replace( QStringLiteral( "@theme_path" ), path );
+ styledata.replace( QLatin1String( "@theme_path" ), path );
if ( variableInfo.exists() )
{
@@ -1460,7 +1459,7 @@ QString QgsApplication::reportStyleSheet( QgsApplication::StyleSheetType styleSh
" width: 95%;"
"}"
".tabular-view th, .tabular-view td { "
- " border:10px solid black;"
+ " border:1px solid black;"
"}" );
break;
@@ -1585,7 +1584,7 @@ QString QgsApplication::absolutePathToRelativePath( const QString &aPath, const
aPathElems.insert( 0, QStringLiteral( "." ) );
}
- return aPathElems.join( QStringLiteral( "/" ) );
+ return aPathElems.join( QLatin1Char( '/' ) );
}
QString QgsApplication::relativePathToAbsolutePath( const QString &rpath, const QString &targetPath )
@@ -1628,7 +1627,7 @@ QString QgsApplication::relativePathToAbsolutePath( const QString &rpath, const
// resolve ..
int pos;
- while ( ( pos = targetElems.indexOf( QStringLiteral( ".." ) ) ) > 0 )
+ while ( ( pos = targetElems.indexOf( QLatin1String( ".." ) ) ) > 0 )
{
// remove preceding element and ..
targetElems.removeAt( pos - 1 );
@@ -1640,7 +1639,7 @@ QString QgsApplication::relativePathToAbsolutePath( const QString &rpath, const
targetElems.prepend( QString() );
#endif
- return targetElems.join( QStringLiteral( "/" ) );
+ return targetElems.join( QLatin1Char( '/' ) );
}
QString QgsApplication::buildSourcePath()
@@ -1696,7 +1695,7 @@ void QgsApplication::setSkippedGdalDrivers( const QStringList &skippedGdalDriver
*sDeferredSkippedGdalDrivers() = deferredSkippedGdalDrivers;
QgsSettings settings;
- settings.setValue( QStringLiteral( "gdal/skipDrivers" ), skippedGdalDrivers.join( QStringLiteral( "," ) ) );
+ settings.setValue( QStringLiteral( "gdal/skipDrivers" ), skippedGdalDrivers.join( QLatin1Char( ',' ) ) );
applyGdalSkippedDrivers();
}
diff --git a/src/core/qgsapplication.h b/src/core/qgsapplication.h
index 83061c8ad230..17fb32d6742d 100644
--- a/src/core/qgsapplication.h
+++ b/src/core/qgsapplication.h
@@ -19,6 +19,7 @@
#include
#include
#include
+#include
#include "qgis_sip.h"
#include "qgsconfig.h"
@@ -379,8 +380,12 @@ class CORE_EXPORT QgsApplication : public QApplication
/**
* Helper to get a theme icon as a pixmap. It will fall back to the
* default theme if the active theme does not have the required icon.
+ *
+ * If \a foreColor or \a backColor are specified, then these colors will
+ * be used for parametrized colors in SVG files wherever available. If
+ * colors are specified then the \a size argument also must be set.
*/
- static QPixmap getThemePixmap( const QString &name );
+ static QPixmap getThemePixmap( const QString &name, const QColor &foreColor = QColor(), const QColor &backColor = QColor(), int size = 16 );
//! Returns the path to user's style.
static QString userStylePath();
diff --git a/src/core/qgsauxiliarystorage.cpp b/src/core/qgsauxiliarystorage.cpp
index 52132b8aa086..3740473c1e39 100644
--- a/src/core/qgsauxiliarystorage.cpp
+++ b/src/core/qgsauxiliarystorage.cpp
@@ -847,7 +847,7 @@ QgsDataSourceUri QgsAuxiliaryStorage::parseOgrUri( const QgsDataSourceUri &uri )
if ( tableParts.count() < 1 )
return newUri;
- const QString tableName = tableParts[0].replace( QStringLiteral( "layername=" ), QString() );
+ const QString tableName = tableParts[0].replace( QLatin1String( "layername=" ), QString() );
newUri.setDataSource( QString(), tableName, QString() );
newUri.setDatabase( databasePath );
diff --git a/src/core/qgsbookmarkmanager.cpp b/src/core/qgsbookmarkmanager.cpp
index ee190f5cf0f8..1f5301edc635 100644
--- a/src/core/qgsbookmarkmanager.cpp
+++ b/src/core/qgsbookmarkmanager.cpp
@@ -279,7 +279,7 @@ bool QgsBookmarkManager::readXml( const QDomElement &element, const QDomDocument
clear();
QDomElement bookmarksElem = element;
- if ( element.tagName() != QStringLiteral( "Bookmarks" ) )
+ if ( element.tagName() != QLatin1String( "Bookmarks" ) )
{
bookmarksElem = element.firstChildElement( QStringLiteral( "Bookmarks" ) );
}
diff --git a/src/core/qgscolorramp.cpp b/src/core/qgscolorramp.cpp
index a6ea688a8d3a..c2a2a5dad09f 100644
--- a/src/core/qgscolorramp.cpp
+++ b/src/core/qgscolorramp.cpp
@@ -207,7 +207,7 @@ QgsStringMap QgsGradientColorRamp::properties() const
{
lst.append( QStringLiteral( "%1;%2" ).arg( it->offset ).arg( QgsSymbolLayerUtils::encodeColor( it->color ) ) );
}
- map[QStringLiteral( "stops" )] = lst.join( QStringLiteral( ":" ) );
+ map[QStringLiteral( "stops" )] = lst.join( QLatin1Char( ':' ) );
}
map[QStringLiteral( "discrete" )] = mDiscrete ? "1" : "0";
diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp
index abddd38e8223..9176d202f705 100644
--- a/src/core/qgscoordinatereferencesystem.cpp
+++ b/src/core/qgscoordinatereferencesystem.cpp
@@ -692,7 +692,12 @@ bool QgsCoordinateReferenceSystem::loadFromDatabase( const QString &db, const QS
if ( !d->mIsValid )
{
if ( !wkt.isEmpty() )
+ {
setWktString( wkt, false );
+ // set WKT string resets the description to that description embedded in the WKT, so manually overwrite this back to the
+ // value from the user DB
+ d->mDescription = statement.columnAsText( 1 );
+ }
else
setProjString( d->mProj4 );
}
@@ -891,6 +896,10 @@ bool QgsCoordinateReferenceSystem::createFromWktInternal( const QString &wkt, co
else
{
setWktString( wkt );
+ if ( !description.isEmpty() )
+ {
+ d->mDescription = description;
+ }
if ( d->mSrsId == 0 )
{
#if PROJ_VERSION_MAJOR>=6
@@ -1520,7 +1529,7 @@ void QgsCoordinateReferenceSystem::setProjString( const QString &proj4String )
QString trimmed = proj4String.trimmed();
#if PROJ_VERSION_MAJOR>=6
- trimmed += QStringLiteral( " +type=crs" );
+ trimmed += QLatin1String( " +type=crs" );
PJ_CONTEXT *ctx = QgsProjContext::get();
{
@@ -1652,6 +1661,7 @@ bool QgsCoordinateReferenceSystem::setWktString( const QString &wkt, bool allowP
{
// Still a valid CRS, just not a known one
d->mIsValid = true;
+ d->mDescription = QString( proj_get_name( d->threadLocalProjObject() ) );
}
setMapUnits();
}
@@ -2478,7 +2488,7 @@ bool QgsCoordinateReferenceSystem::loadFromAuthCode( const QString &auth, const
crs = QgsProjUtils::crsToSingleCrs( crs.get() );
QString proj4 = getFullProjString( crs.get() );
- proj4.replace( QStringLiteral( "+type=crs" ), QString() );
+ proj4.replace( QLatin1String( "+type=crs" ), QString() );
proj4 = proj4.trimmed();
d->mIsValid = true;
@@ -2854,7 +2864,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()
crs = QgsProjUtils::crsToSingleCrs( crs.get() );
QString proj4 = getFullProjString( crs.get() );
- proj4.replace( QStringLiteral( "+type=crs" ), QString() );
+ proj4.replace( QLatin1String( "+type=crs" ), QString() );
proj4 = proj4.trimmed();
if ( proj4.isEmpty() )
diff --git a/src/core/qgsdataitem.cpp b/src/core/qgsdataitem.cpp
index 4c8e6295229c..0f3afa493302 100644
--- a/src/core/qgsdataitem.cpp
+++ b/src/core/qgsdataitem.cpp
@@ -251,7 +251,7 @@ QIcon QgsFieldItem::icon()
parentFields->tableProperty()->geometryColumn() == mName &&
parentFields->tableProperty()->geometryColumnTypes().count() )
{
- if ( mField.typeName() == QStringLiteral( "raster" ) )
+ if ( mField.typeName() == QLatin1String( "raster" ) )
{
return QgsLayerItem::iconRaster();
}
@@ -1662,7 +1662,7 @@ QVector QgsZipItem::createChildren()
continue;
// ugly hack to remove .dbf file if there is a .shp file
- if ( provider->name() == QStringLiteral( "OGR" ) )
+ if ( provider->name() == QLatin1String( "OGR" ) )
{
if ( info.suffix().compare( QLatin1String( "dbf" ), Qt::CaseInsensitive ) == 0 )
{
diff --git a/src/core/qgsdatasourceuri.cpp b/src/core/qgsdatasourceuri.cpp
index 7fbaa5115ff4..31bb1b3b8fe6 100644
--- a/src/core/qgsdatasourceuri.cpp
+++ b/src/core/qgsdatasourceuri.cpp
@@ -532,7 +532,7 @@ QString QgsDataSourceUri::connectionInfo( bool expandAuthConfig ) const
}
}
- return connectionItems.join( QStringLiteral( " " ) );
+ return connectionItems.join( QLatin1Char( ' ' ) );
}
QString QgsDataSourceUri::uri( bool expandAuthConfig ) const
@@ -546,7 +546,7 @@ QString QgsDataSourceUri::uri( bool expandAuthConfig ) const
if ( mUseEstimatedMetadata )
{
- uri += QStringLiteral( " estimatedmetadata=true" );
+ uri += QLatin1String( " estimatedmetadata=true" );
}
if ( !mSrid.isEmpty() )
@@ -562,7 +562,7 @@ QString QgsDataSourceUri::uri( bool expandAuthConfig ) const
if ( mSelectAtIdDisabled )
{
- uri += QStringLiteral( " selectatid=false" );
+ uri += QLatin1String( " selectatid=false" );
}
for ( QMap::const_iterator it = mParams.begin(); it != mParams.end(); ++it )
diff --git a/src/core/qgsdiagramrenderer.h b/src/core/qgsdiagramrenderer.h
index c36fc5799880..e0b2c7886a89 100644
--- a/src/core/qgsdiagramrenderer.h
+++ b/src/core/qgsdiagramrenderer.h
@@ -685,9 +685,9 @@ class CORE_EXPORT QgsDiagramRenderer
#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
- if ( sipCpp->rendererName() == QStringLiteral( "SingleCategory" ) )
+ if ( sipCpp->rendererName() == QLatin1String( "SingleCategory" ) )
sipType = sipType_QgsSingleCategoryDiagramRenderer;
- else if ( sipCpp->rendererName() == QStringLiteral( "LinearlyInterpolated" ) )
+ else if ( sipCpp->rendererName() == QLatin1String( "LinearlyInterpolated" ) )
sipType = sipType_QgsLinearlyInterpolatedDiagramRenderer;
else
sipType = NULL;
diff --git a/src/core/qgseventtracing.cpp b/src/core/qgseventtracing.cpp
index 47e905bac457..e0dd480cad2a 100644
--- a/src/core/qgseventtracing.cpp
+++ b/src/core/qgseventtracing.cpp
@@ -107,7 +107,7 @@ bool QgsEventTracing::writeTrace( const QString &fileName )
// for instant events we always set them as global (currently not supporting instant events at thread scope)
if ( item.type == Instant )
- msg += QStringLiteral( ", \"s\": \"g\"" );
+ msg += QLatin1String( ", \"s\": \"g\"" );
// async events also need to have ID associated
if ( item.type == AsyncBegin || item.type == AsyncEnd )
diff --git a/src/core/qgsfeaturefiltermodel.cpp b/src/core/qgsfeaturefiltermodel.cpp
index edd9e7970ec1..933bd22bd637 100644
--- a/src/core/qgsfeaturefiltermodel.cpp
+++ b/src/core/qgsfeaturefiltermodel.cpp
@@ -62,7 +62,7 @@ void QgsFeatureFilterModel::requestToReloadCurrentFeature( QgsFeatureRequest &re
conditions << QgsExpression::createFieldEqualityExpression( mIdentifierFields.at( i ), mExtraIdentifierValue.toList().at( i ) );
}
}
- request.setFilterExpression( conditions.join( QStringLiteral( " AND " ) ) );
+ request.setFilterExpression( conditions.join( QLatin1String( " AND " ) ) );
}
QSet QgsFeatureFilterModel::requestedAttributes() const
@@ -83,7 +83,7 @@ QgsFeatureExpressionValuesGatherer::Entry QgsFeatureFilterModel::createEntry( co
for ( const QVariant &v : constValues )
values << QStringLiteral( "(%1)" ).arg( v.toString() );
- return QgsFeatureExpressionValuesGatherer::Entry( constValues, values.join( QStringLiteral( " " ) ), QgsFeature( sourceLayer()->fields() ) );
+ return QgsFeatureExpressionValuesGatherer::Entry( constValues, values.join( QLatin1Char( ' ' ) ), QgsFeature( sourceLayer()->fields() ) );
}
bool QgsFeatureFilterModel::compareEntries( const QgsFeatureExpressionValuesGatherer::Entry &a, const QgsFeatureExpressionValuesGatherer::Entry &b ) const
diff --git a/src/core/qgsfeaturerequest.cpp b/src/core/qgsfeaturerequest.cpp
index c3ed3d6294d1..7e73d70929de 100644
--- a/src/core/qgsfeaturerequest.cpp
+++ b/src/core/qgsfeaturerequest.cpp
@@ -523,5 +523,5 @@ QString QgsFeatureRequest::OrderBy::dump() const
results << clause.dump();
}
- return results.join( QStringLiteral( ", " ) );
+ return results.join( QLatin1String( ", " ) );
}
diff --git a/src/core/qgsfileutils.cpp b/src/core/qgsfileutils.cpp
index 94605521a655..b78df98614b3 100644
--- a/src/core/qgsfileutils.cpp
+++ b/src/core/qgsfileutils.cpp
@@ -116,7 +116,7 @@ QString QgsFileUtils::findClosestExistingPath( const QString &path )
if ( visited.contains( parentPath ) )
return QString(); // break circular links
- if ( parentPath.isEmpty() || parentPath == QStringLiteral( "." ) )
+ if ( parentPath.isEmpty() || parentPath == QLatin1String( "." ) )
return QString();
currentPath = QDir( parentPath );
visited << parentPath;
@@ -127,7 +127,7 @@ QString QgsFileUtils::findClosestExistingPath( const QString &path )
if ( res == QDir::currentPath() )
return QString(); // avoid default to binary folder if a filename alone is specified
- return res == QStringLiteral( "." ) ? QString() : res;
+ return res == QLatin1String( "." ) ? QString() : res;
}
QStringList QgsFileUtils::findFile( const QString &file, const QString &basePath, int maxClimbs, int searchCeilling, const QString ¤tDir )
diff --git a/src/core/qgsfontutils.cpp b/src/core/qgsfontutils.cpp
index 9c6ee768f404..a0c750dbe322 100644
--- a/src/core/qgsfontutils.cpp
+++ b/src/core/qgsfontutils.cpp
@@ -395,7 +395,7 @@ QFont QgsFontUtils::fromMimeData( const QMimeData *data, bool *ok )
{
elem = doc.documentElement();
- if ( elem.nodeName() != QStringLiteral( "font" ) )
+ if ( elem.nodeName() != QLatin1String( "font" ) )
elem = elem.firstChildElement( QStringLiteral( "font" ) );
if ( setFromXmlElement( font, elem ) )
@@ -440,7 +440,7 @@ QString QgsFontUtils::translateNamedStyle( const QString &namedStyle )
{
words[i] = QCoreApplication::translate( "QFontDatabase", words[i].toLocal8Bit().constData() );
}
- return words.join( QStringLiteral( " " ) );
+ return words.join( QLatin1Char( ' ' ) );
}
QString QgsFontUtils::untranslateNamedStyle( const QString &namedStyle )
@@ -463,7 +463,7 @@ QString QgsFontUtils::untranslateNamedStyle( const QString &namedStyle )
QgsDebugMsgLevel( QStringLiteral( "Warning: style map does not contain %1" ).arg( words[i] ), 2 );
}
}
- return words.join( QStringLiteral( " " ) );
+ return words.join( QLatin1Char( ' ' ) );
}
QString QgsFontUtils::asCSS( const QFont &font, double pointToPixelScale )
diff --git a/src/core/qgsgmlschema.cpp b/src/core/qgsgmlschema.cpp
index 263af1d1c892..63c31c0ee125 100644
--- a/src/core/qgsgmlschema.cpp
+++ b/src/core/qgsgmlschema.cpp
@@ -285,7 +285,7 @@ QList QgsGmlSchema::domElements( const QDomElement &element, const
}
else
{
- list.append( domElements( el, names.join( QStringLiteral( "." ) ) ) );
+ list.append( domElements( el, names.join( QLatin1Char( '.' ) ) ) );
}
}
}
@@ -357,7 +357,7 @@ void QgsGmlSchema::startElement( const XML_Char *el, const XML_Char **attr )
}
mParsePathStack.append( elementName );
- QString path = mParsePathStack.join( QStringLiteral( "." ) );
+ QString path = mParsePathStack.join( QLatin1Char( '.' ) );
QStringList splitName = elementName.split( NS_SEPARATOR );
QString localName = splitName.last();
diff --git a/src/core/qgsimagecache.cpp b/src/core/qgsimagecache.cpp
index 113e48a455f0..2a09341bd14d 100644
--- a/src/core/qgsimagecache.cpp
+++ b/src/core/qgsimagecache.cpp
@@ -160,7 +160,7 @@ QSize QgsImageCache::originalSize( const QString &path, bool blocking ) const
return QSize();
// direct read if path is a file -- maybe more efficient than going the bytearray route? (untested!)
- if ( !path.startsWith( QStringLiteral( "base64:" ) ) && QFile::exists( path ) )
+ if ( !path.startsWith( QLatin1String( "base64:" ) ) && QFile::exists( path ) )
{
QImageReader reader( path );
if ( reader.size().isValid() )
@@ -196,7 +196,7 @@ QImage QgsImageCache::renderImage( const QString &path, QSize size, const bool k
isBroken = false;
// direct read if path is a file -- maybe more efficient than going the bytearray route? (untested!)
- if ( !path.startsWith( QStringLiteral( "base64:" ) ) && QFile::exists( path ) )
+ if ( !path.startsWith( QLatin1String( "base64:" ) ) && QFile::exists( path ) )
{
im = QImage( path );
}
diff --git a/src/core/qgsmaplayer.cpp b/src/core/qgsmaplayer.cpp
index a276b9d19d31..c6dddfdd026b 100644
--- a/src/core/qgsmaplayer.cpp
+++ b/src/core/qgsmaplayer.cpp
@@ -334,7 +334,7 @@ bool QgsMapLayer::readLayerXml( const QDomElement &layerElement, QgsReadWriteCon
{
kwdList << n.toElement().text();
}
- mKeywordList = kwdList.join( QStringLiteral( ", " ) );
+ mKeywordList = kwdList.join( QLatin1String( ", " ) );
}
//metadataUrl
diff --git a/src/core/qgsmaplayerlegend.cpp b/src/core/qgsmaplayerlegend.cpp
index c50cd32e055e..91736e40a2dc 100644
--- a/src/core/qgsmaplayerlegend.cpp
+++ b/src/core/qgsmaplayerlegend.cpp
@@ -68,7 +68,7 @@ void QgsMapLayerLegendUtils::setLegendNodeOrder( QgsLayerTreeLayer *nodeLayer, c
const auto constOrder = order;
for ( int id : constOrder )
orderStr << QString::number( id );
- QString str = orderStr.isEmpty() ? QStringLiteral( "empty" ) : orderStr.join( QStringLiteral( "," ) );
+ QString str = orderStr.isEmpty() ? QStringLiteral( "empty" ) : orderStr.join( QLatin1Char( ',' ) );
nodeLayer->setCustomProperty( QStringLiteral( "legend/node-order" ), str );
}
diff --git a/src/core/qgsmaplayermodel.cpp b/src/core/qgsmaplayermodel.cpp
index b257b16da359..729954b36161 100644
--- a/src/core/qgsmaplayermodel.cpp
+++ b/src/core/qgsmaplayermodel.cpp
@@ -330,7 +330,7 @@ QVariant QgsMapLayerModel::data( const QModelIndex &index, int role ) const
if ( !layer->abstract().isEmpty() )
parts << " " + layer->abstract().replace( QLatin1String( "\n" ), QLatin1String( " " ) );
parts << "" + layer->publicSource() + "";
- return parts.join( QStringLiteral( " " ) );
+ return parts.join( QLatin1String( " " ) );
}
return QVariant();
}
diff --git a/src/core/qgsmaprendererjob.cpp b/src/core/qgsmaprendererjob.cpp
index 417f708d6f45..9efb891c2909 100644
--- a/src/core/qgsmaprendererjob.cpp
+++ b/src/core/qgsmaprendererjob.cpp
@@ -924,7 +924,7 @@ void QgsMapRendererJob::logRenderingTime( const LayerRenderJobs &jobs, const Lay
const auto constTt = tt;
for ( int t : constTt )
{
- QgsMessageLog::logMessage( tr( "%1 ms: %2" ).arg( t ).arg( QStringList( elapsed.values( t ) ).join( QStringLiteral( ", " ) ) ), tr( "Rendering" ) );
+ QgsMessageLog::logMessage( tr( "%1 ms: %2" ).arg( t ).arg( QStringList( elapsed.values( t ) ).join( QLatin1String( ", " ) ) ), tr( "Rendering" ) );
}
QgsMessageLog::logMessage( QStringLiteral( "---" ), tr( "Rendering" ) );
}
diff --git a/src/core/qgsmaprenderertask.cpp b/src/core/qgsmaprenderertask.cpp
index 97de005177df..48a934cd51d3 100644
--- a/src/core/qgsmaprenderertask.cpp
+++ b/src/core/qgsmaprenderertask.cpp
@@ -118,12 +118,12 @@ class QgsMapRendererTaskRenderedFeatureHandler : public QgsRenderedFeatureHandle
QgsMapRendererTask::QgsMapRendererTask( const QgsMapSettings &ms, const QString &fileName, const QString &fileFormat, const bool forceRaster,
const bool geoPDF, const QgsAbstractGeoPdfExporter::ExportDetails &geoPdfExportDetails )
- : QgsTask( fileFormat == QStringLiteral( "PDF" ) ? tr( "Saving as PDF" ) : tr( "Saving as image" ) )
+ : QgsTask( fileFormat == QLatin1String( "PDF" ) ? tr( "Saving as PDF" ) : tr( "Saving as image" ) )
, mMapSettings( ms )
, mFileName( fileName )
, mFileFormat( fileFormat )
, mForceRaster( forceRaster )
- , mGeoPDF( geoPDF && mFileFormat == QStringLiteral( "PDF" ) && QgsAbstractGeoPdfExporter::geoPDFCreationAvailable() )
+ , mGeoPDF( geoPDF && mFileFormat == QLatin1String( "PDF" ) && QgsAbstractGeoPdfExporter::geoPDFCreationAvailable() )
, mGeoPdfExportDetails( geoPdfExportDetails )
{
prepare();
@@ -297,7 +297,7 @@ bool QgsMapRendererTask::run()
{
mDestPainter->end();
- if ( mFileFormat == QStringLiteral( "PDF" ) )
+ if ( mFileFormat == QLatin1String( "PDF" ) )
{
#ifndef QT_NO_PRINTER
if ( mForceRaster )
@@ -371,7 +371,7 @@ bool QgsMapRendererTask::run()
return false;
#endif // !QT_NO_PRINTER
}
- else if ( mFileFormat != QStringLiteral( "PDF" ) )
+ else if ( mFileFormat != QLatin1String( "PDF" ) )
{
bool success = mImage.save( mFileName, mFileFormat.toLocal8Bit().data() );
if ( !success )
@@ -387,7 +387,7 @@ bool QgsMapRendererTask::run()
// build the world file name
QString outputSuffix = info.suffix();
bool skipWorldFile = false;
- if ( outputSuffix == QStringLiteral( "tif" ) || outputSuffix == QStringLiteral( "tiff" ) )
+ if ( outputSuffix == QLatin1String( "tif" ) || outputSuffix == QLatin1String( "tiff" ) )
{
gdal::dataset_unique_ptr outputDS( GDALOpen( mFileName.toLocal8Bit().constData(), GA_Update ) );
if ( outputDS )
@@ -465,7 +465,7 @@ void QgsMapRendererTask::prepare()
mDestPainter = mPainter;
- if ( mFileFormat == QStringLiteral( "PDF" ) )
+ if ( mFileFormat == QLatin1String( "PDF" ) )
{
#ifndef QT_NO_PRINTER
mPrinter.reset( new QPrinter() );
diff --git a/src/core/qgsmimedatautils.cpp b/src/core/qgsmimedatautils.cpp
index 5498addea790..c73dfec6036d 100644
--- a/src/core/qgsmimedatautils.cpp
+++ b/src/core/qgsmimedatautils.cpp
@@ -273,7 +273,7 @@ QString QgsMimeDataUtils::encode( const QStringList &items )
for ( const QString &item : constItems )
{
QString str = item;
- str.replace( '\\', QStringLiteral( "\\\\" ) );
+ str.replace( '\\', QLatin1String( "\\\\" ) );
str.replace( re, QStringLiteral( "\\:" ) );
encoded += str + ':';
}
diff --git a/src/core/qgsnetworkaccessmanager.h b/src/core/qgsnetworkaccessmanager.h
index f5f22963cb89..97ca9ee06cbc 100644
--- a/src/core/qgsnetworkaccessmanager.h
+++ b/src/core/qgsnetworkaccessmanager.h
@@ -38,8 +38,8 @@ class QgsFeedback;
#include "qgsconfig.h"
constexpr int sFilePrefixLength = CMAKE_SOURCE_DIR[sizeof( CMAKE_SOURCE_DIR ) - 1] == '/' ? sizeof( CMAKE_SOURCE_DIR ) + 1 : sizeof( CMAKE_SOURCE_DIR );
-#define QgsSetRequestInitiatorClass(request, _class) request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorClass ), _class ); request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), QString( __FILE__ ).mid( sFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" );
-#define QgsSetRequestInitiatorId(request, str) request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), QString( __FILE__ ).mid( sFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + "): " + str );
+#define QgsSetRequestInitiatorClass(request, _class) request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorClass ), _class ); request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), QString(QString( __FILE__ ).mid( sFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") );
+#define QgsSetRequestInitiatorId(request, str) request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), QString(QString( __FILE__ ).mid( sFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + "): " + str) );
#endif
/**
diff --git a/src/core/qgsnewsfeedparser.cpp b/src/core/qgsnewsfeedparser.cpp
index 0befccc8c862..b0fc6de1951e 100644
--- a/src/core/qgsnewsfeedparser.cpp
+++ b/src/core/qgsnewsfeedparser.cpp
@@ -46,7 +46,7 @@ QgsNewsFeedParser::QgsNewsFeedParser( const QUrl &feedUrl, const QString &authcf
{
feedLanguage = QgsSettings().value( QStringLiteral( "locale/userLocale" ), QStringLiteral( "en_US" ) ).toString().left( 2 );
}
- if ( !feedLanguage.isEmpty() && feedLanguage != QStringLiteral( "C" ) )
+ if ( !feedLanguage.isEmpty() && feedLanguage != QLatin1String( "C" ) )
query.addQueryItem( QStringLiteral( "lang" ), feedLanguage );
bool latOk = false;
diff --git a/src/core/qgsofflineediting.cpp b/src/core/qgsofflineediting.cpp
index c04b0587ba6b..8950db2847dc 100644
--- a/src/core/qgsofflineediting.cpp
+++ b/src/core/qgsofflineediting.cpp
@@ -327,7 +327,7 @@ void QgsOfflineEditing::synchronize()
}
else
{
- showWarning( remoteLayer->commitErrors().join( QStringLiteral( "\n" ) ) );
+ showWarning( remoteLayer->commitErrors().join( QLatin1Char( '\n' ) ) );
}
}
else
@@ -858,7 +858,7 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
}
else
{
- showWarning( newLayer->commitErrors().join( QStringLiteral( "\n" ) ) );
+ showWarning( newLayer->commitErrors().join( QLatin1Char( '\n' ) ) );
}
// copy the custom properties from original layer
diff --git a/src/core/qgspathresolver.cpp b/src/core/qgspathresolver.cpp
index d35ec9471958..9043b79ad621 100644
--- a/src/core/qgspathresolver.cpp
+++ b/src/core/qgspathresolver.cpp
@@ -157,7 +157,7 @@ QString QgsPathResolver::readPath( const QString &f ) const
// resolve ..
int pos;
- while ( ( pos = projElems.indexOf( QStringLiteral( ".." ) ) ) > 0 )
+ while ( ( pos = projElems.indexOf( QLatin1String( ".." ) ) ) > 0 )
{
// remove preceding element and ..
projElems.removeAt( pos - 1 );
@@ -169,7 +169,7 @@ QString QgsPathResolver::readPath( const QString &f ) const
projElems.prepend( QString() );
#endif
- return vsiPrefix + projElems.join( QStringLiteral( "/" ) );
+ return vsiPrefix + projElems.join( QLatin1Char( '/' ) );
}
QString QgsPathResolver::setPathPreprocessor( const std::function &processor )
@@ -312,7 +312,7 @@ QString QgsPathResolver::writePath( const QString &src ) const
}
// Append url query if any
- QString returnPath { vsiPrefix + srcElems.join( QStringLiteral( "/" ) ) };
+ QString returnPath { vsiPrefix + srcElems.join( QLatin1Char( '/' ) ) };
if ( ! urlQuery.isEmpty() )
{
returnPath.append( '?' );
diff --git a/src/core/qgspointxy.cpp b/src/core/qgspointxy.cpp
index e7df4265e32e..9fde6c9698e0 100644
--- a/src/core/qgspointxy.cpp
+++ b/src/core/qgspointxy.cpp
@@ -70,7 +70,7 @@ QString QgsPointXY::asWkt() const
{
QString wkt = QStringLiteral( "POINT" );
if ( isEmpty() )
- wkt += QStringLiteral( " EMPTY" );
+ wkt += QLatin1String( " EMPTY" );
else
wkt += QStringLiteral( "(%1 %2)" ).arg( qgsDoubleToString( mX ), qgsDoubleToString( mY ) );
diff --git a/src/core/qgspostgresstringutils.cpp b/src/core/qgspostgresstringutils.cpp
index 36eac63b4c0e..d1e03279ed6b 100644
--- a/src/core/qgspostgresstringutils.cpp
+++ b/src/core/qgspostgresstringutils.cpp
@@ -136,8 +136,8 @@ QString QgsPostgresStringUtils::buildArray( const QVariantList &list )
}
else
{
- newS.replace( '\\', QStringLiteral( R"(\\)" ) );
- newS.replace( '\"', QStringLiteral( R"(\")" ) );
+ newS.replace( '\\', QLatin1String( R"(\\)" ) );
+ newS.replace( '\"', QLatin1String( R"(\")" ) );
sl.push_back( "\"" + newS + "\"" );
}
break;
diff --git a/src/core/qgsproject.cpp b/src/core/qgsproject.cpp
index a250e2957b56..ec00db49deae 100644
--- a/src/core/qgsproject.cpp
+++ b/src/core/qgsproject.cpp
@@ -586,7 +586,7 @@ void QgsProject::registerTranslatableObjects( QgsTranslationContext *translation
translationContext->registerTranslation( QStringLiteral( "project:layers:%1:fieldaliases" ).arg( vlayer->id() ), fieldName );
- if ( field.editorWidgetSetup().type() == QStringLiteral( "ValueRelation" ) )
+ if ( field.editorWidgetSetup().type() == QLatin1String( "ValueRelation" ) )
{
translationContext->registerTranslation( QStringLiteral( "project:layers:%1:fields:%2:valuerelationvalue" ).arg( vlayer->id(), field.name() ), field.editorWidgetSetup().config().value( QStringLiteral( "Value" ) ).toString() );
}
diff --git a/src/core/qgsprojectfiletransform.cpp b/src/core/qgsprojectfiletransform.cpp
index c725a02bfdc4..82466650eed7 100644
--- a/src/core/qgsprojectfiletransform.cpp
+++ b/src/core/qgsprojectfiletransform.cpp
@@ -817,23 +817,23 @@ void transform3000( QgsProjectFileTransform *pft )
for ( int configIndex = 0; configIndex < configAttrs.count(); ++configIndex )
{
QDomAttr configAttr = configAttrs.item( configIndex ).toAttr();
- if ( configAttr.name() == QStringLiteral( "fieldEditable" ) )
+ if ( configAttr.name() == QLatin1String( "fieldEditable" ) )
{
editWidgetConfigElement.setAttribute( QStringLiteral( "fieldEditable" ), configAttr.value() );
}
- else if ( configAttr.name() == QStringLiteral( "labelOnTop" ) )
+ else if ( configAttr.name() == QLatin1String( "labelOnTop" ) )
{
editWidgetConfigElement.setAttribute( QStringLiteral( "labelOnTop" ), configAttr.value() );
}
- else if ( configAttr.name() == QStringLiteral( "notNull" ) )
+ else if ( configAttr.name() == QLatin1String( "notNull" ) )
{
editWidgetConfigElement.setAttribute( QStringLiteral( "notNull" ), configAttr.value() );
}
- else if ( configAttr.name() == QStringLiteral( "constraint" ) )
+ else if ( configAttr.name() == QLatin1String( "constraint" ) )
{
constraintExpressionElem.setAttribute( QStringLiteral( "exp" ), configAttr.value() );
}
- else if ( configAttr.name() == QStringLiteral( "constraintDescription" ) )
+ else if ( configAttr.name() == QLatin1String( "constraintDescription" ) )
{
constraintExpressionElem.setAttribute( QStringLiteral( "desc" ), configAttr.value() );
}
@@ -843,7 +843,7 @@ void transform3000( QgsProjectFileTransform *pft )
}
}
- if ( ewv2Type == QStringLiteral( "ValueMap" ) )
+ if ( ewv2Type == QLatin1String( "ValueMap" ) )
{
QDomNodeList configElements = ewv2CfgElem.childNodes();
QVariantMap map;
@@ -854,7 +854,7 @@ void transform3000( QgsProjectFileTransform *pft )
}
editWidgetConfiguration.insert( QStringLiteral( "map" ), map );
}
- else if ( ewv2Type == QStringLiteral( "Photo" ) )
+ else if ( ewv2Type == QLatin1String( "Photo" ) )
{
editWidgetElement.setAttribute( QStringLiteral( "type" ), QStringLiteral( "ExternalResource" ) );
@@ -863,13 +863,13 @@ void transform3000( QgsProjectFileTransform *pft )
editWidgetConfiguration.insert( QStringLiteral( "DocumentViewerWidth" ), editWidgetConfiguration.value( QStringLiteral( "Width" ) ) );
editWidgetConfiguration.insert( QStringLiteral( "RelativeStorage" ), 1 );
}
- else if ( ewv2Type == QStringLiteral( "FileName" ) )
+ else if ( ewv2Type == QLatin1String( "FileName" ) )
{
editWidgetElement.setAttribute( QStringLiteral( "type" ), QStringLiteral( "ExternalResource" ) );
editWidgetConfiguration.insert( QStringLiteral( "RelativeStorage" ), 1 );
}
- else if ( ewv2Type == QStringLiteral( "WebView" ) )
+ else if ( ewv2Type == QLatin1String( "WebView" ) )
{
editWidgetElement.setAttribute( QStringLiteral( "type" ), QStringLiteral( "ExternalResource" ) );
diff --git a/src/core/qgsprojectservervalidator.cpp b/src/core/qgsprojectservervalidator.cpp
index b89d38d5e5d4..c0e02f5a663a 100644
--- a/src/core/qgsprojectservervalidator.cpp
+++ b/src/core/qgsprojectservervalidator.cpp
@@ -117,19 +117,19 @@ bool QgsProjectServerValidator::validate( QgsProject *project, QListdump();
@@ -704,7 +704,7 @@ QString QgsSQLStatement::NodeJoin::dump() const
first = false;
ret += quotedIdentifierIfNeeded( column );
}
- ret += QLatin1String( ")" );
+ ret += QLatin1Char( ')' );
}
return ret;
}
diff --git a/src/core/qgsstringutils.cpp b/src/core/qgsstringutils.cpp
index e25acd1b915f..6806bc8f7b6a 100644
--- a/src/core/qgsstringutils.cpp
+++ b/src/core/qgsstringutils.cpp
@@ -123,11 +123,11 @@ QString QgsStringUtils::ampersandEncode( const QString &string )
if ( ch.unicode() > 160 )
encoded += QStringLiteral( "%1;" ).arg( static_cast< int >( ch.unicode() ) );
else if ( ch.unicode() == 38 )
- encoded += QStringLiteral( "&" );
+ encoded += QLatin1String( "&" );
else if ( ch.unicode() == 60 )
- encoded += QStringLiteral( "<" );
+ encoded += QLatin1String( "<" );
else if ( ch.unicode() == 62 )
- encoded += QStringLiteral( ">" );
+ encoded += QLatin1String( ">" );
else
encoded += ch;
}
@@ -571,7 +571,7 @@ QString QgsStringUtils::htmlToMarkdown( const QString &html )
int offset = 0;
while ( hrefRegEx.indexIn( converted, offset ) != -1 )
{
- QString url = hrefRegEx.cap( 1 ).replace( QStringLiteral( "\"" ), QString() );
+ QString url = hrefRegEx.cap( 1 ).replace( QLatin1String( "\"" ), QString() );
url.replace( '\'', QString() );
QString name = hrefRegEx.cap( 2 );
QString anchor = QStringLiteral( "[%1](%2)" ).arg( name, url );
diff --git a/src/core/qgstransactiongroup.cpp b/src/core/qgstransactiongroup.cpp
index fb99c150701c..057e7ae719c7 100644
--- a/src/core/qgstransactiongroup.cpp
+++ b/src/core/qgstransactiongroup.cpp
@@ -19,6 +19,7 @@
#include "qgsvectorlayer.h"
#include "qgsdatasourceuri.h"
#include "qgsvectordataprovider.h"
+#include "qgslogger.h"
#include
@@ -85,7 +86,7 @@ void QgsTransactionGroup::onEditingStarted()
{
mTransaction->addLayer( layer );
layer->startEditing();
- connect( layer, &QgsVectorLayer::beforeCommitChanges, this, &QgsTransactionGroup::onCommitChanges );
+ connect( layer, &QgsVectorLayer::beforeCommitChanges, this, &QgsTransactionGroup::onBeforeCommitChanges );
connect( layer, &QgsVectorLayer::beforeRollBack, this, &QgsTransactionGroup::onRollback );
}
}
@@ -95,14 +96,14 @@ void QgsTransactionGroup::onLayerDeleted()
mLayers.remove( static_cast( sender() ) );
}
-void QgsTransactionGroup::onCommitChanges()
+void QgsTransactionGroup::onBeforeCommitChanges( bool stopEditing )
{
if ( mEditingStopping )
return;
mEditingStopping = true;
- QgsVectorLayer *triggeringLayer = qobject_cast( sender() );
+ const QgsVectorLayer *triggeringLayer = qobject_cast( sender() );
QString errMsg;
if ( mTransaction->commit( errMsg ) )
@@ -110,17 +111,29 @@ void QgsTransactionGroup::onCommitChanges()
const auto constMLayers = mLayers;
for ( QgsVectorLayer *layer : constMLayers )
{
- if ( layer != sender() )
- layer->commitChanges();
+ if ( layer != triggeringLayer )
+ {
+ layer->commitChanges( stopEditing );
+ }
+ }
+
+ if ( stopEditing )
+ {
+ disableTransaction();
+ }
+ else
+ {
+ if ( ! mTransaction->begin( errMsg ) )
+ {
+ QgsDebugMsg( QStringLiteral( "Could not restart a transaction for %1: %2" ).arg( triggeringLayer->name() ).arg( errMsg ) );
+ }
}
- disableTransaction();
}
else
{
emit commitError( errMsg );
- // Restart editing the calling layer in the next event loop cycle
- QTimer::singleShot( 0, triggeringLayer, &QgsVectorLayer::startEditing );
+ restartTransaction( triggeringLayer );
}
mEditingStopping = false;
}
@@ -147,8 +160,7 @@ void QgsTransactionGroup::onRollback()
}
else
{
- // Restart editing the calling layer in the next event loop cycle
- QTimer::singleShot( 0, triggeringLayer, &QgsVectorLayer::startEditing );
+ restartTransaction( triggeringLayer );
}
mEditingStopping = false;
}
@@ -160,11 +172,17 @@ void QgsTransactionGroup::disableTransaction()
const auto constMLayers = mLayers;
for ( QgsVectorLayer *layer : constMLayers )
{
- disconnect( layer, &QgsVectorLayer::beforeCommitChanges, this, &QgsTransactionGroup::onCommitChanges );
+ disconnect( layer, &QgsVectorLayer::beforeCommitChanges, this, &QgsTransactionGroup::onBeforeCommitChanges );
disconnect( layer, &QgsVectorLayer::beforeRollBack, this, &QgsTransactionGroup::onRollback );
}
}
+void QgsTransactionGroup::restartTransaction( const QgsVectorLayer *layer )
+{
+ // Restart editing the calling layer in the next event loop cycle
+ QTimer::singleShot( 0, layer, &QgsVectorLayer::startEditing );
+}
+
QString QgsTransactionGroup::providerKey() const
{
return mProviderKey;
diff --git a/src/core/qgstransactiongroup.h b/src/core/qgstransactiongroup.h
index 6800534093d2..eb211e0143f8 100644
--- a/src/core/qgstransactiongroup.h
+++ b/src/core/qgstransactiongroup.h
@@ -82,7 +82,7 @@ class CORE_EXPORT QgsTransactionGroup : public QObject
private slots:
void onEditingStarted();
void onLayerDeleted();
- void onCommitChanges();
+ void onBeforeCommitChanges( bool stopEditing );
void onRollback();
private:
@@ -91,6 +91,8 @@ class CORE_EXPORT QgsTransactionGroup : public QObject
void disableTransaction();
+ void restartTransaction( const QgsVectorLayer *layer );
+
QSet mLayers;
//! Only set while a transaction is active
std::unique_ptr mTransaction;
diff --git a/src/core/qgsvectordataprovider.cpp b/src/core/qgsvectordataprovider.cpp
index 21c192d5e00c..c28876b78414 100644
--- a/src/core/qgsvectordataprovider.cpp
+++ b/src/core/qgsvectordataprovider.cpp
@@ -309,7 +309,7 @@ QString QgsVectorDataProvider::capabilitiesString() const
abilitiesList += tr( "Curved Geometries" );
}
- return abilitiesList.join( QStringLiteral( ", " ) );
+ return abilitiesList.join( QLatin1String( ", " ) );
}
diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp
index 33ef2f9401a7..4bba0dfef1e5 100644
--- a/src/core/qgsvectorfilewriter.cpp
+++ b/src/core/qgsvectorfilewriter.cpp
@@ -427,7 +427,7 @@ void QgsVectorFileWriter::init( QString vectorFileName,
// consider spatial reference system of the layer
if ( driverName == QLatin1String( "KML" ) || driverName == QLatin1String( "LIBKML" ) || driverName == QLatin1String( "GPX" ) )
{
- if ( srs.authid() != QStringLiteral( "EPSG:4326" ) )
+ if ( srs.authid() != QLatin1String( "EPSG:4326" ) )
{
// Those drivers outputs WGS84 geometries, let's align our output CRS to have QGIS take charge of geometry transformation
QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromEpsgId( 4326 );
@@ -453,7 +453,7 @@ void QgsVectorFileWriter::init( QString vectorFileName,
OGRwkbGeometryType wkbType = ogrTypeFromWkbType( geometryType );
// Remove FEATURE_DATASET layer option (used for ESRI File GDB driver) if its value is not set
- int optIndex = layerOptions.indexOf( QStringLiteral( "FEATURE_DATASET=" ) );
+ int optIndex = layerOptions.indexOf( QLatin1String( "FEATURE_DATASET=" ) );
if ( optIndex != -1 )
{
layerOptions.removeAt( optIndex );
diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp
index 9151c909ba25..a89af89b75c9 100644
--- a/src/core/qgsvectorlayer.cpp
+++ b/src/core/qgsvectorlayer.cpp
@@ -1835,7 +1835,7 @@ bool QgsVectorLayer::setDataProvider( QString const &provider, const QgsDataProv
if ( mDataSource.right( 10 ) == QLatin1String( "|layerid=0" ) )
mDataSource.chop( 10 );
}
- else if ( provider == QStringLiteral( "memory" ) )
+ else if ( provider == QLatin1String( "memory" ) )
{
// required so that source differs between memory layers
mDataSource = mDataSource + QStringLiteral( "&uid=%1" ).arg( QUuid::createUuid().toString() );
@@ -1947,13 +1947,13 @@ QString QgsVectorLayer::encodedSource( const QString &source, const QgsReadWrite
{
QStringList theURIParts = src.split( '|' );
theURIParts[0] = context.pathResolver().writePath( theURIParts[0] );
- src = theURIParts.join( QStringLiteral( "|" ) );
+ src = theURIParts.join( QLatin1Char( '|' ) );
}
else if ( providerType() == QLatin1String( "gpx" ) )
{
QStringList theURIParts = src.split( '?' );
theURIParts[0] = context.pathResolver().writePath( theURIParts[0] );
- src = theURIParts.join( QStringLiteral( "?" ) );
+ src = theURIParts.join( QLatin1Char( '?' ) );
}
else if ( providerType() == QLatin1String( "delimitedtext" ) )
{
@@ -1998,7 +1998,7 @@ QString QgsVectorLayer::encodedSource( const QString &source, const QgsReadWrite
theURIParts[1] = QUrl::toPercentEncoding( theURIParts[1] );
}
- queryItems[i].second = theURIParts.join( QStringLiteral( ":" ) ) ;
+ queryItems[i].second = theURIParts.join( QLatin1Char( ':' ) ) ;
}
}
@@ -2030,13 +2030,13 @@ QString QgsVectorLayer::decodedSource( const QString &source, const QString &pro
{
QStringList theURIParts = src.split( '|' );
theURIParts[0] = context.pathResolver().readPath( theURIParts[0] );
- src = theURIParts.join( QStringLiteral( "|" ) );
+ src = theURIParts.join( QLatin1Char( '|' ) );
}
else if ( provider == QLatin1String( "gpx" ) )
{
QStringList theURIParts = src.split( '?' );
theURIParts[0] = context.pathResolver().readPath( theURIParts[0] );
- src = theURIParts.join( QStringLiteral( "?" ) );
+ src = theURIParts.join( QLatin1Char( '?' ) );
}
else if ( provider == QLatin1String( "delimitedtext" ) )
{
@@ -2071,7 +2071,7 @@ QString QgsVectorLayer::decodedSource( const QString &source, const QString &pro
theURIParts = value.split( ':' );
theURIParts[1] = QUrl::fromPercentEncoding( theURIParts[1].toUtf8() );
- if ( theURIParts[0] == QStringLiteral( "delimitedtext" ) )
+ if ( theURIParts[0] == QLatin1String( "delimitedtext" ) )
{
QUrl urlSource = QUrl( theURIParts[1] );
@@ -2093,7 +2093,7 @@ QString QgsVectorLayer::decodedSource( const QString &source, const QString &pro
}
theURIParts[1] = QUrl::toPercentEncoding( theURIParts[1] );
- queryItems[i].second = theURIParts.join( QStringLiteral( ":" ) ) ;
+ queryItems[i].second = theURIParts.join( QLatin1Char( ':' ) ) ;
}
}
@@ -2335,7 +2335,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
const QDomElement cfgElem = fieldConfigElement.elementsByTagName( QStringLiteral( "config" ) ).at( 0 ).toElement();
const QDomElement optionsElem = cfgElem.childNodes().at( 0 ).toElement();
QVariantMap optionsMap = QgsXmlUtils::readVariant( optionsElem ).toMap();
- if ( widgetType == QStringLiteral( "ValueRelation" ) )
+ if ( widgetType == QLatin1String( "ValueRelation" ) )
{
optionsMap[ QStringLiteral( "Value" ) ] = context.projectTranslator()->translate( QStringLiteral( "project:layers:%1:fields:%2:valuerelationvalue" ).arg( layerNode.namedItem( QStringLiteral( "id" ) ).toElement().text(), fieldName ), optionsMap[ QStringLiteral( "Value" ) ].toString() );
}
@@ -3364,7 +3364,7 @@ bool QgsVectorLayer::commitChanges( bool stopEditing )
}
else
{
- QgsMessageLog::logMessage( tr( "Commit errors:\n %1" ).arg( mCommitErrors.join( QStringLiteral( "\n " ) ) ) );
+ QgsMessageLog::logMessage( tr( "Commit errors:\n %1" ).arg( mCommitErrors.join( QLatin1String( "\n " ) ) ) );
}
updateFields();
@@ -5120,7 +5120,7 @@ QString QgsVectorLayer::htmlMetadata() const
myMetadata += htmlFormatter.historySectionHtml( );
myMetadata += QLatin1String( "
\n" );
- myMetadata += QStringLiteral( "\n |