From fd9bcd68264247b1a41ef037cd1cf73a25ea92b0 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:11:03 +1000 Subject: [PATCH 01/15] Use QString multi-arg overload (clazy warning) --- src/app/dwg/qgsdwgimporter.cpp | 6 +++--- src/providers/postgres/qgspostgresdataitems.cpp | 2 +- src/providers/virtual/qgsvirtuallayersqlitehelper.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/dwg/qgsdwgimporter.cpp b/src/app/dwg/qgsdwgimporter.cpp index ffc8fc5496de..fa4b29effd2d 100644 --- a/src/app/dwg/qgsdwgimporter.cpp +++ b/src/app/dwg/qgsdwgimporter.cpp @@ -832,9 +832,9 @@ void QgsDwgImporter::addLType( const DRW_LType &data ) if ( OGR_L_CreateFeature( layer, f ) != OGRERR_NONE ) { LOG( QObject::tr( "Could not add %3 %1 [%2]" ) - .arg( data.name.c_str() ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) - .arg( QObject::tr( "line type" ) ) + .arg( data.name.c_str(), + QString::fromUtf8( CPLGetLastErrorMsg() ), + QObject::tr( "line type" ) ) ); } diff --git a/src/providers/postgres/qgspostgresdataitems.cpp b/src/providers/postgres/qgspostgresdataitems.cpp index 5fab099ae59a..70f730ddc829 100644 --- a/src/providers/postgres/qgspostgresdataitems.cpp +++ b/src/providers/postgres/qgspostgresdataitems.cpp @@ -229,7 +229,7 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData *data, const QString &toSc QgsVectorLayer *srcLayer = u.vectorLayer( owner, error ); if ( !srcLayer ) { - importResults.append( tr( "%1: %2" ).arg( u.name ).arg( error ) ); + importResults.append( tr( "%1: %2" ).arg( u.name, error ) ); hasError = true; continue; } diff --git a/src/providers/virtual/qgsvirtuallayersqlitehelper.cpp b/src/providers/virtual/qgsvirtuallayersqlitehelper.cpp index 9ec3266752fa..579abd5d4f53 100644 --- a/src/providers/virtual/qgsvirtuallayersqlitehelper.cpp +++ b/src/providers/virtual/qgsvirtuallayersqlitehelper.cpp @@ -96,7 +96,7 @@ namespace Sqlite int r = sqlite3_prepare_v2( db, ba.constData(), ba.size(), &stmt_, nullptr ); if ( r ) { - QString err = QStringLiteral( "Query preparation error on %1: %2" ).arg( q ).arg( sqlite3_errmsg( db ) ); + QString err = QStringLiteral( "Query preparation error on %1: %2" ).arg( q, sqlite3_errmsg( db ) ); throw std::runtime_error( err.toUtf8().constData() ); } } From e8b90c33e46b528d88f22e686d362ed2e5f85f4c Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:18:20 +1000 Subject: [PATCH 02/15] Fix clazy allocating unneeded temporary container warnings --- src/app/qgisapp.cpp | 5 ++- src/app/qgssnappinglayertreemodel.cpp | 4 +- src/core/qgsdatasourceuri.cpp | 7 +-- src/core/qgsmaplayermodel.cpp | 5 ++- src/core/qgsproject.cpp | 11 +++-- src/core/qgssnappingconfig.cpp | 7 +-- src/core/qgsvectorlayer.cpp | 5 ++- src/gui/qgsexpressionbuilderwidget.cpp | 4 +- src/gui/qgsmaptoolidentify.cpp | 22 +++++----- src/gui/qgsrasterpyramidsoptionswidget.cpp | 24 +++++----- src/gui/qgsrelationeditorwidget.cpp | 5 ++- .../symbology/qgsrulebasedrendererwidget.cpp | 7 +-- .../symbology/qgsrulebasedrendererwidget.h | 2 +- .../symbology/qgssmartgroupeditordialog.cpp | 7 +-- src/providers/arcgisrest/qgsamsprovider.cpp | 24 +++++----- src/providers/grass/qgis.v.in.cpp | 8 ++-- src/providers/grass/qgsgrassprovider.cpp | 10 ++--- src/providers/grass/qgsgrassvector.cpp | 44 ++++++++++--------- src/providers/grass/qgsgrassvectormap.cpp | 4 +- .../grass/qgsgrassvectormaplayer.cpp | 10 ++--- src/providers/ows/qgsowsdataitems.cpp | 5 ++- src/providers/wcs/qgswcscapabilities.cpp | 7 +-- src/providers/wcs/qgswcssourceselect.cpp | 8 ++-- src/providers/wms/qgswmscapabilities.cpp | 4 +- src/providers/wms/qgswmsprovider.cpp | 8 ++-- 25 files changed, 127 insertions(+), 120 deletions(-) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index d0a6dd4143d4..014ff920828a 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -11795,9 +11795,10 @@ void QgisApp::onTaskCompleteShowNotify( long taskId, int status ) void QgisApp::onTransactionGroupsChanged() { - Q_FOREACH ( QgsTransactionGroup *tg, QgsProject::instance()->transactionGroups().values() ) + const auto groups = QgsProject::instance()->transactionGroups(); + for ( auto it = groups.constBegin(); it != groups.constEnd(); ++it ) { - connect( tg, &QgsTransactionGroup::commitError, this, &QgisApp::transactionGroupCommitError, Qt::UniqueConnection ); + connect( it.value(), &QgsTransactionGroup::commitError, this, &QgisApp::transactionGroupCommitError, Qt::UniqueConnection ); } } diff --git a/src/app/qgssnappinglayertreemodel.cpp b/src/app/qgssnappinglayertreemodel.cpp index 1a39037fb608..b58ab8177f20 100644 --- a/src/app/qgssnappinglayertreemodel.cpp +++ b/src/app/qgssnappinglayertreemodel.cpp @@ -232,9 +232,9 @@ void QgsSnappingLayerTreeModel::onSnappingSettingsChanged() { const QHash oldSettings = mIndividualLayerSettings; - Q_FOREACH ( QgsVectorLayer *vl, oldSettings.keys() ) + for ( auto it = oldSettings.constBegin(); it != oldSettings.constEnd(); ++it ) { - if ( !mProject->snappingConfig().individualLayerSettings().contains( vl ) ) + if ( !mProject->snappingConfig().individualLayerSettings().contains( it.key() ) ) { beginResetModel(); mIndividualLayerSettings = mProject->snappingConfig().individualLayerSettings(); diff --git a/src/core/qgsdatasourceuri.cpp b/src/core/qgsdatasourceuri.cpp index 6c9de2c9c0eb..a0649c1fe4b8 100644 --- a/src/core/qgsdatasourceuri.cpp +++ b/src/core/qgsdatasourceuri.cpp @@ -606,12 +606,9 @@ QString QgsDataSourceUri::uri( bool expandAuthConfig ) const QByteArray QgsDataSourceUri::encodedUri() const { QUrl url; - Q_FOREACH ( const QString &key, mParams.uniqueKeys() ) + for ( auto it = mParams.constBegin(); it != mParams.constEnd(); ++it ) { - Q_FOREACH ( const QString &value, mParams.values( key ) ) - { - url.addQueryItem( key, value ); - } + url.addQueryItem( it.key(), it.value() ); } return url.encodedQuery(); } diff --git a/src/core/qgsmaplayermodel.cpp b/src/core/qgsmaplayermodel.cpp index 69dc71e3b978..678c63e4213c 100644 --- a/src/core/qgsmaplayermodel.cpp +++ b/src/core/qgsmaplayermodel.cpp @@ -52,9 +52,10 @@ void QgsMapLayerModel::setItemsCheckable( bool checkable ) void QgsMapLayerModel::checkAll( Qt::CheckState checkState ) { - Q_FOREACH ( const QString &key, mLayersChecked.keys() ) + QMap::iterator i = mLayersChecked.begin(); + for ( ; i != mLayersChecked.end(); ++i ) { - mLayersChecked[key] = checkState; + *i = checkState; } emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ) ); } diff --git a/src/core/qgsproject.cpp b/src/core/qgsproject.cpp index e7c9822fc9ce..728d280693ee 100644 --- a/src/core/qgsproject.cpp +++ b/src/core/qgsproject.cpp @@ -1932,9 +1932,11 @@ bool QgsProject::evaluateDefaultValues() const void QgsProject::setEvaluateDefaultValues( bool evaluateDefaultValues ) { - Q_FOREACH ( QgsMapLayer *layer, mapLayers().values() ) + const QMap layers = mapLayers(); + QMap::const_iterator layerIt = layers.constBegin(); + for ( ; layerIt != layers.constEnd(); ++layerIt ) { - QgsVectorLayer *vl = qobject_cast( layer ); + QgsVectorLayer *vl = qobject_cast( layerIt.value() ); if ( vl ) { vl->dataProvider()->setProviderProperty( QgsVectorDataProvider::EvaluateDefaultValues, evaluateDefaultValues ); @@ -2284,9 +2286,10 @@ void QgsProject::setTrustLayerMetadata( bool trust ) { mTrustLayerMetadata = trust; - Q_FOREACH ( QgsMapLayer *layer, mapLayers().values() ) + auto layers = mapLayers(); + for ( auto it = layers.constBegin(); it != layers.constEnd(); ++it ) { - QgsVectorLayer *vl = qobject_cast( layer ); + QgsVectorLayer *vl = qobject_cast( it.value() ); if ( vl ) { vl->setReadExtentFromXml( trust ); diff --git a/src/core/qgssnappingconfig.cpp b/src/core/qgssnappingconfig.cpp index e63dd3f358ce..e9fccb2b54d6 100644 --- a/src/core/qgssnappingconfig.cpp +++ b/src/core/qgssnappingconfig.cpp @@ -354,12 +354,13 @@ void QgsSnappingConfig::writeProject( QDomDocument &doc ) snapSettingsElem.setAttribute( QStringLiteral( "intersection-snapping" ), QString::number( mIntersectionSnapping ) ); QDomElement ilsElement = doc.createElement( QStringLiteral( "individual-layer-settings" ) ); - Q_FOREACH ( QgsVectorLayer *vl, mIndividualLayerSettings.keys() ) + QHash::const_iterator layerIt = mIndividualLayerSettings.constBegin(); + for ( ; layerIt != mIndividualLayerSettings.constEnd(); ++layerIt ) { - IndividualLayerSettings setting = mIndividualLayerSettings.value( vl ); + const IndividualLayerSettings &setting = layerIt.value(); QDomElement layerElement = doc.createElement( QStringLiteral( "layer-setting" ) ); - layerElement.setAttribute( QStringLiteral( "id" ), vl->id() ); + layerElement.setAttribute( QStringLiteral( "id" ), layerIt.key()->id() ); layerElement.setAttribute( QStringLiteral( "enabled" ), QString::number( setting.enabled() ) ); layerElement.setAttribute( QStringLiteral( "type" ), ( int )setting.type() ); layerElement.setAttribute( QStringLiteral( "tolerance" ), setting.tolerance() ); diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index e681e4e9f378..87b7120bbfdc 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -256,9 +256,10 @@ QgsVectorLayer *QgsVectorLayer::clone() const layer->setDefaultValueExpression( i, defaultValueExpression( i ) ); QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> constraints = fieldConstraintsAndStrength( i ); - Q_FOREACH ( QgsFieldConstraints::Constraint c, constraints.keys() ) + auto constraintIt = constraints.constBegin(); + for ( ; constraintIt != constraints.constEnd(); ++ constraintIt ) { - layer->setFieldConstraint( i, c, constraints.value( c ) ); + layer->setFieldConstraint( i, constraintIt.key(), constraintIt.value() ); } if ( fields().fieldOrigin( i ) == QgsFields::OriginExpression ) diff --git a/src/gui/qgsexpressionbuilderwidget.cpp b/src/gui/qgsexpressionbuilderwidget.cpp index fc2e32cb6cef..9626b18b1fd6 100644 --- a/src/gui/qgsexpressionbuilderwidget.cpp +++ b/src/gui/qgsexpressionbuilderwidget.cpp @@ -316,9 +316,9 @@ void QgsExpressionBuilderWidget::loadFieldNames( const QgsFields &fields ) void QgsExpressionBuilderWidget::loadFieldsAndValues( const QMap &fieldValues ) { QgsFields fields; - Q_FOREACH ( const QString &fieldName, fieldValues.keys() ) + for ( auto it = fieldValues.constBegin(); it != fieldValues.constEnd(); ++it ) { - fields.append( QgsField( fieldName ) ); + fields.append( QgsField( it.key() ) ); } loadFieldNames( fields ); mFieldValues = fieldValues; diff --git a/src/gui/qgsmaptoolidentify.cpp b/src/gui/qgsmaptoolidentify.cpp index 80446f68a9b9..92314f9ccbd2 100644 --- a/src/gui/qgsmaptoolidentify.cpp +++ b/src/gui/qgsmaptoolidentify.cpp @@ -559,16 +559,16 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList *results, Qg QgsGeometry geometry; if ( format == QgsRaster::IdentifyFormatValue ) { - Q_FOREACH ( int bandNo, values.keys() ) + for ( auto it = values.constBegin(); it != values.constEnd(); ++it ) { QString valueString; - if ( values.value( bandNo ).isNull() ) + if ( it.value().isNull() ) { valueString = tr( "no data" ); } else { - QVariant value( values.value( bandNo ) ); + QVariant value( it.value() ); // The cast is legit. Quoting QT doc : // "Although this function is declared as returning QVariant::Type, // the return value should be interpreted as QMetaType::Type" @@ -581,16 +581,16 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList *results, Qg valueString = QgsRasterBlock::printValue( value.toDouble() ); } } - attributes.insert( dprovider->generateBandName( bandNo ), valueString ); + attributes.insert( dprovider->generateBandName( it.key() ), valueString ); } QString label = layer->name(); results->append( IdentifyResult( qobject_cast( layer ), label, attributes, derivedAttributes ) ); } else if ( format == QgsRaster::IdentifyFormatFeature ) { - Q_FOREACH ( int i, values.keys() ) + for ( auto it = values.constBegin(); it != values.constEnd(); ++it ) { - QVariant value = values.value( i ); + QVariant value = it.value(); if ( value.type() == QVariant::Bool && !value.toBool() ) { // sublayer not visible or not queryable @@ -601,7 +601,7 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList *results, Qg { // error // TODO: better error reporting - QString label = layer->subLayers().value( i ); + QString label = layer->subLayers().value( it.key() ); attributes.clear(); attributes.insert( tr( "Error" ), value.toString() ); @@ -610,7 +610,7 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList *results, Qg } // list of feature stores for a single sublayer - const QgsFeatureStoreList featureStoreList = values.value( i ).value(); + const QgsFeatureStoreList featureStoreList = it.value().value(); for ( const QgsFeatureStore &featureStore : featureStoreList ) { @@ -649,13 +649,13 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList *results, Qg else // text or html { QgsDebugMsg( QString( "%1 HTML or text values" ).arg( values.size() ) ); - Q_FOREACH ( int bandNo, values.keys() ) + for ( auto it = values.constBegin(); it != values.constEnd(); ++it ) { - QString value = values.value( bandNo ).toString(); + QString value = it.value().toString(); attributes.clear(); attributes.insert( QLatin1String( "" ), value ); - QString label = layer->subLayers().value( bandNo ); + QString label = layer->subLayers().value( it.key() ); results->append( IdentifyResult( qobject_cast( layer ), label, attributes, derivedAttributes ) ); } } diff --git a/src/gui/qgsrasterpyramidsoptionswidget.cpp b/src/gui/qgsrasterpyramidsoptionswidget.cpp index bf45b1e22612..726f4a6e93ec 100644 --- a/src/gui/qgsrasterpyramidsoptionswidget.cpp +++ b/src/gui/qgsrasterpyramidsoptionswidget.cpp @@ -89,8 +89,8 @@ void QgsRasterPyramidsOptionsWidget::updateUi() } else { - Q_FOREACH ( int i, mOverviewCheckBoxes.keys() ) - mOverviewCheckBoxes[ i ]->setChecked( false ); + for ( auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it ) + it.value()->setChecked( false ); } tmpStr = mySettings.value( prefix + "overviewList", "" ).toString(); Q_FOREACH ( const QString &lev, tmpStr.split( ' ', QString::SkipEmptyParts ) ) @@ -134,10 +134,10 @@ void QgsRasterPyramidsOptionsWidget::apply() // overview list tmpStr = QLatin1String( "" ); - Q_FOREACH ( int i, mOverviewCheckBoxes.keys() ) + for ( auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it ) { - if ( mOverviewCheckBoxes[ i ]->isChecked() ) - tmpStr += QString::number( i ) + ' '; + if ( it.value()->isChecked() ) + tmpStr += QString::number( it.key() ) + ' '; } mySettings.setValue( prefix + "overviewList", tmpStr.trimmed() ); @@ -146,16 +146,16 @@ void QgsRasterPyramidsOptionsWidget::apply() void QgsRasterPyramidsOptionsWidget::checkAllLevels( bool checked ) { - Q_FOREACH ( int i, mOverviewCheckBoxes.keys() ) - mOverviewCheckBoxes[ i ]->setChecked( checked ); + for ( auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it ) + it.value()->setChecked( checked ); } void QgsRasterPyramidsOptionsWidget::on_cbxPyramidsLevelsCustom_toggled( bool toggled ) { // if toggled, disable checkboxes and enable line edit lePyramidsLevels->setEnabled( toggled ); - Q_FOREACH ( int i, mOverviewCheckBoxes.keys() ) - mOverviewCheckBoxes[ i ]->setEnabled( ! toggled ); + for ( auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it ) + it.value()->setEnabled( ! toggled ); setOverviewList(); } @@ -205,10 +205,10 @@ void QgsRasterPyramidsOptionsWidget::setOverviewList() } else { - Q_FOREACH ( int i, mOverviewCheckBoxes.keys() ) + for ( auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it ) { - if ( mOverviewCheckBoxes[ i ]->isChecked() ) - mOverviewList << i; + if ( it.value()->isChecked() ) + mOverviewList << it.key(); } } diff --git a/src/gui/qgsrelationeditorwidget.cpp b/src/gui/qgsrelationeditorwidget.cpp index 67059f92def1..26bab2e1e312 100644 --- a/src/gui/qgsrelationeditorwidget.cpp +++ b/src/gui/qgsrelationeditorwidget.cpp @@ -207,9 +207,10 @@ void QgsRelationEditorWidget::setRelations( const QgsRelation &relation, const Q mToggleEditingButton->setVisible( true ); - Q_FOREACH ( QgsTransactionGroup *tg, QgsProject::instance()->transactionGroups().values() ) + const auto transactionGroups = QgsProject::instance()->transactionGroups(); + for ( auto it = transactionGroups.constBegin(); it != transactionGroups.constEnd(); ++it ) { - if ( tg->layers().contains( mRelation.referencingLayer() ) ) + if ( it.value()->layers().contains( mRelation.referencingLayer() ) ) { mToggleEditingButton->setVisible( false ); mSaveEditsButton->setVisible( false ); diff --git a/src/gui/symbology/qgsrulebasedrendererwidget.cpp b/src/gui/symbology/qgsrulebasedrendererwidget.cpp index 13f13997793b..7e2bd43aed81 100644 --- a/src/gui/symbology/qgsrulebasedrendererwidget.cpp +++ b/src/gui/symbology/qgsrulebasedrendererwidget.cpp @@ -863,10 +863,11 @@ QVariant QgsRuleBasedRendererModel::data( const QModelIndex &index, int role ) c if ( mFeatureCountMap[rule].duplicateCount > 0 ) { QString tip = QStringLiteral( "

    " ); - Q_FOREACH ( QgsRuleBasedRenderer::Rule *duplicateRule, mFeatureCountMap[rule].duplicateCountMap.keys() ) + const auto duplicateMap = mFeatureCountMap[rule].duplicateCountMap; + for ( auto it = duplicateMap.constBegin(); it != duplicateMap.constEnd(); ++it ) { - QString label = duplicateRule->label().replace( '&', QLatin1String( "&" ) ).replace( '>', QLatin1String( ">" ) ).replace( '<', QLatin1String( "<" ) ); - tip += tr( "
  • %1 features also in rule %2
  • " ).arg( mFeatureCountMap[rule].duplicateCountMap[duplicateRule] ).arg( label ); + QString label = it.key()->label().replace( '&', QLatin1String( "&" ) ).replace( '>', QLatin1String( ">" ) ).replace( '<', QLatin1String( "<" ) ); + tip += tr( "
  • %1 features also in rule %2
  • " ).arg( it.value() ).arg( label ); } tip += QLatin1String( "
" ); return tip; diff --git a/src/gui/symbology/qgsrulebasedrendererwidget.h b/src/gui/symbology/qgsrulebasedrendererwidget.h index 6e76d0c2fcdb..bee496653501 100644 --- a/src/gui/symbology/qgsrulebasedrendererwidget.h +++ b/src/gui/symbology/qgsrulebasedrendererwidget.h @@ -33,7 +33,7 @@ struct QgsRuleBasedRendererCount SIP_SKIP int count; // number of features int duplicateCount; // number of features present also in other rule(s) // map of feature counts in other rules - QMap duplicateCountMap; + QHash duplicateCountMap; }; /** \ingroup gui diff --git a/src/gui/symbology/qgssmartgroupeditordialog.cpp b/src/gui/symbology/qgssmartgroupeditordialog.cpp index 6ceaf1d564ed..81ed98250891 100644 --- a/src/gui/symbology/qgssmartgroupeditordialog.cpp +++ b/src/gui/symbology/qgssmartgroupeditordialog.cpp @@ -156,11 +156,8 @@ void QgsSmartGroupEditorDialog::setConditionMap( const QgsSmartConditionMap &map constraints << QStringLiteral( "tag" ) << QStringLiteral( "name" ) << QStringLiteral( "!tag" ) << QStringLiteral( "!name" ); // clear any defaults - Q_FOREACH ( int id, mConditionMap.keys() ) - { - QgsSmartGroupCondition *cond = mConditionMap.take( id ); - delete cond; - } + qDeleteAll( mConditionMap ); + mConditionMap.clear(); //set the constraints Q_FOREACH ( const QString &constr, constraints ) diff --git a/src/providers/arcgisrest/qgsamsprovider.cpp b/src/providers/arcgisrest/qgsamsprovider.cpp index be06d07e6a53..74da09b6f9a7 100644 --- a/src/providers/arcgisrest/qgsamsprovider.cpp +++ b/src/providers/arcgisrest/qgsamsprovider.cpp @@ -221,16 +221,16 @@ static inline QString dumpVariantMap( const QVariantMap &variantMap, const QStri { result += QStringLiteral( "%1" ).arg( title ); } - foreach ( const QString &key, variantMap.keys() ) + for ( auto it = variantMap.constBegin(); it != variantMap.constEnd(); ++it ) { - QVariantMap childMap = variantMap[key].toMap(); + QVariantMap childMap = it.value().toMap(); if ( childMap.isEmpty() ) { - result += QStringLiteral( "%1%2" ).arg( key, variantMap[key].toString() ); + result += QStringLiteral( "%1%2" ).arg( it.key(), it.value().toString() ); } else { - result += QStringLiteral( "%1%2" ).arg( key, dumpVariantMap( childMap ) ); + result += QStringLiteral( "%1%2" ).arg( it.key(), dumpVariantMap( childMap ) ); } } result += QLatin1String( "" ); @@ -399,12 +399,12 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPointXY &point, QgsRa { foreach ( const QVariant &result, queryResults ) { - QVariantMap resultMap = result.toMap(); + const QVariantMap resultMap = result.toMap(); QVariantMap attributesMap = resultMap[QStringLiteral( "attributes" )].toMap(); QString valueStr; - foreach ( const QString &attribute, attributesMap.keys() ) + for ( auto it = attributesMap.constBegin(); it != attributesMap.constEnd(); ++it ) { - valueStr += QStringLiteral( "%1 = %2\n" ).arg( attribute, attributesMap[attribute].toString() ); + valueStr += QStringLiteral( "%1 = %2\n" ).arg( it.key(), it.value().toString() ); } entries.insert( entries.size(), valueStr ); } @@ -413,15 +413,15 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPointXY &point, QgsRa { foreach ( const QVariant &result, queryResults ) { - QVariantMap resultMap = result.toMap(); + const QVariantMap resultMap = result.toMap(); QgsFields fields; - QVariantMap attributesMap = resultMap[QStringLiteral( "attributes" )].toMap(); + const QVariantMap attributesMap = resultMap[QStringLiteral( "attributes" )].toMap(); QgsAttributes featureAttributes; - foreach ( const QString &attribute, attributesMap.keys() ) + for ( auto it = attributesMap.constBegin(); it != attributesMap.constEnd(); ++it ) { - fields.append( QgsField( attribute, QVariant::String, QStringLiteral( "string" ) ) ); - featureAttributes.append( attributesMap[attribute].toString() ); + fields.append( QgsField( it.key(), QVariant::String, QStringLiteral( "string" ) ) ); + featureAttributes.append( it.value().toString() ); } QgsCoordinateReferenceSystem crs; QgsAbstractGeometry *geometry = QgsArcGisRestUtils::parseEsriGeoJSON( resultMap[QStringLiteral( "geometry" )].toMap(), resultMap[QStringLiteral( "geometryType" )].toString(), false, false, &crs ); diff --git a/src/providers/grass/qgis.v.in.cpp b/src/providers/grass/qgis.v.in.cpp index dc663749f91c..5a9bd15e0413 100644 --- a/src/providers/grass/qgis.v.in.cpp +++ b/src/providers/grass/qgis.v.in.cpp @@ -444,14 +444,14 @@ int main( int argc, char **argv ) int centroidsCount = centroids.size(); count = 0; - Q_FOREACH ( const QgsFeature ¢roid, centroids.values() ) + for ( auto it = centroids.constBegin(); it != centroids.constEnd(); ++it ) { - QgsPointXY point = centroid.geometry().asPoint(); + QgsPointXY point = it.value().geometry().asPoint(); - if ( centroid.attributes().size() > 0 ) + if ( it.value().attributes().size() > 0 ) { Vect_reset_cats( cats ); - Q_FOREACH ( const QVariant &attribute, centroid.attributes() ) + Q_FOREACH ( const QVariant &attribute, it.value().attributes() ) { Vect_cat_set( cats, 1, attribute.toInt() ); } diff --git a/src/providers/grass/qgsgrassprovider.cpp b/src/providers/grass/qgsgrassprovider.cpp index a9634c3c91d5..c4a897689d0c 100644 --- a/src/providers/grass/qgsgrassprovider.cpp +++ b/src/providers/grass/qgsgrassprovider.cpp @@ -1905,25 +1905,25 @@ void QgsGrassProvider::setAddedFeaturesSymbol() return; } QgsFeatureMap &features = mEditBuffer->mAddedFeatures; - Q_FOREACH ( QgsFeatureId fid, features.keys() ) + for ( auto it = features.constBegin(); it != features.constEnd(); ++it ) { - QgsFeature feature = features[fid]; + QgsFeature feature = it.value(); if ( !feature.hasGeometry() ) { continue; } - int lid = QgsGrassFeatureIterator::lidFromFid( fid ); + int lid = QgsGrassFeatureIterator::lidFromFid( it.key() ); int realLid = lid; if ( mLayer->map()->newLids().contains( lid ) ) { realLid = mLayer->map()->newLids().value( lid ); } - QgsDebugMsg( QString( "fid = %1 lid = %2 realLid = %3" ).arg( fid ).arg( lid ).arg( realLid ) ); + QgsDebugMsg( QString( "fid = %1 lid = %2 realLid = %3" ).arg( it.key() ).arg( lid ).arg( realLid ) ); QgsGrassVectorMap::TopoSymbol symbol = mLayer->map()->topoSymbol( realLid ); // the feature may be without fields and set attribute by name does not work int index = mLayer->fields().indexFromName( QgsGrassVectorMap::topoSymbolFieldName() ); feature.setAttribute( index, symbol ); - features[fid] = feature; + features[it.key()] = feature; } } diff --git a/src/providers/grass/qgsgrassvector.cpp b/src/providers/grass/qgsgrassvector.cpp index 3c201218275b..3840816a2395 100644 --- a/src/providers/grass/qgsgrassvector.cpp +++ b/src/providers/grass/qgsgrassvector.cpp @@ -60,11 +60,11 @@ QgsGrassVectorLayer::QgsGrassVectorLayer( const QgsGrassObject &grassObject, int int QgsGrassVectorLayer::typeCount( int type ) const { int count = 0; - Q_FOREACH ( int t, mTypeCounts.keys() ) + for ( auto it = mTypeCounts.constBegin(); it != mTypeCounts.constEnd(); ++it ) { - if ( t & type ) + if ( it.key() & type ) { - count += mTypeCounts.value( t ); + count += it.value(); } } return count; @@ -73,11 +73,11 @@ int QgsGrassVectorLayer::typeCount( int type ) const int QgsGrassVectorLayer::type() const { int type = 0; - Q_FOREACH ( int t, mTypeCounts.keys() ) + for ( auto it = mTypeCounts.constBegin(); it != mTypeCounts.constEnd(); ++it ) { - if ( mTypeCounts.value( t ) > 0 ) + if ( it.value() > 0 ) { - type |= t; + type |= it.key(); } } return type; @@ -86,11 +86,11 @@ int QgsGrassVectorLayer::type() const QList QgsGrassVectorLayer::types() const { QList types; - Q_FOREACH ( int t, mTypeCounts.keys() ) + for ( auto it = mTypeCounts.constBegin(); it != mTypeCounts.constEnd(); ++it ) { - if ( mTypeCounts.value( t ) > 0 ) + if ( it.value() > 0 ) { - types << t; + types << it.key(); } } return types; @@ -285,13 +285,14 @@ bool QgsGrassVector::openHead() struct field_info *fieldInfo = Vect_get_field( map, field ); // should work also with field = 0 QgsGrassVectorLayer *layer = new QgsGrassVectorLayer( mGrassObject, field, fieldInfo, this ); - Q_FOREACH ( int type, QgsGrass::vectorTypeMap().keys() ) + const auto typeMap = QgsGrass::vectorTypeMap(); + for ( auto it = typeMap.constBegin(); it != typeMap.constEnd(); ++it ) { - int count = Vect_cidx_get_type_count( map, field, type ); + int count = Vect_cidx_get_type_count( map, field, it.key() ); if ( count > 0 ) { - QgsDebugMsg( QString( "type = %1 count = %2" ).arg( type ).arg( count ) ); - layer->setTypeCount( type, count ); + QgsDebugMsg( QString( "type = %1 count = %2" ).arg( it.key() ).arg( count ) ); + layer->setTypeCount( it.key(), count ); } } mLayers.append( layer ); @@ -299,17 +300,18 @@ bool QgsGrassVector::openHead() QgsDebugMsg( "standard layers listed: " + list.join( "," ) ); // Get primitives - Q_FOREACH ( int type, QgsGrass::vectorTypeMap().keys() ) + const auto typeMap = QgsGrass::vectorTypeMap(); + for ( auto it = typeMap.constBegin(); it != typeMap.constEnd(); ++it ) { - if ( type == GV_AREA ) + if ( it.key() == GV_AREA ) { continue; } - int count = Vect_get_num_primitives( map, type ); + int count = Vect_get_num_primitives( map, it.key() ); if ( count > 0 ) { - QgsDebugMsg( QString( "primitive type = %1 count = %2" ).arg( type ).arg( count ) ); - mTypeCounts[type] = count; + QgsDebugMsg( QString( "primitive type = %1 count = %2" ).arg( it.key() ).arg( count ) ); + mTypeCounts[it.key()] = count; } } mNodeCount = Vect_get_num_nodes( map ); @@ -333,11 +335,11 @@ bool QgsGrassVector::openHead() int QgsGrassVector::typeCount( int type ) const { int count = 0; - Q_FOREACH ( int t, mTypeCounts.keys() ) + for ( auto it = mTypeCounts.constBegin(); it != mTypeCounts.constEnd(); ++it ) { - if ( t & type ) + if ( it.key() & type ) { - count += mTypeCounts.value( t ); + count += it.value(); } } return count; diff --git a/src/providers/grass/qgsgrassvectormap.cpp b/src/providers/grass/qgsgrassvectormap.cpp index d75f604f916f..4756944bfcc1 100644 --- a/src/providers/grass/qgsgrassvectormap.cpp +++ b/src/providers/grass/qgsgrassvectormap.cpp @@ -350,9 +350,9 @@ bool QgsGrassVectorMap::closeEdit( bool newMap ) void QgsGrassVectorMap::clearUndoCommands() { - Q_FOREACH ( int index, mUndoCommands.keys() ) + for ( auto it = mUndoCommands.constBegin(); it != mUndoCommands.constEnd(); ++it ) { - Q_FOREACH ( QgsGrassUndoCommand *command, mUndoCommands[index] ) + Q_FOREACH ( QgsGrassUndoCommand *command, it.value() ) { delete command; } diff --git a/src/providers/grass/qgsgrassvectormaplayer.cpp b/src/providers/grass/qgsgrassvectormaplayer.cpp index cd29765e3e12..747fa4c88311 100644 --- a/src/providers/grass/qgsgrassvectormaplayer.cpp +++ b/src/providers/grass/qgsgrassvectormaplayer.cpp @@ -699,12 +699,12 @@ void QgsGrassVectorMapLayer::addColumn( const QgsField &field, QString &error ) QgsDebugMsg( "insert old values" ); printCachedAttributes(); QStringList errors; - Q_FOREACH ( int cat, mAttributes.keys() ) + for ( auto it = mAttributes.constBegin(); it != mAttributes.constEnd(); ++it ) { - QVariant value = mAttributes.value( cat ).value( index ); + QVariant value = it.value().value( index ); QString valueString = quotedValue( value ); QString query = QStringLiteral( "UPDATE %1 SET %2 = %3 WHERE %4 = %5" ) - .arg( mFieldInfo->table, field.name(), valueString, keyColumnName() ).arg( cat ); + .arg( mFieldInfo->table, field.name(), valueString, keyColumnName() ).arg( it.key() ); QString err; executeSql( query, err ); if ( !err.isEmpty() ) @@ -993,9 +993,9 @@ void QgsGrassVectorMapLayer::updateAttributes( int cat, QgsFeature &feature, QSt executeSql( query, error ); if ( error.isEmpty() ) { - Q_FOREACH ( int index, cacheUpdates.keys() ) + for ( auto it = cacheUpdates.constBegin(); it != cacheUpdates.constEnd(); ++it ) { - mAttributes[cat][index] = cacheUpdates[index]; + mAttributes[cat][it.key()] = it.value(); } } printCachedAttributes(); diff --git a/src/providers/ows/qgsowsdataitems.cpp b/src/providers/ows/qgsowsdataitems.cpp index cca7d9a23039..229f54635418 100644 --- a/src/providers/ows/qgsowsdataitems.cpp +++ b/src/providers/ows/qgsowsdataitems.cpp @@ -87,10 +87,11 @@ QVector QgsOWSConnectionItem::createChildren() } } - Q_FOREACH ( QgsDataItem *item, serviceItems.keys() ) + for ( auto it = serviceItems.constBegin(); it != serviceItems.constEnd(); ++it ) { + QgsDataItem *item = it.key(); QgsDebugMsg( QString( "serviceItems.size = %1 layerCount = %2 rowCount = %3" ).arg( serviceItems.size() ).arg( layerCount ).arg( item->rowCount() ) ); - QString providerKey = serviceItems.value( item ); + QString providerKey = it.value(); if ( serviceItems.size() == 1 || layerCount <= 30 || item->rowCount() <= 10 ) { // Add layers directly to OWS connection diff --git a/src/providers/wcs/qgswcscapabilities.cpp b/src/providers/wcs/qgswcscapabilities.cpp index 66b3e6fe16c2..2120d8b09b97 100644 --- a/src/providers/wcs/qgswcscapabilities.cpp +++ b/src/providers/wcs/qgswcscapabilities.cpp @@ -905,11 +905,12 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom10( QByteArray const &xml, QgsW // Find native bounding box if ( !coverage->nativeCrs.isEmpty() ) { - Q_FOREACH ( const QString &srsName, coverage->boundingBoxes.keys() ) + const auto boundingBoxes = coverage->boundingBoxes; + for ( auto it = boundingBoxes.constBegin(); it != boundingBoxes.constEnd(); ++it ) { - if ( srsName == coverage->nativeCrs ) + if ( it.key() == coverage->nativeCrs ) { - coverage->nativeBoundingBox = coverage->boundingBoxes.value( srsName ); + coverage->nativeBoundingBox = it.value(); } } } diff --git a/src/providers/wcs/qgswcssourceselect.cpp b/src/providers/wcs/qgswcssourceselect.cpp index b1ddebc6edd4..80c224700572 100644 --- a/src/providers/wcs/qgswcssourceselect.cpp +++ b/src/providers/wcs/qgswcssourceselect.cpp @@ -196,13 +196,13 @@ QList QgsWCSSourceSelect::providerFormats() { QList formats; - QMap mimes = QgsWcsProvider::supportedMimes(); - Q_FOREACH ( const QString &mime, mimes.keys() ) + const QMap mimes = QgsWcsProvider::supportedMimes(); + for ( auto it = mimes.constBegin(); it != mimes.constEnd(); ++it ) { - SupportedFormat format = { mime, mimes.value( mime ) }; + SupportedFormat format = { it.key(), it.value() }; // prefer tiff - if ( mime == QLatin1String( "image/tiff" ) ) + if ( it.key() == QLatin1String( "image/tiff" ) ) { formats.prepend( format ); } diff --git a/src/providers/wms/qgswmscapabilities.cpp b/src/providers/wms/qgswmscapabilities.cpp index 185ff5a5d65e..60dd7923000b 100644 --- a/src/providers/wms/qgswmscapabilities.cpp +++ b/src/providers/wms/qgswmscapabilities.cpp @@ -1886,9 +1886,9 @@ int QgsWmsCapabilities::identifyCapabilities() const { int capability = QgsRasterInterface::NoCapabilities; - Q_FOREACH ( QgsRaster::IdentifyFormat f, mIdentifyFormats.keys() ) + for ( auto it = mIdentifyFormats.constBegin(); it != mIdentifyFormats.constEnd(); ++it ) { - capability |= QgsRasterDataProvider::identifyFormatToCapability( f ); + capability |= QgsRasterDataProvider::identifyFormatToCapability( it.key() ); } return capability; diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index a2b71046f7ab..51e73490fe15 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -2720,12 +2720,12 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa bool isGml = false; const QgsNetworkReplyParser::RawHeaderMap &headers = mIdentifyResultHeaders.value( 0 ); - Q_FOREACH ( const QByteArray &v, headers.keys() ) + for ( auto it = headers.constBegin(); it != headers.constEnd(); ++it ) { - if ( QString( v ).compare( QLatin1String( "Content-Type" ), Qt::CaseInsensitive ) == 0 ) + if ( QString( it.key() ).compare( QLatin1String( "Content-Type" ), Qt::CaseInsensitive ) == 0 ) { - isXml = QString( headers.value( v ) ).compare( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) == 0; - isGml = QString( headers.value( v ) ).compare( QLatin1String( "ogr/gml" ), Qt::CaseInsensitive ) == 0; + isXml = QString( it.value() ).compare( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) == 0; + isGml = QString( it.value() ).compare( QLatin1String( "ogr/gml" ), Qt::CaseInsensitive ) == 0; if ( isXml || isGml ) break; } From 1a32f0883c05c70392f54a571533d192176d69ff Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:20:30 +1000 Subject: [PATCH 03/15] Fix clazy detaching range based for warnings --- src/app/locator/qgsinbuiltlocatorfilters.cpp | 3 ++- src/app/nodetool/qgsnodetool.cpp | 17 ++++++++++------- src/core/processing/qgsnativealgorithms.cpp | 2 +- src/gui/qgsprojectionselectiontreewidget.cpp | 6 +++--- src/providers/ogr/qgsogrdataitems.cpp | 3 ++- .../virtual/qgsvirtuallayersourceselect.cpp | 3 ++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/app/locator/qgsinbuiltlocatorfilters.cpp b/src/app/locator/qgsinbuiltlocatorfilters.cpp index 4fa1c47a19b1..413205cdb96c 100644 --- a/src/app/locator/qgsinbuiltlocatorfilters.cpp +++ b/src/app/locator/qgsinbuiltlocatorfilters.cpp @@ -191,7 +191,8 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c // build up request expression QStringList expressionParts; - Q_FOREACH ( const QgsField &field, layer->fields() ) + const QgsFields fields = layer->fields(); + for ( const QgsField &field : fields ) { if ( field.type() == QVariant::String ) { diff --git a/src/app/nodetool/qgsnodetool.cpp b/src/app/nodetool/qgsnodetool.cpp index 5d1226c61412..a4e33130f3c5 100644 --- a/src/app/nodetool/qgsnodetool.cpp +++ b/src/app/nodetool/qgsnodetool.cpp @@ -1079,7 +1079,8 @@ void QgsNodeTool::startDraggingMoveVertex( const QgsPointLocator::Match &m ) if ( !vlayer || !vlayer->isEditable() ) continue; - for ( const QgsPointLocator::Match &otherMatch : layerVerticesSnappedToPoint( vlayer, m.point() ) ) + const auto snappedVertices = layerVerticesSnappedToPoint( vlayer, m.point() ); + for ( const QgsPointLocator::Match &otherMatch : snappedVertices ) { if ( otherMatch.layer() == m.layer() && otherMatch.featureId() == m.featureId() && @@ -1436,7 +1437,8 @@ void QgsNodeTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocator: // topo editing: add vertex to existing segments when moving/adding a vertex to such segment. // this requires that the snapping match is to a segment and the segment layer's CRS // is the same (otherwise we would need to reproject the point and it will not be coincident) - for ( QgsVectorLayer *layer : edits.keys() ) + const auto editKeys = edits.keys(); + for ( QgsVectorLayer *layer : editKeys ) { if ( layer->crs() == mapPointMatch->layer()->crs() ) { @@ -1531,11 +1533,12 @@ void QgsNodeTool::deleteVertex() { // if topo editing is enabled, delete all the vertices that are on the same location QSet topoVerticesToDelete; - for ( const Vertex &vertexToDelete : toDelete ) + for ( const Vertex &vertexToDelete : qgsAsConst( toDelete ) ) { QgsPointXY layerPt = cachedGeometryForVertex( vertexToDelete ).vertexAt( vertexToDelete.vertexId ); QgsPointXY mapPt = toMapCoordinates( vertexToDelete.layer, layerPt ); - for ( const QgsPointLocator::Match &otherMatch : layerVerticesSnappedToPoint( vertexToDelete.layer, mapPt ) ) + const auto snappedVertices = layerVerticesSnappedToPoint( vertexToDelete.layer, mapPt ); + for ( const QgsPointLocator::Match &otherMatch : snappedVertices ) { Vertex otherVertex( otherMatch.layer(), otherMatch.featureId(), otherMatch.vertexIndex() ); if ( toDelete.contains( otherVertex ) || topoVerticesToDelete.contains( otherVertex ) ) @@ -1550,7 +1553,7 @@ void QgsNodeTool::deleteVertex() // switch from a plain list to dictionary { layer: { fid: [vertexNr1, vertexNr2, ...] } } QHash > > toDeleteGrouped; - for ( const Vertex &vertex : toDelete ) + for ( const Vertex &vertex : qgsAsConst( toDelete ) ) { toDeleteGrouped[vertex.layer][vertex.fid].append( vertex.vertexId ); } @@ -1586,7 +1589,7 @@ void QgsNodeTool::deleteVertex() } } // now delete the duplicities - for ( int duplicateVertexIndex : duplicateVertexIndices ) + for ( int duplicateVertexIndex : qgsAsConst( duplicateVertexIndices ) ) vertexIds.removeOne( duplicateVertexIndex ); } } @@ -1779,7 +1782,7 @@ void QgsNodeTool::CircularBand::updateRubberBand( const QgsPointXY &mapPoint ) QgsGeometryUtils::segmentizeArc( QgsPoint( v0 ), QgsPoint( v1 ), QgsPoint( v2 ), points ); // it would be useful to have QgsRubberBand::setPoints() call band->reset(); - for ( const QgsPoint &p : points ) + for ( const QgsPoint &p : qgsAsConst( points ) ) band->addPoint( p ); } diff --git a/src/core/processing/qgsnativealgorithms.cpp b/src/core/processing/qgsnativealgorithms.cpp index 1f66ed01ead8..3be16e4a06b3 100644 --- a/src/core/processing/qgsnativealgorithms.cpp +++ b/src/core/processing/qgsnativealgorithms.cpp @@ -2165,7 +2165,7 @@ QVariantMap QgsLineIntersectionAlgorithm::processAlgorithm( const QVariantMap &p points.append( intersectGeom.asPoint() ); } - for ( QgsPointXY j : qgsAsConst( points ) ) + for ( const QgsPointXY &j : qgsAsConst( points ) ) { outFeature.setGeometry( QgsGeometry::fromPoint( j ) ); outFeature.setAttributes( outAttributes ); diff --git a/src/gui/qgsprojectionselectiontreewidget.cpp b/src/gui/qgsprojectionselectiontreewidget.cpp index 594e91566ed5..0a4095e3f015 100644 --- a/src/gui/qgsprojectionselectiontreewidget.cpp +++ b/src/gui/qgsprojectionselectiontreewidget.cpp @@ -188,12 +188,12 @@ QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet QgsOgrLayerItem::subLayers( const QString &path, cons subLayersMap.insert( pieces[0].toInt(), pieces ); } int prevIdx = -1; - for ( const int &idx : subLayersMap.keys( ) ) + const auto subLayerKeys = subLayersMap.keys( ); + for ( const int &idx : subLayerKeys ) { if ( idx == prevIdx ) { diff --git a/src/providers/virtual/qgsvirtuallayersourceselect.cpp b/src/providers/virtual/qgsvirtuallayersourceselect.cpp index 670d466982ed..1ba2800d264a 100644 --- a/src/providers/virtual/qgsvirtuallayersourceselect.cpp +++ b/src/providers/virtual/qgsvirtuallayersourceselect.cpp @@ -65,7 +65,8 @@ QgsVirtualLayerSourceSelect::QgsVirtualLayerSourceSelect( QWidget *parent, Qt::W } // It needs to find the layertree view without relying on the parent // being the main window - for ( const QWidget *widget : qApp->allWidgets() ) + const QList< QWidget * > widgets = qApp->allWidgets(); + for ( const QWidget *widget : widgets ) { if ( ! mTreeView ) { From a7470b364f29ed9857e997d93d8a8f70e99ab626 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:22:20 +1000 Subject: [PATCH 04/15] Fix clazy connect-3arg-lambda warnings Always use 4 arg overload with a lambda, to avoid lambda execution when context object is deleted. --- src/app/qgisapp.cpp | 6 +++--- src/app/qgsmapsavedialog.cpp | 6 +++--- src/gui/raster/qgspalettedrendererwidget.cpp | 2 +- .../qgssinglebandpseudocolorrendererwidget.cpp | 2 +- .../qgscategorizedsymbolrendererwidget.cpp | 2 +- .../symbology/qgsdatadefinedsizelegendwidget.cpp | 2 +- .../symbology/qgsgraduatedsymbolrendererwidget.cpp | 2 +- .../symbology/qgssinglesymbolrendererwidget.cpp | 2 +- src/gui/symbology/qgsstylemanagerdialog.cpp | 14 +++++++------- src/providers/arcgisrest/qgsafsdataitems.cpp | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 014ff920828a..0c1b6f4a6e7a 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1831,7 +1831,7 @@ void QgisApp::createActions() connect( mActionAddOgrLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "ogr" ) ); } ); connect( mActionAddRasterLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "gdal" ) ); } ); connect( mActionAddPgLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "postgres" ) ); } ); - connect( mActionAddSpatiaLiteLayer, &QAction::triggered, [ = ] { dataSourceManager( QStringLiteral( "spatialite" ) ); } ); + connect( mActionAddSpatiaLiteLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "spatialite" ) ); } ); connect( mActionAddMssqlLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "mssql" ) ); } ); connect( mActionAddDb2Layer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "DB2" ) ); } ); connect( mActionAddOracleLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "oracle" ) ); } ); @@ -5257,7 +5257,7 @@ bool QgisApp::addProject( const QString &projectFile ) 0, mInfoBar ); - connect( btnEnableMacros, &QToolButton::clicked, [this, macroMsg] + connect( btnEnableMacros, &QToolButton::clicked, this, [this, macroMsg] { enableProjectMacros(); mInfoBar->popWidget( macroMsg ); @@ -8223,7 +8223,7 @@ void QgisApp::canvasRefreshStarted() mRenderProgressBarTimer.setSingleShot( true ); mRenderProgressBarTimer.setInterval( 500 ); disconnect( mRenderProgressBarTimerConnection ); - mRenderProgressBarTimerConnection = connect( &mRenderProgressBarTimer, &QTimer::timeout, [ = ]() + mRenderProgressBarTimerConnection = connect( &mRenderProgressBarTimer, &QTimer::timeout, this, [ = ]() { showProgress( -1, 0 ); } diff --git a/src/app/qgsmapsavedialog.cpp b/src/app/qgsmapsavedialog.cpp index 0b14c319b76c..06ea38e51ce5 100644 --- a/src/app/qgsmapsavedialog.cpp +++ b/src/app/qgsmapsavedialog.cpp @@ -118,7 +118,7 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co connect( button, &QPushButton::clicked, this, &QgsMapSaveDialog::copyToClipboard ); } - connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsMapSaveDialog::accepted ); + connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsMapSaveDialog::onAccepted ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsMapSaveDialog::showHelp ); } @@ -349,7 +349,7 @@ void QgsMapSaveDialog::copyToClipboard() mapRendererTask->addDecorations( mDecorations ); } - connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, [ = ] + connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, this, [ = ] { QApplication::clipboard()->setImage( *img, QClipboard::Clipboard ); QApplication::restoreOverrideCursor(); @@ -359,7 +359,7 @@ void QgsMapSaveDialog::copyToClipboard() delete img; setEnabled( true ); } ); - connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, [ = ]( int ) + connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, this, [ = ]( int ) { QApplication::restoreOverrideCursor(); QgisApp::instance()->messageBar()->pushWarning( tr( "Save as PDF" ), tr( "Could not copy the map to clipboard" ) ); diff --git a/src/gui/raster/qgspalettedrendererwidget.cpp b/src/gui/raster/qgspalettedrendererwidget.cpp index 174300b85be9..6a90c04be974 100644 --- a/src/gui/raster/qgspalettedrendererwidget.cpp +++ b/src/gui/raster/qgspalettedrendererwidget.cpp @@ -76,7 +76,7 @@ QgsPalettedRendererWidget::QgsPalettedRendererWidget( QgsRasterLayer *layer, con mTreeView->setSelectionBehavior( QAbstractItemView::SelectRows ); mTreeView->setDefaultDropAction( Qt::MoveAction ); - connect( mTreeView, &QTreeView::customContextMenuRequested, [ = ]( const QPoint & ) { mContextMenu->exec( QCursor::pos() ); } + connect( mTreeView, &QTreeView::customContextMenuRequested, this, [ = ]( const QPoint & ) { mContextMenu->exec( QCursor::pos() ); } ); btnColorRamp->setShowRandomColorRamp( true ); diff --git a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp index 71eaee88b50f..a1d70f5926d1 100644 --- a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp +++ b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp @@ -55,7 +55,7 @@ QgsSingleBandPseudoColorRendererWidget::QgsSingleBandPseudoColorRendererWidget( mColormapTreeWidget->setColumnWidth( ColorColumn, 50 ); mColormapTreeWidget->setContextMenuPolicy( Qt::CustomContextMenu ); mColormapTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection ); - connect( mColormapTreeWidget, &QTreeView::customContextMenuRequested, [ = ]( const QPoint & ) { contextMenu->exec( QCursor::pos() ); } + connect( mColormapTreeWidget, &QTreeView::customContextMenuRequested, this, [ = ]( const QPoint & ) { contextMenu->exec( QCursor::pos() ); } ); QString defaultPalette = settings.value( QStringLiteral( "Raster/defaultPalette" ), "" ).toString(); diff --git a/src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp b/src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp index 238f11d41968..5c485e7f835f 100644 --- a/src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp +++ b/src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp @@ -1047,7 +1047,7 @@ void QgsCategorizedSymbolRendererWidget::dataDefinedSizeLegend() QgsDataDefinedSizeLegendWidget *panel = createDataDefinedSizeLegendWidget( s, mRenderer->dataDefinedSizeLegend() ); if ( panel ) { - connect( panel, &QgsPanelWidget::widgetChanged, [ = ] + connect( panel, &QgsPanelWidget::widgetChanged, this, [ = ] { mRenderer->setDataDefinedSizeLegend( panel->dataDefinedSizeLegend() ); emit widgetChanged(); diff --git a/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp b/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp index 2ccd77fd1d36..bec9d35b2a96 100644 --- a/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp +++ b/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp @@ -110,7 +110,7 @@ QgsDataDefinedSizeLegendWidget::QgsDataDefinedSizeLegendWidget( const QgsDataDef mPreviewModel->setLegendMapViewData( canvas->mapUnitsPerPixel(), canvas->mapSettings().outputDpi(), canvas->scale() ); viewLayerTree->setModel( mPreviewModel ); - connect( cboAlignSymbols, static_cast( &QComboBox::currentIndexChanged ), [ = ] { emit widgetChanged(); } ); + connect( cboAlignSymbols, static_cast( &QComboBox::currentIndexChanged ), this, [ = ] { emit widgetChanged(); } ); connect( radDisabled, &QRadioButton::clicked, this, &QgsPanelWidget::widgetChanged ); connect( radSeparated, &QRadioButton::clicked, this, &QgsPanelWidget::widgetChanged ); connect( radCollapsed, &QRadioButton::clicked, this, &QgsPanelWidget::widgetChanged ); diff --git a/src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp b/src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp index 2a6fda604787..04f35905bf71 100644 --- a/src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp +++ b/src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp @@ -1179,7 +1179,7 @@ void QgsGraduatedSymbolRendererWidget::dataDefinedSizeLegend() QgsDataDefinedSizeLegendWidget *panel = createDataDefinedSizeLegendWidget( s, mRenderer->dataDefinedSizeLegend() ); if ( panel ) { - connect( panel, &QgsPanelWidget::widgetChanged, [ = ] + connect( panel, &QgsPanelWidget::widgetChanged, this, [ = ] { mRenderer->setDataDefinedSizeLegend( panel->dataDefinedSizeLegend() ); emit widgetChanged(); diff --git a/src/gui/symbology/qgssinglesymbolrendererwidget.cpp b/src/gui/symbology/qgssinglesymbolrendererwidget.cpp index 5c9c9ea8c839..2505725cb6c3 100644 --- a/src/gui/symbology/qgssinglesymbolrendererwidget.cpp +++ b/src/gui/symbology/qgssinglesymbolrendererwidget.cpp @@ -122,7 +122,7 @@ void QgsSingleSymbolRendererWidget::dataDefinedSizeLegend() QgsDataDefinedSizeLegendWidget *panel = createDataDefinedSizeLegendWidget( s, mRenderer->dataDefinedSizeLegend() ); if ( panel ) { - connect( panel, &QgsPanelWidget::widgetChanged, [ = ] + connect( panel, &QgsPanelWidget::widgetChanged, this, [ = ] { mRenderer->setDataDefinedSizeLegend( panel->dataDefinedSizeLegend() ); emit widgetChanged(); diff --git a/src/gui/symbology/qgsstylemanagerdialog.cpp b/src/gui/symbology/qgsstylemanagerdialog.cpp index 5e434b4868a8..dd45b5a9f132 100644 --- a/src/gui/symbology/qgsstylemanagerdialog.cpp +++ b/src/gui/symbology/qgsstylemanagerdialog.cpp @@ -69,15 +69,15 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent ) connect( listItems, &QAbstractItemView::doubleClicked, this, &QgsStyleManagerDialog::editItem ); - connect( btnAddItem, &QPushButton::clicked, [ = ]( bool ) { addItem(); } + connect( btnAddItem, &QPushButton::clicked, this, [ = ]( bool ) { addItem(); } ); - connect( btnEditItem, &QPushButton::clicked, [ = ]( bool ) { editItem(); } + connect( btnEditItem, &QPushButton::clicked, this, [ = ]( bool ) { editItem(); } ); - connect( actnEditItem, &QAction::triggered, [ = ]( bool ) { editItem(); } + connect( actnEditItem, &QAction::triggered, this, [ = ]( bool ) { editItem(); } ); - connect( btnRemoveItem, &QPushButton::clicked, [ = ]( bool ) { removeItem(); } + connect( btnRemoveItem, &QPushButton::clicked, this, [ = ]( bool ) { removeItem(); } ); - connect( actnRemoveItem, &QAction::triggered, [ = ]( bool ) { removeItem(); } + connect( actnRemoveItem, &QAction::triggered, this, [ = ]( bool ) { removeItem(); } ); QMenu *shareMenu = new QMenu( tr( "Share menu" ), this ); @@ -178,10 +178,10 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent ) mGroupTreeContextMenu = new QMenu( this ); connect( actnEditSmartGroup, &QAction::triggered, this, &QgsStyleManagerDialog::editSmartgroupAction ); mGroupTreeContextMenu->addAction( actnEditSmartGroup ); - connect( actnAddTag, &QAction::triggered, [ = ]( bool ) { addTag(); } + connect( actnAddTag, &QAction::triggered, this, [ = ]( bool ) { addTag(); } ); mGroupTreeContextMenu->addAction( actnAddTag ); - connect( actnAddSmartgroup, &QAction::triggered, [ = ]( bool ) { addSmartgroup(); } + connect( actnAddSmartgroup, &QAction::triggered, this, [ = ]( bool ) { addSmartgroup(); } ); mGroupTreeContextMenu->addAction( actnAddSmartgroup ); connect( actnRemoveGroup, &QAction::triggered, this, &QgsStyleManagerDialog::removeGroup ); diff --git a/src/providers/arcgisrest/qgsafsdataitems.cpp b/src/providers/arcgisrest/qgsafsdataitems.cpp index 96c205487e39..88f012368221 100644 --- a/src/providers/arcgisrest/qgsafsdataitems.cpp +++ b/src/providers/arcgisrest/qgsafsdataitems.cpp @@ -60,7 +60,7 @@ QList QgsAfsRootItem::actions( QWidget *parent ) QWidget *QgsAfsRootItem::paramWidget() { QgsAfsSourceSelect *select = new QgsAfsSourceSelect( 0, 0, QgsProviderRegistry::WidgetMode::Manager ); - connect( select, &QgsArcGisServiceSourceSelect::connectionsChanged, this, &QgsAfsRootItem::connectionsChanged ); + connect( select, &QgsArcGisServiceSourceSelect::connectionsChanged, this, &QgsAfsRootItem::onConnectionsChanged ); return select; } From e4f17f41c36bb255d2b5707942a3dd91752d0c17 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:24:50 +1000 Subject: [PATCH 05/15] Add missing QStringLiterals --- src/core/composer/qgsatlascomposition.cpp | 12 ++++++------ src/core/gps/qgsgpsdetector.cpp | 5 ++++- .../symbology/qgscategorizedsymbolrenderer.cpp | 9 +++++---- src/core/symbology/qgscptcityarchive.cpp | 6 ++++-- src/core/symbology/qgsfillsymbollayer.cpp | 8 ++++---- src/core/symbology/qgsgraduatedsymbolrenderer.cpp | 14 +++++++------- src/core/symbology/qgsheatmaprenderer.cpp | 2 +- src/core/symbology/qgsinvertedpolygonrenderer.cpp | 8 +++++--- src/core/symbology/qgslinesymbollayer.cpp | 12 ++++++------ src/core/symbology/qgsmarkersymbollayer.cpp | 6 +++--- src/core/symbology/qgspointclusterrenderer.cpp | 4 ++-- 11 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/core/composer/qgsatlascomposition.cpp b/src/core/composer/qgsatlascomposition.cpp index ad290154df59..80f2cec34843 100644 --- a/src/core/composer/qgsatlascomposition.cpp +++ b/src/core/composer/qgsatlascomposition.cpp @@ -602,7 +602,7 @@ QString QgsAtlasComposition::currentFilename() const void QgsAtlasComposition::writeXml( QDomElement &elem, QDomDocument &doc ) const { QDomElement atlasElem = doc.createElement( QStringLiteral( "Atlas" ) ); - atlasElem.setAttribute( QStringLiteral( "enabled" ), mEnabled ? "true" : "false" ); + atlasElem.setAttribute( QStringLiteral( "enabled" ), mEnabled ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); if ( !mEnabled ) { return; @@ -620,18 +620,18 @@ void QgsAtlasComposition::writeXml( QDomElement &elem, QDomDocument &doc ) const atlasElem.setAttribute( QStringLiteral( "coverageLayer" ), QLatin1String( "" ) ); } - atlasElem.setAttribute( QStringLiteral( "hideCoverage" ), mHideCoverage ? "true" : "false" ); - atlasElem.setAttribute( QStringLiteral( "singleFile" ), mSingleFile ? "true" : "false" ); + atlasElem.setAttribute( QStringLiteral( "hideCoverage" ), mHideCoverage ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); + atlasElem.setAttribute( QStringLiteral( "singleFile" ), mSingleFile ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); atlasElem.setAttribute( QStringLiteral( "filenamePattern" ), mFilenamePattern ); atlasElem.setAttribute( QStringLiteral( "pageNameExpression" ), mPageNameExpression ); - atlasElem.setAttribute( QStringLiteral( "sortFeatures" ), mSortFeatures ? "true" : "false" ); + atlasElem.setAttribute( QStringLiteral( "sortFeatures" ), mSortFeatures ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); if ( mSortFeatures ) { atlasElem.setAttribute( QStringLiteral( "sortKey" ), mSortKeyAttributeName ); - atlasElem.setAttribute( QStringLiteral( "sortAscending" ), mSortAscending ? "true" : "false" ); + atlasElem.setAttribute( QStringLiteral( "sortAscending" ), mSortAscending ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); } - atlasElem.setAttribute( QStringLiteral( "filterFeatures" ), mFilterFeatures ? "true" : "false" ); + atlasElem.setAttribute( QStringLiteral( "filterFeatures" ), mFilterFeatures ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); if ( mFilterFeatures ) { atlasElem.setAttribute( QStringLiteral( "featureFilter" ), mFeatureFilter ); diff --git a/src/core/gps/qgsgpsdetector.cpp b/src/core/gps/qgsgpsdetector.cpp index 1e1e9e77d72c..87e8ea1247eb 100644 --- a/src/core/gps/qgsgpsdetector.cpp +++ b/src/core/gps/qgsgpsdetector.cpp @@ -44,7 +44,10 @@ QList< QPair > QgsGPSDetector::availablePorts() #ifdef Q_OS_LINUX // look for linux serial devices - Q_FOREACH ( const QString &linuxDev, QStringList() << "/dev/ttyS%1" << "/dev/ttyUSB%1" << "/dev/rfcomm%1" << "/dev/ttyACM%1" ) + const QStringList devices { QStringLiteral( "/dev/ttyS%1" ), + QStringLiteral( "/dev/ttyUSB%1" ), + QStringLiteral( "/dev/rfcomm%1" ), QStringLiteral( "/dev/ttyACM%1" ) }; + for ( const QString &linuxDev : devices ) { for ( int i = 0; i < 10; ++i ) { diff --git a/src/core/symbology/qgscategorizedsymbolrenderer.cpp b/src/core/symbology/qgscategorizedsymbolrenderer.cpp index 3a6b4547cd96..83c9c3edaedf 100644 --- a/src/core/symbology/qgscategorizedsymbolrenderer.cpp +++ b/src/core/symbology/qgscategorizedsymbolrenderer.cpp @@ -644,7 +644,7 @@ QgsFeatureRenderer *QgsCategorizedSymbolRenderer::create( QDomElement &element, } } - QDomElement ddsLegendSizeElem = element.firstChildElement( "data-defined-size-legend" ); + QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral( "data-defined-size-legend" ) ); if ( !ddsLegendSizeElem.isNull() ) { r->mDataDefinedSizeLegend.reset( QgsDataDefinedSizeLegend::readXml( ddsLegendSizeElem, context ) ); @@ -656,10 +656,11 @@ QgsFeatureRenderer *QgsCategorizedSymbolRenderer::create( QDomElement &element, QDomElement QgsCategorizedSymbolRenderer::save( QDomDocument &doc, const QgsReadWriteContext &context ) { + // clazy:skip QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME ); rendererElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "categorizedSymbol" ) ); - rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? "1" : "0" ) ); - rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); + rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); rendererElem.setAttribute( QStringLiteral( "attr" ), mAttrName ); // categories @@ -722,7 +723,7 @@ QDomElement QgsCategorizedSymbolRenderer::save( QDomDocument &doc, const QgsRead mOrderBy.save( orderBy ); rendererElem.appendChild( orderBy ); } - rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); if ( mDataDefinedSizeLegend ) { diff --git a/src/core/symbology/qgscptcityarchive.cpp b/src/core/symbology/qgscptcityarchive.cpp index 89b74908e264..3c0b548e39fe 100644 --- a/src/core/symbology/qgscptcityarchive.cpp +++ b/src/core/symbology/qgscptcityarchive.cpp @@ -67,7 +67,8 @@ QgsCptCityArchive::QgsCptCityArchive( const QString &archiveName, const QString QgsCptCitySelectionItem *selItem = nullptr; QDir seldir( mBaseDir + '/' + "selections" ); QgsDebugMsg( "populating selection from " + seldir.path() ); - Q_FOREACH ( const QString &selfile, seldir.entryList( QStringList( "*.xml" ), QDir::Files ) ) + const QStringList fileList = seldir.entryList( QStringList() << QStringLiteral( "*.xml" ), QDir::Files ); + for ( const QString &selfile : fileList ) { QgsDebugMsg( "file= " + seldir.path() + '/' + selfile ); selItem = new QgsCptCitySelectionItem( nullptr, QFileInfo( selfile ).baseName(), @@ -460,7 +461,8 @@ void QgsCptCityArchive::initArchives( bool loadAll ) if ( loadAll ) { QDir dir( baseDir ); - Q_FOREACH ( const QString &entry, dir.entryList( QStringList( "cpt-city*" ), QDir::Dirs ) ) + const QStringList fileList = dir.entryList( QStringList() << QStringLiteral( "cpt-city*" ), QDir::Dirs ); + for ( const QString &entry : fileList ) { if ( QFile::exists( baseDir + '/' + entry + "/VERSION.xml" ) ) archivesMap[ entry ] = baseDir + '/' + entry; diff --git a/src/core/symbology/qgsfillsymbollayer.cpp b/src/core/symbology/qgsfillsymbollayer.cpp index 30aee08bc896..e125ef195e2b 100644 --- a/src/core/symbology/qgsfillsymbollayer.cpp +++ b/src/core/symbology/qgsfillsymbollayer.cpp @@ -381,7 +381,7 @@ QgsSymbolLayer *QgsSimpleFillSymbolLayer::createFromSld( QDomElement &element ) QPointF offset; QgsSymbolLayerUtils::displacementFromSldElement( element, offset ); - QString uom = element.attribute( QStringLiteral( "uom" ), "" ); + QString uom = element.attribute( QStringLiteral( "uom" ), QString() ); offset.setX( QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, offset.x() ) ); offset.setY( QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, offset.y() ) ); strokeWidth = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, strokeWidth ); @@ -1013,7 +1013,7 @@ QgsSymbolLayer *QgsShapeburstFillSymbolLayer::create( const QgsStringMap &props //attempt to create color ramp from props QgsColorRamp *gradientRamp = nullptr; - if ( props.contains( QStringLiteral( "rampType" ) ) && props["rampType"] == QStringLiteral( "cpt-city" ) ) + if ( props.contains( QStringLiteral( "rampType" ) ) && props[QStringLiteral( "rampType" )] == QStringLiteral( "cpt-city" ) ) { gradientRamp = QgsCptCityColorRamp::create( props ); } @@ -2139,7 +2139,7 @@ QgsSymbolLayer *QgsSVGFillSymbolLayer::createFromSld( QDomElement &element ) QgsSymbolLayerUtils::lineFromSld( graphicElem, penStyle, strokeColor, strokeWidth ); - QString uom = element.attribute( QStringLiteral( "uom" ), "" ); + QString uom = element.attribute( QStringLiteral( "uom" ) ); size = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, size ); strokeWidth = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, strokeWidth ); @@ -2964,7 +2964,7 @@ QgsSymbolLayer *QgsLinePatternFillSymbolLayer::createFromSld( QDomElement &eleme offset = std::sqrt( std::pow( vectOffset.x(), 2 ) + std::pow( vectOffset.y(), 2 ) ); } - QString uom = element.attribute( QStringLiteral( "uom" ), "" ); + QString uom = element.attribute( QStringLiteral( "uom" ) ); size = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, size ); lineWidth = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, lineWidth ); diff --git a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp index b536040200b8..a00021b3bacd 100644 --- a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp +++ b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp @@ -169,7 +169,7 @@ void QgsRendererRange::toSld( QDomDocument &doc, QDomElement &element, QgsString // create the ogc:Filter for the range QString filterFunc = QStringLiteral( "\"%1\" %2 %3 AND \"%1\" <= %4" ) .arg( attrName.replace( '\"', QLatin1String( "\"\"" ) ), - firstRange ? ">=" : ">", + firstRange ? QStringLiteral( ">=" ) : QStringLiteral( ">" ), qgsDoubleToString( mLowerValue ), qgsDoubleToString( mUpperValue ) ); QgsSymbolLayerUtils::createFunctionElement( doc, ruleElem, filterFunc ); @@ -282,7 +282,7 @@ void QgsRendererRangeLabelFormat::saveToDomElement( QDomElement &element ) { element.setAttribute( QStringLiteral( "format" ), mFormat ); element.setAttribute( QStringLiteral( "decimalplaces" ), mPrecision ); - element.setAttribute( QStringLiteral( "trimtrailingzeroes" ), mTrimTrailingZeroes ? "true" : "false" ); + element.setAttribute( QStringLiteral( "trimtrailingzeroes" ), mTrimTrailingZeroes ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); } /////////// @@ -1040,7 +1040,7 @@ QgsFeatureRenderer *QgsGraduatedSymbolRenderer::create( QDomElement &element, co r->setLabelFormat( labelFormat ); } - QDomElement ddsLegendSizeElem = element.firstChildElement( "data-defined-size-legend" ); + QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral( "data-defined-size-legend" ) ); if ( !ddsLegendSizeElem.isNull() ) { r->mDataDefinedSizeLegend.reset( QgsDataDefinedSizeLegend::readXml( ddsLegendSizeElem, context ) ); @@ -1054,8 +1054,8 @@ QDomElement QgsGraduatedSymbolRenderer::save( QDomDocument &doc, const QgsReadWr { QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME ); rendererElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "graduatedSymbol" ) ); - rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? "1" : "0" ) ); - rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); + rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); rendererElem.setAttribute( QStringLiteral( "attr" ), mAttrName ); rendererElem.setAttribute( QStringLiteral( "graduatedMethod" ), graduatedMethodStr( mGraduatedMethod ) ); @@ -1075,7 +1075,7 @@ QDomElement QgsGraduatedSymbolRenderer::save( QDomDocument &doc, const QgsReadWr rangeElem.setAttribute( QStringLiteral( "upper" ), QString::number( range.upperValue(), 'f', 15 ) ); rangeElem.setAttribute( QStringLiteral( "symbol" ), symbolName ); rangeElem.setAttribute( QStringLiteral( "label" ), range.label() ); - rangeElem.setAttribute( QStringLiteral( "render" ), range.renderState() ? "true" : "false" ); + rangeElem.setAttribute( QStringLiteral( "render" ), range.renderState() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); rangesElem.appendChild( rangeElem ); i++; } @@ -1140,7 +1140,7 @@ QDomElement QgsGraduatedSymbolRenderer::save( QDomDocument &doc, const QgsReadWr mOrderBy.save( orderBy ); rendererElem.appendChild( orderBy ); } - rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); if ( mDataDefinedSizeLegend ) { diff --git a/src/core/symbology/qgsheatmaprenderer.cpp b/src/core/symbology/qgsheatmaprenderer.cpp index 457c232af965..8066baa55894 100644 --- a/src/core/symbology/qgsheatmaprenderer.cpp +++ b/src/core/symbology/qgsheatmaprenderer.cpp @@ -340,7 +340,7 @@ QDomElement QgsHeatmapRenderer::save( QDomDocument &doc, const QgsReadWriteConte QDomElement colorRampElem = QgsSymbolLayerUtils::saveColorRamp( QStringLiteral( "[source]" ), mGradientRamp, doc ); rendererElem.appendChild( colorRampElem ); } - rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); if ( mPaintEffect && !QgsPaintEffectRegistry::isDefaultStack( mPaintEffect ) ) mPaintEffect->saveProperties( doc, rendererElem ); diff --git a/src/core/symbology/qgsinvertedpolygonrenderer.cpp b/src/core/symbology/qgsinvertedpolygonrenderer.cpp index fc5d508fba08..aeb3bc9618e6 100644 --- a/src/core/symbology/qgsinvertedpolygonrenderer.cpp +++ b/src/core/symbology/qgsinvertedpolygonrenderer.cpp @@ -387,10 +387,12 @@ QgsFeatureRenderer *QgsInvertedPolygonRenderer::create( QDomElement &element, co QDomElement QgsInvertedPolygonRenderer::save( QDomDocument &doc, const QgsReadWriteContext &context ) { + // clazy:skip + QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME ); rendererElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "invertedPolygonRenderer" ) ); - rendererElem.setAttribute( QStringLiteral( "preprocessing" ), preprocessingEnabled() ? "1" : "0" ); - rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "preprocessing" ), preprocessingEnabled() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); + rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); if ( mSubRenderer ) { @@ -407,7 +409,7 @@ QDomElement QgsInvertedPolygonRenderer::save( QDomDocument &doc, const QgsReadWr mOrderBy.save( orderBy ); rendererElem.appendChild( orderBy ); } - rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); return rendererElem; } diff --git a/src/core/symbology/qgslinesymbollayer.cpp b/src/core/symbology/qgslinesymbollayer.cpp index db2837fb3167..8f96c893d410 100644 --- a/src/core/symbology/qgslinesymbollayer.cpp +++ b/src/core/symbology/qgslinesymbollayer.cpp @@ -355,11 +355,11 @@ QgsStringMap QgsSimpleLineSymbolLayer::properties() const map[QStringLiteral( "offset" )] = QString::number( mOffset ); map[QStringLiteral( "offset_unit" )] = QgsUnitTypes::encodeUnit( mOffsetUnit ); map[QStringLiteral( "offset_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mOffsetMapUnitScale ); - map[QStringLiteral( "use_custom_dash" )] = ( mUseCustomDashPattern ? "1" : "0" ); + map[QStringLiteral( "use_custom_dash" )] = ( mUseCustomDashPattern ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); map[QStringLiteral( "customdash" )] = QgsSymbolLayerUtils::encodeRealVector( mCustomDashVector ); map[QStringLiteral( "customdash_unit" )] = QgsUnitTypes::encodeUnit( mCustomDashPatternUnit ); map[QStringLiteral( "customdash_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mCustomDashPatternMapUnitScale ); - map[QStringLiteral( "draw_inside_polygon" )] = ( mDrawInsidePolygon ? "1" : "0" ); + map[QStringLiteral( "draw_inside_polygon" )] = ( mDrawInsidePolygon ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); return map; } @@ -462,7 +462,7 @@ QgsSymbolLayer *QgsSimpleLineSymbolLayer::createFromSld( QDomElement &element ) offset = d; } - QString uom = element.attribute( QStringLiteral( "uom" ), "" ); + QString uom = element.attribute( QStringLiteral( "uom" ) ); width = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, width ); offset = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, offset ); @@ -747,7 +747,7 @@ QgsSymbolLayer *QgsMarkerLineSymbolLayer::create( const QgsStringMap &props ) { x->setOffsetAlongLineUnit( QgsUnitTypes::decodeRenderUnit( props[QStringLiteral( "offset_along_line_unit" )] ) ); } - if ( props.contains( ( "offset_along_line_map_unit_scale" ) ) ) + if ( props.contains( ( QStringLiteral( "offset_along_line_map_unit_scale" ) ) ) ) { x->setOffsetAlongLineMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( props[QStringLiteral( "offset_along_line_map_unit_scale" )] ) ); } @@ -1320,7 +1320,7 @@ void QgsMarkerLineSymbolLayer::renderPolylineCentral( const QPolygonF &points, Q QgsStringMap QgsMarkerLineSymbolLayer::properties() const { QgsStringMap map; - map[QStringLiteral( "rotate" )] = ( mRotateMarker ? "1" : "0" ); + map[QStringLiteral( "rotate" )] = ( mRotateMarker ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); map[QStringLiteral( "interval" )] = QString::number( mInterval ); map[QStringLiteral( "offset" )] = QString::number( mOffset ); map[QStringLiteral( "offset_along_line" )] = QString::number( mOffsetAlongLine ); @@ -1523,7 +1523,7 @@ QgsSymbolLayer *QgsMarkerLineSymbolLayer::createFromSld( QDomElement &element ) offset = d; } - QString uom = element.attribute( QStringLiteral( "uom" ), "" ); + QString uom = element.attribute( QStringLiteral( "uom" ) ); interval = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, interval ); offset = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, offset ); diff --git a/src/core/symbology/qgsmarkersymbollayer.cpp b/src/core/symbology/qgsmarkersymbollayer.cpp index 0481b23aeb9d..ce041ca71645 100644 --- a/src/core/symbology/qgsmarkersymbollayer.cpp +++ b/src/core/symbology/qgsmarkersymbollayer.cpp @@ -1194,7 +1194,7 @@ QgsSymbolLayer *QgsSimpleMarkerSymbolLayer::createFromSld( QDomElement &element Shape shape = decodeShape( name ); - QString uom = element.attribute( QStringLiteral( "uom" ), "" ); + QString uom = element.attribute( QStringLiteral( "uom" ) ); size = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, size ); offset.setX( QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, offset.x() ) ); offset.setY( QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, offset.y() ) ); @@ -2223,7 +2223,7 @@ QgsSymbolLayer *QgsSvgMarkerSymbolLayer::createFromSld( QDomElement &element ) if ( !QgsSymbolLayerUtils::externalGraphicFromSld( graphicElem, path, mimeType, fillColor, size ) ) return nullptr; - QString uom = element.attribute( QStringLiteral( "uom" ), "" ); + QString uom = element.attribute( QStringLiteral( "uom" ) ); size = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, size ); if ( mimeType != QLatin1String( "image/svg+xml" ) ) @@ -2883,7 +2883,7 @@ QgsSymbolLayer *QgsFontMarkerSymbolLayer::createFromSld( QDomElement &element ) QPointF offset; QgsSymbolLayerUtils::displacementFromSldElement( graphicElem, offset ); - QString uom = element.attribute( QStringLiteral( "uom" ), "" ); + QString uom = element.attribute( QStringLiteral( "uom" ) ); offset.setX( QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, offset.x() ) ); offset.setY( QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, offset.y() ) ); size = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, size ); diff --git a/src/core/symbology/qgspointclusterrenderer.cpp b/src/core/symbology/qgspointclusterrenderer.cpp index 1e2891fc2de3..5159829a6bda 100644 --- a/src/core/symbology/qgspointclusterrenderer.cpp +++ b/src/core/symbology/qgspointclusterrenderer.cpp @@ -124,7 +124,7 @@ QgsMarkerSymbol *QgsPointClusterRenderer::clusterSymbol() QDomElement QgsPointClusterRenderer::save( QDomDocument &doc, const QgsReadWriteContext &context ) { QDomElement rendererElement = doc.createElement( RENDERER_TAG_NAME ); - rendererElement.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); + rendererElement.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); rendererElement.setAttribute( QStringLiteral( "type" ), QStringLiteral( "pointCluster" ) ); rendererElement.setAttribute( QStringLiteral( "tolerance" ), QString::number( mTolerance ) ); rendererElement.setAttribute( QStringLiteral( "toleranceUnit" ), QgsUnitTypes::encodeUnit( mToleranceUnit ) ); @@ -150,7 +150,7 @@ QDomElement QgsPointClusterRenderer::save( QDomDocument &doc, const QgsReadWrite mOrderBy.save( orderBy ); rendererElement.appendChild( orderBy ); } - rendererElement.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? "1" : "0" ) ); + rendererElement.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); return rendererElement; } From a463acba5711780805c6b8ade1f08858a3717ac7 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:26:10 +1000 Subject: [PATCH 06/15] Fix clazy overriden signals with non signal warnings --- src/app/qgsmapsavedialog.cpp | 2 +- src/app/qgsmapsavedialog.h | 4 +++- src/providers/arcgisrest/qgsafsdataitems.cpp | 2 +- src/providers/arcgisrest/qgsafsdataitems.h | 2 +- src/providers/arcgisrest/qgsamsdataitems.cpp | 4 ++-- src/providers/arcgisrest/qgsamsdataitems.h | 2 +- src/providers/mssql/qgsmssqldataitems.cpp | 4 ++-- src/providers/mssql/qgsmssqldataitems.h | 2 +- src/providers/ogr/qgsgeopackagedataitems.cpp | 2 +- src/providers/ogr/qgsgeopackagedataitems.h | 2 +- src/providers/ows/qgsowsdataitems.cpp | 2 +- src/providers/ows/qgsowsdataitems.h | 2 +- src/providers/postgres/qgspostgresdataitems.cpp | 4 ++-- src/providers/postgres/qgspostgresdataitems.h | 2 +- src/providers/spatialite/qgsspatialitedataitems.cpp | 4 ++-- src/providers/spatialite/qgsspatialitedataitems.h | 2 +- src/providers/wcs/qgswcsdataitems.cpp | 4 ++-- src/providers/wcs/qgswcsdataitems.h | 2 +- src/providers/wfs/qgswfsdataitems.cpp | 4 ++-- src/providers/wfs/qgswfsdataitems.h | 2 +- src/providers/wfs/qgswfsfeatureiterator.cpp | 4 ++-- src/providers/wfs/qgswfsfeatureiterator.h | 4 ++-- 22 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/app/qgsmapsavedialog.cpp b/src/app/qgsmapsavedialog.cpp index 06ea38e51ce5..346b69dc6225 100644 --- a/src/app/qgsmapsavedialog.cpp +++ b/src/app/qgsmapsavedialog.cpp @@ -375,7 +375,7 @@ void QgsMapSaveDialog::copyToClipboard() QgsApplication::taskManager()->addTask( mapRendererTask ); } -void QgsMapSaveDialog::accepted() +void QgsMapSaveDialog::onAccepted() { if ( mDialogType == Image ) { diff --git a/src/app/qgsmapsavedialog.h b/src/app/qgsmapsavedialog.h index af7dc3c8136c..8922e862b71c 100644 --- a/src/app/qgsmapsavedialog.h +++ b/src/app/qgsmapsavedialog.h @@ -76,10 +76,12 @@ class APP_EXPORT QgsMapSaveDialog: public QDialog, private Ui::QgsMapSaveDialog //! configure a map settings object void applyMapSettings( QgsMapSettings &mapSettings ); + private slots: + void onAccepted(); + private: void lockChanged( const bool locked ); - void accepted(); void copyToClipboard(); void updateDpi( int dpi ); diff --git a/src/providers/arcgisrest/qgsafsdataitems.cpp b/src/providers/arcgisrest/qgsafsdataitems.cpp index 88f012368221..8677dd47ad44 100644 --- a/src/providers/arcgisrest/qgsafsdataitems.cpp +++ b/src/providers/arcgisrest/qgsafsdataitems.cpp @@ -64,7 +64,7 @@ QWidget *QgsAfsRootItem::paramWidget() return select; } -void QgsAfsRootItem::connectionsChanged() +void QgsAfsRootItem::onConnectionsChanged() { refresh(); } diff --git a/src/providers/arcgisrest/qgsafsdataitems.h b/src/providers/arcgisrest/qgsafsdataitems.h index ffe765e768bc..1d561f4b131c 100644 --- a/src/providers/arcgisrest/qgsafsdataitems.h +++ b/src/providers/arcgisrest/qgsafsdataitems.h @@ -32,7 +32,7 @@ class QgsAfsRootItem : public QgsDataCollectionItem public slots: #ifdef HAVE_GUI - void connectionsChanged(); + void onConnectionsChanged(); void newConnection(); #endif }; diff --git a/src/providers/arcgisrest/qgsamsdataitems.cpp b/src/providers/arcgisrest/qgsamsdataitems.cpp index 969bb0bb9008..c53e18f1136f 100644 --- a/src/providers/arcgisrest/qgsamsdataitems.cpp +++ b/src/providers/arcgisrest/qgsamsdataitems.cpp @@ -59,11 +59,11 @@ QList QgsAmsRootItem::actions( QWidget *parent ) QWidget *QgsAmsRootItem::paramWidget() { QgsAmsSourceSelect *select = new QgsAmsSourceSelect( 0, 0, QgsProviderRegistry::WidgetMode::Manager ); - connect( select, &QgsArcGisServiceSourceSelect::connectionsChanged, this, &QgsAmsRootItem::connectionsChanged ); + connect( select, &QgsArcGisServiceSourceSelect::connectionsChanged, this, &QgsAmsRootItem::onConnectionsChanged ); return select; } -void QgsAmsRootItem::connectionsChanged() +void QgsAmsRootItem::onConnectionsChanged() { refresh(); } diff --git a/src/providers/arcgisrest/qgsamsdataitems.h b/src/providers/arcgisrest/qgsamsdataitems.h index 69fc83801437..a2e24f881bdb 100644 --- a/src/providers/arcgisrest/qgsamsdataitems.h +++ b/src/providers/arcgisrest/qgsamsdataitems.h @@ -35,7 +35,7 @@ class QgsAmsRootItem : public QgsDataCollectionItem public slots: #ifdef HAVE_GUI - void connectionsChanged(); + void onConnectionsChanged(); void newConnection(); #endif }; diff --git a/src/providers/mssql/qgsmssqldataitems.cpp b/src/providers/mssql/qgsmssqldataitems.cpp index c1bb143cfc6d..10c155d7bdb5 100644 --- a/src/providers/mssql/qgsmssqldataitems.cpp +++ b/src/providers/mssql/qgsmssqldataitems.cpp @@ -619,11 +619,11 @@ QList QgsMssqlRootItem::actions( QWidget *parent ) QWidget *QgsMssqlRootItem::paramWidget() { QgsMssqlSourceSelect *select = new QgsMssqlSourceSelect( nullptr, 0, QgsProviderRegistry::WidgetMode::Manager ); - connect( select, &QgsMssqlSourceSelect::connectionsChanged, this, &QgsMssqlRootItem::connectionsChanged ); + connect( select, &QgsMssqlSourceSelect::connectionsChanged, this, &QgsMssqlRootItem::onConnectionsChanged ); return select; } -void QgsMssqlRootItem::connectionsChanged() +void QgsMssqlRootItem::onConnectionsChanged() { refresh(); } diff --git a/src/providers/mssql/qgsmssqldataitems.h b/src/providers/mssql/qgsmssqldataitems.h index a2c4c7694f37..7e24280951eb 100644 --- a/src/providers/mssql/qgsmssqldataitems.h +++ b/src/providers/mssql/qgsmssqldataitems.h @@ -45,7 +45,7 @@ class QgsMssqlRootItem : public QgsDataCollectionItem public slots: #ifdef HAVE_GUI - void connectionsChanged(); + void onConnectionsChanged(); void newConnection(); #endif }; diff --git a/src/providers/ogr/qgsgeopackagedataitems.cpp b/src/providers/ogr/qgsgeopackagedataitems.cpp index 751698536676..70b5ead07004 100644 --- a/src/providers/ogr/qgsgeopackagedataitems.cpp +++ b/src/providers/ogr/qgsgeopackagedataitems.cpp @@ -91,7 +91,7 @@ QWidget *QgsGeoPackageRootItem::paramWidget() } #endif -void QgsGeoPackageRootItem::connectionsChanged() +void QgsGeoPackageRootItem::onConnectionsChanged() { refresh(); } diff --git a/src/providers/ogr/qgsgeopackagedataitems.h b/src/providers/ogr/qgsgeopackagedataitems.h index 7738c2f38b71..2c4a6052b95b 100644 --- a/src/providers/ogr/qgsgeopackagedataitems.h +++ b/src/providers/ogr/qgsgeopackagedataitems.h @@ -141,7 +141,7 @@ class QgsGeoPackageRootItem : public QgsDataCollectionItem public slots: void newConnection(); - void connectionsChanged(); + void onConnectionsChanged(); void createDatabase(); #endif }; diff --git a/src/providers/ows/qgsowsdataitems.cpp b/src/providers/ows/qgsowsdataitems.cpp index 229f54635418..23543b0a61e6 100644 --- a/src/providers/ows/qgsowsdataitems.cpp +++ b/src/providers/ows/qgsowsdataitems.cpp @@ -237,7 +237,7 @@ QWidget *QgsOWSRootItem::paramWidget() #endif return nullptr; } -void QgsOWSRootItem::connectionsChanged() +void QgsOWSRootItem::onConnectionsChanged() { refresh(); } diff --git a/src/providers/ows/qgsowsdataitems.h b/src/providers/ows/qgsowsdataitems.h index 4a5a4f5c2ba7..71da02a691cf 100644 --- a/src/providers/ows/qgsowsdataitems.h +++ b/src/providers/ows/qgsowsdataitems.h @@ -57,7 +57,7 @@ class QgsOWSRootItem : public QgsDataCollectionItem public slots: #ifdef HAVE_GUI - void connectionsChanged(); + void onConnectionsChanged(); void newConnection(); #endif diff --git a/src/providers/postgres/qgspostgresdataitems.cpp b/src/providers/postgres/qgspostgresdataitems.cpp index 70f730ddc829..3103a7b05c81 100644 --- a/src/providers/postgres/qgspostgresdataitems.cpp +++ b/src/providers/postgres/qgspostgresdataitems.cpp @@ -739,11 +739,11 @@ QList QgsPGRootItem::actions( QWidget *parent ) QWidget *QgsPGRootItem::paramWidget() { QgsPgSourceSelect *select = new QgsPgSourceSelect( nullptr, 0, QgsProviderRegistry::WidgetMode::Manager ); - connect( select, &QgsPgSourceSelect::connectionsChanged, this, &QgsPGRootItem::connectionsChanged ); + connect( select, &QgsPgSourceSelect::connectionsChanged, this, &QgsPGRootItem::onConnectionsChanged ); return select; } -void QgsPGRootItem::connectionsChanged() +void QgsPGRootItem::onConnectionsChanged() { refresh(); } diff --git a/src/providers/postgres/qgspostgresdataitems.h b/src/providers/postgres/qgspostgresdataitems.h index 2a451fba23e0..aa8d846bf36d 100644 --- a/src/providers/postgres/qgspostgresdataitems.h +++ b/src/providers/postgres/qgspostgresdataitems.h @@ -46,7 +46,7 @@ class QgsPGRootItem : public QgsDataCollectionItem public slots: #ifdef HAVE_GUI - void connectionsChanged(); + void onConnectionsChanged(); void newConnection(); #endif }; diff --git a/src/providers/spatialite/qgsspatialitedataitems.cpp b/src/providers/spatialite/qgsspatialitedataitems.cpp index e3b7b78cd057..b0eb72e6c3fe 100644 --- a/src/providers/spatialite/qgsspatialitedataitems.cpp +++ b/src/providers/spatialite/qgsspatialitedataitems.cpp @@ -313,11 +313,11 @@ QList QgsSLRootItem::actions( QWidget *parent ) QWidget *QgsSLRootItem::paramWidget() { QgsSpatiaLiteSourceSelect *select = new QgsSpatiaLiteSourceSelect( nullptr, 0, QgsProviderRegistry::WidgetMode::Manager ); - connect( select, &QgsSpatiaLiteSourceSelect::connectionsChanged, this, &QgsSLRootItem::connectionsChanged ); + connect( select, &QgsSpatiaLiteSourceSelect::connectionsChanged, this, &QgsSLRootItem::onConnectionsChanged ); return select; } -void QgsSLRootItem::connectionsChanged() +void QgsSLRootItem::onConnectionsChanged() { refresh(); } diff --git a/src/providers/spatialite/qgsspatialitedataitems.h b/src/providers/spatialite/qgsspatialitedataitems.h index a7ca19662e16..492520c97f72 100644 --- a/src/providers/spatialite/qgsspatialitedataitems.h +++ b/src/providers/spatialite/qgsspatialitedataitems.h @@ -74,7 +74,7 @@ class QgsSLRootItem : public QgsDataCollectionItem public slots: #ifdef HAVE_GUI - void connectionsChanged(); + void onConnectionsChanged(); void newConnection(); #endif void createDatabase(); diff --git a/src/providers/wcs/qgswcsdataitems.cpp b/src/providers/wcs/qgswcsdataitems.cpp index 3758f83f9e04..cbf624251266 100644 --- a/src/providers/wcs/qgswcsdataitems.cpp +++ b/src/providers/wcs/qgswcsdataitems.cpp @@ -261,11 +261,11 @@ QList QgsWCSRootItem::actions( QWidget *parent ) QWidget *QgsWCSRootItem::paramWidget() { QgsWCSSourceSelect *select = new QgsWCSSourceSelect( nullptr, 0, QgsProviderRegistry::WidgetMode::Manager ); - connect( select, &QgsOWSSourceSelect::connectionsChanged, this, &QgsWCSRootItem::connectionsChanged ); + connect( select, &QgsOWSSourceSelect::connectionsChanged, this, &QgsWCSRootItem::onConnectionsChanged ); return select; } -void QgsWCSRootItem::connectionsChanged() +void QgsWCSRootItem::onConnectionsChanged() { refresh(); } diff --git a/src/providers/wcs/qgswcsdataitems.h b/src/providers/wcs/qgswcsdataitems.h index 9deb6017f2df..d3b6f12dd114 100644 --- a/src/providers/wcs/qgswcsdataitems.h +++ b/src/providers/wcs/qgswcsdataitems.h @@ -80,7 +80,7 @@ class QgsWCSRootItem : public QgsDataCollectionItem public slots: #ifdef HAVE_GUI - void connectionsChanged(); + void onConnectionsChanged(); void newConnection(); #endif }; diff --git a/src/providers/wfs/qgswfsdataitems.cpp b/src/providers/wfs/qgswfsdataitems.cpp index a13e9a03f713..c0e03f38a0fe 100644 --- a/src/providers/wfs/qgswfsdataitems.cpp +++ b/src/providers/wfs/qgswfsdataitems.cpp @@ -259,11 +259,11 @@ QList QgsWfsRootItem::actions( QWidget *parent ) QWidget *QgsWfsRootItem::paramWidget() { QgsWFSSourceSelect *select = new QgsWFSSourceSelect( nullptr, 0, QgsProviderRegistry::WidgetMode::Manager ); - connect( select, &QgsWFSSourceSelect::connectionsChanged, this, &QgsWfsRootItem::connectionsChanged ); + connect( select, &QgsWFSSourceSelect::connectionsChanged, this, &QgsWfsRootItem::onConnectionsChanged ); return select; } -void QgsWfsRootItem::connectionsChanged() +void QgsWfsRootItem::onConnectionsChanged() { refresh(); } diff --git a/src/providers/wfs/qgswfsdataitems.h b/src/providers/wfs/qgswfsdataitems.h index 8df96ab8bd9b..f55955a5e595 100644 --- a/src/providers/wfs/qgswfsdataitems.h +++ b/src/providers/wfs/qgswfsdataitems.h @@ -37,7 +37,7 @@ class QgsWfsRootItem : public QgsDataCollectionItem public slots: #ifdef HAVE_GUI - void connectionsChanged(); + void onConnectionsChanged(); void newConnection(); #endif }; diff --git a/src/providers/wfs/qgswfsfeatureiterator.cpp b/src/providers/wfs/qgswfsfeatureiterator.cpp index b3f2614f17d7..c8784f3bb7ae 100644 --- a/src/providers/wfs/qgswfsfeatureiterator.cpp +++ b/src/providers/wfs/qgswfsfeatureiterator.cpp @@ -128,7 +128,7 @@ QgsWFSProgressDialog::QgsWFSProgressDialog( const QString &labelText, mCancel = new QPushButton( cancelButtonText, this ); setCancelButton( mCancel ); mHide = new QPushButton( tr( "Hide" ), this ); - connect( mHide, &QAbstractButton::clicked, this, &QgsWFSProgressDialog::hide ); + connect( mHide, &QAbstractButton::clicked, this, &QgsWFSProgressDialog::hideRequest ); } void QgsWFSProgressDialog::resizeEvent( QResizeEvent *ev ) @@ -173,7 +173,7 @@ void QgsWFSFeatureDownloader::createProgressDialog() connect( mProgressDialog, &QProgressDialog::canceled, this, &QgsWFSFeatureDownloader::setStopFlag, Qt::DirectConnection ); connect( mProgressDialog, &QProgressDialog::canceled, this, &QgsWFSFeatureDownloader::stop ); - connect( mProgressDialog, &QWidget::hide, this, &QgsWFSFeatureDownloader::hideProgressDialog ); + connect( mProgressDialog, &QgsWFSProgressDialog::hideRequest, this, &QgsWFSFeatureDownloader::hideProgressDialog ); // Make sure the progress dialog has not been deleted by another thread if ( mProgressDialog ) diff --git a/src/providers/wfs/qgswfsfeatureiterator.h b/src/providers/wfs/qgswfsfeatureiterator.h index 1fc98882f234..f98ddb51c26f 100644 --- a/src/providers/wfs/qgswfsfeatureiterator.h +++ b/src/providers/wfs/qgswfsfeatureiterator.h @@ -72,7 +72,7 @@ class QgsWFSProgressDialog: public QProgressDialog void resizeEvent( QResizeEvent *ev ) override; signals: - void hide(); + void hideRequest(); private: QPushButton *mCancel = nullptr; @@ -141,7 +141,7 @@ class QgsWFSFeatureDownloader: public QgsWfsRequest //! Whether the download should stop bool mStop; //! Progress dialog - QProgressDialog *mProgressDialog = nullptr; + QgsWFSProgressDialog *mProgressDialog = nullptr; /** If the progress dialog should be shown immediately, or if it should be let to QProgressDialog logic to decide when to show it */ From 3837ddfd3d45eb946142161bcd5731838e41e33f Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:27:11 +1000 Subject: [PATCH 07/15] Flip some easy QLists to QVectors --- src/app/qgisapp.cpp | 4 ++-- src/app/qgisapp.h | 2 +- src/core/qgsdatadefinedsizelegend.h | 6 +++--- src/core/symbology/qgsgraduatedsymbolrenderer.cpp | 2 +- src/core/symbology/qgsgraduatedsymbolrenderer.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 0c1b6f4a6e7a..c4b1a72e114a 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1345,7 +1345,7 @@ void QgisApp::dropEvent( QDropEvent *event ) timer->setInterval( 50 ); // first, allow custom handlers to directly operate on the mime data - const QList> handlers = mCustomDropHandlers; + const QVector> handlers = mCustomDropHandlers; for ( QgsCustomDropHandler *handler : handlers ) { if ( handler ) @@ -1427,7 +1427,7 @@ void QgisApp::dropEvent( QDropEvent *event ) bool handled = false; // give custom drop handlers first priority at handling the file - const QList>handlers = mCustomDropHandlers; + const QVector> handlers = mCustomDropHandlers; for ( QgsCustomDropHandler *handler : handlers ) { if ( handler && handler->handleFileDrop( file ) ) diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 3ea173cdb56e..2bba1d42a2ce 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -2053,7 +2053,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QList mMapLayerPanelFactories; QList> mOptionsWidgetFactories; - QList> mCustomDropHandlers; + QVector> mCustomDropHandlers; QDateTime mProjectLastModified; diff --git a/src/core/qgsdatadefinedsizelegend.h b/src/core/qgsdatadefinedsizelegend.h index 9ac9d5b1a33a..3c29c9f40417 100644 --- a/src/core/qgsdatadefinedsizelegend.h +++ b/src/core/qgsdatadefinedsizelegend.h @@ -88,9 +88,9 @@ class CORE_EXPORT QgsDataDefinedSizeLegend QgsSizeScaleTransformer *sizeScaleTransformer() const; //! Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label - void setClasses( const QList &classes ) { mSizeClasses = classes; } + void setClasses( const QList< QgsDataDefinedSizeLegend::SizeClass > &classes ) { mSizeClasses = classes; } //! Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label - QList classes() const { return mSizeClasses; } + QList< QgsDataDefinedSizeLegend::SizeClass > classes() const { return mSizeClasses; } //! Sets title label for data-defined size legend void setTitle( const QString &title ) { mTitleLabel = title; } @@ -142,7 +142,7 @@ class CORE_EXPORT QgsDataDefinedSizeLegend private: LegendType mType = LegendSeparated; QString mTitleLabel; //!< Title label for the following size-based item(s) - QList mSizeClasses; //!< List of classes: symbol size (in whatever units symbol uses) + label + QList< SizeClass > mSizeClasses; //!< List of classes: symbol size (in whatever units symbol uses) + label std::unique_ptr mSymbol; std::unique_ptr mSizeScaleTransformer; //!< Optional transformer for classes VerticalAlignment mVAlign = AlignBottom; diff --git a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp index a00021b3bacd..ecc2f45d7908 100644 --- a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp +++ b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp @@ -1390,7 +1390,7 @@ void QgsGraduatedSymbolRenderer::addClass( double lower, double upper ) void QgsGraduatedSymbolRenderer::addBreak( double breakValue, bool updateSymbols ) { - QMutableListIterator< QgsRendererRange > it( mRanges ); + QMutableVectorIterator< QgsRendererRange > it( mRanges ); while ( it.hasNext() ) { QgsRendererRange range = it.next(); diff --git a/src/core/symbology/qgsgraduatedsymbolrenderer.h b/src/core/symbology/qgsgraduatedsymbolrenderer.h index 4af3dbf8904e..149656aaa296 100644 --- a/src/core/symbology/qgsgraduatedsymbolrenderer.h +++ b/src/core/symbology/qgsgraduatedsymbolrenderer.h @@ -78,7 +78,7 @@ class CORE_EXPORT QgsRendererRange void swap( QgsRendererRange &other ); }; -typedef QList QgsRangeList; +typedef QVector QgsRangeList; /** \ingroup core From be7f85bfa18d48dc09bbbcdcd0503ad9196e69ec Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:27:49 +1000 Subject: [PATCH 08/15] Remove some unused variables --- src/app/qgisapp.cpp | 1 - src/providers/db2/qgsdb2provider.cpp | 4 ++-- src/providers/grass/qgsgrassimport.cpp | 2 ++ src/providers/wfs/qgswfsdataitems.cpp | 4 ++++ src/providers/wms/qgsxyzconnection.cpp | 1 - 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index c4b1a72e114a..c496ac923e4a 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -4349,7 +4349,6 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer ) } QStringList sublayers = layer->dataProvider()->subLayers(); - QString layertype = layer->dataProvider()->storageType(); QgsSublayersDialog::LayerDefinitionList list; Q_FOREACH ( const QString &sublayer, sublayers ) diff --git a/src/providers/db2/qgsdb2provider.cpp b/src/providers/db2/qgsdb2provider.cpp index ae095bc78be9..23d2ff588e96 100644 --- a/src/providers/db2/qgsdb2provider.cpp +++ b/src/providers/db2/qgsdb2provider.cpp @@ -1106,10 +1106,10 @@ bool QgsDb2Provider::addFeatures( QgsFeatureList &flist, Flags flags ) query.bindValue( bindIdx, bytea, QSql::In | QSql::Binary ); } - QList list = query.boundValues().values(); - // Show bound values #if 0 + QList list = query.boundValues().values(); + for ( int i = 0; i < list.size(); ++i ) { QgsDebugMsg( QString( "i: %1; value: %2; type: %3" ) diff --git a/src/providers/grass/qgsgrassimport.cpp b/src/providers/grass/qgsgrassimport.cpp index 5609805f5eae..95496ea2dc53 100644 --- a/src/providers/grass/qgsgrassimport.cpp +++ b/src/providers/grass/qgsgrassimport.cpp @@ -715,7 +715,9 @@ bool QgsGrassVectorImport::import() QgsDebugMsg( "waitForFinished" ); mProcess->waitForFinished( 30000 ); +#ifdef QGISDEBUG QString stdoutString = mProcess->readAllStandardOutput().constData(); +#endif QString stderrString = mProcess->readAllStandardError().constData(); #ifdef QGISDEBUG diff --git a/src/providers/wfs/qgswfsdataitems.cpp b/src/providers/wfs/qgswfsdataitems.cpp index c0e03f38a0fe..2fba0ba6e548 100644 --- a/src/providers/wfs/qgswfsdataitems.cpp +++ b/src/providers/wfs/qgswfsdataitems.cpp @@ -89,8 +89,10 @@ void QgsWfsLayerItem::copyStyle() if ( !connection ) { +#ifdef QGISDEBUG QString errorMsg( QStringLiteral( "Cannot get style for layer %1" ).arg( this->name() ) ); QgsDebugMsg( " Cannot get style: " + errorMsg ); +#endif #if 0 // TODO: how to emit message from provider (which does not know about QgisApp) QgisApp::instance()->messageBar()->pushMessage( tr( "Cannot copy style" ), @@ -105,8 +107,10 @@ void QgsWfsLayerItem::copyStyle() QgsGeoNodeStyle style = geoNodeRequest.fetchDefaultStyleBlocking( this->name() ); if ( style.name.isEmpty() ) { +#ifdef QGISDEBUG QString errorMsg( QStringLiteral( "Cannot get style for layer %1" ).arg( this->name() ) ); QgsDebugMsg( " Cannot get style: " + errorMsg ); +#endif #if 0 // TODO: how to emit message from provider (which does not know about QgisApp) QgisApp::instance()->messageBar()->pushMessage( tr( "Cannot copy style" ), diff --git a/src/providers/wms/qgsxyzconnection.cpp b/src/providers/wms/qgsxyzconnection.cpp index 155c51e2b25c..99c36c6d0ce0 100644 --- a/src/providers/wms/qgsxyzconnection.cpp +++ b/src/providers/wms/qgsxyzconnection.cpp @@ -54,7 +54,6 @@ QStringList QgsXyzConnectionUtils::connectionList() { settings.beginGroup( "qgis/connections-xyz/" + s ); bool isHidden = settings.value( QStringLiteral( "hidden" ), false ).toBool(); - QString url = settings.value( QStringLiteral( "url" ), "" ).toString(); settings.endGroup(); if ( isHidden ) { From 6c74502da4f4a6c0be2c490405e84cabbd0af1a4 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:28:21 +1000 Subject: [PATCH 09/15] Fix clazy override signal with signal warnings --- src/app/qgslabelingwidget.h | 3 --- src/app/qgsmaptoolidentifyaction.h | 3 +-- src/app/qgsrulebasedlabelingwidget.h | 6 ------ src/providers/postgres/qgspgsourceselect.h | 1 - src/providers/postgres/qgspostgresprovider.h | 7 ------- src/providers/spatialite/qgsspatialiteprovider.h | 7 ------- src/providers/wcs/qgswcsprovider.h | 5 ----- src/providers/wcs/qgswcssourceselect.h | 7 ------- src/providers/wms/qgswmsprovider.h | 4 ---- 9 files changed, 1 insertion(+), 42 deletions(-) diff --git a/src/app/qgslabelingwidget.h b/src/app/qgslabelingwidget.h index b530026b503d..7d3e42e971b6 100644 --- a/src/app/qgslabelingwidget.h +++ b/src/app/qgslabelingwidget.h @@ -51,9 +51,6 @@ class QgsLabelingWidget : public QgsMapLayerConfigWidget, private Ui::QgsLabelin void resetSettings(); - signals: - void widgetChanged(); - protected slots: void labelModeChanged( int index ); void showEngineConfigDialog(); diff --git a/src/app/qgsmaptoolidentifyaction.h b/src/app/qgsmaptoolidentifyaction.h index 35196de937d9..018553ad26d4 100644 --- a/src/app/qgsmaptoolidentifyaction.h +++ b/src/app/qgsmaptoolidentifyaction.h @@ -64,8 +64,7 @@ class APP_EXPORT QgsMapToolIdentifyAction : public QgsMapToolIdentify void handleChangedRasterResults( QList &results ); signals: - void identifyProgress( int, int ); - void identifyMessage( const QString & ); + void copyToClipboard( QgsFeatureStore & ); private slots: diff --git a/src/app/qgsrulebasedlabelingwidget.h b/src/app/qgsrulebasedlabelingwidget.h index 12f7c44dc438..95211d13a324 100644 --- a/src/app/qgsrulebasedlabelingwidget.h +++ b/src/app/qgsrulebasedlabelingwidget.h @@ -88,9 +88,6 @@ class QgsRuleBasedLabelingWidget : public QgsPanelWidget, private Ui::QgsRuleBas //! Gives access to the internal root of the rule tree const QgsRuleBasedLabeling::Rule *rootRule() const { return mRootRule; } - signals: - void widgetChanged(); - protected slots: void addRule(); void editRule(); @@ -144,9 +141,6 @@ class APP_EXPORT QgsLabelingRulePropsWidget : public QgsPanelWidget, private Ui: virtual void setDockMode( bool dockMode ) override; - signals: - void widgetChanged(); - public slots: void testFilter(); void buildExpression(); diff --git a/src/providers/postgres/qgspgsourceselect.h b/src/providers/postgres/qgspgsourceselect.h index eb165a38b6b9..5033475981a9 100644 --- a/src/providers/postgres/qgspgsourceselect.h +++ b/src/providers/postgres/qgspgsourceselect.h @@ -79,7 +79,6 @@ class QgsPgSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsDbS signals: void addGeometryColumn( const QgsPostgresLayerProperty & ); - void progress( int, int ); void progressMessage( const QString & ); public slots: diff --git a/src/providers/postgres/qgspostgresprovider.h b/src/providers/postgres/qgspostgresprovider.h index 7a586e8e4389..ae06dcb945f1 100644 --- a/src/providers/postgres/qgspostgresprovider.h +++ b/src/providers/postgres/qgspostgresprovider.h @@ -219,13 +219,6 @@ class QgsPostgresProvider : public QgsVectorDataProvider signals: - /** - * This is emitted whenever the worker thread has fully calculated the - * PostGIS extents for this layer, and its event has been received by this - * provider. - */ - void fullExtentCalculated(); - /** * This is emitted when this provider is satisfied that all objects * have had a chance to adjust themselves after they'd been notified that diff --git a/src/providers/spatialite/qgsspatialiteprovider.h b/src/providers/spatialite/qgsspatialiteprovider.h index f9bc2e060afd..a0c95084606a 100644 --- a/src/providers/spatialite/qgsspatialiteprovider.h +++ b/src/providers/spatialite/qgsspatialiteprovider.h @@ -175,13 +175,6 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider signals: - /** - * This is emitted whenever the worker thread has fully calculated the - * extents for this layer, and its event has been received by this - * provider. - */ - void fullExtentCalculated(); - /** * This is emitted when this provider is satisfied that all objects * have had a chance to adjust themselves after they'd been notified that diff --git a/src/providers/wcs/qgswcsprovider.h b/src/providers/wcs/qgswcsprovider.h index 2b314145097c..6fd2a10e5b8f 100644 --- a/src/providers/wcs/qgswcsprovider.h +++ b/src/providers/wcs/qgswcsprovider.h @@ -191,11 +191,6 @@ class QgsWcsProvider : public QgsRasterDataProvider, QgsGdalProviderBase */ static bool parseServiceExceptionReportDom( QByteArray const &xml, const QString &wcsVersion, QString &errorTitle, QString &errorText ); - - signals: - - void dataChanged(); - private: // case insensitive attribute value lookup static QString nodeAttribute( const QDomElement &e, const QString &name, const QString &defValue = QString() ); diff --git a/src/providers/wcs/qgswcssourceselect.h b/src/providers/wcs/qgswcssourceselect.h index 35da8bfdffff..c098ecbd6222 100644 --- a/src/providers/wcs/qgswcssourceselect.h +++ b/src/providers/wcs/qgswcssourceselect.h @@ -58,13 +58,6 @@ class QgsWCSSourceSelect : public QgsOWSSourceSelect ~QgsWCSSourceSelect(); - public slots: - - signals: - void addRasterLayer( QString const &rasterLayerPath, - QString const &baseName, - QString const &providerKey ); - private: QgsWcsCapabilities mCapabilities; diff --git a/src/providers/wms/qgswmsprovider.h b/src/providers/wms/qgswmsprovider.h index e44351b67bf0..0830bcce0476 100644 --- a/src/providers/wms/qgswmsprovider.h +++ b/src/providers/wms/qgswmsprovider.h @@ -253,10 +253,6 @@ class QgsWmsProvider : public QgsRasterDataProvider } TilePosition; typedef QList TilePositions; - signals: - - void dataChanged(); - private slots: void identifyReplyFinished(); void getLegendGraphicReplyFinished( const QImage & ); From f952e6a6477751a598612db21750c1deae336cfb Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:28:44 +1000 Subject: [PATCH 10/15] Misc clazy fixes --- src/core/composer/qgsatlascomposition.h | 2 +- src/core/gps/qgsgpsdetector.cpp | 2 +- src/core/qgsrendercontext.h | 2 +- src/core/qgsvectorlayereditpassthrough.cpp | 3 ++- src/core/symbology/qgsinvertedpolygonrenderer.cpp | 2 +- src/gui/qgsmapcanvas.cpp | 2 +- src/gui/qgsmetadatawidget.cpp | 2 +- src/providers/postgres/qgspostgresprovider.cpp | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/core/composer/qgsatlascomposition.h b/src/core/composer/qgsatlascomposition.h index 8b37d61ec510..543dfe8ad6b9 100644 --- a/src/core/composer/qgsatlascomposition.h +++ b/src/core/composer/qgsatlascomposition.h @@ -162,7 +162,7 @@ class CORE_EXPORT QgsAtlasComposition : public QObject * \note This property is only used for image exports. * \since QGIS 3.0 */ - void setFileFormat( QString format ) { mFileFormat = format; } + void setFileFormat( const QString &format ) { mFileFormat = format; } bool sortFeatures() const { return mSortFeatures; } void setSortFeatures( bool doSort ) { mSortFeatures = doSort; } diff --git a/src/core/gps/qgsgpsdetector.cpp b/src/core/gps/qgsgpsdetector.cpp index 87e8ea1247eb..24579007b6fa 100644 --- a/src/core/gps/qgsgpsdetector.cpp +++ b/src/core/gps/qgsgpsdetector.cpp @@ -190,7 +190,7 @@ void QgsGPSDetector::advance() connect( mConn, &QObject::destroyed, this, &QgsGPSDetector::connDestroyed ); // leave 2s to pickup a valid string - QTimer::singleShot( 2000, this, SLOT( advance() ) ); + QTimer::singleShot( 2000, this, &QgsGPSDetector::advance ); } void QgsGPSDetector::detected( const QgsGPSInformation &info ) diff --git a/src/core/qgsrendercontext.h b/src/core/qgsrendercontext.h index 41cd997825a9..717bb67b2df2 100644 --- a/src/core/qgsrendercontext.h +++ b/src/core/qgsrendercontext.h @@ -184,7 +184,7 @@ class CORE_EXPORT QgsRenderContext * Will be used to convert meter distances to active MapUnit values for QgsUnitTypes::RenderMetersInMapUnits * \since QGIS 3.0 */ - void setDistanceArea( const QgsDistanceArea distanceArea ) {mDistanceArea = distanceArea ;} + void setDistanceArea( const QgsDistanceArea &distanceArea ) {mDistanceArea = distanceArea ;} /** * Sets the scaling factor for the render to convert painter units diff --git a/src/core/qgsvectorlayereditpassthrough.cpp b/src/core/qgsvectorlayereditpassthrough.cpp index 9ca61ea365a7..ac5bdacd9dee 100644 --- a/src/core/qgsvectorlayereditpassthrough.cpp +++ b/src/core/qgsvectorlayereditpassthrough.cpp @@ -45,7 +45,8 @@ bool QgsVectorLayerEditPassthrough::addFeature( QgsFeature &f ) if ( !modify( cmd ) ) // modify takes owneship -> no need for cmd to be a smart ptr return false; - f = cmd->features().last(); + const QgsFeatureList features = cmd->features(); + f = features.at( features.count() - 1 ); return true; } diff --git a/src/core/symbology/qgsinvertedpolygonrenderer.cpp b/src/core/symbology/qgsinvertedpolygonrenderer.cpp index aeb3bc9618e6..48755cfa6fdf 100644 --- a/src/core/symbology/qgsinvertedpolygonrenderer.cpp +++ b/src/core/symbology/qgsinvertedpolygonrenderer.cpp @@ -89,7 +89,7 @@ void QgsInvertedPolygonRenderer::checkLegendSymbolItem( const QString &key, bool if ( !mSubRenderer ) return; - return mSubRenderer->checkLegendSymbolItem( key, state ); + mSubRenderer->checkLegendSymbolItem( key, state ); } void QgsInvertedPolygonRenderer::startRender( QgsRenderContext &context, const QgsFields &fields ) diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index d810b2961d69..8dc20f0253fb 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -2193,7 +2193,7 @@ void QgsMapCanvas::schedulePreviewJob( int number ) mPreviewTimer.setSingleShot( true ); mPreviewTimer.setInterval( 250 ); disconnect( mPreviewTimerConnection ); - mPreviewTimerConnection = connect( &mPreviewTimer, &QTimer::timeout, [ = ]() + mPreviewTimerConnection = connect( &mPreviewTimer, &QTimer::timeout, this, [ = ]() { startPreviewJob( number ); } diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 6bb2e9b9c29a..0362372bec79 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -515,7 +515,7 @@ bool QgsMetadataWidget::checkMetadata() const if ( results == false ) { errors = QStringLiteral(); - for ( const QgsMetadataValidator::ValidationResult &result : validationResults ) + for ( const QgsMetadataValidator::ValidationResult &result : qgsAsConst( validationResults ) ) { errors += QLatin1String( "" ) % result.section; if ( ! result.identifier.isNull() ) diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index 7ddf38802981..cc2dc60f8631 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -2472,7 +2472,7 @@ bool QgsPostgresProvider::deleteAttributes( const QgsAttributeIds &ids ) QList idsList = ids.values(); std::sort( idsList.begin(), idsList.end(), std::greater() ); - for ( QList::const_iterator iter = idsList.begin(); iter != idsList.end(); ++iter ) + for ( auto iter = idsList.constBegin(); iter != idsList.constEnd(); ++iter ) { int index = *iter; if ( index < 0 || index >= mAttributeFields.count() ) From 60b8ec5488f65fe5286535175d964dc68ce0c55d Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 11:29:33 +1000 Subject: [PATCH 11/15] Sip sync --- python/core/composer/qgsatlascomposition.sip | 2 +- python/core/qgsdatadefinedsizelegend.sip | 4 ++-- python/core/qgsrendercontext.sip | 2 +- python/core/symbology/qgsgraduatedsymbolrenderer.sip | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/core/composer/qgsatlascomposition.sip b/python/core/composer/qgsatlascomposition.sip index 56a6b060c1c2..dc6520cc8785 100644 --- a/python/core/composer/qgsatlascomposition.sip +++ b/python/core/composer/qgsatlascomposition.sip @@ -171,7 +171,7 @@ class QgsAtlasComposition : QObject :rtype: str %End - void setFileFormat( QString format ); + void setFileFormat( const QString &format ); %Docstring Sets the atlas file format used for image exports. \param format set the file format extension diff --git a/python/core/qgsdatadefinedsizelegend.sip b/python/core/qgsdatadefinedsizelegend.sip index 41bc42d0e09e..4c04d170fa45 100644 --- a/python/core/qgsdatadefinedsizelegend.sip +++ b/python/core/qgsdatadefinedsizelegend.sip @@ -86,11 +86,11 @@ Returns transformer for scaling of symbol sizes. Returns null if no transformer :rtype: QgsSizeScaleTransformer %End - void setClasses( const QList &classes ); + void setClasses( const QList< QgsDataDefinedSizeLegend::SizeClass > &classes ); %Docstring Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label %End - QList classes() const; + QList< QgsDataDefinedSizeLegend::SizeClass > classes() const; %Docstring Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label :rtype: list of QgsDataDefinedSizeLegend.SizeClass diff --git a/python/core/qgsrendercontext.sip b/python/core/qgsrendercontext.sip index 5257d45e8d76..438b597d3032 100644 --- a/python/core/qgsrendercontext.sip +++ b/python/core/qgsrendercontext.sip @@ -189,7 +189,7 @@ Sets coordinate transformation. void setRenderingStopped( bool stopped ); - void setDistanceArea( const QgsDistanceArea distanceArea ); + void setDistanceArea( const QgsDistanceArea &distanceArea ); %Docstring A general purpose distance and area calculator, capable of performing ellipsoid based calculations. Will be used to convert meter distances to active MapUnit values for QgsUnitTypes.RenderMetersInMapUnits diff --git a/python/core/symbology/qgsgraduatedsymbolrenderer.sip b/python/core/symbology/qgsgraduatedsymbolrenderer.sip index d1a299e34509..aa26d2dc4d6d 100644 --- a/python/core/symbology/qgsgraduatedsymbolrenderer.sip +++ b/python/core/symbology/qgsgraduatedsymbolrenderer.sip @@ -75,7 +75,7 @@ class QgsRendererRange void swap( QgsRendererRange &other ); }; -typedef QList QgsRangeList; +typedef QVector QgsRangeList; class QgsRendererRangeLabelFormat From 31c1ae1c6af87d253a055b9acda89f440dc68d0e Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 13:20:30 +1000 Subject: [PATCH 12/15] Add missing QStringLiterals --- src/analysis/network/qgsgraphbuilder.h | 2 + .../network/qgsgraphbuilderinterface.h | 2 + src/analysis/openstreetmap/qgsosmdownload.cpp | 2 +- src/analysis/vector/qgszonalstatistics.h | 4 +- src/app/composer/qgscomposer.cpp | 2 +- src/app/dwg/libdxfrw/drw_entities.cpp | 2 +- src/app/dwg/libdxfrw/drw_header.cpp | 4 +- src/app/dwg/libdxfrw/drw_objects.cpp | 2 +- src/app/dwg/libdxfrw/intern/drw_dbg.cpp | 10 +- src/app/dwg/libdxfrw/intern/dwgreader.cpp | 2 +- src/app/dwg/qgsdwgimportdialog.cpp | 72 +-- src/app/dwg/qgsdwgimporter.cpp | 418 +++++++++--------- src/app/layout/qgslayoutdesignerdialog.cpp | 2 +- src/app/main.cpp | 12 +- src/app/nodetool/qgsnodetool.cpp | 2 +- .../qgspluginsortfilterproxymodel.h | 4 +- src/app/qgisapp.cpp | 18 +- src/app/qgisapp.h | 2 + .../qgsattributeactionpropertiesdialog.cpp | 8 +- src/app/qgscrashdialog.cpp | 8 +- src/app/qgscrashreport.cpp | 44 +- src/app/qgsdecorationcopyright.cpp | 2 +- src/app/qgsdecorationlayoutextentdialog.cpp | 2 +- src/app/qgsfeatureaction.cpp | 6 +- src/app/qgsidentifyresultsdialog.cpp | 4 +- src/app/qgsmapsavedialog.cpp | 4 +- src/app/qgsoptions.cpp | 4 +- src/app/qgspluginregistry.h | 5 +- src/app/qgsprojectproperties.cpp | 4 +- src/app/qgsrasterlayerproperties.cpp | 4 +- src/app/qgssnappingwidget.cpp | 2 +- src/app/qgsvectorlayerproperties.cpp | 26 +- src/core/auth/qgsauthmanager.cpp | 8 +- src/core/auth/qgsauthmethodregistry.cpp | 6 +- .../composer/qgscomposerattributetablev2.cpp | 2 +- src/core/composer/qgscomposerlegend.cpp | 2 +- src/core/composer/qgscomposerpicture.cpp | 4 +- src/core/diagram/qgshistogramdiagram.cpp | 5 + src/core/diagram/qgshistogramdiagram.h | 2 +- src/core/diagram/qgspiediagram.cpp | 5 + src/core/diagram/qgspiediagram.h | 2 +- src/core/diagram/qgstextdiagram.cpp | 5 + src/core/diagram/qgstextdiagram.h | 2 +- src/core/dxf/qgsdxfexport.cpp | 6 +- src/core/effects/qgsblureffect.cpp | 2 +- src/core/effects/qgscoloreffect.cpp | 4 +- src/core/expression/qgsexpression.cpp | 6 +- src/core/expression/qgsexpressionfunction.cpp | 22 +- src/core/expression/qgsexpressionnodeimpl.cpp | 10 +- .../qgsrelationreferencefieldformatter.cpp | 10 +- .../qgsvaluerelationfieldformatter.cpp | 18 +- .../geocms/geonode/qgsgeonodeconnection.cpp | 4 +- src/core/geometry/qgsabstractgeometry.h | 2 + src/core/geometry/qgscircularstring.h | 2 + src/core/geometry/qgscompoundcurve.cpp | 2 +- src/core/geometry/qgscompoundcurve.h | 2 + src/core/geometry/qgscurvepolygon.cpp | 6 +- src/core/geometry/qgscurvepolygon.h | 2 + src/core/geometry/qgsgeometrycollection.h | 2 + src/core/geometry/qgsgeometrymakevalid.cpp | 34 +- src/core/geometry/qgsgeometryutils.cpp | 12 +- src/core/geometry/qgsgeometryutils.h | 2 +- src/core/geometry/qgslinestring.h | 2 + src/core/geometry/qgsmulticurve.h | 2 + src/core/geometry/qgsmultilinestring.h | 2 + src/core/geometry/qgsmultipoint.h | 2 + src/core/geometry/qgsmultipolygon.h | 2 + src/core/geometry/qgsmultisurface.h | 2 + src/core/geometry/qgspoint.cpp | 10 +- src/core/geometry/qgspoint.h | 2 + src/core/geometry/qgstriangle.cpp | 2 +- src/core/layertree/qgslayertreelayer.cpp | 8 +- src/core/layertree/qgslayertreemodel.cpp | 2 +- src/core/layertree/qgslayertreeutils.cpp | 4 +- src/core/layout/qgslayout.cpp | 2 +- src/core/layout/qgslayoutguidecollection.cpp | 2 +- src/core/layout/qgslayoutitem.cpp | 6 +- src/core/layout/qgslayoutitempage.cpp | 2 +- src/core/locator/qgslocatormodel.cpp | 2 +- src/core/metadata/qgslayermetadata.cpp | 10 +- .../metadata/qgslayermetadataformatter.cpp | 66 +-- .../models/qgsprocessingmodelalgorithm.cpp | 12 +- .../qgsprocessingmodelchildalgorithm.cpp | 4 +- .../processing/qgsprocessingalgorithm.cpp | 4 +- src/core/processing/qgsprocessingalgorithm.h | 2 + .../processing/qgsprocessingparameters.cpp | 14 +- src/core/processing/qgsprocessingparameters.h | 2 + src/core/processing/qgsprocessingprovider.cpp | 2 +- src/core/processing/qgsprocessingutils.cpp | 10 +- src/core/qgsaction.cpp | 8 +- src/core/qgsactionmanager.cpp | 4 +- src/core/qgsapplication.h | 2 + src/core/qgscolorramp.h | 1 + src/core/qgscoordinatereferencesystem.cpp | 2 +- src/core/qgsdatadefinedsizelegend.cpp | 62 +-- src/core/qgsdiagramrenderer.cpp | 6 +- src/core/qgseditformconfig.cpp | 2 +- src/core/qgsfontutils.h | 2 + src/core/qgsmaplayermodel.cpp | 2 +- src/core/qgsmaprenderertask.h | 2 + src/core/qgsproject.cpp | 4 +- src/core/qgsprojectfiletransform.cpp | 16 +- src/core/qgsprojectversion.h | 2 + src/core/qgsproperty.cpp | 30 +- src/core/qgspropertytransformer.cpp | 12 +- src/core/qgsproviderregistry.cpp | 2 +- src/core/qgsrenderchecker.h | 2 +- src/core/qgssettings.cpp | 16 +- src/core/qgsstacktrace.cpp | 8 +- src/core/qgsuserprofile.cpp | 10 +- src/core/qgsuserprofilemanager.cpp | 12 +- src/core/qgsuserprofilemanager.h | 2 + src/core/qgsvectorfilewriter.cpp | 18 +- src/core/qgsvectorfilewriter.h | 1 + src/core/qgsvectorlayer.cpp | 118 ++--- src/core/qgsvectorlayer.h | 2 + src/core/qgsvectorlayerexporter.cpp | 4 +- src/core/qgsvectorlayerlabeling.cpp | 26 +- src/core/qgsvectorlayerutils.cpp | 2 +- src/core/qgsvirtuallayerdefinition.h | 2 + src/core/raster/qgspalettedrasterrenderer.cpp | 4 +- src/core/raster/qgsrasterchecker.h | 4 +- src/core/raster/qgsrasterdataprovider.h | 3 + src/core/raster/qgsrasterlayer.cpp | 50 +-- src/core/raster/qgsrasterlayer.h | 2 + src/core/raster/qgsrasterrenderer.h | 2 +- src/core/raster/qgsrastershader.cpp | 4 +- src/core/symbology/qgscolorbrewerpalette.h | 2 + src/core/symbology/qgscptcityarchive.h | 2 + src/core/symbology/qgsellipsesymbollayer.cpp | 2 +- src/core/symbology/qgsellipsesymbollayer.h | 2 + src/core/symbology/qgsheatmaprenderer.cpp | 2 +- src/core/symbology/qgsmarkersymbollayer.h | 1 + .../qgspointdisplacementrenderer.cpp | 4 +- src/core/symbology/qgsrenderer.cpp | 4 +- src/core/symbology/qgsrulebasedrenderer.cpp | 8 +- .../symbology/qgssinglesymbolrenderer.cpp | 8 +- src/core/symbology/qgsstyle.cpp | 20 +- src/core/symbology/qgssymbollayer.cpp | 4 +- src/core/symbology/qgssymbollayerutils.cpp | 8 +- src/gui/auth/qgsauthguiutils.h | 2 + .../core/qgseditorwidgetwrapper.cpp | 8 +- src/gui/editorwidgets/qgsdatetimeedit.h | 2 +- .../qgsexternalresourcewidgetwrapper.cpp | 4 +- src/gui/layertree/qgslayertreeview.cpp | 2 +- src/gui/layout/qgslayoutruler.cpp | 2 +- src/gui/layout/qgslayoutview.cpp | 2 +- src/gui/locator/qgslocatorwidget.cpp | 4 +- src/gui/qgsbusyindicatordialog.h | 4 +- src/gui/qgscheckablecombobox.cpp | 2 +- src/gui/qgscodeeditor.h | 4 +- src/gui/qgscolorbutton.h | 2 +- src/gui/qgscolorrampbutton.cpp | 2 +- src/gui/qgsexpressionbuilderdialog.h | 2 + src/gui/qgsexpressionbuilderwidget.h | 6 +- src/gui/qgsfieldvalidator.h | 2 + src/gui/qgsfiledownloader.cpp | 4 +- src/gui/qgsfilewidget.cpp | 6 +- src/gui/qgshelp.cpp | 10 +- src/gui/qgsmanageconnectionsdialog.h | 4 +- src/gui/qgsmapcanvas.h | 2 +- src/gui/qgsmessagebar.cpp | 2 +- src/gui/qgsmessagelogviewer.cpp | 8 +- src/gui/qgsmetadatawidget.cpp | 10 +- src/gui/qgsnewgeopackagelayerdialog.cpp | 2 +- src/gui/qgsnewhttpconnection.h | 2 + src/gui/qgsoptionsdialogbase.cpp | 10 +- src/gui/qgspasswordlineedit.cpp | 8 +- src/gui/qgsprojectionselectiontreewidget.cpp | 2 +- src/gui/qgspropertyoverridebutton.cpp | 8 +- src/gui/qgsrasterformatsaveoptionswidget.h | 2 + src/gui/qgsrasterpyramidsoptionswidget.h | 2 + src/gui/qgsratiolockbutton.cpp | 2 +- src/gui/qgsshortcutsmanager.cpp | 2 +- src/gui/qgsshortcutsmanager.h | 2 + src/gui/qgstaskmanagerwidget.cpp | 12 +- .../qgsrendererrasterpropertieswidget.cpp | 4 +- ...qgssinglebandpseudocolorrendererwidget.cpp | 2 +- .../qgsdatadefinedsizelegendwidget.cpp | 4 +- .../symbology/qgsstyleexportimportdialog.cpp | 4 +- src/gui/symbology/qgsstylemanagerdialog.cpp | 4 +- src/gui/symbology/qgssymbolslistwidget.cpp | 4 +- .../checks/qgsgeometryselfcontactcheck.h | 2 +- src/providers/gdal/qgsgdaldataitems.cpp | 4 +- src/providers/gdal/qgsgdalprovider.cpp | 6 +- .../geonode/qgsgeonodenewconnection.cpp | 2 +- .../geonode/qgsgeonodesourceselect.cpp | 6 +- src/providers/grass/qgsgrass.h | 2 + src/providers/mssql/qgsmssqlprovider.cpp | 8 +- src/providers/ogr/qgsogrdataitems.cpp | 6 +- src/providers/ogr/qgsogrprovider.cpp | 28 +- src/providers/ogr/qgsogrprovider.h | 4 +- src/providers/postgres/qgspostgresconn.cpp | 6 +- src/providers/postgres/qgspostgresconn.h | 1 + .../qgspostgresexpressioncompiler.cpp | 12 +- .../postgres/qgspostgresprovider.cpp | 18 +- src/providers/postgres/qgspostgresprovider.h | 4 +- .../spatialite/qgsspatialiteprovider.cpp | 6 +- .../spatialite/qgsspatialiteprovider.h | 4 +- .../virtual/qgsvirtuallayerprovider.h | 8 +- src/providers/wfs/qgswfscapabilities.cpp | 4 +- src/providers/wfs/qgswfsdataitems.cpp | 10 +- src/providers/wfs/qgswfsfeatureiterator.cpp | 14 +- src/providers/wfs/qgswfsprovider.cpp | 16 +- src/providers/wfs/qgswfsshareddata.cpp | 4 +- src/providers/wms/qgswmsdataitems.cpp | 4 +- src/python/qgspythonutilsimpl.cpp | 10 +- tests/src/app/testqgsattributetable.cpp | 2 +- tests/src/app/testqgsnodetool.cpp | 10 +- tests/src/core/testqgscomposergroup.cpp | 2 +- tests/src/core/testqgscomposermap.cpp | 2 +- tests/src/core/testqgscomposerscalebar.cpp | 8 +- tests/src/core/testqgscomposition.cpp | 78 ++-- .../core/testqgscoordinatereferencesystem.cpp | 4 +- tests/src/core/testqgscurve.cpp | 4 +- .../src/core/testqgsdatadefinedsizelegend.cpp | 36 +- tests/src/core/testqgsdiagram.cpp | 50 +-- tests/src/core/testqgsexpression.cpp | 10 +- tests/src/core/testqgsexpressioncontext.cpp | 8 +- tests/src/core/testqgsfield.cpp | 2 +- tests/src/core/testqgsfields.cpp | 2 +- tests/src/core/testqgsgeometry.cpp | 76 ++-- tests/src/core/testqgsgeometryimport.cpp | 24 +- tests/src/core/testqgsgeonodeconnection.cpp | 2 +- tests/src/core/testqgslabelingengine.cpp | 14 +- tests/src/core/testqgslayertree.cpp | 14 +- tests/src/core/testqgslayout.cpp | 14 +- tests/src/core/testqgslayoutcontext.cpp | 4 +- tests/src/core/testqgslayoutitem.cpp | 28 +- tests/src/core/testqgslayoutobject.cpp | 16 +- tests/src/core/testqgslayoutpage.cpp | 2 +- tests/src/core/testqgslayoutunits.cpp | 6 +- tests/src/core/testqgslayoututils.cpp | 6 +- tests/src/core/testqgslegendrenderer.cpp | 20 +- tests/src/core/testqgsmaplayer.cpp | 8 +- tests/src/core/testqgsmapsettings.cpp | 20 +- tests/src/core/testqgspagesizeregistry.cpp | 20 +- tests/src/core/testqgspointlocator.cpp | 4 +- .../core/testqgspointpatternfillsymbol.cpp | 2 +- tests/src/core/testqgsproject.cpp | 36 +- tests/src/core/testqgsproperty.cpp | 96 ++-- tests/src/core/testqgsrasterblock.cpp | 6 +- tests/src/core/testqgsrasterfilewriter.cpp | 12 +- tests/src/core/testqgsstyle.cpp | 8 +- tests/src/core/testqgstaskmanager.cpp | 24 +- tests/src/core/testqgsvectorlayer.cpp | 2 +- tests/src/gui/testqgsattributeform.cpp | 80 ++-- tests/src/gui/testqgsdualview.cpp | 4 +- tests/src/gui/testqgseditorwidgetregistry.cpp | 2 +- tests/src/gui/testqgsfiledownloader.cpp | 14 +- tests/src/gui/testqgslayoutview.cpp | 2 +- tests/src/gui/testqgsmaptooledit.cpp | 2 +- .../gui/testqgsrelationreferencewidget.cpp | 24 +- .../gui/testqgsvaluerelationwidgetwrapper.cpp | 2 +- 254 files changed, 1433 insertions(+), 1314 deletions(-) diff --git a/src/analysis/network/qgsgraphbuilder.h b/src/analysis/network/qgsgraphbuilder.h index d9d355d5f938..054e06132768 100644 --- a/src/analysis/network/qgsgraphbuilder.h +++ b/src/analysis/network/qgsgraphbuilder.h @@ -60,4 +60,6 @@ class ANALYSIS_EXPORT QgsGraphBuilder : public QgsGraphBuilderInterface QgsGraph *mGraph = nullptr; }; +// clazy:excludeall=qstring-allocations + #endif // QGSGRAPHBUILDER_H diff --git a/src/analysis/network/qgsgraphbuilderinterface.h b/src/analysis/network/qgsgraphbuilderinterface.h index cba6f0617191..1308ce2b5afa 100644 --- a/src/analysis/network/qgsgraphbuilderinterface.h +++ b/src/analysis/network/qgsgraphbuilderinterface.h @@ -134,4 +134,6 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface }; +// clazy:excludeall=qstring-allocations + #endif // QGSGRAPHBUILDERINTERFACE_H diff --git a/src/analysis/openstreetmap/qgsosmdownload.cpp b/src/analysis/openstreetmap/qgsosmdownload.cpp index b20b70851db4..8364edd1460c 100644 --- a/src/analysis/openstreetmap/qgsosmdownload.cpp +++ b/src/analysis/openstreetmap/qgsosmdownload.cpp @@ -26,7 +26,7 @@ QString QgsOSMDownload::defaultServiceUrl() { QgsSettings settings; - return settings.value( "overpass_url", "http://overpass-api.de/api/interpreter" ).toString(); + return settings.value( QStringLiteral( "overpass_url" ), "http://overpass-api.de/api/interpreter" ).toString(); } diff --git a/src/analysis/vector/qgszonalstatistics.h b/src/analysis/vector/qgszonalstatistics.h index 90133a37c624..499dfb874656 100644 --- a/src/analysis/vector/qgszonalstatistics.h +++ b/src/analysis/vector/qgszonalstatistics.h @@ -64,7 +64,7 @@ class ANALYSIS_EXPORT QgsZonalStatistics */ QgsZonalStatistics( QgsVectorLayer *polygonLayer, QgsRasterLayer *rasterLayer, - const QString &attributePrefix = "", + const QString &attributePrefix = QString(), int rasterBand = 1, QgsZonalStatistics::Statistics stats = QgsZonalStatistics::Statistics( QgsZonalStatistics::Count | QgsZonalStatistics::Sum | QgsZonalStatistics::Mean ) ); @@ -147,4 +147,6 @@ class ANALYSIS_EXPORT QgsZonalStatistics Q_DECLARE_OPERATORS_FOR_FLAGS( QgsZonalStatistics::Statistics ) +// clazy:excludeall=qstring-allocations + #endif // QGSZONALSTATISTICS_H diff --git a/src/app/composer/qgscomposer.cpp b/src/app/composer/qgscomposer.cpp index 4853f0a533de..665d379fd6e6 100644 --- a/src/app/composer/qgscomposer.cpp +++ b/src/app/composer/qgscomposer.cpp @@ -2315,7 +2315,7 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode ) bool QgsComposer::saveImage( const QImage &img, const QString &imageFilename, const QString &imageFormat ) { QImageWriter w( imageFilename, imageFormat.toLocal8Bit().constData() ); - if ( imageFormat.compare( "tiff", Qt::CaseInsensitive ) == 0 || imageFormat.compare( "tif", Qt::CaseInsensitive ) == 0 ) + if ( imageFormat.compare( QLatin1String( "tiff" ), Qt::CaseInsensitive ) == 0 || imageFormat.compare( QLatin1String( "tif" ), Qt::CaseInsensitive ) == 0 ) { w.setCompression( 1 ); //use LZW compression } diff --git a/src/app/dwg/libdxfrw/drw_entities.cpp b/src/app/dwg/libdxfrw/drw_entities.cpp index 501509c5d08e..e4400ab85eae 100644 --- a/src/app/dwg/libdxfrw/drw_entities.cpp +++ b/src/app/dwg/libdxfrw/drw_entities.cpp @@ -299,7 +299,7 @@ bool DRW_Entity::parseDwg( DRW::Version version, dwgBuffer *buf, dwgBuffer *strB for ( int i = 0; i < strLength + 1; i++ ) //string length + null terminating char { duint8 dxfChar = tmpExtDataBuf.getRawChar8(); - l << QString( "0x%1" ).arg( dxfChar, 0, 16 ); + l << QStringLiteral( "0x%1" ).arg( dxfChar, 0, 16 ); } QgsDebugMsg( QString( "strLength:%1; str codepage:%2; %3" ).arg( strLength ).arg( cp ).arg( l.join( " " ) ) ); diff --git a/src/app/dwg/libdxfrw/drw_header.cpp b/src/app/dwg/libdxfrw/drw_header.cpp index 4391ed65a18b..a98479572dbd 100644 --- a/src/app/dwg/libdxfrw/drw_header.cpp +++ b/src/app/dwg/libdxfrw/drw_header.cpp @@ -2708,7 +2708,7 @@ bool DRW_Header::parseDwg( DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbu for ( int i = 0; i < 16; i++ ) { t = buf->getRawChar8(); - l << QString( "0x%1" ).arg( t, 0, 16 ); + l << QStringLiteral( "0x%1" ).arg( t, 0, 16 ); } QgsDebugMsg( QString( "dwg header end sentinel=%1" ).arg( l.join( " " ) ) ); @@ -2753,7 +2753,7 @@ bool DRW_Header::parseDwg( DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbu for ( int i = 0; i < 16; i++ ) { t = buf->getRawChar8(); - l << QString( "0x%1" ).arg( t, 0, 16 ); + l << QStringLiteral( "0x%1" ).arg( t, 0, 16 ); } QgsDebugMsg( QString( "dwg header end sentinel=%1" ).arg( l.join( " " ) ) ); diff --git a/src/app/dwg/libdxfrw/drw_objects.cpp b/src/app/dwg/libdxfrw/drw_objects.cpp index 217706b30f69..e4c6c532516b 100644 --- a/src/app/dwg/libdxfrw/drw_objects.cpp +++ b/src/app/dwg/libdxfrw/drw_objects.cpp @@ -571,7 +571,7 @@ bool DRW_LType::parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs ) QStringList l; for ( unsigned i = 0; i < path.size() ; i++ ) { - l << QString( "%1" ).arg( path[i] ); + l << QStringLiteral( "%1" ).arg( path[i] ); } QgsDebugMsg( QString( "path=%1 rem:%2" ).arg( l.join( " " ) ).arg( buf->numRemainingBytes() ) ); diff --git a/src/app/dwg/libdxfrw/intern/drw_dbg.cpp b/src/app/dwg/libdxfrw/intern/drw_dbg.cpp index beff3171d075..e7de6d3e9d63 100644 --- a/src/app/dwg/libdxfrw/intern/drw_dbg.cpp +++ b/src/app/dwg/libdxfrw/intern/drw_dbg.cpp @@ -178,30 +178,30 @@ void print_debug::printUI( long long unsigned int i ) void print_debug::printD( double d ) { - mTS << QString( "%1 " ).arg( d, 0, 'g' ); + mTS << QStringLiteral( "%1 " ).arg( d, 0, 'g' ); flush(); } void print_debug::printH( long long i ) { - mTS << QString( "0x%1" ).arg( i, 0, 16 ); + mTS << QStringLiteral( "0x%1" ).arg( i, 0, 16 ); flush(); } void print_debug::printB( int i ) { - mTS << QString( "0%1" ).arg( i, 0, 8 ); + mTS << QStringLiteral( "0%1" ).arg( i, 0, 8 ); flush(); } void print_debug::printHL( int c, int s, int h ) { - mTS << QString( "%1.%2 0x%3" ).arg( c ).arg( s ).arg( h, 0, 16 ); + mTS << QStringLiteral( "%1.%2 0x%3" ).arg( c ).arg( s ).arg( h, 0, 16 ); flush(); } void print_debug::printPT( double x, double y, double z ) { - mTS << QString( "x:%1 y:%2 z:%3" ).arg( x, 0, 'g' ).arg( y, 0, 'g' ).arg( z, 0, 'g' ); + mTS << QStringLiteral( "x:%1 y:%2 z:%3" ).arg( x, 0, 'g' ).arg( y, 0, 'g' ).arg( z, 0, 'g' ); flush(); } diff --git a/src/app/dwg/libdxfrw/intern/dwgreader.cpp b/src/app/dwg/libdxfrw/intern/dwgreader.cpp index 8f5d2f09f655..01b1765b2db2 100644 --- a/src/app/dwg/libdxfrw/intern/dwgreader.cpp +++ b/src/app/dwg/libdxfrw/intern/dwgreader.cpp @@ -141,7 +141,7 @@ bool dwgReader::checkSentinel( dwgBuffer *buf, enum secEnum::DWGSection, bool st for ( int i = 0; i < 16; i++ ) { int t = buf->getRawChar8(); - l << QString( "0x%1" ).arg( t, 0, 16 ); + l << QStringLiteral( "0x%1" ).arg( t, 0, 16 ); } QgsDebugMsg( l.join( " " ) ); return true; diff --git a/src/app/dwg/qgsdwgimportdialog.cpp b/src/app/dwg/qgsdwgimportdialog.cpp index 5ef0f4091021..26c96f0a5ee1 100644 --- a/src/app/dwg/qgsdwgimportdialog.cpp +++ b/src/app/dwg/qgsdwgimportdialog.cpp @@ -67,16 +67,16 @@ QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f ) connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDwgImportDialog::showHelp ); QgsSettings s; - leDatabase->setText( s.value( "/DwgImport/lastDatabase", "" ).toString() ); - cbExpandInserts->setChecked( s.value( "/DwgImport/lastExpandInserts", true ).toBool() ); - cbMergeLayers->setChecked( s.value( "/DwgImport/lastMergeLayers", false ).toBool() ); - cbUseCurves->setChecked( s.value( "/DwgImport/lastUseCurves", true ).toBool() ); + leDatabase->setText( s.value( QStringLiteral( "/DwgImport/lastDatabase" ), "" ).toString() ); + cbExpandInserts->setChecked( s.value( QStringLiteral( "/DwgImport/lastExpandInserts" ), true ).toBool() ); + cbMergeLayers->setChecked( s.value( QStringLiteral( "/DwgImport/lastMergeLayers" ), false ).toBool() ); + cbUseCurves->setChecked( s.value( QStringLiteral( "/DwgImport/lastUseCurves" ), true ).toBool() ); leDrawing->setReadOnly( true ); pbImportDrawing->setHidden( true ); lblMessage->setHidden( true ); - int crsid = s.value( "/DwgImport/lastCrs", QString::number( QgsProject::instance()->crs().srsid() ) ).toInt(); + int crsid = s.value( QStringLiteral( "/DwgImport/lastCrs" ), QString::number( QgsProject::instance()->crs().srsid() ) ).toInt(); QgsCoordinateReferenceSystem crs( crsid, QgsCoordinateReferenceSystem::InternalCrsId ); mCrsSelector->setCrs( crs ); @@ -87,17 +87,17 @@ QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f ) on_pbLoadDatabase_clicked(); updateUI(); - restoreGeometry( s.value( "/Windows/DwgImport/geometry" ).toByteArray() ); + restoreGeometry( s.value( QStringLiteral( "/Windows/DwgImport/geometry" ) ).toByteArray() ); } QgsDwgImportDialog::~QgsDwgImportDialog() { QgsSettings s; - s.setValue( "/DwgImport/lastDatabase", leDatabase->text() ); - s.setValue( "/DwgImport/lastExpandInserts", cbExpandInserts->isChecked() ); - s.setValue( "/DwgImport/lastMergeLayers", cbMergeLayers->isChecked() ); - s.setValue( "/DwgImport/lastUseCurves", cbUseCurves->isChecked() ); - s.setValue( "/Windows/DwgImport/geometry", saveGeometry() ); + s.setValue( QStringLiteral( "/DwgImport/lastDatabase" ), leDatabase->text() ); + s.setValue( QStringLiteral( "/DwgImport/lastExpandInserts" ), cbExpandInserts->isChecked() ); + s.setValue( QStringLiteral( "/DwgImport/lastMergeLayers" ), cbMergeLayers->isChecked() ); + s.setValue( QStringLiteral( "/DwgImport/lastUseCurves" ), cbUseCurves->isChecked() ); + s.setValue( QStringLiteral( "/Windows/DwgImport/geometry" ), saveGeometry() ); } void QgsDwgImportDialog::updateUI() @@ -158,12 +158,12 @@ void QgsDwgImportDialog::on_pbLoadDatabase_clicked() bool lblVisible = false; - std::unique_ptr d( new QgsVectorLayer( QString( "%1|layername=drawing" ).arg( leDatabase->text() ), "layers", "ogr", false ) ); + std::unique_ptr d( new QgsVectorLayer( QStringLiteral( "%1|layername=drawing" ).arg( leDatabase->text() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), false ) ); if ( d && d->isValid() ) { - int idxPath = d->fields().lookupField( "path" ); - int idxLastModified = d->fields().lookupField( "lastmodified" ); - int idxCrs = d->fields().lookupField( "crs" ); + int idxPath = d->fields().lookupField( QStringLiteral( "path" ) ); + int idxLastModified = d->fields().lookupField( QStringLiteral( "lastmodified" ) ); + int idxCrs = d->fields().lookupField( QStringLiteral( "crs" ) ); QgsFeature f; if ( d->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() << idxPath << idxLastModified << idxCrs ) ).nextFeature( f ) ) @@ -193,12 +193,12 @@ void QgsDwgImportDialog::on_pbLoadDatabase_clicked() lblMessage->setVisible( lblVisible ); - std::unique_ptr l( new QgsVectorLayer( QString( "%1|layername=layers" ).arg( leDatabase->text() ), "layers", "ogr", false ) ); + std::unique_ptr l( new QgsVectorLayer( QStringLiteral( "%1|layername=layers" ).arg( leDatabase->text() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), false ) ); if ( l && l->isValid() ) { - int idxName = l->fields().lookupField( "name" ); - int idxColor = l->fields().lookupField( "ocolor" ); - int idxFlags = l->fields().lookupField( "flags" ); + int idxName = l->fields().lookupField( QStringLiteral( "name" ) ); + int idxColor = l->fields().lookupField( QStringLiteral( "ocolor" ) ); + int idxFlags = l->fields().lookupField( QStringLiteral( "flags" ) ); QgsDebugMsg( QString( "idxName:%1 idxColor:%2 idxFlags:%3" ).arg( idxName ).arg( idxColor ).arg( idxFlags ) ); @@ -269,8 +269,8 @@ void QgsDwgImportDialog::on_pbImportDrawing_clicked() QgsVectorLayer *QgsDwgImportDialog::layer( QgsLayerTreeGroup *layerGroup, const QString &layerFilter, const QString &table ) { - QgsVectorLayer *l = new QgsVectorLayer( QString( "%1|layername=%2" ).arg( leDatabase->text(), table ), table, "ogr", false ); - l->setSubsetString( QString( "%1space=0 AND block=-1" ).arg( layerFilter ) ); + QgsVectorLayer *l = new QgsVectorLayer( QStringLiteral( "%1|layername=%2" ).arg( leDatabase->text(), table ), table, QStringLiteral( "ogr" ), false ); + l->setSubsetString( QStringLiteral( "%1space=0 AND block=-1" ).arg( layerFilter ) ); if ( l->featureCount() == 0 ) { @@ -295,32 +295,32 @@ void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, const QString &n QStringList exprlist; Q_FOREACH ( QString layer, layers ) { - exprlist.append( QString( "'%1'" ).arg( layer.replace( "'", "''" ) ) ); + exprlist.append( QStringLiteral( "'%1'" ).arg( layer.replace( QLatin1String( "'" ), QLatin1String( "''" ) ) ) ); } - layerFilter = QString( "layer IN (%1) AND " ).arg( exprlist.join( "," ) ); + layerFilter = QStringLiteral( "layer IN (%1) AND " ).arg( exprlist.join( QStringLiteral( "," ) ) ); } QgsVectorLayer *l = nullptr; QgsSymbol *sym = nullptr; - l = layer( layerGroup, layerFilter, "hatches" ); + l = layer( layerGroup, layerFilter, QStringLiteral( "hatches" ) ); if ( l ) { QgsSimpleFillSymbolLayer *sfl = new QgsSimpleFillSymbolLayer(); - sfl->setDataDefinedProperty( QgsSymbolLayer::PropertyFillColor, QgsProperty::fromField( "color" ) ); + sfl->setDataDefinedProperty( QgsSymbolLayer::PropertyFillColor, QgsProperty::fromField( QStringLiteral( "color" ) ) ); sfl->setStrokeStyle( Qt::NoPen ); sym = new QgsFillSymbol(); sym->changeSymbolLayer( 0, sfl ); l->setRenderer( new QgsSingleSymbolRenderer( sym ) ); } - l = layer( layerGroup, layerFilter, "lines" ); + l = layer( layerGroup, layerFilter, QStringLiteral( "lines" ) ); if ( l ) { QgsSimpleLineSymbolLayer *sll = new QgsSimpleLineSymbolLayer(); - sll->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeColor, QgsProperty::fromField( "color" ) ); + sll->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeColor, QgsProperty::fromField( QStringLiteral( "color" ) ) ); sll->setPenJoinStyle( Qt::MiterJoin ); - sll->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeWidth, QgsProperty::fromField( "linewidth" ) ); + sll->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeWidth, QgsProperty::fromField( QStringLiteral( "linewidth" ) ) ); // sll->setUseCustomDashPattern( true ); // sll->setCustomDashPatternUnit( QgsSymbolV2::MapUnit ); // sll->setDataDefinedProperty( QgsSymbolLayer::PropertyCustomDash, QgsProperty::fromField( "linetype" ) ); @@ -330,13 +330,13 @@ void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, const QString &n l->setRenderer( new QgsSingleSymbolRenderer( sym ) ); } - l = layer( layerGroup, layerFilter, "polylines" ); + l = layer( layerGroup, layerFilter, QStringLiteral( "polylines" ) ); if ( l ) { QgsSimpleLineSymbolLayer *sll = new QgsSimpleLineSymbolLayer(); - sll->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeColor, QgsProperty::fromField( "color" ) ); + sll->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeColor, QgsProperty::fromField( QStringLiteral( "color" ) ) ); sll->setPenJoinStyle( Qt::MiterJoin ); - sll->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeWidth, QgsProperty::fromField( "width" ) ); + sll->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeWidth, QgsProperty::fromField( QStringLiteral( "width" ) ) ); // sll->setUseCustomDashPattern( true ); // sll->setCustomDashPatternUnit( QgsSymbolV2::MapUnit ); // sll->setDataDefinedProperty( QgsSymbolLayer::PropertyCustomDash, QgsProperty::fromField( "linetype" ) ); @@ -346,7 +346,7 @@ void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, const QString &n l->setRenderer( new QgsSingleSymbolRenderer( sym ) ); } - l = layer( layerGroup, layerFilter, "texts" ); + l = layer( layerGroup, layerFilter, QStringLiteral( "texts" ) ); if ( l ) { l->setRenderer( new QgsNullSymbolRenderer() ); @@ -358,8 +358,8 @@ void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, const QString &n pls.setFormat( tf ); pls.drawLabels = true; - pls.fieldName = "text"; - pls.wrapChar = "\\P"; + pls.fieldName = QStringLiteral( "text" ); + pls.wrapChar = QStringLiteral( "\\P" ); pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::Size, QgsProperty::fromField( QStringLiteral( "height" ) ) ); pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::Color, QgsProperty::fromField( QStringLiteral( "color" ) ) ); @@ -403,7 +403,7 @@ void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, const QString &n l->setLabeling( new QgsVectorLayerSimpleLabeling( pls ) ); } - l = layer( layerGroup, layerFilter, "points" ); + l = layer( layerGroup, layerFilter, QStringLiteral( "points" ) ); if ( l ) { // FIXME: use PDMODE? @@ -411,7 +411,7 @@ void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, const QString &n } if ( !cbExpandInserts->isChecked() ) - layer( layerGroup, layerFilter, "inserts" ); + layer( layerGroup, layerFilter, QStringLiteral( "inserts" ) ); if ( !layerGroup->children().isEmpty() ) { diff --git a/src/app/dwg/qgsdwgimporter.cpp b/src/app/dwg/qgsdwgimporter.cpp index fa4b29effd2d..21a848d5c5e2 100644 --- a/src/app/dwg/qgsdwgimporter.cpp +++ b/src/app/dwg/qgsdwgimporter.cpp @@ -300,186 +300,186 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa QList tables = QList
() - << table( "drawing", QObject::tr( "Imported drawings" ), wkbNone, QList() - << field( "path", OFTString ) - << field( "comments", OFTString ) - << field( "importdat", OFTDateTime ) - << field( "lastmodified", OFTDateTime ) - << field( "crs", OFTInteger ) + << table( QStringLiteral( "drawing" ), QObject::tr( "Imported drawings" ), wkbNone, QList() + << field( QStringLiteral( "path" ), OFTString ) + << field( QStringLiteral( "comments" ), OFTString ) + << field( QStringLiteral( "importdat" ), OFTDateTime ) + << field( QStringLiteral( "lastmodified" ), OFTDateTime ) + << field( QStringLiteral( "crs" ), OFTInteger ) ) - << table( "headers", QObject::tr( "Headers" ), wkbNone, QList() - << field( "k", OFTString ) - << field( "v", OFTString ) + << table( QStringLiteral( "headers" ), QObject::tr( "Headers" ), wkbNone, QList() + << field( QStringLiteral( "k" ), OFTString ) + << field( QStringLiteral( "v" ), OFTString ) ) - << table( "linetypes", QObject::tr( "Line types" ), wkbNone, QList() - << field( "name", OFTString ) - << field( "desc", OFTString ) - << field( "path", OFTRealList ) + << table( QStringLiteral( "linetypes" ), QObject::tr( "Line types" ), wkbNone, QList() + << field( QStringLiteral( "name" ), OFTString ) + << field( QStringLiteral( "desc" ), OFTString ) + << field( QStringLiteral( "path" ), OFTRealList ) ) - << table( "layers", QObject::tr( "Layer list" ), wkbNone, QList() - << field( "name", OFTString ) - << field( "linetype", OFTString ) - << field( "color", OFTString ) - << field( "ocolor", OFTInteger ) - << field( "color24", OFTInteger ) - << field( "transparency", OFTInteger ) - << field( "lweight", OFTInteger ) - << field( "linewidth", OFTReal ) - << field( "flags", OFTInteger ) + << table( QStringLiteral( "layers" ), QObject::tr( "Layer list" ), wkbNone, QList() + << field( QStringLiteral( "name" ), OFTString ) + << field( QStringLiteral( "linetype" ), OFTString ) + << field( QStringLiteral( "color" ), OFTString ) + << field( QStringLiteral( "ocolor" ), OFTInteger ) + << field( QStringLiteral( "color24" ), OFTInteger ) + << field( QStringLiteral( "transparency" ), OFTInteger ) + << field( QStringLiteral( "lweight" ), OFTInteger ) + << field( QStringLiteral( "linewidth" ), OFTReal ) + << field( QStringLiteral( "flags" ), OFTInteger ) ) - << table( "dimstyles", QObject::tr( "Dimension styles" ), wkbNone, QList() - << field( "name", OFTString ) - << field( "dimpost", OFTString ) - << field( "dimapost", OFTString ) - << field( "dimblk", OFTString ) - << field( "dimblk1", OFTString ) - << field( "dimblk2", OFTString ) - << field( "dimscale", OFTReal ) - << field( "dimasz", OFTReal ) - << field( "dimexo", OFTReal ) - << field( "dimdli", OFTReal ) - << field( "dimexe", OFTReal ) - << field( "dimrnd", OFTReal ) - << field( "dimdle", OFTReal ) - << field( "dimtp", OFTReal ) - << field( "dimtm", OFTReal ) - << field( "dimfxl", OFTReal ) - << field( "dimtxt", OFTReal ) - << field( "dimcen", OFTReal ) - << field( "dimtsz", OFTReal ) - << field( "dimaltf", OFTReal ) - << field( "dimlfac", OFTReal ) - << field( "dimtvp", OFTReal ) - << field( "dimtfac", OFTReal ) - << field( "dimgap", OFTReal ) - << field( "dimaltrnd", OFTReal ) - << field( "dimtol", OFTInteger ) - << field( "dimlim", OFTInteger ) - << field( "dimtih", OFTInteger ) - << field( "dimtoh", OFTInteger ) - << field( "dimse1", OFTInteger ) - << field( "dimse2", OFTInteger ) - << field( "dimtad", OFTInteger ) - << field( "dimzin", OFTInteger ) - << field( "dimazin", OFTInteger ) - << field( "dimalt", OFTInteger ) - << field( "dimaltd", OFTInteger ) - << field( "dimtofl", OFTInteger ) - << field( "dimsah", OFTInteger ) - << field( "dimtix", OFTInteger ) - << field( "dimsoxd", OFTInteger ) - << field( "dimclrd", OFTInteger ) - << field( "dimclre", OFTInteger ) - << field( "dimclrt", OFTInteger ) - << field( "dimadec", OFTInteger ) - << field( "dimunit", OFTInteger ) - << field( "dimdec", OFTInteger ) - << field( "dimtdec", OFTInteger ) - << field( "dimaltu", OFTInteger ) - << field( "dimalttd", OFTInteger ) - << field( "dimaunit", OFTInteger ) - << field( "dimfrac", OFTInteger ) - << field( "dimlunit", OFTInteger ) - << field( "dimdsep", OFTInteger ) - << field( "dimtmove", OFTInteger ) - << field( "dimjust", OFTInteger ) - << field( "dimsd1", OFTInteger ) - << field( "dimsd2", OFTInteger ) - << field( "dimtolj", OFTInteger ) - << field( "dimtzin", OFTInteger ) - << field( "dimaltz", OFTInteger ) - << field( "dimaltttz", OFTInteger ) - << field( "dimfit", OFTInteger ) - << field( "dimupt", OFTInteger ) - << field( "dimatfit", OFTInteger ) - << field( "dimfxlon", OFTInteger ) - << field( "dimtxsty", OFTString ) - << field( "dimldrblk", OFTString ) - << field( "dimlwd", OFTInteger ) - << field( "dimlwe", OFTInteger ) + << table( QStringLiteral( "dimstyles" ), QObject::tr( "Dimension styles" ), wkbNone, QList() + << field( QStringLiteral( "name" ), OFTString ) + << field( QStringLiteral( "dimpost" ), OFTString ) + << field( QStringLiteral( "dimapost" ), OFTString ) + << field( QStringLiteral( "dimblk" ), OFTString ) + << field( QStringLiteral( "dimblk1" ), OFTString ) + << field( QStringLiteral( "dimblk2" ), OFTString ) + << field( QStringLiteral( "dimscale" ), OFTReal ) + << field( QStringLiteral( "dimasz" ), OFTReal ) + << field( QStringLiteral( "dimexo" ), OFTReal ) + << field( QStringLiteral( "dimdli" ), OFTReal ) + << field( QStringLiteral( "dimexe" ), OFTReal ) + << field( QStringLiteral( "dimrnd" ), OFTReal ) + << field( QStringLiteral( "dimdle" ), OFTReal ) + << field( QStringLiteral( "dimtp" ), OFTReal ) + << field( QStringLiteral( "dimtm" ), OFTReal ) + << field( QStringLiteral( "dimfxl" ), OFTReal ) + << field( QStringLiteral( "dimtxt" ), OFTReal ) + << field( QStringLiteral( "dimcen" ), OFTReal ) + << field( QStringLiteral( "dimtsz" ), OFTReal ) + << field( QStringLiteral( "dimaltf" ), OFTReal ) + << field( QStringLiteral( "dimlfac" ), OFTReal ) + << field( QStringLiteral( "dimtvp" ), OFTReal ) + << field( QStringLiteral( "dimtfac" ), OFTReal ) + << field( QStringLiteral( "dimgap" ), OFTReal ) + << field( QStringLiteral( "dimaltrnd" ), OFTReal ) + << field( QStringLiteral( "dimtol" ), OFTInteger ) + << field( QStringLiteral( "dimlim" ), OFTInteger ) + << field( QStringLiteral( "dimtih" ), OFTInteger ) + << field( QStringLiteral( "dimtoh" ), OFTInteger ) + << field( QStringLiteral( "dimse1" ), OFTInteger ) + << field( QStringLiteral( "dimse2" ), OFTInteger ) + << field( QStringLiteral( "dimtad" ), OFTInteger ) + << field( QStringLiteral( "dimzin" ), OFTInteger ) + << field( QStringLiteral( "dimazin" ), OFTInteger ) + << field( QStringLiteral( "dimalt" ), OFTInteger ) + << field( QStringLiteral( "dimaltd" ), OFTInteger ) + << field( QStringLiteral( "dimtofl" ), OFTInteger ) + << field( QStringLiteral( "dimsah" ), OFTInteger ) + << field( QStringLiteral( "dimtix" ), OFTInteger ) + << field( QStringLiteral( "dimsoxd" ), OFTInteger ) + << field( QStringLiteral( "dimclrd" ), OFTInteger ) + << field( QStringLiteral( "dimclre" ), OFTInteger ) + << field( QStringLiteral( "dimclrt" ), OFTInteger ) + << field( QStringLiteral( "dimadec" ), OFTInteger ) + << field( QStringLiteral( "dimunit" ), OFTInteger ) + << field( QStringLiteral( "dimdec" ), OFTInteger ) + << field( QStringLiteral( "dimtdec" ), OFTInteger ) + << field( QStringLiteral( "dimaltu" ), OFTInteger ) + << field( QStringLiteral( "dimalttd" ), OFTInteger ) + << field( QStringLiteral( "dimaunit" ), OFTInteger ) + << field( QStringLiteral( "dimfrac" ), OFTInteger ) + << field( QStringLiteral( "dimlunit" ), OFTInteger ) + << field( QStringLiteral( "dimdsep" ), OFTInteger ) + << field( QStringLiteral( "dimtmove" ), OFTInteger ) + << field( QStringLiteral( "dimjust" ), OFTInteger ) + << field( QStringLiteral( "dimsd1" ), OFTInteger ) + << field( QStringLiteral( "dimsd2" ), OFTInteger ) + << field( QStringLiteral( "dimtolj" ), OFTInteger ) + << field( QStringLiteral( "dimtzin" ), OFTInteger ) + << field( QStringLiteral( "dimaltz" ), OFTInteger ) + << field( QStringLiteral( "dimaltttz" ), OFTInteger ) + << field( QStringLiteral( "dimfit" ), OFTInteger ) + << field( QStringLiteral( "dimupt" ), OFTInteger ) + << field( QStringLiteral( "dimatfit" ), OFTInteger ) + << field( QStringLiteral( "dimfxlon" ), OFTInteger ) + << field( QStringLiteral( "dimtxsty" ), OFTString ) + << field( QStringLiteral( "dimldrblk" ), OFTString ) + << field( QStringLiteral( "dimlwd" ), OFTInteger ) + << field( QStringLiteral( "dimlwe" ), OFTInteger ) ) - << table( "textstyles", QObject::tr( "Text styles" ), wkbNone, QList() - << field( "name", OFTString ) - << field( "height", OFTReal ) - << field( "width", OFTReal ) - << field( "oblique", OFTReal ) - << field( "genFlag", OFTInteger ) - << field( "lastHeight", OFTReal ) - << field( "font", OFTString ) - << field( "bigFont", OFTString ) - << field( "fontFamily", OFTInteger ) + << table( QStringLiteral( "textstyles" ), QObject::tr( "Text styles" ), wkbNone, QList() + << field( QStringLiteral( "name" ), OFTString ) + << field( QStringLiteral( "height" ), OFTReal ) + << field( QStringLiteral( "width" ), OFTReal ) + << field( QStringLiteral( "oblique" ), OFTReal ) + << field( QStringLiteral( "genFlag" ), OFTInteger ) + << field( QStringLiteral( "lastHeight" ), OFTReal ) + << field( QStringLiteral( "font" ), OFTString ) + << field( QStringLiteral( "bigFont" ), OFTString ) + << field( QStringLiteral( "fontFamily" ), OFTInteger ) ) - << table( "appdata", QObject::tr( "Application data" ), wkbNone, QList() - << field( "handle", OFTInteger ) - << field( "i", OFTInteger ) - << field( "value", OFTString ) + << table( QStringLiteral( "appdata" ), QObject::tr( "Application data" ), wkbNone, QList() + << field( QStringLiteral( "handle" ), OFTInteger ) + << field( QStringLiteral( "i" ), OFTInteger ) + << field( QStringLiteral( "value" ), OFTString ) ) - << table( "blocks", QObject::tr( "BLOCK entities" ), wkbPoint25D, QList() + << table( QStringLiteral( "blocks" ), QObject::tr( "BLOCK entities" ), wkbPoint25D, QList() ENTITY_ATTRIBUTES - << field( "thickness", OFTReal ) - << field( "ext", OFTRealList ) - << field( "name", OFTString ) - << field( "flags", OFTInteger ) + << field( QStringLiteral( "thickness" ), OFTReal ) + << field( QStringLiteral( "ext" ), OFTRealList ) + << field( QStringLiteral( "name" ), OFTString ) + << field( QStringLiteral( "flags" ), OFTInteger ) ) - << table( "points", QObject::tr( "POINT entities" ), wkbPoint25D, QList() + << table( QStringLiteral( "points" ), QObject::tr( "POINT entities" ), wkbPoint25D, QList() ENTITY_ATTRIBUTES - << field( "thickness", OFTReal ) - << field( "ext", OFTRealList ) + << field( QStringLiteral( "thickness" ), OFTReal ) + << field( QStringLiteral( "ext" ), OFTRealList ) ) - << table( "lines", QObject::tr( "LINE entities" ), lineGeomType, QList() + << table( QStringLiteral( "lines" ), QObject::tr( "LINE entities" ), lineGeomType, QList() ENTITY_ATTRIBUTES - << field( "thickness", OFTReal ) - << field( "ext", OFTRealList ) - << field( "width", OFTReal ) + << field( QStringLiteral( "thickness" ), OFTReal ) + << field( QStringLiteral( "ext" ), OFTRealList ) + << field( QStringLiteral( "width" ), OFTReal ) ) - << table( "polylines", QObject::tr( "POLYLINE entities" ), lineGeomType, QList() + << table( QStringLiteral( "polylines" ), QObject::tr( "POLYLINE entities" ), lineGeomType, QList() ENTITY_ATTRIBUTES - << field( "width", OFTReal ) - << field( "thickness", OFTReal ) - << field( "ext", OFTRealList ) + << field( QStringLiteral( "width" ), OFTReal ) + << field( QStringLiteral( "thickness" ), OFTReal ) + << field( QStringLiteral( "ext" ), OFTRealList ) ) - << table( "texts", QObject::tr( "TEXT entities" ), wkbPoint25D, QList() + << table( QStringLiteral( "texts" ), QObject::tr( "TEXT entities" ), wkbPoint25D, QList() ENTITY_ATTRIBUTES - << field( "thickness", OFTReal ) - << field( "ext", OFTRealList ) - << field( "height", OFTReal ) - << field( "text", OFTString ) - << field( "angle", OFTReal ) - << field( "widthscale", OFTReal ) - << field( "oblique", OFTReal ) - << field( "style", OFTString ) - << field( "textgen", OFTInteger ) - << field( "alignh", OFTInteger ) - << field( "alignv", OFTInteger ) - << field( "interlin", OFTReal ) + << field( QStringLiteral( "thickness" ), OFTReal ) + << field( QStringLiteral( "ext" ), OFTRealList ) + << field( QStringLiteral( "height" ), OFTReal ) + << field( QStringLiteral( "text" ), OFTString ) + << field( QStringLiteral( "angle" ), OFTReal ) + << field( QStringLiteral( "widthscale" ), OFTReal ) + << field( QStringLiteral( "oblique" ), OFTReal ) + << field( QStringLiteral( "style" ), OFTString ) + << field( QStringLiteral( "textgen" ), OFTInteger ) + << field( QStringLiteral( "alignh" ), OFTInteger ) + << field( QStringLiteral( "alignv" ), OFTInteger ) + << field( QStringLiteral( "interlin" ), OFTReal ) ) - << table( "hatches", QObject::tr( "HATCH entities" ), hatchGeomType, QList() + << table( QStringLiteral( "hatches" ), QObject::tr( "HATCH entities" ), hatchGeomType, QList() ENTITY_ATTRIBUTES - << field( "thickness", OFTReal ) - << field( "ext", OFTRealList ) - << field( "name", OFTString ) - << field( "solid", OFTInteger ) - << field( "associative", OFTInteger ) - << field( "hstyle", OFTInteger ) - << field( "hpattern", OFTInteger ) - << field( "doubleflag", OFTInteger ) - << field( "angle", OFTReal ) - << field( "scale", OFTReal ) - << field( "deflines", OFTInteger ) + << field( QStringLiteral( "thickness" ), OFTReal ) + << field( QStringLiteral( "ext" ), OFTRealList ) + << field( QStringLiteral( "name" ), OFTString ) + << field( QStringLiteral( "solid" ), OFTInteger ) + << field( QStringLiteral( "associative" ), OFTInteger ) + << field( QStringLiteral( "hstyle" ), OFTInteger ) + << field( QStringLiteral( "hpattern" ), OFTInteger ) + << field( QStringLiteral( "doubleflag" ), OFTInteger ) + << field( QStringLiteral( "angle" ), OFTReal ) + << field( QStringLiteral( "scale" ), OFTReal ) + << field( QStringLiteral( "deflines" ), OFTInteger ) ) - << table( "inserts", QObject::tr( "INSERT entities" ), wkbPoint25D, QList() + << table( QStringLiteral( "inserts" ), QObject::tr( "INSERT entities" ), wkbPoint25D, QList() ENTITY_ATTRIBUTES - << field( "thickness", OFTReal ) - << field( "ext", OFTRealList ) - << field( "name", OFTString ) - << field( "xscale", OFTReal ) - << field( "yscale", OFTReal ) - << field( "zscale", OFTReal ) - << field( "angle", OFTReal ) - << field( "colcount", OFTReal ) - << field( "rowcount", OFTReal ) - << field( "colspace", OFTReal ) - << field( "rowspace", OFTReal ) + << field( QStringLiteral( "thickness" ), OFTReal ) + << field( QStringLiteral( "ext" ), OFTRealList ) + << field( QStringLiteral( "name" ), OFTString ) + << field( QStringLiteral( "xscale" ), OFTReal ) + << field( QStringLiteral( "yscale" ), OFTReal ) + << field( QStringLiteral( "zscale" ), OFTReal ) + << field( QStringLiteral( "angle" ), OFTReal ) + << field( QStringLiteral( "colcount" ), OFTReal ) + << field( QStringLiteral( "rowcount" ), OFTReal ) + << field( QStringLiteral( "colspace" ), OFTReal ) + << field( QStringLiteral( "rowspace" ), OFTReal ) ) ; @@ -605,7 +605,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa DRW::error result( DRW::BAD_NONE ); - if ( fi.suffix().toLower() == "dxf" ) + if ( fi.suffix().toLower() == QLatin1String( "dxf" ) ) { //loads dxf std::unique_ptr dxf( new dxfRW( drawing.toUtf8() ) ); @@ -614,7 +614,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa result = DRW::BAD_UNKNOWN; } } - else if ( fi.suffix().toLower() == "dwg" ) + else if ( fi.suffix().toLower() == QLatin1String( "dwg" ) ) { //loads dwg std::unique_ptr dwg( new dwgR( drawing.toUtf8() ) ); @@ -734,7 +734,7 @@ void QgsDwgImporter::addHeader( const DRW_Header *data ) case DRW_Variant::INTEGER: v = QString::number( it->second->content.i ); - if ( k == "SPLINESEGS" ) + if ( k == QLatin1String( "SPLINESEGS" ) ) mSplineSegs = it->second->content.i; break; @@ -744,7 +744,7 @@ void QgsDwgImporter::addHeader( const DRW_Header *data ) break; case DRW_Variant::COORD: - v = QString( "%1,%2,%3" ) + v = QStringLiteral( "%1,%2,%3" ) .arg( qgsDoubleToString( it->second->content.v->x ), qgsDoubleToString( it->second->content.v->y ), qgsDoubleToString( it->second->content.v->z ) ); @@ -810,12 +810,12 @@ void QgsDwgImporter::addLType( const DRW_LType &data ) } } - QString typeName( data.name.c_str() ), dash( "" ); + QString typeName( data.name.c_str() ), dash( QLatin1String( "" ) ); if ( !upath.empty() ) { QStringList l; if ( upath[0] < 0 ) - l << "0"; + l << QStringLiteral( "0" ); Q_FOREACH ( double p, upath ) { @@ -823,9 +823,9 @@ void QgsDwgImporter::addLType( const DRW_LType &data ) } if ( upath.size() % 2 == 1 ) - l << "0"; + l << QStringLiteral( "0" ); - dash = l.join( ";" ).toUtf8().constData(); + dash = l.join( QStringLiteral( ";" ) ).toUtf8().constData(); } mLinetype.insert( typeName.toLower(), dash ); @@ -852,18 +852,18 @@ QString QgsDwgImporter::colorString( int color, int color24, int transparency, c { if ( color == 0 ) { - return "byblock"; + return QStringLiteral( "byblock" ); } else if ( color == 256 ) { - return mLayerColor.value( layer.c_str(), "0,0,0,255" ); + return mLayerColor.value( layer.c_str(), QStringLiteral( "0,0,0,255" ) ); } else { if ( color < 0 ) color = -color; - return QString( "%1,%2,%3,%4" ) + return QStringLiteral( "%1,%2,%3,%4" ) .arg( DRW::dxfColors[ color ][0] ) .arg( DRW::dxfColors[ color ][1] ) .arg( DRW::dxfColors[ color ][2] ) @@ -872,7 +872,7 @@ QString QgsDwgImporter::colorString( int color, int color24, int transparency, c } else { - return QString( "%1,%2,%3,%4" ) + return QStringLiteral( "%1,%2,%3,%4" ) .arg( ( color24 & 0xff0000 ) >> 16 ) .arg( ( color24 & 0x00ff00 ) >> 8 ) .arg( ( color24 & 0x0000ff ) ) @@ -884,10 +884,10 @@ QString QgsDwgImporter::linetypeString( const std::string &olinetype, const std: { QString linetype( olinetype.c_str() ); - if ( linetype == "bylayer" ) - return mLayerLinetype.value( layer.c_str(), "" ); + if ( linetype == QLatin1String( "bylayer" ) ) + return mLayerLinetype.value( layer.c_str(), QLatin1String( "" ) ); else - return mLinetype.value( linetype, "" ); + return mLinetype.value( linetype, QLatin1String( "" ) ); } void QgsDwgImporter::addLayer( const DRW_Layer &data ) @@ -912,12 +912,12 @@ void QgsDwgImporter::addLayer( const DRW_Layer &data ) mLayerLinewidth.insert( data.name.c_str(), linewidth ); mLayerLinetype.insert( data.name.c_str(), linetypeString( data.lineType, "" ) ); - setInteger( dfn, f, "ocolor", data.color ); + setInteger( dfn, f, QStringLiteral( "ocolor" ), data.color ); SETINTEGER( color24 ); SETINTEGER( transparency ); - setString( dfn, f, "color", color.toUtf8().constData() ); - setInteger( dfn, f, "lweight", DRW_LW_Conv::lineWidth2dxfInt( data.lWeight ) ); - setInteger( dfn, f, "linewidth", linewidth ); + setString( dfn, f, QStringLiteral( "color" ), color.toUtf8().constData() ); + setInteger( dfn, f, QStringLiteral( "lweight" ), DRW_LW_Conv::lineWidth2dxfInt( data.lWeight ) ); + setInteger( dfn, f, QStringLiteral( "linewidth" ), linewidth ); if ( OGR_L_CreateFeature( layer, f ) != OGRERR_NONE ) { @@ -1248,24 +1248,24 @@ void QgsDwgImporter::addEntity( OGRFeatureDefnH dfn, OGRFeatureH f, const DRW_En { QgsDebugMsgLevel( QString( "handle:0x%1 block:0x%2" ).arg( data.handle, 0, 16 ).arg( mBlockHandle, 0, 16 ), 5 ); SETINTEGER( handle ); - setInteger( dfn, f, "block", mBlockHandle ); + setInteger( dfn, f, QStringLiteral( "block" ), mBlockHandle ); SETINTEGER( eType ); SETINTEGER( space ); SETSTRING( layer ); - setString( dfn, f, "olinetype", data.lineType ); + setString( dfn, f, QStringLiteral( "olinetype" ), data.lineType ); QString linetype = linetypeString( data.lineType, data.layer ); - if ( linetype == "1" ) + if ( linetype == QLatin1String( "1" ) ) { QgsDebugMsg( "Linetype == 1" ); } - setString( dfn, f, "linetype", linetype.toUtf8().constData() ); - setInteger( dfn, f, "ocolor", data.color ); + setString( dfn, f, QStringLiteral( "linetype" ), linetype.toUtf8().constData() ); + setInteger( dfn, f, QStringLiteral( "ocolor" ), data.color ); SETINTEGER( color24 ); SETINTEGER( transparency ); - setString( dfn, f, "color", colorString( data.color, data.color24, data.transparency, data.layer ).toUtf8().constData() ); - setInteger( dfn, f, "lweight", DRW_LW_Conv::lineWidth2dxfInt( data.lWeight ) ); - setDouble( dfn, f, "linewidth", lineWidth( data.lWeight, data.layer ) ); - setInteger( dfn, f, "ltscale", data.ltypeScale ); + setString( dfn, f, QStringLiteral( "color" ), colorString( data.color, data.color24, data.transparency, data.layer ).toUtf8().constData() ); + setInteger( dfn, f, QStringLiteral( "lweight" ), DRW_LW_Conv::lineWidth2dxfInt( data.lWeight ) ); + setDouble( dfn, f, QStringLiteral( "linewidth" ), lineWidth( data.lWeight, data.layer ) ); + setInteger( dfn, f, QStringLiteral( "ltscale" ), data.ltypeScale ); SETINTEGER( visible ); } @@ -1282,7 +1282,7 @@ void QgsDwgImporter::addPoint( const DRW_Point &data ) SETDOUBLE( thickness ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); QgsPoint p( QgsWkbTypes::PointZ, data.basePoint.x, data.basePoint.y, data.basePoint.z ); if ( !createFeature( layer, f, p ) ) @@ -1319,7 +1319,7 @@ void QgsDwgImporter::addArc( const DRW_Arc &data ) SETDOUBLE( thickness ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); double half = ( data.staangle + data.endangle ) / 2.0; if ( data.staangle > data.endangle ) @@ -1361,7 +1361,7 @@ void QgsDwgImporter::addCircle( const DRW_Circle &data ) SETDOUBLE( thickness ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); QgsCircularString c; c.setPoints( QgsPointSequence() @@ -1520,7 +1520,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) SETDOUBLE( thickness ); SETDOUBLE( width ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); if ( !createFeature( layer, f, cc ) ) { @@ -1573,7 +1573,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) SETDOUBLE( thickness ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); QgsPointXY ps( p0.x(), p0.y() ); QgsPointXY pe( p1.x(), p1.y() ); @@ -1637,7 +1637,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) SETDOUBLE( thickness ); SETDOUBLE( width ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); // QgsDebugMsg( QString( "write curve:%1" ).arg( cc.asWkt() ) ); @@ -1717,9 +1717,9 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) addEntity( dfn, f, data ); SETDOUBLE( thickness ); - setDouble( dfn, f, "width", width ); + setDouble( dfn, f, QStringLiteral( "width" ), width ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); // QgsDebugMsg( QString( "write curve:%1" ).arg( cc.asWkt() ) ); @@ -1775,7 +1775,7 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) SETDOUBLE( thickness ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); QgsPointXY ps( p0.x(), p0.y() ); QgsPointXY pe( p1.x(), p1.y() ); @@ -1841,9 +1841,9 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) addEntity( dfn, f, data ); SETDOUBLE( thickness ); - setDouble( dfn, f, "width", width ); + setDouble( dfn, f, QStringLiteral( "width" ), width ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); // QgsDebugMsg( QString( "write curve:%1" ).arg( cc.asWkt() ) ); @@ -2117,7 +2117,7 @@ void QgsDwgImporter::addInsert( const DRW_Insert &data ) SETDOUBLE( thickness ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); SETSTRING( name ); SETDOUBLE( xscale ); @@ -2165,8 +2165,8 @@ void QgsDwgImporter::addSolid( const DRW_Solid &data ) SETDOUBLE( thickness ); - setPoint( dfn, f, "ext", data.extPoint ); - setString( dfn, f, "hpattern", "SOLID" ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); + setString( dfn, f, QStringLiteral( "hpattern" ), "SOLID" ); QgsPolygonV2 poly; @@ -2215,7 +2215,7 @@ void QgsDwgImporter::addMText( const DRW_MText &data ) SETDOUBLE( thickness ); SETDOUBLE( interlin ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); QgsPoint p( QgsWkbTypes::PointZ, data.basePoint.x, data.basePoint.y, data.basePoint.z ); @@ -2249,9 +2249,9 @@ void QgsDwgImporter::addText( const DRW_Text &data ) SETINTEGER( alignH ); SETINTEGER( alignV ); SETDOUBLE( thickness ); - setDouble( dfn, f, "interlin", -1.0 ); + setDouble( dfn, f, QStringLiteral( "interlin" ), -1.0 ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); QgsPoint p( QgsWkbTypes::PointZ, ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.x : data.basePoint.x, @@ -2331,7 +2331,7 @@ void QgsDwgImporter::addHatch( const DRW_Hatch *pdata ) SETDOUBLE( thickness ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); SETSTRING( name ); SETINTEGER( solid ); @@ -2413,7 +2413,7 @@ void QgsDwgImporter::addLine( const DRW_Line &data ) SETDOUBLE( thickness ); - setPoint( dfn, f, "ext", data.extPoint ); + setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); QgsLineString l; @@ -2584,7 +2584,7 @@ bool QgsDwgImporter::expandInserts( QString &error ) QString blockLayer = QString::fromUtf8( OGR_F_GetFieldAsString( insert, layerIdx ) ); QString blockColor = QString::fromUtf8( OGR_F_GetFieldAsString( insert, colorIdx ) ); QString blockLinetype = QString::fromUtf8( OGR_F_GetFieldAsString( insert, linetypeIdx ) ); - if ( blockLinetype == "1" ) + if ( blockLinetype == QLatin1String( "1" ) ) { QgsDebugMsg( "blockLinetype == 1" ); } @@ -2607,7 +2607,7 @@ bool QgsDwgImporter::expandInserts( QString &error ) Q_FOREACH ( const QString &name, QStringList() << "hatches" << "lines" << "polylines" << "texts" << "points" ) { - OGRLayerH src = OGR_DS_ExecuteSQL( mDs, QString( "SELECT * FROM %1 WHERE block=%2" ).arg( name ).arg( handle ).toUtf8().constData(), nullptr, nullptr ); + OGRLayerH src = OGR_DS_ExecuteSQL( mDs, QStringLiteral( "SELECT * FROM %1 WHERE block=%2" ).arg( name ).arg( handle ).toUtf8().constData(), nullptr, nullptr ); if ( !src ) { QgsDebugMsg( QString( "%1: could not execute query for block %2" ).arg( name ).arg( handle ) ); diff --git a/src/app/layout/qgslayoutdesignerdialog.cpp b/src/app/layout/qgslayoutdesignerdialog.cpp index abdb9be2670a..e9a68eada03a 100644 --- a/src/app/layout/qgslayoutdesignerdialog.cpp +++ b/src/app/layout/qgslayoutdesignerdialog.cpp @@ -208,7 +208,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mStatusZoomCombo->setCompleter( nullptr ); mStatusZoomCombo->setMinimumWidth( 100 ); //zoom combo box accepts decimals in the range 1-9999, with an optional decimal point and "%" sign - QRegularExpression zoomRx( "\\s*\\d{1,4}(\\.\\d?)?\\s*%?" ); + QRegularExpression zoomRx( QStringLiteral( "\\s*\\d{1,4}(\\.\\d?)?\\s*%?" ) ); QValidator *zoomValidator = new QRegularExpressionValidator( zoomRx, mStatusZoomCombo ); mStatusZoomCombo->lineEdit()->setValidator( zoomValidator ); diff --git a/src/app/main.cpp b/src/app/main.cpp index 963b009d3f3a..d139d738d12c 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -492,8 +492,8 @@ int main( int argc, char *argv[] ) // This behavior is used to load the app, snapshot the map, // save the image to disk and then exit - QString mySnapshotFileName = ""; - QString configLocalStorageLocation = ""; + QString mySnapshotFileName = QLatin1String( "" ); + QString configLocalStorageLocation = QLatin1String( "" ); QString profileName; int mySnapshotWidth = 800; int mySnapshotHeight = 600; @@ -792,9 +792,9 @@ int main( int argc, char *argv[] ) { configLocalStorageLocation = getenv( "QGIS_CUSTOM_CONFIG_PATH" ); } - else if ( settings.contains( "profilesPath", QgsSettings::Core ) ) + else if ( settings.contains( QStringLiteral( "profilesPath" ), QgsSettings::Core ) ) { - configLocalStorageLocation = settings.value( "profilesPath", "", QgsSettings::Core ).toString(); + configLocalStorageLocation = settings.value( QStringLiteral( "profilesPath" ), "", QgsSettings::Core ).toString(); QgsDebugMsg( QString( "Loading profiles path from global config at %1" ).arg( configLocalStorageLocation ) ); } @@ -839,11 +839,11 @@ int main( int argc, char *argv[] ) { if ( ! QgsSettings::setGlobalSettingsPath( globalsettingsfile ) ) { - QgsMessageLog::logMessage( QString( "Invalid globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" ) ); + QgsMessageLog::logMessage( QStringLiteral( "Invalid globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" ) ); } else { - QgsMessageLog::logMessage( QString( "Successfully loaded globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" ) ); + QgsMessageLog::logMessage( QStringLiteral( "Successfully loaded globalsettingsfile path: %1" ).arg( globalsettingsfile ), QStringLiteral( "QGIS" ) ); } } diff --git a/src/app/nodetool/qgsnodetool.cpp b/src/app/nodetool/qgsnodetool.cpp index a4e33130f3c5..c29ff93ed11f 100644 --- a/src/app/nodetool/qgsnodetool.cpp +++ b/src/app/nodetool/qgsnodetool.cpp @@ -391,7 +391,7 @@ void QgsNodeTool::cadCanvasPressEvent( QgsMapMouseEvent *e ) if ( mLastMouseMoveMatch.isValid() && mLastMouseMoveMatch.layer() ) { QMenu menu; - QAction *actionNodeEditor = menu.addAction( "Node editor" ); + QAction *actionNodeEditor = menu.addAction( QStringLiteral( "Node editor" ) ); connect( actionNodeEditor, &QAction::triggered, this, &QgsNodeTool::showNodeEditor ); menu.exec( mCanvas->mapToGlobal( e->pos() ) ); } diff --git a/src/app/pluginmanager/qgspluginsortfilterproxymodel.h b/src/app/pluginmanager/qgspluginsortfilterproxymodel.h index 40c14900e023..f4f0fbd54121 100644 --- a/src/app/pluginmanager/qgspluginsortfilterproxymodel.h +++ b/src/app/pluginmanager/qgspluginsortfilterproxymodel.h @@ -49,7 +49,7 @@ class QgsPluginSortFilterProxyModel : public QSortFilterProxyModel void setAcceptedStatuses( const QStringList &statuses ); //! (Re)configire the spacer filter - void setAcceptedSpacers( const QString &spacers = "" ); + void setAcceptedSpacers( const QString &spacers = QString() ); //! Return number of item with status filter matching (no other filters are considered) int countWithCurrentStatus(); @@ -75,4 +75,6 @@ class QgsPluginSortFilterProxyModel : public QSortFilterProxyModel QString mAcceptedSpacers; }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index c496ac923e4a..d9da25ccd5bc 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -968,7 +968,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh new QgsCredentialDialog( this ); mLocatorWidget->setMapCanvas( mMapCanvas ); - connect( mLocatorWidget, &QgsLocatorWidget::configTriggered, this, [ = ] { showOptionsDialog( this, QString( "mOptionsLocatorSettings" ) ); } ); + connect( mLocatorWidget, &QgsLocatorWidget::configTriggered, this, [ = ] { showOptionsDialog( this, QStringLiteral( "mOptionsLocatorSettings" ) ); } ); qApp->processEvents(); @@ -1146,9 +1146,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh zoomInToolShortCut->setProperty( "Icon", QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomIn.svg" ) ) ); QShortcut *toggleSnapping = new QShortcut( QKeySequence( tr( "S" ) ), this ); - toggleSnapping->setObjectName( "toggleSnapping" ); + toggleSnapping->setObjectName( QStringLiteral( "toggleSnapping" ) ); toggleSnapping->setWhatsThis( tr( "Toggle snapping" ) ); - toggleSnapping->setProperty( "Icon", QgsApplication::getThemeIcon( "/mIconSnapping.svg" ) ); + toggleSnapping->setProperty( "Icon", QgsApplication::getThemeIcon( QStringLiteral( "/mIconSnapping.svg" ) ) ); connect( toggleSnapping, &QShortcut::activated, mSnappingUtils, &QgsSnappingUtils::toggleEnabled ); if ( ! QTouchDevice::devices().isEmpty() ) @@ -1563,7 +1563,7 @@ void QgisApp::dataSourceManager( const QString &pageName ) { mDataSourceManagerDialog->openPage( pageName ); } - if ( QgsSettings().value( "/qgis/dataSourceManagerNonModal", true ).toBool() ) + if ( QgsSettings().value( QStringLiteral( "/qgis/dataSourceManagerNonModal" ), true ).toBool() ) { mDataSourceManagerDialog->show(); } @@ -4683,7 +4683,7 @@ void QgisApp::fileExit() // active tasks if ( QMessageBox::question( this, tr( "Active tasks" ), - tr( "The following tasks are currently running in the background:\n\n%1\n\nDo you want to try canceling these active tasks?" ).arg( tasks.join( "\n" ) ), + tr( "The following tasks are currently running in the background:\n\n%1\n\nDo you want to try canceling these active tasks?" ).arg( tasks.join( QStringLiteral( "\n" ) ) ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) { QgsApplication::taskManager()->cancelAll(); @@ -5879,8 +5879,8 @@ void QgisApp::togglePanelsVisibility() { QgsSettings settings; - QStringList docksTitle = settings.value( "UI/hiddenDocksTitle", QString() ).toStringList(); - QStringList docksActive = settings.value( "UI/hiddenDocksActive", QString() ).toStringList(); + QStringList docksTitle = settings.value( QStringLiteral( "UI/hiddenDocksTitle" ), QString() ).toStringList(); + QStringList docksActive = settings.value( QStringLiteral( "UI/hiddenDocksActive" ), QString() ).toStringList(); QList docks = findChildren(); QList tabBars = findChildren(); @@ -8780,7 +8780,7 @@ void QgisApp::removeLayer() if ( !activeTaskDescriptions.isEmpty() ) { QMessageBox::warning( this, tr( "Active tasks" ), - tr( "The following tasks are currently running which depend on this layer:\n\n%1\n\nPlease cancel these tasks and retry." ).arg( activeTaskDescriptions.join( "\n" ) ) ); + tr( "The following tasks are currently running which depend on this layer:\n\n%1\n\nPlease cancel these tasks and retry." ).arg( activeTaskDescriptions.join( QStringLiteral( "\n" ) ) ) ); return; } @@ -10010,7 +10010,7 @@ bool QgisApp::checkTasksDependOnProject() if ( !activeTaskDescriptions.isEmpty() ) { QMessageBox::warning( this, tr( "Active tasks" ), - tr( "The following tasks are currently running which depend on layers in this project:\n\n%1\n\nPlease cancel these tasks and retry." ).arg( activeTaskDescriptions.toList().join( "\n" ) ) ); + tr( "The following tasks are currently running which depend on layers in this project:\n\n%1\n\nPlease cancel these tasks and retry." ).arg( activeTaskDescriptions.toList().join( QStringLiteral( "\n" ) ) ) ); return true; } return false; diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 2bba1d42a2ce..6de8b4108741 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -2090,4 +2090,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow #define QGIS_ICON_SIZE 24 #endif +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/app/qgsattributeactionpropertiesdialog.cpp b/src/app/qgsattributeactionpropertiesdialog.cpp index bbee988d6fde..b8d54de29586 100644 --- a/src/app/qgsattributeactionpropertiesdialog.cpp +++ b/src/app/qgsattributeactionpropertiesdialog.cpp @@ -195,11 +195,11 @@ void QgsAttributeActionPropertiesDialog::init( const QSet &actionScopes QString tooltip = scope.description(); if ( !variables.empty() ) { - tooltip += "

"; + tooltip += QLatin1String( "

" ); tooltip += tr( "Additional variables" ); - tooltip += "
  • "; - tooltip += variables.join( "
  • " ); - tooltip += "
"; + tooltip += QLatin1String( "
  • " ); + tooltip += variables.join( QStringLiteral( "
  • " ) ); + tooltip += QLatin1String( "
" ); } actionScopeCheckBox->setToolTip( tooltip ); actionScopeCheckBox->setProperty( "ActionScopeName", scope.id() ); diff --git a/src/app/qgscrashdialog.cpp b/src/app/qgscrashdialog.cpp index 7a4fa221ec25..7fc535c3b750 100644 --- a/src/app/qgscrashdialog.cpp +++ b/src/app/qgscrashdialog.cpp @@ -63,10 +63,10 @@ void QgsCrashDialog::createBugReport() QString QgsCrashDialog::htmlToMarkdown( const QString &html ) { QString markdown = html; - markdown.replace( "
", "\n" ); - markdown.replace( "", "*" ); - markdown.replace( "", "*" ); - markdown.replace( "QGIS code revision: ", "QGIS code revision: commit:" ); + markdown.replace( QLatin1String( "
" ), QLatin1String( "\n" ) ); + markdown.replace( QLatin1String( "" ), QLatin1String( "*" ) ); + markdown.replace( QLatin1String( "" ), QLatin1String( "*" ) ); + markdown.replace( QLatin1String( "QGIS code revision: " ), QLatin1String( "QGIS code revision: commit:" ) ); return markdown; } diff --git a/src/app/qgscrashreport.cpp b/src/app/qgscrashreport.cpp index e4d9797ab0d8..085467ff7e10 100644 --- a/src/app/qgscrashreport.cpp +++ b/src/app/qgscrashreport.cpp @@ -40,22 +40,22 @@ const QString QgsCrashReport::toHtml() const if ( flags().testFlag( QgsCrashReport::Stack ) ) { - reportData.append( "
" ); - reportData.append( "Stack Trace" ); + reportData.append( QStringLiteral( "
" ) ); + reportData.append( QStringLiteral( "Stack Trace" ) ); if ( mStackTrace.isEmpty() ) { - reportData.append( "Stack trace unable to be generated." ); + reportData.append( QStringLiteral( "Stack trace unable to be generated." ) ); } else { - reportData.append( "
" );
+      reportData.append( QStringLiteral( "
" ) );
       Q_FOREACH ( const QgsStackTrace::StackLine &line, mStackTrace )
       {
         QFileInfo fileInfo( line.fileName );
         QString filename( fileInfo.fileName() );
-        reportData.append( QString( "(%1) %2 %3:%4" ).arg( line.moduleName, line.symbolName, filename, line.lineNumber ) );
+        reportData.append( QStringLiteral( "(%1) %2 %3:%4" ).arg( line.moduleName, line.symbolName, filename, line.lineNumber ) );
       }
-      reportData.append( "
" ); + reportData.append( QStringLiteral( "
" ) ); } } @@ -77,34 +77,34 @@ const QString QgsCrashReport::toHtml() const if ( flags().testFlag( QgsCrashReport::QgisInfo ) ) { - reportData.append( "
" ); - reportData.append( "QGIS Info" ); - reportData.append( QString( "QGIS Version: %1" ).arg( Qgis::QGIS_VERSION ) ); + reportData.append( QStringLiteral( "
" ) ); + reportData.append( QStringLiteral( "QGIS Info" ) ); + reportData.append( QStringLiteral( "QGIS Version: %1" ).arg( Qgis::QGIS_VERSION ) ); if ( QString( Qgis::QGIS_DEV_VERSION ) == QLatin1String( "exported" ) ) { - reportData.append( QString( "QGIS code branch: Release %1.%2" ) + reportData.append( QStringLiteral( "QGIS code branch: Release %1.%2" ) .arg( Qgis::QGIS_VERSION_INT / 10000 ).arg( Qgis::QGIS_VERSION_INT / 100 % 100 ) ); } else { - reportData.append( QString( "QGIS code revision: %1" ).arg( Qgis::QGIS_DEV_VERSION ) ); + reportData.append( QStringLiteral( "QGIS code revision: %1" ).arg( Qgis::QGIS_DEV_VERSION ) ); } - reportData.append( QString( "Compiled against Qt: %1" ).arg( QT_VERSION_STR ) ); - reportData.append( QString( "Running against Qt: %1" ).arg( qVersion() ) ); + reportData.append( QStringLiteral( "Compiled against Qt: %1" ).arg( QT_VERSION_STR ) ); + reportData.append( QStringLiteral( "Running against Qt: %1" ).arg( qVersion() ) ); - reportData.append( QString( "Compiled against GDAL: %1" ).arg( GDAL_RELEASE_NAME ) ); - reportData.append( QString( "Running against GDAL: %1" ).arg( GDALVersionInfo( "RELEASE_NAME" ) ) ); + reportData.append( QStringLiteral( "Compiled against GDAL: %1" ).arg( GDAL_RELEASE_NAME ) ); + reportData.append( QStringLiteral( "Running against GDAL: %1" ).arg( GDALVersionInfo( "RELEASE_NAME" ) ) ); } if ( flags().testFlag( QgsCrashReport::SystemInfo ) ) { - reportData.append( "
" ); - reportData.append( "System Info" ); - reportData.append( QString( "CPU Type: %1" ).arg( QSysInfo::currentCpuArchitecture() ) ); - reportData.append( QString( "Kernel Type: %1" ).arg( QSysInfo::kernelType() ) ); - reportData.append( QString( "Kernel Version: %1" ).arg( QSysInfo::kernelVersion() ) ); + reportData.append( QStringLiteral( "
" ) ); + reportData.append( QStringLiteral( "System Info" ) ); + reportData.append( QStringLiteral( "CPU Type: %1" ).arg( QSysInfo::currentCpuArchitecture() ) ); + reportData.append( QStringLiteral( "Kernel Type: %1" ).arg( QSysInfo::kernelType() ) ); + reportData.append( QStringLiteral( "Kernel Version: %1" ).arg( QSysInfo::kernelVersion() ) ); } QString report; @@ -118,7 +118,7 @@ const QString QgsCrashReport::toHtml() const const QString QgsCrashReport::crashID() const { if ( mStackTrace.isEmpty() ) - return "ID not generated due to missing information\n\n Your version of QGIS install might not have debug information included."; + return QStringLiteral( "ID not generated due to missing information\n\n Your version of QGIS install might not have debug information included." ); QString data = QString(); @@ -133,7 +133,7 @@ const QString QgsCrashReport::crashID() const } if ( data.isNull() ) - return "ID not generated due to missing information"; + return QStringLiteral( "ID not generated due to missing information" ); QString hash = QString( QCryptographicHash::hash( data.toAscii(), QCryptographicHash::Sha1 ).toHex() ); return hash; diff --git a/src/app/qgsdecorationcopyright.cpp b/src/app/qgsdecorationcopyright.cpp index ca5f5227e02c..c4f55c8b2ac2 100644 --- a/src/app/qgsdecorationcopyright.cpp +++ b/src/app/qgsdecorationcopyright.cpp @@ -106,7 +106,7 @@ void QgsDecorationCopyright::render( const QgsMapSettings &mapSettings, QgsRende // To set the text color in a QTextDocument we use a CSS style QString style = ""; + QStringLiteral( "rgba( %1, %2, %3, %4 )" ).arg( mColor.red() ).arg( mColor.green() ).arg( mColor.blue() ).arg( QString::number( mColor.alphaF(), 'f', 2 ) ) + "}"; text.setHtml( style + "

" + mLabelQString + "

" ); QSizeF size = text.size(); diff --git a/src/app/qgsdecorationlayoutextentdialog.cpp b/src/app/qgsdecorationlayoutextentdialog.cpp index 39de5d6c8f36..8b7ca79fd028 100644 --- a/src/app/qgsdecorationlayoutextentdialog.cpp +++ b/src/app/qgsdecorationlayoutextentdialog.cpp @@ -38,7 +38,7 @@ QgsDecorationLayoutExtentDialog::QgsDecorationLayoutExtentDialog( QgsDecorationL mSymbolButton->setSymbolType( QgsSymbol::Fill ); QgsSettings settings; - restoreGeometry( settings.value( "/Windows/DecorationLayoutExtent/geometry" ).toByteArray() ); + restoreGeometry( settings.value( QStringLiteral( "/Windows/DecorationLayoutExtent/geometry" ) ).toByteArray() ); updateGuiElements(); connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsDecorationLayoutExtentDialog::apply ); diff --git a/src/app/qgsfeatureaction.cpp b/src/app/qgsfeatureaction.cpp index 5791299ad2f5..204d0225bcec 100644 --- a/src/app/qgsfeatureaction.cpp +++ b/src/app/qgsfeatureaction.cpp @@ -66,7 +66,7 @@ QgsAttributeDialog *QgsFeatureAction::newDialog( bool cloneFeature ) QgsAttributeDialog *dialog = new QgsAttributeDialog( mLayer, f, cloneFeature, parentWidget(), true, context ); dialog->setWindowFlags( dialog->windowFlags() | Qt::Tool ); - dialog->setObjectName( QString( "featureactiondlg:%1:%2" ).arg( mLayer->id() ).arg( f->id() ) ); + dialog->setObjectName( QStringLiteral( "featureactiondlg:%1:%2" ).arg( mLayer->id() ).arg( f->id() ) ); QList actions = mLayer->actions()->actions( QStringLiteral( "Feature" ) ); if ( !actions.isEmpty() ) @@ -101,7 +101,7 @@ bool QgsFeatureAction::viewFeatureForm( QgsHighlight *h ) if ( !mLayer || !mFeature ) return false; - QString name( QString( "featureactiondlg:%1:%2" ).arg( mLayer->id() ).arg( mFeature->id() ) ); + QString name( QStringLiteral( "featureactiondlg:%1:%2" ).arg( mLayer->id() ).arg( mFeature->id() ) ); QgsAttributeDialog *dialog = QgisApp::instance()->findChild( name ); if ( dialog ) @@ -139,7 +139,7 @@ bool QgsFeatureAction::editFeature( bool showModal ) } else { - QString name( QString( "featureactiondlg:%1:%2" ).arg( mLayer->id() ).arg( mFeature->id() ) ); + QString name( QStringLiteral( "featureactiondlg:%1:%2" ).arg( mLayer->id() ).arg( mFeature->id() ) ); QgsAttributeDialog *dialog = QgisApp::instance()->findChild( name ); if ( dialog ) diff --git a/src/app/qgsidentifyresultsdialog.cpp b/src/app/qgsidentifyresultsdialog.cpp index d8418ea34524..337b4cf4ccd2 100644 --- a/src/app/qgsidentifyresultsdialog.cpp +++ b/src/app/qgsidentifyresultsdialog.cpp @@ -113,12 +113,12 @@ void QgsIdentifyResultsWebView::handleDownload( QUrl url ) } else { - const QString DOWNLOADER_LAST_DIR_KEY( "Qgis/fileDownloaderLastDir" ); + const QString DOWNLOADER_LAST_DIR_KEY( QStringLiteral( "Qgis/fileDownloaderLastDir" ) ); QgsSettings settings; // Try to get some information from the URL QFileInfo info( url.toString() ); QString savePath = settings.value( DOWNLOADER_LAST_DIR_KEY ).toString(); - QString fileName = info.fileName().replace( QRegExp( "[^A-z0-9\\-_\\.]" ), "_" ); + QString fileName = info.fileName().replace( QRegExp( "[^A-z0-9\\-_\\.]" ), QStringLiteral( "_" ) ); if ( ! savePath.isEmpty() && ! fileName.isEmpty() ) { savePath = QDir::cleanPath( savePath + QDir::separator() + fileName ); diff --git a/src/app/qgsmapsavedialog.cpp b/src/app/qgsmapsavedialog.cpp index 346b69dc6225..21f695defe7b 100644 --- a/src/app/qgsmapsavedialog.cpp +++ b/src/app/qgsmapsavedialog.cpp @@ -73,7 +73,7 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co if ( activeDecorations.isEmpty() ) activeDecorations = decoration->name().toLower(); else - activeDecorations += QString( ", %1" ).arg( decoration->name().toLower() ); + activeDecorations += QStringLiteral( ", %1" ).arg( decoration->name().toLower() ); } mDrawDecorations->setText( tr( "Draw active decorations: %1" ).arg( !activeDecorations.isEmpty() ? activeDecorations : tr( "none" ) ) ); @@ -100,7 +100,7 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co layers << QChar( 0x2026 ); } mInfo->setText( tr( "The following layer(s) use advanced effects:\n%1\nRasterizing map is recommended for proper rendering." ).arg( - QChar( 0x2022 ) + QString( " " ) + layers.join( QString( "\n" ) + QChar( 0x2022 ) + QString( " " ) ) ) ); + QChar( 0x2022 ) + QStringLiteral( " " ) + layers.join( QStringLiteral( "\n" ) + QChar( 0x2022 ) + QStringLiteral( " " ) ) ) ); mSaveAsRaster->setChecked( true ); } else diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index dcf9d4eb5b06..d272263ff47d 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -628,7 +628,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetChecked( mSettings->value( QStringLiteral( "/qgis/legendLayersBold" ), true ).toBool() ); mLegendGroupsBoldChkBx->setChecked( mSettings->value( QStringLiteral( "/qgis/legendGroupsBold" ), false ).toBool() ); cbxHideSplash->setChecked( mSettings->value( QStringLiteral( "/qgis/hideSplash" ), false ).toBool() ); - mDataSourceManagerNonModal->setChecked( mSettings->value( "/qgis/dataSourceManagerNonModal", false ).toBool() ); + mDataSourceManagerNonModal->setChecked( mSettings->value( QStringLiteral( "/qgis/dataSourceManagerNonModal" ), false ).toBool() ); cbxCheckVersion->setChecked( mSettings->value( QStringLiteral( "/qgis/checkVersion" ), true ).toBool() ); cbxAttributeTableDocked->setChecked( mSettings->value( QStringLiteral( "/qgis/dockAttributeTable" ), false ).toBool() ); cbxAddPostgisDC->setChecked( mSettings->value( QStringLiteral( "/qgis/addPostgisDC" ), false ).toBool() ); @@ -1964,7 +1964,7 @@ void QgsOptions::loadGdalDriverList() // in GDAL 2.0 vector and mixed drivers are returned by GDALGetDriver, so filter out non-raster drivers // TODO add same UI for vector drivers - if ( QString( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_RASTER, nullptr ) ) != "YES" ) + if ( QString( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_RASTER, nullptr ) ) != QLatin1String( "YES" ) ) continue; myGdalDriverDescription = GDALGetDescription( myGdalDriver ); diff --git a/src/app/qgspluginregistry.h b/src/app/qgspluginregistry.h index f6421e7666f9..e1c2f541d1f8 100644 --- a/src/app/qgspluginregistry.h +++ b/src/app/qgspluginregistry.h @@ -105,7 +105,7 @@ class APP_EXPORT QgsPluginRegistry //! Check current QGIS version against requested minimal and optionally maximal QGIS version //! if maxVersion not specified, the default value is assumed: std::floor(minVersion) + 0.99.99 - bool checkQgisVersion( const QString &minVersion, const QString &maxVersion = "" ) const; + bool checkQgisVersion( const QString &minVersion, const QString &maxVersion = QString() ) const; private: static QgsPluginRegistry *sInstance; @@ -113,4 +113,7 @@ class APP_EXPORT QgsPluginRegistry QgsPythonUtils *mPythonUtils = nullptr; QgisInterface *mQgisInterface = nullptr; }; + +// clazy:excludeall=qstring-allocations + #endif //QgsPluginRegistry_H diff --git a/src/app/qgsprojectproperties.cpp b/src/app/qgsprojectproperties.cpp index 9b09f938238f..96f31c02d9c6 100644 --- a/src/app/qgsprojectproperties.cpp +++ b/src/app/qgsprojectproperties.cpp @@ -523,7 +523,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa bool addWktGeometry = QgsProject::instance()->readBoolEntry( QStringLiteral( "WMSAddWktGeometry" ), QStringLiteral( "/" ) ); mAddWktGeometryCheckBox->setChecked( addWktGeometry ); - bool requestDefinedSources = QgsProject::instance()->readBoolEntry( "WMSRequestDefinedDataSources", "/", false ); + bool requestDefinedSources = QgsProject::instance()->readBoolEntry( QStringLiteral( "WMSRequestDefinedDataSources" ), QStringLiteral( "/" ), false ); mAllowRequestDefinedDataSourcesBox->setChecked( requestDefinedSources ); bool segmentizeFeatureInfoGeometry = QgsProject::instance()->readBoolEntry( QStringLiteral( "WMSSegmentizeFeatureInfoGeometry" ), QStringLiteral( "/" ) ); @@ -1042,7 +1042,7 @@ void QgsProjectProperties::apply() } QgsProject::instance()->writeEntry( QStringLiteral( "WMSAddWktGeometry" ), QStringLiteral( "/" ), mAddWktGeometryCheckBox->isChecked() ); - QgsProject::instance()->writeEntry( "WMSRequestDefinedDataSources", "/", mAllowRequestDefinedDataSourcesBox->isChecked() ); + QgsProject::instance()->writeEntry( QStringLiteral( "WMSRequestDefinedDataSources" ), QStringLiteral( "/" ), mAllowRequestDefinedDataSourcesBox->isChecked() ); QgsProject::instance()->writeEntry( QStringLiteral( "WMSSegmentizeFeatureInfoGeometry" ), QStringLiteral( "/" ), mSegmentizeFeatureInfoGeometryCheckBox->isChecked() ); QgsProject::instance()->writeEntry( QStringLiteral( "WMSUseLayerIDs" ), QStringLiteral( "/" ), mWmsUseLayerIDs->isChecked() ); diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp index 6426c1a85fa7..6911bfda9594 100644 --- a/src/app/qgsrasterlayerproperties.cpp +++ b/src/app/qgsrasterlayerproperties.cpp @@ -550,12 +550,12 @@ void QgsRasterLayerProperties::setRendererWidget( const QString &rendererName ) QgsRectangle myExtent = mMapCanvas->mapSettings().outputExtentToLayerExtent( mRasterLayer, mMapCanvas->extent() ); if ( oldWidget && ( !oldRenderer || rendererName != oldRenderer->type() ) ) { - if ( rendererName == "singlebandgray" ) + if ( rendererName == QLatin1String( "singlebandgray" ) ) { whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::SingleBandGray, mRasterLayer->dataProvider() ) ); whileBlocking( mRasterLayer )->setDefaultContrastEnhancement(); } - else if ( rendererName == "multibandcolor" ) + else if ( rendererName == QLatin1String( "multibandcolor" ) ) { whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::MultiBandColor, mRasterLayer->dataProvider() ) ); whileBlocking( mRasterLayer )->setDefaultContrastEnhancement(); diff --git a/src/app/qgssnappingwidget.cpp b/src/app/qgssnappingwidget.cpp index d37887307937..06f9fcb05379 100644 --- a/src/app/qgssnappingwidget.cpp +++ b/src/app/qgssnappingwidget.cpp @@ -238,7 +238,7 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas, bool defaultSnapEnabled = QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool(); enableSnapping( defaultSnapEnabled ); - restoreGeometry( QgsSettings().value( "/Windows/SnappingWidget/geometry" ).toByteArray() ); + restoreGeometry( QgsSettings().value( QStringLiteral( "/Windows/SnappingWidget/geometry" ) ).toByteArray() ); } QgsSnappingWidget::~QgsSnappingWidget() diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index 7d9d8d0aae80..39cf3bc1833e 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -172,11 +172,11 @@ QgsVectorLayerProperties::QgsVectorLayerProperties( //for saving QString providerName = mLayer->providerType(); - if ( providerName == "ogr" ) + if ( providerName == QLatin1String( "ogr" ) ) { providerName = mLayer->dataProvider()->storageType(); - if ( providerName == "GPKG" ) - providerName = "GeoPackage"; + if ( providerName == QLatin1String( "GPKG" ) ) + providerName = QStringLiteral( "GeoPackage" ); } mSaveAsMenu->addAction( tr( "Save in database (%1)" ).arg( providerName ) ); } @@ -1236,7 +1236,7 @@ void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorLayerJoinInfo return; } - joinItem->setText( 0, "Join layer" ); + joinItem->setText( 0, QStringLiteral( "Join layer" ) ); joinItem->setText( 1, joinLayer->name() ); QFont f = joinItem->font( 0 ); @@ -1247,53 +1247,53 @@ void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorLayerJoinInfo joinItem->setData( 0, Qt::UserRole, join.joinLayerId() ); QTreeWidgetItem *childJoinField = new QTreeWidgetItem(); - childJoinField->setText( 0, "Join field" ); + childJoinField->setText( 0, QStringLiteral( "Join field" ) ); childJoinField->setText( 1, join.joinFieldName() ); childJoinField->setFlags( Qt::ItemIsEnabled ); joinItem->addChild( childJoinField ); QTreeWidgetItem *childTargetField = new QTreeWidgetItem(); - childTargetField->setText( 0, "Target field" ); + childTargetField->setText( 0, QStringLiteral( "Target field" ) ); childTargetField->setText( 1, join.targetFieldName() ); joinItem->addChild( childTargetField ); QTreeWidgetItem *childMemCache = new QTreeWidgetItem(); - childMemCache->setText( 0, "Cache join layer in virtual memory" ); + childMemCache->setText( 0, QStringLiteral( "Cache join layer in virtual memory" ) ); if ( join.isUsingMemoryCache() ) childMemCache->setText( 1, QChar( 0x2714 ) ); joinItem->addChild( childMemCache ); QTreeWidgetItem *childDynForm = new QTreeWidgetItem(); - childDynForm->setText( 0, "Dynamic form" ); + childDynForm->setText( 0, QStringLiteral( "Dynamic form" ) ); if ( join.isDynamicFormEnabled() ) childDynForm->setText( 1, QChar( 0x2714 ) ); joinItem->addChild( childDynForm ); QTreeWidgetItem *childEditable = new QTreeWidgetItem(); - childEditable->setText( 0, "Editable join layer" ); + childEditable->setText( 0, QStringLiteral( "Editable join layer" ) ); if ( join.isEditable() ) childEditable->setText( 1, QChar( 0x2714 ) ); joinItem->addChild( childEditable ); QTreeWidgetItem *childUpsert = new QTreeWidgetItem(); - childUpsert->setText( 0, "Upsert on edit" ); + childUpsert->setText( 0, QStringLiteral( "Upsert on edit" ) ); if ( join.hasUpsertOnEdit() ) childUpsert->setText( 1, QChar( 0x2714 ) ); joinItem->addChild( childUpsert ); QTreeWidgetItem *childCascade = new QTreeWidgetItem(); - childCascade->setText( 0, "Delete cascade" ); + childCascade->setText( 0, QStringLiteral( "Delete cascade" ) ); if ( join.hasCascadedDelete() ) childCascade->setText( 1, QChar( 0x2714 ) ); joinItem->addChild( childCascade ); QTreeWidgetItem *childPrefix = new QTreeWidgetItem(); - childPrefix->setText( 0, "Custom field name prefix" ); + childPrefix->setText( 0, QStringLiteral( "Custom field name prefix" ) ); childPrefix->setText( 1, join.prefix() ); joinItem->addChild( childPrefix ); QTreeWidgetItem *childFields = new QTreeWidgetItem(); - childFields->setText( 0, "Joined fields" ); + childFields->setText( 0, QStringLiteral( "Joined fields" ) ); const QStringList *list = join.joinFieldNamesSubset(); if ( list ) childFields->setText( 1, QStringLiteral( "%1" ).arg( list->count() ) ); diff --git a/src/core/auth/qgsauthmanager.cpp b/src/core/auth/qgsauthmanager.cpp index 1da89b94c835..f9c4543a059d 100644 --- a/src/core/auth/qgsauthmanager.cpp +++ b/src/core/auth/qgsauthmanager.cpp @@ -75,7 +75,7 @@ static const QString sDescription = QObject::tr( "Master Password <-> KeyChain s const QString QgsAuthManager::AUTH_PASSWORD_HELPER_DISPLAY_NAME( "Password Manager" ); static const QString sDescription = QObject::tr( "Master Password <-> Password Manager storage plugin. Store and retrieve your master password in your Password Manager" ); #elif defined(Q_OS_LINUX) -const QString QgsAuthManager::AUTH_PASSWORD_HELPER_DISPLAY_NAME( "Wallet/KeyRing" ); +const QString QgsAuthManager::AUTH_PASSWORD_HELPER_DISPLAY_NAME( QStringLiteral( "Wallet/KeyRing" ) ); static const QString sDescription = QObject::tr( "Master Password <-> Wallet/KeyRing storage plugin. Store and retrieve your master password in your Wallet/KeyRing" ); #else const QString QgsAuthManager::AUTH_PASSWORD_HELPER_DISPLAY_NAME( "Password Manager" ); @@ -2854,7 +2854,7 @@ QgsAuthManager::QgsAuthManager() , mScheduledDbEraseRequestCount( 0 ) , mIgnoredSslErrorsCache( QHash >() ) , mPasswordHelperVerificationError( false ) - , mPasswordHelperErrorMessage( "" ) + , mPasswordHelperErrorMessage( QLatin1String( "" ) ) , mPasswordHelperErrorCode( QKeychain::NoError ) , mPasswordHelperLoggingEnabled( false ) , mPasswordHelperFailedInit( false ) @@ -2933,7 +2933,7 @@ bool QgsAuthManager::passwordHelperDelete() QString QgsAuthManager::passwordHelperRead() { // Retrieve it! - QString password( "" ); + QString password( QLatin1String( "" ) ); passwordHelperLog( tr( "Opening %1 for READ ..." ).arg( AUTH_PASSWORD_HELPER_DISPLAY_NAME ) ); QKeychain::ReadPasswordJob job( AUTH_PASSWORD_HELPER_FOLDER_NAME ); QgsSettings settings; @@ -3039,7 +3039,7 @@ void QgsAuthManager::setPasswordHelperLoggingEnabled( const bool enabled ) void QgsAuthManager::passwordHelperClearErrors() { mPasswordHelperErrorCode = QKeychain::NoError; - mPasswordHelperErrorMessage = ""; + mPasswordHelperErrorMessage = QLatin1String( "" ); } void QgsAuthManager::passwordHelperProcessError() diff --git a/src/core/auth/qgsauthmethodregistry.cpp b/src/core/auth/qgsauthmethodregistry.cpp index d62f091467c0..b368a1357528 100644 --- a/src/core/auth/qgsauthmethodregistry.cpp +++ b/src/core/auth/qgsauthmethodregistry.cpp @@ -78,7 +78,7 @@ QgsAuthMethodRegistry::QgsAuthMethodRegistry( const QString &pluginPath ) } // auth method file regex pattern, only files matching the pattern are loaded if the variable is defined - QString filePattern = getenv( "QGIS_AUTHMETHOD_FILE" ); + QString filePattern = getenv( QStringLiteral( "QGIS_AUTHMETHOD_FILE" ) ); QRegExp fileRegexp; if ( !filePattern.isEmpty() ) { @@ -228,7 +228,7 @@ QString QgsAuthMethodRegistry::pluginList( bool asHtml ) const if ( asHtml ) { - list += "
"; + list += QLatin1String( "
" ); } else { @@ -316,7 +316,7 @@ typedef QWidget *editFactoryFunction_t( QWidget *parent ); QWidget *QgsAuthMethodRegistry::editWidget( const QString &authMethodKey, QWidget *parent ) { editFactoryFunction_t *editFactory = - reinterpret_cast< editFactoryFunction_t * >( cast_to_fptr( function( authMethodKey, "editWidget" ) ) ); + reinterpret_cast< editFactoryFunction_t * >( cast_to_fptr( function( authMethodKey, QStringLiteral( "editWidget" ) ) ) ); if ( !editFactory ) return nullptr; diff --git a/src/core/composer/qgscomposerattributetablev2.cpp b/src/core/composer/qgscomposerattributetablev2.cpp index fa0276200ace..0eb2ccaa8f96 100644 --- a/src/core/composer/qgscomposerattributetablev2.cpp +++ b/src/core/composer/qgscomposerattributetablev2.cpp @@ -641,7 +641,7 @@ bool QgsComposerAttributeTableV2::writeXml( QDomElement &elem, QDomDocument &doc composerTableElem.setAttribute( QStringLiteral( "showOnlyVisibleFeatures" ), mShowOnlyVisibleFeatures ); composerTableElem.setAttribute( QStringLiteral( "filterToAtlasIntersection" ), mFilterToAtlasIntersection ); composerTableElem.setAttribute( QStringLiteral( "maxFeatures" ), mMaximumNumberOfFeatures ); - composerTableElem.setAttribute( QStringLiteral( "filterFeatures" ), mFilterFeatures ? "true" : "false" ); + composerTableElem.setAttribute( QStringLiteral( "filterFeatures" ), mFilterFeatures ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); composerTableElem.setAttribute( QStringLiteral( "featureFilter" ), mFeatureFilter ); composerTableElem.setAttribute( QStringLiteral( "wrapString" ), mWrapString ); diff --git a/src/core/composer/qgscomposerlegend.cpp b/src/core/composer/qgscomposerlegend.cpp index 38f1950f3287..2019ec35d799 100644 --- a/src/core/composer/qgscomposerlegend.cpp +++ b/src/core/composer/qgscomposerlegend.cpp @@ -462,7 +462,7 @@ bool QgsComposerLegend::readXml( const QDomElement &itemElem, const QDomDocument mSettings.setSymbolSize( QSizeF( itemElem.attribute( QStringLiteral( "symbolWidth" ), QStringLiteral( "7.0" ) ).toDouble(), itemElem.attribute( QStringLiteral( "symbolHeight" ), QStringLiteral( "14.0" ) ).toDouble() ) ); mSettings.setWmsLegendSize( QSizeF( itemElem.attribute( QStringLiteral( "wmsLegendWidth" ), QStringLiteral( "50" ) ).toDouble(), itemElem.attribute( QStringLiteral( "wmsLegendHeight" ), QStringLiteral( "25" ) ).toDouble() ) ); - mSettings.setLineSpacing( itemElem.attribute( QStringLiteral( "lineSpacing" ), "1.0" ).toDouble() ); + mSettings.setLineSpacing( itemElem.attribute( QStringLiteral( "lineSpacing" ), QStringLiteral( "1.0" ) ).toDouble() ); mSettings.setDrawRasterStroke( itemElem.attribute( QStringLiteral( "rasterBorder" ), QStringLiteral( "1" ) ) != QLatin1String( "0" ) ); mSettings.setRasterStrokeColor( QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "rasterBorderColor" ), QStringLiteral( "0,0,0" ) ) ) ); diff --git a/src/core/composer/qgscomposerpicture.cpp b/src/core/composer/qgscomposerpicture.cpp index 285d008fad82..2891a1a2d8b7 100644 --- a/src/core/composer/qgscomposerpicture.cpp +++ b/src/core/composer/qgscomposerpicture.cpp @@ -745,7 +745,7 @@ bool QgsComposerPicture::writeXml( QDomElement &elem, QDomDocument &doc ) const { // convert from absolute path to relative. For SVG we also need to consider system SVG paths QgsPathResolver pathResolver = mComposition->project()->pathResolver(); - if ( imagePath.endsWith( ".svg", Qt::CaseInsensitive ) ) + if ( imagePath.endsWith( QLatin1String( ".svg" ), Qt::CaseInsensitive ) ) imagePath = QgsSymbolLayerUtils::svgSymbolPathToName( imagePath, pathResolver ); else imagePath = pathResolver.writePath( imagePath ); @@ -826,7 +826,7 @@ bool QgsComposerPicture::readXml( const QDomElement &itemElem, const QDomDocumen { // convert from relative path to absolute. For SVG we also need to consider system SVG paths QgsPathResolver pathResolver = mComposition->project()->pathResolver(); - if ( imagePath.endsWith( ".svg", Qt::CaseInsensitive ) ) + if ( imagePath.endsWith( QLatin1String( ".svg" ), Qt::CaseInsensitive ) ) imagePath = QgsSymbolLayerUtils::svgSymbolNameToPath( imagePath, pathResolver ); else imagePath = pathResolver.readPath( imagePath ); diff --git a/src/core/diagram/qgshistogramdiagram.cpp b/src/core/diagram/qgshistogramdiagram.cpp index d039c7138884..d94eb09fe9ec 100644 --- a/src/core/diagram/qgshistogramdiagram.cpp +++ b/src/core/diagram/qgshistogramdiagram.cpp @@ -94,6 +94,11 @@ double QgsHistogramDiagram::legendSize( double value, const QgsDiagramSettings & return value * scaleFactor; } +QString QgsHistogramDiagram::diagramName() const +{ + return DIAGRAM_NAME_HISTOGRAM; +} + QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s ) { Q_UNUSED( c ); diff --git a/src/core/diagram/qgshistogramdiagram.h b/src/core/diagram/qgshistogramdiagram.h index f2612b147651..e8d5680bc48b 100644 --- a/src/core/diagram/qgshistogramdiagram.h +++ b/src/core/diagram/qgshistogramdiagram.h @@ -47,7 +47,7 @@ class CORE_EXPORT QgsHistogramDiagram: public QgsDiagram QSizeF diagramSize( const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s ) override; QSizeF diagramSize( const QgsFeature &feature, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is ) override; double legendSize( double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is ) const override; - QString diagramName() const override { return DIAGRAM_NAME_HISTOGRAM; } + QString diagramName() const override; private: QBrush mCategoryBrush; diff --git a/src/core/diagram/qgspiediagram.cpp b/src/core/diagram/qgspiediagram.cpp index 20bb11991a09..108135b919d3 100644 --- a/src/core/diagram/qgspiediagram.cpp +++ b/src/core/diagram/qgspiediagram.cpp @@ -67,6 +67,11 @@ double QgsPieDiagram::legendSize( double value, const QgsDiagramSettings &s, con return std::max( size.width(), size.height() ); } +QString QgsPieDiagram::diagramName() const +{ + return DIAGRAM_NAME_PIE; +} + QSizeF QgsPieDiagram::diagramSize( const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s ) { Q_UNUSED( c ); diff --git a/src/core/diagram/qgspiediagram.h b/src/core/diagram/qgspiediagram.h index 4f0cfe4b32a0..9d9c79ca8dd3 100644 --- a/src/core/diagram/qgspiediagram.h +++ b/src/core/diagram/qgspiediagram.h @@ -45,7 +45,7 @@ class CORE_EXPORT QgsPieDiagram: public QgsDiagram QSizeF diagramSize( const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s ) override; QSizeF diagramSize( const QgsFeature &feature, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is ) override; double legendSize( double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is ) const override; - QString diagramName() const override { return DIAGRAM_NAME_PIE; } + QString diagramName() const override; private: QBrush mCategoryBrush; diff --git a/src/core/diagram/qgstextdiagram.cpp b/src/core/diagram/qgstextdiagram.cpp index 6ae1f9119cb2..3c73d136e968 100644 --- a/src/core/diagram/qgstextdiagram.cpp +++ b/src/core/diagram/qgstextdiagram.cpp @@ -66,6 +66,11 @@ double QgsTextDiagram::legendSize( double value, const QgsDiagramSettings &s, co return std::max( size.width(), size.height() ); } +QString QgsTextDiagram::diagramName() const +{ + return DIAGRAM_NAME_TEXT; +} + QSizeF QgsTextDiagram::diagramSize( const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s ) { Q_UNUSED( c ); diff --git a/src/core/diagram/qgstextdiagram.h b/src/core/diagram/qgstextdiagram.h index 7a0a52e38219..a83cd73a0482 100644 --- a/src/core/diagram/qgstextdiagram.h +++ b/src/core/diagram/qgstextdiagram.h @@ -58,7 +58,7 @@ class CORE_EXPORT QgsTextDiagram: public QgsDiagram QSizeF diagramSize( const QgsFeature &feature, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is ) override; double legendSize( double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is ) const override; - QString diagramName() const override { return DIAGRAM_NAME_TEXT; } + QString diagramName() const override; private: Orientation mOrientation; diff --git a/src/core/dxf/qgsdxfexport.cpp b/src/core/dxf/qgsdxfexport.cpp index 33d9eede9cd5..39dcf261f254 100644 --- a/src/core/dxf/qgsdxfexport.cpp +++ b/src/core/dxf/qgsdxfexport.cpp @@ -656,7 +656,7 @@ void QgsDxfExport::writeTables() writeGroup( 100, QStringLiteral( "AcDbSymbolTable" ) ); writeGroup( 70, 0 ); - const QStringList blockStrings = QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0"; + const QStringList blockStrings = QStringList() << QStringLiteral( "*Model_Space" ) << QStringLiteral( "*Paper_Space" ) << QStringLiteral( "*Paper_Space0" ); for ( const QString &block : blockStrings ) { writeGroup( 0, QStringLiteral( "BLOCK_RECORD" ) ); @@ -862,7 +862,7 @@ void QgsDxfExport::writeBlocks() startSection(); writeGroup( 2, QStringLiteral( "BLOCKS" ) ); - const QStringList blockStrings = QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0"; + const QStringList blockStrings = QStringList() << QStringLiteral( "*Model_Space" ) << QStringLiteral( "*Paper_Space" ) << QStringLiteral( "*Paper_Space0" ); for ( const QString &block : blockStrings ) { writeGroup( 0, QStringLiteral( "BLOCK" ) ); @@ -4022,7 +4022,7 @@ QList< QPair< QgsSymbolLayer *, QgsSymbol * > > QgsDxfExport::symbolLayers( QgsR void QgsDxfExport::writeDefaultLinetypes() { // continuous (Qt solid line) - const QStringList blockStrings = QStringList() << "ByLayer" << "ByBlock" << "CONTINUOUS"; + const QStringList blockStrings = QStringList() << QStringLiteral( "ByLayer" ) << QStringLiteral( "ByBlock" ) << QStringLiteral( "CONTINUOUS" ); for ( const QString <ype : blockStrings ) { writeGroup( 0, QStringLiteral( "LTYPE" ) ); diff --git a/src/core/effects/qgsblureffect.cpp b/src/core/effects/qgsblureffect.cpp index 047d9651bf55..5e6d3f48d456 100644 --- a/src/core/effects/qgsblureffect.cpp +++ b/src/core/effects/qgsblureffect.cpp @@ -80,7 +80,7 @@ void QgsBlurEffect::drawBlurredImage( QgsRenderContext &context, QImage &image ) QgsStringMap QgsBlurEffect::properties() const { QgsStringMap props; - props.insert( QStringLiteral( "enabled" ), mEnabled ? "1" : "0" ); + props.insert( QStringLiteral( "enabled" ), mEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); props.insert( QStringLiteral( "draw_mode" ), QString::number( static_cast< int >( mDrawMode ) ) ); props.insert( QStringLiteral( "blend_mode" ), QString::number( static_cast< int >( mBlendMode ) ) ); props.insert( QStringLiteral( "opacity" ), QString::number( mOpacity ) ); diff --git a/src/core/effects/qgscoloreffect.cpp b/src/core/effects/qgscoloreffect.cpp index a9ec38d71ed5..8fe43e9d416b 100644 --- a/src/core/effects/qgscoloreffect.cpp +++ b/src/core/effects/qgscoloreffect.cpp @@ -68,7 +68,7 @@ void QgsColorEffect::draw( QgsRenderContext &context ) QgsStringMap QgsColorEffect::properties() const { QgsStringMap props; - props.insert( QStringLiteral( "enabled" ), mEnabled ? "1" : "0" ); + props.insert( QStringLiteral( "enabled" ), mEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); props.insert( QStringLiteral( "draw_mode" ), QString::number( int( mDrawMode ) ) ); props.insert( QStringLiteral( "blend_mode" ), QString::number( int( mBlendMode ) ) ); props.insert( QStringLiteral( "opacity" ), QString::number( mOpacity ) ); @@ -76,7 +76,7 @@ QgsStringMap QgsColorEffect::properties() const props.insert( QStringLiteral( "contrast" ), QString::number( mContrast ) ); props.insert( QStringLiteral( "saturation" ), QString::number( mSaturation ) ); props.insert( QStringLiteral( "grayscale_mode" ), QString::number( int( mGrayscaleMode ) ) ); - props.insert( QStringLiteral( "colorize" ), mColorizeOn ? "1" : "0" ); + props.insert( QStringLiteral( "colorize" ), mColorizeOn ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); props.insert( QStringLiteral( "colorize_color" ), QgsSymbolLayerUtils::encodeColor( mColorizeColor ) ); props.insert( QStringLiteral( "colorize_strength" ), QString::number( mColorizeStrength ) ); diff --git a/src/core/expression/qgsexpression.cpp b/src/core/expression/qgsexpression.cpp index 3069dca884de..ba96e5634e4e 100644 --- a/src/core/expression/qgsexpression.cpp +++ b/src/core/expression/qgsexpression.cpp @@ -144,7 +144,7 @@ QString QgsExpression::quotedValue( const QVariant &value, QVariant::Type type ) return value.toString(); case QVariant::Bool: - return value.toBool() ? "TRUE" : "FALSE"; + return value.toBool() ? QStringLiteral( "TRUE" ) : QStringLiteral( "FALSE" ); case QVariant::List: { @@ -154,7 +154,7 @@ QString QgsExpression::quotedValue( const QVariant &value, QVariant::Type type ) { quotedValues += quotedValue( v ); } - return QStringLiteral( "array( %1 )" ).arg( quotedValues.join( ", " ) ); + return QStringLiteral( "array( %1 )" ).arg( quotedValues.join( QStringLiteral( ", " ) ) ); } default: @@ -546,7 +546,7 @@ QString QgsExpression::helpText( QString name ) delim = QStringLiteral( ", " ); if ( !a.mDescOnly ) { - helpContents += QStringLiteral( "%2%3" ).arg( a.mOptional ? "optional" : "", a.mArg, + helpContents += QStringLiteral( "%2%3" ).arg( a.mOptional ? QStringLiteral( "optional" ) : QStringLiteral( "" ), a.mArg, a.mDefaultVal.isEmpty() ? QLatin1String( "" ) : '=' + a.mDefaultVal ); } } diff --git a/src/core/expression/qgsexpressionfunction.cpp b/src/core/expression/qgsexpressionfunction.cpp index ee11797a4811..c8781f16fddd 100644 --- a/src/core/expression/qgsexpressionfunction.cpp +++ b/src/core/expression/qgsexpressionfunction.cpp @@ -507,9 +507,9 @@ static QVariant fcnAggregate( const QVariantList &values, const QgsExpressionCon QString cacheKey; QgsExpression subExp( subExpression ); QgsExpression filterExp( parameters.filter ); - if ( filterExp.referencedVariables().contains( "parent" ) + if ( filterExp.referencedVariables().contains( QStringLiteral( "parent" ) ) || filterExp.referencedVariables().contains( QString() ) - || subExp.referencedVariables().contains( "parent" ) + || subExp.referencedVariables().contains( QStringLiteral( "parent" ) ) || subExp.referencedVariables().contains( QString() ) ) { cacheKey = QStringLiteral( "aggfcn:%1:%2:%3:%4:%5%6" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.filter, @@ -525,7 +525,7 @@ static QVariant fcnAggregate( const QVariantList &values, const QgsExpressionCon QgsExpressionContext subContext( *context ); QgsExpressionContextScope *subScope = new QgsExpressionContextScope(); - subScope->setVariable( "parent", context->feature() ); + subScope->setVariable( QStringLiteral( "parent" ), context->feature() ); subContext.appendScope( subScope ); result = vl->aggregate( aggregate, subExpression, parameters, &subContext, &ok ); @@ -553,7 +553,7 @@ static QVariant fcnAggregateRelation( const QVariantList &values, const QgsExpre } // first step - find current layer - QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->variable( "layer" ), parent ); + QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->variable( QStringLiteral( "layer" ) ), parent ); if ( !vl ) { parent->setEvalErrorString( QObject::tr( "Cannot use relation aggregate function in this context" ) ); @@ -655,7 +655,7 @@ static QVariant fcnAggregateGeneric( QgsAggregateCalculator::Aggregate aggregate } // first step - find current layer - QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->variable( "layer" ), parent ); + QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->variable( QStringLiteral( "layer" ) ), parent ); if ( !vl ) { parent->setEvalErrorString( QObject::tr( "Cannot use aggregate function in this context" ) ); @@ -698,7 +698,7 @@ static QVariant fcnAggregateGeneric( QgsAggregateCalculator::Aggregate aggregate QgsExpression groupByExp( groupBy ); QVariant groupByValue = groupByExp.evaluate( context ); QString groupByClause = QStringLiteral( "%1 %2 %3" ).arg( groupBy, - groupByValue.isNull() ? "is" : "=", + groupByValue.isNull() ? QStringLiteral( "is" ) : QStringLiteral( "=" ), QgsExpression::quotedValue( groupByValue ) ); if ( !parameters.filter.isEmpty() ) parameters.filter = QStringLiteral( "(%1) AND (%2)" ).arg( parameters.filter, groupByClause ); @@ -1284,11 +1284,11 @@ static QVariant fcnIsSelected( const QVariantList &values, const QgsExpressionCo if ( values.isEmpty() ) { feature = context->feature(); - layer = QgsExpressionUtils::getVectorLayer( context->variable( "layer" ), parent ); + layer = QgsExpressionUtils::getVectorLayer( context->variable( QStringLiteral( "layer" ) ), parent ); } else if ( values.size() == 1 ) { - layer = QgsExpressionUtils::getVectorLayer( context->variable( "layer" ), parent ); + layer = QgsExpressionUtils::getVectorLayer( context->variable( QStringLiteral( "layer" ) ), parent ); feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent ); } else if ( values.size() == 2 ) @@ -1315,7 +1315,7 @@ static QVariant fcnNumSelected( const QVariantList &values, const QgsExpressionC QgsVectorLayer *layer = nullptr; if ( values.isEmpty() ) - layer = QgsExpressionUtils::getVectorLayer( context->variable( "layer" ), parent ); + layer = QgsExpressionUtils::getVectorLayer( context->variable( QStringLiteral( "layer" ) ), parent ); else if ( values.count() == 1 ) layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent ); else @@ -3918,7 +3918,7 @@ const QList &QgsExpression::Functions() QgsExpressionNode *filterNode = node->args()->at( 3 ); referencedVars.unite( filterNode->referencedVariables() ); } - return referencedVars.contains( "parent" ) || referencedVars.contains( QString() ); + return referencedVars.contains( QStringLiteral( "parent" ) ) || referencedVars.contains( QString() ); }, []( const QgsExpressionNodeFunction * node ) { @@ -3946,7 +3946,7 @@ const QList &QgsExpression::Functions() referencedCols.unite( filterNode->referencedColumns() ); } - if ( referencedVars.contains( "parent" ) || referencedVars.contains( QString() ) ) + if ( referencedVars.contains( QStringLiteral( "parent" ) ) || referencedVars.contains( QString() ) ) return QSet() << QgsFeatureRequest::ALL_ATTRIBUTES; else return referencedCols; diff --git a/src/core/expression/qgsexpressionnodeimpl.cpp b/src/core/expression/qgsexpressionnodeimpl.cpp index b56e50a0c4fc..2099cdac3679 100644 --- a/src/core/expression/qgsexpressionnodeimpl.cpp +++ b/src/core/expression/qgsexpressionnodeimpl.cpp @@ -696,15 +696,15 @@ QString QgsExpressionNodeBinaryOperator::dump() const QString fmt; if ( leftAssociative() ) { - fmt += lOp && ( lOp->precedence() < precedence() ) ? "(%1)" : "%1"; + fmt += lOp && ( lOp->precedence() < precedence() ) ? QStringLiteral( "(%1)" ) : QStringLiteral( "%1" ); fmt += QLatin1String( " %2 " ); - fmt += rOp && ( rOp->precedence() <= precedence() ) ? "(%3)" : "%3"; + fmt += rOp && ( rOp->precedence() <= precedence() ) ? QStringLiteral( "(%3)" ) : QStringLiteral( "%3" ); } else { - fmt += lOp && ( lOp->precedence() <= precedence() ) ? "(%1)" : "%1"; + fmt += lOp && ( lOp->precedence() <= precedence() ) ? QStringLiteral( "(%1)" ) : QStringLiteral( "%1" ); fmt += QLatin1String( " %2 " ); - fmt += rOp && ( rOp->precedence() < precedence() ) ? "(%3)" : "%3"; + fmt += rOp && ( rOp->precedence() < precedence() ) ? QStringLiteral( "(%3)" ) : QStringLiteral( "%3" ); } return fmt.arg( mOpLeft->dump(), BINARY_OPERATOR_TEXT[mOp], rdump ); @@ -951,7 +951,7 @@ QSet QgsExpressionNodeFunction::referencedColumns() const QSet QgsExpressionNodeFunction::referencedVariables() const { QgsExpressionFunction *fd = QgsExpression::QgsExpression::Functions()[mFnIndex]; - if ( fd->name() == "var" ) + if ( fd->name() == QLatin1String( "var" ) ) { if ( !mArgs->list().isEmpty() ) { diff --git a/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp b/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp index c4fdee6314ec..adbeb7b13296 100644 --- a/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp +++ b/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp @@ -34,31 +34,31 @@ QString QgsRelationReferenceFieldFormatter::representValue( QgsVectorLayer *laye // Some sanity checks if ( !config.contains( QStringLiteral( "Relation" ) ) ) { - QgsMessageLog::logMessage( "Missing Relation in configuration" ); + QgsMessageLog::logMessage( QStringLiteral( "Missing Relation in configuration" ) ); return value.toString(); } QgsRelation relation = QgsProject::instance()->relationManager()->relation( config[QStringLiteral( "Relation" )].toString() ); if ( !relation.isValid() ) { - QgsMessageLog::logMessage( "Invalid relation" ); + QgsMessageLog::logMessage( QStringLiteral( "Invalid relation" ) ); return value.toString(); } QgsVectorLayer *referencingLayer = relation.referencingLayer(); if ( layer != referencingLayer ) { - QgsMessageLog::logMessage( "representValue() with inconsistent layer parameter w.r.t relation referencingLayer" ); + QgsMessageLog::logMessage( QStringLiteral( "representValue() with inconsistent layer parameter w.r.t relation referencingLayer" ) ); return value.toString(); } int referencingFieldIdx = referencingLayer->fields().lookupField( relation.fieldPairs().at( 0 ).first ); if ( referencingFieldIdx != fieldIndex ) { - QgsMessageLog::logMessage( "representValue() with inconsistent fieldIndex parameter w.r.t relation referencingFieldIdx" ); + QgsMessageLog::logMessage( QStringLiteral( "representValue() with inconsistent fieldIndex parameter w.r.t relation referencingFieldIdx" ) ); return value.toString(); } QgsVectorLayer *referencedLayer = relation.referencedLayer(); if ( !referencedLayer ) { - QgsMessageLog::logMessage( "Cannot find referenced layer" ); + QgsMessageLog::logMessage( QStringLiteral( "Cannot find referenced layer" ) ); return value.toString(); } diff --git a/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp b/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp index 2d07516eafca..8f85702327e4 100644 --- a/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp +++ b/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp @@ -52,7 +52,7 @@ QString QgsValueRelationFieldFormatter::representValue( QgsVectorLayer *layer, i vrCache = QgsValueRelationFieldFormatter::createCache( config ); } - if ( config.value( "AllowMulti" ).toBool() ) + if ( config.value( QStringLiteral( "AllowMulti" ) ).toBool() ) { QStringList keyList = value.toString().remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( ',' ); QStringList valueList; @@ -65,7 +65,7 @@ QString QgsValueRelationFieldFormatter::representValue( QgsVectorLayer *layer, i } } - return valueList.join( ", " ).prepend( '{' ).append( '}' ); + return valueList.join( QStringLiteral( ", " ) ).prepend( '{' ).append( '}' ); } else { @@ -83,7 +83,7 @@ QString QgsValueRelationFieldFormatter::representValue( QgsVectorLayer *layer, i } } - return QString( "(%1)" ).arg( value.toString() ); + return QStringLiteral( "(%1)" ).arg( value.toString() ); } QVariant QgsValueRelationFieldFormatter::sortValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const @@ -103,22 +103,22 @@ QgsValueRelationFieldFormatter::ValueRelationCache QgsValueRelationFieldFormatte { ValueRelationCache cache; - QgsVectorLayer *layer = qobject_cast( QgsProject::instance()->mapLayer( config.value( "Layer" ).toString() ) ); + QgsVectorLayer *layer = qobject_cast( QgsProject::instance()->mapLayer( config.value( QStringLiteral( "Layer" ) ).toString() ) ); if ( !layer ) return cache; QgsFields fields = layer->fields(); - int ki = fields.indexOf( config.value( "Key" ).toString() ); - int vi = fields.indexOf( config.value( "Value" ).toString() ); + int ki = fields.indexOf( config.value( QStringLiteral( "Key" ) ).toString() ); + int vi = fields.indexOf( config.value( QStringLiteral( "Value" ) ).toString() ); QgsFeatureRequest request; request.setFlags( QgsFeatureRequest::NoGeometry ); request.setSubsetOfAttributes( QgsAttributeList() << ki << vi ); - if ( !config.value( "FilterExpression" ).toString().isEmpty() ) + if ( !config.value( QStringLiteral( "FilterExpression" ) ).toString().isEmpty() ) { - request.setFilterExpression( config.value( "FilterExpression" ).toString() ); + request.setFilterExpression( config.value( QStringLiteral( "FilterExpression" ) ).toString() ); } QgsFeatureIterator fit = layer->getFeatures( request ); @@ -129,7 +129,7 @@ QgsValueRelationFieldFormatter::ValueRelationCache QgsValueRelationFieldFormatte cache.append( ValueRelationItem( f.attribute( ki ), f.attribute( vi ).toString() ) ); } - if ( config.value( "OrderByValue" ).toBool() ) + if ( config.value( QStringLiteral( "OrderByValue" ) ).toBool() ) { std::sort( cache.begin(), cache.end(), orderByValueLessThan ); } diff --git a/src/core/geocms/geonode/qgsgeonodeconnection.cpp b/src/core/geocms/geonode/qgsgeonodeconnection.cpp index 0706bb3195b3..b5025fff090b 100644 --- a/src/core/geocms/geonode/qgsgeonodeconnection.cpp +++ b/src/core/geocms/geonode/qgsgeonodeconnection.cpp @@ -19,8 +19,8 @@ #include "qgsdatasourceuri.h" #include "qgsowsconnection.h" -const QString QgsGeoNodeConnectionUtils::sPathGeoNodeConnection = "qgis/connections-geonode"; -const QString QgsGeoNodeConnectionUtils::sPathGeoNodeConnectionDetails = "qgis/GeoNode"; +const QString QgsGeoNodeConnectionUtils::sPathGeoNodeConnection = QStringLiteral( "qgis/connections-geonode" ); +const QString QgsGeoNodeConnectionUtils::sPathGeoNodeConnectionDetails = QStringLiteral( "qgis/GeoNode" ); QgsGeoNodeConnection::QgsGeoNodeConnection( const QString &name ) : mConnName( name ) diff --git a/src/core/geometry/qgsabstractgeometry.h b/src/core/geometry/qgsabstractgeometry.h index 21d1ccd54482..43ab0ba7ad41 100644 --- a/src/core/geometry/qgsabstractgeometry.h +++ b/src/core/geometry/qgsabstractgeometry.h @@ -500,4 +500,6 @@ inline T qgsgeometry_cast( const QgsAbstractGeometry *geom ) } #endif +// clazy:excludeall=qstring-allocations + #endif //QGSABSTRACTGEOMETRYV2 diff --git a/src/core/geometry/qgscircularstring.h b/src/core/geometry/qgscircularstring.h index 26dc80134142..70dd9ea4d80b 100644 --- a/src/core/geometry/qgscircularstring.h +++ b/src/core/geometry/qgscircularstring.h @@ -154,4 +154,6 @@ class CORE_EXPORT QgsCircularString: public QgsCurve }; +// clazy:excludeall=qstring-allocations + #endif // QGSCIRCULARSTRING_H diff --git a/src/core/geometry/qgscompoundcurve.cpp b/src/core/geometry/qgscompoundcurve.cpp index 6ca3535c110c..0a70b12afb60 100644 --- a/src/core/geometry/qgscompoundcurve.cpp +++ b/src/core/geometry/qgscompoundcurve.cpp @@ -173,7 +173,7 @@ bool QgsCompoundCurve::fromWkt( const QString &wkt ) return false; mWkbType = parts.first; - QString defaultChildWkbType = QStringLiteral( "LineString%1%2" ).arg( is3D() ? "Z" : QString(), isMeasure() ? "M" : QString() ); + QString defaultChildWkbType = QStringLiteral( "LineString%1%2" ).arg( is3D() ? QStringLiteral( "Z" ) : QString(), isMeasure() ? QStringLiteral( "M" ) : QString() ); const QStringList blocks = QgsGeometryUtils::wktGetChildBlocks( parts.second, defaultChildWkbType ); for ( const QString &childWkt : blocks ) diff --git a/src/core/geometry/qgscompoundcurve.h b/src/core/geometry/qgscompoundcurve.h index fa61a0a6b861..9d09a32f1f21 100644 --- a/src/core/geometry/qgscompoundcurve.h +++ b/src/core/geometry/qgscompoundcurve.h @@ -156,4 +156,6 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve }; +// clazy:excludeall=qstring-allocations + #endif // QGSCOMPOUNDCURVEV2_H diff --git a/src/core/geometry/qgscurvepolygon.cpp b/src/core/geometry/qgscurvepolygon.cpp index 316a3307979b..08e73d92aba6 100644 --- a/src/core/geometry/qgscurvepolygon.cpp +++ b/src/core/geometry/qgscurvepolygon.cpp @@ -200,7 +200,7 @@ bool QgsCurvePolygon::fromWkt( const QString &wkt ) mWkbType = parts.first; - QString defaultChildWkbType = QStringLiteral( "LineString%1%2" ).arg( is3D() ? "Z" : QString(), isMeasure() ? "M" : QString() ); + QString defaultChildWkbType = QStringLiteral( "LineString%1%2" ).arg( is3D() ? QStringLiteral( "Z" ) : QString(), isMeasure() ? QStringLiteral( "M" ) : QString() ); const QStringList blocks = QgsGeometryUtils::wktGetChildBlocks( parts.second, defaultChildWkbType ); for ( const QString &childWkt : blocks ) @@ -357,7 +357,7 @@ QDomElement QgsCurvePolygon::asGML3( QDomDocument &doc, int precision, const QSt QDomElement elemCurvePolygon = doc.createElementNS( ns, QStringLiteral( "Polygon" ) ); QDomElement elemExterior = doc.createElementNS( ns, QStringLiteral( "exterior" ) ); QDomElement curveElem = exteriorRing()->asGML3( doc, precision, ns ); - if ( curveElem.tagName() == "LineString" ) + if ( curveElem.tagName() == QLatin1String( "LineString" ) ) { curveElem.setTagName( QStringLiteral( "LinearRing" ) ); } @@ -368,7 +368,7 @@ QDomElement QgsCurvePolygon::asGML3( QDomDocument &doc, int precision, const QSt { QDomElement elemInterior = doc.createElementNS( ns, QStringLiteral( "interior" ) ); QDomElement innerRing = interiorRing( i )->asGML3( doc, precision, ns ); - if ( innerRing.tagName() == "LineString" ) + if ( innerRing.tagName() == QLatin1String( "LineString" ) ) { innerRing.setTagName( QStringLiteral( "LinearRing" ) ); } diff --git a/src/core/geometry/qgscurvepolygon.h b/src/core/geometry/qgscurvepolygon.h index 566d7b1294cd..b969567b81a4 100644 --- a/src/core/geometry/qgscurvepolygon.h +++ b/src/core/geometry/qgscurvepolygon.h @@ -174,4 +174,6 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface QgsRectangle calculateBoundingBox() const override; }; +// clazy:excludeall=qstring-allocations + #endif // QGSCURVEPOLYGONV2_H diff --git a/src/core/geometry/qgsgeometrycollection.h b/src/core/geometry/qgsgeometrycollection.h index 8b227b8b0b5b..2672a2f4cace 100644 --- a/src/core/geometry/qgsgeometrycollection.h +++ b/src/core/geometry/qgsgeometrycollection.h @@ -170,4 +170,6 @@ class CORE_EXPORT QgsGeometryCollection: public QgsAbstractGeometry mutable QgsCoordinateSequence mCoordinateSequence; }; +// clazy:excludeall=qstring-allocations + #endif // QGSGEOMETRYCOLLECTIONV2_H diff --git a/src/core/geometry/qgsgeometrymakevalid.cpp b/src/core/geometry/qgsgeometrymakevalid.cpp index 486fbb7a17da..b3dbfad65d43 100644 --- a/src/core/geometry/qgsgeometrymakevalid.cpp +++ b/src/core/geometry/qgsgeometrymakevalid.cpp @@ -162,7 +162,7 @@ static GEOSGeometry *LWGEOM_GEOS_buildArea( const GEOSGeometry *geom_in, QString } catch ( GEOSException &e ) { - errorMessage = QString( "GEOSPolygonize(): %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSPolygonize(): %1" ).arg( e.what() ); return nullptr; } @@ -492,7 +492,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr if ( !geos_cut_edges ) { GEOSGeom_destroy_r( handle, geos_bound ); - errorMessage = "LWGEOM_GEOS_nodeLines() failed"; + errorMessage = QStringLiteral( "LWGEOM_GEOS_nodeLines() failed" ); return nullptr; } @@ -509,7 +509,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr catch ( GEOSException &e ) { GEOSGeom_destroy_r( handle, geos_bound ); - errorMessage = QString( "GEOSGeom_extractUniquePoints(): %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSGeom_extractUniquePoints(): %1" ).arg( e.what() ); return nullptr; } @@ -521,7 +521,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr { GEOSGeom_destroy_r( handle, geos_bound ); GEOSGeom_destroy_r( handle, pi ); - errorMessage = QString( "GEOSGeom_extractUniquePoints(): %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSGeom_extractUniquePoints(): %1" ).arg( e.what() ); return nullptr; } @@ -534,7 +534,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr GEOSGeom_destroy_r( handle, geos_bound ); GEOSGeom_destroy_r( handle, pi ); GEOSGeom_destroy_r( handle, po ); - errorMessage = QString( "GEOSDifference(): %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSDifference(): %1" ).arg( e.what() ); return nullptr; } @@ -550,7 +550,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { - errorMessage = QString( "GEOSGeom_createEmptyPolygon(): %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSGeom_createEmptyPolygon(): %1" ).arg( e.what() ); GEOSGeom_destroy_r( handle, geos_cut_edges ); return nullptr; } @@ -576,7 +576,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr { GEOSGeom_destroy_r( handle, geos_cut_edges ); GEOSGeom_destroy_r( handle, geos_area ); - errorMessage = QString( "LWGEOM_GEOS_buildArea() threw an error: %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "LWGEOM_GEOS_buildArea() threw an error: %1" ).arg( e.what() ); return nullptr; } @@ -599,7 +599,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr { // We did check for empty area already so // this must be some other error - errorMessage = QString( "GEOSBoundary() threw an error: %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSBoundary() threw an error: %1" ).arg( e.what() ); GEOSGeom_destroy_r( handle, new_area ); GEOSGeom_destroy_r( handle, geos_area ); return nullptr; @@ -616,7 +616,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr GEOSGeom_destroy_r( handle, new_area ); GEOSGeom_destroy_r( handle, new_area_bound ); GEOSGeom_destroy_r( handle, geos_area ); - errorMessage = QString( "GEOSSymDifference() threw an error: %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSSymDifference() threw an error: %1" ).arg( e.what() ); return nullptr; } @@ -642,7 +642,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr GEOSGeom_destroy_r( handle, geos_cut_edges ); GEOSGeom_destroy_r( handle, new_area_bound ); GEOSGeom_destroy_r( handle, geos_area ); - errorMessage = QString( "GEOSDifference() threw an error: %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSDifference() threw an error: %1" ).arg( e.what() ); return nullptr; } GEOSGeom_destroy_r( handle, geos_cut_edges ); @@ -691,7 +691,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { - errorMessage = QString( "GEOSGeom_createCollection() threw an error: %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSGeom_createCollection() threw an error: %1" ).arg( e.what() ); // TODO: cleanup! return nullptr; } @@ -750,7 +750,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidMultiLine( const GEOSGeometry *gin, QS else { // NOTE: return from GEOSGeomType will leak but we really don't expect this to happen - errorMessage = QString( "unexpected geom type returned by LWGEOM_GEOS_makeValid: %1" ).arg( GEOSGeomTypeId_r( handle, vg ) ); + errorMessage = QStringLiteral( "unexpected geom type returned by LWGEOM_GEOS_makeValid: %1" ).arg( GEOSGeomTypeId_r( handle, vg ) ); } } @@ -812,7 +812,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidCollection( const GEOSGeometry *gin, Q int nvgeoms = GEOSGetNumGeometries_r( handle, gin ); if ( nvgeoms == -1 ) { - errorMessage = QString( "GEOSGetNumGeometries: %1" ).arg( "?" ); + errorMessage = QStringLiteral( "GEOSGetNumGeometries: %1" ).arg( QStringLiteral( "?" ) ); return nullptr; } @@ -839,7 +839,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidCollection( const GEOSGeometry *gin, Q // cleanup and throw for ( int i = 0; i < nvgeoms; ++i ) GEOSGeom_destroy_r( handle, vgeoms[i] ); - errorMessage = QString( "GEOSGeom_createCollection() threw an error: %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSGeom_createCollection() threw an error: %1" ).arg( e.what() ); return nullptr; } } @@ -862,7 +862,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValid( const GEOSGeometry *gin, QString &er catch ( GEOSException &e ) { // I don't think should ever happen - errorMessage = QString( "GEOSisValid(): %1" ).arg( e.what() ); + errorMessage = QStringLiteral( "GEOSisValid(): %1" ).arg( e.what() ); return nullptr; } Q_NOWARN_UNREACHABLE_POP @@ -891,7 +891,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValid( const GEOSGeometry *gin, QString &er return LWGEOM_GEOS_makeValidCollection( gin, errorMessage ); default: - errorMessage = QString( "ST_MakeValid: doesn't support geometry type: %1" ).arg( GEOSGeomTypeId_r( handle, gin ) ); + errorMessage = QStringLiteral( "ST_MakeValid: doesn't support geometry type: %1" ).arg( GEOSGeomTypeId_r( handle, gin ) ); return nullptr; } } @@ -922,7 +922,7 @@ QgsAbstractGeometry *_qgis_lwgeom_make_valid( const QgsAbstractGeometry *lwgeom_ if ( ! geosgeom ) { - errorMessage = "Could not convert QGIS geom to GEOS"; + errorMessage = QStringLiteral( "Could not convert QGIS geom to GEOS" ); return nullptr; } } diff --git a/src/core/geometry/qgsgeometryutils.cpp b/src/core/geometry/qgsgeometryutils.cpp index e136b014769f..c226c322d502 100644 --- a/src/core/geometry/qgsgeometryutils.cpp +++ b/src/core/geometry/qgsgeometryutils.cpp @@ -798,7 +798,7 @@ QgsPointSequence QgsGeometryUtils::pointsFromWKT( const QString &wktCoordinateLi //first scan through for extra unexpected dimensions bool foundZ = false; bool foundM = false; - QRegularExpression rx( "\\s" ); + QRegularExpression rx( QStringLiteral( "\\s" ) ); for ( const QString &pointCoordinates : coordList ) { QStringList coordinates = pointCoordinates.split( rx, QString::SkipEmptyParts ); @@ -898,12 +898,12 @@ QDomElement QgsGeometryUtils::pointsToGML2( const QgsPointSequence &points, QDom QDomElement elemCoordinates = doc.createElementNS( ns, QStringLiteral( "coordinates" ) ); // coordinate separator - QString cs = ","; + QString cs = QStringLiteral( "," ); // tupel separator - QString ts = " "; + QString ts = QStringLiteral( " " ); - elemCoordinates.setAttribute( "cs", cs ); - elemCoordinates.setAttribute( "ts", ts ); + elemCoordinates.setAttribute( QStringLiteral( "cs" ), cs ); + elemCoordinates.setAttribute( QStringLiteral( "ts" ), ts ); QString strCoordinates; @@ -969,7 +969,7 @@ QPair QgsGeometryUtils::wktReadBlock( const QString { QgsWkbTypes::Type wkbType = QgsWkbTypes::parseType( wkt ); - QRegularExpression cooRegEx( "^[^\\(]*\\((.*)\\)[^\\)]*$" ); + QRegularExpression cooRegEx( QStringLiteral( "^[^\\(]*\\((.*)\\)[^\\)]*$" ) ); cooRegEx.setPatternOptions( QRegularExpression::DotMatchesEverythingOption ); QRegularExpressionMatch match = cooRegEx.match( wkt ); QString contents = match.hasMatch() ? match.captured( 1 ) : QString(); diff --git a/src/core/geometry/qgsgeometryutils.h b/src/core/geometry/qgsgeometryutils.h index da1e08d472e2..2f28d22ffb20 100644 --- a/src/core/geometry/qgsgeometryutils.h +++ b/src/core/geometry/qgsgeometryutils.h @@ -296,7 +296,7 @@ class CORE_EXPORT QgsGeometryUtils * \returns list of WKT child block strings, e.g., List("TYPE1 (contents1)", "TYPE2 (TYPE3 (contents3), TYPE4 (contents4))") * \note not available in Python bindings */ - static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = "" ) SIP_SKIP; + static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = QString() ) SIP_SKIP; /** Returns a middle point between points pt1 and pt2. * Z value is computed if one of this point have Z. diff --git a/src/core/geometry/qgslinestring.h b/src/core/geometry/qgslinestring.h index 16ff09da9037..88c0a3b7a2e5 100644 --- a/src/core/geometry/qgslinestring.h +++ b/src/core/geometry/qgslinestring.h @@ -262,4 +262,6 @@ class CORE_EXPORT QgsLineString: public QgsCurve }; +// clazy:excludeall=qstring-allocations + #endif // QGSLINESTRINGV2_H diff --git a/src/core/geometry/qgsmulticurve.h b/src/core/geometry/qgsmulticurve.h index 3ce7b7a06812..be4adf99bfbc 100644 --- a/src/core/geometry/qgsmulticurve.h +++ b/src/core/geometry/qgsmulticurve.h @@ -76,4 +76,6 @@ class CORE_EXPORT QgsMultiCurve: public QgsGeometryCollection }; +// clazy:excludeall=qstring-allocations + #endif // QGSMULTICURVEV2_H diff --git a/src/core/geometry/qgsmultilinestring.h b/src/core/geometry/qgsmultilinestring.h index 95dd9c12fd74..382ca3accf4d 100644 --- a/src/core/geometry/qgsmultilinestring.h +++ b/src/core/geometry/qgsmultilinestring.h @@ -69,4 +69,6 @@ class CORE_EXPORT QgsMultiLineString: public QgsMultiCurve bool wktOmitChildType() const override; }; +// clazy:excludeall=qstring-allocations + #endif // QGSMULTILINESTRINGV2_H diff --git a/src/core/geometry/qgsmultipoint.h b/src/core/geometry/qgsmultipoint.h index 4c6128f50714..29ff94f12cd9 100644 --- a/src/core/geometry/qgsmultipoint.h +++ b/src/core/geometry/qgsmultipoint.h @@ -71,4 +71,6 @@ class CORE_EXPORT QgsMultiPointV2: public QgsGeometryCollection }; +// clazy:excludeall=qstring-allocations + #endif // QGSMULTIPOINTV2_H diff --git a/src/core/geometry/qgsmultipolygon.h b/src/core/geometry/qgsmultipolygon.h index ac87de48aec4..105118fa5580 100644 --- a/src/core/geometry/qgsmultipolygon.h +++ b/src/core/geometry/qgsmultipolygon.h @@ -71,4 +71,6 @@ class CORE_EXPORT QgsMultiPolygonV2: public QgsMultiSurface bool wktOmitChildType() const override; }; +// clazy:excludeall=qstring-allocations + #endif // QGSMULTIPOLYGONV2_H diff --git a/src/core/geometry/qgsmultisurface.h b/src/core/geometry/qgsmultisurface.h index d69cb58265c9..1b34d4234c64 100644 --- a/src/core/geometry/qgsmultisurface.h +++ b/src/core/geometry/qgsmultisurface.h @@ -73,4 +73,6 @@ class CORE_EXPORT QgsMultiSurface: public QgsGeometryCollection }; +// clazy:excludeall=qstring-allocations + #endif // QGSMULTISURFACEV2_H diff --git a/src/core/geometry/qgspoint.cpp b/src/core/geometry/qgspoint.cpp index 34534118ad78..f16bd9e078b8 100644 --- a/src/core/geometry/qgspoint.cpp +++ b/src/core/geometry/qgspoint.cpp @@ -156,7 +156,7 @@ bool QgsPoint::fromWkt( const QString &wkt ) return false; mWkbType = parts.first; - QRegularExpression rx( "\\s" ); + QRegularExpression rx( QStringLiteral( "\\s" ) ); QStringList coordinates = parts.second.split( rx, QString::SkipEmptyParts ); if ( coordinates.size() < 2 ) { @@ -234,12 +234,12 @@ QDomElement QgsPoint::asGML2( QDomDocument &doc, int precision, const QString &n QDomElement elemCoordinates = doc.createElementNS( ns, QStringLiteral( "coordinates" ) ); // coordinate separator - QString cs = ","; + QString cs = QStringLiteral( "," ); // tupel separator - QString ts = " "; + QString ts = QStringLiteral( " " ); - elemCoordinates.setAttribute( "cs", cs ); - elemCoordinates.setAttribute( "ts", ts ); + elemCoordinates.setAttribute( QStringLiteral( "cs" ), cs ); + elemCoordinates.setAttribute( QStringLiteral( "ts" ), ts ); QString strCoordinates = qgsDoubleToString( mX, precision ) + cs + qgsDoubleToString( mY, precision ); elemCoordinates.appendChild( doc.createTextNode( strCoordinates ) ); diff --git a/src/core/geometry/qgspoint.h b/src/core/geometry/qgspoint.h index ade71e1c418e..2651c89df300 100644 --- a/src/core/geometry/qgspoint.h +++ b/src/core/geometry/qgspoint.h @@ -438,4 +438,6 @@ class CORE_EXPORT QgsPoint: public QgsAbstractGeometry double mM; }; +// clazy:excludeall=qstring-allocations + #endif // QGSPOINTV2_H diff --git a/src/core/geometry/qgstriangle.cpp b/src/core/geometry/qgstriangle.cpp index b54b75e961c8..83b20648c1b8 100644 --- a/src/core/geometry/qgstriangle.cpp +++ b/src/core/geometry/qgstriangle.cpp @@ -184,7 +184,7 @@ bool QgsTriangle::fromWkt( const QString &wkt ) mWkbType = parts.first; - QString defaultChildWkbType = QStringLiteral( "LineString%1%2" ).arg( is3D() ? "Z" : QString(), isMeasure() ? "M" : QString() ); + QString defaultChildWkbType = QStringLiteral( "LineString%1%2" ).arg( is3D() ? QStringLiteral( "Z" ) : QString(), isMeasure() ? QStringLiteral( "M" ) : QString() ); const QStringList blocks = QgsGeometryUtils::wktGetChildBlocks( parts.second, defaultChildWkbType ); for ( const QString &childWkt : blocks ) diff --git a/src/core/layertree/qgslayertreelayer.cpp b/src/core/layertree/qgslayertreelayer.cpp index a0ba7d7a6c7f..b55d8b3032ce 100644 --- a/src/core/layertree/qgslayertreelayer.cpp +++ b/src/core/layertree/qgslayertreelayer.cpp @@ -105,8 +105,8 @@ QgsLayerTreeLayer *QgsLayerTreeLayer::readXml( QDomElement &element ) QString layerID = element.attribute( QStringLiteral( "id" ) ); QString layerName = element.attribute( QStringLiteral( "name" ) ); - QString providerKey = element.attribute( "providerKey" ); - QString source = element.attribute( "source" ); + QString providerKey = element.attribute( QStringLiteral( "providerKey" ) ); + QString source = element.attribute( QStringLiteral( "source" ) ); Qt::CheckState checked = QgsLayerTreeUtils::checkStateFromXml( element.attribute( QStringLiteral( "checked" ) ) ); bool isExpanded = ( element.attribute( QStringLiteral( "expanded" ), QStringLiteral( "1" ) ) == QLatin1String( "1" ) ); @@ -138,8 +138,8 @@ void QgsLayerTreeLayer::writeXml( QDomElement &parentElement ) if ( mRef ) { - elem.setAttribute( "source", mRef->publicSource() ); - elem.setAttribute( "providerKey", mRef->dataProvider() ? mRef->dataProvider()->name() : QString() ); + elem.setAttribute( QStringLiteral( "source" ), mRef->publicSource() ); + elem.setAttribute( QStringLiteral( "providerKey" ), mRef->dataProvider() ? mRef->dataProvider()->name() : QString() ); } elem.setAttribute( QStringLiteral( "checked" ), mChecked ? QStringLiteral( "Qt::Checked" ) : QStringLiteral( "Qt::Unchecked" ) ); diff --git a/src/core/layertree/qgslayertreemodel.cpp b/src/core/layertree/qgslayertreemodel.cpp index 2c0721f75ca5..e3e9c346daa3 100644 --- a/src/core/layertree/qgslayertreemodel.cpp +++ b/src/core/layertree/qgslayertreemodel.cpp @@ -304,7 +304,7 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const if ( !layer->abstract().isEmpty() ) parts << "
" + layer->abstract().replace( QLatin1String( "\n" ), QLatin1String( "
" ) ); parts << "" + layer->publicSource() + ""; - return parts.join( "
" ); + return parts.join( QStringLiteral( "
" ) ); } } } diff --git a/src/core/layertree/qgslayertreeutils.cpp b/src/core/layertree/qgslayertreeutils.cpp index d8bb91bfefbf..cbb7c2fc525f 100644 --- a/src/core/layertree/qgslayertreeutils.cpp +++ b/src/core/layertree/qgslayertreeutils.cpp @@ -111,7 +111,7 @@ static QDomElement _writeOldLegendLayer( QDomDocument &doc, QgsLayerTreeLayer *n QDomElement layerElem = doc.createElement( QStringLiteral( "legendlayer" ) ); layerElem.setAttribute( QStringLiteral( "drawingOrder" ), drawingOrder ); - layerElem.setAttribute( QStringLiteral( "open" ), nodeLayer->isExpanded() ? "true" : "false" ); + layerElem.setAttribute( QStringLiteral( "open" ), nodeLayer->isExpanded() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); layerElem.setAttribute( QStringLiteral( "checked" ), QgsLayerTreeUtils::checkStateToXml( nodeLayer->itemVisibilityChecked() ? Qt::Checked : Qt::Unchecked ) ); layerElem.setAttribute( QStringLiteral( "name" ), nodeLayer->name() ); layerElem.setAttribute( QStringLiteral( "showFeatureCount" ), nodeLayer->customProperty( QStringLiteral( "showFeatureCount" ) ).toInt() ); @@ -170,7 +170,7 @@ static void _writeOldLegendGroupChildren( QDomDocument &doc, QDomElement &groupE QDomElement QgsLayerTreeUtils::writeOldLegend( QDomDocument &doc, QgsLayerTreeGroup *root, bool hasCustomOrder, const QList &order ) { QDomElement legendElem = doc.createElement( QStringLiteral( "legend" ) ); - legendElem.setAttribute( QStringLiteral( "updateDrawingOrder" ), hasCustomOrder ? "false" : "true" ); + legendElem.setAttribute( QStringLiteral( "updateDrawingOrder" ), hasCustomOrder ? QStringLiteral( "false" ) : QStringLiteral( "true" ) ); _writeOldLegendGroupChildren( doc, legendElem, root, hasCustomOrder, order ); diff --git a/src/core/layout/qgslayout.cpp b/src/core/layout/qgslayout.cpp index 3564c7a2200d..595ee38e7ad9 100644 --- a/src/core/layout/qgslayout.cpp +++ b/src/core/layout/qgslayout.cpp @@ -293,7 +293,7 @@ bool QgsLayout::readXmlLayoutSettings( const QDomElement &layoutElement, const Q bool QgsLayout::readXml( const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context ) { - if ( layoutElement.nodeName() != QString( "Layout" ) ) + if ( layoutElement.nodeName() != QStringLiteral( "Layout" ) ) { return false; } diff --git a/src/core/layout/qgslayoutguidecollection.cpp b/src/core/layout/qgslayoutguidecollection.cpp index a00e56e6d5c4..bc707eb7713b 100644 --- a/src/core/layout/qgslayoutguidecollection.cpp +++ b/src/core/layout/qgslayoutguidecollection.cpp @@ -197,7 +197,7 @@ QgsLayoutGuideCollection::QgsLayoutGuideCollection( QgsLayout *layout, QgsLayout , mPageCollection( pageCollection ) { QFont f; - mHeaderSize = QFontMetrics( f ).width( "XX" ); + mHeaderSize = QFontMetrics( f ).width( QStringLiteral( "XX" ) ); connect( mPageCollection, &QgsLayoutPageCollection::pageAboutToBeRemoved, this, &QgsLayoutGuideCollection::pageAboutToBeRemoved ); } diff --git a/src/core/layout/qgslayoutitem.cpp b/src/core/layout/qgslayoutitem.cpp index 44386033d3c5..d9a47549c459 100644 --- a/src/core/layout/qgslayoutitem.cpp +++ b/src/core/layout/qgslayoutitem.cpp @@ -242,8 +242,8 @@ double QgsLayoutItem::itemRotation() const bool QgsLayoutItem::writeXml( QDomElement &parentElement, QDomDocument &doc, const QgsReadWriteContext &context ) const { - QDomElement element = doc.createElement( "LayoutItem" ); - element.setAttribute( "type", stringType() ); + QDomElement element = doc.createElement( QStringLiteral( "LayoutItem" ) ); + element.setAttribute( QStringLiteral( "type" ), stringType() ); writePropertiesToElement( element, doc, context ); parentElement.appendChild( element ); @@ -253,7 +253,7 @@ bool QgsLayoutItem::writeXml( QDomElement &parentElement, QDomDocument &doc, con bool QgsLayoutItem::readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) { - if ( itemElem.nodeName() != QString( "LayoutItem" ) || itemElem.attribute( "type" ) != stringType() ) + if ( itemElem.nodeName() != QStringLiteral( "LayoutItem" ) || itemElem.attribute( QStringLiteral( "type" ) ) != stringType() ) { return false; } diff --git a/src/core/layout/qgslayoutitempage.cpp b/src/core/layout/qgslayoutitempage.cpp index 47bd59cdf497..04af50c8f06f 100644 --- a/src/core/layout/qgslayoutitempage.cpp +++ b/src/core/layout/qgslayoutitempage.cpp @@ -37,7 +37,7 @@ QgsLayoutItemPage::QgsLayoutItemPage( QgsLayout *layout ) QFont font; QFontMetrics fm( font ); - mMaximumShadowWidth = fm.width( "X" ); + mMaximumShadowWidth = fm.width( QStringLiteral( "X" ) ); mGrid.reset( new QgsLayoutItemPageGrid( pos().x(), pos().y(), rect().width(), rect().height(), mLayout ) ); mGrid->setParentItem( this ); diff --git a/src/core/locator/qgslocatormodel.cpp b/src/core/locator/qgslocatormodel.cpp index f3e72859669d..aee581530c82 100644 --- a/src/core/locator/qgslocatormodel.cpp +++ b/src/core/locator/qgslocatormodel.cpp @@ -96,7 +96,7 @@ QVariant QgsLocatorModel::data( const QModelIndex &index, int role ) const QIcon icon = mResults.at( index.row() ).result.icon; if ( !icon.isNull() ) return icon; - return QgsApplication::getThemeIcon( "/search.svg" ); + return QgsApplication::getThemeIcon( QStringLiteral( "/search.svg" ) ); } else return QVariant(); diff --git a/src/core/metadata/qgslayermetadata.cpp b/src/core/metadata/qgslayermetadata.cpp index cd1664b8566a..1a9552c37a4f 100644 --- a/src/core/metadata/qgslayermetadata.cpp +++ b/src/core/metadata/qgslayermetadata.cpp @@ -180,9 +180,9 @@ QStringList QgsLayerMetadata::keywords( const QString &vocabulary ) const QStringList QgsLayerMetadata::categories() const { - if ( mKeywords.contains( "gmd:topicCategory" ) ) + if ( mKeywords.contains( QStringLiteral( "gmd:topicCategory" ) ) ) { - return mKeywords.value( "gmd:topicCategory" ); + return mKeywords.value( QStringLiteral( "gmd:topicCategory" ) ); } else { @@ -192,7 +192,7 @@ QStringList QgsLayerMetadata::categories() const void QgsLayerMetadata::setCategories( const QStringList &category ) { - mKeywords.insert( "gmd:topicCategory", category ); + mKeywords.insert( QStringLiteral( "gmd:topicCategory" ), category ); } QList QgsLayerMetadata::contacts() const @@ -410,8 +410,8 @@ bool QgsLayerMetadata::readMetadataXml( const QDomElement &metadataElement ) QDomNodeList periodList = mnl.toElement().elementsByTagName( QStringLiteral( "period" ) ); for ( int i = 0; i < periodList.size(); i++ ) { - QDomNode begin = periodList.at( i ).namedItem( "start" ); - QDomNode end = periodList.at( i ).namedItem( "end" ); + QDomNode begin = periodList.at( i ).namedItem( QStringLiteral( "start" ) ); + QDomNode end = periodList.at( i ).namedItem( QStringLiteral( "end" ) ); QDateTime beginDate = QDateTime().fromString( begin.toElement().text(), Qt::ISODate ); QDateTime endDate = QDateTime().fromString( end.toElement().text(), Qt::ISODate ); QgsDateTimeRange date = QgsDateTimeRange( beginDate, endDate ); diff --git a/src/core/metadata/qgslayermetadataformatter.cpp b/src/core/metadata/qgslayermetadataformatter.cpp index f031ddc66310..bc25a7572477 100644 --- a/src/core/metadata/qgslayermetadataformatter.cpp +++ b/src/core/metadata/qgslayermetadataformatter.cpp @@ -12,10 +12,10 @@ QgsLayerMetadataFormatter::QgsLayerMetadataFormatter( const QgsLayerMetadata &me QString QgsLayerMetadataFormatter::accessSectionHtml() const { QString myMetadata = QStringLiteral( "
\n" ); - myMetadata += QLatin1String( "\n" ); - myMetadata += QLatin1String( "\n" ); - myMetadata += QLatin1String( "\n" ); - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); + myMetadata += QStringLiteral( "\n" ); + myMetadata += QStringLiteral( "\n" ); - mMetadata.rights().join( QStringLiteral( "
" ) ) + QLatin1String( "\n" ); + mMetadata.rights().join( QStringLiteral( "
" ) ) + QStringLiteral( "\n" ); myMetadata += QLatin1String( "
" ) + QObject::tr( "Fees" ) + QLatin1String( "" ) + mMetadata.fees() + QLatin1String( "
" ) + QObject::tr( "Licenses" ) + QLatin1String( "" ) + mMetadata.licenses().join( QStringLiteral( "
" ) ) + QLatin1String( "
" ) + QObject::tr( "Rights" ) + QLatin1String( "" ) + mMetadata.rights().join( QStringLiteral( "
" ) ) + QLatin1String( "
" ) + QObject::tr( "Constraints" ) + QLatin1String( "" ); + myMetadata += QStringLiteral( "
" ) + QObject::tr( "Fees" ) + QStringLiteral( "" ) + mMetadata.fees() + QStringLiteral( "
" ) + QObject::tr( "Licenses" ) + QStringLiteral( "" ) + mMetadata.licenses().join( QStringLiteral( "
" ) ) + QStringLiteral( "
" ) + QObject::tr( "Rights" ) + QStringLiteral( "" ) + mMetadata.rights().join( QStringLiteral( "
" ) ) + QStringLiteral( "
" ) + QObject::tr( "Constraints" ) + QStringLiteral( "" ); const QList &constraints = mMetadata.constraints(); bool notFirstRow = false; for ( const QgsLayerMetadata::Constraint &constraint : constraints ) @@ -24,11 +24,11 @@ QString QgsLayerMetadataFormatter::accessSectionHtml() const { myMetadata += QLatin1String( "
" ); } - myMetadata += QLatin1String( "" ) + constraint.type + QLatin1String( ": " ) + constraint.constraint; + myMetadata += QStringLiteral( "" ) + constraint.type + QStringLiteral( ": " ) + constraint.constraint; notFirstRow = true; } myMetadata += QLatin1String( "
\n" ); return myMetadata; } @@ -39,7 +39,7 @@ QString QgsLayerMetadataFormatter::contactsSectionHtml() const QString myMetadata; if ( contacts.isEmpty() ) { - myMetadata += QLatin1String( "

" ) + QObject::tr( "No contact yet." ) + QLatin1String( "

" ); + myMetadata += QStringLiteral( "

" ) + QObject::tr( "No contact yet." ) + QStringLiteral( "

" ); } else { @@ -50,7 +50,7 @@ QString QgsLayerMetadataFormatter::contactsSectionHtml() const { QString rowClass; if ( i % 2 ) - rowClass = QString( "class=\"odd-row\"" ); + rowClass = QStringLiteral( "class=\"odd-row\"" ); myMetadata += "" + QString::number( i ) + "" + contact.name + "" + contact.position + "" + contact.organization + "" + contact.role + "" + contact.email + "" + contact.voice + "" + contact.fax + ""; bool notFirstRow = false; for ( const QgsLayerMetadata::Address &oneAddress : contact.addresses ) @@ -61,23 +61,23 @@ QString QgsLayerMetadataFormatter::contactsSectionHtml() const } if ( ! oneAddress.type.isEmpty() ) { - myMetadata += oneAddress.type + QLatin1String( "
" ); + myMetadata += oneAddress.type + QStringLiteral( "
" ); } if ( ! oneAddress.address.isEmpty() ) { - myMetadata += oneAddress.address + QLatin1String( "
" ); + myMetadata += oneAddress.address + QStringLiteral( "
" ); } if ( ! oneAddress.postalCode.isEmpty() ) { - myMetadata += oneAddress.postalCode + QLatin1String( "
" ); + myMetadata += oneAddress.postalCode + QStringLiteral( "
" ); } if ( ! oneAddress.city.isEmpty() ) { - myMetadata += oneAddress.city + QLatin1String( "
" ); + myMetadata += oneAddress.city + QStringLiteral( "
" ); } if ( ! oneAddress.administrativeArea.isEmpty() ) { - myMetadata += oneAddress.administrativeArea + QLatin1String( "
" ); + myMetadata += oneAddress.administrativeArea + QStringLiteral( "
" ); } if ( ! oneAddress.country.isEmpty() ) { @@ -85,7 +85,7 @@ QString QgsLayerMetadataFormatter::contactsSectionHtml() const } notFirstRow = true; } - myMetadata += "\n"; + myMetadata += QLatin1String( "\n" ); i++; } myMetadata += QLatin1String( "\n" ); @@ -96,8 +96,8 @@ QString QgsLayerMetadataFormatter::contactsSectionHtml() const QString QgsLayerMetadataFormatter::extentSectionHtml() const { QString myMetadata = QStringLiteral( "\n" ); - myMetadata += QStringLiteral( "\n" ); const QgsLayerMetadata::Extent extent = mMetadata.extent(); - myMetadata += QStringLiteral( "\n" ); - myMetadata += QStringLiteral( "
" ) + QObject::tr( "CRS" ) + QLatin1String( "" ) + mMetadata.crs().authid() + QLatin1String( " - " ); - myMetadata += mMetadata.crs().description() + QLatin1String( " - " ); + myMetadata += QStringLiteral( "
" ) + QObject::tr( "CRS" ) + QStringLiteral( "" ) + mMetadata.crs().authid() + QStringLiteral( " - " ); + myMetadata += mMetadata.crs().description() + QStringLiteral( " - " ); if ( mMetadata.crs().isGeographic() ) myMetadata += QObject::tr( "Geographic" ); else @@ -105,7 +105,7 @@ QString QgsLayerMetadataFormatter::extentSectionHtml() const myMetadata += QLatin1String( "
" ) + QObject::tr( "Spatial Extent" ) + QLatin1String( "" ); + myMetadata += QStringLiteral( "
" ) + QObject::tr( "Spatial Extent" ) + QStringLiteral( "" ); const QList< QgsLayerMetadata::SpatialExtent > spatialExtents = extent.spatialExtents(); bool notFirstRow = false; for ( const QgsLayerMetadata::SpatialExtent &spatialExtent : spatialExtents ) @@ -114,8 +114,8 @@ QString QgsLayerMetadataFormatter::extentSectionHtml() const { myMetadata += QLatin1String( "
\n" ); } - myMetadata += QStringLiteral( "" ) + QObject::tr( "CRS" ) + QStringLiteral( ": " ) + spatialExtent.extentCrs.authid() + QLatin1String( " - " ); - myMetadata += spatialExtent.extentCrs.description() + QLatin1String( " - " ); + myMetadata += QStringLiteral( "" ) + QObject::tr( "CRS" ) + QStringLiteral( ": " ) + spatialExtent.extentCrs.authid() + QStringLiteral( " - " ); + myMetadata += spatialExtent.extentCrs.description() + QStringLiteral( " - " ); if ( spatialExtent.extentCrs.isGeographic() ) myMetadata += QObject::tr( "Geographic" ); else @@ -133,7 +133,7 @@ QString QgsLayerMetadataFormatter::extentSectionHtml() const notFirstRow = true; } myMetadata += QLatin1String( "
" ) + QObject::tr( "Temporal Extent" ) + QLatin1String( "" ); + myMetadata += QStringLiteral( "
" ) + QObject::tr( "Temporal Extent" ) + QStringLiteral( "" ); const QList< QgsDateTimeRange > temporalExtents = extent.temporalExtents(); notFirstRow = false; for ( const QgsDateTimeRange &temporalExtent : temporalExtents ) @@ -163,28 +163,28 @@ QString QgsLayerMetadataFormatter::identificationSectionHtml() const QString myMetadata = QStringLiteral( "\n" ); // Identifier - myMetadata += QStringLiteral( "\n" ); + myMetadata += QStringLiteral( "\n" ); // Parent Identifier - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // Title - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // Type - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // Language - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // Abstract - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // Categories - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // Keywords - myMetadata += QLatin1String( "\n"; j++; } @@ -213,7 +213,7 @@ QString QgsLayerMetadataFormatter::historySectionHtml() const const QStringList historyItems = mMetadata.history(); if ( historyItems.isEmpty() ) { - myMetadata += QLatin1String( "

" ) + QObject::tr( "No history yet." ) + QLatin1String( "

\n" ); + myMetadata += QStringLiteral( "

" ) + QObject::tr( "No history yet." ) + QStringLiteral( "

\n" ); } else { @@ -224,7 +224,7 @@ QString QgsLayerMetadataFormatter::historySectionHtml() const { QString rowClass; if ( i % 2 ) - rowClass = QString( "class=\"odd-row\"" ); + rowClass = QStringLiteral( "class=\"odd-row\"" ); myMetadata += "\n"; i++; } @@ -239,7 +239,7 @@ QString QgsLayerMetadataFormatter::linksSectionHtml() const const QList &links = mMetadata.links(); if ( links.isEmpty() ) { - myMetadata += QLatin1String( "

" ) + QObject::tr( "No links yet." ) + QLatin1String( "

\n" ); + myMetadata += QStringLiteral( "

" ) + QObject::tr( "No links yet." ) + QStringLiteral( "

\n" ); } else { @@ -250,7 +250,7 @@ QString QgsLayerMetadataFormatter::linksSectionHtml() const { QString rowClass; if ( i % 2 ) - rowClass = QString( "class=\"odd-row\"" ); + rowClass = QStringLiteral( "class=\"odd-row\"" ); myMetadata += "
\n"; i++; } diff --git a/src/core/processing/models/qgsprocessingmodelalgorithm.cpp b/src/core/processing/models/qgsprocessingmodelalgorithm.cpp index 98985fdcc3f5..5e1b175cab27 100644 --- a/src/core/processing/models/qgsprocessingmodelalgorithm.cpp +++ b/src/core/processing/models/qgsprocessingmodelalgorithm.cpp @@ -341,7 +341,7 @@ QString QgsProcessingModelAlgorithm::asPythonCode() const auto safeName = []( const QString & name )->QString { QString n = name.toLower().trimmed(); - QRegularExpression rx( "[^a-z_]" ); + QRegularExpression rx( QStringLiteral( "[^a-z_]" ) ); n.replace( rx, QString() ); return n; }; @@ -416,7 +416,7 @@ QMap QgsProcessingMode auto safeName = []( const QString & name )->QString { QString s = name; - return s.replace( QRegularExpression( "[\\s'\"\\(\\):]" ), QStringLiteral( "_" ) ); + return s.replace( QRegularExpression( QStringLiteral( "[\\s'\"\\(\\):]" ) ), QStringLiteral( "_" ) ); }; // "static"/single value sources @@ -789,7 +789,7 @@ QVariant QgsProcessingModelAlgorithm::toVariant() const { childMap.insert( childIt.key(), childIt.value().toVariant() ); } - map.insert( "children", childMap ); + map.insert( QStringLiteral( "children" ), childMap ); QVariantMap paramMap; QMap< QString, QgsProcessingModelParameter >::const_iterator paramIt = mParameterComponents.constBegin(); @@ -797,14 +797,14 @@ QVariant QgsProcessingModelAlgorithm::toVariant() const { paramMap.insert( paramIt.key(), paramIt.value().toVariant() ); } - map.insert( "parameters", paramMap ); + map.insert( QStringLiteral( "parameters" ), paramMap ); QVariantMap paramDefMap; Q_FOREACH ( const QgsProcessingParameterDefinition *def, mParameters ) { paramDefMap.insert( def->name(), def->toVariantMap() ); } - map.insert( "parameterDefinitions", paramDefMap ); + map.insert( QStringLiteral( "parameterDefinitions" ), paramDefMap ); return map; } @@ -865,7 +865,7 @@ bool QgsProcessingModelAlgorithm::loadVariant( const QVariant &model ) bool QgsProcessingModelAlgorithm::toFile( const QString &path ) const { - QDomDocument doc = QDomDocument( "model" ); + QDomDocument doc = QDomDocument( QStringLiteral( "model" ) ); QDomElement elem = QgsXmlUtils::writeVariant( toVariant(), doc ); doc.appendChild( elem ); diff --git a/src/core/processing/models/qgsprocessingmodelchildalgorithm.cpp b/src/core/processing/models/qgsprocessingmodelchildalgorithm.cpp index 0ff87496d9cd..f5f8074c88e4 100644 --- a/src/core/processing/models/qgsprocessingmodelchildalgorithm.cpp +++ b/src/core/processing/models/qgsprocessingmodelchildalgorithm.cpp @@ -97,7 +97,7 @@ QVariant QgsProcessingModelChildAlgorithm::toVariant() const } paramMap.insert( paramIt.key(), sources ); } - map.insert( "params", paramMap ); + map.insert( QStringLiteral( "params" ), paramMap ); QVariantMap outputMap; QMap< QString, QgsProcessingModelOutput >::const_iterator outputIt = mModelOutputs.constBegin(); @@ -105,7 +105,7 @@ QVariant QgsProcessingModelChildAlgorithm::toVariant() const { outputMap.insert( outputIt.key(), outputIt.value().toVariant() ); } - map.insert( "outputs", outputMap ); + map.insert( QStringLiteral( "outputs" ), outputMap ); return map; } diff --git a/src/core/processing/qgsprocessingalgorithm.cpp b/src/core/processing/qgsprocessingalgorithm.cpp index 8ebadca65eae..684cb69ca998 100644 --- a/src/core/processing/qgsprocessingalgorithm.cpp +++ b/src/core/processing/qgsprocessingalgorithm.cpp @@ -44,7 +44,7 @@ QgsProcessingAlgorithm *QgsProcessingAlgorithm::create( const QVariantMap &confi QString QgsProcessingAlgorithm::id() const { if ( mProvider ) - return QString( "%1:%2" ).arg( mProvider->id(), name() ); + return QStringLiteral( "%1:%2" ).arg( mProvider->id(), name() ); else return name(); } @@ -71,7 +71,7 @@ QIcon QgsProcessingAlgorithm::icon() const QString QgsProcessingAlgorithm::svgIconPath() const { - return QgsApplication::iconPath( "processingAlgorithm.svg" ); + return QgsApplication::iconPath( QStringLiteral( "processingAlgorithm.svg" ) ); } QgsProcessingAlgorithm::Flags QgsProcessingAlgorithm::flags() const diff --git a/src/core/processing/qgsprocessingalgorithm.h b/src/core/processing/qgsprocessingalgorithm.h index d13aa80b6395..dcee1dcc55e1 100644 --- a/src/core/processing/qgsprocessingalgorithm.h +++ b/src/core/processing/qgsprocessingalgorithm.h @@ -876,6 +876,8 @@ class CORE_EXPORT QgsProcessingFeatureBasedAlgorithm : public QgsProcessingAlgor }; +// clazy:excludeall=qstring-allocations + #endif // QGSPROCESSINGALGORITHM_H diff --git a/src/core/processing/qgsprocessingparameters.cpp b/src/core/processing/qgsprocessingparameters.cpp index 356e04c10309..8d3133d9f80b 100644 --- a/src/core/processing/qgsprocessingparameters.cpp +++ b/src/core/processing/qgsprocessingparameters.cpp @@ -1141,7 +1141,7 @@ QgsProcessingParameterDefinition *QgsProcessingParameters::parameterFromScriptCo bool QgsProcessingParameters::parseScriptCodeParameterOptions( const QString &code, bool &isOptional, QString &name, QString &type, QString &definition ) { - QRegularExpression re( "(?:#*)(.*?)=\\s*(.*)" ); + QRegularExpression re( QStringLiteral( "(?:#*)(.*?)=\\s*(.*)" ) ); QRegularExpressionMatch m = re.match( code ); if ( !m.hasMatch() ) return false; @@ -1160,7 +1160,7 @@ bool QgsProcessingParameters::parseScriptCodeParameterOptions( const QString &co tokens = tokens.trimmed(); - QRegularExpression re2( "(.*?)\\s+(.*)" ); + QRegularExpression re2( QStringLiteral( "(.*?)\\s+(.*)" ) ); m = re2.match( tokens ); if ( !m.hasMatch() ) { @@ -1922,7 +1922,7 @@ QgsProcessingParameterMultipleLayers *QgsProcessingParameterMultipleLayers::from { QString type = definition; QString defaultVal; - QRegularExpression re( "(.*?)\\s+(.*)" ); + QRegularExpression re( QStringLiteral( "(.*?)\\s+(.*)" ) ); QRegularExpressionMatch m = re.match( definition ); if ( m.hasMatch() ) { @@ -2349,7 +2349,7 @@ QgsProcessingParameterEnum *QgsProcessingParameterEnum::fromScriptCode( const QS def = def.mid( 9 ); } - QRegularExpression re( "(.*)\\s+(.*?)$" ); + QRegularExpression re( QStringLiteral( "(.*)\\s+(.*?)$" ) ); QRegularExpressionMatch m = re.match( def ); QString values = def; if ( m.hasMatch() ) @@ -2788,7 +2788,7 @@ QgsProcessingParameterField *QgsProcessingParameterField::fromScriptCode( const def = def.mid( 8 ).trimmed(); } - QRegularExpression re( "(.*?)\\s+(.*)$" ); + QRegularExpression re( QStringLiteral( "(.*?)\\s+(.*)$" ) ); QRegularExpressionMatch m = re.match( def ); if ( m.hasMatch() ) { @@ -3320,7 +3320,7 @@ QString QgsProcessingParameterFileDestination::defaultFileExtension() const return QStringLiteral( "file" ); // get first extension from filter - QRegularExpression rx( ".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ); + QRegularExpression rx( QStringLiteral( ".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) ); QRegularExpressionMatch match = rx.match( mFileFilter ); if ( !match.hasMatch() ) return QStringLiteral( "file" ); @@ -3700,7 +3700,7 @@ QgsProcessingParameterBand *QgsProcessingParameterBand::fromScriptCode( const QS QString parent; QString def = definition; - QRegularExpression re( "(.*?)\\s+(.*)$" ); + QRegularExpression re( QStringLiteral( "(.*?)\\s+(.*)$" ) ); QRegularExpressionMatch m = re.match( def ); if ( m.hasMatch() ) { diff --git a/src/core/processing/qgsprocessingparameters.h b/src/core/processing/qgsprocessingparameters.h index 014105f24826..d019f869a0f6 100644 --- a/src/core/processing/qgsprocessingparameters.h +++ b/src/core/processing/qgsprocessingparameters.h @@ -1976,6 +1976,8 @@ class CORE_EXPORT QgsProcessingParameterBand : public QgsProcessingParameterDefi QString mParentLayerParameterName; }; +// clazy:excludeall=qstring-allocations + #endif // QGSPROCESSINGPARAMETERS_H diff --git a/src/core/processing/qgsprocessingprovider.cpp b/src/core/processing/qgsprocessingprovider.cpp index 1a9a4c042078..a66bae0b951b 100644 --- a/src/core/processing/qgsprocessingprovider.cpp +++ b/src/core/processing/qgsprocessingprovider.cpp @@ -36,7 +36,7 @@ QIcon QgsProcessingProvider::icon() const QString QgsProcessingProvider::svgIconPath() const { - return QgsApplication::iconPath( "processingAlgorithm.svg" ); + return QgsApplication::iconPath( QStringLiteral( "processingAlgorithm.svg" ) ); } void QgsProcessingProvider::refreshAlgorithms() diff --git a/src/core/processing/qgsprocessingutils.cpp b/src/core/processing/qgsprocessingutils.cpp index 3004b99deac5..59dadc683fb8 100644 --- a/src/core/processing/qgsprocessingutils.cpp +++ b/src/core/processing/qgsprocessingutils.cpp @@ -282,13 +282,13 @@ QString QgsProcessingUtils::normalizeLayerSource( const QString &source ) { QString normalized = source; normalized.replace( '\\', '/' ); - normalized.replace( '"', "'" ); + normalized.replace( '"', QLatin1String( "'" ) ); return normalized.trimmed(); } void parseDestinationString( QString &destination, QString &providerKey, QString &uri, QString &format, QMap &options ) { - QRegularExpression splitRx( "^(.{3,}):(.*)$" ); + QRegularExpression splitRx( QStringLiteral( "^(.{3,}):(.*)$" ) ); QRegularExpressionMatch match = splitRx.match( destination ); if ( match.hasMatch() ) { @@ -302,7 +302,7 @@ void parseDestinationString( QString &destination, QString &providerKey, QString else { providerKey = QStringLiteral( "ogr" ); - QRegularExpression splitRx( "^(.*)\\.(.*?)$" ); + QRegularExpression splitRx( QStringLiteral( "^(.*)\\.(.*?)$" ) ); QRegularExpressionMatch match = splitRx.match( destination ); QString extension; if ( match.hasMatch() ) @@ -359,7 +359,7 @@ QgsFeatureSink *QgsProcessingUtils::createFeatureSink( QString &destination, Qgs QString format; parseDestinationString( destination, providerKey, uri, format, options ); - if ( providerKey == "ogr" ) + if ( providerKey == QLatin1String( "ogr" ) ) { // use QgsVectorFileWriter for OGR destinations instead of QgsVectorLayerImport, as that allows // us to use any OGR format which supports feature addition @@ -511,7 +511,7 @@ QString QgsProcessingUtils::formatHelpMapAsHtml( const QVariantMap &map, const Q s += QStringLiteral( "

" ) + def->description() + QStringLiteral( "

\n" ); s += QStringLiteral( "

" ) + getText( def->name() ) + QStringLiteral( "

\n" ); } - s += "
"; + s += QLatin1String( "
" ); s += QObject::tr( "

Algorithm author: %1

" ).arg( getText( QStringLiteral( "ALG_CREATOR" ) ) ); s += QObject::tr( "

Help author: %1

" ).arg( getText( QStringLiteral( "ALG_HELP_CREATOR" ) ) ); s += QObject::tr( "

Algorithm version: %1

" ).arg( getText( QStringLiteral( "ALG_VERSION" ) ) ); diff --git a/src/core/qgsaction.cpp b/src/core/qgsaction.cpp index 827d749b5db9..3f869cc45c4b 100644 --- a/src/core/qgsaction.cpp +++ b/src/core/qgsaction.cpp @@ -95,7 +95,7 @@ void QgsAction::setActionScopes( const QSet &actionScopes ) void QgsAction::readXml( const QDomNode &actionNode ) { QDomElement actionElement = actionNode.toElement(); - QDomNodeList actionScopeNodes = actionElement.elementsByTagName( "actionScope" ); + QDomNodeList actionScopeNodes = actionElement.elementsByTagName( QStringLiteral( "actionScope" ) ); if ( actionScopeNodes.isEmpty() ) { @@ -109,7 +109,7 @@ void QgsAction::readXml( const QDomNode &actionNode ) for ( int j = 0; j < actionScopeNodes.length(); ++j ) { QDomElement actionScopeElem = actionScopeNodes.item( j ).toElement(); - mActionScopes << actionScopeElem.attribute( "id" ); + mActionScopes << actionScopeElem.attribute( QStringLiteral( "id" ) ); } } @@ -139,8 +139,8 @@ void QgsAction::writeXml( QDomNode &actionsNode ) const Q_FOREACH ( const QString &scope, mActionScopes ) { - QDomElement actionScopeElem = actionsNode.ownerDocument().createElement( "actionScope" ); - actionScopeElem.setAttribute( "id", scope ); + QDomElement actionScopeElem = actionsNode.ownerDocument().createElement( QStringLiteral( "actionScope" ) ); + actionScopeElem.setAttribute( QStringLiteral( "id" ), scope ); actionSetting.appendChild( actionScopeElem ); } diff --git a/src/core/qgsactionmanager.cpp b/src/core/qgsactionmanager.cpp index ac8fa8a86978..084b27739bcc 100644 --- a/src/core/qgsactionmanager.cpp +++ b/src/core/qgsactionmanager.cpp @@ -256,12 +256,12 @@ bool QgsActionManager::readXml( const QDomNode &layer_node ) addAction( action ); } - QDomNodeList defaultActionNodes = aaNode.toElement().elementsByTagName( "defaultAction" ); + QDomNodeList defaultActionNodes = aaNode.toElement().elementsByTagName( QStringLiteral( "defaultAction" ) ); for ( int i = 0; i < defaultActionNodes.size(); ++i ) { QDomElement defaultValueElem = defaultActionNodes.at( i ).toElement(); - mDefaultActions.insert( defaultValueElem.attribute( "key" ), defaultValueElem.attribute( "value" ) ); + mDefaultActions.insert( defaultValueElem.attribute( QStringLiteral( "key" ) ), defaultValueElem.attribute( QStringLiteral( "value" ) ) ); } } return true; diff --git a/src/core/qgsapplication.h b/src/core/qgsapplication.h index 3da119dc594d..03bedf36d3fd 100644 --- a/src/core/qgsapplication.h +++ b/src/core/qgsapplication.h @@ -735,4 +735,6 @@ class CORE_EXPORT QgsApplication : public QApplication static ApplicationMembers *members(); }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/core/qgscolorramp.h b/src/core/qgscolorramp.h index 3bacf474ddca..3750cce943cb 100644 --- a/src/core/qgscolorramp.h +++ b/src/core/qgscolorramp.h @@ -630,5 +630,6 @@ class CORE_EXPORT QgsCptCityColorRamp : public QgsGradientColorRamp }; +// clazy:excludeall=qstring-allocations #endif diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index 89e25c51cffa..e3875aa7a109 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -120,7 +120,7 @@ QList QgsCoordinateReferenceSystem::validSrsIds() continue; } - QString sql = "select srs_id from tbl_srs"; + QString sql = QStringLiteral( "select srs_id from tbl_srs" ); ( void )sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &statement, &tail ); diff --git a/src/core/qgsdatadefinedsizelegend.cpp b/src/core/qgsdatadefinedsizelegend.cpp index cff5d55fd7d3..8aa27d0e1bb3 100644 --- a/src/core/qgsdatadefinedsizelegend.cpp +++ b/src/core/qgsdatadefinedsizelegend.cpp @@ -317,18 +317,18 @@ QgsDataDefinedSizeLegend *QgsDataDefinedSizeLegend::readXml( const QDomElement & if ( elem.isNull() ) return nullptr; QgsDataDefinedSizeLegend *ddsLegend = new QgsDataDefinedSizeLegend; - ddsLegend->setLegendType( elem.attribute( "type" ) == "collapsed" ? LegendCollapsed : LegendSeparated ); - ddsLegend->setVerticalAlignment( elem.attribute( "valign" ) == "center" ? AlignCenter : AlignBottom ); - ddsLegend->setTitle( elem.attribute( "title" ) ); + ddsLegend->setLegendType( elem.attribute( QStringLiteral( "type" ) ) == QLatin1String( "collapsed" ) ? LegendCollapsed : LegendSeparated ); + ddsLegend->setVerticalAlignment( elem.attribute( QStringLiteral( "valign" ) ) == QLatin1String( "center" ) ? AlignCenter : AlignBottom ); + ddsLegend->setTitle( elem.attribute( QStringLiteral( "title" ) ) ); - QDomElement elemSymbol = elem.firstChildElement( "symbol" ); + QDomElement elemSymbol = elem.firstChildElement( QStringLiteral( "symbol" ) ); if ( !elemSymbol.isNull() ) { ddsLegend->setSymbol( QgsSymbolLayerUtils::loadSymbol( elemSymbol, context ) ); } QgsSizeScaleTransformer *transformer = nullptr; - QDomElement elemTransformer = elem.firstChildElement( "transformer" ); + QDomElement elemTransformer = elem.firstChildElement( QStringLiteral( "transformer" ) ); if ( !elemTransformer.isNull() ) { transformer = new QgsSizeScaleTransformer; @@ -336,27 +336,27 @@ QgsDataDefinedSizeLegend *QgsDataDefinedSizeLegend::readXml( const QDomElement & } ddsLegend->setSizeScaleTransformer( transformer ); - QDomElement elemTextStyle = elem.firstChildElement( "text-style" ); + QDomElement elemTextStyle = elem.firstChildElement( QStringLiteral( "text-style" ) ); if ( !elemTextStyle.isNull() ) { - QDomElement elemFont = elemTextStyle.firstChildElement( "font" ); + QDomElement elemFont = elemTextStyle.firstChildElement( QStringLiteral( "font" ) ); if ( !elemFont.isNull() ) { - ddsLegend->setFont( QFont( elemFont.attribute( "family" ), elemFont.attribute( "size" ).toInt(), - elemFont.attribute( "weight" ).toInt(), elemFont.attribute( "italic" ).toInt() ) ); + ddsLegend->setFont( QFont( elemFont.attribute( QStringLiteral( "family" ) ), elemFont.attribute( QStringLiteral( "size" ) ).toInt(), + elemFont.attribute( QStringLiteral( "weight" ) ).toInt(), elemFont.attribute( QStringLiteral( "italic" ) ).toInt() ) ); } - ddsLegend->setTextColor( QgsSymbolLayerUtils::decodeColor( elemTextStyle.attribute( "color" ) ) ); - ddsLegend->setTextAlignment( static_cast( elemTextStyle.attribute( "align" ).toInt() ) ); + ddsLegend->setTextColor( QgsSymbolLayerUtils::decodeColor( elemTextStyle.attribute( QStringLiteral( "color" ) ) ) ); + ddsLegend->setTextAlignment( static_cast( elemTextStyle.attribute( QStringLiteral( "align" ) ).toInt() ) ); } - QDomElement elemClasses = elem.firstChildElement( "classes" ); + QDomElement elemClasses = elem.firstChildElement( QStringLiteral( "classes" ) ); if ( !elemClasses.isNull() ) { QList classes; - QDomElement elemClass = elemClasses.firstChildElement( "class" ); + QDomElement elemClass = elemClasses.firstChildElement( QStringLiteral( "class" ) ); while ( !elemClass.isNull() ) { - classes << SizeClass( elemClass.attribute( "size" ).toDouble(), elemClass.attribute( "label" ) ); + classes << SizeClass( elemClass.attribute( QStringLiteral( "size" ) ).toDouble(), elemClass.attribute( QStringLiteral( "label" ) ) ); elemClass = elemClass.nextSiblingElement(); } ddsLegend->setClasses( classes ); @@ -369,43 +369,43 @@ void QgsDataDefinedSizeLegend::writeXml( QDomElement &elem, const QgsReadWriteCo { QDomDocument doc = elem.ownerDocument(); - elem.setAttribute( "type", mType == LegendCollapsed ? "collapsed" : "separated" ); - elem.setAttribute( "valign", mVAlign == AlignCenter ? "center" : "bottom" ); - elem.setAttribute( "title", mTitleLabel ); + elem.setAttribute( QStringLiteral( "type" ), mType == LegendCollapsed ? "collapsed" : "separated" ); + elem.setAttribute( QStringLiteral( "valign" ), mVAlign == AlignCenter ? "center" : "bottom" ); + elem.setAttribute( QStringLiteral( "title" ), mTitleLabel ); if ( mSymbol ) { - QDomElement elemSymbol = QgsSymbolLayerUtils::saveSymbol( "source", mSymbol.get(), doc, context ); + QDomElement elemSymbol = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "source" ), mSymbol.get(), doc, context ); elem.appendChild( elemSymbol ); } if ( mSizeScaleTransformer ) { QDomElement elemTransformer = QgsXmlUtils::writeVariant( mSizeScaleTransformer->toVariant(), doc ); - elemTransformer.setTagName( "transformer" ); + elemTransformer.setTagName( QStringLiteral( "transformer" ) ); elem.appendChild( elemTransformer ); } - QDomElement elemFont = doc.createElement( "font" ); - elemFont.setAttribute( "family", mFont.family() ); - elemFont.setAttribute( "size", mFont.pointSize() ); - elemFont.setAttribute( "weight", mFont.weight() ); - elemFont.setAttribute( "italic", mFont.italic() ); + QDomElement elemFont = doc.createElement( QStringLiteral( "font" ) ); + elemFont.setAttribute( QStringLiteral( "family" ), mFont.family() ); + elemFont.setAttribute( QStringLiteral( "size" ), mFont.pointSize() ); + elemFont.setAttribute( QStringLiteral( "weight" ), mFont.weight() ); + elemFont.setAttribute( QStringLiteral( "italic" ), mFont.italic() ); - QDomElement elemTextStyle = doc.createElement( "text-style" ); - elemTextStyle.setAttribute( "color", QgsSymbolLayerUtils::encodeColor( mTextColor ) ); - elemTextStyle.setAttribute( "align", static_cast( mTextAlignment ) ); + QDomElement elemTextStyle = doc.createElement( QStringLiteral( "text-style" ) ); + elemTextStyle.setAttribute( QStringLiteral( "color" ), QgsSymbolLayerUtils::encodeColor( mTextColor ) ); + elemTextStyle.setAttribute( QStringLiteral( "align" ), static_cast( mTextAlignment ) ); elemTextStyle.appendChild( elemFont ); elem.appendChild( elemTextStyle ); if ( !mSizeClasses.isEmpty() ) { - QDomElement elemClasses = doc.createElement( "classes" ); + QDomElement elemClasses = doc.createElement( QStringLiteral( "classes" ) ); Q_FOREACH ( const SizeClass &sc, mSizeClasses ) { - QDomElement elemClass = doc.createElement( "class" ); - elemClass.setAttribute( "size", sc.size ); - elemClass.setAttribute( "label", sc.label ); + QDomElement elemClass = doc.createElement( QStringLiteral( "class" ) ); + elemClass.setAttribute( QStringLiteral( "size" ), sc.size ); + elemClass.setAttribute( QStringLiteral( "label" ), sc.label ); elemClasses.appendChild( elemClass ); } elem.appendChild( elemClasses ); diff --git a/src/core/qgsdiagramrenderer.cpp b/src/core/qgsdiagramrenderer.cpp index fd081c9a3994..03fd550fa0e2 100644 --- a/src/core/qgsdiagramrenderer.cpp +++ b/src/core/qgsdiagramrenderer.cpp @@ -113,7 +113,7 @@ void QgsDiagramLayerSettings::setCoordinateTransform( const QgsCoordinateTransfo void QgsDiagramLayerSettings::readXml( const QDomElement &elem ) { - QDomNodeList propertyElems = elem.elementsByTagName( "properties" ); + QDomNodeList propertyElems = elem.elementsByTagName( QStringLiteral( "properties" ) ); if ( !propertyElems.isEmpty() ) { ( void )mDataDefinedProperties.readXml( propertyElems.at( 0 ).toElement(), sPropertyDefinitions ); @@ -135,7 +135,7 @@ void QgsDiagramLayerSettings::readXml( const QDomElement &elem ) void QgsDiagramLayerSettings::writeXml( QDomElement &layerElem, QDomDocument &doc ) const { QDomElement diagramLayerElem = doc.createElement( QStringLiteral( "DiagramLayerSettings" ) ); - QDomElement propertiesElem = doc.createElement( "properties" ); + QDomElement propertiesElem = doc.createElement( QStringLiteral( "properties" ) ); ( void )mDataDefinedProperties.writeXml( propertiesElem, sPropertyDefinitions ); diagramLayerElem.appendChild( propertiesElem ); diagramLayerElem.setAttribute( QStringLiteral( "placement" ), mPlacement ); @@ -689,7 +689,7 @@ void QgsLinearlyInterpolatedDiagramRenderer::readXml( const QDomElement &elem, c delete mDataDefinedSizeLegend; - QDomElement ddsLegendSizeElem = elem.firstChildElement( "data-defined-size-legend" ); + QDomElement ddsLegendSizeElem = elem.firstChildElement( QStringLiteral( "data-defined-size-legend" ) ); if ( !ddsLegendSizeElem.isNull() ) { mDataDefinedSizeLegend = QgsDataDefinedSizeLegend::readXml( ddsLegendSizeElem, context ); diff --git a/src/core/qgseditformconfig.cpp b/src/core/qgseditformconfig.cpp index 0ac44871a7ee..0d75f256b8a0 100644 --- a/src/core/qgseditformconfig.cpp +++ b/src/core/qgseditformconfig.cpp @@ -343,7 +343,7 @@ void QgsEditFormConfig::readXml( const QDomNode &node, const QgsReadWriteContext for ( int i = 0; i < widgetsNodeList.size(); ++i ) { QDomElement widgetElement = widgetsNodeList.at( i ).toElement(); - QVariant config = QgsXmlUtils::readVariant( widgetElement.firstChildElement( "config" ) ); + QVariant config = QgsXmlUtils::readVariant( widgetElement.firstChildElement( QStringLiteral( "config" ) ) ); d->mWidgetConfigs[widgetElement.attribute( QStringLiteral( "name" ) )] = config.toMap(); } diff --git a/src/core/qgsfontutils.h b/src/core/qgsfontutils.h index 348a36adfc6b..9f33638cd7aa 100644 --- a/src/core/qgsfontutils.h +++ b/src/core/qgsfontutils.h @@ -181,4 +181,6 @@ class CORE_EXPORT QgsFontUtils static QStringList recentFontFamilies(); }; +// clazy:excludeall=qstring-allocations + #endif // QGSFONTUTILS_H diff --git a/src/core/qgsmaplayermodel.cpp b/src/core/qgsmaplayermodel.cpp index 678c63e4213c..cd887a0e01f4 100644 --- a/src/core/qgsmaplayermodel.cpp +++ b/src/core/qgsmaplayermodel.cpp @@ -298,7 +298,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( "
" ); + return parts.join( QStringLiteral( "
" ) ); } return QVariant(); } diff --git a/src/core/qgsmaprenderertask.h b/src/core/qgsmaprenderertask.h index 0d2a9fdee9d9..e93ecb9fdbca 100644 --- a/src/core/qgsmaprenderertask.h +++ b/src/core/qgsmaprenderertask.h @@ -118,4 +118,6 @@ class CORE_EXPORT QgsMapRendererTask : public QgsTask int mError = 0; }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/core/qgsproject.cpp b/src/core/qgsproject.cpp index 728d280693ee..26c8b90609b5 100644 --- a/src/core/qgsproject.cpp +++ b/src/core/qgsproject.cpp @@ -1413,7 +1413,7 @@ bool QgsProject::writeProjectFile( const QString &filename ) // Create backup file if ( QFile::exists( fileName() ) ) { - QFile backupFile( QString( "%1~" ).arg( filename ) ); + QFile backupFile( QStringLiteral( "%1~" ).arg( filename ) ); bool ok = true; ok &= backupFile.open( QIODevice::WriteOnly | QIODevice::Truncate ); ok &= projectFile.open( QIODevice::ReadOnly ); @@ -2156,7 +2156,7 @@ bool QgsProject::zip( const QString &filename ) // save the current project in a temporary .qgs file std::unique_ptr archive( new QgsProjectArchive() ); const QString baseName = QFileInfo( filename ).baseName(); - const QString qgsFileName = QString( "%1.qgs" ).arg( baseName ); + const QString qgsFileName = QStringLiteral( "%1.qgs" ).arg( baseName ); QFile qgsFile( QDir( archive->dir() ).filePath( qgsFileName ) ); bool writeOk = false; diff --git a/src/core/qgsprojectfiletransform.cpp b/src/core/qgsprojectfiletransform.cpp index 28587675c098..820489f792b2 100644 --- a/src/core/qgsprojectfiletransform.cpp +++ b/src/core/qgsprojectfiletransform.cpp @@ -643,7 +643,7 @@ void QgsProjectFileTransform::transform2990() { srsElem = mDom.createElement( QStringLiteral( "SpatialRefSys" ) ); projElem = mDom.createElement( QStringLiteral( "ProjectionsEnabled" ) ); - projElem.setAttribute( "type", "int" ); + projElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "int" ) ); QDomText projText = mDom.createTextNode( QStringLiteral( "0" ) ); projElem.appendChild( projText ); srsElem.appendChild( projElem ); @@ -761,14 +761,14 @@ void QgsProjectFileTransform::transform2990() QString name = editTypeElement.attribute( QStringLiteral( "name" ) ); fieldElement.setAttribute( QStringLiteral( "name" ), name ); QDomElement constraintExpressionElem = mDom.createElement( QStringLiteral( "constraint" ) ); - constraintExpressionElem.setAttribute( "field", name ); + constraintExpressionElem.setAttribute( QStringLiteral( "field" ), name ); constraintExpressionsElem.appendChild( constraintExpressionElem ); QDomElement editWidgetElement = mDom.createElement( QStringLiteral( "editWidget" ) ); fieldElement.appendChild( editWidgetElement ); QString ewv2Type = editTypeElement.attribute( QStringLiteral( "widgetv2type" ) ); - editWidgetElement.setAttribute( "type", ewv2Type ); + editWidgetElement.setAttribute( QStringLiteral( "type" ), ewv2Type ); QDomElement ewv2CfgElem = editTypeElement.namedItem( QStringLiteral( "widgetv2config" ) ).toElement(); @@ -797,11 +797,11 @@ void QgsProjectFileTransform::transform2990() } else if ( configAttr.name() == QStringLiteral( "constraint" ) ) { - constraintExpressionElem.setAttribute( "exp", configAttr.value() ); + constraintExpressionElem.setAttribute( QStringLiteral( "exp" ), configAttr.value() ); } else if ( configAttr.name() == QStringLiteral( "constraintDescription" ) ) { - constraintExpressionElem.setAttribute( "desc", configAttr.value() ); + constraintExpressionElem.setAttribute( QStringLiteral( "desc" ), configAttr.value() ); } else { @@ -822,7 +822,7 @@ void QgsProjectFileTransform::transform2990() } else if ( ewv2Type == QStringLiteral( "Photo" ) ) { - editWidgetElement.setAttribute( "type", QStringLiteral( "ExternalResource" ) ); + editWidgetElement.setAttribute( QStringLiteral( "type" ), QStringLiteral( "ExternalResource" ) ); editWidgetConfiguration.insert( QStringLiteral( "DocumentViewer" ), 1 ); editWidgetConfiguration.insert( QStringLiteral( "DocumentViewerHeight" ), editWidgetConfiguration.value( QStringLiteral( "Height" ) ) ); @@ -831,13 +831,13 @@ void QgsProjectFileTransform::transform2990() } else if ( ewv2Type == QStringLiteral( "FileName" ) ) { - editWidgetElement.setAttribute( "type", QStringLiteral( "ExternalResource" ) ); + editWidgetElement.setAttribute( QStringLiteral( "type" ), QStringLiteral( "ExternalResource" ) ); editWidgetConfiguration.insert( QStringLiteral( "RelativeStorage" ), 1 ); } else if ( ewv2Type == QStringLiteral( "WebView" ) ) { - editWidgetElement.setAttribute( "type", QStringLiteral( "ExternalResource" ) ); + editWidgetElement.setAttribute( QStringLiteral( "type" ), QStringLiteral( "ExternalResource" ) ); editWidgetConfiguration.insert( QStringLiteral( "DocumentViewerHeight" ), editWidgetConfiguration.value( QStringLiteral( "Height" ) ) ); editWidgetConfiguration.insert( QStringLiteral( "DocumentViewerWidth" ), editWidgetConfiguration.value( QStringLiteral( "Width" ) ) ); diff --git a/src/core/qgsprojectversion.h b/src/core/qgsprojectversion.h index 24fe011075b0..bdf1ddcc606c 100644 --- a/src/core/qgsprojectversion.h +++ b/src/core/qgsprojectversion.h @@ -77,4 +77,6 @@ class CORE_EXPORT QgsProjectVersion QString mName; }; +// clazy:excludeall=qstring-allocations + #endif // QGSPROJECTVERSION_H diff --git a/src/core/qgsproperty.cpp b/src/core/qgsproperty.cpp index 92d5d2528e80..c5d1fa126bdb 100644 --- a/src/core/qgsproperty.cpp +++ b/src/core/qgsproperty.cpp @@ -85,7 +85,7 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString case RenderUnits: mTypes = DataTypeString; - mHelpText = trString() + QLatin1String( "[MM|MapUnit|Pixel|Point]" ); + mHelpText = trString() + QStringLiteral( "[MM|MapUnit|Pixel|Point]" ); break; case ColorWithAlpha: @@ -100,14 +100,14 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString case PenJoinStyle: mTypes = DataTypeString; - mHelpText = trString() + QLatin1String( "[bevel|miter|round]" ); + mHelpText = trString() + QStringLiteral( "[bevel|miter|round]" ); break; case BlendMode: mTypes = DataTypeString; - mHelpText = trString() + QLatin1String( "[Normal|Lighten|Screen|Dodge|
" - "Addition|Darken|Multiply|Burn|Overlay|
" - "SoftLight|HardLight|Difference|Subtract]" ); + mHelpText = trString() + QStringLiteral( "[Normal|Lighten|Screen|Dodge|
" + "Addition|Darken|Multiply|Burn|Overlay|
" + "SoftLight|HardLight|Difference|Subtract]" ); break; case Point: @@ -127,7 +127,7 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString case LineStyle: mTypes = DataTypeString; - mHelpText = trString() + QLatin1String( "[no|solid|dash|dot|dash dot|dash dot dot]" ); + mHelpText = trString() + QStringLiteral( "[no|solid|dash|dot|dash dot|dash dot dot]" ); break; case StrokeWidth: @@ -137,31 +137,31 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString case FillStyle: mTypes = DataTypeString; - mHelpText = trString() + QLatin1String( "[solid|horizontal|vertical|cross|b_diagonal|f_diagonal" - "|diagonal_x|dense1|dense2|dense3|dense4|dense5" - "|dense6|dense7|no]" ); + mHelpText = trString() + QStringLiteral( "[solid|horizontal|vertical|cross|b_diagonal|f_diagonal" + "|diagonal_x|dense1|dense2|dense3|dense4|dense5" + "|dense6|dense7|no]" ); break; case CapStyle: mTypes = DataTypeString; - mHelpText = trString() + QLatin1String( "[square|flat|round]" ); + mHelpText = trString() + QStringLiteral( "[square|flat|round]" ); break; case HorizontalAnchor: mTypes = DataTypeString; - mHelpText = trString() + QLatin1String( "[left|center|right]" ); + mHelpText = trString() + QStringLiteral( "[left|center|right]" ); break; case VerticalAnchor: mTypes = DataTypeString; - mHelpText = trString() + QLatin1String( "[top|center|bottom]" ); + mHelpText = trString() + QStringLiteral( "[top|center|bottom]" ); break; case SvgPath: mTypes = DataTypeString; - mHelpText = trString() + QLatin1String( "[filepath] as
" - "''=empty|absolute|search-paths-relative|
" - "project-relative|URL" ); + mHelpText = trString() + QStringLiteral( "[filepath] as
" + "''=empty|absolute|search-paths-relative|
" + "project-relative|URL" ); break; case Offset: diff --git a/src/core/qgspropertytransformer.cpp b/src/core/qgspropertytransformer.cpp index f8f2a868f3fc..9a8aafb8ecc7 100644 --- a/src/core/qgspropertytransformer.cpp +++ b/src/core/qgspropertytransformer.cpp @@ -72,7 +72,7 @@ bool QgsPropertyTransformer::loadVariant( const QVariant &transformer ) mMaxValue = transformerMap.value( QStringLiteral( "maxValue" ), 1.0 ).toDouble(); mCurveTransform.reset( nullptr ); - QVariantMap curve = transformerMap.value( "curve" ).toMap(); + QVariantMap curve = transformerMap.value( QStringLiteral( "curve" ) ).toMap(); if ( !curve.isEmpty() ) { @@ -340,11 +340,11 @@ bool QgsSizeScaleTransformer::loadVariant( const QVariant &transformer ) QVariantMap transformerMap = transformer.toMap(); - mType = static_cast< ScaleType >( transformerMap.value( "scaleType", Linear ).toInt() ); - mMinSize = transformerMap.value( "minSize", 0.0 ).toDouble(); - mMaxSize = transformerMap.value( "maxSize", 1.0 ).toDouble(); - mNullSize = transformerMap.value( "nullSize", 0.0 ).toDouble(); - mExponent = transformerMap.value( "exponent", 1.0 ).toDouble(); + mType = static_cast< ScaleType >( transformerMap.value( QStringLiteral( "scaleType" ), Linear ).toInt() ); + mMinSize = transformerMap.value( QStringLiteral( "minSize" ), 0.0 ).toDouble(); + mMaxSize = transformerMap.value( QStringLiteral( "maxSize" ), 1.0 ).toDouble(); + mNullSize = transformerMap.value( QStringLiteral( "nullSize" ), 0.0 ).toDouble(); + mExponent = transformerMap.value( QStringLiteral( "exponent" ), 1.0 ).toDouble(); return true; } diff --git a/src/core/qgsproviderregistry.cpp b/src/core/qgsproviderregistry.cpp index fc28bee9f5f0..aea595b23883 100644 --- a/src/core/qgsproviderregistry.cpp +++ b/src/core/qgsproviderregistry.cpp @@ -316,7 +316,7 @@ QString QgsProviderRegistry::pluginList( bool asHTML ) const list += it->second->description(); if ( asHTML ) - list += "
"; + list += QLatin1String( "
" ); else list += '\n'; diff --git a/src/core/qgsrenderchecker.h b/src/core/qgsrenderchecker.h index 35cfa6b661b2..fbd41932e67d 100644 --- a/src/core/qgsrenderchecker.h +++ b/src/core/qgsrenderchecker.h @@ -122,7 +122,7 @@ class CORE_EXPORT QgsRenderChecker * \param renderedImageFile to optionally override the output filename * \note: make sure to call setExpectedImage and setRenderedImage first. */ - bool compareImages( const QString &testName, unsigned int mismatchCount = 0, const QString &renderedImageFile = "" ); + bool compareImages( const QString &testName, unsigned int mismatchCount = 0, const QString &renderedImageFile = QString() ); /** Get a list of all the anomalies. An anomaly is a rendered difference * file where there is some red pixel content (indicating a render check diff --git a/src/core/qgssettings.cpp b/src/core/qgssettings.cpp index f50d78f2c0ed..c43e79c8d58b 100644 --- a/src/core/qgssettings.cpp +++ b/src/core/qgssettings.cpp @@ -202,28 +202,28 @@ QString QgsSettings::prefixedKey( const QString &key, const Section section ) co switch ( section ) { case Section::Core : - prefix = "core"; + prefix = QStringLiteral( "core" ); break; case Section::Server : - prefix = "server"; + prefix = QStringLiteral( "server" ); break; case Section::Gui : - prefix = "gui"; + prefix = QStringLiteral( "gui" ); break; case Section::Plugins : - prefix = "plugins"; + prefix = QStringLiteral( "plugins" ); break; case Section::Misc : - prefix = "misc"; + prefix = QStringLiteral( "misc" ); break; case Section::Auth : - prefix = "auth"; + prefix = QStringLiteral( "auth" ); break; case Section::App : - prefix = "app"; + prefix = QStringLiteral( "app" ); break; case Section::Providers : - prefix = "providers"; + prefix = QStringLiteral( "providers" ); break; case Section::NoSection: default: diff --git a/src/core/qgsstacktrace.cpp b/src/core/qgsstacktrace.cpp index dae74a7cb7a0..91303ee27efe 100644 --- a/src/core/qgsstacktrace.cpp +++ b/src/core/qgsstacktrace.cpp @@ -163,14 +163,14 @@ QVector QgsStackTrace::trace( unsigned int maxFrames ) bool QgsStackTrace::StackLine::isQgisModule() const { - return moduleName.contains( "qgis", Qt::CaseInsensitive ); + return moduleName.contains( QLatin1String( "qgis" ), Qt::CaseInsensitive ); } bool QgsStackTrace::StackLine::isValid() const { - return !( fileName.contains( "exe_common", Qt::CaseInsensitive ) || - fileName.contains( "unknown", Qt::CaseInsensitive ) || - lineNumber.contains( "unknown", Qt::CaseInsensitive ) ); + return !( fileName.contains( QLatin1String( "exe_common" ), Qt::CaseInsensitive ) || + fileName.contains( QLatin1String( "unknown" ), Qt::CaseInsensitive ) || + lineNumber.contains( QLatin1String( "unknown" ), Qt::CaseInsensitive ) ); } ///@endcond diff --git a/src/core/qgsuserprofile.cpp b/src/core/qgsuserprofile.cpp index c42698fa6880..32d1279b020a 100644 --- a/src/core/qgsuserprofile.cpp +++ b/src/core/qgsuserprofile.cpp @@ -67,13 +67,13 @@ const QString QgsUserProfile::alias() const return name(); } - QSqlDatabase db = QSqlDatabase::addDatabase( "QSQLITE" ); + QSqlDatabase db = QSqlDatabase::addDatabase( QStringLiteral( "QSQLITE" ) ); db.setDatabaseName( qgisDB() ); if ( !db.open() ) return name(); QSqlQuery query; - query.prepare( "SELECT value FROM tbl_config_variables WHERE variable = 'ALIAS'" ); + query.prepare( QStringLiteral( "SELECT value FROM tbl_config_variables WHERE variable = 'ALIAS'" ) ); QString profileAlias = name(); if ( query.exec() ) { @@ -99,7 +99,7 @@ QgsError QgsUserProfile::setAlias( const QString &alias ) return error; } - QSqlDatabase db = QSqlDatabase::addDatabase( "QSQLITE", "userprofile" ); + QSqlDatabase db = QSqlDatabase::addDatabase( QStringLiteral( "QSQLITE" ), QStringLiteral( "userprofile" ) ); db.setDatabaseName( qgisDB() ); if ( !db.open() ) { @@ -108,9 +108,9 @@ QgsError QgsUserProfile::setAlias( const QString &alias ) } QSqlQuery query; - QString sql = "INSERT OR REPLACE INTO tbl_config_variables VALUES ('ALIAS', :alias);"; + QString sql = QStringLiteral( "INSERT OR REPLACE INTO tbl_config_variables VALUES ('ALIAS', :alias);" ); query.prepare( sql ); - query.bindValue( ":alias", alias ); + query.bindValue( QStringLiteral( ":alias" ), alias ); if ( !query.exec() ) { error.append( QObject::tr( "Could not save alias to database: %1" ).arg( query.lastError().text() ) ); diff --git a/src/core/qgsuserprofilemanager.cpp b/src/core/qgsuserprofilemanager.cpp index 139b8626bfdc..25b283d1ab2e 100644 --- a/src/core/qgsuserprofilemanager.cpp +++ b/src/core/qgsuserprofilemanager.cpp @@ -93,22 +93,22 @@ bool QgsUserProfileManager::rootLocationIsSet() const QString QgsUserProfileManager::defaultProfileName() const { - QString defaultName = "default"; + QString defaultName = QStringLiteral( "default" ); // If the profiles.ini doesn't have the default profile we grab it from // global settings as it might be set by the admin. // If the overrideProfile flag is set then no matter what the profiles.ini says we always take the // global profile. QgsSettings globalSettings; - if ( !mSettings->contains( "/core/defaultProfile" ) || globalSettings.value( "overrideLocalProfile", false, QgsSettings::Core ).toBool() ) + if ( !mSettings->contains( QStringLiteral( "/core/defaultProfile" ) ) || globalSettings.value( QStringLiteral( "overrideLocalProfile" ), false, QgsSettings::Core ).toBool() ) { - return globalSettings.value( "defaultProfile", defaultName, QgsSettings::Core ).toString(); + return globalSettings.value( QStringLiteral( "defaultProfile" ), defaultName, QgsSettings::Core ).toString(); } - return mSettings->value( "/core/defaultProfile", defaultName ).toString(); + return mSettings->value( QStringLiteral( "/core/defaultProfile" ), defaultName ).toString(); } void QgsUserProfileManager::setDefaultProfileName( const QString &name ) { - mSettings->setValue( "/core/defaultProfile", name ); + mSettings->setValue( QStringLiteral( "/core/defaultProfile" ), name ); mSettings->sync(); } @@ -204,7 +204,7 @@ void QgsUserProfileManager::loadUserProfile( const QString &name ) // http://doc.qt.io/qt-5/qcoreapplication.html#arguments arguments.removeFirst(); - arguments << "--profile" << name; + arguments << QStringLiteral( "--profile" ) << name; QgsDebugMsg( QString( "Starting instance from %1 with %2" ).arg( path ).arg( arguments.join( " " ) ) ); QProcess::startDetached( path, arguments, QDir::toNativeSeparators( QCoreApplication::applicationDirPath() ) ); } diff --git a/src/core/qgsuserprofilemanager.h b/src/core/qgsuserprofilemanager.h index 567a2fe43111..507a88c6842e 100644 --- a/src/core/qgsuserprofilemanager.h +++ b/src/core/qgsuserprofilemanager.h @@ -212,4 +212,6 @@ class CORE_EXPORT QgsUserProfileManager : public QObject std::unique_ptr< QSettings > mSettings; }; +// clazy:excludeall=qstring-allocations + #endif // QGSUSERPROFILEMANAGER_H diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index 4d4759e6d8cb..fd22f21bbda9 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -1127,7 +1127,7 @@ QMap QgsVectorFileWriter::initMetaData() QStringLiteral( "geom" ) // Default value ) ); - layerOptions.insert( "SPATIAL_INDEX", new BoolOption( + layerOptions.insert( QStringLiteral( "SPATIAL_INDEX" ), new BoolOption( QObject::tr( "If a spatial index must be created." ), true // Default value ) ); @@ -1308,7 +1308,7 @@ QMap QgsVectorFileWriter::initMetaData() QStringList() << QStringLiteral( "QUICK" ) << QStringLiteral( "OPTIMIZED" ), - QLatin1String( "QUICK" ), // Default value + QStringLiteral( "QUICK" ), // Default value true // Allow None ) ); @@ -1663,12 +1663,12 @@ QMap QgsVectorFileWriter::initMetaData() datasetOptions.clear(); layerOptions.clear(); - datasetOptions.insert( "HEADER", new StringOption( + datasetOptions.insert( QStringLiteral( "HEADER" ), new StringOption( QObject::tr( "Override the header file used - in place of header.dxf." ), QLatin1String( "" ) // Default value ) ); - datasetOptions.insert( "TRAILER", new StringOption( + datasetOptions.insert( QStringLiteral( "TRAILER" ), new StringOption( QObject::tr( "Override the trailer file used - in place of trailer.dxf." ), QLatin1String( "" ) // Default value ) ); @@ -1697,14 +1697,14 @@ QMap QgsVectorFileWriter::initMetaData() QStringLiteral( "GXT" ) // Default value ) ); - datasetOptions.insert( "CONFIG", new StringOption( + datasetOptions.insert( QStringLiteral( "CONFIG" ), new StringOption( QObject::tr( "path to the GCT : the GCT file describe the GeoConcept types definitions: " "In this file, every line must start with //# followed by a keyword. " "Lines starting with // are comments." ), QLatin1String( "" ) // Default value ) ); - datasetOptions.insert( "FEATURETYPE", new StringOption( + datasetOptions.insert( QStringLiteral( "FEATURETYPE" ), new StringOption( QObject::tr( "defines the feature to be created. The TYPE corresponds to one of the Name " "found in the GCT file for a type section. The SUBTYPE corresponds to one of " "the Name found in the GCT file for a sub-type section within the previous " @@ -2744,7 +2744,7 @@ QStringList QgsVectorFileWriter::supportedFormatExtensions() QgsStringMap formats = supportedFiltersAndFormats(); QStringList extensions; - QRegularExpression rx( "\\*\\.([a-zA-Z0-9]*)" ); + QRegularExpression rx( QStringLiteral( "\\*\\.([a-zA-Z0-9]*)" ) ); QgsStringMap::const_iterator formatIt = formats.constBegin(); for ( ; formatIt != formats.constEnd(); ++formatIt ) @@ -2803,11 +2803,11 @@ QMap QgsVectorFileWriter::ogrDriverList() poDriver = OGRGetDriverByName( drvName.toLocal8Bit().constData() ); if ( poDriver ) { - OGRDataSourceH ds = OGR_Dr_CreateDataSource( poDriver, QString( "/vsimem/spatialitetest.sqlite" ).toUtf8().constData(), options ); + OGRDataSourceH ds = OGR_Dr_CreateDataSource( poDriver, QStringLiteral( "/vsimem/spatialitetest.sqlite" ).toUtf8().constData(), options ); if ( ds ) { writableDrivers << QStringLiteral( "SpatiaLite" ); - OGR_Dr_DeleteDataSource( poDriver, QString( "/vsimem/spatialitetest.sqlite" ).toUtf8().constData() ); + OGR_Dr_DeleteDataSource( poDriver, QStringLiteral( "/vsimem/spatialitetest.sqlite" ).toUtf8().constData() ); OGR_DS_Destroy( ds ); } } diff --git a/src/core/qgsvectorfilewriter.h b/src/core/qgsvectorfilewriter.h index a4a6f34a75dd..00a92f386851 100644 --- a/src/core/qgsvectorfilewriter.h +++ b/src/core/qgsvectorfilewriter.h @@ -675,5 +675,6 @@ class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink Q_DECLARE_OPERATORS_FOR_FLAGS( QgsVectorFileWriter::EditionCapabilities ) +// clazy:excludeall=qstring-allocations #endif diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index 87b7120bbfdc..f8fe144ed648 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -1744,24 +1744,24 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes // constraints mFieldConstraints.clear(); mFieldConstraintStrength.clear(); - QDomNode constraintsNode = layerNode.namedItem( "constraints" ); + QDomNode constraintsNode = layerNode.namedItem( QStringLiteral( "constraints" ) ); if ( !constraintsNode.isNull() ) { - QDomNodeList constraintNodeList = constraintsNode.toElement().elementsByTagName( "constraint" ); + QDomNodeList constraintNodeList = constraintsNode.toElement().elementsByTagName( QStringLiteral( "constraint" ) ); for ( int i = 0; i < constraintNodeList.size(); ++i ) { QDomElement constraintElem = constraintNodeList.at( i ).toElement(); - QString field = constraintElem.attribute( "field", QString() ); - int constraints = constraintElem.attribute( "constraints", QString( "0" ) ).toInt(); + QString field = constraintElem.attribute( QStringLiteral( "field" ), QString() ); + int constraints = constraintElem.attribute( QStringLiteral( "constraints" ), QStringLiteral( "0" ) ).toInt(); if ( field.isEmpty() || constraints == 0 ) continue; mFieldConstraints.insert( field, static_cast< QgsFieldConstraints::Constraints >( constraints ) ); - int uniqueStrength = constraintElem.attribute( "unique_strength", QString( "1" ) ).toInt(); - int notNullStrength = constraintElem.attribute( "notnull_strength", QString( "1" ) ).toInt(); - int expStrength = constraintElem.attribute( "exp_strength", QString( "1" ) ).toInt(); + int uniqueStrength = constraintElem.attribute( QStringLiteral( "unique_strength" ), QStringLiteral( "1" ) ).toInt(); + int notNullStrength = constraintElem.attribute( QStringLiteral( "notnull_strength" ), QStringLiteral( "1" ) ).toInt(); + int expStrength = constraintElem.attribute( QStringLiteral( "exp_strength" ), QStringLiteral( "1" ) ).toInt(); mFieldConstraintStrength.insert( qMakePair( field, QgsFieldConstraints::ConstraintUnique ), static_cast< QgsFieldConstraints::ConstraintStrength >( uniqueStrength ) ); mFieldConstraintStrength.insert( qMakePair( field, QgsFieldConstraints::ConstraintNotNull ), static_cast< QgsFieldConstraints::ConstraintStrength >( notNullStrength ) ); @@ -1769,17 +1769,17 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes } } mFieldConstraintExpressions.clear(); - QDomNode constraintExpressionsNode = layerNode.namedItem( "constraintExpressions" ); + QDomNode constraintExpressionsNode = layerNode.namedItem( QStringLiteral( "constraintExpressions" ) ); if ( !constraintExpressionsNode.isNull() ) { - QDomNodeList constraintNodeList = constraintExpressionsNode.toElement().elementsByTagName( "constraint" ); + QDomNodeList constraintNodeList = constraintExpressionsNode.toElement().elementsByTagName( QStringLiteral( "constraint" ) ); for ( int i = 0; i < constraintNodeList.size(); ++i ) { QDomElement constraintElem = constraintNodeList.at( i ).toElement(); - QString field = constraintElem.attribute( "field", QString() ); - QString exp = constraintElem.attribute( "exp", QString() ); - QString desc = constraintElem.attribute( "desc", QString() ); + QString field = constraintElem.attribute( QStringLiteral( "field" ), QString() ); + QString exp = constraintElem.attribute( QStringLiteral( "exp" ), QString() ); + QString desc = constraintElem.attribute( QStringLiteral( "desc" ), QString() ); if ( field.isEmpty() || exp.isEmpty() ) continue; @@ -1881,7 +1881,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage, con QDomElement labelingElement = node.firstChildElement( QStringLiteral( "labeling" ) ); QgsAbstractVectorLayerLabeling *labeling = nullptr; if ( labelingElement.isNull() || - ( labelingElement.attribute( "type" ) == "simple" && labelingElement.firstChildElement( QStringLiteral( "settings" ) ).isNull() ) ) + ( labelingElement.attribute( QStringLiteral( "type" ) ) == QLatin1String( "simple" ) && labelingElement.firstChildElement( QStringLiteral( "settings" ) ).isNull() ) ) { // make sure we have custom properties for labeling for 2.x projects // (custom properties should be already loaded when reading the whole layer from XML, @@ -1953,7 +1953,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage, con // fix project from before QGIS 3.0 int idx = linearDiagramElem.attribute( QStringLiteral( "classificationAttribute" ) ).toInt(); if ( idx >= 0 && idx < mFields.count() ) - linearDiagramElem.setAttribute( "classificationField", mFields.at( idx ).name() ); + linearDiagramElem.setAttribute( QStringLiteral( "classificationField" ), mFields.at( idx ).name() ); } mDiagramRenderer = new QgsLinearlyInterpolatedDiagramRenderer(); @@ -1990,7 +1990,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage, con if ( showColumn >= 0 && showColumn < mFields.count() ) ddp.setProperty( QgsDiagramLayerSettings::Show, QgsProperty::fromField( mFields.at( showColumn ).name(), true ) ); } - QDomElement propertiesElem = diagramSettingsElem.ownerDocument().createElement( "properties" ); + QDomElement propertiesElem = diagramSettingsElem.ownerDocument().createElement( QStringLiteral( "properties" ) ); QgsPropertiesDefinition defs = QgsPropertiesDefinition { { QgsDiagramLayerSettings::PositionX, QgsPropertyDefinition( "positionX", QObject::tr( "Position (X)" ), QgsPropertyDefinition::Double ) }, @@ -2031,7 +2031,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString // TODO : wrap this part in an if to only save if it was user-modified QDomElement editWidgetElement = doc.createElement( QStringLiteral( "editWidget" ) ); fieldElement.appendChild( editWidgetElement ); - editWidgetElement.setAttribute( "type", field.editorWidgetSetup().type() ); + editWidgetElement.setAttribute( QStringLiteral( "type" ), field.editorWidgetSetup().type() ); QDomElement editWidgetConfigElement = doc.createElement( QStringLiteral( "config" ) ); editWidgetConfigElement.appendChild( QgsXmlUtils::writeVariant( widgetSetup.config(), doc ) ); @@ -2089,27 +2089,27 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString node.appendChild( defaultsElem ); // constraints - QDomElement constraintsElem = doc.createElement( "constraints" ); + QDomElement constraintsElem = doc.createElement( QStringLiteral( "constraints" ) ); Q_FOREACH ( const QgsField &field, mFields ) { - QDomElement constraintElem = doc.createElement( "constraint" ); - constraintElem.setAttribute( "field", field.name() ); - constraintElem.setAttribute( "constraints", field.constraints().constraints() ); - constraintElem.setAttribute( "unique_strength", field.constraints().constraintStrength( QgsFieldConstraints::ConstraintUnique ) ); - constraintElem.setAttribute( "notnull_strength", field.constraints().constraintStrength( QgsFieldConstraints::ConstraintNotNull ) ); - constraintElem.setAttribute( "exp_strength", field.constraints().constraintStrength( QgsFieldConstraints::ConstraintExpression ) ); + QDomElement constraintElem = doc.createElement( QStringLiteral( "constraint" ) ); + constraintElem.setAttribute( QStringLiteral( "field" ), field.name() ); + constraintElem.setAttribute( QStringLiteral( "constraints" ), field.constraints().constraints() ); + constraintElem.setAttribute( QStringLiteral( "unique_strength" ), field.constraints().constraintStrength( QgsFieldConstraints::ConstraintUnique ) ); + constraintElem.setAttribute( QStringLiteral( "notnull_strength" ), field.constraints().constraintStrength( QgsFieldConstraints::ConstraintNotNull ) ); + constraintElem.setAttribute( QStringLiteral( "exp_strength" ), field.constraints().constraintStrength( QgsFieldConstraints::ConstraintExpression ) ); constraintsElem.appendChild( constraintElem ); } node.appendChild( constraintsElem ); // constraint expressions - QDomElement constraintExpressionsElem = doc.createElement( "constraintExpressions" ); + QDomElement constraintExpressionsElem = doc.createElement( QStringLiteral( "constraintExpressions" ) ); Q_FOREACH ( const QgsField &field, mFields ) { - QDomElement constraintExpressionElem = doc.createElement( "constraint" ); - constraintExpressionElem.setAttribute( "field", field.name() ); - constraintExpressionElem.setAttribute( "exp", field.constraints().constraintExpression() ); - constraintExpressionElem.setAttribute( "desc", field.constraints().constraintDescription() ); + QDomElement constraintExpressionElem = doc.createElement( QStringLiteral( "constraint" ) ); + constraintExpressionElem.setAttribute( QStringLiteral( "field" ), field.name() ); + constraintExpressionElem.setAttribute( QStringLiteral( "exp" ), field.constraints().constraintExpression() ); + constraintExpressionElem.setAttribute( QStringLiteral( "desc" ), field.constraints().constraintDescription() ); constraintExpressionsElem.appendChild( constraintExpressionElem ); } node.appendChild( constraintExpressionsElem ); @@ -2242,19 +2242,19 @@ bool QgsVectorLayer::writeSld( QDomNode &node, QDomDocument &doc, QString &error if ( isSpatial() ) { // store the Name element - QDomElement nameNode = doc.createElement( "se:Name" ); + QDomElement nameNode = doc.createElement( QStringLiteral( "se:Name" ) ); nameNode.appendChild( doc.createTextNode( name() ) ); node.appendChild( nameNode ); - QDomElement userStyleElem = doc.createElement( "UserStyle" ); + QDomElement userStyleElem = doc.createElement( QStringLiteral( "UserStyle" ) ); node.appendChild( userStyleElem ); - QDomElement nameElem = doc.createElement( "se:Name" ); + QDomElement nameElem = doc.createElement( QStringLiteral( "se:Name" ) ); nameElem.appendChild( doc.createTextNode( name() ) ); userStyleElem.appendChild( nameElem ); - QDomElement featureTypeStyleElem = doc.createElement( "se:FeatureTypeStyle" ); + QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral( "se:FeatureTypeStyle" ) ); userStyleElem.appendChild( featureTypeStyleElem ); mRenderer->toSld( doc, featureTypeStyleElem, localProps ); @@ -3703,7 +3703,7 @@ void QgsVectorLayer::readSldLabeling( const QDomNode &node ) return; } - QString fontFamily = "Sans-Serif"; + QString fontFamily = QStringLiteral( "Sans-Serif" ); int fontPointSize = 10; int fontWeight = -1; bool fontItalic = false; @@ -3913,31 +3913,31 @@ QString QgsVectorLayer::htmlMetadata() const QString myMetadata = QStringLiteral( "\n\n" ); // identification section - myMetadata += QLatin1String( "

" ) + tr( "Identification" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Identification" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.identificationSectionHtml( ); myMetadata += QLatin1String( "

\n" ); // Begin Provider section - myMetadata += QLatin1String( "

" ) + tr( "Information from provider" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Information from provider" ) + QStringLiteral( "

\n
\n" ); myMetadata += QLatin1String( "
" ) + QObject::tr( "Identifier" ) + QLatin1String( "" ) + mMetadata.identifier() + QLatin1String( "
" ) + QObject::tr( "Identifier" ) + QStringLiteral( "" ) + mMetadata.identifier() + QStringLiteral( "
" ) + QObject::tr( "Parent Identifier" ) + QLatin1String( "" ) + mMetadata.parentIdentifier() + QLatin1String( "
" ) + QObject::tr( "Parent Identifier" ) + QStringLiteral( "" ) + mMetadata.parentIdentifier() + QStringLiteral( "
" ) + QObject::tr( "Title" ) + QLatin1String( "" ) + mMetadata.title() + QLatin1String( "
" ) + QObject::tr( "Title" ) + QStringLiteral( "" ) + mMetadata.title() + QStringLiteral( "
" ) + QObject::tr( "Type" ) + QLatin1String( "" ) + mMetadata.type() + QLatin1String( "
" ) + QObject::tr( "Type" ) + QStringLiteral( "" ) + mMetadata.type() + QStringLiteral( "
" ) + QObject::tr( "Language" ) + QLatin1String( "" ) + mMetadata.language() + QLatin1String( "
" ) + QObject::tr( "Language" ) + QStringLiteral( "" ) + mMetadata.language() + QStringLiteral( "
" ) + QObject::tr( "Abstract" ) + QLatin1String( "" ) + mMetadata.abstract() + QLatin1String( "
" ) + QObject::tr( "Abstract" ) + QStringLiteral( "" ) + mMetadata.abstract() + QStringLiteral( "
" ) + QObject::tr( "Categories" ) + QLatin1String( "" ) + mMetadata.categories().join( QStringLiteral( ", " ) ) + QLatin1String( "
" ) + QObject::tr( "Categories" ) + QStringLiteral( "" ) + mMetadata.categories().join( QStringLiteral( ", " ) ) + QStringLiteral( "
" ) + QObject::tr( "Keywords" ) + QLatin1String( "\n" ); + myMetadata += QStringLiteral( "
" ) + QObject::tr( "Keywords" ) + QStringLiteral( "\n" ); QMapIterator i( mMetadata.keywords() ); if ( i.hasNext() ) { @@ -196,7 +196,7 @@ QString QgsLayerMetadataFormatter::identificationSectionHtml() const i.next(); QString rowClass; if ( j % 2 ) - rowClass = QString( "class=\"odd-row\"" ); + rowClass = QStringLiteral( "class=\"odd-row\"" ); myMetadata += "
" + i.key() + "" + i.value().join( QStringLiteral( ", " ) ) + "
" + QString::number( i ) + "" + history + "
" + QString::number( i ) + "" + link.name + "" + link.type + "" + link.url + "" + link.description + "" + link.format + "" + link.mimeType + "" + link.size + "
\n" ); // original name - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // name - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // data source - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // storage type - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // comment - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // encoding - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // geom type QgsWkbTypes::GeometryType type = geometryType(); @@ -3949,12 +3949,12 @@ QString QgsVectorLayer::htmlMetadata() const { QString typeString( QStringLiteral( "%1 (%2)" ).arg( QgsWkbTypes::geometryDisplayString( geometryType() ), QgsWkbTypes::displayString( wkbType() ) ) ); - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); } // EPSG - myMetadata += QLatin1String( "\n" ); // Extent - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // unit - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // feature count - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // End Provider section myMetadata += QLatin1String( "
" ) + tr( "Original" ) + QLatin1String( "" ) + originalName() + QLatin1String( "
" ) + tr( "Original" ) + QStringLiteral( "" ) + originalName() + QStringLiteral( "
" ) + tr( "Name" ) + QLatin1String( "" ) + name() + QLatin1String( "
" ) + tr( "Name" ) + QStringLiteral( "" ) + name() + QStringLiteral( "
" ) + tr( "Source" ) + QLatin1String( "" ) + publicSource() + QLatin1String( "
" ) + tr( "Source" ) + QStringLiteral( "" ) + publicSource() + QStringLiteral( "
" ) + tr( "Storage" ) + QLatin1String( "" ) + storageType() + QLatin1String( "
" ) + tr( "Storage" ) + QStringLiteral( "" ) + storageType() + QStringLiteral( "
" ) + tr( "Comment" ) + QLatin1String( "" ) + dataComment() + QLatin1String( "
" ) + tr( "Comment" ) + QStringLiteral( "" ) + dataComment() + QStringLiteral( "
" ) + tr( "Encoding" ) + QLatin1String( "" ) + dataProvider()->encoding() + QLatin1String( "
" ) + tr( "Encoding" ) + QStringLiteral( "" ) + dataProvider()->encoding() + QStringLiteral( "
" ) + tr( "Geometry" ) + QLatin1String( "" ) + typeString + QLatin1String( "
" ) + tr( "Geometry" ) + QStringLiteral( "" ) + typeString + QStringLiteral( "
" ) + tr( "CRS" ) + QLatin1String( "" ) + crs().authid() + QLatin1String( " - " ); - myMetadata += crs().description() + QLatin1String( " - " ); + myMetadata += QStringLiteral( "
" ) + tr( "CRS" ) + QStringLiteral( "" ) + crs().authid() + QStringLiteral( " - " ); + myMetadata += crs().description() + QStringLiteral( " - " ); if ( crs().isGeographic() ) myMetadata += tr( "Geographic" ); else @@ -3962,35 +3962,35 @@ QString QgsVectorLayer::htmlMetadata() const myMetadata += QLatin1String( "
" ) + tr( "Extent" ) + QLatin1String( "" ) + extent().toString() + QLatin1String( "
" ) + tr( "Extent" ) + QStringLiteral( "" ) + extent().toString() + QStringLiteral( "
" ) + tr( "Unit" ) + QLatin1String( "" ) + QgsUnitTypes::toString( crs().mapUnits() ) + QLatin1String( "
" ) + tr( "Unit" ) + QStringLiteral( "" ) + QgsUnitTypes::toString( crs().mapUnits() ) + QStringLiteral( "
" ) + tr( "Feature count" ) + QLatin1String( "" ) + QString::number( featureCount() ) + QLatin1String( "
" ) + tr( "Feature count" ) + QStringLiteral( "" ) + QString::number( featureCount() ) + QStringLiteral( "
\n

" ); // extent section - myMetadata += QLatin1String( "

" ) + tr( "Extent" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Extent" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.extentSectionHtml( ); myMetadata += QLatin1String( "

\n" ); // Start the Access section - myMetadata += QLatin1String( "

" ) + tr( "Access" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Access" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.accessSectionHtml( ); myMetadata += QLatin1String( "

\n" ); // Fields section - myMetadata += QLatin1String( "

" ) + tr( "Fields" ) + QLatin1String( "

\n
\n\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Fields" ) + QStringLiteral( "

\n
\n
\n" ); // primary key QgsAttributeList pkAttrList = pkAttributeList(); if ( !pkAttrList.isEmpty() ) { - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); - myMetadata += "
" ) + tr( "Primary key attributes" ) + QLatin1String( "" ); + myMetadata += QStringLiteral( "
" ) + tr( "Primary key attributes" ) + QStringLiteral( "" ); Q_FOREACH ( int idx, pkAttrList ) { myMetadata += fields().at( idx ).name() + ' '; @@ -4001,17 +4001,17 @@ QString QgsVectorLayer::htmlMetadata() const const QgsFields &myFields = pendingFields(); // count fields - myMetadata += QLatin1String( "
" ) + tr( "Count" ) + QLatin1String( "" ) + QString::number( myFields.size() ) + QLatin1String( "
" ) + tr( "Count" ) + QStringLiteral( "" ) + QString::number( myFields.size() ) + QStringLiteral( "
\n
\n"; + myMetadata += QLatin1String( "
\n
\n" ); myMetadata += "\n"; for ( int i = 0; i < myFields.size(); ++i ) { QgsField myField = myFields.at( i ); - QString rowClass = QString( "" ); + QString rowClass = QLatin1String( "" ); if ( i % 2 ) - rowClass = QString( "class=\"odd-row\"" ); + rowClass = QStringLiteral( "class=\"odd-row\"" ); myMetadata += "\n"; } @@ -4019,17 +4019,17 @@ QString QgsVectorLayer::htmlMetadata() const myMetadata += QLatin1String( "
" + tr( "Field" ) + "" + tr( "Type" ) + "" + tr( "Length" ) + "" + tr( "Precision" ) + "" + tr( "Comment" ) + "
" + myField.name() + "" + myField.typeName() + "" + QString::number( myField.length() ) + "" + QString::number( myField.precision() ) + "" + myField.comment() + "
\n

" ); // Start the contacts section - myMetadata += QLatin1String( "

" ) + tr( "Contacts" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Contacts" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.contactsSectionHtml( ); myMetadata += QLatin1String( "

\n" ); // Start the links section - myMetadata += QLatin1String( "

" ) + tr( "Links" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Links" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.linksSectionHtml( ); myMetadata += QLatin1String( "

\n" ); // Start the history section - myMetadata += QLatin1String( "

" ) + tr( "History" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "History" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.historySectionHtml( ); myMetadata += QLatin1String( "

\n" ); @@ -4418,7 +4418,7 @@ QgsAbstractVectorLayerLabeling *QgsVectorLayer::readLabelingFromCustomProperties removeCustomProperty( QStringLiteral( "labeling" ) ); Q_FOREACH ( const QString &key, customPropertyKeys() ) { - if ( key.startsWith( "labeling/" ) ) + if ( key.startsWith( QLatin1String( "labeling/" ) ) ) removeCustomProperty( key ); } } diff --git a/src/core/qgsvectorlayer.h b/src/core/qgsvectorlayer.h index 44d0ebb7f0cd..e023800d6dcf 100644 --- a/src/core/qgsvectorlayer.h +++ b/src/core/qgsvectorlayer.h @@ -2089,4 +2089,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte friend class QgsVectorLayerFeatureSource; }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/core/qgsvectorlayerexporter.cpp b/src/core/qgsvectorlayerexporter.cpp index 761a6e1b2ac4..436d55404c18 100644 --- a/src/core/qgsvectorlayerexporter.cpp +++ b/src/core/qgsvectorlayerexporter.cpp @@ -97,14 +97,14 @@ QgsVectorLayerExporter::QgsVectorLayerExporter( const QString &uri, QString uriUpdated( uri ); // HACK sorry... - if ( providerKey == "ogr" ) + if ( providerKey == QLatin1String( "ogr" ) ) { QString layerName; if ( options.contains( QStringLiteral( "layerName" ) ) ) layerName = options.value( QStringLiteral( "layerName" ) ).toString(); if ( !layerName.isEmpty() ) { - uriUpdated += "|layername="; + uriUpdated += QLatin1String( "|layername=" ); uriUpdated += layerName; } } diff --git a/src/core/qgsvectorlayerlabeling.cpp b/src/core/qgsvectorlayerlabeling.cpp index 5af5ae873413..3e02a89fada3 100644 --- a/src/core/qgsvectorlayerlabeling.cpp +++ b/src/core/qgsvectorlayerlabeling.cpp @@ -235,8 +235,8 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & if ( mSettings->scaleVisibility ) { QgsStringMap scaleProps = QgsStringMap(); - scaleProps.insert( "scaleMinDenom", qgsDoubleToString( mSettings->minimumScale ) ); - scaleProps.insert( "scaleMaxDenom", qgsDoubleToString( mSettings->maximumScale ) ); + scaleProps.insert( QStringLiteral( "scaleMinDenom" ), qgsDoubleToString( mSettings->minimumScale ) ); + scaleProps.insert( QStringLiteral( "scaleMaxDenom" ), qgsDoubleToString( mSettings->maximumScale ) ); QgsSymbolLayerUtils::applyScaleDependency( doc, ruleElement, scaleProps ); } @@ -252,7 +252,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & if ( mSettings->isExpression ) { labelElement.appendChild( doc.createComment( QStringLiteral( "SE Export for %1 not implemented yet" ).arg( mSettings->getLabelExpression()->dump() ) ) ); - labelElement.appendChild( doc.createTextNode( "Placeholder" ) ); + labelElement.appendChild( doc.createTextNode( QStringLiteral( "Placeholder" ) ) ); } else { @@ -300,7 +300,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & { case QgsPalLayerSettings::OverPoint: { - QDomElement pointPlacement = doc.createElement( "se:PointPlacement" ); + QDomElement pointPlacement = doc.createElement( QStringLiteral( "se:PointPlacement" ) ); labelPlacement.appendChild( pointPlacement ); // anchor point QPointF anchor = quadOffsetToSldAnchor( mSettings->quadOffset ); @@ -316,7 +316,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & // rotation if ( mSettings->angleOffset != 0 ) { - QDomElement rotation = doc.createElement( "se:Rotation" ); + QDomElement rotation = doc.createElement( QStringLiteral( "se:Rotation" ) ); pointPlacement.appendChild( rotation ); rotation.appendChild( doc.createTextNode( QString::number( mSettings->angleOffset ) ) ); } @@ -325,7 +325,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & case QgsPalLayerSettings::AroundPoint: case QgsPalLayerSettings::OrderedPositionsAroundPoint: { - QDomElement pointPlacement = doc.createElement( "se:PointPlacement" ); + QDomElement pointPlacement = doc.createElement( QStringLiteral( "se:PointPlacement" ) ); labelPlacement.appendChild( pointPlacement ); // SLD cannot do either, but let's do a best effort setting the distance using @@ -342,7 +342,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & case QgsPalLayerSettings::Free: { // still a point placement (for "free" it's a fallback, there is no SLD equivalent) - QDomElement pointPlacement = doc.createElement( "se:PointPlacement" ); + QDomElement pointPlacement = doc.createElement( QStringLiteral( "se:PointPlacement" ) ); labelPlacement.appendChild( pointPlacement ); QgsSymbolLayerUtils::createAnchorPointElement( doc, pointPlacement, QPointF( 0.5, 0.5 ) ); QgsUnitTypes::RenderUnit distUnit = mSettings->distUnits; @@ -354,7 +354,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & case QgsPalLayerSettings::Curved: case QgsPalLayerSettings::PerimeterCurved: { - QDomElement linePlacement = doc.createElement( "se:LinePlacement" ); + QDomElement linePlacement = doc.createElement( QStringLiteral( "se:LinePlacement" ) ); labelPlacement.appendChild( linePlacement ); // perpendicular distance if required @@ -362,7 +362,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & { QgsUnitTypes::RenderUnit distUnit = mSettings->distUnits; double dist = QgsSymbolLayerUtils::rescaleUom( mSettings->dist, distUnit, props ); - QDomElement perpendicular = doc.createElement( "se:PerpendicularOffset" ); + QDomElement perpendicular = doc.createElement( QStringLiteral( "se:PerpendicularOffset" ) ); linePlacement.appendChild( perpendicular ); perpendicular.appendChild( doc.createTextNode( qgsDoubleToString( dist, 2 ) ) ); } @@ -370,17 +370,17 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & // repeat distance if required if ( mSettings->repeatDistance > 0 ) { - QDomElement repeat = doc.createElement( "se:Repeat" ); + QDomElement repeat = doc.createElement( QStringLiteral( "se:Repeat" ) ); linePlacement.appendChild( repeat ); repeat.appendChild( doc.createTextNode( QStringLiteral( "true" ) ) ); - QDomElement gap = doc.createElement( "se:Gap" ); + QDomElement gap = doc.createElement( QStringLiteral( "se:Gap" ) ); linePlacement.appendChild( gap ); repeatDistance = QgsSymbolLayerUtils::rescaleUom( mSettings->repeatDistance, mSettings->repeatDistanceUnit, props ); gap.appendChild( doc.createTextNode( qgsDoubleToString( repeatDistance, 2 ) ) ); } // always generalized - QDomElement generalize = doc.createElement( "se:GeneralizeLine" ); + QDomElement generalize = doc.createElement( QStringLiteral( "se:GeneralizeLine" ) ); linePlacement.appendChild( generalize ); generalize.appendChild( doc.createTextNode( QStringLiteral( "true" ) ) ); } @@ -529,7 +529,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & x += fontSize / 2; y += fontSize; } - QString resizeSpec = QString( "%1 %2" ).arg( qgsDoubleToString( x, 2 ), qgsDoubleToString( y, 2 ) ); + QString resizeSpec = QStringLiteral( "%1 %2" ).arg( qgsDoubleToString( x, 2 ), qgsDoubleToString( y, 2 ) ); QDomElement voMargin = QgsSymbolLayerUtils::createVendorOptionElement( doc, QStringLiteral( "graphic-margin" ), resizeSpec ); textSymbolizerElement.appendChild( voMargin ); } diff --git a/src/core/qgsvectorlayerutils.cpp b/src/core/qgsvectorlayerutils.cpp index 05b5d30b183d..908ffe5a9723 100644 --- a/src/core/qgsvectorlayerutils.cpp +++ b/src/core/qgsvectorlayerutils.cpp @@ -88,7 +88,7 @@ QVariant QgsVectorLayerUtils::createUniqueValue( const QgsVectorLayer *layer, in if ( !base.isEmpty() ) { // strip any existing _1, _2 from the seed - QRegularExpression rx( "(.*)_\\d+" ); + QRegularExpression rx( QStringLiteral( "(.*)_\\d+" ) ); QRegularExpressionMatch match = rx.match( base ); if ( match.hasMatch() ) { diff --git a/src/core/qgsvirtuallayerdefinition.h b/src/core/qgsvirtuallayerdefinition.h index c4be183bdd15..3f1ae1cc26c2 100644 --- a/src/core/qgsvirtuallayerdefinition.h +++ b/src/core/qgsvirtuallayerdefinition.h @@ -172,4 +172,6 @@ class CORE_EXPORT QgsVirtualLayerDefinition long mGeometrySrid; }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/core/raster/qgspalettedrasterrenderer.cpp b/src/core/raster/qgspalettedrasterrenderer.cpp index 07dae110b7b1..8829289ef56a 100644 --- a/src/core/raster/qgspalettedrasterrenderer.cpp +++ b/src/core/raster/qgspalettedrasterrenderer.cpp @@ -289,7 +289,7 @@ QgsPalettedRasterRenderer::ClassData QgsPalettedRasterRenderer::classDataFromStr { QgsPalettedRasterRenderer::ClassData classes; - QRegularExpression linePartRx( "[\\s,:]+" ); + QRegularExpression linePartRx( QStringLiteral( "[\\s,:]+" ) ); QStringList parts = string.split( '\n', QString::SkipEmptyParts ); Q_FOREACH ( const QString &part, parts ) @@ -389,7 +389,7 @@ QString QgsPalettedRasterRenderer::classDataToString( const QgsPalettedRasterRen Q_FOREACH ( const Class &c, cd ) { - out << QString( "%1 %2 %3 %4 %5 %6" ).arg( c.value ).arg( c.color.red() ) + out << QStringLiteral( "%1 %2 %3 %4 %5 %6" ).arg( c.value ).arg( c.color.red() ) .arg( c.color.green() ).arg( c.color.blue() ).arg( c.color.alpha() ).arg( c.label ); } return out.join( '\n' ); diff --git a/src/core/raster/qgsrasterchecker.h b/src/core/raster/qgsrasterchecker.h index 708962ef000f..f548e926ab33 100644 --- a/src/core/raster/qgsrasterchecker.h +++ b/src/core/raster/qgsrasterchecker.h @@ -60,8 +60,10 @@ class CORE_EXPORT QgsRasterChecker bool compare( double verifiedVal, double expectedVal, double tolerance ); void compare( const QString ¶mName, int verifiedVal, int expectedVal, QString &report, bool &ok ); void compare( const QString ¶mName, double verifiedVal, double expectedVal, QString &report, bool &ok, double tolerance = 0 ); - void compareRow( const QString ¶mName, const QString &verifiedVal, const QString &expectedVal, QString &report, bool ok, const QString &difference = "", const QString &tolerance = "" ); + void compareRow( const QString ¶mName, const QString &verifiedVal, const QString &expectedVal, QString &report, bool ok, const QString &difference = QString(), const QString &tolerance = QString() ); double tolerance( double val, int places = 6 ); }; // class QgsRasterChecker +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/core/raster/qgsrasterdataprovider.h b/src/core/raster/qgsrasterdataprovider.h index 648d6d1a966e..ce93a574bf55 100644 --- a/src/core/raster/qgsrasterdataprovider.h +++ b/src/core/raster/qgsrasterdataprovider.h @@ -519,4 +519,7 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast mutable QgsRectangle mExtent; }; + +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index 5b7292df6b01..33598ffe859e 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -308,29 +308,29 @@ QString QgsRasterLayer::htmlMetadata() const QString myMetadata = QStringLiteral( "\n\n" ); // Identification section - myMetadata += QLatin1String( "

" ) + tr( "Identification" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Identification" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.identificationSectionHtml(); myMetadata += QLatin1String( "

\n" ); // Begin Provider section - myMetadata += QLatin1String( "

" ) + tr( "Information from provider" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Information from provider" ) + QStringLiteral( "

\n
\n" ); myMetadata += QLatin1String( "\n" ); // original name - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // name - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // data source - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // storage type - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // EPSG - myMetadata += QLatin1String( "\n" ); // Extent - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // unit - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // Raster Width - myMetadata += QLatin1String( "\n" ); // Raster height - myMetadata += QLatin1String( "\n" ); // Data type - myMetadata += QLatin1String( "
" ) + tr( "Original" ) + QLatin1String( "" ) + originalName() + QLatin1String( "
" ) + tr( "Original" ) + QStringLiteral( "" ) + originalName() + QStringLiteral( "
" ) + tr( "Name" ) + QLatin1String( "" ) + name() + QLatin1String( "
" ) + tr( "Name" ) + QStringLiteral( "" ) + name() + QStringLiteral( "
" ) + tr( "Source" ) + QLatin1String( "" ) + publicSource() + QLatin1String( "
" ) + tr( "Source" ) + QStringLiteral( "" ) + publicSource() + QStringLiteral( "
" ) + tr( "Provider" ) + QLatin1String( "" ) + providerType() + QLatin1String( "
" ) + tr( "Provider" ) + QStringLiteral( "" ) + providerType() + QStringLiteral( "
" ) + tr( "CRS" ) + QLatin1String( "" ) + crs().authid() + QLatin1String( " - " ); - myMetadata += crs().description() + QLatin1String( " - " ); + myMetadata += QStringLiteral( "
" ) + tr( "CRS" ) + QStringLiteral( "" ) + crs().authid() + QStringLiteral( " - " ); + myMetadata += crs().description() + QStringLiteral( " - " ); if ( crs().isGeographic() ) myMetadata += tr( "Geographic" ); else @@ -338,13 +338,13 @@ QString QgsRasterLayer::htmlMetadata() const myMetadata += QLatin1String( "
" ) + tr( "Extent" ) + QLatin1String( "" ) + extent().toString() + QLatin1String( "
" ) + tr( "Extent" ) + QStringLiteral( "" ) + extent().toString() + QStringLiteral( "
" ) + tr( "Unit" ) + QLatin1String( "" ) + QgsUnitTypes::toString( crs().mapUnits() ) + QLatin1String( "
" ) + tr( "Unit" ) + QStringLiteral( "" ) + QgsUnitTypes::toString( crs().mapUnits() ) + QStringLiteral( "
" ) + tr( "Width" ) + QLatin1String( "" ); + myMetadata += QStringLiteral( "
" ) + tr( "Width" ) + QStringLiteral( "" ); if ( dataProvider()->capabilities() & QgsRasterDataProvider::Size ) myMetadata += QString::number( width() ); else @@ -352,7 +352,7 @@ QString QgsRasterLayer::htmlMetadata() const myMetadata += QLatin1String( "
" ) + tr( "Height" ) + QLatin1String( "" ); + myMetadata += QStringLiteral( "
" ) + tr( "Height" ) + QStringLiteral( "" ); if ( dataProvider()->capabilities() & QgsRasterDataProvider::Size ) myMetadata += QString::number( height() ); else @@ -360,7 +360,7 @@ QString QgsRasterLayer::htmlMetadata() const myMetadata += QLatin1String( "
" ) + tr( "Data type" ) + QLatin1String( "" ); + myMetadata += QStringLiteral( "
" ) + tr( "Data type" ) + QStringLiteral( "" ); // Just use the first band switch ( mDataProvider->sourceDataType( 1 ) ) { @@ -406,38 +406,38 @@ QString QgsRasterLayer::htmlMetadata() const myMetadata += QLatin1String( "
\n

" ); // extent section - myMetadata += QLatin1String( "

" ) + tr( "Extent" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Extent" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.extentSectionHtml( ); myMetadata += QLatin1String( "

\n" ); // Start the Access section - myMetadata += QLatin1String( "

" ) + tr( "Access" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Access" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.accessSectionHtml( ); myMetadata += QLatin1String( "

\n" ); // Bands section - myMetadata += QLatin1String( "
\n

" ) + tr( "Bands" ) + QLatin1String( "

\n
\n\n" ); + myMetadata += QStringLiteral( "
\n

" ) + tr( "Bands" ) + QStringLiteral( "

\n
\n\n" ); // Band count - myMetadata += QLatin1String( "\n" ); + myMetadata += QStringLiteral( "\n" ); // Band table - myMetadata += "
" ) + tr( "Band count" ) + QLatin1String( "" ) + QString::number( bandCount() ) + QLatin1String( "
" ) + tr( "Band count" ) + QStringLiteral( "" ) + QString::number( bandCount() ) + QStringLiteral( "
\n
\n"; + myMetadata += QLatin1String( "
\n
\n" ); myMetadata += "\n"; QgsRasterDataProvider *provider = const_cast< QgsRasterDataProvider * >( mDataProvider ); for ( int i = 1; i <= bandCount(); i++ ) { - QString rowClass = QString( "" ); + QString rowClass = QLatin1String( "" ); if ( i % 2 ) - rowClass = QString( "class=\"odd-row\"" ); + rowClass = QStringLiteral( "class=\"odd-row\"" ); myMetadata += ""; + myMetadata += QLatin1String( "" ); if ( provider->hasStatistics( i ) ) { @@ -450,24 +450,24 @@ QString QgsRasterLayer::htmlMetadata() const myMetadata += ""; } - myMetadata += "\n"; + myMetadata += QLatin1String( "\n" ); } //close previous bands table myMetadata += QLatin1String( "
" + tr( "Number" ) + "" + tr( "Band" ) + "" + tr( "No-Data" ) + "" + tr( "Min" ) + "" + tr( "Max" ) + "
" + QString::number( i ) + "" + bandName( i ) + ""; if ( dataProvider()->sourceHasNoDataValue( i ) ) myMetadata += QString::number( dataProvider()->sourceNoDataValue( i ) ); else myMetadata += tr( "n/a" ); - myMetadata += "" + tr( "n/a" ) + "" + tr( "n/a" ) + "
\n

" ); // Start the contacts section - myMetadata += QLatin1String( "

" ) + tr( "Contacts" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "Contacts" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.contactsSectionHtml( ); myMetadata += QLatin1String( "

\n" ); // Start the links section - myMetadata += QLatin1String( "

" ) + tr( "References" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "References" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.linksSectionHtml( ); myMetadata += QLatin1String( "

\n" ); // Start the history section - myMetadata += QLatin1String( "

" ) + tr( "History" ) + QLatin1String( "

\n
\n" ); + myMetadata += QStringLiteral( "

" ) + tr( "History" ) + QStringLiteral( "

\n
\n" ); myMetadata += htmlFormatter.historySectionHtml( ); myMetadata += QLatin1String( "

\n" ); diff --git a/src/core/raster/qgsrasterlayer.h b/src/core/raster/qgsrasterlayer.h index 3c229f313247..bdf9fff0c887 100644 --- a/src/core/raster/qgsrasterlayer.h +++ b/src/core/raster/qgsrasterlayer.h @@ -426,4 +426,6 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer QgsRectangle mLastRectangleUsedByRefreshContrastEnhancementIfNeeded; }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/core/raster/qgsrasterrenderer.h b/src/core/raster/qgsrasterrenderer.h index 5f96abfdd4eb..46e3f13ed2d4 100644 --- a/src/core/raster/qgsrasterrenderer.h +++ b/src/core/raster/qgsrasterrenderer.h @@ -42,7 +42,7 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface static const QRgb NODATA_COLOR; - QgsRasterRenderer( QgsRasterInterface *input = nullptr, const QString &type = "" ); + QgsRasterRenderer( QgsRasterInterface *input = nullptr, const QString &type = QString() ); virtual ~QgsRasterRenderer(); //! QgsRasterRenderer cannot be copied. Use clone() instead. diff --git a/src/core/raster/qgsrastershader.cpp b/src/core/raster/qgsrastershader.cpp index a57b5e886ad7..44f2a8f28f3c 100644 --- a/src/core/raster/qgsrastershader.cpp +++ b/src/core/raster/qgsrastershader.cpp @@ -139,8 +139,8 @@ void QgsRasterShader::writeXml( QDomDocument &doc, QDomElement &parent ) const if ( colorRampShader ) { QDomElement colorRampShaderElem = doc.createElement( QStringLiteral( "colorrampshader" ) ); - colorRampShaderElem.setAttribute( "colorRampType", colorRampShader->colorRampTypeAsQString() ); - colorRampShaderElem.setAttribute( "classificationMode", colorRampShader->classificationMode() ); + colorRampShaderElem.setAttribute( QStringLiteral( "colorRampType" ), colorRampShader->colorRampTypeAsQString() ); + colorRampShaderElem.setAttribute( QStringLiteral( "classificationMode" ), colorRampShader->classificationMode() ); colorRampShaderElem.setAttribute( QStringLiteral( "clip" ), colorRampShader->clip() ); // save source color ramp diff --git a/src/core/symbology/qgscolorbrewerpalette.h b/src/core/symbology/qgscolorbrewerpalette.h index e20b957bc56b..afa40d5a4066 100644 --- a/src/core/symbology/qgscolorbrewerpalette.h +++ b/src/core/symbology/qgscolorbrewerpalette.h @@ -84,4 +84,6 @@ class CORE_EXPORT QgsColorBrewerPalette static const char *BREWER_STRING; }; +// clazy:excludeall=qstring-allocations + #endif // QGSCOLORBREWERPALETTE_H diff --git a/src/core/symbology/qgscptcityarchive.h b/src/core/symbology/qgscptcityarchive.h index 05c6d21f2899..c57d88ad8544 100644 --- a/src/core/symbology/qgscptcityarchive.h +++ b/src/core/symbology/qgscptcityarchive.h @@ -403,4 +403,6 @@ class CORE_EXPORT QgsCptCityBrowserModel : public QAbstractItemModel QSize mIconSize; }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/core/symbology/qgsellipsesymbollayer.cpp b/src/core/symbology/qgsellipsesymbollayer.cpp index 13c9126b0335..752c19b3b592 100644 --- a/src/core/symbology/qgsellipsesymbollayer.cpp +++ b/src/core/symbology/qgsellipsesymbollayer.cpp @@ -451,7 +451,7 @@ QgsSymbolLayer *QgsEllipseSymbolLayer::createFromSld( QDomElement &element ) if ( !QgsSymbolLayerUtils::wellKnownMarkerFromSld( graphicElem, name, fillColor, strokeColor, strokeStyle, strokeWidth, size ) ) return nullptr; - QString uom = element.attribute( QStringLiteral( "uom" ), "" ); + QString uom = element.attribute( QStringLiteral( "uom" ) ); size = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, size ); strokeWidth = QgsSymbolLayerUtils::sizeInPixelsFromSldUom( uom, strokeWidth ); diff --git a/src/core/symbology/qgsellipsesymbollayer.h b/src/core/symbology/qgsellipsesymbollayer.h index a7f8e70d997b..6dd4c7ad342d 100644 --- a/src/core/symbology/qgsellipsesymbollayer.h +++ b/src/core/symbology/qgsellipsesymbollayer.h @@ -161,6 +161,8 @@ class CORE_EXPORT QgsEllipseSymbolLayer: public QgsMarkerSymbolLayer void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const; }; +// clazy:excludeall=qstring-allocations + #endif // QGSELLIPSESYMBOLLAYERV2_H diff --git a/src/core/symbology/qgsheatmaprenderer.cpp b/src/core/symbology/qgsheatmaprenderer.cpp index 8066baa55894..f39ef0c752d2 100644 --- a/src/core/symbology/qgsheatmaprenderer.cpp +++ b/src/core/symbology/qgsheatmaprenderer.cpp @@ -351,7 +351,7 @@ QDomElement QgsHeatmapRenderer::save( QDomDocument &doc, const QgsReadWriteConte mOrderBy.save( orderBy ); rendererElem.appendChild( orderBy ); } - rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); return rendererElem; } diff --git a/src/core/symbology/qgsmarkersymbollayer.h b/src/core/symbology/qgsmarkersymbollayer.h index 1c7a76e9f099..4e8eec20a14c 100644 --- a/src/core/symbology/qgsmarkersymbollayer.h +++ b/src/core/symbology/qgsmarkersymbollayer.h @@ -654,6 +654,7 @@ class CORE_EXPORT QgsFontMarkerSymbolLayer : public QgsMarkerSymbolLayer double calculateSize( QgsSymbolRenderContext &context ); }; +// clazy:excludeall=qstring-allocations #endif diff --git a/src/core/symbology/qgspointdisplacementrenderer.cpp b/src/core/symbology/qgspointdisplacementrenderer.cpp index 56ba78b2f2c9..7b8d0338397e 100644 --- a/src/core/symbology/qgspointdisplacementrenderer.cpp +++ b/src/core/symbology/qgspointdisplacementrenderer.cpp @@ -171,7 +171,7 @@ QgsMarkerSymbol *QgsPointDisplacementRenderer::centerSymbol() QDomElement QgsPointDisplacementRenderer::save( QDomDocument &doc, const QgsReadWriteContext &context ) { QDomElement rendererElement = doc.createElement( RENDERER_TAG_NAME ); - rendererElement.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); + rendererElement.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); rendererElement.setAttribute( QStringLiteral( "type" ), QStringLiteral( "pointDisplacement" ) ); rendererElement.setAttribute( QStringLiteral( "labelAttributeName" ), mLabelAttributeName ); rendererElement.appendChild( QgsFontUtils::toXmlElement( mLabelFont, doc, QStringLiteral( "labelFontProperties" ) ) ); @@ -205,7 +205,7 @@ QDomElement QgsPointDisplacementRenderer::save( QDomDocument &doc, const QgsRead mOrderBy.save( orderBy ); rendererElement.appendChild( orderBy ); } - rendererElement.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? "1" : "0" ) ); + rendererElement.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); return rendererElement; } diff --git a/src/core/symbology/qgsrenderer.cpp b/src/core/symbology/qgsrenderer.cpp index 07f48f9f624e..7f5f0bfd6fc3 100644 --- a/src/core/symbology/qgsrenderer.cpp +++ b/src/core/symbology/qgsrenderer.cpp @@ -154,7 +154,7 @@ QDomElement QgsFeatureRenderer::save( QDomDocument &doc, const QgsReadWriteConte Q_UNUSED( context ); // create empty renderer element QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME ); - rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); if ( mPaintEffect && !QgsPaintEffectRegistry::isDefaultStack( mPaintEffect ) ) mPaintEffect->saveProperties( doc, rendererElem ); @@ -165,7 +165,7 @@ QDomElement QgsFeatureRenderer::save( QDomDocument &doc, const QgsReadWriteConte mOrderBy.save( orderBy ); rendererElem.appendChild( orderBy ); } - rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); return rendererElem; } diff --git a/src/core/symbology/qgsrulebasedrenderer.cpp b/src/core/symbology/qgsrulebasedrenderer.cpp index cca00e3e5a9a..4bf327a4c247 100644 --- a/src/core/symbology/qgsrulebasedrenderer.cpp +++ b/src/core/symbology/qgsrulebasedrenderer.cpp @@ -939,8 +939,8 @@ QDomElement QgsRuleBasedRenderer::save( QDomDocument &doc, const QgsReadWriteCon { QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME ); rendererElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "RuleRenderer" ) ); - rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? "1" : "0" ) ); - rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); + rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); QgsSymbolMap symbols; @@ -960,7 +960,7 @@ QDomElement QgsRuleBasedRenderer::save( QDomDocument &doc, const QgsReadWriteCon mOrderBy.save( orderBy ); rendererElem.appendChild( orderBy ); } - rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); return rendererElem; } @@ -1107,7 +1107,7 @@ void QgsRuleBasedRenderer::refineRuleRanges( QgsRuleBasedRenderer::Rule *initial { // due to the loss of precision in double->string conversion we may miss out values at the limit of the range // TODO: have a possibility to construct expressions directly as a parse tree to avoid loss of precision - QString filter = QStringLiteral( "%1 %2 %3 AND %1 <= %4" ).arg( attr, firstRange ? ">=" : ">", + QString filter = QStringLiteral( "%1 %2 %3 AND %1 <= %4" ).arg( attr, firstRange ? QStringLiteral( ">=" ) : QStringLiteral( ">" ), QString::number( rng.lowerValue(), 'f', 4 ), QString::number( rng.upperValue(), 'f', 4 ) ); firstRange = false; diff --git a/src/core/symbology/qgssinglesymbolrenderer.cpp b/src/core/symbology/qgssinglesymbolrenderer.cpp index 6c8f303bbde3..9439080b25b5 100644 --- a/src/core/symbology/qgssinglesymbolrenderer.cpp +++ b/src/core/symbology/qgssinglesymbolrenderer.cpp @@ -156,7 +156,7 @@ QgsFeatureRenderer *QgsSingleSymbolRenderer::create( QDomElement &element, const sizeScaleElem.attribute( QStringLiteral( "field" ) ) ); } - QDomElement ddsLegendSizeElem = element.firstChildElement( "data-defined-size-legend" ); + QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral( "data-defined-size-legend" ) ); if ( !ddsLegendSizeElem.isNull() ) { r->mDataDefinedSizeLegend.reset( QgsDataDefinedSizeLegend::readXml( ddsLegendSizeElem, context ) ); @@ -258,8 +258,8 @@ QDomElement QgsSingleSymbolRenderer::save( QDomDocument &doc, const QgsReadWrite { QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME ); rendererElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "singleSymbol" ) ); - rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? "1" : "0" ) ); - rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); + rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); QgsSymbolMap symbols; symbols[QStringLiteral( "0" )] = mSymbol.get(); @@ -281,7 +281,7 @@ QDomElement QgsSingleSymbolRenderer::save( QDomDocument &doc, const QgsReadWrite mOrderBy.save( orderBy ); rendererElem.appendChild( orderBy ); } - rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? "1" : "0" ) ); + rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) ); if ( mDataDefinedSizeLegend ) { diff --git a/src/core/symbology/qgsstyle.cpp b/src/core/symbology/qgsstyle.cpp index 4821d3066679..a641e47be990 100644 --- a/src/core/symbology/qgsstyle.cpp +++ b/src/core/symbology/qgsstyle.cpp @@ -803,7 +803,7 @@ QStringList QgsStyle::findSymbols( StyleEntity type, const QString &qword ) } // first find symbols with matching name - QString item = ( type == SymbolEntity ) ? "symbol" : "colorramp"; + QString item = ( type == SymbolEntity ) ? QStringLiteral( "symbol" ) : QStringLiteral( "colorramp" ); char *query = sqlite3_mprintf( "SELECT name FROM %q WHERE name LIKE '%%%q%%'", item.toUtf8().constData(), qword.toUtf8().constData() ); @@ -887,7 +887,7 @@ bool QgsStyle::tagSymbol( StyleEntity type, const QString &symbol, const QString Q_FOREACH ( const QString &t, tags ) { tag = t.trimmed(); - if ( tag != "" ) + if ( !tag.isEmpty() ) { // sql: gets the id of the tag if present or insert the tag and get the id of the tag char *query = sqlite3_mprintf( "SELECT id FROM tag WHERE LOWER(name)='%q'", tag.toUtf8().toLower().constData() ); @@ -1463,11 +1463,11 @@ bool QgsStyle::exportXml( const QString &filename ) QStringList tags = tagsOfSymbol( SymbolEntity, name ); if ( tags.count() > 0 ) { - symbol.setAttribute( QStringLiteral( "tags" ), tags.join( "," ) ); + symbol.setAttribute( QStringLiteral( "tags" ), tags.join( ',' ) ); } if ( favoriteSymbols.contains( name ) ) { - symbol.setAttribute( QStringLiteral( "favorite" ), "1" ); + symbol.setAttribute( QStringLiteral( "favorite" ), QStringLiteral( "1" ) ); } } @@ -1479,11 +1479,11 @@ bool QgsStyle::exportXml( const QString &filename ) QStringList tags = tagsOfSymbol( ColorrampEntity, itr.key() ); if ( tags.count() > 0 ) { - rampEl.setAttribute( QStringLiteral( "tags" ), tags.join( "," ) ); + rampEl.setAttribute( QStringLiteral( "tags" ), tags.join( ',' ) ); } if ( favoriteColorramps.contains( itr.key() ) ) { - rampEl.setAttribute( QStringLiteral( "favorite" ), "1" ); + rampEl.setAttribute( QStringLiteral( "favorite" ), QStringLiteral( "1" ) ); } rampsElem.appendChild( rampEl ); } @@ -1564,10 +1564,10 @@ bool QgsStyle::importXml( const QString &filename ) QStringList tags; if ( e.hasAttribute( QStringLiteral( "tags" ) ) ) { - tags = e.attribute( QStringLiteral( "tags" ) ).split( "," ); + tags = e.attribute( QStringLiteral( "tags" ) ).split( ',' ); } bool favorite = false; - if ( e.hasAttribute( QStringLiteral( "favorite" ) ) && e.attribute( QStringLiteral( "favorite" ) ) == "1" ) + if ( e.hasAttribute( QStringLiteral( "favorite" ) ) && e.attribute( QStringLiteral( "favorite" ) ) == QStringLiteral( "1" ) ) { favorite = true; } @@ -1612,10 +1612,10 @@ bool QgsStyle::importXml( const QString &filename ) QStringList tags; if ( e.hasAttribute( QStringLiteral( "tags" ) ) ) { - tags = e.attribute( QStringLiteral( "tags" ) ).split( "," ); + tags = e.attribute( QStringLiteral( "tags" ) ).split( ',' ); } bool favorite = false; - if ( e.hasAttribute( QStringLiteral( "favorite" ) ) && e.attribute( QStringLiteral( "favorite" ) ) == "1" ) + if ( e.hasAttribute( QStringLiteral( "favorite" ) ) && e.attribute( QStringLiteral( "favorite" ) ) == QStringLiteral( "1" ) ) { favorite = true; } diff --git a/src/core/symbology/qgssymbollayer.cpp b/src/core/symbology/qgssymbollayer.cpp index d84b2f2fd1d9..b0574ea16d9b 100644 --- a/src/core/symbology/qgssymbollayer.cpp +++ b/src/core/symbology/qgssymbollayer.cpp @@ -350,9 +350,9 @@ void QgsSymbolLayer::restoreOldDataDefinedProperties( const QgsStringMap &string if ( type() == QgsSymbol::Line ) { //these keys had different meaning for line symbol layers - if ( propertyName == "width" ) + if ( propertyName == QLatin1String( "width" ) ) key = QgsSymbolLayer::PropertyStrokeWidth; - else if ( propertyName == "color" ) + else if ( propertyName == QLatin1String( "color" ) ) key = QgsSymbolLayer::PropertyStrokeColor; } diff --git a/src/core/symbology/qgssymbollayerutils.cpp b/src/core/symbology/qgssymbollayerutils.cpp index 05062070e112..fa05931d7e88 100644 --- a/src/core/symbology/qgssymbollayerutils.cpp +++ b/src/core/symbology/qgssymbollayerutils.cpp @@ -885,7 +885,7 @@ QgsSymbol *QgsSymbolLayerUtils::loadSymbol( const QDomElement &element, const Qg { symbol->setOutputUnit( QgsUnitTypes::decodeRenderUnit( element.attribute( QStringLiteral( "outputUnit" ) ) ) ); } - if ( element.hasAttribute( ( "mapUnitScale" ) ) ) + if ( element.hasAttribute( ( QStringLiteral( "mapUnitScale" ) ) ) ) { QgsMapUnitScale mapUnitScale; double oldMin = element.attribute( QStringLiteral( "mapUnitMinScale" ), QStringLiteral( "0.0" ) ).toDouble(); @@ -966,7 +966,7 @@ QDomElement QgsSymbolLayerUtils::saveSymbol( const QString &name, QgsSymbol *sym symEl.setAttribute( QStringLiteral( "type" ), _nameForSymbolType( symbol->type() ) ); symEl.setAttribute( QStringLiteral( "name" ), name ); symEl.setAttribute( QStringLiteral( "alpha" ), QString::number( symbol->opacity() ) ); - symEl.setAttribute( QStringLiteral( "clip_to_extent" ), symbol->clipFeaturesToExtent() ? "1" : "0" ); + symEl.setAttribute( QStringLiteral( "clip_to_extent" ), symbol->clipFeaturesToExtent() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); //QgsDebugMsg( "num layers " + QString::number( symbol->symbolLayerCount() ) ); for ( int i = 0; i < symbol->symbolLayerCount(); i++ ) @@ -2050,8 +2050,8 @@ QString QgsSymbolLayerUtils::getSvgParametricPath( const QString &basePath, cons } else { - url.addQueryItem( "fill", QStringLiteral( "#000000" ) ); - url.addQueryItem( "fill-opacity", QStringLiteral( "1" ) ); + url.addQueryItem( QStringLiteral( "fill" ), QStringLiteral( "#000000" ) ); + url.addQueryItem( QStringLiteral( "fill-opacity" ), QStringLiteral( "1" ) ); } if ( strokeColor.isValid() ) { diff --git a/src/gui/auth/qgsauthguiutils.h b/src/gui/auth/qgsauthguiutils.h index be1f2cedc756..47c0f4c3721c 100644 --- a/src/gui/auth/qgsauthguiutils.h +++ b/src/gui/auth/qgsauthguiutils.h @@ -97,4 +97,6 @@ class GUI_EXPORT QgsAuthGuiUtils }; +// clazy:excludeall=qstring-allocations + #endif // QGSAUTHGUIUTILS_H diff --git a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp index 38764515f19b..399abed8ee84 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp +++ b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp @@ -186,7 +186,7 @@ void QgsEditorWidgetWrapper::updateConstraint( const QgsVectorLayer *layer, int hardConstraintsOk = true; softConstraintsOk = false; - errors << "Invalid feature"; + errors << QStringLiteral( "Invalid feature" ); toEmit = true; } @@ -195,16 +195,16 @@ void QgsEditorWidgetWrapper::updateConstraint( const QgsVectorLayer *layer, int mValidConstraint = hardConstraintsOk && softConstraintsOk; mIsBlockingCommit = !hardConstraintsOk; - mConstraintFailureReason = errors.join( ", " ); + mConstraintFailureReason = errors.join( QStringLiteral( ", " ) ); if ( toEmit ) { QString errStr = errors.isEmpty() ? tr( "Constraint checks passed" ) : mConstraintFailureReason; - QString description = descriptions.join( ", " ); + QString description = descriptions.join( QStringLiteral( ", " ) ); QString expressionDesc; if ( expressions.size() > 1 ) - expressionDesc = "( " + expressions.join( " ) AND ( " ) + " )"; + expressionDesc = "( " + expressions.join( QStringLiteral( " ) AND ( " ) ) + " )"; else if ( !expressions.isEmpty() ) expressionDesc = expressions.at( 0 ); diff --git a/src/gui/editorwidgets/qgsdatetimeedit.h b/src/gui/editorwidgets/qgsdatetimeedit.h index 62e38c615f1b..53336ff36f25 100644 --- a/src/gui/editorwidgets/qgsdatetimeedit.h +++ b/src/gui/editorwidgets/qgsdatetimeedit.h @@ -94,7 +94,7 @@ class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit */ void setMinimumEditDateTime() { - setMinimumDateTime( QDateTime::fromString( "0100-01-01", Qt::ISODate ) ); + setMinimumDateTime( QDateTime::fromString( QStringLiteral( "0100-01-01" ), Qt::ISODate ) ); } }; diff --git a/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp b/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp index 74327bb63a14..16c2fde19ddc 100644 --- a/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp +++ b/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp @@ -93,7 +93,7 @@ void QgsExternalResourceWidgetWrapper::setFeature( const QgsFeature &feature ) } if ( mPropertyCollection.isActive( QgsEditorWidgetWrapper::DocumentViewerContent ) ) { - QString dvcString = mPropertyCollection.valueAsString( QgsEditorWidgetWrapper::DocumentViewerContent, expressionContext, "NoContent", &ok ); + QString dvcString = mPropertyCollection.valueAsString( QgsEditorWidgetWrapper::DocumentViewerContent, expressionContext, QStringLiteral( "NoContent" ), &ok ); if ( ok ) { QgsExternalResourceWidget::DocumentViewerContent dvc; @@ -154,7 +154,7 @@ void QgsExternalResourceWidgetWrapper::initWidget( QWidget *editor ) mQgsWidget->fileWidget()->setFullUrl( cfg.value( QStringLiteral( "FullUrl" ) ).toBool() ); } - mPropertyCollection.loadVariant( cfg.value( "PropertyCollection" ), propertyDefinitions() ); + mPropertyCollection.loadVariant( cfg.value( QStringLiteral( "PropertyCollection" ) ), propertyDefinitions() ); if ( !mPropertyCollection.isActive( QgsWidgetWrapper::RootPath ) ) { mQgsWidget->setDefaultRoot( cfg.value( QStringLiteral( "DefaultRoot" ) ).toString() ); diff --git a/src/gui/layertree/qgslayertreeview.cpp b/src/gui/layertree/qgslayertreeview.cpp index 6dd783a38446..accdb5e43f3f 100644 --- a/src/gui/layertree/qgslayertreeview.cpp +++ b/src/gui/layertree/qgslayertreeview.cpp @@ -355,7 +355,7 @@ static void _expandAllLegendNodes( QgsLayerTreeLayer *nodeLayer, bool expanded, lst << parentKey; } } - nodeLayer->setCustomProperty( "expandedLegendNodes", lst ); + nodeLayer->setCustomProperty( QStringLiteral( "expandedLegendNodes" ), lst ); } diff --git a/src/gui/layout/qgslayoutruler.cpp b/src/gui/layout/qgslayoutruler.cpp index c95aee8e4c84..744954a9412f 100644 --- a/src/gui/layout/qgslayoutruler.cpp +++ b/src/gui/layout/qgslayoutruler.cpp @@ -55,7 +55,7 @@ QgsLayoutRuler::QgsLayoutRuler( QWidget *parent, Qt::Orientation orientation ) mTextBaseline = mRulerMinSize / 1.667; mMinSpacingVerticalLabels = mRulerMinSize / 5; - double guideMarkerSize = mRulerFontMetrics->width( "*" ); + double guideMarkerSize = mRulerFontMetrics->width( QStringLiteral( "*" ) ); mDragGuideTolerance = guideMarkerSize; switch ( mOrientation ) { diff --git a/src/gui/layout/qgslayoutview.cpp b/src/gui/layout/qgslayoutview.cpp index 785ec47f1524..08e1878116c2 100644 --- a/src/gui/layout/qgslayoutview.cpp +++ b/src/gui/layout/qgslayoutview.cpp @@ -503,7 +503,7 @@ QgsLayoutViewSnapMarker::QgsLayoutViewSnapMarker() { QFont f; QFontMetrics fm( f ); - mSize = fm.width( "X" ); + mSize = fm.width( QStringLiteral( "X" ) ); setPen( QPen( Qt::transparent, mSize ) ); setFlags( flags() | QGraphicsItem::ItemIgnoresTransformations ); diff --git a/src/gui/locator/qgslocatorwidget.cpp b/src/gui/locator/qgslocatorwidget.cpp index 2b183ae1117d..583613c62b8d 100644 --- a/src/gui/locator/qgslocatorwidget.cpp +++ b/src/gui/locator/qgslocatorwidget.cpp @@ -100,7 +100,7 @@ QgsLocatorWidget::QgsLocatorWidget( QWidget *parent ) mLocator->registerFilter( new QgsLocatorFilterFilter( this, this ) ); mMenu = new QMenu( this ); - QAction *menuAction = mLineEdit->addAction( QgsApplication::getThemeIcon( "/search.svg" ), QLineEdit::LeadingPosition ); + QAction *menuAction = mLineEdit->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/search.svg" ) ), QLineEdit::LeadingPosition ); connect( menuAction, &QAction::triggered, this, [ = ] { mFocusTimer.stop(); @@ -421,7 +421,7 @@ void QgsLocatorFilterFilter::fetchResults( const QString &string, const QgsLocat result.displayString = fIt.key(); result.description = fIt.value()->displayName(); result.userData = fIt.key() + ' '; - result.icon = QgsApplication::getThemeIcon( "/search.svg" ); + result.icon = QgsApplication::getThemeIcon( QStringLiteral( "/search.svg" ) ); emit resultFetched( result ); } } diff --git a/src/gui/qgsbusyindicatordialog.h b/src/gui/qgsbusyindicatordialog.h index 2ebd85f7d224..94fc241e32bf 100644 --- a/src/gui/qgsbusyindicatordialog.h +++ b/src/gui/qgsbusyindicatordialog.h @@ -41,7 +41,7 @@ class GUI_EXPORT QgsBusyIndicatorDialog : public QDialog * \param parent parent object (owner) * \param fl widget flags */ - QgsBusyIndicatorDialog( const QString &message = "", QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags ); + QgsBusyIndicatorDialog( const QString &message = QString(), QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags ); QString message() const { return mMessage; } void setMessage( const QString &message ); @@ -51,4 +51,6 @@ class GUI_EXPORT QgsBusyIndicatorDialog : public QDialog QLabel *mMsgLabel = nullptr; }; +// clazy:excludeall=qstring-allocations + #endif // QGSBUSYINDICATORDIALOG_H diff --git a/src/gui/qgscheckablecombobox.cpp b/src/gui/qgscheckablecombobox.cpp index 6d18c9739148..6e18ea8a5eb0 100644 --- a/src/gui/qgscheckablecombobox.cpp +++ b/src/gui/qgscheckablecombobox.cpp @@ -75,7 +75,7 @@ void QgsCheckBoxDelegate::paint( QPainter *painter, const QStyleOptionViewItem & QgsCheckableComboBox::QgsCheckableComboBox( QWidget *parent ) : QComboBox( parent ) - , mSeparator( ", " ) + , mSeparator( QStringLiteral( ", " ) ) { setModel( new QgsCheckableItemModel( this ) ); setItemDelegate( new QgsCheckBoxDelegate( this ) ); diff --git a/src/gui/qgscodeeditor.h b/src/gui/qgscodeeditor.h index 09560e276b00..e9a8830b8472 100644 --- a/src/gui/qgscodeeditor.h +++ b/src/gui/qgscodeeditor.h @@ -49,7 +49,7 @@ class GUI_EXPORT QgsCodeEditor : public QsciScintilla * \param margin false: Enable margin for code editor * \since QGIS 2.6 */ - QgsCodeEditor( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &title = "", bool folding = false, bool margin = false ); + QgsCodeEditor( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &title = QString(), bool folding = false, bool margin = false ); /** Set the widget title * \param title widget title @@ -92,4 +92,6 @@ class GUI_EXPORT QgsCodeEditor : public QsciScintilla bool mMargin; }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/gui/qgscolorbutton.h b/src/gui/qgscolorbutton.h index 4ee2ee6d8796..27f65a0b8325 100644 --- a/src/gui/qgscolorbutton.h +++ b/src/gui/qgscolorbutton.h @@ -74,7 +74,7 @@ class GUI_EXPORT QgsColorButton : public QToolButton * Use a color scheme \a registry for color swatch grids to show in the drop-down menu. If not specified, * the button will use the global color scheme registry instead */ - QgsColorButton( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &cdt = "", QgsColorSchemeRegistry *registry = nullptr ); + QgsColorButton( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &cdt = QString(), QgsColorSchemeRegistry *registry = nullptr ); virtual QSize minimumSizeHint() const override; virtual QSize sizeHint() const override; diff --git a/src/gui/qgscolorrampbutton.cpp b/src/gui/qgscolorrampbutton.cpp index 1c6de28b9d2c..be7b3f306f2c 100644 --- a/src/gui/qgscolorrampbutton.cpp +++ b/src/gui/qgscolorrampbutton.cpp @@ -561,7 +561,7 @@ void QgsColorRampButton::setButtonBackground( QgsColorRamp *colorramp ) painter.begin( &pm ); painter.setPen( pen ); - painter.drawText( QRect( 0, 0, currentIconSize.width(), currentIconSize.height() ), Qt::AlignCenter, "Random colors" ); + painter.drawText( QRect( 0, 0, currentIconSize.width(), currentIconSize.height() ), Qt::AlignCenter, QStringLiteral( "Random colors" ) ); painter.end(); } else diff --git a/src/gui/qgsexpressionbuilderdialog.h b/src/gui/qgsexpressionbuilderdialog.h index e2a1d33d66fe..00bf86607cd8 100644 --- a/src/gui/qgsexpressionbuilderdialog.h +++ b/src/gui/qgsexpressionbuilderdialog.h @@ -82,4 +82,6 @@ class GUI_EXPORT QgsExpressionBuilderDialog : public QDialog, private Ui::QgsExp }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/gui/qgsexpressionbuilderwidget.h b/src/gui/qgsexpressionbuilderwidget.h index 3c27aaf53c02..63705dc836ef 100644 --- a/src/gui/qgsexpressionbuilderwidget.h +++ b/src/gui/qgsexpressionbuilderwidget.h @@ -188,7 +188,7 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp * \param sortOrder sort ranking for item */ void registerItem( const QString &group, const QString &label, const QString &expressionText, - const QString &helpText = "", + const QString &helpText = QString(), QgsExpressionItem::ItemType type = QgsExpressionItem::ExpressionNode, bool highlightedItem = false, int sortOrder = 1 ); @@ -325,7 +325,7 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp * \param sortOrder sort ranking for item */ void registerItemForAllGroups( const QStringList &groups, const QString &label, const QString &expressionText, - const QString &helpText = "", + const QString &helpText = QString(), QgsExpressionItem::ItemType type = QgsExpressionItem::ExpressionNode, bool highlightedItem = false, int sortOrder = 1 ); @@ -356,4 +356,6 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp QPointer< QgsProject > mProject; }; +// clazy:excludeall=qstring-allocations + #endif // QGSEXPRESSIONBUILDER_H diff --git a/src/gui/qgsfieldvalidator.h b/src/gui/qgsfieldvalidator.h index d1cee224dcb8..c406fa2b147e 100644 --- a/src/gui/qgsfieldvalidator.h +++ b/src/gui/qgsfieldvalidator.h @@ -53,4 +53,6 @@ class GUI_EXPORT QgsFieldValidator : public QValidator QString mDateFormat; }; +// clazy:excludeall=qstring-allocations + #endif // QGSFIELDVALIDATOR_H diff --git a/src/gui/qgsfiledownloader.cpp b/src/gui/qgsfiledownloader.cpp index 13bfcee76232..85b46c8fb510 100644 --- a/src/gui/qgsfiledownloader.cpp +++ b/src/gui/qgsfiledownloader.cpp @@ -110,7 +110,7 @@ void QgsFileDownloader::onSslErrors( QNetworkReply *reply, const QList" ) ); + QMessageBox::warning( nullptr, tr( "Download failed" ), mErrors.join( QStringLiteral( "
" ) ) ); } emit downloadError( mErrors ); } diff --git a/src/gui/qgsfilewidget.cpp b/src/gui/qgsfilewidget.cpp index b980e8608868..b08348f545d9 100644 --- a/src/gui/qgsfilewidget.cpp +++ b/src/gui/qgsfilewidget.cpp @@ -316,7 +316,7 @@ void QgsFileWidget::openFileDialog() } if ( fileNames.length() > 1 ) { - setFilePath( QStringLiteral( "\"%1\"" ).arg( fileNames.join( "\" \"" ) ) ); + setFilePath( QStringLiteral( "\"%1\"" ).arg( fileNames.join( QStringLiteral( "\" \"" ) ) ) ); } else { @@ -403,7 +403,7 @@ void QgsFileDropEdit::setFilters( const QString &filters ) if ( filters.contains( QStringLiteral( "*.*" ) ) ) return; // everything is allowed! - QRegularExpression rx( "\\*\\.(\\w+)" ); + QRegularExpression rx( QStringLiteral( "\\*\\.(\\w+)" ) ); QRegularExpressionMatchIterator i = rx.globalMatch( filters ); while ( i.hasNext() ) { @@ -431,7 +431,7 @@ QString QgsFileDropEdit::acceptableFilePath( QDropEvent *event ) const } if ( paths.size() > 1 ) { - return QStringLiteral( "\"%1\"" ).arg( paths.join( "\" \"" ) ); + return QStringLiteral( "\"%1\"" ).arg( paths.join( QStringLiteral( "\" \"" ) ) ); } else if ( paths.size() == 1 ) { diff --git a/src/gui/qgshelp.cpp b/src/gui/qgshelp.cpp index 5977ebafa350..c12184085acc 100644 --- a/src/gui/qgshelp.cpp +++ b/src/gui/qgshelp.cpp @@ -55,7 +55,7 @@ QUrl QgsHelp::helpUrl( const QString &key ) Q_FOREACH ( const QString &path, paths ) { - if ( path.endsWith( "\\" ) || path.endsWith( "/" ) ) + if ( path.endsWith( QLatin1String( "\\" ) ) || path.endsWith( QLatin1String( "/" ) ) ) { fullPath = path.left( path.size() - 1 ); } @@ -69,7 +69,7 @@ QUrl QgsHelp::helpUrl( const QString &key ) QRegularExpression rx( QStringLiteral( "(variable( var ).toString() ); } - fullPath.replace( QRegularExpression( "(\\$\\$)" ), "$" ); + fullPath.replace( QRegularExpression( QStringLiteral( "(\\$\\$)" ) ), QStringLiteral( "$" ) ); helpPath = QStringLiteral( "%1/%2" ).arg( fullPath, key ); @@ -83,16 +83,16 @@ QUrl QgsHelp::helpUrl( const QString &key ) } else { - QString filePath = helpPath.mid( 0, helpPath.lastIndexOf( "#" ) ); + QString filePath = helpPath.mid( 0, helpPath.lastIndexOf( QLatin1String( "#" ) ) ); if ( !QFileInfo::exists( filePath ) ) { continue; } helpUrl = QUrl::fromLocalFile( filePath ); - int pos = helpPath.lastIndexOf( "#" ); + int pos = helpPath.lastIndexOf( QLatin1String( "#" ) ); if ( pos != -1 ) { - helpUrl.setFragment( helpPath.mid( helpPath.lastIndexOf( "#" ) + 1, -1 ) ); + helpUrl.setFragment( helpPath.mid( helpPath.lastIndexOf( QLatin1String( "#" ) ) + 1, -1 ) ); } } diff --git a/src/gui/qgsmanageconnectionsdialog.h b/src/gui/qgsmanageconnectionsdialog.h index 36f907223d8c..af483e010f58 100644 --- a/src/gui/qgsmanageconnectionsdialog.h +++ b/src/gui/qgsmanageconnectionsdialog.h @@ -53,7 +53,7 @@ class GUI_EXPORT QgsManageConnectionsDialog : public QDialog, private Ui::QgsMan // constructor // mode argument must be 0 for export and 1 for import // type argument must be 0 for WMS and 1 for PostGIS - QgsManageConnectionsDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Mode mode = Export, Type type = WMS, const QString &fileName = "" ); + QgsManageConnectionsDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Mode mode = Export, Type type = WMS, const QString &fileName = QString() ); public slots: void doExportImport(); @@ -85,5 +85,7 @@ class GUI_EXPORT QgsManageConnectionsDialog : public QDialog, private Ui::QgsMan Type mConnectionType; }; +// clazy:excludeall=qstring-allocations + #endif // QGSMANAGECONNECTIONSDIALOG_H diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index 3abeb2417967..47eb3b8aeb46 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -911,6 +911,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView }; // class QgsMapCanvas - +// clazy:excludeall=qstring-allocations #endif diff --git a/src/gui/qgsmessagebar.cpp b/src/gui/qgsmessagebar.cpp index 5a2f1258aa03..b07a09b06b2e 100644 --- a/src/gui/qgsmessagebar.cpp +++ b/src/gui/qgsmessagebar.cpp @@ -272,7 +272,7 @@ void QgsMessageBar::pushItem( QgsMessageBarItem *item ) // Log all messages that are sent to the message bar into the message log so the // user can get them back easier. - QString formattedTitle = QString( "%1 : %2" ).arg( item->title(), item->text() ); + QString formattedTitle = QStringLiteral( "%1 : %2" ).arg( item->title(), item->text() ); QgsMessageLog::MessageLevel level; switch ( item->level() ) { diff --git a/src/gui/qgsmessagelogviewer.cpp b/src/gui/qgsmessagelogviewer.cpp index 98de30298675..5e6befc467fb 100644 --- a/src/gui/qgsmessagelogviewer.cpp +++ b/src/gui/qgsmessagelogviewer.cpp @@ -79,16 +79,16 @@ void QgsMessageLogViewer::logMessage( const QString &message, const QString &tag switch ( level ) { case QgsMessageLog::INFO: - levelString = "INFO"; + levelString = QStringLiteral( "INFO" ); break; case QgsMessageLog::WARNING: - levelString = "WARNING"; + levelString = QStringLiteral( "WARNING" ); break; case QgsMessageLog::CRITICAL: - levelString = "CRITICAL"; + levelString = QStringLiteral( "CRITICAL" ); break; case QgsMessageLog::NONE: - levelString = "NONE"; + levelString = QStringLiteral( "NONE" ); break; } diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 0362372bec79..1ea0c2699163 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -379,7 +379,7 @@ void QgsMetadataWidget::setPropertiesFromLayer() const addVocabulary(); int currentRow = tabKeywords->rowCount() - 1; tabKeywords->item( currentRow, 0 )->setText( i.key() ); - tabKeywords->item( currentRow, 1 )->setText( i.value().join( "," ) ); + tabKeywords->item( currentRow, 1 )->setText( i.value().join( QStringLiteral( "," ) ) ); } // Fees @@ -635,7 +635,7 @@ QStringList QgsMetadataWidget::parseMimeTypes() QStringList wordList; wordList.append( QString() ); // We add an empty line, because it's not compulsory. - QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "mime.csv" ) ); + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QStringLiteral( "mime.csv" ) ); QFile file( path ); if ( !file.open( QIODevice::ReadOnly ) ) { @@ -700,7 +700,7 @@ void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() const row = tabKeywords->rowCount() - 1; tabKeywords->item( row, 0 )->setText( QStringLiteral( "gmd:topicCategory" ) ); } - tabKeywords->item( row, 1 )->setText( mCategoriesModel->stringList().join( "," ) ); + tabKeywords->item( row, 1 )->setText( mCategoriesModel->stringList().join( QStringLiteral( "," ) ) ); } } @@ -716,7 +716,7 @@ void QgsMetadataWidget::updatePanel() const if ( !categories.isEmpty() ) { int row = categories.at( 0 )->row(); - mCategoriesModel->setStringList( tabKeywords->item( row, 1 )->text().split( "," ) ); + mCategoriesModel->setStringList( tabKeywords->item( row, 1 )->text().split( QStringLiteral( "," ) ) ); } else { @@ -829,7 +829,7 @@ QWidget *ConstraintItemDelegate::createEditor( QWidget *parent, const QStyleOpti QComboBox *typeEditor = new QComboBox( parent ); typeEditor->setEditable( true ); QStringList types; - types << QString( "access" ) << QString( "use" ) << QString( "other" ); + types << QStringLiteral( "access" ) << QStringLiteral( "use" ) << QStringLiteral( "other" ); QStringListModel *model = new QStringListModel( parent ); model->setStringList( types ); typeEditor->setModel( model ); diff --git a/src/gui/qgsnewgeopackagelayerdialog.cpp b/src/gui/qgsnewgeopackagelayerdialog.cpp index e90cfc6f8a39..e7083984d416 100644 --- a/src/gui/qgsnewgeopackagelayerdialog.cpp +++ b/src/gui/qgsnewgeopackagelayerdialog.cpp @@ -412,7 +412,7 @@ bool QgsNewGeoPackageLayerDialog::apply() ogrType = OFTString; else if ( fieldType == QLatin1String( "integer" ) ) ogrType = OFTInteger; - else if ( fieldType == "integer64" ) + else if ( fieldType == QLatin1String( "integer64" ) ) ogrType = OFTInteger64; else if ( fieldType == QLatin1String( "real" ) ) ogrType = OFTReal; diff --git a/src/gui/qgsnewhttpconnection.h b/src/gui/qgsnewhttpconnection.h index 3ae0d57b12e1..2ae2ad89aa64 100644 --- a/src/gui/qgsnewhttpconnection.h +++ b/src/gui/qgsnewhttpconnection.h @@ -147,4 +147,6 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo Q_DECLARE_OPERATORS_FOR_FLAGS( QgsNewHttpConnection::ConnectionTypes ) Q_DECLARE_OPERATORS_FOR_FLAGS( QgsNewHttpConnection::Flags ) +// clazy:excludeall=qstring-allocations + #endif // QGSNEWHTTPCONNECTION_H diff --git a/src/gui/qgsoptionsdialogbase.cpp b/src/gui/qgsoptionsdialogbase.cpp index e3667299de0e..2cf746ad7b8e 100644 --- a/src/gui/qgsoptionsdialogbase.cpp +++ b/src/gui/qgsoptionsdialogbase.cpp @@ -99,7 +99,7 @@ void QgsOptionsDialogBase::initOptionsBase( bool restoreUi, const QString &title mOptSplitter = findChild( QStringLiteral( "mOptionsSplitter" ) ); mOptButtonBox = findChild( QStringLiteral( "buttonBox" ) ); QFrame *buttonBoxFrame = findChild( QStringLiteral( "mButtonBoxFrame" ) ); - mSearchLineEdit = findChild( "mSearchLineEdit" ); + mSearchLineEdit = findChild( QStringLiteral( "mSearchLineEdit" ) ); if ( !mOptListWidget || !mOptStackedWidget || !mOptSplitter || !optionsFrame ) { @@ -402,22 +402,22 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget { if ( qobject_cast( widget ) ) { - mStyleSheet = "QLabel { background-color: yellow; color: blue;}"; + mStyleSheet = QStringLiteral( "QLabel { background-color: yellow; color: blue;}" ); mText = [ = ]() {return qobject_cast( mWidget )->text();}; } else if ( qobject_cast( widget ) ) { - mStyleSheet = "QCheckBox { background-color: yellow; color: blue;}"; + mStyleSheet = QStringLiteral( "QCheckBox { background-color: yellow; color: blue;}" ); mText = [ = ]() {return qobject_cast( mWidget )->text();}; } else if ( qobject_cast( widget ) ) { - mStyleSheet = "QAbstractButton { background-color: yellow; color: blue;}"; + mStyleSheet = QStringLiteral( "QAbstractButton { background-color: yellow; color: blue;}" ); mText = [ = ]() {return qobject_cast( mWidget )->text();}; } else if ( qobject_cast( widget ) ) { - mStyleSheet = "QGroupBox::title { background-color: yellow; color: blue;}"; + mStyleSheet = QStringLiteral( "QGroupBox::title { background-color: yellow; color: blue;}" ); mText = [ = ]() {return qobject_cast( mWidget )->title();}; } else if ( qobject_cast( widget ) ) diff --git a/src/gui/qgspasswordlineedit.cpp b/src/gui/qgspasswordlineedit.cpp index 6ccbe5cbfba2..5fd958b5760f 100644 --- a/src/gui/qgspasswordlineedit.cpp +++ b/src/gui/qgspasswordlineedit.cpp @@ -22,15 +22,15 @@ QgsPasswordLineEdit::QgsPasswordLineEdit( QWidget *parent, bool passwordVisible : QLineEdit( parent ) , mLockIconVisible( false ) { - mShowPasswordIcon = QgsApplication::getThemeIcon( "/mActionShowAllLayers.svg" ); - mHidePasswordIcon = QgsApplication::getThemeIcon( "/mActionHideAllLayers.svg" ); + mShowPasswordIcon = QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowAllLayers.svg" ) ); + mHidePasswordIcon = QgsApplication::getThemeIcon( QStringLiteral( "/mActionHideAllLayers.svg" ) ); mActionShowHidePassword = addAction( mShowPasswordIcon, QLineEdit::TrailingPosition ); mActionShowHidePassword->setCheckable( true ); if ( mLockIconVisible ) { - mActionLock = addAction( QgsApplication::getThemeIcon( "/lockedGray.svg" ), QLineEdit::LeadingPosition ); + mActionLock = addAction( QgsApplication::getThemeIcon( QStringLiteral( "/lockedGray.svg" ) ), QLineEdit::LeadingPosition ); } setPasswordVisibility( passwordVisible ); @@ -65,7 +65,7 @@ void QgsPasswordLineEdit::setShowLockIcon( bool visible ) { if ( !mActionLock ) { - mActionLock = addAction( QgsApplication::getThemeIcon( "/lockedGray.svg" ), QLineEdit::LeadingPosition ); + mActionLock = addAction( QgsApplication::getThemeIcon( QStringLiteral( "/lockedGray.svg" ) ), QLineEdit::LeadingPosition ); } } else diff --git a/src/gui/qgsprojectionselectiontreewidget.cpp b/src/gui/qgsprojectionselectiontreewidget.cpp index 0a4095e3f015..0f935aa57bdf 100644 --- a/src/gui/qgsprojectionselectiontreewidget.cpp +++ b/src/gui/qgsprojectionselectiontreewidget.cpp @@ -428,7 +428,7 @@ QgsCoordinateReferenceSystem QgsProjectionSelectionTreeWidget::crs() const int srid = getSelectedExpression( QStringLiteral( "srs_id" ) ).toLong(); if ( srid >= USER_CRS_START_ID ) - return QgsCoordinateReferenceSystem::fromOgcWmsCrs( QString( "USER:%1" ).arg( srid ) ); + return QgsCoordinateReferenceSystem::fromOgcWmsCrs( QStringLiteral( "USER:%1" ).arg( srid ) ); else return QgsCoordinateReferenceSystem::fromOgcWmsCrs( getSelectedExpression( QStringLiteral( "upper(auth_name||':'||auth_id)" ) ) ); } diff --git a/src/gui/qgspropertyoverridebutton.cpp b/src/gui/qgspropertyoverridebutton.cpp index eae6e879251b..54d70375a51b 100644 --- a/src/gui/qgspropertyoverridebutton.cpp +++ b/src/gui/qgspropertyoverridebutton.cpp @@ -39,7 +39,7 @@ QgsPropertyOverrideButton::QgsPropertyOverrideButton( QWidget *parent, // set default tool button icon properties setFixedSize( 30, 26 ); - setStyleSheet( QString( "QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) ); + setStyleSheet( QStringLiteral( "QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) ); setIconSize( QSize( 24, 24 ) ); setPopupMode( QToolButton::InstantPopup ); @@ -114,7 +114,7 @@ void QgsPropertyOverrideButton::init( int propertyKey, const QgsProperty &proper if ( !ts.isEmpty() ) { - mDataTypesString = ts.join( ", " ); + mDataTypesString = ts.join( QStringLiteral( ", " ) ); mActionDataTypes->setText( tr( "Field type: " ) + mDataTypesString ); } @@ -670,10 +670,10 @@ void QgsPropertyOverrideButton::updateGui() mFullDescription += tr( "Valid input types:
%1
" ).arg( mDataTypesString ); } - QString deftype( "" ); + QString deftype( QLatin1String( "" ) ); if ( deftip != tr( "undefined" ) ) { - deftype = QString( " (%1)" ).arg( mProperty.propertyType() == QgsProperty::ExpressionBasedProperty ? tr( "expression" ) : tr( "field" ) ); + deftype = QStringLiteral( " (%1)" ).arg( mProperty.propertyType() == QgsProperty::ExpressionBasedProperty ? tr( "expression" ) : tr( "field" ) ); } // truncate long expressions, or tool tip may be too wide for screen diff --git a/src/gui/qgsrasterformatsaveoptionswidget.h b/src/gui/qgsrasterformatsaveoptionswidget.h index a7ce38ed0515..2a10d8fd37cf 100644 --- a/src/gui/qgsrasterformatsaveoptionswidget.h +++ b/src/gui/qgsrasterformatsaveoptionswidget.h @@ -158,4 +158,6 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget, private Ui::Q }; +// clazy:excludeall=qstring-allocations + #endif // QGSRASTERLAYERSAVEASDIALOG_H diff --git a/src/gui/qgsrasterpyramidsoptionswidget.h b/src/gui/qgsrasterpyramidsoptionswidget.h index eabce63cde76..5e0ec5458f69 100644 --- a/src/gui/qgsrasterpyramidsoptionswidget.h +++ b/src/gui/qgsrasterpyramidsoptionswidget.h @@ -76,4 +76,6 @@ class GUI_EXPORT QgsRasterPyramidsOptionsWidget: public QWidget, private Ui::Qgs QMap< int, QCheckBox * > mOverviewCheckBoxes; }; +// clazy:excludeall=qstring-allocations + #endif // QGSRASTERLAYERSAVEASDIALOG_H diff --git a/src/gui/qgsratiolockbutton.cpp b/src/gui/qgsratiolockbutton.cpp index f578f1713be8..7af07597764b 100644 --- a/src/gui/qgsratiolockbutton.cpp +++ b/src/gui/qgsratiolockbutton.cpp @@ -28,7 +28,7 @@ QgsRatioLockButton::QgsRatioLockButton( QWidget *parent ) { setMinimumSize( QSize( 24, 24 ) ); - setMaximumWidth( fontMetrics().width( "000" ) ); + setMaximumWidth( fontMetrics().width( QStringLiteral( "000" ) ) ); setCheckable( true ); setAutoRaise( true ); connect( this, &QPushButton::clicked, this, &QgsRatioLockButton::buttonClicked ); diff --git a/src/gui/qgsshortcutsmanager.cpp b/src/gui/qgsshortcutsmanager.cpp index 18ad148e3355..7e4134eb59a0 100644 --- a/src/gui/qgsshortcutsmanager.cpp +++ b/src/gui/qgsshortcutsmanager.cpp @@ -307,7 +307,7 @@ void QgsShortcutsManager::updateActionToolTip( QAction *action, const QString &s QString current = action->toolTip(); // Remove the old shortcut. QRegExp rx( "\\(.*\\)" ); - current.replace( rx, "" ); + current.replace( rx, QLatin1String( "" ) ); if ( !sequence.isEmpty() ) { diff --git a/src/gui/qgsshortcutsmanager.h b/src/gui/qgsshortcutsmanager.h index b956e1cf0430..d30437357662 100644 --- a/src/gui/qgsshortcutsmanager.h +++ b/src/gui/qgsshortcutsmanager.h @@ -241,4 +241,6 @@ class GUI_EXPORT QgsShortcutsManager : public QObject void updateActionToolTip( QAction *action, const QString &sequence ); }; +// clazy:excludeall=qstring-allocations + #endif // QGSSHORTCUTSMANAGER_H diff --git a/src/gui/qgstaskmanagerwidget.cpp b/src/gui/qgstaskmanagerwidget.cpp index 2f56dc5e5dcc..632a881856c9 100644 --- a/src/gui/qgstaskmanagerwidget.cpp +++ b/src/gui/qgstaskmanagerwidget.cpp @@ -392,26 +392,26 @@ void QgsTaskStatusWidget::paintEvent( QPaintEvent *e ) QIcon icon; if ( mInside && ( mCanCancel || ( mStatus == QgsTask::Queued || mStatus == QgsTask::OnHold ) ) ) { - icon = QgsApplication::getThemeIcon( "/mTaskCancel.svg" ); + icon = QgsApplication::getThemeIcon( QStringLiteral( "/mTaskCancel.svg" ) ); } else { switch ( mStatus ) { case QgsTask::Queued: - icon = QgsApplication::getThemeIcon( "/mTaskQueued.svg" ); + icon = QgsApplication::getThemeIcon( QStringLiteral( "/mTaskQueued.svg" ) ); break; case QgsTask::OnHold: - icon = QgsApplication::getThemeIcon( "/mTaskOnHold.svg" ); + icon = QgsApplication::getThemeIcon( QStringLiteral( "/mTaskOnHold.svg" ) ); break; case QgsTask::Running: - icon = QgsApplication::getThemeIcon( "/mTaskRunning.svg" ); + icon = QgsApplication::getThemeIcon( QStringLiteral( "/mTaskRunning.svg" ) ); break; case QgsTask::Complete: - icon = QgsApplication::getThemeIcon( "/mTaskComplete.svg" ); + icon = QgsApplication::getThemeIcon( QStringLiteral( "/mTaskComplete.svg" ) ); break; case QgsTask::Terminated: - icon = QgsApplication::getThemeIcon( "/mTaskTerminated.svg" ); + icon = QgsApplication::getThemeIcon( QStringLiteral( "/mTaskTerminated.svg" ) ); break; } } diff --git a/src/gui/raster/qgsrendererrasterpropertieswidget.cpp b/src/gui/raster/qgsrendererrasterpropertieswidget.cpp index 958c1fd628ce..511c0698f36c 100644 --- a/src/gui/raster/qgsrendererrasterpropertieswidget.cpp +++ b/src/gui/raster/qgsrendererrasterpropertieswidget.cpp @@ -342,12 +342,12 @@ void QgsRendererRasterPropertiesWidget::setRendererWidget( const QString &render QgsRectangle myExtent = mMapCanvas->mapSettings().outputExtentToLayerExtent( mRasterLayer, mMapCanvas->extent() ); if ( oldWidget ) { - if ( rendererName == "singlebandgray" ) + if ( rendererName == QLatin1String( "singlebandgray" ) ) { whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::SingleBandGray, mRasterLayer->dataProvider() ) ); whileBlocking( mRasterLayer )->setDefaultContrastEnhancement(); } - else if ( rendererName == "multibandcolor" ) + else if ( rendererName == QLatin1String( "multibandcolor" ) ) { whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::MultiBandColor, mRasterLayer->dataProvider() ) ); whileBlocking( mRasterLayer )->setDefaultContrastEnhancement(); diff --git a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp index a1d70f5926d1..51078b43d262 100644 --- a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp +++ b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp @@ -663,7 +663,7 @@ void QgsSingleBandPseudoColorRendererWidget::setFromRenderer( const QgsRasterRen else { QgsSettings settings; - QString defaultPalette = settings.value( "/Raster/defaultPalette", "Spectral" ).toString(); + QString defaultPalette = settings.value( QStringLiteral( "/Raster/defaultPalette" ), "Spectral" ).toString(); btnColorRamp->setColorRampFromName( defaultPalette ); } diff --git a/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp b/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp index bec9d35b2a96..7e9e546949a1 100644 --- a/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp +++ b/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp @@ -102,7 +102,7 @@ QgsDataDefinedSizeLegendWidget::QgsDataDefinedSizeLegendWidget( const QgsDataDef connect( mSizeClassesModel, &QStandardItemModel::dataChanged, this, &QgsDataDefinedSizeLegendWidget::onSizeClassesChanged ); // prepare layer and model to preview legend - mPreviewLayer = new QgsVectorLayer( "Point?crs=EPSG:4326", "Preview", "memory" ); + mPreviewLayer = new QgsVectorLayer( QStringLiteral( "Point?crs=EPSG:4326" ), QStringLiteral( "Preview" ), QStringLiteral( "memory" ) ); mPreviewTree = new QgsLayerTree; mPreviewLayerNode = mPreviewTree->addLayer( mPreviewLayer ); // node owned by the tree mPreviewModel = new QgsLayerTreeModel( mPreviewTree ); @@ -184,7 +184,7 @@ void QgsDataDefinedSizeLegendWidget::changeSymbol() context.setExpressionContext( &ec ); QString crsAuthId = mMapCanvas ? mMapCanvas->mapSettings().destinationCrs().authid() : QString(); - std::unique_ptr layer( new QgsVectorLayer( "Point?crs=" + crsAuthId, "tmp", "memory" ) ); + std::unique_ptr layer( new QgsVectorLayer( "Point?crs=" + crsAuthId, QStringLiteral( "tmp" ), QStringLiteral( "memory" ) ) ); QgsSymbolSelectorDialog d( newSymbol.get(), QgsStyle::defaultStyle(), layer.get(), this ); d.setContext( context ); diff --git a/src/gui/symbology/qgsstyleexportimportdialog.cpp b/src/gui/symbology/qgsstyleexportimportdialog.cpp index 8f80bab6d80f..e687a0175ad5 100644 --- a/src/gui/symbology/qgsstyleexportimportdialog.cpp +++ b/src/gui/symbology/qgsstyleexportimportdialog.cpp @@ -74,7 +74,7 @@ QgsStyleExportImportDialog::QgsStyleExportImportDialog( QgsStyle *style, QWidget importTypeCombo->addItem( tr( "URL specified below" ), QVariant( "url" ) ); connect( importTypeCombo, static_cast( &QComboBox::currentIndexChanged ), this, &QgsStyleExportImportDialog::importTypeChanged ); - mSymbolTags->setText( "imported" ); + mSymbolTags->setText( QStringLiteral( "imported" ) ); btnBrowse->setText( QStringLiteral( "Browse" ) ); connect( btnBrowse, &QAbstractButton::clicked, this, &QgsStyleExportImportDialog::browse ); @@ -202,7 +202,7 @@ bool QgsStyleExportImportDialog::populateStyles( QgsStyle *style ) QStandardItem *item = new QStandardItem( name ); QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize(), 15 ); item->setIcon( icon ); - item->setToolTip( QString( "%1
%2" ).arg( name, tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) ); + item->setToolTip( QStringLiteral( "%1
%2" ).arg( name, tags.count() > 0 ? tags.join( QStringLiteral( ", " ) ) : tr( "Not tagged" ) ) ); // Set font to 10points to show reasonable text QFont itemFont = item->font(); itemFont.setPointSize( 10 ); diff --git a/src/gui/symbology/qgsstylemanagerdialog.cpp b/src/gui/symbology/qgsstylemanagerdialog.cpp index dd45b5a9f132..7d6d4f819b59 100644 --- a/src/gui/symbology/qgsstylemanagerdialog.cpp +++ b/src/gui/symbology/qgsstylemanagerdialog.cpp @@ -286,7 +286,7 @@ void QgsStyleManagerDialog::populateSymbols( const QStringList &symbolNames, boo item->setIcon( icon ); item->setData( name ); // used to find out original name when user edited the name item->setCheckable( check ); - item->setToolTip( QString( "%1
%2" ).arg( name, tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) ); + item->setToolTip( QStringLiteral( "%1
%2" ).arg( name, tags.count() > 0 ? tags.join( QStringLiteral( ", " ) ) : tr( "Not tagged" ) ) ); // add to model model->appendRow( item ); } @@ -1389,7 +1389,7 @@ void QgsStyleManagerDialog::listitemsContextMenu( QPoint point ) { mGroupListMenu->addSeparator(); } - a = new QAction( "Create new tag... ", mGroupListMenu ); + a = new QAction( QStringLiteral( "Create new tag... " ), mGroupListMenu ); connect( a, &QAction::triggered, this, [ = ]( bool ) { tagSelectedSymbols( true ); } ); mGroupListMenu->addAction( a ); diff --git a/src/gui/symbology/qgssymbolslistwidget.cpp b/src/gui/symbology/qgssymbolslistwidget.cpp index f9de9036dc67..23e31499baad 100644 --- a/src/gui/symbology/qgssymbolslistwidget.cpp +++ b/src/gui/symbology/qgssymbolslistwidget.cpp @@ -182,7 +182,7 @@ void QgsSymbolsListWidget::populateGroups() groupsCombo->blockSignals( false ); QgsSettings settings; - index = settings.value( "qgis/symbolsListGroupsIndex", 0 ).toInt(); + index = settings.value( QStringLiteral( "qgis/symbolsListGroupsIndex" ), 0 ).toInt(); groupsCombo->setCurrentIndex( index ); populateSymbolView(); @@ -240,7 +240,7 @@ void QgsSymbolsListWidget::populateSymbols( const QStringList &names ) QStandardItem *item = new QStandardItem( names[i] ); item->setData( names[i], Qt::UserRole ); //so we can load symbol with that name item->setText( names[i] ); - item->setToolTip( QString( "%1
%2" ).arg( names[i], tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) ); + item->setToolTip( QStringLiteral( "%1
%2" ).arg( names[i], tags.count() > 0 ? tags.join( QStringLiteral( ", " ) ) : tr( "Not tagged" ) ) ); item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); // Set font to 10points to show reasonable text QFont itemFont = item->font(); diff --git a/src/plugins/geometry_checker/checks/qgsgeometryselfcontactcheck.h b/src/plugins/geometry_checker/checks/qgsgeometryselfcontactcheck.h index 85171dc14c6f..82535a69b3f4 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryselfcontactcheck.h +++ b/src/plugins/geometry_checker/checks/qgsgeometryselfcontactcheck.h @@ -21,7 +21,7 @@ class QgsGeometrySelfContactCheck : public QgsGeometryCheck void fixError( QgsGeometryCheckError *error, int method, int, Changes & ) const; QStringList getResolutionMethods() const; QString errorDescription() const { return tr( "Self contact" ); } - QString errorName() const { return "QgsGeometrySelfContactCheck"; } + QString errorName() const { return QStringLiteral( "QgsGeometrySelfContactCheck" ); } private: enum ResolutionMethod { NoChange }; }; diff --git a/src/providers/gdal/qgsgdaldataitems.cpp b/src/providers/gdal/qgsgdaldataitems.cpp index d4a630ffea27..ee73eb126fb3 100644 --- a/src/providers/gdal/qgsgdaldataitems.cpp +++ b/src/providers/gdal/qgsgdaldataitems.cpp @@ -251,9 +251,9 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem ) // class // TODO: add more OGR supported multiple layers formats here! QStringList ogrSupportedDbLayersExtensions; - ogrSupportedDbLayersExtensions << QLatin1String( "gpkg" ) << QLatin1String( "sqlite" ) << QLatin1String( "db" ) << QLatin1String( "gdb" ); + ogrSupportedDbLayersExtensions << QStringLiteral( "gpkg" ) << QStringLiteral( "sqlite" ) << QStringLiteral( "db" ) << QStringLiteral( "gdb" ); QStringList ogrSupportedDbDriverNames; - ogrSupportedDbDriverNames << QLatin1String( "GPKG" ) << QLatin1String( "db" ) << QLatin1String( "gdb" ); + ogrSupportedDbDriverNames << QStringLiteral( "GPKG" ) << QStringLiteral( "db" ) << QStringLiteral( "gdb" ); // return item without testing if: // scanExtSetting diff --git a/src/providers/gdal/qgsgdalprovider.cpp b/src/providers/gdal/qgsgdalprovider.cpp index 5546c55d433e..3c0d60d52779 100644 --- a/src/providers/gdal/qgsgdalprovider.cpp +++ b/src/providers/gdal/qgsgdalprovider.cpp @@ -1977,7 +1977,7 @@ void buildSupportedRasterFileFilterAndExtensions( QString &fileFiltersString, QS // in GDAL 2.0 vector and mixed drivers are returned by GDALGetDriver, so filter out non-raster drivers // TODO also make sure drivers are not loaded unnecessarily (as GDALAllRegister() and OGRRegisterAll load all drivers) - if ( QString( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_RASTER, nullptr ) ) != "YES" ) + if ( QString( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_RASTER, nullptr ) ) != QLatin1String( "YES" ) ) continue; // now we need to see if the driver is for something currently @@ -3041,8 +3041,8 @@ QGISEXTERN QList > *pyramidResamplingMethods() methods.append( QPair( QStringLiteral( "AVERAGE" ), QObject::tr( "Average" ) ) ); methods.append( QPair( QStringLiteral( "GAUSS" ), QObject::tr( "Gauss" ) ) ); methods.append( QPair( QStringLiteral( "CUBIC" ), QObject::tr( "Cubic" ) ) ); - methods.append( QPair( "CUBICSPLINE", QObject::tr( "Cubic Spline" ) ) ); - methods.append( QPair( "LANCZOS", QObject::tr( "Lanczos" ) ) ); + methods.append( QPair( QStringLiteral( "CUBICSPLINE" ), QObject::tr( "Cubic Spline" ) ) ); + methods.append( QPair( QStringLiteral( "LANCZOS" ), QObject::tr( "Lanczos" ) ) ); methods.append( QPair( QStringLiteral( "MODE" ), QObject::tr( "Mode" ) ) ); methods.append( QPair( QStringLiteral( "NONE" ), QObject::tr( "None" ) ) ); } diff --git a/src/providers/geonode/qgsgeonodenewconnection.cpp b/src/providers/geonode/qgsgeonodenewconnection.cpp index fe73a659c0d2..e1b66297d207 100644 --- a/src/providers/geonode/qgsgeonodenewconnection.cpp +++ b/src/providers/geonode/qgsgeonodenewconnection.cpp @@ -55,7 +55,7 @@ void QgsGeoNodeNewConnection::testConnection() bool QgsGeoNodeNewConnection::validate() { - if ( !url().contains( "://" ) ) + if ( !url().contains( QLatin1String( "://" ) ) ) { QMessageBox::warning( this, diff --git a/src/providers/geonode/qgsgeonodesourceselect.cpp b/src/providers/geonode/qgsgeonodesourceselect.cpp index eea029a13168..7a51e7100dd6 100644 --- a/src/providers/geonode/qgsgeonodesourceselect.cpp +++ b/src/providers/geonode/qgsgeonodesourceselect.cpp @@ -420,7 +420,7 @@ void QgsGeoNodeSourceSelect::addButtonClicked() // restrictToRequestBBOX='1' srsname='EPSG:26719' typename='geonode:cab_mun' url='http://demo.geonode.org/geoserver/geonode/wms' table=\"\" sql=" QgsDataSourceUri uri; - uri.setParam( QStringLiteral( "restrictToRequestBBOX" ), "1" ); + uri.setParam( QStringLiteral( "restrictToRequestBBOX" ), QStringLiteral( "1" ) ); uri.setParam( QStringLiteral( "srsname" ), crs ); if ( serviceURL.contains( QStringLiteral( "qgis-server" ) ) ) { @@ -448,8 +448,8 @@ void QgsGeoNodeSourceSelect::addButtonClicked() QgsDataSourceUri uri; uri.setParam( QStringLiteral( "url" ), serviceURL ); uri.setParam( QStringLiteral( "type" ), QStringLiteral( "xyz" ) ); - uri.setParam( QStringLiteral( "zmin" ), "0" ); - uri.setParam( QStringLiteral( "zmax" ), "18" ); + uri.setParam( QStringLiteral( "zmin" ), QStringLiteral( "0" ) ); + uri.setParam( QStringLiteral( "zmax" ), QStringLiteral( "18" ) ); emit addRasterLayer( uri.encodedUri(), layerName, QStringLiteral( "wms" ) ); } } diff --git a/src/providers/grass/qgsgrass.h b/src/providers/grass/qgsgrass.h index 898855654b02..ae326b79a897 100644 --- a/src/providers/grass/qgsgrass.h +++ b/src/providers/grass/qgsgrass.h @@ -686,4 +686,6 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject static bool sMute; }; +// clazy:excludeall=qstring-allocations + #endif // QGSGRASS_H diff --git a/src/providers/mssql/qgsmssqlprovider.cpp b/src/providers/mssql/qgsmssqlprovider.cpp index 1311664fc191..40d8bb57ee54 100644 --- a/src/providers/mssql/qgsmssqlprovider.cpp +++ b/src/providers/mssql/qgsmssqlprovider.cpp @@ -422,7 +422,7 @@ void QgsMssqlProvider::loadFields() if ( sqlType == QVariant::String ) { int length = query.value( 7 ).toInt(); - if ( sqlTypeName.startsWith( "n" ) ) + if ( sqlTypeName.startsWith( QLatin1String( "n" ) ) ) { length = length / 2; } @@ -1007,7 +1007,7 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList &flist, Flags flags ) // Z and M on the end of a WKT string isn't valid for // SQL Server so we have to remove it first. wkt = geom.exportToWkt(); - wkt.replace( QRegExp( "[mzMZ]+\\s*\\(" ), "(" ); + wkt.replace( QRegExp( "[mzMZ]+\\s*\\(" ), QStringLiteral( "(" ) ); } query.addBindValue( wkt ); } @@ -1343,7 +1343,7 @@ bool QgsMssqlProvider::changeGeometryValues( const QgsGeometryMap &geometry_map QString wkt = it->exportToWkt(); // Z and M on the end of a WKT string isn't valid for // SQL Server so we have to remove it first. - wkt.replace( QRegExp( "[mzMZ]+\\s*\\(" ), "(" ); + wkt.replace( QRegExp( "[mzMZ]+\\s*\\(" ), QStringLiteral( "(" ) ); query.addBindValue( wkt ); } @@ -1459,7 +1459,7 @@ bool QgsMssqlProvider::createAttributeIndex( int field ) if ( field < 0 || field >= mAttributeFields.size() ) { - pushError( "createAttributeIndex invalid index" ); + pushError( QStringLiteral( "createAttributeIndex invalid index" ) ); return false; } diff --git a/src/providers/ogr/qgsogrdataitems.cpp b/src/providers/ogr/qgsogrdataitems.cpp index b911a62b2749..ff4ce93fbfaf 100644 --- a/src/providers/ogr/qgsogrdataitems.cpp +++ b/src/providers/ogr/qgsogrdataitems.cpp @@ -452,7 +452,7 @@ bool QgsOgrDataCollectionItem::storeConnection( const QString &path, const QStri bool QgsOgrDataCollectionItem::createConnection( const QString &name, const QString &extensions, const QString &ogrDriverName ) { - QString path = QFileDialog::getOpenFileName( nullptr, tr( "Open %1" ).arg( name ), "", extensions ); + QString path = QFileDialog::getOpenFileName( nullptr, tr( "Open %1" ).arg( name ), QLatin1String( "" ), extensions ); return storeConnection( path, ogrDriverName ); } @@ -581,9 +581,9 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem ) // class // TODO: add more OGR supported multiple layers formats here! QStringList ogrSupportedDbLayersExtensions; - ogrSupportedDbLayersExtensions << QLatin1String( "gpkg" ) << QLatin1String( "sqlite" ) << QLatin1String( "db" ) << QStringLiteral( "gdb" ); + ogrSupportedDbLayersExtensions << QStringLiteral( "gpkg" ) << QStringLiteral( "sqlite" ) << QStringLiteral( "db" ) << QStringLiteral( "gdb" ); QStringList ogrSupportedDbDriverNames; - ogrSupportedDbDriverNames << QLatin1String( "GPKG" ) << QLatin1String( "db" ) << QStringLiteral( "gdb" ); + ogrSupportedDbDriverNames << QStringLiteral( "GPKG" ) << QStringLiteral( "db" ) << QStringLiteral( "gdb" ); // Fast track: return item without testing if: // scanExtSetting or zipfile and scan zip == "Basic scan" diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index af8bf1ecc972..ac7953f14d36 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -451,7 +451,7 @@ QgsOgrProvider::QgsOgrProvider( QString const &uri ) QList nativeTypes; nativeTypes << QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), QStringLiteral( "integer" ), QVariant::Int, 0, 11 ) - << QgsVectorDataProvider::NativeType( tr( "Whole number (integer 64 bit)" ), "integer64", QVariant::LongLong, 0, 21 ) + << QgsVectorDataProvider::NativeType( tr( "Whole number (integer 64 bit)" ), QStringLiteral( "integer64" ), QVariant::LongLong, 0, 21 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), QStringLiteral( "double" ), QVariant::Double, 0, 20, 0, 15 ) << QgsVectorDataProvider::NativeType( tr( "Text (string)" ), QStringLiteral( "string" ), QVariant::String, 0, 65535 ) << QgsVectorDataProvider::NativeType( tr( "Date" ), QStringLiteral( "date" ), QVariant::Date, 8, 8 ); @@ -585,9 +585,9 @@ QString QgsOgrProvider::ogrWkbGeometryTypeName( OGRwkbGeometryType type ) const { geom = ogrWkbGeometryTypeName( wkbFlatten( type ) ); if ( wkbHasZ( type ) ) - geom += "Z"; + geom += QLatin1String( "Z" ); if ( wkbHasM( type ) ) - geom += "M"; + geom += QLatin1String( "M" ); return geom; } @@ -1067,7 +1067,7 @@ QgsRectangle QgsOgrProvider::extent() const QgsDebugMsg( "Starting get extent" ); #if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,1,2) - if ( mForceRecomputeExtent && mValid && mGDALDriverName == "GPKG" && mGDALDataset && ogrOrigLayer ) + if ( mForceRecomputeExtent && mValid && mGDALDriverName == QLatin1String( "GPKG" ) && mGDALDataset && ogrOrigLayer ) { QByteArray layerName = OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) ); // works with unquoted layerName @@ -1138,7 +1138,7 @@ QVariant QgsOgrProvider::defaultValue( int fieldId ) const { defaultVal = defaultVal.remove( 0, 1 ); defaultVal.chop( 1 ); - defaultVal.replace( "''", "'" ); + defaultVal.replace( QLatin1String( "''" ), QLatin1String( "'" ) ); resultVar = defaultVal; } @@ -3696,7 +3696,7 @@ void QgsOgrProvider::open( OpenMode mode ) // Ensure subset is set (setSubsetString does nothing if the passed sql subset string is equal to mSubsetString, which is the case when reloading the dataset) QString origSubsetString = mSubsetString; - mSubsetString = ""; + mSubsetString = QLatin1String( "" ); // Block signals to avoid endless recusion reloadData -> emit dataChanged -> reloadData blockSignals( true ); mValid = setSubsetString( origSubsetString ); @@ -4172,7 +4172,7 @@ QGISEXTERN QString loadStyle( const QString &uri, QString &errCause ) OGRLayerH hUserLayer = nullptr; GDALDatasetH hDS = LoadDataSourceAndLayer( uri, hUserLayer, errCause ); if ( !hDS ) - return ""; + return QLatin1String( "" ); // check if layer_styles table already exist OGRLayerH hLayer = GDALDatasetGetLayerByName( hDS, "layer_styles" ); @@ -4180,7 +4180,7 @@ QGISEXTERN QString loadStyle( const QString &uri, QString &errCause ) { errCause = QObject::tr( "Cannot find layer_styles layer" ); QgsOgrProviderUtils::GDALCloseWrapper( hDS ); - return ""; + return QLatin1String( "" ); } QString selectQmlQuery = QStringLiteral( "f_table_schema=''" @@ -4277,7 +4277,7 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na geometryColumn == QString::fromUtf8( OGR_L_GetGeometryColumn( hUserLayer ) ) ) { // Append first all related styles - QString id( QString( "%1" ).arg( fid ) ); + QString id( QStringLiteral( "%1" ).arg( fid ) ); ids.append( id ); names.append( styleName ); descriptions.append( description ); @@ -4308,7 +4308,7 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na for ( int j = 0; j < listId.size(); j++ ) { int fid = listId[j]; - QString id( QString( "%1" ).arg( fid ) ); + QString id( QStringLiteral( "%1" ).arg( fid ) ); ids.append( id ); names.append( mapIdToStyleName[fid] ); descriptions.append( mapIdToDescription[fid] ); @@ -4325,7 +4325,7 @@ QGISEXTERN QString getStyleById( const QString &uri, QString styleId, QString &e OGRLayerH hUserLayer = nullptr; GDALDatasetH hDS = LoadDataSourceAndLayer( uri, hUserLayer, errCause ); if ( !hDS ) - return ""; + return QLatin1String( "" ); // check if layer_styles table already exist OGRLayerH hLayer = GDALDatasetGetLayerByName( hDS, "layer_styles" ); @@ -4333,7 +4333,7 @@ QGISEXTERN QString getStyleById( const QString &uri, QString styleId, QString &e { errCause = QObject::tr( "Cannot find layer_styles layer" ); QgsOgrProviderUtils::GDALCloseWrapper( hDS ); - return ""; + return QLatin1String( "" ); } bool ok; @@ -4342,7 +4342,7 @@ QGISEXTERN QString getStyleById( const QString &uri, QString styleId, QString &e { errCause = QObject::tr( "Invalid style identifier" ); QgsOgrProviderUtils::GDALCloseWrapper( hDS ); - return ""; + return QLatin1String( "" ); } OGRFeatureH hFeature = OGR_L_GetFeature( hLayer, id ); @@ -4350,7 +4350,7 @@ QGISEXTERN QString getStyleById( const QString &uri, QString styleId, QString &e { errCause = QObject::tr( "No style corresponding to style identifier" ); QgsOgrProviderUtils::GDALCloseWrapper( hDS ); - return ""; + return QLatin1String( "" ); } OGRFeatureDefnH hLayerDefn = OGR_L_GetLayerDefn( hLayer ); diff --git a/src/providers/ogr/qgsogrprovider.h b/src/providers/ogr/qgsogrprovider.h index a8a3b9bbba3d..ddd808d660bc 100644 --- a/src/providers/ogr/qgsogrprovider.h +++ b/src/providers/ogr/qgsogrprovider.h @@ -58,7 +58,7 @@ class QgsOgrProvider : public QgsVectorDataProvider * Constructor of the vector provider * \param uri uniform resource locator (URI) for a dataset */ - explicit QgsOgrProvider( QString const &uri = "" ); + explicit QgsOgrProvider( QString const &uri = QString() ); virtual ~QgsOgrProvider(); @@ -275,4 +275,6 @@ class QgsOgrProviderUtils static void GDALCloseWrapper( GDALDatasetH mhDS ); }; +// clazy:excludeall=qstring-allocations + #endif // QGSOGRPROVIDER_H diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index f703dec9cffb..af80456b5c4e 100644 --- a/src/providers/postgres/qgspostgresconn.cpp +++ b/src/providers/postgres/qgspostgresconn.cpp @@ -1566,17 +1566,17 @@ void QgsPostgresConn::postgisWkbType( QgsWkbTypes::Type wkbType, QString &geomet if ( QgsWkbTypes::hasZ( wkbType ) && QgsWkbTypes::hasM( wkbType ) ) { - geometryType += "ZM"; + geometryType += QLatin1String( "ZM" ); dim = 4; } else if ( QgsWkbTypes::hasZ( wkbType ) ) { - geometryType += "Z"; + geometryType += QLatin1String( "Z" ); dim = 3; } else if ( QgsWkbTypes::hasM( wkbType ) ) { - geometryType += "M"; + geometryType += QLatin1String( "M" ); dim = 3; } else if ( wkbType >= QgsWkbTypes::Point25D && wkbType <= QgsWkbTypes::MultiPolygon25D ) diff --git a/src/providers/postgres/qgspostgresconn.h b/src/providers/postgres/qgspostgresconn.h index 1c0db014eeea..59c1dda8db04 100644 --- a/src/providers/postgres/qgspostgresconn.h +++ b/src/providers/postgres/qgspostgresconn.h @@ -414,5 +414,6 @@ class QgsPostgresConn : public QObject QMutex mLock; }; +// clazy:excludeall=qstring-allocations #endif diff --git a/src/providers/postgres/qgspostgresexpressioncompiler.cpp b/src/providers/postgres/qgspostgresexpressioncompiler.cpp index 41427aa6bc7e..038a29a2c825 100644 --- a/src/providers/postgres/qgspostgresexpressioncompiler.cpp +++ b/src/providers/postgres/qgspostgresexpressioncompiler.cpp @@ -114,21 +114,21 @@ QString QgsPostgresExpressionCompiler::sqlFunctionFromFunctionName( const QStrin QStringList QgsPostgresExpressionCompiler::sqlArgumentsFromFunctionName( const QString &fnName, const QStringList &fnArgs ) const { QStringList args( fnArgs ); - if ( fnName == "geom_from_wkt" ) + if ( fnName == QLatin1String( "geom_from_wkt" ) ) { args << ( mRequestedSrid.isEmpty() ? mDetectedSrid : mRequestedSrid ); } - else if ( fnName == "geom_from_gml" ) + else if ( fnName == QLatin1String( "geom_from_gml" ) ) { args << ( mRequestedSrid.isEmpty() ? mDetectedSrid : mRequestedSrid ); } - else if ( fnName == "x" || fnName == "y" ) + else if ( fnName == QLatin1String( "x" ) || fnName == QLatin1String( "y" ) ) { args = QStringList( QStringLiteral( "ST_Centroid(%1)" ).arg( args[0] ) ); } - else if ( fnName == "buffer" && args.length() == 2 ) + else if ( fnName == QLatin1String( "buffer" ) && args.length() == 2 ) { - args << "8"; + args << QStringLiteral( "8" ); } // x and y functions have to be adapted return args; @@ -153,7 +153,7 @@ QgsSqlExpressionCompiler::Result QgsPostgresExpressionCompiler::compileNode( con const QgsExpressionNodeFunction *n = static_cast( node ); QgsExpressionFunction *fd = QgsExpression::Functions()[n->fnIndex()]; - if ( fd->name() == "$geometry" ) + if ( fd->name() == QLatin1String( "$geometry" ) ) { result = quotedIdentifier( mGeometryColumn ); return Complete; diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index cc2dc60f8631..802f9fc2d4b9 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -118,7 +118,7 @@ QgsPostgresProvider::QgsPostgresProvider( QString const &uri ) if ( mUri.hasParam( QStringLiteral( "checkPrimaryKeyUnicity" ) ) ) { - if ( mUri.param( QStringLiteral( "checkPrimaryKeyUnicity" ) ).compare( "0" ) == 0 ) + if ( mUri.param( QStringLiteral( "checkPrimaryKeyUnicity" ) ).compare( QLatin1String( "0" ) ) == 0 ) { mCheckPrimaryKeyUnicity = false; } @@ -213,7 +213,7 @@ QgsPostgresProvider::QgsPostgresProvider( QString const &uri ) // Set the PostgreSQL message level so that we don't get the // 'there is no transaction in progress' warning. #ifndef QGISDEBUG - mConnectionRO->PQexecNR( "set client_min_messages to error" ); + mConnectionRO->PQexecNR( QStringLiteral( "set client_min_messages to error" ) ); #endif //fill type names into sets @@ -1638,26 +1638,26 @@ QStringList QgsPostgresProvider::uniqueStringsMatching( int index, const QString { // get the field name QgsField fld = field( index ); - QString sql = QString( "SELECT DISTINCT %1 FROM %2 WHERE" ) + QString sql = QStringLiteral( "SELECT DISTINCT %1 FROM %2 WHERE" ) .arg( quotedIdentifier( fld.name() ), mQuery ); if ( !mSqlWhereClause.isEmpty() ) { - sql += QString( " ( %1 ) AND " ).arg( mSqlWhereClause ); + sql += QStringLiteral( " ( %1 ) AND " ).arg( mSqlWhereClause ); } - sql += QString( " %1 ILIKE '%%2%'" ).arg( quotedIdentifier( fld.name() ), substring ); + sql += QStringLiteral( " %1 ILIKE '%%2%'" ).arg( quotedIdentifier( fld.name() ), substring ); - sql += QString( " ORDER BY %1" ).arg( quotedIdentifier( fld.name() ) ); + sql += QStringLiteral( " ORDER BY %1" ).arg( quotedIdentifier( fld.name() ) ); if ( limit >= 0 ) { - sql += QString( " LIMIT %1" ).arg( limit ); + sql += QStringLiteral( " LIMIT %1" ).arg( limit ); } - sql = QString( "SELECT %1 FROM (%2) foo" ).arg( connectionRO()->fieldExpression( fld ), sql ); + sql = QStringLiteral( "SELECT %1 FROM (%2) foo" ).arg( connectionRO()->fieldExpression( fld ), sql ); QgsPostgresResult res( connectionRO()->PQexec( sql ) ); if ( res.PQresultStatus() == PGRES_TUPLES_OK ) @@ -3752,7 +3752,7 @@ QgsVectorLayerExporter::ExportError QgsPostgresProvider::createEmptyLayer( const } pkList = QStringList( primaryKey ); - pkType = QStringList( "serial" ); + pkType = QStringList( QStringLiteral( "serial" ) ); } else { diff --git a/src/providers/postgres/qgspostgresprovider.h b/src/providers/postgres/qgspostgresprovider.h index ae06dcb945f1..ad49393557b4 100644 --- a/src/providers/postgres/qgspostgresprovider.h +++ b/src/providers/postgres/qgspostgresprovider.h @@ -86,7 +86,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider * \param uri String containing the required parameters to connect to the database * and query the table. */ - explicit QgsPostgresProvider( QString const &uri = "" ); + explicit QgsPostgresProvider( QString const &uri = QString() ); virtual ~QgsPostgresProvider(); @@ -507,4 +507,6 @@ class QgsPostgresSharedData QMap mFidToKey; // map feature id back to key values }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/providers/spatialite/qgsspatialiteprovider.cpp b/src/providers/spatialite/qgsspatialiteprovider.cpp index cfb21511573f..faa1a7c27f86 100644 --- a/src/providers/spatialite/qgsspatialiteprovider.cpp +++ b/src/providers/spatialite/qgsspatialiteprovider.cpp @@ -870,9 +870,9 @@ void QgsSpatiaLiteProvider::fetchConstraints() if ( fieldIdx >= 0 ) { QgsFieldConstraints constraints = mAttributeFields.at( fieldIdx ).constraints(); - if ( definition.contains( "unique", Qt::CaseInsensitive ) || definition.contains( "primary key", Qt::CaseInsensitive ) ) + if ( definition.contains( QLatin1String( "unique" ), Qt::CaseInsensitive ) || definition.contains( QLatin1String( "primary key" ), Qt::CaseInsensitive ) ) constraints.setConstraint( QgsFieldConstraints::ConstraintUnique, QgsFieldConstraints::ConstraintOriginProvider ); - if ( definition.contains( "not null", Qt::CaseInsensitive ) || definition.contains( "primary key", Qt::CaseInsensitive ) ) + if ( definition.contains( QLatin1String( "not null" ), Qt::CaseInsensitive ) || definition.contains( QLatin1String( "primary key" ), Qt::CaseInsensitive ) ) constraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintOriginProvider ); mAttributeFields[ fieldIdx ].setConstraints( constraints ); } @@ -913,7 +913,7 @@ void QgsSpatiaLiteProvider::insertDefaultValue( int fieldIndex, QString defaultV defaultVal = defaultVal.remove( 0, 1 ); if ( defaultVal.endsWith( '\'' ) ) defaultVal.chop( 1 ); - defaultVal.replace( "''", "'" ); + defaultVal.replace( QLatin1String( "''" ), QLatin1String( "'" ) ); defaultVariant = defaultVal; break; diff --git a/src/providers/spatialite/qgsspatialiteprovider.h b/src/providers/spatialite/qgsspatialiteprovider.h index a0c95084606a..39adefd8e377 100644 --- a/src/providers/spatialite/qgsspatialiteprovider.h +++ b/src/providers/spatialite/qgsspatialiteprovider.h @@ -71,7 +71,7 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider * Constructor of the vector provider * \param uri uniform resource locator (URI) for a dataset */ - explicit QgsSpatiaLiteProvider( QString const &uri = "" ); + explicit QgsSpatiaLiteProvider( QString const &uri = QString() ); virtual ~ QgsSpatiaLiteProvider(); @@ -387,4 +387,6 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/providers/virtual/qgsvirtuallayerprovider.h b/src/providers/virtual/qgsvirtuallayerprovider.h index c514e607b631..50e3429d9479 100644 --- a/src/providers/virtual/qgsvirtuallayerprovider.h +++ b/src/providers/virtual/qgsvirtuallayerprovider.h @@ -34,7 +34,7 @@ class QgsVirtualLayerProvider: public QgsVectorDataProvider * Constructor of the vector provider * \param uri uniform resource locator (URI) for a dataset */ - explicit QgsVirtualLayerProvider( QString const &uri = "" ); + explicit QgsVirtualLayerProvider( QString const &uri = QString() ); virtual ~QgsVirtualLayerProvider(); @@ -68,11 +68,11 @@ class QgsVirtualLayerProvider: public QgsVectorDataProvider struct SourceLayer { SourceLayer(): layer( nullptr ) {} - SourceLayer( QgsVectorLayer *l, const QString &n = "" ) + SourceLayer( QgsVectorLayer *l, const QString &n = QLatin1String( "" ) ) : layer( l ) , name( n ) {} - SourceLayer( const QString &p, const QString &s, const QString &n, const QString &e = "UTF-8" ) + SourceLayer( const QString &p, const QString &s, const QString &n, const QString &e = QStringLiteral( "UTF-8" ) ) : layer( nullptr ) , name( n ) , source( s ) @@ -119,4 +119,6 @@ class QgsVirtualLayerProvider: public QgsVectorDataProvider void invalidateStatistics(); }; +// clazy:excludeall=qstring-allocations + #endif diff --git a/src/providers/wfs/qgswfscapabilities.cpp b/src/providers/wfs/qgswfscapabilities.cpp index 89e317be8d4f..af0bdfcc9725 100644 --- a/src/providers/wfs/qgswfscapabilities.cpp +++ b/src/providers/wfs/qgswfscapabilities.cpp @@ -294,11 +294,11 @@ void QgsWfsCapabilities::capabilitiesReplyFinished() } else // WFS 2.0.0 tested on GeoServer { - QDomNodeList operationNodes = doc.elementsByTagName( "Operation" ); + QDomNodeList operationNodes = doc.elementsByTagName( QStringLiteral( "Operation" ) ); for ( int i = 0; i < operationNodes.count(); i++ ) { QDomElement operationElement = operationNodes.at( i ).toElement(); - if ( operationElement.isElement() && "Transaction" == operationElement.attribute( "name" ) ) + if ( operationElement.isElement() && "Transaction" == operationElement.attribute( QStringLiteral( "name" ) ) ) { insertCap = true; updateCap = true; diff --git a/src/providers/wfs/qgswfsdataitems.cpp b/src/providers/wfs/qgswfsdataitems.cpp index 2fba0ba6e548..91a3b0b60c2a 100644 --- a/src/providers/wfs/qgswfsdataitems.cpp +++ b/src/providers/wfs/qgswfsdataitems.cpp @@ -49,7 +49,7 @@ QgsWfsLayerItem::QgsWfsLayerItem( QgsDataItem *parent, QString name, const QgsDa mUri = QgsWFSDataSourceURI::build( uri.uri(), featureType, crsString, QString(), useCurrentViewExtent ); setState( Populated ); mIconName = QStringLiteral( "mIconConnect.png" ); - mBaseUri = uri.param( QString( "url" ) ); + mBaseUri = uri.param( QStringLiteral( "url" ) ); } QgsWfsLayerItem::~QgsWfsLayerItem() @@ -81,7 +81,7 @@ void QgsWfsLayerItem::copyStyle() for ( const QString &connName : connections ) { connection.reset( new QgsGeoNodeConnection( connName ) ); - if ( mBaseUri.contains( connection->uri().param( QString( "url" ) ) ) ) + if ( mBaseUri.contains( connection->uri().param( QStringLiteral( "url" ) ) ) ) break; else connection.reset( nullptr ); @@ -103,7 +103,7 @@ void QgsWfsLayerItem::copyStyle() } QString url( connection->uri().encodedUri() ); - QgsGeoNodeRequest geoNodeRequest( url.replace( QString( "url=" ), QString() ), true ); + QgsGeoNodeRequest geoNodeRequest( url.replace( QStringLiteral( "url=" ), QString() ), true ); QgsGeoNodeStyle style = geoNodeRequest.fetchDefaultStyleBlocking( this->name() ); if ( style.name.isEmpty() ) { @@ -314,7 +314,7 @@ QgsDataItem *QgsWfsDataItemProvider::createDataItem( const QString &path, QgsDat { QgsGeoNodeConnection connection( connectionName ); - QString url = connection.uri().param( "url" ); + QString url = connection.uri().param( QStringLiteral( "url" ) ); QgsGeoNodeRequest geonodeRequest( url, true ); QgsWFSDataSourceURI sourceUri( geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "WFS" ) )[0] ); @@ -338,7 +338,7 @@ QVector QgsWfsDataItemProvider::createDataItems( const QString &p { QgsGeoNodeConnection connection( connectionName ); - QString url = connection.uri().param( "url" ); + QString url = connection.uri().param( QStringLiteral( "url" ) ); QgsGeoNodeRequest geonodeRequest( url, true ); const QStringList encodedUris( geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "WFS" ) ) ); diff --git a/src/providers/wfs/qgswfsfeatureiterator.cpp b/src/providers/wfs/qgswfsfeatureiterator.cpp index c8784f3bb7ae..b54d428e8c35 100644 --- a/src/providers/wfs/qgswfsfeatureiterator.cpp +++ b/src/providers/wfs/qgswfsfeatureiterator.cpp @@ -340,13 +340,13 @@ QUrl QgsWFSFeatureDownloader::buildURL( int startIndex, int maxFeatures, bool fo else if ( !forHits && mShared->mWFSVersion.startsWith( QLatin1String( "1.0" ) ) ) { QStringList list; - list << QLatin1String( "text/xml; subtype=gml/3.2.1" ); - list << QLatin1String( "application/gml+xml; version=3.2" ); - list << QLatin1String( "text/xml; subtype=gml/3.1.1" ); - list << QLatin1String( "application/gml+xml; version=3.1" ); - list << QLatin1String( "text/xml; subtype=gml/3.0.1" ); - list << QLatin1String( "application/gml+xml; version=3.0" ); - list << QLatin1String( "GML3" ); + list << QStringLiteral( "text/xml; subtype=gml/3.2.1" ); + list << QStringLiteral( "application/gml+xml; version=3.2" ); + list << QStringLiteral( "text/xml; subtype=gml/3.1.1" ); + list << QStringLiteral( "application/gml+xml; version=3.1" ); + list << QStringLiteral( "text/xml; subtype=gml/3.0.1" ); + list << QStringLiteral( "application/gml+xml; version=3.0" ); + list << QStringLiteral( "GML3" ); Q_FOREACH ( const QString &format, list ) { if ( mShared->mCaps.outputFormats.contains( format ) ) diff --git a/src/providers/wfs/qgswfsprovider.cpp b/src/providers/wfs/qgswfsprovider.cpp index a81159fb6c5e..e0fa2e283fc4 100644 --- a/src/providers/wfs/qgswfsprovider.cpp +++ b/src/providers/wfs/qgswfsprovider.cpp @@ -1121,23 +1121,23 @@ bool QgsWFSProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_ QVariantMap QgsWFSProvider::metadata() const { QVariantMap result; - result["MaxFeatures"] = mShared->mCaps.maxFeatures; - result["SupportsPaging"] = mShared->mCaps.supportsPaging; - result["SupportsJoins"] = mShared->mCaps.supportsJoins; + result[QStringLiteral( "MaxFeatures" )] = mShared->mCaps.maxFeatures; + result[QStringLiteral( "SupportsPaging" )] = mShared->mCaps.supportsPaging; + result[QStringLiteral( "SupportsJoins" )] = mShared->mCaps.supportsJoins; return result; } QString QgsWFSProvider::translateMetadataKey( const QString &mdKey ) const { - if ( mdKey == "MaxFeatures" ) + if ( mdKey == QLatin1String( "MaxFeatures" ) ) { return tr( "Max Features" ); } - else if ( mdKey == "SupportsPaging" ) + else if ( mdKey == QLatin1String( "SupportsPaging" ) ) { return tr( "Supports Paging" ); } - else if ( mdKey == "SupportsJoins" ) + else if ( mdKey == QLatin1String( "SupportsJoins" ) ) { return tr( "Supports Joins" ); } @@ -1149,11 +1149,11 @@ QString QgsWFSProvider::translateMetadataKey( const QString &mdKey ) const QString QgsWFSProvider::translateMetadataValue( const QString &mdKey, const QVariant &value ) const { - if ( mdKey == "MaxFeatures" ) + if ( mdKey == QLatin1String( "MaxFeatures" ) ) { return value.toInt() == 0 ? tr( "not provided" ) : value.toString(); } - else if ( mdKey == "SupportsPaging" || mdKey == "SupportsJoins" ) + else if ( mdKey == QLatin1String( "SupportsPaging" ) || mdKey == QLatin1String( "SupportsJoins" ) ) { return value.toBool() ? tr( "supported" ) : tr( "unsupported" ); } diff --git a/src/providers/wfs/qgswfsshareddata.cpp b/src/providers/wfs/qgswfsshareddata.cpp index f24c0b8f5f0b..08f724f64eb8 100644 --- a/src/providers/wfs/qgswfsshareddata.cpp +++ b/src/providers/wfs/qgswfsshareddata.cpp @@ -256,8 +256,8 @@ bool QgsWFSSharedData::createCache() QStringList layerOptions; datasourceOptions.push_back( QStringLiteral( "INIT_WITH_EPSG=NO" ) ); layerOptions.push_back( QStringLiteral( "LAUNDER=NO" ) ); // to get exact matches for field names, especially regarding case - layerOptions.push_back( "FID=__ogc_fid" ); - layerOptions.push_back( "GEOMETRY_NAME=__spatialite_geometry" ); + layerOptions.push_back( QStringLiteral( "FID=__ogc_fid" ) ); + layerOptions.push_back( QStringLiteral( "GEOMETRY_NAME=__spatialite_geometry" ) ); vsimemFilename.sprintf( "/vsimem/qgis_wfs_cache_template_%p/features.sqlite", this ); mCacheTablename = CPLGetBasename( vsimemFilename.toStdString().c_str() ); VSIUnlink( vsimemFilename.toStdString().c_str() ); diff --git a/src/providers/wms/qgswmsdataitems.cpp b/src/providers/wms/qgswmsdataitems.cpp index a1dca096c138..b7e49d2ae21d 100644 --- a/src/providers/wms/qgswmsdataitems.cpp +++ b/src/providers/wms/qgswmsdataitems.cpp @@ -563,7 +563,7 @@ QVector QgsWmsDataItemProvider::createDataItems( const QString &p { QgsGeoNodeConnection connection( connectionName ); - QString url = connection.uri().param( "url" ); + QString url = connection.uri().param( QStringLiteral( "url" ) ); QgsGeoNodeRequest geonodeRequest( url, true ); const QStringList encodedUris( geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "WMS" ) ) ); @@ -609,7 +609,7 @@ QVector QgsXyzTileDataItemProvider::createDataItems( const QStrin { QgsGeoNodeConnection connection( connectionName ); - QString url = connection.uri().param( "url" ); + QString url = connection.uri().param( QStringLiteral( "url" ) ); QgsGeoNodeRequest geonodeRequest( url, true ); const QgsStringMap urlData( geonodeRequest.fetchServiceUrlDataBlocking( QStringLiteral( "XYZ" ) ) ); diff --git a/src/python/qgspythonutilsimpl.cpp b/src/python/qgspythonutilsimpl.cpp index 1f680d9a1d7b..f5673374a163 100644 --- a/src/python/qgspythonutilsimpl.cpp +++ b/src/python/qgspythonutilsimpl.cpp @@ -191,20 +191,20 @@ bool QgsPythonUtilsImpl::checkQgisUser() void QgsPythonUtilsImpl::doCustomImports() { - QStringList startupPaths = QStandardPaths::locateAll( QStandardPaths::AppDataLocation, "startup.py" ); + QStringList startupPaths = QStandardPaths::locateAll( QStandardPaths::AppDataLocation, QStringLiteral( "startup.py" ) ); if ( startupPaths.isEmpty() ) { return; } - runString( "import importlib.util" ); + runString( QStringLiteral( "import importlib.util" ) ); QStringList::const_iterator iter = startupPaths.constBegin(); for ( ; iter != startupPaths.constEnd(); ++iter ) { - runString( QString( "spec = importlib.util.spec_from_file_location('startup','%1')" ).arg( *iter ) ); - runString( "module = importlib.util.module_from_spec(spec)" ); - runString( "spec.loader.exec_module(module)" ); + runString( QStringLiteral( "spec = importlib.util.spec_from_file_location('startup','%1')" ).arg( *iter ) ); + runString( QStringLiteral( "module = importlib.util.module_from_spec(spec)" ) ); + runString( QStringLiteral( "spec.loader.exec_module(module)" ) ); } } diff --git a/tests/src/app/testqgsattributetable.cpp b/tests/src/app/testqgsattributetable.cpp index 14214d63243a..4b84d1137d10 100644 --- a/tests/src/app/testqgsattributetable.cpp +++ b/tests/src/app/testqgsattributetable.cpp @@ -255,7 +255,7 @@ void TestQgsAttributeTable::testRegression15974() QString path = QDir::tempPath() + "/testshp15974.shp"; std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); - QgsVectorFileWriter::writeAsVectorFormat( tempLayer.get(), path, "system", QgsCoordinateReferenceSystem( 4326 ), "ESRI Shapefile" ); + QgsVectorFileWriter::writeAsVectorFormat( tempLayer.get(), path, QStringLiteral( "system" ), QgsCoordinateReferenceSystem( 4326 ), QStringLiteral( "ESRI Shapefile" ) ); std::unique_ptr< QgsVectorLayer> shpLayer( new QgsVectorLayer( path, QStringLiteral( "test" ), QStringLiteral( "ogr" ) ) ); QgsFeature f1( shpLayer->dataProvider()->fields(), 1 ); QgsGeometry geom; diff --git a/tests/src/app/testqgsnodetool.cpp b/tests/src/app/testqgsnodetool.cpp index ff32ac324f62..e15abc11d99b 100644 --- a/tests/src/app/testqgsnodetool.cpp +++ b/tests/src/app/testqgsnodetool.cpp @@ -138,16 +138,16 @@ void TestQgsNodeTool::initTestCase() mCanvas = new QgsMapCanvas(); - mCanvas->setDestinationCrs( QgsCoordinateReferenceSystem( "EPSG:27700" ) ); + mCanvas->setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:27700" ) ) ); mAdvancedDigitizingDockWidget = new QgsAdvancedDigitizingDockWidget( mCanvas ); // make testing layers - mLayerLine = new QgsVectorLayer( "LineString?crs=EPSG:27700", "layer line", "memory" ); + mLayerLine = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:27700" ), QStringLiteral( "layer line" ), QStringLiteral( "memory" ) ); QVERIFY( mLayerLine->isValid() ); - mLayerPolygon = new QgsVectorLayer( "Polygon?crs=EPSG:27700", "layer polygon", "memory" ); + mLayerPolygon = new QgsVectorLayer( QStringLiteral( "Polygon?crs=EPSG:27700" ), QStringLiteral( "layer polygon" ), QStringLiteral( "memory" ) ); QVERIFY( mLayerPolygon->isValid() ); - mLayerPoint = new QgsVectorLayer( "Point?crs=EPSG:27700", "layer point", "memory" ); + mLayerPoint = new QgsVectorLayer( QStringLiteral( "Point?crs=EPSG:27700" ), QStringLiteral( "layer point" ), QStringLiteral( "memory" ) ); QVERIFY( mLayerPoint->isValid() ); QgsProject::instance()->addMapLayers( QList() << mLayerLine << mLayerPolygon << mLayerPoint ); @@ -538,7 +538,7 @@ void TestQgsNodeTool::testActiveLayerPriority() // check that features from current layer get priority when picking points // create a temporary line layer that has a common vertex with existing line layer at (1, 1) - QgsVectorLayer *layerLine2 = new QgsVectorLayer( "LineString?crs=EPSG:27700", "layer line 2", "memory" ); + QgsVectorLayer *layerLine2 = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:27700" ), QStringLiteral( "layer line 2" ), QStringLiteral( "memory" ) ); QVERIFY( layerLine2->isValid() ); QgsPolyline line1; line1 << QgsPointXY( 0, 1 ) << QgsPointXY( 1, 1 ) << QgsPointXY( 1, 0 ); diff --git a/tests/src/core/testqgscomposergroup.cpp b/tests/src/core/testqgscomposergroup.cpp index e4bba02d72b3..d91cb74ca3cc 100644 --- a/tests/src/core/testqgscomposergroup.cpp +++ b/tests/src/core/testqgscomposergroup.cpp @@ -53,7 +53,7 @@ class TestQgsComposerGroup : public QObject private: - void dumpUndoStack( const QUndoStack &, QString prefix = QLatin1String( QLatin1String( "" ) ) ) const; + void dumpUndoStack( const QUndoStack &, QString prefix = QString() ) const; QgsComposition *mComposition = nullptr; QgsMapSettings *mMapSettings = nullptr; diff --git a/tests/src/core/testqgscomposermap.cpp b/tests/src/core/testqgscomposermap.cpp index 87a8658f15f2..7ddf1962ad7b 100644 --- a/tests/src/core/testqgscomposermap.cpp +++ b/tests/src/core/testqgscomposermap.cpp @@ -262,7 +262,7 @@ void TestQgsComposerMap::dataDefinedLayers() mComposition->addComposerMap( mComposerMap ); //test malformed layer set string - mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapLayers, QgsProperty::fromExpression( "'x'" ) ); + mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapLayers, QgsProperty::fromExpression( QStringLiteral( "'x'" ) ) ); QList result = mComposerMap->layersToRender(); QVERIFY( result.isEmpty() ); diff --git a/tests/src/core/testqgscomposerscalebar.cpp b/tests/src/core/testqgscomposerscalebar.cpp index fec6ed3ae7ba..ce31831380a6 100644 --- a/tests/src/core/testqgscomposerscalebar.cpp +++ b/tests/src/core/testqgscomposerscalebar.cpp @@ -205,10 +205,10 @@ void TestQgsComposerScaleBar::tick() void TestQgsComposerScaleBar::dataDefined() { - mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarFillColor, QgsProperty::fromExpression( "'red'" ) ); - mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarFillColor2, QgsProperty::fromExpression( "'blue'" ) ); - mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarLineColor, QgsProperty::fromExpression( "'yellow'" ) ); - mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarLineWidth, QgsProperty::fromExpression( "1.2" ) ); + mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarFillColor, QgsProperty::fromExpression( QStringLiteral( "'red'" ) ) ); + mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarFillColor2, QgsProperty::fromExpression( QStringLiteral( "'blue'" ) ) ); + mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarLineColor, QgsProperty::fromExpression( QStringLiteral( "'yellow'" ) ) ); + mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarLineWidth, QgsProperty::fromExpression( QStringLiteral( "1.2" ) ) ); mComposerScaleBar->refreshDataDefinedProperty(); QCOMPARE( mComposerScaleBar->brush().color().name(), QColor( 255, 0, 0 ).name() ); QCOMPARE( mComposerScaleBar->brush2().color().name(), QColor( 0, 0, 255 ).name() ); diff --git a/tests/src/core/testqgscomposition.cpp b/tests/src/core/testqgscomposition.cpp index 4f8faf60064e..50e98e492b06 100644 --- a/tests/src/core/testqgscomposition.cpp +++ b/tests/src/core/testqgscomposition.cpp @@ -609,7 +609,7 @@ void TestQgsComposition::itemVariablesFunction() QgsRectangle extent( 2000, 2800, 2500, 2900 ); QgsComposition *composition = new QgsComposition( QgsProject::instance() ); - QgsExpression e( "map_get( item_variables( 'map_id' ), 'map_scale' )" ); + QgsExpression e( QStringLiteral( "map_get( item_variables( 'map_id' ), 'map_scale' )" ) ); // no map QgsExpressionContext c = composition->createExpressionContext(); QVariant r = e.evaluate( &c ); @@ -620,21 +620,21 @@ void TestQgsComposition::itemVariablesFunction() map->setSceneRect( QRectF( 30, 60, 200, 100 ) ); map->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); composition->addComposerMap( map ); - map->setId( "map_id" ); + map->setId( QStringLiteral( "map_id" ) ); c = composition->createExpressionContext(); r = e.evaluate( &c ); QGSCOMPARENEAR( r.toDouble(), 1.38916e+08, 100 ); - QgsExpression e2( "map_get( item_variables( 'map_id' ), 'map_crs' )" ); + QgsExpression e2( QStringLiteral( "map_get( item_variables( 'map_id' ), 'map_crs' )" ) ); r = e2.evaluate( &c ); QCOMPARE( r.toString(), QString( "EPSG:4326" ) ); - QgsExpression e3( "map_get( item_variables( 'map_id' ), 'map_crs_definition' )" ); + QgsExpression e3( QStringLiteral( "map_get( item_variables( 'map_id' ), 'map_crs_definition' )" ) ); r = e3.evaluate( &c ); QCOMPARE( r.toString(), QString( "+proj=longlat +datum=WGS84 +no_defs" ) ); - QgsExpression e4( "map_get( item_variables( 'map_id' ), 'map_units' )" ); + QgsExpression e4( QStringLiteral( "map_get( item_variables( 'map_id' ), 'map_units' )" ) ); r = e4.evaluate( &c ); QCOMPARE( r.toString(), QString( "degrees" ) ); @@ -675,10 +675,10 @@ void TestQgsComposition::legendRestoredFromTemplate() { // load a layer - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/points.shp" ); + QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); QgsProject p; p.addMapLayer( layer ); @@ -697,13 +697,13 @@ void TestQgsComposition::legendRestoredFromTemplate() QCOMPARE( layerNode->layer(), layer ); // got it! - layerNode->setCustomProperty( "legend/title-label", QString( "new title!" ) ); + layerNode->setCustomProperty( QStringLiteral( "legend/title-label" ), QStringLiteral( "new title!" ) ); // make sure new title stuck QCOMPARE( model->data( model->node2index( layerNode ), Qt::DisplayRole ).toString(), QString( "new title!" ) ); // save composition to template QDomDocument doc; - QDomElement composerElem = doc.createElement( "Composer" ); + QDomElement composerElem = doc.createElement( QStringLiteral( "Composer" ) ); doc.appendChild( composerElem ); c.writeXml( composerElem, doc ); c.atlasComposition().writeXml( composerElem, doc ); @@ -733,7 +733,7 @@ void TestQgsComposition::legendRestoredFromTemplate() // reload it, with a new id QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); p.addMapLayer( layer2 ); QVERIFY( oldId != layer2->id() ); @@ -759,10 +759,10 @@ void TestQgsComposition::legendRestoredFromTemplateAutoUpdate() { // load a layer - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/points.shp" ); + QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); QgsProject p; p.addMapLayer( layer ); @@ -783,7 +783,7 @@ void TestQgsComposition::legendRestoredFromTemplateAutoUpdate() // save composition to template QDomDocument doc; - QDomElement composerElem = doc.createElement( "Composer" ); + QDomElement composerElem = doc.createElement( QStringLiteral( "Composer" ) ); doc.appendChild( composerElem ); c.writeXml( composerElem, doc ); c.atlasComposition().writeXml( composerElem, doc ); @@ -791,7 +791,7 @@ void TestQgsComposition::legendRestoredFromTemplateAutoUpdate() //new project QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); QgsProject p2; p2.addMapLayer( layer2 ); @@ -815,11 +815,11 @@ void TestQgsComposition::legendRestoredFromTemplateAutoUpdate() void TestQgsComposition::attributeTableRestoredFromTemplate() { // load some layers - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/points.shp" ); + QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); - QgsVectorLayer *layer2 = new QgsVectorLayer( "Point", "memory", "memory" ); + QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer2 = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "memory" ), QStringLiteral( "memory" ) ); QgsProject p; p.addMapLayer( layer2 ); p.addMapLayer( layer ); @@ -836,7 +836,7 @@ void TestQgsComposition::attributeTableRestoredFromTemplate() // save composition to template QDomDocument doc; - QDomElement composerElem = doc.createElement( "Composer" ); + QDomElement composerElem = doc.createElement( QStringLiteral( "Composer" ) ); doc.appendChild( composerElem ); c.writeXml( composerElem, doc ); c.atlasComposition().writeXml( composerElem, doc ); @@ -845,8 +845,8 @@ void TestQgsComposition::attributeTableRestoredFromTemplate() QgsProject p2; QgsVectorLayer *layer3 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); - QgsVectorLayer *layer4 = new QgsVectorLayer( "Point", "memory", "memory" ); + QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer4 = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "memory" ), QStringLiteral( "memory" ) ); p2.addMapLayer( layer4 ); p2.addMapLayer( layer3 ); @@ -865,15 +865,15 @@ void TestQgsComposition::attributeTableRestoredFromTemplate() void TestQgsComposition::mapLayersRestoredFromTemplate() { // load some layers - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/points.shp" ); + QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); - QFileInfo vectorFileInfo2( QString( TEST_DATA_DIR ) + "/polys.shp" ); + QStringLiteral( "ogr" ) ); + QFileInfo vectorFileInfo2( QStringLiteral( TEST_DATA_DIR ) + "/polys.shp" ); QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo2.filePath(), vectorFileInfo2.completeBaseName(), - "ogr" ); - QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/landsat.tif" ); + QStringLiteral( "ogr" ) ); + QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ); QgsRasterLayer *rl = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); @@ -891,7 +891,7 @@ void TestQgsComposition::mapLayersRestoredFromTemplate() // save composition to template QDomDocument doc; - QDomElement composerElem = doc.createElement( "Composer" ); + QDomElement composerElem = doc.createElement( QStringLiteral( "Composer" ) ); doc.appendChild( composerElem ); c.writeXml( composerElem, doc ); c.atlasComposition().writeXml( composerElem, doc ); @@ -900,10 +900,10 @@ void TestQgsComposition::mapLayersRestoredFromTemplate() QgsProject p2; QgsVectorLayer *layer3 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); QgsVectorLayer *layer4 = new QgsVectorLayer( vectorFileInfo2.filePath(), vectorFileInfo2.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); QgsRasterLayer *rl5 = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); p2.addMapLayer( layer4 ); @@ -925,14 +925,14 @@ void TestQgsComposition::mapLayersRestoredFromTemplate() void TestQgsComposition::mapLayersStyleOverrideRestoredFromTemplate() { // load some layers - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/points.shp" ); + QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); - QFileInfo vectorFileInfo2( QString( TEST_DATA_DIR ) + "/polys.shp" ); + QStringLiteral( "ogr" ) ); + QFileInfo vectorFileInfo2( QStringLiteral( TEST_DATA_DIR ) + "/polys.shp" ); QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo2.filePath(), vectorFileInfo2.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); QgsProject p; p.addMapLayer( layer2 ); p.addMapLayer( layer ); @@ -951,7 +951,7 @@ void TestQgsComposition::mapLayersStyleOverrideRestoredFromTemplate() // save composition to template QDomDocument doc; - QDomElement composerElem = doc.createElement( "Composer" ); + QDomElement composerElem = doc.createElement( QStringLiteral( "Composer" ) ); doc.appendChild( composerElem ); c.writeXml( composerElem, doc ); c.atlasComposition().writeXml( composerElem, doc ); @@ -960,10 +960,10 @@ void TestQgsComposition::mapLayersStyleOverrideRestoredFromTemplate() QgsProject p2; QgsVectorLayer *layer3 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); QgsVectorLayer *layer4 = new QgsVectorLayer( vectorFileInfo2.filePath(), vectorFileInfo2.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); p2.addMapLayer( layer4 ); p2.addMapLayer( layer3 ); @@ -987,10 +987,10 @@ void TestQgsComposition::mapLayersStyleOverrideRestoredFromTemplate() void TestQgsComposition::atlasLayerRestoredFromTemplate() { // load some layers - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/points.shp" ); + QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); QgsProject p; p.addMapLayer( layer ); @@ -1002,7 +1002,7 @@ void TestQgsComposition::atlasLayerRestoredFromTemplate() // save composition to template QDomDocument doc; - QDomElement composerElem = doc.createElement( "Composer" ); + QDomElement composerElem = doc.createElement( QStringLiteral( "Composer" ) ); doc.appendChild( composerElem ); c.writeXml( composerElem, doc ); c.atlasComposition().writeXml( composerElem, doc ); @@ -1011,7 +1011,7 @@ void TestQgsComposition::atlasLayerRestoredFromTemplate() QgsProject p2; QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), - "ogr" ); + QStringLiteral( "ogr" ) ); p2.addMapLayer( layer2 ); // make a new composition from template diff --git a/tests/src/core/testqgscoordinatereferencesystem.cpp b/tests/src/core/testqgscoordinatereferencesystem.cpp index ebf0d292da3f..ed6ffcd9ec47 100644 --- a/tests/src/core/testqgscoordinatereferencesystem.cpp +++ b/tests/src/core/testqgscoordinatereferencesystem.cpp @@ -364,8 +364,8 @@ void TestQgsCoordinateReferenceSystem::createFromESRIWkt() myGdalVersionOK << 1900; //proj definition for EPSG:4618 was updated in GDAL 2.0 - see https://github.com/OSGeo/proj.4/issues/241 - myProj4Strings << "+proj=longlat +ellps=aust_SA +towgs84=-66.87,4.37,-38.52,0,0,0,0 +no_defs"; - myTOWGS84Strings << "+towgs84=-66.87,4.37,-38.52,0,0,0,0"; + myProj4Strings << QStringLiteral( "+proj=longlat +ellps=aust_SA +towgs84=-66.87,4.37,-38.52,0,0,0,0 +no_defs" ); + myTOWGS84Strings << QStringLiteral( "+towgs84=-66.87,4.37,-38.52,0,0,0,0" ); myAuthIdStrings << QStringLiteral( "EPSG:4618" ); // do test with WKT definitions diff --git a/tests/src/core/testqgscurve.cpp b/tests/src/core/testqgscurve.cpp index 337815c2c835..c4d66af776b7 100644 --- a/tests/src/core/testqgscurve.cpp +++ b/tests/src/core/testqgscurve.cpp @@ -80,7 +80,7 @@ void TestQgsCurve::curveToLine() /* input: 2 quadrants arc (180 degrees, PI radians) */ circularString.reset( dynamic_cast< QgsCircularString *>( - QgsGeometryFactory::geomFromWkt( QString( + QgsGeometryFactory::geomFromWkt( QStringLiteral( "CIRCULARSTRING(0 0,100 100,200 0)" ) ).release() @@ -103,7 +103,7 @@ void TestQgsCurve::curveToLine() /* input: 2 arcs of 2 quadrants each (180 degrees + 180 degrees other direction) */ circularString.reset( dynamic_cast( - QgsGeometryFactory::geomFromWkt( QString( + QgsGeometryFactory::geomFromWkt( QStringLiteral( "CIRCULARSTRING(0 0,100 100,200 0,300 -100,400 0)" ) ).release() ) ); diff --git a/tests/src/core/testqgsdatadefinedsizelegend.cpp b/tests/src/core/testqgsdatadefinedsizelegend.cpp index 04a12e17e2a6..d25bed713fe5 100644 --- a/tests/src/core/testqgsdatadefinedsizelegend.cpp +++ b/tests/src/core/testqgsdatadefinedsizelegend.cpp @@ -100,28 +100,28 @@ void TestQgsDataDefinedSizeLegend::testBasic() settings.setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ); QList classes; - classes << QgsDataDefinedSizeLegend::SizeClass( 3., QString( "3" ) ); - classes << QgsDataDefinedSizeLegend::SizeClass( 15., QString( "15" ) ); - classes << QgsDataDefinedSizeLegend::SizeClass( 30., QString( "30" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 3., QStringLiteral( "3" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 15., QStringLiteral( "15" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 30., QStringLiteral( "30" ) ); settings.setClasses( classes ); QgsStringMap props; - props["name"] = "circle"; - props["color"] = "200,255,200"; - props["outline_color"] = "0,255,0"; + props[QStringLiteral( "name" )] = QStringLiteral( "circle" ); + props[QStringLiteral( "color" )] = QStringLiteral( "200,255,200" ); + props[QStringLiteral( "outline_color" )] = QStringLiteral( "0,255,0" ); settings.setSymbol( QgsMarkerSymbol::createSimple( props ) ); // takes ownership QgsRenderContext context( _createRenderContext( 100, 96, 100 ) ); QImage imgBottom = settings.collapsedLegendImage( context, Qt::white, 1 ); - imgBottom.save( _fileNameForTest( "basic_bottom" ) ); + imgBottom.save( _fileNameForTest( QStringLiteral( "basic_bottom" ) ) ); QVERIFY( _verifyImage( "basic_bottom", mReport ) ); settings.setVerticalAlignment( QgsDataDefinedSizeLegend::AlignCenter ); QImage imgCenter = settings.collapsedLegendImage( context, Qt::white, 1 ); - imgCenter.save( _fileNameForTest( "basic_center" ) ); + imgCenter.save( _fileNameForTest( QStringLiteral( "basic_center" ) ) ); QVERIFY( _verifyImage( "basic_center", mReport ) ); } @@ -132,25 +132,25 @@ void TestQgsDataDefinedSizeLegend::testCrowded() settings.setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ); QList classes; - classes << QgsDataDefinedSizeLegend::SizeClass( 2., QString( "2" ) ); - classes << QgsDataDefinedSizeLegend::SizeClass( 5., QString( "5" ) ); - classes << QgsDataDefinedSizeLegend::SizeClass( 10., QString( "10" ) ); - classes << QgsDataDefinedSizeLegend::SizeClass( 12., QString( "12" ) ); - classes << QgsDataDefinedSizeLegend::SizeClass( 15., QString( "15" ) ); - classes << QgsDataDefinedSizeLegend::SizeClass( 18., QString( "18" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 2., QStringLiteral( "2" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 5., QStringLiteral( "5" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 10., QStringLiteral( "10" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 12., QStringLiteral( "12" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 15., QStringLiteral( "15" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 18., QStringLiteral( "18" ) ); settings.setClasses( classes ); QgsStringMap props; - props["name"] = "circle"; - props["color"] = "200,255,200"; - props["outline_color"] = "0,255,0"; + props[QStringLiteral( "name" )] = QStringLiteral( "circle" ); + props[QStringLiteral( "color" )] = QStringLiteral( "200,255,200" ); + props[QStringLiteral( "outline_color" )] = QStringLiteral( "0,255,0" ); settings.setSymbol( QgsMarkerSymbol::createSimple( props ) ); // takes ownership QgsRenderContext context( _createRenderContext( 100, 96, 100 ) ); QImage img = settings.collapsedLegendImage( context, Qt::white, 1 ); - img.save( _fileNameForTest( "crowded" ) ); + img.save( _fileNameForTest( QStringLiteral( "crowded" ) ) ); QVERIFY( _verifyImage( "crowded", mReport ) ); } diff --git a/tests/src/core/testqgsdiagram.cpp b/tests/src/core/testqgsdiagram.cpp index 18c08a49efaa..68fe80b1f3a9 100644 --- a/tests/src/core/testqgsdiagram.cpp +++ b/tests/src/core/testqgsdiagram.cpp @@ -91,8 +91,8 @@ class TestQgsDiagram : public QObject //we don't want to render the points themselves, just the diagrams QgsStringMap symbolProps; - symbolProps.insert( "color", "0,0,0,0" ); - symbolProps.insert( "outline_style", "no" ); + symbolProps.insert( QStringLiteral( "color" ), QStringLiteral( "0,0,0,0" ) ); + symbolProps.insert( QStringLiteral( "outline_style" ), QStringLiteral( "no" ) ); QgsMarkerSymbol *symbol = QgsMarkerSymbol::createSimple( symbolProps ); QgsSingleSymbolRenderer *symbolRenderer = new QgsSingleSymbolRenderer( symbol ); mPointsLayer->setRenderer( symbolRenderer ); @@ -160,7 +160,7 @@ class TestQgsDiagram : public QObject dr->setLowerSize( QSizeF( 0.0, 0.0 ) ); dr->setUpperValue( 10 ); dr->setUpperSize( QSizeF( 40, 40 ) ); - dr->setClassificationField( "Staff" ); + dr->setClassificationField( QStringLiteral( "Staff" ) ); dr->setDiagram( new QgsPieDiagram() ); dr->setDiagramSettings( ds ); mPointsLayer->setDiagramRenderer( dr ); @@ -223,7 +223,7 @@ class TestQgsDiagram : public QObject col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2; - ds.categoryAttributes = QList() << "\"Pilots\"" << "\"Cabin Crew\""; + ds.categoryAttributes = QList() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" ); ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -244,8 +244,8 @@ class TestQgsDiagram : public QObject dls.setShowAllDiagrams( true ); //Set data defined position - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::PositionX, QgsProperty::fromExpression( "$x + -5", true ) ); - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::PositionY, QgsProperty::fromExpression( "$y + 5", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::PositionX, QgsProperty::fromExpression( QStringLiteral( "$x + -5" ), true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::PositionY, QgsProperty::fromExpression( QStringLiteral( "$y + 5" ), true ) ); mPointsLayer->setDiagramLayerSettings( dls ); @@ -260,7 +260,7 @@ class TestQgsDiagram : public QObject col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2; - ds.categoryAttributes = QList() << "\"Pilots\"" << "\"Cabin Crew\""; + ds.categoryAttributes = QList() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" ); ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -281,8 +281,8 @@ class TestQgsDiagram : public QObject dls.setShowAllDiagrams( true ); //setup data defined stroke - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::StrokeColor, QgsProperty::fromExpression( "if(\"Pilots\">1,'0,0,0,255','255,0,0,255')", true ) ); - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::StrokeWidth, QgsProperty::fromExpression( "\"Staff\" / 2.0", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::StrokeColor, QgsProperty::fromExpression( QStringLiteral( "if(\"Pilots\">1,'0,0,0,255','255,0,0,255')" ), true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::StrokeWidth, QgsProperty::fromExpression( QStringLiteral( "\"Staff\" / 2.0" ), true ) ); mPointsLayer->setDiagramLayerSettings( dls ); @@ -297,7 +297,7 @@ class TestQgsDiagram : public QObject col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2; - ds.categoryAttributes = QList() << "\"Pilots\"" << "\"Cabin Crew\""; + ds.categoryAttributes = QList() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" ); ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -318,7 +318,7 @@ class TestQgsDiagram : public QObject dls.setShowAllDiagrams( true ); //setup data defined start angle - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::StartAngle, QgsProperty::fromExpression( "360.0-\"Importance\"/20.0 * 360.0", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::StartAngle, QgsProperty::fromExpression( QStringLiteral( "360.0-\"Importance\"/20.0 * 360.0" ), true ) ); mPointsLayer->setDiagramLayerSettings( dls ); @@ -333,7 +333,7 @@ class TestQgsDiagram : public QObject col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2; - ds.categoryAttributes = QList() << "\"Pilots\"" << "\"Cabin Crew\""; + ds.categoryAttributes = QList() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" ); ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -354,7 +354,7 @@ class TestQgsDiagram : public QObject dls.setShowAllDiagrams( true ); //setup data defined distance - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::Distance, QgsProperty::fromExpression( "\"Staff\"*2", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::Distance, QgsProperty::fromExpression( QStringLiteral( "\"Staff\"*2" ), true ) ); mPointsLayer->setDiagramLayerSettings( dls ); @@ -369,7 +369,7 @@ class TestQgsDiagram : public QObject col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2; - ds.categoryAttributes = QList() << "\"Pilots\"" << "\"Cabin Crew\""; + ds.categoryAttributes = QList() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" ); ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -390,7 +390,7 @@ class TestQgsDiagram : public QObject dls.setShowAllDiagrams( true ); //setup data defined show - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::Show, QgsProperty::fromExpression( "\"Pilots\"=1", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::Show, QgsProperty::fromExpression( QStringLiteral( "\"Pilots\"=1" ), true ) ); mPointsLayer->setDiagramLayerSettings( dls ); @@ -405,7 +405,7 @@ class TestQgsDiagram : public QObject col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2; - ds.categoryAttributes = QList() << "\"Pilots\"" << "\"Cabin Crew\""; + ds.categoryAttributes = QList() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" ); ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -426,7 +426,7 @@ class TestQgsDiagram : public QObject dls.setShowAllDiagrams( false ); //setup data defined priority - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::Priority, QgsProperty::fromExpression( "\"importance\"/2", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::Priority, QgsProperty::fromExpression( QStringLiteral( "\"importance\"/2" ), true ) ); mPointsLayer->setDiagramLayerSettings( dls ); @@ -439,7 +439,7 @@ class TestQgsDiagram : public QObject QColor col1 = Qt::red; QColor col2 = Qt::yellow; ds.categoryColors = QList() << col1 << col2; - ds.categoryAttributes = QList() << "\"Pilots\"" << "\"Cabin Crew\""; + ds.categoryAttributes = QList() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" ); ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -460,7 +460,7 @@ class TestQgsDiagram : public QObject dls.setShowAllDiagrams( true ); //setup data defined z index - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::ZIndex, QgsProperty::fromExpression( "\"importance\"/2", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::ZIndex, QgsProperty::fromExpression( QStringLiteral( "\"importance\"/2" ), true ) ); mPointsLayer->setDiagramLayerSettings( dls ); @@ -475,7 +475,7 @@ class TestQgsDiagram : public QObject col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2; - ds.categoryAttributes = QList() << "\"Pilots\"" << "\"Cabin Crew\""; + ds.categoryAttributes = QList() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" ); ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -496,9 +496,9 @@ class TestQgsDiagram : public QObject dls.setShowAllDiagrams( false ); //setup data defined priority (required to only show certain diagrams) - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::Priority, QgsProperty::fromExpression( "\"importance\"/2", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::Priority, QgsProperty::fromExpression( QStringLiteral( "\"importance\"/2" ), true ) ); //setup data defined "always show" - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::AlwaysShow, QgsProperty::fromExpression( "\"Staff\">=6", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::AlwaysShow, QgsProperty::fromExpression( QStringLiteral( "\"Staff\">=6" ), true ) ); mPointsLayer->setDiagramLayerSettings( dls ); @@ -516,7 +516,7 @@ class TestQgsDiagram : public QObject col1.setAlphaF( 0 ); col2.setAlphaF( 0 ); ds.categoryColors = QList() << col1 << col2; - ds.categoryAttributes = QList() << "\"Pilots\"" << "\"Cabin Crew\""; + ds.categoryAttributes = QList() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" ); ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -537,7 +537,7 @@ class TestQgsDiagram : public QObject dls.setShowAllDiagrams( true ); //setup data defined stroke - dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::BackgroundColor, QgsProperty::fromExpression( "if(\"Pilots\">1,'0,0,255,150','255,0,0,150')", true ) ); + dls.dataDefinedProperties().setProperty( QgsDiagramLayerSettings::BackgroundColor, QgsProperty::fromExpression( QStringLiteral( "if(\"Pilots\">1,'0,0,255,150','255,0,0,150')" ), true ) ); mPointsLayer->setDiagramLayerSettings( dls ); @@ -556,7 +556,7 @@ bool TestQgsDiagram::imageCheck( const QString &testType ) mMapSettings->setFlag( QgsMapSettings::ForceVectorOutput ); mMapSettings->setOutputDpi( 96 ); QgsMultiRenderChecker checker; - checker.setControlPathPrefix( "diagrams" ); + checker.setControlPathPrefix( QStringLiteral( "diagrams" ) ); checker.setControlName( "expected_" + testType ); checker.setMapSettings( *mMapSettings ); checker.setColorTolerance( 15 ); diff --git a/tests/src/core/testqgsexpression.cpp b/tests/src/core/testqgsexpression.cpp index b43462b4a904..9de6a6d29aeb 100644 --- a/tests/src/core/testqgsexpression.cpp +++ b/tests/src/core/testqgsexpression.cpp @@ -1403,7 +1403,7 @@ class TestQgsExpression: public QObject scope->setVariable( QStringLiteral( "test_var" ), 10 ); context << scope; QgsFeature f; - mAggregatesLayer->getFeatures( "col1 = 4 " ).nextFeature( f ); + mAggregatesLayer->getFeatures( QStringLiteral( "col1 = 4 " ) ).nextFeature( f ); context.setFeature( f ); QFETCH( QString, string ); @@ -1506,7 +1506,7 @@ class TestQgsExpression: public QObject mMemoryLayer->selectByIds( selectedFeatures ); QgsExpression exp( expression ); - QCOMPARE( exp.parserErrorString(), QString( "" ) ); + QCOMPARE( exp.parserErrorString(), QLatin1String( "" ) ); exp.prepare( &context ); QVariant res = exp.evaluate( &context ); QCOMPARE( res, result ); @@ -2813,7 +2813,7 @@ class TestQgsExpression: public QObject setenv( "TESTENV_STRING", "Hello World", 1 ); #endif - QgsExpression e( "env('TESTENV_STRING')" ); + QgsExpression e( QStringLiteral( "env('TESTENV_STRING')" ) ); QVariant result = e.evaluate( &context ); @@ -2826,7 +2826,7 @@ class TestQgsExpression: public QObject setenv( "TESTENV_INT", "5", 1 ); #endif - QgsExpression e2( "env('TESTENV_INT')" ); + QgsExpression e2( QStringLiteral( "env('TESTENV_INT')" ) ); QVariant result2 = e2.evaluate( &context ); @@ -2837,7 +2837,7 @@ class TestQgsExpression: public QObject unsetenv( "TESTENV_INT" ); #endif - QgsExpression e3( "env('TESTENV_I_DO_NOT_EXIST')" ); + QgsExpression e3( QStringLiteral( "env('TESTENV_I_DO_NOT_EXIST')" ) ); QVariant result3 = e3.evaluate( &context ); Q_ASSERT( result3.isNull() ); diff --git a/tests/src/core/testqgsexpressioncontext.cpp b/tests/src/core/testqgsexpressioncontext.cpp index 9f841b461b94..2547b48006ea 100644 --- a/tests/src/core/testqgsexpressioncontext.cpp +++ b/tests/src/core/testqgsexpressioncontext.cpp @@ -724,8 +724,8 @@ void TestQgsExpressionContext::valuesAsMap() //add a scope to the context QgsExpressionContextScope *s1 = new QgsExpressionContextScope(); - s1->setVariable( "v1", "t1" ); - s1->setVariable( "v2", "t2" ); + s1->setVariable( QStringLiteral( "v1" ), "t1" ); + s1->setVariable( QStringLiteral( "v2" ), "t2" ); context << s1; QVariantMap m = context.variablesToMap(); @@ -734,8 +734,8 @@ void TestQgsExpressionContext::valuesAsMap() QCOMPARE( m.value( "v2" ).toString(), QString( "t2" ) ); QgsExpressionContextScope *s2 = new QgsExpressionContextScope(); - s2->setVariable( "v2", "t2a" ); - s2->setVariable( "v3", "t3" ); + s2->setVariable( QStringLiteral( "v2" ), "t2a" ); + s2->setVariable( QStringLiteral( "v3" ), "t3" ); context << s2; m = context.variablesToMap(); diff --git a/tests/src/core/testqgsfield.cpp b/tests/src/core/testqgsfield.cpp index 37fb2ee94aa9..700d39692303 100644 --- a/tests/src/core/testqgsfield.cpp +++ b/tests/src/core/testqgsfield.cpp @@ -303,7 +303,7 @@ void TestQgsField::displayString() QCOMPARE( stringField.displayString( test ), test ); //test NULL - QgsApplication::setNullRepresentation( "TEST NULL" ); + QgsApplication::setNullRepresentation( QStringLiteral( "TEST NULL" ) ); QVariant nullString = QVariant( QVariant::String ); QCOMPARE( stringField.displayString( nullString ), QString( "TEST NULL" ) ); diff --git a/tests/src/core/testqgsfields.cpp b/tests/src/core/testqgsfields.cpp index 7e41d32d04af..081f8e15929a 100644 --- a/tests/src/core/testqgsfields.cpp +++ b/tests/src/core/testqgsfields.cpp @@ -337,7 +337,7 @@ void TestQgsFields::indexFromName() field3.setAlias( QStringLiteral( "" ) ); fields.append( field3 ); - QCOMPARE( fields.lookupField( QString( "" ) ), -1 ); + QCOMPARE( fields.lookupField( QLatin1String( "" ) ), -1 ); QCOMPARE( fields.lookupField( QString() ), -1 ); QCOMPARE( fields.indexFromName( QString( "bad" ) ), -1 ); diff --git a/tests/src/core/testqgsgeometry.cpp b/tests/src/core/testqgsgeometry.cpp index dfc314af9ddf..908eeadbada5 100644 --- a/tests/src/core/testqgsgeometry.cpp +++ b/tests/src/core/testqgsgeometry.cpp @@ -134,7 +134,7 @@ class TestQgsGeometry : public QObject private: //! A helper method to do a render check to see if the geometry op is as expected - bool renderCheck( const QString &testName, const QString &comment = QLatin1String( QLatin1String( "" ) ), int mismatchCount = 0 ); + bool renderCheck( const QString &testName, const QString &comment = QString(), int mismatchCount = 0 ); //! A helper method to dump to qdebug the geometry of a multipolygon void dumpMultiPolygon( QgsMultiPolygon &multiPolygon ); //! A helper method to dump to qdebug the geometry of a polygon @@ -4599,7 +4599,7 @@ void TestQgsGeometry::polygon() exportPolygon.setExteriorRing( ext ); // GML document for compare - QDomDocument doc( "gml" ); + QDomDocument doc( QStringLiteral( "gml" ) ); // as GML2 QString expectedSimpleGML2( QStringLiteral( "0,0 0,10 10,10 10,0 0,0" ) ); @@ -4610,7 +4610,7 @@ void TestQgsGeometry::polygon() QCOMPARE( elemToString( exportPolygon.asGML3( doc ) ), expectedSimpleGML3 ); // as JSON - QString expectedSimpleJson( "{\"type\": \"Polygon\", \"coordinates\": [[ [0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]] }" ); + QString expectedSimpleJson( QStringLiteral( "{\"type\": \"Polygon\", \"coordinates\": [[ [0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]] }" ) ); QCOMPARE( exportPolygon.asJSON(), expectedSimpleJson ); ring = new QgsLineString(); @@ -7286,7 +7286,7 @@ void TestQgsGeometry::curvePolygon() // GML document for compare - QDomDocument doc( "gml" ); + QDomDocument doc( QStringLiteral( "gml" ) ); // as GML2 QString expectedSimpleGML2( QStringLiteral( "0,0 1,0 2,0 2,0 2,0 2,0.1 1.9,0.1 1.9,0.1 1.9,0.1 1.9,0.1 1.9,0.1 1.9,0.1 1.9,0.2 1.8,0.2 1.8,0.2 1.8,0.2 1.8,0.2 1.8,0.2 1.8,0.2 1.7,0.3 1.7,0.3 1.7,0.3 1.7,0.3 1.7,0.3 1.6,0.3 1.6,0.3 1.6,0.3 1.6,0.4 1.6,0.4 1.6,0.4 1.5,0.4 1.5,0.4 1.5,0.4 1.5,0.4 1.5,0.4 1.4,0.4 1.4,0.4 1.4,0.4 1.4,0.4 1.4,0.4 1.3,0.5 1.3,0.5 1.3,0.5 1.3,0.5 1.2,0.5 1.2,0.5 1.2,0.5 1.2,0.5 1.2,0.5 1.1,0.5 1.1,0.5 1.1,0.5 1.1,0.5 1.1,0.5 1,0.5 1,0.5 1,0.5 1,0.5 0.9,0.5 0.9,0.5 0.9,0.5 0.9,0.5 0.9,0.5 0.8,0.5 0.8,0.5 0.8,0.5 0.8,0.5 0.8,0.5 0.7,0.5 0.7,0.5 0.7,0.5 0.7,0.5 0.6,0.4 0.6,0.4 0.6,0.4 0.6,0.4 0.6,0.4 0.5,0.4 0.5,0.4 0.5,0.4 0.5,0.4 0.5,0.4 0.4,0.4 0.4,0.4 0.4,0.4 0.4,0.3 0.4,0.3 0.4,0.3 0.3,0.3 0.3,0.3 0.3,0.3 0.3,0.3 0.3,0.3 0.2,0.2 0.2,0.2 0.2,0.2 0.2,0.2 0.2,0.2 0.2,0.2 0.1,0.2 0.1,0.1 0.1,0.1 0.1,0.1 0.1,0.1 0.1,0.1 0.1,0.1 0,0.1 0,0 0,0 0,0" ) ); @@ -7299,7 +7299,7 @@ void TestQgsGeometry::curvePolygon() QCOMPARE( elemToString( exportPolygon.asGML3( doc ) ), expectedSimpleGML3 ); // as JSON - QString expectedSimpleJson( "{\"type\": \"Polygon\", \"coordinates\": [[ [0, 0], [1, 0], [2, 0], [2, 0], [2, 0], [2, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.2], [1.8, 0.2], [1.8, 0.2], [1.8, 0.2], [1.8, 0.2], [1.8, 0.2], [1.8, 0.2], [1.7, 0.3], [1.7, 0.3], [1.7, 0.3], [1.7, 0.3], [1.7, 0.3], [1.6, 0.3], [1.6, 0.3], [1.6, 0.3], [1.6, 0.4], [1.6, 0.4], [1.6, 0.4], [1.5, 0.4], [1.5, 0.4], [1.5, 0.4], [1.5, 0.4], [1.5, 0.4], [1.4, 0.4], [1.4, 0.4], [1.4, 0.4], [1.4, 0.4], [1.4, 0.4], [1.3, 0.5], [1.3, 0.5], [1.3, 0.5], [1.3, 0.5], [1.2, 0.5], [1.2, 0.5], [1.2, 0.5], [1.2, 0.5], [1.2, 0.5], [1.1, 0.5], [1.1, 0.5], [1.1, 0.5], [1.1, 0.5], [1.1, 0.5], [1, 0.5], [1, 0.5], [1, 0.5], [1, 0.5], [0.9, 0.5], [0.9, 0.5], [0.9, 0.5], [0.9, 0.5], [0.9, 0.5], [0.8, 0.5], [0.8, 0.5], [0.8, 0.5], [0.8, 0.5], [0.8, 0.5], [0.7, 0.5], [0.7, 0.5], [0.7, 0.5], [0.7, 0.5], [0.6, 0.4], [0.6, 0.4], [0.6, 0.4], [0.6, 0.4], [0.6, 0.4], [0.5, 0.4], [0.5, 0.4], [0.5, 0.4], [0.5, 0.4], [0.5, 0.4], [0.4, 0.4], [0.4, 0.4], [0.4, 0.4], [0.4, 0.3], [0.4, 0.3], [0.4, 0.3], [0.3, 0.3], [0.3, 0.3], [0.3, 0.3], [0.3, 0.3], [0.3, 0.3], [0.2, 0.2], [0.2, 0.2], [0.2, 0.2], [0.2, 0.2], [0.2, 0.2], [0.2, 0.2], [0.1, 0.2], [0.1, 0.1], [0.1, 0.1], [0.1, 0.1], [0.1, 0.1], [0.1, 0.1], [0.1, 0.1], [0, 0.1], [0, 0], [0, 0], [0, 0]]] }" ); + QString expectedSimpleJson( QStringLiteral( "{\"type\": \"Polygon\", \"coordinates\": [[ [0, 0], [1, 0], [2, 0], [2, 0], [2, 0], [2, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.1], [1.9, 0.2], [1.8, 0.2], [1.8, 0.2], [1.8, 0.2], [1.8, 0.2], [1.8, 0.2], [1.8, 0.2], [1.7, 0.3], [1.7, 0.3], [1.7, 0.3], [1.7, 0.3], [1.7, 0.3], [1.6, 0.3], [1.6, 0.3], [1.6, 0.3], [1.6, 0.4], [1.6, 0.4], [1.6, 0.4], [1.5, 0.4], [1.5, 0.4], [1.5, 0.4], [1.5, 0.4], [1.5, 0.4], [1.4, 0.4], [1.4, 0.4], [1.4, 0.4], [1.4, 0.4], [1.4, 0.4], [1.3, 0.5], [1.3, 0.5], [1.3, 0.5], [1.3, 0.5], [1.2, 0.5], [1.2, 0.5], [1.2, 0.5], [1.2, 0.5], [1.2, 0.5], [1.1, 0.5], [1.1, 0.5], [1.1, 0.5], [1.1, 0.5], [1.1, 0.5], [1, 0.5], [1, 0.5], [1, 0.5], [1, 0.5], [0.9, 0.5], [0.9, 0.5], [0.9, 0.5], [0.9, 0.5], [0.9, 0.5], [0.8, 0.5], [0.8, 0.5], [0.8, 0.5], [0.8, 0.5], [0.8, 0.5], [0.7, 0.5], [0.7, 0.5], [0.7, 0.5], [0.7, 0.5], [0.6, 0.4], [0.6, 0.4], [0.6, 0.4], [0.6, 0.4], [0.6, 0.4], [0.5, 0.4], [0.5, 0.4], [0.5, 0.4], [0.5, 0.4], [0.5, 0.4], [0.4, 0.4], [0.4, 0.4], [0.4, 0.4], [0.4, 0.3], [0.4, 0.3], [0.4, 0.3], [0.3, 0.3], [0.3, 0.3], [0.3, 0.3], [0.3, 0.3], [0.3, 0.3], [0.2, 0.2], [0.2, 0.2], [0.2, 0.2], [0.2, 0.2], [0.2, 0.2], [0.2, 0.2], [0.1, 0.2], [0.1, 0.1], [0.1, 0.1], [0.1, 0.1], [0.1, 0.1], [0.1, 0.1], [0.1, 0.1], [0, 0.1], [0, 0], [0, 0], [0, 0]]] }" ) ); res = exportPolygon.asJSON( 1 ); QCOMPARE( res, expectedSimpleJson ); @@ -10715,12 +10715,12 @@ void TestQgsGeometry::poleOfInaccessibility() QGSCOMPARENEAR( point.y(), 3263.50, 0.01 ); //test degenerate polygons - QgsGeometry degen1 = QgsGeometry::fromWkt( "Polygon(( 0 0, 1 0, 2 0, 0 0 ))" ); + QgsGeometry degen1 = QgsGeometry::fromWkt( QStringLiteral( "Polygon(( 0 0, 1 0, 2 0, 0 0 ))" ) ); point = degen1.poleOfInaccessibility( 1 ).asPoint(); QGSCOMPARENEAR( point.x(), 0, 0.01 ); QGSCOMPARENEAR( point.y(), 0, 0.01 ); - QgsGeometry degen2 = QgsGeometry::fromWkt( "Polygon(( 0 0, 1 0, 1 1 , 1 0, 0 0 ))" ); + QgsGeometry degen2 = QgsGeometry::fromWkt( QStringLiteral( "Polygon(( 0 0, 1 0, 1 1 , 1 0, 0 0 ))" ) ); point = degen2.poleOfInaccessibility( 1 ).asPoint(); QGSCOMPARENEAR( point.x(), 0, 0.01 ); QGSCOMPARENEAR( point.y(), 0, 0.01 ); @@ -10729,7 +10729,7 @@ void TestQgsGeometry::poleOfInaccessibility() QVERIFY( QgsGeometry().poleOfInaccessibility( 1 ).isNull() ); // not a polygon - QgsGeometry lineString = QgsGeometry::fromWkt( "LineString(1 0, 2 2 )" ); + QgsGeometry lineString = QgsGeometry::fromWkt( QStringLiteral( "LineString(1 0, 2 2 )" ) ); QVERIFY( lineString.poleOfInaccessibility( 1 ).isNull() ); // invalid threshold @@ -10756,20 +10756,20 @@ void TestQgsGeometry::makeValid() typedef QPair InputAndExpectedWktPair; QList geoms; // dimension collapse - geoms << qMakePair( QString( "LINESTRING(0 0)" ), - QString( "POINT(0 0)" ) ); + geoms << qMakePair( QStringLiteral( "LINESTRING(0 0)" ), + QStringLiteral( "POINT(0 0)" ) ); // unclosed ring - geoms << qMakePair( QString( "POLYGON((10 22,10 32,20 32,20 22))" ), - QString( "POLYGON((10 22,10 32,20 32,20 22,10 22))" ) ); + geoms << qMakePair( QStringLiteral( "POLYGON((10 22,10 32,20 32,20 22))" ), + QStringLiteral( "POLYGON((10 22,10 32,20 32,20 22,10 22))" ) ); // butterfly polygon (self-intersecting ring) - geoms << qMakePair( QString( "POLYGON((0 0, 10 10, 10 0, 0 10, 0 0))" ), - QString( "MULTIPOLYGON(((5 5, 0 0, 0 10, 5 5)),((5 5, 10 10, 10 0, 5 5)))" ) ); + geoms << qMakePair( QStringLiteral( "POLYGON((0 0, 10 10, 10 0, 0 10, 0 0))" ), + QStringLiteral( "MULTIPOLYGON(((5 5, 0 0, 0 10, 5 5)),((5 5, 10 10, 10 0, 5 5)))" ) ); // polygon with extra tail (a part of the ring does not form any area) - geoms << qMakePair( QString( "POLYGON((0 0, 1 0, 1 1, 0 1, 0 0, -1 0, 0 0))" ), - QString( "GEOMETRYCOLLECTION(POLYGON((0 0, 0 1, 1 1, 1 0, 0 0)), LINESTRING(0 0, -1 0))" ) ); + geoms << qMakePair( QStringLiteral( "POLYGON((0 0, 1 0, 1 1, 0 1, 0 0, -1 0, 0 0))" ), + QStringLiteral( "GEOMETRYCOLLECTION(POLYGON((0 0, 0 1, 1 1, 1 0, 0 0)), LINESTRING(0 0, -1 0))" ) ); // collection with invalid geometries - geoms << qMakePair( QString( "GEOMETRYCOLLECTION(LINESTRING(0 0, 0 0), POLYGON((0 0, 10 10, 10 0, 0 10, 0 0)), LINESTRING(10 0, 10 10))" ), - QString( "GEOMETRYCOLLECTION(POINT(0 0), MULTIPOLYGON(((5 5, 0 0, 0 10, 5 5)),((5 5, 10 10, 10 0, 5 5))), LINESTRING(10 0, 10 10)))" ) ); + geoms << qMakePair( QStringLiteral( "GEOMETRYCOLLECTION(LINESTRING(0 0, 0 0), POLYGON((0 0, 10 10, 10 0, 0 10, 0 0)), LINESTRING(10 0, 10 10))" ), + QStringLiteral( "GEOMETRYCOLLECTION(POINT(0 0), MULTIPOLYGON(((5 5, 0 0, 0 10, 5 5)),((5 5, 10 10, 10 0, 5 5))), LINESTRING(10 0, 10 10)))" ) ); Q_FOREACH ( const InputAndExpectedWktPair &pair, geoms ) { @@ -10788,18 +10788,18 @@ void TestQgsGeometry::isSimple() { typedef QPair InputWktAndExpectedResult; QList geoms; - geoms << qMakePair( QString( "LINESTRING(0 0, 1 0, 1 1)" ), true ); - geoms << qMakePair( QString( "LINESTRING(0 0, 1 0, 1 1, 0 0)" ), true ); // may be closed (linear ring) - geoms << qMakePair( QString( "LINESTRING(0 0, 1 0, 1 1, 0 -1)" ), false ); // self-intersection - geoms << qMakePair( QString( "LINESTRING(0 0, 1 0, 1 1, 0.5 0, 0 1)" ), false ); // self-tangency - geoms << qMakePair( QString( "POINT(1 1)" ), true ); // points are simple - geoms << qMakePair( QString( "POLYGON((0 0, 1 1, 1 1, 0 0))" ), true ); // polygons are always simple, even if they are invalid - geoms << qMakePair( QString( "MULTIPOINT((1 1), (2 2))" ), true ); - geoms << qMakePair( QString( "MULTIPOINT((1 1), (1 1))" ), false ); // must not contain the same point twice - geoms << qMakePair( QString( "MULTILINESTRING((0 0, 1 0), (0 1, 1 1))" ), true ); - geoms << qMakePair( QString( "MULTILINESTRING((0 0, 1 0), (0 0, 1 0))" ), true ); // may be touching at endpoints - geoms << qMakePair( QString( "MULTILINESTRING((0 0, 1 1), (0 1, 1 0))" ), false ); // must not intersect each other - geoms << qMakePair( QString( "MULTIPOLYGON(((0 0, 1 1, 1 1, 0 0)),((0 0, 1 1, 1 1, 0 0)))" ), true ); // multi-polygons are always simple + geoms << qMakePair( QStringLiteral( "LINESTRING(0 0, 1 0, 1 1)" ), true ); + geoms << qMakePair( QStringLiteral( "LINESTRING(0 0, 1 0, 1 1, 0 0)" ), true ); // may be closed (linear ring) + geoms << qMakePair( QStringLiteral( "LINESTRING(0 0, 1 0, 1 1, 0 -1)" ), false ); // self-intersection + geoms << qMakePair( QStringLiteral( "LINESTRING(0 0, 1 0, 1 1, 0.5 0, 0 1)" ), false ); // self-tangency + geoms << qMakePair( QStringLiteral( "POINT(1 1)" ), true ); // points are simple + geoms << qMakePair( QStringLiteral( "POLYGON((0 0, 1 1, 1 1, 0 0))" ), true ); // polygons are always simple, even if they are invalid + geoms << qMakePair( QStringLiteral( "MULTIPOINT((1 1), (2 2))" ), true ); + geoms << qMakePair( QStringLiteral( "MULTIPOINT((1 1), (1 1))" ), false ); // must not contain the same point twice + geoms << qMakePair( QStringLiteral( "MULTILINESTRING((0 0, 1 0), (0 1, 1 1))" ), true ); + geoms << qMakePair( QStringLiteral( "MULTILINESTRING((0 0, 1 0), (0 0, 1 0))" ), true ); // may be touching at endpoints + geoms << qMakePair( QStringLiteral( "MULTILINESTRING((0 0, 1 1), (0 1, 1 0))" ), false ); // must not intersect each other + geoms << qMakePair( QStringLiteral( "MULTIPOLYGON(((0 0, 1 1, 1 1, 0 0)),((0 0, 1 1, 1 1, 0 0)))" ), true ); // multi-polygons are always simple Q_FOREACH ( const InputWktAndExpectedResult &pair, geoms ) { @@ -10814,8 +10814,8 @@ void TestQgsGeometry::isSimple() void TestQgsGeometry::reshapeGeometryLineMerge() { int res; - QgsGeometry g2D = QgsGeometry::fromWkt( "LINESTRING(10 10, 20 20)" ); - QgsGeometry g3D = QgsGeometry::fromWkt( "LINESTRINGZ(10 10 1, 20 20 2)" ); + QgsGeometry g2D = QgsGeometry::fromWkt( QStringLiteral( "LINESTRING(10 10, 20 20)" ) ); + QgsGeometry g3D = QgsGeometry::fromWkt( QStringLiteral( "LINESTRINGZ(10 10 1, 20 20 2)" ) ); // prepare 2D reshaping line QVector v2D_1, v2D_2; @@ -10909,35 +10909,35 @@ void TestQgsGeometry::minimalEnclosingCircle() QCOMPARE( result, resultTest ); // case 2 - geomTest = QgsGeometry::fromWkt( QString( "MULTIPOINT( 3 8, 7 4 )" ) ); + geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 3 8, 7 4 )" ) ); result = geomTest.minimalEnclosingCircle( center, radius ); QGSCOMPARENEARPOINT( center, QgsPointXY( 5, 6 ), 0.0001 ); QGSCOMPARENEAR( radius, sqrt( 2 ) * 2, 0.0001 ); resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) ); QCOMPARE( result, resultTest ); - geomTest = QgsGeometry::fromWkt( QString( "LINESTRING( 0 5, 2 2, 0 -5, -1 -1 )" ) ); + geomTest = QgsGeometry::fromWkt( QStringLiteral( "LINESTRING( 0 5, 2 2, 0 -5, -1 -1 )" ) ); result = geomTest.minimalEnclosingCircle( center, radius ); QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 ); QGSCOMPARENEAR( radius, 5, 0.0001 ); resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) ); QCOMPARE( result, resultTest ); - geomTest = QgsGeometry::fromWkt( QString( "MULTIPOINT( 0 5, 2 2, 0 -5, -1 -1 )" ) ); + geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 2 2, 0 -5, -1 -1 )" ) ); result = geomTest.minimalEnclosingCircle( center, radius ); QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 ); QGSCOMPARENEAR( radius, 5, 0.0001 ); resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) ); QCOMPARE( result, resultTest ); - geomTest = QgsGeometry::fromWkt( QString( "POLYGON(( 0 5, 2 2, 0 -5, -1 -1 ))" ) ); + geomTest = QgsGeometry::fromWkt( QStringLiteral( "POLYGON(( 0 5, 2 2, 0 -5, -1 -1 ))" ) ); result = geomTest.minimalEnclosingCircle( center, radius ); QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 ); QGSCOMPARENEAR( radius, 5, 0.0001 ); resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) ); QCOMPARE( result, resultTest ); - geomTest = QgsGeometry::fromWkt( QString( "MULTIPOINT( 0 5, 0 -5, 0 0 )" ) ); + geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 0 -5, 0 0 )" ) ); result = geomTest.minimalEnclosingCircle( center, radius ); QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 ); QGSCOMPARENEAR( radius, 5, 0.0001 ); @@ -10945,7 +10945,7 @@ void TestQgsGeometry::minimalEnclosingCircle() QCOMPARE( result, resultTest ); // case 3 - geomTest = QgsGeometry::fromWkt( QString( "MULTIPOINT((0 0), (5 5), (0 -5), (0 5), (-5 0))" ) ); + geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT((0 0), (5 5), (0 -5), (0 5), (-5 0))" ) ); result = geomTest.minimalEnclosingCircle( center, radius ); QGSCOMPARENEARPOINT( center, QgsPointXY( 0.8333, 0.8333 ), 0.0001 ); QGSCOMPARENEAR( radius, 5.8926, 0.0001 ); diff --git a/tests/src/core/testqgsgeometryimport.cpp b/tests/src/core/testqgsgeometryimport.cpp index 2dc7bd03078d..54d0d289e1d9 100644 --- a/tests/src/core/testqgsgeometryimport.cpp +++ b/tests/src/core/testqgsgeometryimport.cpp @@ -252,18 +252,18 @@ void TestQgsGeometryImport::delimiters_data() { QTest::addColumn( "input" ); QTest::addColumn( "expected" ); - QTest::newRow( "tab delimiter" ) << QString( "POINT (180398\t5459331)" ) << QString( "Point (180398 5459331)" ); - QTest::newRow( "newline" ) << QString( "POINT\n(1\n3)" ) << QString( "Point (1 3)" ); - QTest::newRow( "tab and newline" ) << QString( "POINT\t\n(1\t\n3)" ) << QString( "Point (1 3)" ); - QTest::newRow( "tab, newline and space" ) << QString( "POINT\n (1\t\n 3)" ) << QString( "Point (1 3)" ); - - QTest::newRow( "tab delimiter" ) << QString( "LINESTRING\t(30\t10,\t10\t30,\t40\t40)" ) << QString( "LineString (30 10, 10 30, 40 40)" ); - QTest::newRow( "newline delimiter" ) << QString( "LINESTRING\n(30\n10,\n10\n30,\n40\n40)" ) << QString( "LineString (30 10, 10 30, 40 40)" ); - QTest::newRow( "mixed delimiter" ) << QString( "LINESTRING\n(30\t10, 10\t30,\n40\t40)" ) << QString( "LineString (30 10, 10 30, 40 40)" ); - - QTest::newRow( "tab delimiter" ) << QString( "Polygon\t(\t(30\t10,\t10\t30,\t40\t40,30\t10)\t)" ) << QString( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); - QTest::newRow( "newline delimiter" ) << QString( "\nPolygon\n(\n(30\n10,\n10\n30,\n40\n40,30\n10)\n)\n" ) << QString( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); - QTest::newRow( "mixed delimiter" ) << QString( " Polygon (\t(30\n10,\t10\n30,\t40 40,30\n10)\t)\n" ) << QString( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); + QTest::newRow( "tab delimiter" ) << QStringLiteral( "POINT (180398\t5459331)" ) << QStringLiteral( "Point (180398 5459331)" ); + QTest::newRow( "newline" ) << QStringLiteral( "POINT\n(1\n3)" ) << QStringLiteral( "Point (1 3)" ); + QTest::newRow( "tab and newline" ) << QStringLiteral( "POINT\t\n(1\t\n3)" ) << QStringLiteral( "Point (1 3)" ); + QTest::newRow( "tab, newline and space" ) << QStringLiteral( "POINT\n (1\t\n 3)" ) << QStringLiteral( "Point (1 3)" ); + + QTest::newRow( "tab delimiter" ) << QStringLiteral( "LINESTRING\t(30\t10,\t10\t30,\t40\t40)" ) << QStringLiteral( "LineString (30 10, 10 30, 40 40)" ); + QTest::newRow( "newline delimiter" ) << QStringLiteral( "LINESTRING\n(30\n10,\n10\n30,\n40\n40)" ) << QStringLiteral( "LineString (30 10, 10 30, 40 40)" ); + QTest::newRow( "mixed delimiter" ) << QStringLiteral( "LINESTRING\n(30\t10, 10\t30,\n40\t40)" ) << QStringLiteral( "LineString (30 10, 10 30, 40 40)" ); + + QTest::newRow( "tab delimiter" ) << QStringLiteral( "Polygon\t(\t(30\t10,\t10\t30,\t40\t40,30\t10)\t)" ) << QStringLiteral( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); + QTest::newRow( "newline delimiter" ) << QStringLiteral( "\nPolygon\n(\n(30\n10,\n10\n30,\n40\n40,30\n10)\n)\n" ) << QStringLiteral( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); + QTest::newRow( "mixed delimiter" ) << QStringLiteral( " Polygon (\t(30\n10,\t10\n30,\t40 40,30\n10)\t)\n" ) << QStringLiteral( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); } void TestQgsGeometryImport::delimiters() diff --git a/tests/src/core/testqgsgeonodeconnection.cpp b/tests/src/core/testqgsgeonodeconnection.cpp index c3072822862e..ca3f712229fd 100644 --- a/tests/src/core/testqgsgeonodeconnection.cpp +++ b/tests/src/core/testqgsgeonodeconnection.cpp @@ -149,7 +149,7 @@ void TestQgsGeoNodeConnection::testStyleAPI() QVERIFY( defaultStyle.body.toString().startsWith( QStringLiteral( "" ) ) ); - QgsGeoNodeStyle geoNodeStyle = geonodeRequest.fetchStyleBlocking( "76" ); + QgsGeoNodeStyle geoNodeStyle = geonodeRequest.fetchStyleBlocking( QStringLiteral( "76" ) ); QVERIFY( !geoNodeStyle.name.isEmpty() ); QVERIFY( geoNodeStyle.body.toString().startsWith( QStringLiteral( "" ) ) ); diff --git a/tests/src/core/testqgslabelingengine.cpp b/tests/src/core/testqgslabelingengine.cpp index 64270165f2ca..48aba3f0cdf1 100644 --- a/tests/src/core/testqgslabelingengine.cpp +++ b/tests/src/core/testqgslabelingengine.cpp @@ -101,7 +101,7 @@ void TestQgsLabelingEngine::setDefaultLabelParams( QgsPalLayerSettings &settings QgsTextFormat format; format.setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ).family() ); format.setSize( 12 ); - format.setNamedStyle( "Bold" ); + format.setNamedStyle( QStringLiteral( "Bold" ) ); format.setColor( QColor( 200, 0, 200 ) ); settings.setFormat( format ); } @@ -128,7 +128,7 @@ void TestQgsLabelingEngine::testBasic() context.setPainter( &p ); QgsPalLayerSettings settings; - settings.fieldName = "Class"; + settings.fieldName = QStringLiteral( "Class" ); setDefaultLabelParams( settings ); vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! @@ -590,22 +590,22 @@ bool TestQgsLabelingEngine::imageCheck( const QString &testName, QImage &image, void TestQgsLabelingEngine::testRegisterFeatureUnprojectible() { QgsPalLayerSettings settings; - settings.fieldName = QString( "'aa label'" ); + settings.fieldName = QStringLiteral( "'aa label'" ); settings.isExpression = true; settings.fitInPolygonOnly = true; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( "polygon?crs=epsg:4326&field=id:integer", "vl", "memory" ) ); - QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), "test", true, &settings ); + std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); QgsFeature f( vl2->fields(), 1 ); - QString wkt1 = "POLYGON((0 0,8 0,8 -90,0 0))"; + QString wkt1 = QStringLiteral( "POLYGON((0 0,8 0,8 -90,0 0))" ); f.setGeometry( QgsGeometry().fromWkt( wkt1 ) ); // make a fake render context QSize size( 640, 480 ); QgsMapSettings mapSettings; QgsCoordinateReferenceSystem tgtCrs; - tgtCrs.createFromString( "EPSG:3857" ); + tgtCrs.createFromString( QStringLiteral( "EPSG:3857" ) ); mapSettings.setDestinationCrs( tgtCrs ); mapSettings.setOutputSize( size ); diff --git a/tests/src/core/testqgslayertree.cpp b/tests/src/core/testqgslayertree.cpp index 8da329169934..76fa2bf896e2 100644 --- a/tests/src/core/testqgslayertree.cpp +++ b/tests/src/core/testqgslayertree.cpp @@ -93,7 +93,7 @@ void TestQgsLayerTree::testGroupNameChanged() QgsLayerTreeNode *secondGroup = mRoot->children()[1]; QSignalSpy spy( mRoot, SIGNAL( nameChanged( QgsLayerTreeNode *, QString ) ) ); - secondGroup->setName( "grp2+" ); + secondGroup->setName( QStringLiteral( "grp2+" ) ); QCOMPARE( secondGroup->name(), QString( "grp2+" ) ); @@ -102,7 +102,7 @@ void TestQgsLayerTree::testGroupNameChanged() QCOMPARE( arguments.at( 0 ).value(), secondGroup ); QCOMPARE( arguments.at( 1 ).toString(), QString( "grp2+" ) ); - secondGroup->setName( "grp2" ); + secondGroup->setName( QStringLiteral( "grp2" ) ); QCOMPARE( secondGroup->name(), QString( "grp2" ) ); } @@ -117,7 +117,7 @@ void TestQgsLayerTree::testLayerNameChanged() QSignalSpy spy( mRoot, SIGNAL( nameChanged( QgsLayerTreeNode *, QString ) ) ); QCOMPARE( n->name(), QString( "vl" ) ); - n->setName( "changed 1" ); + n->setName( QStringLiteral( "changed 1" ) ); QCOMPARE( n->name(), QString( "changed 1" ) ); QCOMPARE( spy.count(), 1 ); @@ -130,7 +130,7 @@ void TestQgsLayerTree::testLayerNameChanged() n->resolveReferences( &project ); // set name via map layer - vl->setName( "changed 2" ); + vl->setName( QStringLiteral( "changed 2" ) ); QCOMPARE( n->name(), QString( "changed 2" ) ); QCOMPARE( spy.count(), 1 ); arguments = spy.takeFirst(); @@ -138,7 +138,7 @@ void TestQgsLayerTree::testLayerNameChanged() QCOMPARE( arguments.at( 1 ).toString(), QString( "changed 2" ) ); // set name via layer tree - n->setName( "changed 3" ); + n->setName( QStringLiteral( "changed 3" ) ); QCOMPARE( n->name(), QString( "changed 3" ) ); QCOMPARE( spy.count(), 1 ); arguments = spy.takeFirst(); @@ -426,13 +426,13 @@ void TestQgsLayerTree::testResolveReferences() QVERIFY( vl->isValid() ); QString n1id = vl->id(); - QString n2id = "XYZ"; + QString n2id = QStringLiteral( "XYZ" ); QgsMapLayer *nullLayer = nullptr; // QCOMPARE does not like nullptr directly QgsLayerTreeGroup *root = new QgsLayerTreeGroup(); QgsLayerTreeLayer *n1 = new QgsLayerTreeLayer( n1id, vl->name() ); - QgsLayerTreeLayer *n2 = new QgsLayerTreeLayer( n2id, "invalid layer" ); + QgsLayerTreeLayer *n2 = new QgsLayerTreeLayer( n2id, QStringLiteral( "invalid layer" ) ); root->addChildNode( n1 ); root->addChildNode( n2 ); diff --git a/tests/src/core/testqgslayout.cpp b/tests/src/core/testqgslayout.cpp index 9987f27d924d..e605ccc5e654 100644 --- a/tests/src/core/testqgslayout.cpp +++ b/tests/src/core/testqgslayout.cpp @@ -49,7 +49,7 @@ class TestQgsLayout: public QObject void TestQgsLayout::initTestCase() { - mReport = "

Layout Tests

\n"; + mReport = QStringLiteral( "

Layout Tests

\n" ); } void TestQgsLayout::cleanupTestCase() @@ -136,7 +136,7 @@ void TestQgsLayout::name() { QgsProject p; QgsLayout layout( &p ); - QString layoutName = "test name"; + QString layoutName = QStringLiteral( "test name" ); layout.setName( layoutName ); QCOMPARE( layout.name(), layoutName ); } @@ -191,19 +191,19 @@ void TestQgsLayout::scope() // no crash std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::layoutScope( nullptr ) ); - l.setName( "test" ); + l.setName( QStringLiteral( "test" ) ); scope.reset( QgsExpressionContextUtils::layoutScope( &l ) ); QCOMPARE( scope->variable( "layout_name" ).toString(), QStringLiteral( "test" ) ); - QgsExpressionContextUtils::setLayoutVariable( &l, "new_var", 5 ); - QgsExpressionContextUtils::setLayoutVariable( &l, "new_var2", 15 ); + QgsExpressionContextUtils::setLayoutVariable( &l, QStringLiteral( "new_var" ), 5 ); + QgsExpressionContextUtils::setLayoutVariable( &l, QStringLiteral( "new_var2" ), 15 ); scope.reset( QgsExpressionContextUtils::layoutScope( &l ) ); QCOMPARE( scope->variable( "layout_name" ).toString(), QStringLiteral( "test" ) ); QCOMPARE( scope->variable( "new_var" ).toInt(), 5 ); QCOMPARE( scope->variable( "new_var2" ).toInt(), 15 ); QVariantMap newVars; - newVars.insert( "new_var3", 17 ); + newVars.insert( QStringLiteral( "new_var3" ), 17 ); QgsExpressionContextUtils::setLayoutVariables( &l, newVars ); scope.reset( QgsExpressionContextUtils::layoutScope( &l ) ); QCOMPARE( scope->variable( "layout_name" ).toString(), QStringLiteral( "test" ) ); @@ -211,7 +211,7 @@ void TestQgsLayout::scope() QVERIFY( !scope->hasVariable( "new_var2" ) ); QCOMPARE( scope->variable( "new_var3" ).toInt(), 17 ); - p.setTitle( "my title" ); + p.setTitle( QStringLiteral( "my title" ) ); QgsExpressionContext c = l.createExpressionContext(); // should contain project variables QCOMPARE( c.variable( "project_title" ).toString(), QStringLiteral( "my title" ) ); diff --git a/tests/src/core/testqgslayoutcontext.cpp b/tests/src/core/testqgslayoutcontext.cpp index d3ca359160bc..efa724ec6091 100644 --- a/tests/src/core/testqgslayoutcontext.cpp +++ b/tests/src/core/testqgslayoutcontext.cpp @@ -45,7 +45,7 @@ class TestQgsLayoutContext: public QObject void TestQgsLayoutContext::initTestCase() { - mReport = "

Layout Context Tests

\n"; + mReport = QStringLiteral( "

Layout Context Tests

\n" ); } void TestQgsLayoutContext::cleanupTestCase() @@ -117,7 +117,7 @@ void TestQgsLayoutContext::layer() QVERIFY( !context.layer() ); //test setting/getting layer - QgsVectorLayer *layer = new QgsVectorLayer( "Point?field=id_a:integer", "A", "memory" ); + QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "A" ), QStringLiteral( "memory" ) ); context.setLayer( layer ); QCOMPARE( context.layer(), layer ); diff --git a/tests/src/core/testqgslayoutitem.cpp b/tests/src/core/testqgslayoutitem.cpp index 273be006c773..04cffbdaf8f8 100644 --- a/tests/src/core/testqgslayoutitem.cpp +++ b/tests/src/core/testqgslayoutitem.cpp @@ -157,7 +157,7 @@ class TestQgsLayoutItem: public QObject void TestQgsLayoutItem::initTestCase() { - mReport = "

Layout Item Tests

\n"; + mReport = QStringLiteral( "

Layout Item Tests

\n" ); } void TestQgsLayoutItem::cleanupTestCase() @@ -327,7 +327,7 @@ void TestQgsLayoutItem::debugRect() l.render( &painter ); painter.end(); - bool result = renderCheck( "layoutitem_debugrect", image, 0 ); + bool result = renderCheck( QStringLiteral( "layoutitem_debugrect" ), image, 0 ); QVERIFY( result ); } @@ -346,7 +346,7 @@ void TestQgsLayoutItem::draw() QPainter painter( &image ); l.render( &painter ); painter.end(); - bool result = renderCheck( "layoutitem_draw", image, 0 ); + bool result = renderCheck( QStringLiteral( "layoutitem_draw" ), image, 0 ); QVERIFY( result ); } @@ -357,7 +357,7 @@ bool TestQgsLayoutItem::renderCheck( QString testName, QImage &image, int mismat QString myFileName = myTmpDir + testName + ".png"; image.save( myFileName, "PNG" ); QgsRenderChecker myChecker; - myChecker.setControlPathPrefix( "layouts" ); + myChecker.setControlPathPrefix( QStringLiteral( "layouts" ) ); myChecker.setControlName( "expected_" + testName ); myChecker.setRenderedImage( myFileName ); bool myResultFlag = myChecker.compareImages( testName, mismatchCount ); @@ -1211,7 +1211,7 @@ void TestQgsLayoutItem::rotation() l.render( &painter ); painter.end(); - bool result = renderCheck( "layoutitem_rotation", image, 0 ); + bool result = renderCheck( QStringLiteral( "layoutitem_rotation" ), image, 0 ); delete item; QVERIFY( result ); } @@ -1226,7 +1226,7 @@ void TestQgsLayoutItem::writeXml() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); @@ -1242,7 +1242,7 @@ void TestQgsLayoutItem::writeXml() QCOMPARE( element.attribute( "type", "" ), item->stringType() ); //check that element has an object node - QDomNodeList objectNodeList = element.elementsByTagName( "LayoutObject" ); + QDomNodeList objectNodeList = element.elementsByTagName( QStringLiteral( "LayoutObject" ) ); QCOMPARE( objectNodeList.count(), 1 ); delete item; @@ -1253,7 +1253,7 @@ void TestQgsLayoutItem::readXml() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QgsProject proj; @@ -1261,19 +1261,19 @@ void TestQgsLayoutItem::readXml() TestItem *item = new TestItem( &l ); //try reading bad elements - QDomElement badElement = doc.createElement( "bad" ); + QDomElement badElement = doc.createElement( QStringLiteral( "bad" ) ); QDomElement noNode; QVERIFY( !item->readXml( badElement, doc, QgsReadWriteContext() ) ); QVERIFY( !item->readXml( noNode, doc, QgsReadWriteContext() ) ); //element with wrong type - QDomElement wrongType = doc.createElement( "LayoutItem" ); - wrongType.setAttribute( QString( "type" ), "bad" ); + QDomElement wrongType = doc.createElement( QStringLiteral( "LayoutItem" ) ); + wrongType.setAttribute( QStringLiteral( "type" ), QStringLiteral( "bad" ) ); QVERIFY( !item->readXml( wrongType, doc, QgsReadWriteContext() ) ); //try good element - QDomElement goodElement = doc.createElement( "LayoutItem" ); - goodElement.setAttribute( QString( "type" ), "TestItemType" ); + QDomElement goodElement = doc.createElement( QStringLiteral( "LayoutItem" ) ); + goodElement.setAttribute( QStringLiteral( "type" ), QStringLiteral( "TestItemType" ) ); QVERIFY( item->readXml( goodElement, doc, QgsReadWriteContext() ) ); delete item; } @@ -1315,7 +1315,7 @@ QgsLayoutItem *TestQgsLayoutItem::createCopyViaXml( QgsLayout *layout, QgsLayout QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); diff --git a/tests/src/core/testqgslayoutobject.cpp b/tests/src/core/testqgslayoutobject.cpp index 63d5c429c58a..a76c4de2dade 100644 --- a/tests/src/core/testqgslayoutobject.cpp +++ b/tests/src/core/testqgslayoutobject.cpp @@ -46,7 +46,7 @@ class TestQgsLayoutObject: public QObject void TestQgsLayoutObject::initTestCase() { - mReport = "

Layout Object Tests

\n"; + mReport = QStringLiteral( "

Layout Object Tests

\n" ); } void TestQgsLayoutObject::cleanupTestCase() @@ -125,9 +125,9 @@ void TestQgsLayoutObject::customProperties() void TestQgsLayoutObject::context() { QgsProject p; - p.setTitle( "my title" ); + p.setTitle( QStringLiteral( "my title" ) ); QgsLayout l( &p ); - l.setName( "my layout" ); + l.setName( QStringLiteral( "my layout" ) ); QgsLayoutObject *object = new QgsLayoutObject( nullptr ); // no crash @@ -152,21 +152,21 @@ void TestQgsLayoutObject::writeReadXml() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); //test writing with no parent node - QDomElement rootNode = doc.createElement( "qgis" ); + QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); QDomElement noNode; QCOMPARE( object->writeObjectPropertiesToElement( noNode, doc, QgsReadWriteContext() ), false ); //test writing with node - QDomElement layoutObjectElem = doc.createElement( "item" ); + QDomElement layoutObjectElem = doc.createElement( QStringLiteral( "item" ) ); rootNode.appendChild( layoutObjectElem ); QVERIFY( object->writeObjectPropertiesToElement( layoutObjectElem, doc, QgsReadWriteContext() ) ); //check if object node was written - QDomNodeList evalNodeList = rootNode.elementsByTagName( "LayoutObject" ); + QDomNodeList evalNodeList = rootNode.elementsByTagName( QStringLiteral( "LayoutObject" ) ); QCOMPARE( evalNodeList.count(), 1 ); //test reading node @@ -176,7 +176,7 @@ void TestQgsLayoutObject::writeReadXml() QCOMPARE( readObject->readObjectPropertiesFromElement( noNode, doc, QgsReadWriteContext() ), false ); //test node with no layout object child - QDomElement badLayoutObjectElem = doc.createElement( "item" ); + QDomElement badLayoutObjectElem = doc.createElement( QStringLiteral( "item" ) ); rootNode.appendChild( badLayoutObjectElem ); QCOMPARE( readObject->readObjectPropertiesFromElement( badLayoutObjectElem, doc, QgsReadWriteContext() ), false ); diff --git a/tests/src/core/testqgslayoutpage.cpp b/tests/src/core/testqgslayoutpage.cpp index 13e78d20d02c..d6142cb452fd 100644 --- a/tests/src/core/testqgslayoutpage.cpp +++ b/tests/src/core/testqgslayoutpage.cpp @@ -44,7 +44,7 @@ class TestQgsLayoutPage : public QObject void TestQgsLayoutPage::initTestCase() { - mReport = "

Layout Page Tests

\n"; + mReport = QStringLiteral( "

Layout Page Tests

\n" ); } void TestQgsLayoutPage::cleanupTestCase() diff --git a/tests/src/core/testqgslayoutunits.cpp b/tests/src/core/testqgslayoutunits.cpp index 44333141047a..2764fd975fe8 100644 --- a/tests/src/core/testqgslayoutunits.cpp +++ b/tests/src/core/testqgslayoutunits.cpp @@ -236,7 +236,7 @@ void TestQgsLayoutUnits::measurementEncodeDecode() QCOMPARE( original, result ); //test with bad string - result = QgsLayoutMeasurement::decodeMeasurement( QString( "1" ) ); + result = QgsLayoutMeasurement::decodeMeasurement( QStringLiteral( "1" ) ); QCOMPARE( result, QgsLayoutMeasurement( 0 ) ); } @@ -376,7 +376,7 @@ void TestQgsLayoutUnits::sizeEncodeDecode() QCOMPARE( original, result ); //test with bad string - result = QgsLayoutSize::decodeSize( QString( "1,2" ) ); + result = QgsLayoutSize::decodeSize( QStringLiteral( "1,2" ) ); QCOMPARE( result, QgsLayoutSize() ); } @@ -516,7 +516,7 @@ void TestQgsLayoutUnits::pointEncodeDecode() QCOMPARE( original, result ); //test with bad string - result = QgsLayoutPoint::decodePoint( QString( "1,2" ) ); + result = QgsLayoutPoint::decodePoint( QStringLiteral( "1,2" ) ); QCOMPARE( result, QgsLayoutPoint() ); } diff --git a/tests/src/core/testqgslayoututils.cpp b/tests/src/core/testqgslayoututils.cpp index 3b36307931c6..907a699803e7 100644 --- a/tests/src/core/testqgslayoututils.cpp +++ b/tests/src/core/testqgslayoututils.cpp @@ -41,7 +41,7 @@ class TestQgsLayoutUtils: public QObject void TestQgsLayoutUtils::initTestCase() { - mReport = "

Layout Utils Tests

\n"; + mReport = QStringLiteral( "

Layout Utils Tests

\n" ); } void TestQgsLayoutUtils::cleanupTestCase() @@ -88,7 +88,7 @@ void TestQgsLayoutUtils::normalizedAngle() { double result = QgsLayoutUtils::normalizedAngle( ( *it ).first ); - qDebug() << QString( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second ); + qDebug() << QStringLiteral( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second ); QGSCOMPARENEAR( result, ( *it ).second, 4 * DBL_EPSILON ); } @@ -109,7 +109,7 @@ void TestQgsLayoutUtils::normalizedAngle() { double result = QgsLayoutUtils::normalizedAngle( ( *it ).first, true ); - qDebug() << QString( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second ); + qDebug() << QStringLiteral( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second ); QGSCOMPARENEAR( result, ( *it ).second, 4 * DBL_EPSILON ); } diff --git a/tests/src/core/testqgslegendrenderer.cpp b/tests/src/core/testqgslegendrenderer.cpp index aed878bd136d..377429e2e92b 100644 --- a/tests/src/core/testqgslegendrenderer.cpp +++ b/tests/src/core/testqgslegendrenderer.cpp @@ -365,24 +365,24 @@ void TestQgsLegendRenderer::testTallSymbol() void TestQgsLegendRenderer::testLineSpacing() { - QString testName = "legend_line_spacing"; + QString testName = QStringLiteral( "legend_line_spacing" ); QgsCategorizedSymbolRenderer *catRenderer = dynamic_cast( mVL3->renderer() ); QVERIFY( catRenderer ); - catRenderer->updateCategoryLabel( 1, "This is\nthree lines\nlong label" ); + catRenderer->updateCategoryLabel( 1, QStringLiteral( "This is\nthree lines\nlong label" ) ); - mVL2->setName( "This is a two lines\nlong label" ); + mVL2->setName( QStringLiteral( "This is a two lines\nlong label" ) ); QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.setWrapChar( "\n" ); + settings.setWrapChar( QStringLiteral( "\n" ) ); settings.setLineSpacing( 3 ); _setStandardTestFont( settings ); _renderLegend( testName, &legendModel, settings ); QVERIFY( _verifyImage( testName, mReport ) ); - mVL2->setName( "Polygon Layer" ); + mVL2->setName( QStringLiteral( "Polygon Layer" ) ); } void TestQgsLegendRenderer::testLongSymbolText() @@ -703,7 +703,7 @@ void TestQgsLegendRenderer::testDiagramSizeLegend() dr->setLowerSize( QSizeF( 1, 1 ) ); dr->setUpperValue( 10 ); dr->setUpperSize( QSizeF( 20, 20 ) ); - dr->setClassificationField( QString( "a" ) ); + dr->setClassificationField( QStringLiteral( "a" ) ); dr->setDiagram( new QgsPieDiagram() ); dr->setDiagramSettings( ds ); dr->setDataDefinedSizeLegend( new QgsDataDefinedSizeLegend() ); @@ -760,11 +760,11 @@ void TestQgsLegendRenderer::testDataDefinedSizeCollapsed() } QgsStringMap props; - props["name"] = "circle"; - props["color"] = "200,200,200"; - props["outline_color"] = "0,0,0"; + props[QStringLiteral( "name" )] = QStringLiteral( "circle" ); + props[QStringLiteral( "color" )] = QStringLiteral( "200,200,200" ); + props[QStringLiteral( "outline_color" )] = QStringLiteral( "0,0,0" ); QgsMarkerSymbol *symbol = QgsMarkerSymbol::createSimple( props ); - QgsProperty ddsProperty = QgsProperty::fromField( "test_attr" ); + QgsProperty ddsProperty = QgsProperty::fromField( QStringLiteral( "test_attr" ) ); ddsProperty.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 100, 300, 10, 30 ) ); // takes ownership symbol->setDataDefinedSize( ddsProperty ); diff --git a/tests/src/core/testqgsmaplayer.cpp b/tests/src/core/testqgsmaplayer.cpp index 6d829a957b20..d522431803a4 100644 --- a/tests/src/core/testqgsmaplayer.cpp +++ b/tests/src/core/testqgsmaplayer.cpp @@ -254,8 +254,8 @@ void TestQgsMapLayer::layerRef() void TestQgsMapLayer::layerRefListUtils() { // conversion utils - QgsVectorLayer *vlA = new QgsVectorLayer( "Point", "a", "memory" ); - QgsVectorLayer *vlB = new QgsVectorLayer( "Point", "b", "memory" ); + QgsVectorLayer *vlA = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); + QgsVectorLayer *vlB = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "b" ), QStringLiteral( "memory" ) ); QList listRawSource; listRawSource << vlA << vlB; @@ -268,8 +268,8 @@ void TestQgsMapLayer::layerRefListUtils() QCOMPARE( raw, QList< QgsMapLayer *>() << vlA << vlB ); //remove layers - QgsVectorLayer *vlC = new QgsVectorLayer( "Point", "c", "memory" ); - QgsVectorLayer *vlD = new QgsVectorLayer( "Point", "d", "memory" ); + QgsVectorLayer *vlC = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "c" ), QStringLiteral( "memory" ) ); + QgsVectorLayer *vlD = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "d" ), QStringLiteral( "memory" ) ); refs << QgsMapLayerRef( vlC ) << QgsMapLayerRef( vlD ); _qgis_removeLayers( refs, QList< QgsMapLayer *>() << vlB << vlD ); diff --git a/tests/src/core/testqgsmapsettings.cpp b/tests/src/core/testqgsmapsettings.cpp index 481a93abe7d9..e4264757f62d 100644 --- a/tests/src/core/testqgsmapsettings.cpp +++ b/tests/src/core/testqgsmapsettings.cpp @@ -169,8 +169,8 @@ void TestQgsMapSettings::visiblePolygon() void TestQgsMapSettings::testIsLayerVisible() { - QgsVectorLayer *vlA = new QgsVectorLayer( "Point", "a", "memory" ); - QgsVectorLayer *vlB = new QgsVectorLayer( "Point", "b", "memory" ); + QgsVectorLayer *vlA = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); + QgsVectorLayer *vlB = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "b" ), QStringLiteral( "memory" ) ); QList layers; layers << vlA << vlB; @@ -181,17 +181,17 @@ void TestQgsMapSettings::testIsLayerVisible() context << QgsExpressionContextUtils::mapSettingsScope( ms ); // test checking for visible layer by id - QgsExpression e( QString( "is_layer_visible( '%1' )" ).arg( vlA-> id() ) ); + QgsExpression e( QStringLiteral( "is_layer_visible( '%1' )" ).arg( vlA-> id() ) ); QVariant r = e.evaluate( &context ); QCOMPARE( r.toBool(), true ); // test checking for visible layer by name - QgsExpression e2( QString( "is_layer_visible( '%1' )" ).arg( vlB-> name() ) ); + QgsExpression e2( QStringLiteral( "is_layer_visible( '%1' )" ).arg( vlB-> name() ) ); r = e2.evaluate( &context ); QCOMPARE( r.toBool(), true ); // test checking for non-existent layer - QgsExpression e3( QString( "is_layer_visible( 'non matching name' )" ) ); + QgsExpression e3( QStringLiteral( "is_layer_visible( 'non matching name' )" ) ); r = e3.evaluate( &context ); QCOMPARE( r.toBool(), false ); @@ -201,8 +201,8 @@ void TestQgsMapSettings::testIsLayerVisible() void TestQgsMapSettings::testMapLayerListUtils() { - QgsVectorLayer *vlA = new QgsVectorLayer( "Point", "a", "memory" ); - QgsVectorLayer *vlB = new QgsVectorLayer( "Point", "b", "memory" ); + QgsVectorLayer *vlA = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); + QgsVectorLayer *vlB = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "b" ), QStringLiteral( "memory" ) ); QList listRawSource; listRawSource << vlA << vlB; @@ -256,9 +256,9 @@ void TestQgsMapSettings::testXmlReadWrite() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); - QDomElement element = doc.createElement( "s" ); + QDomElement element = doc.createElement( QStringLiteral( "s" ) ); //create a map settings object QgsMapSettings s1; @@ -274,7 +274,7 @@ void TestQgsMapSettings::testXmlReadWrite() QCOMPARE( s2.destinationCrs().authid(), QStringLiteral( "EPSG:3111" ) ); // test writing a map settings without a valid CRS - element = doc.createElement( "s" ); + element = doc.createElement( QStringLiteral( "s" ) ); s1.setDestinationCrs( QgsCoordinateReferenceSystem() ); s1.writeXml( element, doc ); s2.readXml( element ); diff --git a/tests/src/core/testqgspagesizeregistry.cpp b/tests/src/core/testqgspagesizeregistry.cpp index 046d57d5f179..a3742f68696a 100644 --- a/tests/src/core/testqgspagesizeregistry.cpp +++ b/tests/src/core/testqgspagesizeregistry.cpp @@ -65,12 +65,12 @@ void TestQgsPageSizeRegistry::cleanup() void TestQgsPageSizeRegistry::pageSizeEquality() { - QgsPageSize size1( QString( "test" ), QgsLayoutSize( 1, 2 ) ); - QgsPageSize size2( QString( "test" ), QgsLayoutSize( 1, 2 ) ); + QgsPageSize size1( QStringLiteral( "test" ), QgsLayoutSize( 1, 2 ) ); + QgsPageSize size2( QStringLiteral( "test" ), QgsLayoutSize( 1, 2 ) ); QCOMPARE( size1, size2 ); QVERIFY( !( size1 != size2 ) ); - QgsPageSize size3( QString( "no match" ), QgsLayoutSize( 1, 2 ) ); - QgsPageSize size4( QString( "test" ), QgsLayoutSize( 3, 4 ) ); + QgsPageSize size3( QStringLiteral( "no match" ), QgsLayoutSize( 1, 2 ) ); + QgsPageSize size4( QStringLiteral( "test" ), QgsLayoutSize( 3, 4 ) ); QVERIFY( !( size1 == size3 ) ); QVERIFY( size1 != size3 ); QVERIFY( !( size1 == size4 ) ); @@ -81,7 +81,7 @@ void TestQgsPageSizeRegistry::pageSizeEquality() void TestQgsPageSizeRegistry::pageCopyConstructor() { - QgsPageSize size1( QString( "test" ), QgsLayoutSize( 1, 2 ) ); + QgsPageSize size1( QStringLiteral( "test" ), QgsLayoutSize( 1, 2 ) ); QgsPageSize size2( size1 ); QCOMPARE( size1.name, size2.name ); QCOMPARE( size1.size, size2.size ); @@ -103,7 +103,7 @@ void TestQgsPageSizeRegistry::addSize() { QgsPageSizeRegistry *registry = QgsApplication::pageSizeRegistry(); int oldSize = registry->entries().length(); - QgsPageSize newSize( QString( "new" ), QgsLayoutSize( 1, 2 ) ); + QgsPageSize newSize( QStringLiteral( "new" ), QgsLayoutSize( 1, 2 ) ); registry->add( newSize ); QCOMPARE( registry->entries().length(), oldSize + 1 ); QVERIFY( registry->entries().indexOf( newSize ) >= 0 ); @@ -112,13 +112,13 @@ void TestQgsPageSizeRegistry::addSize() void TestQgsPageSizeRegistry::findSize() { QgsPageSizeRegistry *registry = QgsApplication::pageSizeRegistry(); - QgsPageSize newSize( QString( "test size" ), QgsLayoutSize( 1, 2 ) ); + QgsPageSize newSize( QStringLiteral( "test size" ), QgsLayoutSize( 1, 2 ) ); registry->add( newSize ); - QList< QgsPageSize > results = registry->find( QString( "test size" ) ); + QList< QgsPageSize > results = registry->find( QStringLiteral( "test size" ) ); QVERIFY( results.length() > 0 ); QCOMPARE( results.at( 0 ), newSize ); //check that match is case insensitive - QList< QgsPageSize > results2 = registry->find( QString( "tEsT Size" ) ); + QList< QgsPageSize > results2 = registry->find( QStringLiteral( "tEsT Size" ) ); QVERIFY( results2.length() > 0 ); QCOMPARE( results2.at( 0 ), newSize ); } @@ -146,7 +146,7 @@ void TestQgsPageSizeRegistry::decodePageSize() QCOMPARE( result.size, QgsLayoutSize( 297.0, 420.0 ) ); //test with bad string - QgsPageSize result2( QString( "nomatch" ), QgsLayoutSize( 10.0, 20.0 ) ); + QgsPageSize result2( QStringLiteral( "nomatch" ), QgsLayoutSize( 10.0, 20.0 ) ); QgsPageSize expected( result2 ); //for a bad match, expect page size to be unchanged QVERIFY( !registry->decodePageSize( QString( "bad" ), result2 ) ); QCOMPARE( result2, expected ); diff --git a/tests/src/core/testqgspointlocator.cpp b/tests/src/core/testqgspointlocator.cpp index 0fb8b25de430..8afb43ffa77f 100644 --- a/tests/src/core/testqgspointlocator.cpp +++ b/tests/src/core/testqgspointlocator.cpp @@ -265,7 +265,7 @@ class TestQgsPointLocator : public QObject void testNullGeometries() { - QgsVectorLayer *vlNullGeom = new QgsVectorLayer( "Polygon", "x", "memory" ); + QgsVectorLayer *vlNullGeom = new QgsVectorLayer( QStringLiteral( "Polygon" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsFeature ff( 0 ); ff.setGeometry( QgsGeometry() ); QgsFeatureList flist; @@ -285,7 +285,7 @@ class TestQgsPointLocator : public QObject void testEmptyGeometries() { - QgsVectorLayer *vlEmptyGeom = new QgsVectorLayer( "Polygon", "x", "memory" ); + QgsVectorLayer *vlEmptyGeom = new QgsVectorLayer( QStringLiteral( "Polygon" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsFeature ff( 0 ); QgsGeometry g; g.setGeometry( new QgsPolygonV2() ); diff --git a/tests/src/core/testqgspointpatternfillsymbol.cpp b/tests/src/core/testqgspointpatternfillsymbol.cpp index 1ece39670044..85095d0ffd32 100644 --- a/tests/src/core/testqgspointpatternfillsymbol.cpp +++ b/tests/src/core/testqgspointpatternfillsymbol.cpp @@ -155,7 +155,7 @@ void TestQgsPointPatternFillSymbol::dataDefinedSubSymbol() properties.insert( QStringLiteral( "name" ), QStringLiteral( "circle" ) ); properties.insert( QStringLiteral( "size" ), QStringLiteral( "5.0" ) ); QgsMarkerSymbol *pointSymbol = QgsMarkerSymbol::createSimple( properties ); - pointSymbol->symbolLayer( 0 )->setDataDefinedProperty( QgsSymbolLayer::PropertyFillColor, QgsProperty::fromExpression( "if(\"Name\" ='Lake','#ff0000','#ff00ff')" ) ); + pointSymbol->symbolLayer( 0 )->setDataDefinedProperty( QgsSymbolLayer::PropertyFillColor, QgsProperty::fromExpression( QStringLiteral( "if(\"Name\" ='Lake','#ff0000','#ff00ff')" ) ) ); mPointPatternFill->setSubSymbol( pointSymbol ); QVERIFY( imageCheck( "datadefined_subsymbol" ) ); } diff --git a/tests/src/core/testqgsproject.cpp b/tests/src/core/testqgsproject.cpp index a4a0a585a640..be2d0d4f07a6 100644 --- a/tests/src/core/testqgsproject.cpp +++ b/tests/src/core/testqgsproject.cpp @@ -99,7 +99,7 @@ void TestQgsProject::testReadPath() void TestQgsProject::testPathResolver() { - QgsPathResolver resolverRel( "/home/qgis/test.qgs" ); + QgsPathResolver resolverRel( QStringLiteral( "/home/qgis/test.qgs" ) ); QCOMPARE( resolverRel.writePath( "/home/qgis/file1.txt" ), QString( "./file1.txt" ) ); QCOMPARE( resolverRel.writePath( "/home/qgis/subdir/file1.txt" ), QString( "./subdir/file1.txt" ) ); QCOMPARE( resolverRel.writePath( "/home/file1.txt" ), QString( "../file1.txt" ) ); @@ -154,22 +154,22 @@ static QHash _parseSvgPathsForLayers( const QString &projectFi projectFile.close(); QDomElement docElem = doc.documentElement(); - QDomElement layersElem = docElem.firstChildElement( "projectlayers" ); + QDomElement layersElem = docElem.firstChildElement( QStringLiteral( "projectlayers" ) ); QDomElement layerElem = layersElem.firstChildElement(); while ( !layerElem.isNull() ) { - QString layerName = layerElem.firstChildElement( "layername" ).text(); + QString layerName = layerElem.firstChildElement( QStringLiteral( "layername" ) ).text(); QString svgPath; - QDomElement symbolElem = layerElem.firstChildElement( "renderer-v2" ).firstChildElement( "symbols" ).firstChildElement( "symbol" ).firstChildElement( "layer" ); - QDomElement propElem = symbolElem.firstChildElement( "prop" ); + QDomElement symbolElem = layerElem.firstChildElement( QStringLiteral( "renderer-v2" ) ).firstChildElement( QStringLiteral( "symbols" ) ).firstChildElement( QStringLiteral( "symbol" ) ).firstChildElement( QStringLiteral( "layer" ) ); + QDomElement propElem = symbolElem.firstChildElement( QStringLiteral( "prop" ) ); while ( !propElem.isNull() ) { - if ( propElem.attribute( "k" ) == "name" ) + if ( propElem.attribute( QStringLiteral( "k" ) ) == QLatin1String( "name" ) ) { - svgPath = propElem.attribute( "v" ); + svgPath = propElem.attribute( QStringLiteral( "v" ) ); break; } - propElem = propElem.nextSiblingElement( "prop" ); + propElem = propElem.nextSiblingElement( QStringLiteral( "prop" ) ); } projectFileSvgPaths[layerName] = svgPath; layerElem = layerElem.nextSiblingElement(); @@ -203,15 +203,15 @@ void TestQgsProject::testPathResolverSvg() QVERIFY( QFileInfo::exists( ourSvgPath ) ); // should exist now - QString librarySvgPath = QgsSymbolLayerUtils::svgSymbolNameToPath( "transport/transport_airport.svg", QgsPathResolver() ); + QString librarySvgPath = QgsSymbolLayerUtils::svgSymbolNameToPath( QStringLiteral( "transport/transport_airport.svg" ), QgsPathResolver() ); - QgsVectorLayer *layer1 = new QgsVectorLayer( layerPath, "points 1", "ogr" ); + QgsVectorLayer *layer1 = new QgsVectorLayer( layerPath, QStringLiteral( "points 1" ), QStringLiteral( "ogr" ) ); _useRendererWithSvgSymbol( layer1, ourSvgPath ); - QgsVectorLayer *layer2 = new QgsVectorLayer( layerPath, "points 2", "ogr" ); + QgsVectorLayer *layer2 = new QgsVectorLayer( layerPath, QStringLiteral( "points 2" ), QStringLiteral( "ogr" ) ); _useRendererWithSvgSymbol( layer2, invalidSvgPath ); - QgsVectorLayer *layer3 = new QgsVectorLayer( layerPath, "points 3", "ogr" ); + QgsVectorLayer *layer3 = new QgsVectorLayer( layerPath, QStringLiteral( "points 3" ), QStringLiteral( "ogr" ) ); _useRendererWithSvgSymbol( layer3, librarySvgPath ); QVERIFY( layer1->isValid() ); @@ -237,9 +237,9 @@ void TestQgsProject::testPathResolverSvg() // load project again, check that the paths are absolute QgsProject projectLoaded; projectLoaded.read( projectFilename ); - QString svg1 = _getLayerSvgMarkerPath( projectLoaded, "points 1" ); - QString svg2 = _getLayerSvgMarkerPath( projectLoaded, "points 2" ); - QString svg3 = _getLayerSvgMarkerPath( projectLoaded, "points 3" ); + QString svg1 = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 1" ) ); + QString svg2 = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 2" ) ); + QString svg3 = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 3" ) ); QCOMPARE( svg1, ourSvgPath ); QCOMPARE( svg2, invalidSvgPath ); QCOMPARE( svg3, librarySvgPath ); @@ -254,9 +254,9 @@ void TestQgsProject::testPathResolverSvg() QVERIFY( projectMaster.createEmbeddedLayer( layer2->id(), projectFilename, brokenNodes ) ); QVERIFY( projectMaster.createEmbeddedLayer( layer3->id(), projectFilename, brokenNodes ) ); - QString svg1x = _getLayerSvgMarkerPath( projectMaster, "points 1" ); - QString svg2x = _getLayerSvgMarkerPath( projectLoaded, "points 2" ); - QString svg3x = _getLayerSvgMarkerPath( projectLoaded, "points 3" ); + QString svg1x = _getLayerSvgMarkerPath( projectMaster, QStringLiteral( "points 1" ) ); + QString svg2x = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 2" ) ); + QString svg3x = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 3" ) ); QCOMPARE( svg1x, ourSvgPath ); QCOMPARE( svg2x, invalidSvgPath ); QCOMPARE( svg3x, librarySvgPath ); diff --git a/tests/src/core/testqgsproperty.cpp b/tests/src/core/testqgsproperty.cpp index c6e9fe8733aa..d9ca4cae125c 100644 --- a/tests/src/core/testqgsproperty.cpp +++ b/tests/src/core/testqgsproperty.cpp @@ -104,10 +104,10 @@ void TestQgsProperty::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - mDefinitions.insert( Property1, QgsPropertyDefinition( "p1", QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); - mDefinitions.insert( Property2, QgsPropertyDefinition( "p2", QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); - mDefinitions.insert( Property3, QgsPropertyDefinition( "p3", QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); - mDefinitions.insert( Property4, QgsPropertyDefinition( "p4", QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); + mDefinitions.insert( Property1, QgsPropertyDefinition( QStringLiteral( "p1" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); + mDefinitions.insert( Property2, QgsPropertyDefinition( QStringLiteral( "p2" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); + mDefinitions.insert( Property3, QgsPropertyDefinition( QStringLiteral( "p3" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); + mDefinitions.insert( Property4, QgsPropertyDefinition( QStringLiteral( "p4" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); } void TestQgsProperty::cleanupTestCase() @@ -289,7 +289,7 @@ void TestQgsProperty::staticProperty() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QgsProperty p1; @@ -357,8 +357,8 @@ void TestQgsProperty::fieldBasedProperty() //make a feature QgsFeature ft; QgsFields fields; - fields.append( QgsField( "field1", QVariant::Int ) ); - fields.append( QgsField( "field2", QVariant::Int ) ); + fields.append( QgsField( QStringLiteral( "field1" ), QVariant::Int ) ); + fields.append( QgsField( QStringLiteral( "field2" ), QVariant::Int ) ); ft.setFields( fields ); QgsAttributes attr; attr << QVariant( 5 ) << QVariant( 7 ); @@ -379,12 +379,12 @@ void TestQgsProperty::fieldBasedProperty() QVERIFY( !property.isActive() ); QCOMPARE( property.value( context, -1 ).toInt(), -1 ); QVERIFY( property.referencedFields( context ).isEmpty() ); - property.setField( "field2" ); + property.setField( QStringLiteral( "field2" ) ); property.setActive( true ); QCOMPARE( property.value( context, -1 ).toInt(), 7 ); QCOMPARE( property.referencedFields( context ), QSet< QString >() << "field2" ); //bad field reference - property.setField( "bad_field" ); + property.setField( QStringLiteral( "bad_field" ) ); QCOMPARE( property.value( context, -1 ).toInt(), -1 ); // unset field name QgsProperty defaultProperty = QgsProperty::fromField( QString() ); @@ -405,12 +405,12 @@ void TestQgsProperty::fieldBasedProperty() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QgsProperty p1; p1.setActive( true ); - p1.setField( "test_field" ); + p1.setField( QStringLiteral( "test_field" ) ); QVariant element; QgsProperty r1; @@ -433,7 +433,7 @@ void TestQgsProperty::fieldBasedProperty() // test copying a field based property QgsProperty p2; p2.setActive( true ); - p2.setField( "test" ); + p2.setField( QStringLiteral( "test" ) ); p2.setTransformer( new TestTransformer( 10, 20 ) ); // copy constructor @@ -456,8 +456,8 @@ void TestQgsProperty::expressionBasedProperty() //make a feature QgsFeature ft; QgsFields fields; - fields.append( QgsField( "field1", QVariant::Int ) ); - fields.append( QgsField( "field2", QVariant::Int ) ); + fields.append( QgsField( QStringLiteral( "field1" ), QVariant::Int ) ); + fields.append( QgsField( QStringLiteral( "field2" ), QVariant::Int ) ); ft.setFields( fields ); QgsAttributes attr; attr << QVariant( 5 ) << QVariant( 7 ); @@ -476,19 +476,19 @@ void TestQgsProperty::expressionBasedProperty() QCOMPARE( property.referencedFields( context ).count(), 2 ); QVERIFY( property.referencedFields( context ).contains( "field1" ) ); QVERIFY( property.referencedFields( context ).contains( "field2" ) ); - property.setExpressionString( "\"field2\"*2" ); + property.setExpressionString( QStringLiteral( "\"field2\"*2" ) ); QCOMPARE( property.value( context, -1 ).toInt(), 14 ); QCOMPARE( property.referencedFields( context ), QSet< QString >() << "field2" ); property.setActive( false ); QVERIFY( !property.isActive() ); QCOMPARE( property.value( context, -1 ).toInt(), -1 ); QVERIFY( property.referencedFields( context ).isEmpty() ); - property.setExpressionString( "'a'||'b'" ); + property.setExpressionString( QStringLiteral( "'a'||'b'" ) ); property.setActive( true ); QVERIFY( property.referencedFields( context ).isEmpty() ); QCOMPARE( property.value( context, "bb" ).toString(), QStringLiteral( "ab" ) ); //bad expression - property.setExpressionString( "bad_ 5" ); + property.setExpressionString( QStringLiteral( "bad_ 5" ) ); QCOMPARE( property.value( context, -1 ).toInt(), -1 ); QVERIFY( property.referencedFields( context ).isEmpty() ); // unset expression @@ -512,12 +512,12 @@ void TestQgsProperty::expressionBasedProperty() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QgsProperty p1; p1.setActive( true ); - p1.setExpressionString( "4+5" ); + p1.setExpressionString( QStringLiteral( "4+5" ) ); QVariant element; QgsProperty r1; @@ -543,7 +543,7 @@ void TestQgsProperty::expressionBasedProperty() // test copying an expression based property QgsProperty p2; p2.setActive( true ); - p2.setExpressionString( "1+6" ); + p2.setExpressionString( QStringLiteral( "1+6" ) ); // copy constructor QgsProperty p3( p2 ); @@ -622,7 +622,7 @@ void TestQgsProperty::propertyTransformer() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); TestTransformer t1( -5, 6 ); @@ -743,7 +743,7 @@ void TestQgsProperty::genericNumericTransformer() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QgsGenericNumericTransformer t2( 15, @@ -936,7 +936,7 @@ void TestQgsProperty::sizeScaleTransformer() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QgsSizeScaleTransformer t1( QgsSizeScaleTransformer::Exponential, @@ -1166,14 +1166,14 @@ void TestQgsProperty::colorRampTransformer() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QgsColorRampTransformer t1( 15, 25, new QgsGradientColorRamp( QColor( 10, 20, 30 ), QColor( 200, 190, 180 ) ), QColor( 100, 150, 200 ) ); - t1.setRampName( "rampname " ); + t1.setRampName( QStringLiteral( "rampname " ) ); t1.setCurveTransform( new QgsCurveTransform( QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ) ); QVariant element; @@ -1236,7 +1236,7 @@ void TestQgsProperty::colorRampTransformer() QCOMPARE( t.nullColor(), QColor( 1, 10, 11, 21 ) ); t.setColorRamp( new QgsGradientColorRamp( QColor( 10, 20, 100 ), QColor( 100, 200, 200 ) ) ); QCOMPARE( static_cast< QgsGradientColorRamp * >( t.colorRamp() )->color1(), QColor( 10, 20, 100 ) ); - t.setRampName( "colorramp" ); + t.setRampName( QStringLiteral( "colorramp" ) ); QCOMPARE( t.rampName(), QStringLiteral( "colorramp" ) ); //test colors @@ -1252,7 +1252,7 @@ void TestQgsProperty::colorRampTransformer() new QgsGradientColorRamp( QColor( 10, 20, 30 ), QColor( 200, 190, 180 ) ), QColor( 100, 150, 200 ) ); QCOMPARE( t5.toExpression( "5+6" ), QStringLiteral( "coalesce(ramp_color('custom ramp',scale_linear(5+6, 15, 25, 0, 1), '#6496c8')" ) ); - t5.setRampName( "my ramp" ); + t5.setRampName( QStringLiteral( "my ramp" ) ); QCOMPARE( t5.toExpression( "5+6" ), QStringLiteral( "coalesce(ramp_color('my ramp',scale_linear(5+6, 15, 25, 0, 1), '#6496c8')" ) ); } @@ -1261,7 +1261,7 @@ void TestQgsProperty::propertyToTransformer() // not convertible to a transformer: // fields cannot be converted - QgsProperty p = QgsProperty::fromField( "a field" ); + QgsProperty p = QgsProperty::fromField( QStringLiteral( "a field" ) ); QVERIFY( !p.convertToTransformer() ); QVERIFY( !p.transformer() ); QCOMPARE( p.field(), QStringLiteral( "a field" ) ); @@ -1273,7 +1273,7 @@ void TestQgsProperty::propertyToTransformer() QCOMPARE( p.staticValue(), QVariant( 5 ) ); // bad expression which cannot be converted - p = QgsProperty::fromExpression( "5*5" ); + p = QgsProperty::fromExpression( QStringLiteral( "5*5" ) ); QVERIFY( !p.convertToTransformer() ); QVERIFY( !p.transformer() ); QCOMPARE( p.expressionString(), QStringLiteral( "5*5" ) ); @@ -1300,11 +1300,11 @@ void TestQgsProperty::asExpression() QCOMPARE( p.asExpression(), QStringLiteral( "'value'" ) ); // field based property - p = QgsProperty::fromField( "a field" ); + p = QgsProperty::fromField( QStringLiteral( "a field" ) ); QCOMPARE( p.asExpression(), QStringLiteral( "\"a field\"" ) ); // expression based property - p = QgsProperty::fromExpression( "5 + 6" ); + p = QgsProperty::fromExpression( QStringLiteral( "5 + 6" ) ); QCOMPARE( p.asExpression(), QStringLiteral( "5 + 6" ) ); // with transformer @@ -1323,8 +1323,8 @@ void TestQgsProperty::propertyCollection() //make a feature QgsFeature ft; QgsFields fields; - fields.append( QgsField( "field1", QVariant::Int ) ); - fields.append( QgsField( "field2", QVariant::Int ) ); + fields.append( QgsField( QStringLiteral( "field1" ), QVariant::Int ) ); + fields.append( QgsField( QStringLiteral( "field2" ), QVariant::Int ) ); ft.setFields( fields ); QgsAttributes attr; attr << QVariant( 5 ) << QVariant( 7 ); @@ -1336,7 +1336,7 @@ void TestQgsProperty::propertyCollection() context.setFeature( ft ); context.setFields( fields ); - QgsPropertyCollection collection( "collection" ); + QgsPropertyCollection collection( QStringLiteral( "collection" ) ); QCOMPARE( collection.name(), QStringLiteral( "collection" ) ); QVERIFY( !collection.hasProperty( Property1 ) ); QVERIFY( collection.referencedFields( context ).isEmpty() ); @@ -1398,8 +1398,8 @@ void TestQgsProperty::propertyCollection() collection.setProperty( Property1, QgsProperty::fromValue( "v1", true ) ); collection.setProperty( Property2, QgsProperty::fromValue( "v2", false ) ); - collection.setProperty( Property3, QgsProperty::fromField( "field1", true ) ); - collection.setProperty( Property4, QgsProperty::fromExpression( "\"field1\" + \"field2\"", true ) ); + collection.setProperty( Property3, QgsProperty::fromField( QStringLiteral( "field1" ), true ) ); + collection.setProperty( Property4, QgsProperty::fromExpression( QStringLiteral( "\"field1\" + \"field2\"" ), true ) ); QCOMPARE( collection.count(), 4 ); // test referenced fields @@ -1412,7 +1412,7 @@ void TestQgsProperty::propertyCollection() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); QVariant collectionElement = collection.toVariant( mDefinitions ); @@ -1506,8 +1506,8 @@ void TestQgsProperty::collectionStack() //make a feature QgsFeature ft; QgsFields fields; - fields.append( QgsField( "field1", QVariant::Int ) ); - fields.append( QgsField( "field2", QVariant::Int ) ); + fields.append( QgsField( QStringLiteral( "field1" ), QVariant::Int ) ); + fields.append( QgsField( QStringLiteral( "field2" ), QVariant::Int ) ); ft.setFields( fields ); QgsAttributes attr; attr << QVariant( 5 ) << QVariant( 7 ); @@ -1534,7 +1534,7 @@ void TestQgsProperty::collectionStack() QVERIFY( !stack.hasActiveProperties() ); //add a collection to the stack - QgsPropertyCollection *collection = new QgsPropertyCollection( "collection" ); + QgsPropertyCollection *collection = new QgsPropertyCollection( QStringLiteral( "collection" ) ); stack.appendCollection( collection ); QCOMPARE( stack.count(), 1 ); QCOMPARE( stack.at( 0 ), collection ); @@ -1564,7 +1564,7 @@ void TestQgsProperty::collectionStack() QVERIFY( stack.hasActiveProperties() ); //add a second collection - QgsPropertyCollection *collection2 = new QgsPropertyCollection( "collection2" ); + QgsPropertyCollection *collection2 = new QgsPropertyCollection( QStringLiteral( "collection2" ) ); stack.appendCollection( collection2 ); QCOMPARE( stack.count(), 2 ); QCOMPARE( stack.at( 1 ), collection2 ); @@ -1610,10 +1610,10 @@ void TestQgsProperty::collectionStack() // test copying a stack QgsPropertyCollectionStack stack2; - stack2.appendCollection( new QgsPropertyCollection( "collection1" ) ); + stack2.appendCollection( new QgsPropertyCollection( QStringLiteral( "collection1" ) ) ); stack2.at( 0 )->setProperty( Property1, "val1" ); stack2.at( 0 )->setProperty( Property2, "val2" ); - stack2.appendCollection( new QgsPropertyCollection( "collection2" ) ); + stack2.appendCollection( new QgsPropertyCollection( QStringLiteral( "collection2" ) ) ); stack2.at( 1 )->setProperty( Property3, "val3" ); //copy constructor QgsPropertyCollectionStack stack3( stack2 ); @@ -1627,7 +1627,7 @@ void TestQgsProperty::collectionStack() QVERIFY( stack3.hasActiveProperties() ); //assignment operator stack3.clear(); - stack3.appendCollection( new QgsPropertyCollection( "temp" ) ); + stack3.appendCollection( new QgsPropertyCollection( QStringLiteral( "temp" ) ) ); stack3 = stack2; QCOMPARE( stack3.count(), 2 ); QCOMPARE( stack3.at( 0 )->name(), QStringLiteral( "collection1" ) ); @@ -1640,7 +1640,7 @@ void TestQgsProperty::collectionStack() //check hasDynamicProperties() and hasActiveProperties() QgsPropertyCollectionStack stack4; - stack4.appendCollection( new QgsPropertyCollection( "collection1" ) ); + stack4.appendCollection( new QgsPropertyCollection( QStringLiteral( "collection1" ) ) ); stack4.at( 0 )->setProperty( Property1, "val1" ); QVERIFY( !stack4.hasDynamicProperties() ); QVERIFY( stack4.hasActiveProperties() ); @@ -1648,7 +1648,7 @@ void TestQgsProperty::collectionStack() QVERIFY( !stack4.hasActiveProperties() ); stack4.at( 0 )->setProperty( Property1, "6" ); QVERIFY( stack4.hasActiveProperties() ); - stack4.at( 0 )->setProperty( Property2, QgsProperty::fromExpression( "\"field1\" + \"field2\"", true ) ); + stack4.at( 0 )->setProperty( Property2, QgsProperty::fromExpression( QStringLiteral( "\"field1\" + \"field2\"" ), true ) ); QVERIFY( stack4.hasActiveProperties() ); QVERIFY( stack4.hasDynamicProperties() ); QCOMPARE( stack4.referencedFields( context ), QSet< QString>() << "field1" << "field2" ); @@ -1752,10 +1752,10 @@ void TestQgsProperty::curveTransform() QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( - "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" ); + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); QDomDocument doc( documentType ); - QDomElement element = doc.createElement( "xform" ); + QDomElement element = doc.createElement( QStringLiteral( "xform" ) ); QVERIFY( src.writeXml( element, doc ) ); QgsCurveTransform r1; diff --git a/tests/src/core/testqgsrasterblock.cpp b/tests/src/core/testqgsrasterblock.cpp index 371d2c9106e1..282066e53901 100644 --- a/tests/src/core/testqgsrasterblock.cpp +++ b/tests/src/core/testqgsrasterblock.cpp @@ -61,7 +61,7 @@ void TestQgsRasterBlock::initTestCase() mTestDataDir = QStringLiteral( TEST_DATA_DIR ); //defined in CmakeLists.txt QString band1byteRaster = mTestDataDir + "/raster/band1_byte_ct_epsg4326.tif"; - mpRasterLayer = new QgsRasterLayer( band1byteRaster, "band1_byte" ); + mpRasterLayer = new QgsRasterLayer( band1byteRaster, QStringLiteral( "band1_byte" ) ); QVERIFY( mpRasterLayer && mpRasterLayer->isValid() ); } @@ -149,7 +149,7 @@ void TestQgsRasterBlock::testWrite() // create a GeoTIFF - this will create data provider in editable mode QString filename = tmpFile.fileName(); - QgsRasterDataProvider *dp = QgsRasterDataProvider::create( "gdal", filename, "GTiff", 1, Qgis::Byte, 10, 10, tform, mpRasterLayer->crs() ); + QgsRasterDataProvider *dp = QgsRasterDataProvider::create( QStringLiteral( "gdal" ), filename, QStringLiteral( "GTiff" ), 1, Qgis::Byte, 10, 10, tform, mpRasterLayer->crs() ); QgsRasterBlock *block = mpRasterLayer->dataProvider()->block( 1, mpRasterLayer->extent(), mpRasterLayer->width(), mpRasterLayer->height() ); @@ -172,7 +172,7 @@ void TestQgsRasterBlock::testWrite() delete dp; // newly open raster and verify the write was permanent - QgsRasterLayer *rlayer = new QgsRasterLayer( filename, "tmp", "gdal" ); + QgsRasterLayer *rlayer = new QgsRasterLayer( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); QVERIFY( rlayer->isValid() ); QgsRasterBlock *block3 = rlayer->dataProvider()->block( 1, rlayer->extent(), rlayer->width(), rlayer->height() ); QByteArray newData3 = block3->data(); diff --git a/tests/src/core/testqgsrasterfilewriter.cpp b/tests/src/core/testqgsrasterfilewriter.cpp index 4efa039ba659..4ed5ae0b44bf 100644 --- a/tests/src/core/testqgsrasterfilewriter.cpp +++ b/tests/src/core/testqgsrasterfilewriter.cpp @@ -192,7 +192,7 @@ void TestQgsRasterFileWriter::testCreateOneBandRaster() int width = 200, height = 100; QgsRasterFileWriter writer( filename ); - QgsRasterDataProvider *dp = writer.createOneBandRaster( Qgis::Byte, width, height, extent, QgsCoordinateReferenceSystem( "EPSG:4326" ) ); + QgsRasterDataProvider *dp = writer.createOneBandRaster( Qgis::Byte, width, height, extent, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); QVERIFY( dp ); QCOMPARE( dp->xSize(), width ); QCOMPARE( dp->ySize(), height ); @@ -202,7 +202,7 @@ void TestQgsRasterFileWriter::testCreateOneBandRaster() QVERIFY( dp->isEditable() ); delete dp; - QgsRasterLayer *rlayer = new QgsRasterLayer( filename, "tmp", "gdal" ); + QgsRasterLayer *rlayer = new QgsRasterLayer( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); QVERIFY( rlayer->isValid() ); QCOMPARE( rlayer->width(), width ); QCOMPARE( rlayer->height(), height ); @@ -224,7 +224,7 @@ void TestQgsRasterFileWriter::testCreateMultiBandRaster() int width = 200, height = 100, nBands = 1; QgsRasterFileWriter writer( filename ); - QgsRasterDataProvider *dp = writer.createMultiBandRaster( Qgis::Byte, width, height, extent, QgsCoordinateReferenceSystem( "EPSG:4326" ), nBands ); + QgsRasterDataProvider *dp = writer.createMultiBandRaster( Qgis::Byte, width, height, extent, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), nBands ); QVERIFY( dp ); QCOMPARE( dp->xSize(), width ); QCOMPARE( dp->ySize(), height ); @@ -234,7 +234,7 @@ void TestQgsRasterFileWriter::testCreateMultiBandRaster() QVERIFY( dp->isEditable() ); delete dp; - QgsRasterLayer *rlayer = new QgsRasterLayer( filename, "tmp", "gdal" ); + QgsRasterLayer *rlayer = new QgsRasterLayer( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); QVERIFY( rlayer->isValid() ); QCOMPARE( rlayer->width(), width ); QCOMPARE( rlayer->height(), height ); @@ -244,7 +244,7 @@ void TestQgsRasterFileWriter::testCreateMultiBandRaster() delete rlayer; nBands = 3; - dp = writer.createMultiBandRaster( Qgis::Byte, width, height, extent, QgsCoordinateReferenceSystem( "EPSG:4326" ), nBands ); + dp = writer.createMultiBandRaster( Qgis::Byte, width, height, extent, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), nBands ); QVERIFY( dp ); QCOMPARE( dp->xSize(), width ); QCOMPARE( dp->ySize(), height ); @@ -257,7 +257,7 @@ void TestQgsRasterFileWriter::testCreateMultiBandRaster() QVERIFY( dp->isEditable() ); delete dp; - rlayer = new QgsRasterLayer( filename, "tmp", "gdal" ); + rlayer = new QgsRasterLayer( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); QVERIFY( rlayer->isValid() ); QCOMPARE( rlayer->width(), width ); QCOMPARE( rlayer->height(), height ); diff --git a/tests/src/core/testqgsstyle.cpp b/tests/src/core/testqgsstyle.cpp index 435bca64e8ba..42f32b4d09cc 100644 --- a/tests/src/core/testqgsstyle.cpp +++ b/tests/src/core/testqgsstyle.cpp @@ -258,9 +258,9 @@ void TestStyle::testFavorites() std::unique_ptr< QgsMarkerSymbol > sym1( QgsMarkerSymbol::createSimple( QgsStringMap() ) ); std::unique_ptr< QgsMarkerSymbol > sym2( QgsMarkerSymbol::createSimple( QgsStringMap() ) ); std::unique_ptr< QgsMarkerSymbol > sym3( QgsMarkerSymbol::createSimple( QgsStringMap() ) ); - mStyle->saveSymbol( "symbolA", sym1.get(), true, QStringList() ); - mStyle->saveSymbol( "symbolB", sym2.get(), false, QStringList() ); - mStyle->saveSymbol( "symbolC", sym3.get(), true, QStringList() ); + mStyle->saveSymbol( QStringLiteral( "symbolA" ), sym1.get(), true, QStringList() ); + mStyle->saveSymbol( QStringLiteral( "symbolB" ), sym2.get(), false, QStringList() ); + mStyle->saveSymbol( QStringLiteral( "symbolC" ), sym3.get(), true, QStringList() ); // check for added symbols to favorites favorites = mStyle->symbolsOfFavorite( QgsStyle::SymbolEntity ); @@ -269,7 +269,7 @@ void TestStyle::testFavorites() QVERIFY( favorites.contains( "symbolC" ) ); // remove one symbol from favorites - mStyle->removeFavorite( QgsStyle::SymbolEntity, "symbolA" ); + mStyle->removeFavorite( QgsStyle::SymbolEntity, QStringLiteral( "symbolA" ) ); // insure favorites updated after removal favorites = mStyle->symbolsOfFavorite( QgsStyle::SymbolEntity ); diff --git a/tests/src/core/testqgstaskmanager.cpp b/tests/src/core/testqgstaskmanager.cpp index dc9593515d33..5e384c4a81ea 100644 --- a/tests/src/core/testqgstaskmanager.cpp +++ b/tests/src/core/testqgstaskmanager.cpp @@ -235,7 +235,7 @@ void TestQgsTaskManager::cleanup() void TestQgsTaskManager::task() { - std::unique_ptr< TestTask > task( new TestTask( "desc" ) ); + std::unique_ptr< TestTask > task( new TestTask( QStringLiteral( "desc" ) ) ); QCOMPARE( task->status(), QgsTask::Queued ); QCOMPARE( task->description(), QString( "desc" ) ); QVERIFY( !task->isActive() ); @@ -284,10 +284,10 @@ void TestQgsTaskManager::task() QCOMPARE( task->status(), QgsTask::Terminated ); // test flags - task.reset( new TestTask( "desc", 0 ) ); + task.reset( new TestTask( QStringLiteral( "desc" ), 0 ) ); QVERIFY( !task->canCancel() ); QVERIFY( !( task->flags() & QgsTask::CanCancel ) ); - task.reset( new TestTask( "desc", QgsTask::CanCancel ) ); + task.reset( new TestTask( QStringLiteral( "desc" ), QgsTask::CanCancel ) ); QVERIFY( task->canCancel() ); QVERIFY( task->flags() & QgsTask::CanCancel ); } @@ -1058,11 +1058,11 @@ void TestQgsTaskManager::dependencies() void TestQgsTaskManager::layerDependencies() { //make some layers - QgsVectorLayer *layer1 = new QgsVectorLayer( "Point?field=col1:string&field=col2:string&field=col3:string", "layer1", "memory" ); + QgsVectorLayer *layer1 = new QgsVectorLayer( QStringLiteral( "Point?field=col1:string&field=col2:string&field=col3:string" ), QStringLiteral( "layer1" ), QStringLiteral( "memory" ) ); QVERIFY( layer1->isValid() ); - QgsVectorLayer *layer2 = new QgsVectorLayer( "Point?field=col1:string&field=col2:string&field=col3:string", "layer2", "memory" ); + QgsVectorLayer *layer2 = new QgsVectorLayer( QStringLiteral( "Point?field=col1:string&field=col2:string&field=col3:string" ), QStringLiteral( "layer2" ), QStringLiteral( "memory" ) ); QVERIFY( layer2->isValid() ); - QgsVectorLayer *layer3 = new QgsVectorLayer( "Point?field=col1:string&field=col2:string&field=col3:string", "layer3", "memory" ); + QgsVectorLayer *layer3 = new QgsVectorLayer( QStringLiteral( "Point?field=col1:string&field=col2:string&field=col3:string" ), QStringLiteral( "layer3" ), QStringLiteral( "memory" ) ); QVERIFY( layer3->isValid() ); QgsProject::instance()->addMapLayers( QList< QgsMapLayer * >() << layer1 << layer2 << layer3 ); @@ -1101,9 +1101,9 @@ void TestQgsTaskManager::managerWithSubTasks() QSKIP( "This test is disabled on Travis CI environment" ); // parent with subtasks - ProgressReportingTask *parent = new ProgressReportingTask( "parent" ); - ProgressReportingTask *subTask = new ProgressReportingTask( "subtask" ); - ProgressReportingTask *subsubTask = new ProgressReportingTask( "subsubtask" ); + ProgressReportingTask *parent = new ProgressReportingTask( QStringLiteral( "parent" ) ); + ProgressReportingTask *subTask = new ProgressReportingTask( QStringLiteral( "subtask" ) ); + ProgressReportingTask *subsubTask = new ProgressReportingTask( QStringLiteral( "subsubtask" ) ); subTask->addSubTask( subsubTask ); parent->addSubTask( subTask ); @@ -1217,11 +1217,11 @@ void TestQgsTaskManager::managerWithSubTasks3() { //test 2 QgsTaskManager manager3; - TestTask *parent = new TestTask( "parent" ); + TestTask *parent = new TestTask( QStringLiteral( "parent" ) ); parent->hold(); - TestTask *subTask = new TestTask( "subtask" ); + TestTask *subTask = new TestTask( QStringLiteral( "subtask" ) ); subTask->hold(); - TestTask *subTask2 = new TestTask( "subtask2" ); + TestTask *subTask2 = new TestTask( QStringLiteral( "subtask2" ) ); subTask2->hold(); parent->addSubTask( subTask, QgsTaskList() << subTask2 ); diff --git a/tests/src/core/testqgsvectorlayer.cpp b/tests/src/core/testqgsvectorlayer.cpp index 06d45866f703..549cb913f87d 100644 --- a/tests/src/core/testqgsvectorlayer.cpp +++ b/tests/src/core/testqgsvectorlayer.cpp @@ -342,7 +342,7 @@ void TestQgsVectorLayer::testAddTopologicalPoints() { // create a simple linestring layer - QgsVectorLayer *layerLine = new QgsVectorLayer( "LineString?crs=EPSG:27700", "layer line", "memory" ); + QgsVectorLayer *layerLine = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:27700" ), QStringLiteral( "layer line" ), QStringLiteral( "memory" ) ); QVERIFY( layerLine->isValid() ); QgsPolyline line1; diff --git a/tests/src/gui/testqgsattributeform.cpp b/tests/src/gui/testqgsattributeform.cpp index 4d9e3db5fb78..c7c46fda051d 100644 --- a/tests/src/gui/testqgsattributeform.cpp +++ b/tests/src/gui/testqgsattributeform.cpp @@ -325,17 +325,17 @@ void TestQgsAttributeForm::testDynamicForm() // join configuration QgsVectorLayerJoinInfo infoJoinAB; - infoJoinAB.setTargetFieldName( "id_a" ); + infoJoinAB.setTargetFieldName( QStringLiteral( "id_a" ) ); infoJoinAB.setJoinLayer( layerB ); - infoJoinAB.setJoinFieldName( "id_b" ); + infoJoinAB.setJoinFieldName( QStringLiteral( "id_b" ) ); infoJoinAB.setDynamicFormEnabled( true ); layerA->addJoin( infoJoinAB ); QgsVectorLayerJoinInfo infoJoinAC; - infoJoinAC.setTargetFieldName( "id_a" ); + infoJoinAC.setTargetFieldName( QStringLiteral( "id_a" ) ); infoJoinAC.setJoinLayer( layerC ); - infoJoinAC.setJoinFieldName( "id_c" ); + infoJoinAC.setJoinFieldName( QStringLiteral( "id_c" ) ); infoJoinAC.setDynamicFormEnabled( true ); layerA->addJoin( infoJoinAC ); @@ -393,7 +393,7 @@ void TestQgsAttributeForm::testDynamicForm() QCOMPARE( ww->value(), QVariant( QVariant::Int ) ); // change layerA join id field to join with layerB - form.changeAttribute( "id_a", QVariant( 30 ) ); + form.changeAttribute( QStringLiteral( "id_a" ), QVariant( 30 ) ); ww = qobject_cast( form.mWidgets[0] ); QCOMPARE( ww->field().name(), QString( "id_a" ) ); @@ -408,7 +408,7 @@ void TestQgsAttributeForm::testDynamicForm() QCOMPARE( ww->value(), QVariant( QVariant::Int ) ); // change layerA join id field to join with layerC - form.changeAttribute( "id_a", QVariant( 32 ) ); + form.changeAttribute( QStringLiteral( "id_a" ), QVariant( 32 ) ); ww = qobject_cast( form.mWidgets[0] ); QCOMPARE( ww->field().name(), QString( "id_a" ) ); @@ -423,7 +423,7 @@ void TestQgsAttributeForm::testDynamicForm() QCOMPARE( ww->value(), QVariant( 12 ) ); // change layerA join id field to join with layerA and layerC - form.changeAttribute( "id_a", QVariant( 31 ) ); + form.changeAttribute( QStringLiteral( "id_a" ), QVariant( 31 ) ); ww = qobject_cast( form.mWidgets[0] ); QCOMPARE( ww->field().name(), QString( "id_a" ) ); @@ -461,9 +461,9 @@ void TestQgsAttributeForm::testConstraintsOnJoinedFields() // join configuration QgsVectorLayerJoinInfo infoJoinAB; - infoJoinAB.setTargetFieldName( "id_a" ); + infoJoinAB.setTargetFieldName( QStringLiteral( "id_a" ) ); infoJoinAB.setJoinLayer( layerB ); - infoJoinAB.setJoinFieldName( "id_b" ); + infoJoinAB.setJoinFieldName( QStringLiteral( "id_b" ) ); infoJoinAB.setDynamicFormEnabled( true ); layerA->addJoin( infoJoinAB ); @@ -496,7 +496,7 @@ void TestQgsAttributeForm::testConstraintsOnJoinedFields() form.setFeature( ftA ); // change layerA join id field - form.changeAttribute( "id_a", QVariant( 30 ) ); + form.changeAttribute( QStringLiteral( "id_a" ), QVariant( 30 ) ); // compare QgsEditorWidgetWrapper *ww = nullptr; @@ -505,7 +505,7 @@ void TestQgsAttributeForm::testConstraintsOnJoinedFields() QCOMPARE( label->text(), "layerB_" + validLabel ); // change layerA join id field - form.changeAttribute( "id_a", QVariant( 31 ) ); + form.changeAttribute( QStringLiteral( "id_a" ), QVariant( 31 ) ); // compare ww = qobject_cast( form.mWidgets[1] ); @@ -527,18 +527,18 @@ void TestQgsAttributeForm::testEditableJoin() // join configuration QgsVectorLayerJoinInfo infoJoinAB; - infoJoinAB.setTargetFieldName( "id_a" ); + infoJoinAB.setTargetFieldName( QStringLiteral( "id_a" ) ); infoJoinAB.setJoinLayer( layerB ); - infoJoinAB.setJoinFieldName( "id_b" ); + infoJoinAB.setJoinFieldName( QStringLiteral( "id_b" ) ); infoJoinAB.setDynamicFormEnabled( true ); infoJoinAB.setEditable( true ); layerA->addJoin( infoJoinAB ); QgsVectorLayerJoinInfo infoJoinAC; - infoJoinAC.setTargetFieldName( "id_a" ); + infoJoinAC.setTargetFieldName( QStringLiteral( "id_a" ) ); infoJoinAC.setJoinLayer( layerC ); - infoJoinAC.setJoinFieldName( "id_c" ); + infoJoinAC.setJoinFieldName( QStringLiteral( "id_c" ) ); infoJoinAC.setDynamicFormEnabled( true ); infoJoinAC.setEditable( false ); @@ -606,8 +606,8 @@ void TestQgsAttributeForm::testEditableJoin() QCOMPARE( ww->widget()->isEnabled(), false ); // change attributes - form.changeAttribute( "layerB_col0", QVariant( 333 ) ); - form.changeAttribute( "layerC_col0", QVariant( 444 ) ); + form.changeAttribute( QStringLiteral( "layerB_col0" ), QVariant( 333 ) ); + form.changeAttribute( QStringLiteral( "layerC_col0" ), QVariant( 444 ) ); form.save(); // commit changes @@ -642,9 +642,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() // join configuration QgsVectorLayerJoinInfo infoJoinAB; - infoJoinAB.setTargetFieldName( "id_a" ); + infoJoinAB.setTargetFieldName( QStringLiteral( "id_a" ) ); infoJoinAB.setJoinLayer( layerB ); - infoJoinAB.setJoinFieldName( "id_b" ); + infoJoinAB.setJoinFieldName( QStringLiteral( "id_b" ) ); infoJoinAB.setDynamicFormEnabled( true ); infoJoinAB.setEditable( true ); infoJoinAB.setUpsertOnEdit( true ); @@ -652,9 +652,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() layerA->addJoin( infoJoinAB ); QgsVectorLayerJoinInfo infoJoinAC; - infoJoinAC.setTargetFieldName( "id_a" ); + infoJoinAC.setTargetFieldName( QStringLiteral( "id_a" ) ); infoJoinAC.setJoinLayer( layerC ); - infoJoinAC.setJoinFieldName( "id_c" ); + infoJoinAC.setJoinFieldName( QStringLiteral( "id_c" ) ); infoJoinAC.setDynamicFormEnabled( true ); infoJoinAC.setEditable( true ); infoJoinAC.setUpsertOnEdit( false ); @@ -685,7 +685,7 @@ void TestQgsAttributeForm::testUpsertOnEdit() // get committed feature from layerA QgsFeature feature; - QString filter = QgsExpression::createFieldEqualityExpression( "id_a", 31 ); + QString filter = QgsExpression::createFieldEqualityExpression( QStringLiteral( "id_a" ), 31 ); QgsFeatureRequest request; request.setFilterExpression( filter ); @@ -709,9 +709,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() // add a new feature with null joined fields. Joined feature should not be // added - form.changeAttribute( "id_a", QVariant( 32 ) ); - form.changeAttribute( "layerB_col0", QVariant() ); - form.changeAttribute( "layerC_col0", QVariant() ); + form.changeAttribute( QStringLiteral( "id_a" ), QVariant( 32 ) ); + form.changeAttribute( QStringLiteral( "layerB_col0" ), QVariant() ); + form.changeAttribute( QStringLiteral( "layerC_col0" ), QVariant() ); form.save(); // commit @@ -735,9 +735,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() form1.setMode( QgsAttributeForm::AddFeatureMode ); form1.setFeature( ft0A ); - form1.changeAttribute( "id_a", QVariant( 34 ) ); - form1.changeAttribute( "layerB_col0", QVariant( 3434 ) ); - form1.changeAttribute( "layerC_col0", QVariant( 343434 ) ); + form1.changeAttribute( QStringLiteral( "id_a" ), QVariant( 34 ) ); + form1.changeAttribute( QStringLiteral( "layerB_col0" ), QVariant( 3434 ) ); + form1.changeAttribute( QStringLiteral( "layerC_col0" ), QVariant( 343434 ) ); form1.save(); // commit @@ -751,7 +751,7 @@ void TestQgsAttributeForm::testUpsertOnEdit() QCOMPARE( ( int )layerC->featureCount(), 1 ); // check joined feature value - filter = QgsExpression::createFieldEqualityExpression( "id_a", 34 ); + filter = QgsExpression::createFieldEqualityExpression( QStringLiteral( "id_a" ), 34 ); request.setFilterExpression( filter ); request.setLimit( 1 ); @@ -769,9 +769,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() QgsAttributeForm form2( layerA ); form2.setMode( QgsAttributeForm::AddFeatureMode ); form2.setFeature( ft0A ); - form2.changeAttribute( "id_a", QVariant( 33 ) ); - form2.changeAttribute( "layerB_col0", QVariant( 3333 ) ); - form2.changeAttribute( "layerC_col0", QVariant( 323232 ) ); + form2.changeAttribute( QStringLiteral( "id_a" ), QVariant( 33 ) ); + form2.changeAttribute( QStringLiteral( "layerB_col0" ), QVariant( 3333 ) ); + form2.changeAttribute( QStringLiteral( "layerC_col0" ), QVariant( 323232 ) ); form2.save(); // commit @@ -785,7 +785,7 @@ void TestQgsAttributeForm::testUpsertOnEdit() QCOMPARE( ( int )layerC->featureCount(), 1 ); // check joined feature value - filter = QgsExpression::createFieldEqualityExpression( "id_a", 33 ); + filter = QgsExpression::createFieldEqualityExpression( QStringLiteral( "id_a" ), 33 ); request.setFilterExpression( filter ); request.setLimit( 1 ); @@ -803,9 +803,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() QgsAttributeForm form3( layerA ); form3.setMode( QgsAttributeForm::SingleEditMode ); form3.setFeature( ft0A ); - form3.changeAttribute( "id_a", QVariant( 31 ) ); - form3.changeAttribute( "layerB_col0", QVariant() ); - form3.changeAttribute( "layerC_col0", QVariant() ); + form3.changeAttribute( QStringLiteral( "id_a" ), QVariant( 31 ) ); + form3.changeAttribute( QStringLiteral( "layerB_col0" ), QVariant() ); + form3.changeAttribute( QStringLiteral( "layerC_col0" ), QVariant() ); form3.save(); // commit @@ -828,9 +828,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() QgsAttributeForm form4( layerA ); form4.setMode( QgsAttributeForm::SingleEditMode ); form4.setFeature( ft0A ); - form4.changeAttribute( "id_a", QVariant( 31 ) ); - form4.changeAttribute( "layerB_col0", QVariant( 1111 ) ); - form4.changeAttribute( "layerC_col0", QVariant( 3131 ) ); + form4.changeAttribute( QStringLiteral( "id_a" ), QVariant( 31 ) ); + form4.changeAttribute( QStringLiteral( "layerB_col0" ), QVariant( 1111 ) ); + form4.changeAttribute( QStringLiteral( "layerC_col0" ), QVariant( 3131 ) ); form4.save(); // commit @@ -844,7 +844,7 @@ void TestQgsAttributeForm::testUpsertOnEdit() QCOMPARE( ( int )layerC->featureCount(), 1 ); // check joined feature value - filter = QgsExpression::createFieldEqualityExpression( "id_a", 31 ); + filter = QgsExpression::createFieldEqualityExpression( QStringLiteral( "id_a" ), 31 ); request.setFilterExpression( filter ); request.setLimit( 1 ); diff --git a/tests/src/gui/testqgsdualview.cpp b/tests/src/gui/testqgsdualview.cpp index 558a0c75c63f..0d6d54bcc12f 100644 --- a/tests/src/gui/testqgsdualview.cpp +++ b/tests/src/gui/testqgsdualview.cpp @@ -140,7 +140,7 @@ void TestQgsDualView::testFilterSelected() { QgsFeature feature; QList< QgsFeatureId > ids; - QgsFeatureIterator it = mPointsLayer->getFeatures( QgsFeatureRequest().setOrderBy( QgsFeatureRequest::OrderBy() << QgsFeatureRequest::OrderByClause( "Heading" ) ) ); + QgsFeatureIterator it = mPointsLayer->getFeatures( QgsFeatureRequest().setOrderBy( QgsFeatureRequest::OrderBy() << QgsFeatureRequest::OrderByClause( QStringLiteral( "Heading" ) ) ) ); while ( it.nextFeature( feature ) ) ids << feature.id(); @@ -152,7 +152,7 @@ void TestQgsDualView::testFilterSelected() mDualView->setFilterMode( QgsAttributeTableFilterModel::ShowSelected ); QCOMPARE( mDualView->tableView()->model()->rowCount(), 2 ); - int headingIdx = mPointsLayer->fields().lookupField( "Heading" ); + int headingIdx = mPointsLayer->fields().lookupField( QStringLiteral( "Heading" ) ); QgsField fld = mPointsLayer->fields().at( headingIdx ); for ( int i = 0; i < selected.count(); ++i ) { diff --git a/tests/src/gui/testqgseditorwidgetregistry.cpp b/tests/src/gui/testqgseditorwidgetregistry.cpp index 0606213e2c32..1a5c2490b2da 100644 --- a/tests/src/gui/testqgseditorwidgetregistry.cpp +++ b/tests/src/gui/testqgseditorwidgetregistry.cpp @@ -125,7 +125,7 @@ class TestQgsEditorWidgetRegistry: public QObject relation.setName( QStringLiteral( "vl1->vl2" ) ); relation.setReferencingLayer( vl1.id() ); relation.setReferencedLayer( vl2.id() ); - relation.addFieldPair( "fk", "pk" ); + relation.addFieldPair( QStringLiteral( "fk" ), QStringLiteral( "pk" ) ); QVERIFY( relation.isValid() ); QgsProject::instance()->relationManager()->addRelation( relation ); diff --git a/tests/src/gui/testqgsfiledownloader.cpp b/tests/src/gui/testqgsfiledownloader.cpp index 14af041da5f1..aada4aaefdde 100644 --- a/tests/src/gui/testqgsfiledownloader.cpp +++ b/tests/src/gui/testqgsfiledownloader.cpp @@ -60,7 +60,7 @@ class TestQgsFileDownloader: public QObject { mError = true; errorMessages.sort(); - mErrorMessage = errorMessages.join( ";" ); + mErrorMessage = errorMessages.join( QStringLiteral( ";" ) ); } //! Called when data ready to be processed void downloadProgress( qint64 bytesReceived, qint64 bytesTotal ) @@ -154,7 +154,7 @@ void TestQgsFileDownloader::cleanup() void TestQgsFileDownloader::testValidDownload() { QVERIFY( ! mTempFile->fileName().isEmpty() ); - makeCall( QUrl( "http://www.qgis.org" ), mTempFile->fileName() ); + makeCall( QUrl( QStringLiteral( "http://www.qgis.org" ) ), mTempFile->fileName() ); QVERIFY( mExited ); QVERIFY( mCompleted ); QVERIFY( mProgress ); @@ -166,7 +166,7 @@ void TestQgsFileDownloader::testValidDownload() void TestQgsFileDownloader::testInValidDownload() { QVERIFY( ! mTempFile->fileName().isEmpty() ); - makeCall( QUrl( "http://www.doesnotexistofthatimsure.qgis" ), mTempFile->fileName() ); + makeCall( QUrl( QStringLiteral( "http://www.doesnotexistofthatimsure.qgis" ) ), mTempFile->fileName() ); QVERIFY( mExited ); QVERIFY( !mCompleted ); QVERIFY( mError ); @@ -178,7 +178,7 @@ void TestQgsFileDownloader::testInValidDownload() void TestQgsFileDownloader::testCanceledDownload() { QVERIFY( ! mTempFile->fileName().isEmpty() ); - makeCall( QUrl( "https://github.com/qgis/QGIS/archive/master.zip" ), mTempFile->fileName(), true ); + makeCall( QUrl( QStringLiteral( "https://github.com/qgis/QGIS/archive/master.zip" ) ), mTempFile->fileName(), true ); QVERIFY( mExited ); QVERIFY( !mCompleted ); QVERIFY( !mError ); @@ -189,7 +189,7 @@ void TestQgsFileDownloader::testCanceledDownload() void TestQgsFileDownloader::testInvalidFile() { - makeCall( QUrl( "https://github.com/qgis/QGIS/archive/master.zip" ), QString() ); + makeCall( QUrl( QStringLiteral( "https://github.com/qgis/QGIS/archive/master.zip" ) ), QString() ); QVERIFY( mExited ); QVERIFY( !mCompleted ); QVERIFY( mError ); @@ -200,7 +200,7 @@ void TestQgsFileDownloader::testInvalidFile() void TestQgsFileDownloader::testInvalidUrl() { QVERIFY( ! mTempFile->fileName().isEmpty() ); - makeCall( QUrl( "xyz://www" ), mTempFile->fileName() ); + makeCall( QUrl( QStringLiteral( "xyz://www" ) ), mTempFile->fileName() ); QVERIFY( mExited ); QVERIFY( !mCompleted ); QVERIFY( mError ); @@ -211,7 +211,7 @@ void TestQgsFileDownloader::testInvalidUrl() void TestQgsFileDownloader::testBlankUrl() { QVERIFY( ! mTempFile->fileName().isEmpty() ); - makeCall( QUrl( "" ), mTempFile->fileName() ); + makeCall( QUrl( QLatin1String( "" ) ), mTempFile->fileName() ); QVERIFY( mExited ); QVERIFY( !mCompleted ); QVERIFY( mError ); diff --git a/tests/src/gui/testqgslayoutview.cpp b/tests/src/gui/testqgslayoutview.cpp index dbedb93e7aea..94f4d35a769e 100644 --- a/tests/src/gui/testqgslayoutview.cpp +++ b/tests/src/gui/testqgslayoutview.cpp @@ -126,7 +126,7 @@ class LoggingTool : public QgsLayoutViewTool public: LoggingTool( QgsLayoutView *view ) - : QgsLayoutViewTool( view, "logging" ) + : QgsLayoutViewTool( view, QStringLiteral( "logging" ) ) {} bool receivedMoveEvent = false; diff --git a/tests/src/gui/testqgsmaptooledit.cpp b/tests/src/gui/testqgsmaptooledit.cpp index 947bb564a10f..9e3090900192 100644 --- a/tests/src/gui/testqgsmaptooledit.cpp +++ b/tests/src/gui/testqgsmaptooledit.cpp @@ -68,7 +68,7 @@ void TestQgsMapToolEdit::cleanup() void TestQgsMapToolEdit::checkDefaultZValue() { QgsSettings settings; - settings.remove( "/qgis/digitizing/default_z_value" ); + settings.remove( QStringLiteral( "/qgis/digitizing/default_z_value" ) ); QgsMapToolEdit *tool = new QgsMapToolEdit( mCanvas ); QCOMPARE( tool->defaultZValue(), Qgis::DEFAULT_Z_COORDINATE ); diff --git a/tests/src/gui/testqgsrelationreferencewidget.cpp b/tests/src/gui/testqgsrelationreferencewidget.cpp index 6d1b72f13778..810d861bcf56 100644 --- a/tests/src/gui/testqgsrelationreferencewidget.cpp +++ b/tests/src/gui/testqgsrelationreferencewidget.cpp @@ -74,7 +74,7 @@ void TestQgsRelationReferenceWidget::init() mRelation->setName( QStringLiteral( "vl1.vl2" ) ); mRelation->setReferencingLayer( mLayer1->id() ); mRelation->setReferencedLayer( mLayer2->id() ); - mRelation->addFieldPair( "fk", "pk" ); + mRelation->addFieldPair( QStringLiteral( "fk" ), QStringLiteral( "pk" ) ); QVERIFY( mRelation->isValid() ); QgsProject::instance()->relationManager()->addRelation( *mRelation.get() ); @@ -141,25 +141,25 @@ void TestQgsRelationReferenceWidget::testChainFilter() QCOMPARE( cbs.count(), 3 ); Q_FOREACH ( const QComboBox *cb, cbs ) { - if ( cb->currentText() == "raccord" ) + if ( cb->currentText() == QLatin1String( "raccord" ) ) QCOMPARE( cb->count(), 5 ); - else if ( cb->currentText() == "material" ) + else if ( cb->currentText() == QLatin1String( "material" ) ) QCOMPARE( cb->count(), 4 ); - else if ( cb->currentText() == "diameter" ) + else if ( cb->currentText() == QLatin1String( "diameter" ) ) QCOMPARE( cb->count(), 3 ); } // set first filter - cbs[0]->setCurrentIndex( cbs[0]->findText( "iron" ) ); - cbs[1]->setCurrentIndex( cbs[1]->findText( "120" ) ); + cbs[0]->setCurrentIndex( cbs[0]->findText( QStringLiteral( "iron" ) ) ); + cbs[1]->setCurrentIndex( cbs[1]->findText( QStringLiteral( "120" ) ) ); Q_FOREACH ( const QComboBox *cb, cbs ) { - if ( cb->itemText( 0 ) == "material" ) + if ( cb->itemText( 0 ) == QLatin1String( "material" ) ) QCOMPARE( cb->count(), 4 ); - else if ( cb->itemText( 0 ) == "diameter" ) + else if ( cb->itemText( 0 ) == QLatin1String( "diameter" ) ) QCOMPARE( cb->count(), 2 ); - else if ( cb->itemText( 0 ) == "raccord" ) + else if ( cb->itemText( 0 ) == QLatin1String( "raccord" ) ) { QStringList items; for ( int i = 0; i < cb->count(); i++ ) @@ -175,15 +175,15 @@ void TestQgsRelationReferenceWidget::testChainFilter() // set the filter for "raccord" and then reset filter for "diameter". As // chain filter is activated, the filter on "raccord" field should be reset - cbs[2]->setCurrentIndex( cbs[2]->findText( "brides" ) ); - cbs[1]->setCurrentIndex( cbs[1]->findText( "diameter" ) ); + cbs[2]->setCurrentIndex( cbs[2]->findText( QStringLiteral( "brides" ) ) ); + cbs[1]->setCurrentIndex( cbs[1]->findText( QStringLiteral( "diameter" ) ) ); // combobox should propose NULL, 10 and 11 because the filter is now: // "material" == 'iron' QCOMPARE( w.mComboBox->count(), 3 ); // if there's no filter at all, all features' id should be proposed - cbs[0]->setCurrentIndex( cbs[0]->findText( "material" ) ); + cbs[0]->setCurrentIndex( cbs[0]->findText( QStringLiteral( "material" ) ) ); QCOMPARE( w.mComboBox->count(), 4 ); } diff --git a/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp b/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp index 63c90ec93a09..8aae60557777 100644 --- a/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp +++ b/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp @@ -75,7 +75,7 @@ void TestQgsValueRelationWidgetWrapper::testScrollBarUnlocked() // add an item virtually QListWidgetItem item; - item.setText( "MyText" ); + item.setText( QStringLiteral( "MyText" ) ); w.mListWidget->addItem( &item ); QCOMPARE( w.mListWidget->item( 0 )->text(), QString( "MyText" ) ); From 01d34ede9deb32c6f095b7458355dd75dc8146df Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 14:20:39 +1000 Subject: [PATCH 13/15] Sip sync --- python/analysis/network/qgsgraphbuilder.sip | 1 + python/analysis/network/qgsgraphbuilderinterface.sip | 1 + python/analysis/vector/qgszonalstatistics.sip | 3 ++- python/core/diagram/qgshistogramdiagram.sip | 1 + python/core/diagram/qgspiediagram.sip | 1 + python/core/diagram/qgstextdiagram.sip | 1 + python/core/geometry/qgsabstractgeometry.sip | 1 + python/core/geometry/qgscircularstring.sip | 1 + python/core/geometry/qgscompoundcurve.sip | 1 + python/core/geometry/qgscurvepolygon.sip | 1 + python/core/geometry/qgsgeometrycollection.sip | 1 + python/core/geometry/qgslinestring.sip | 1 + python/core/geometry/qgsmulticurve.sip | 1 + python/core/geometry/qgsmultilinestring.sip | 1 + python/core/geometry/qgsmultipoint.sip | 1 + python/core/geometry/qgsmultipolygon.sip | 1 + python/core/geometry/qgsmultisurface.sip | 1 + python/core/geometry/qgspoint.sip | 1 + python/core/processing/qgsprocessingalgorithm.sip | 1 + python/core/processing/qgsprocessingparameters.sip | 1 + python/core/qgsapplication.sip | 1 + python/core/qgsfontutils.sip | 1 + python/core/qgsmaprenderertask.sip | 1 + python/core/qgsprojectversion.sip | 1 + python/core/qgsrenderchecker.sip | 2 +- python/core/qgsuserprofilemanager.sip | 1 + python/core/qgsvectorlayer.sip | 1 + python/core/qgsvirtuallayerdefinition.sip | 1 + python/core/raster/qgsrasterchecker.sip | 1 + python/core/raster/qgsrasterdataprovider.sip | 2 ++ python/core/raster/qgsrasterlayer.sip | 1 + python/core/raster/qgsrasterrenderer.sip | 2 +- python/core/symbology/qgscolorbrewerpalette.sip | 1 + python/core/symbology/qgscptcityarchive.sip | 1 + python/core/symbology/qgsellipsesymbollayer.sip | 1 + python/gui/qgsbusyindicatordialog.sip | 3 ++- python/gui/qgscodeeditor.sip | 3 ++- python/gui/qgscolorbutton.sip | 2 +- python/gui/qgsexpressionbuilderdialog.sip | 1 + python/gui/qgsexpressionbuilderwidget.sip | 3 ++- python/gui/qgsfieldvalidator.sip | 1 + python/gui/qgsmanageconnectionsdialog.sip | 3 ++- python/gui/qgsmapcanvas.sip | 1 - python/gui/qgsnewhttpconnection.sip | 1 + python/gui/qgsrasterformatsaveoptionswidget.sip | 1 + python/gui/qgsrasterpyramidsoptionswidget.sip | 1 + python/gui/qgsshortcutsmanager.sip | 1 + 47 files changed, 52 insertions(+), 9 deletions(-) diff --git a/python/analysis/network/qgsgraphbuilder.sip b/python/analysis/network/qgsgraphbuilder.sip index 85bbcef5a601..8332f7e9c288 100644 --- a/python/analysis/network/qgsgraphbuilder.sip +++ b/python/analysis/network/qgsgraphbuilder.sip @@ -44,6 +44,7 @@ class QgsGraphBuilder : QgsGraphBuilderInterface }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/analysis/network/qgsgraphbuilderinterface.sip b/python/analysis/network/qgsgraphbuilderinterface.sip index 3de8f628b5e9..623ba09c1b8a 100644 --- a/python/analysis/network/qgsgraphbuilderinterface.sip +++ b/python/analysis/network/qgsgraphbuilderinterface.sip @@ -92,6 +92,7 @@ Returns measurement tool }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/analysis/vector/qgszonalstatistics.sip b/python/analysis/vector/qgszonalstatistics.sip index 59da3bfae9d2..8310b6c115f8 100644 --- a/python/analysis/vector/qgszonalstatistics.sip +++ b/python/analysis/vector/qgszonalstatistics.sip @@ -44,7 +44,7 @@ class QgsZonalStatistics QgsZonalStatistics( QgsVectorLayer *polygonLayer, QgsRasterLayer *rasterLayer, - const QString &attributePrefix = "", + const QString &attributePrefix = QString(), int rasterBand = 1, QgsZonalStatistics::Statistics stats = QgsZonalStatistics::Statistics( QgsZonalStatistics::Count | QgsZonalStatistics::Sum | QgsZonalStatistics::Mean ) ); %Docstring @@ -64,6 +64,7 @@ class QgsZonalStatistics QFlags operator|(QgsZonalStatistics::Statistic f1, QFlags f2); + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/diagram/qgshistogramdiagram.sip b/python/core/diagram/qgshistogramdiagram.sip index bea7e92cd5fb..18750b27a45d 100644 --- a/python/core/diagram/qgshistogramdiagram.sip +++ b/python/core/diagram/qgshistogramdiagram.sip @@ -33,6 +33,7 @@ class QgsHistogramDiagram: QgsDiagram virtual QString diagramName() const; + }; diff --git a/python/core/diagram/qgspiediagram.sip b/python/core/diagram/qgspiediagram.sip index 1c54b875c166..04d4b2fa1a9c 100644 --- a/python/core/diagram/qgspiediagram.sip +++ b/python/core/diagram/qgspiediagram.sip @@ -31,6 +31,7 @@ class QgsPieDiagram: QgsDiagram virtual QString diagramName() const; + }; /************************************************************************ diff --git a/python/core/diagram/qgstextdiagram.sip b/python/core/diagram/qgstextdiagram.sip index cca962b89271..aa60328ae7a7 100644 --- a/python/core/diagram/qgstextdiagram.sip +++ b/python/core/diagram/qgstextdiagram.sip @@ -44,6 +44,7 @@ class QgsTextDiagram: QgsDiagram virtual QString diagramName() const; + }; /************************************************************************ diff --git a/python/core/geometry/qgsabstractgeometry.sip b/python/core/geometry/qgsabstractgeometry.sip index 8f447cfa7102..4310db4a3e79 100644 --- a/python/core/geometry/qgsabstractgeometry.sip +++ b/python/core/geometry/qgsabstractgeometry.sip @@ -528,6 +528,7 @@ struct QgsVertexId }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgscircularstring.sip b/python/core/geometry/qgscircularstring.sip index ceb673be75b2..f2d6c65f9d86 100644 --- a/python/core/geometry/qgscircularstring.sip +++ b/python/core/geometry/qgscircularstring.sip @@ -136,6 +136,7 @@ class QgsCircularString: QgsCurve }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgscompoundcurve.sip b/python/core/geometry/qgscompoundcurve.sip index aa16c5365232..c7e67ffcafcf 100644 --- a/python/core/geometry/qgscompoundcurve.sip +++ b/python/core/geometry/qgscompoundcurve.sip @@ -152,6 +152,7 @@ Appends first point if not already closed. }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgscurvepolygon.sip b/python/core/geometry/qgscurvepolygon.sip index d1e4faa9aa19..2cac48215d1d 100644 --- a/python/core/geometry/qgscurvepolygon.sip +++ b/python/core/geometry/qgscurvepolygon.sip @@ -199,6 +199,7 @@ Adds an interior ring to the geometry (takes ownership) }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgsgeometrycollection.sip b/python/core/geometry/qgsgeometrycollection.sip index 5e82789ce4eb..1999edcfd7e8 100644 --- a/python/core/geometry/qgsgeometrycollection.sip +++ b/python/core/geometry/qgsgeometrycollection.sip @@ -190,6 +190,7 @@ Adds a geometry and takes ownership. Returns true in case of success. }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgslinestring.sip b/python/core/geometry/qgslinestring.sip index ab533e817224..ea1b00059fe3 100644 --- a/python/core/geometry/qgslinestring.sip +++ b/python/core/geometry/qgslinestring.sip @@ -274,6 +274,7 @@ Closes the line string by appending the first point to the end of the line, if i }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgsmulticurve.sip b/python/core/geometry/qgsmulticurve.sip index ed25b1f66499..04b4f5e15dd4 100644 --- a/python/core/geometry/qgsmulticurve.sip +++ b/python/core/geometry/qgsmulticurve.sip @@ -57,6 +57,7 @@ Adds a geometry and takes ownership. Returns true in case of success }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgsmultilinestring.sip b/python/core/geometry/qgsmultilinestring.sip index 45314dcc3017..6c667ebee3de 100644 --- a/python/core/geometry/qgsmultilinestring.sip +++ b/python/core/geometry/qgsmultilinestring.sip @@ -56,6 +56,7 @@ Adds a geometry and takes ownership. Returns true in case of success }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgsmultipoint.sip b/python/core/geometry/qgsmultipoint.sip index 534d2d631350..6e32cf73c9fe 100644 --- a/python/core/geometry/qgsmultipoint.sip +++ b/python/core/geometry/qgsmultipoint.sip @@ -57,6 +57,7 @@ Adds a geometry and takes ownership. Returns true in case of success }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgsmultipolygon.sip b/python/core/geometry/qgsmultipolygon.sip index 97e69930d978..c53ab77f1b22 100644 --- a/python/core/geometry/qgsmultipolygon.sip +++ b/python/core/geometry/qgsmultipolygon.sip @@ -59,6 +59,7 @@ Adds a geometry and takes ownership. Returns true in case of success }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgsmultisurface.sip b/python/core/geometry/qgsmultisurface.sip index 084e446d0a48..fa5c290e50fa 100644 --- a/python/core/geometry/qgsmultisurface.sip +++ b/python/core/geometry/qgsmultisurface.sip @@ -51,6 +51,7 @@ Adds a geometry and takes ownership. Returns true in case of success }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/geometry/qgspoint.sip b/python/core/geometry/qgspoint.sip index cc40febdd6dd..eb6964a21405 100644 --- a/python/core/geometry/qgspoint.sip +++ b/python/core/geometry/qgspoint.sip @@ -412,6 +412,7 @@ class QgsPoint: QgsAbstractGeometry }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/processing/qgsprocessingalgorithm.sip b/python/core/processing/qgsprocessingalgorithm.sip index 4a84c2f26655..2f11f379858a 100644 --- a/python/core/processing/qgsprocessingalgorithm.sip +++ b/python/core/processing/qgsprocessingalgorithm.sip @@ -893,6 +893,7 @@ class QgsProcessingFeatureBasedAlgorithm : QgsProcessingAlgorithm + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/processing/qgsprocessingparameters.sip b/python/core/processing/qgsprocessingparameters.sip index da7215c7aa96..fee23fccab3a 100644 --- a/python/core/processing/qgsprocessingparameters.sip +++ b/python/core/processing/qgsprocessingparameters.sip @@ -2143,6 +2143,7 @@ class QgsProcessingParameterBand : QgsProcessingParameterDefinition + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/qgsapplication.sip b/python/core/qgsapplication.sip index 12215b38145e..d95c662d58fa 100644 --- a/python/core/qgsapplication.sip +++ b/python/core/qgsapplication.sip @@ -778,6 +778,7 @@ Returns path to the build output directory. Valid only when running from build d }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/qgsfontutils.sip b/python/core/qgsfontutils.sip index a1410fecbcf6..a264515a4e28 100644 --- a/python/core/qgsfontutils.sip +++ b/python/core/qgsfontutils.sip @@ -204,6 +204,7 @@ class QgsFontUtils %End }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/qgsmaprenderertask.sip b/python/core/qgsmaprenderertask.sip index 52e060afa998..1e962b14fc4f 100644 --- a/python/core/qgsmaprenderertask.sip +++ b/python/core/qgsmaprenderertask.sip @@ -80,6 +80,7 @@ class QgsMapRendererTask : QgsTask }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/qgsprojectversion.sip b/python/core/qgsprojectversion.sip index a19fefaf35ec..0c472de738bb 100644 --- a/python/core/qgsprojectversion.sip +++ b/python/core/qgsprojectversion.sip @@ -75,6 +75,7 @@ class QgsProjectVersion }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/qgsrenderchecker.sip b/python/core/qgsrenderchecker.sip index 6b38f9db2372..b77f28b76aec 100644 --- a/python/core/qgsrenderchecker.sip +++ b/python/core/qgsrenderchecker.sip @@ -116,7 +116,7 @@ Get an md5 hash that uniquely identifies an image :rtype: bool %End - bool compareImages( const QString &testName, unsigned int mismatchCount = 0, const QString &renderedImageFile = "" ); + bool compareImages( const QString &testName, unsigned int mismatchCount = 0, const QString &renderedImageFile = QString() ); %Docstring Test using two arbitrary images (map renderer will not be used) \param testName - to be used as the basis for writing a file to diff --git a/python/core/qgsuserprofilemanager.sip b/python/core/qgsuserprofilemanager.sip index 2f7dd0c679f9..2ba8214dd649 100644 --- a/python/core/qgsuserprofilemanager.sip +++ b/python/core/qgsuserprofilemanager.sip @@ -204,6 +204,7 @@ class QgsUserProfileManager : QObject }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/qgsvectorlayer.sip b/python/core/qgsvectorlayer.sip index cfe9b0cb35b0..c95757512e19 100644 --- a/python/core/qgsvectorlayer.sip +++ b/python/core/qgsvectorlayer.sip @@ -2093,6 +2093,7 @@ Set the extent QgsVectorLayer( const QgsVectorLayer &rhs ); }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/qgsvirtuallayerdefinition.sip b/python/core/qgsvirtuallayerdefinition.sip index f515d0fbd38f..b250e4cac2cf 100644 --- a/python/core/qgsvirtuallayerdefinition.sip +++ b/python/core/qgsvirtuallayerdefinition.sip @@ -212,6 +212,7 @@ Convenient method to test if the geometry is defined (not NoGeometry and not Unk }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/raster/qgsrasterchecker.sip b/python/core/raster/qgsrasterchecker.sip index 2b2b409312b2..12b0f50b8c8f 100644 --- a/python/core/raster/qgsrasterchecker.sip +++ b/python/core/raster/qgsrasterchecker.sip @@ -40,6 +40,7 @@ class QgsRasterChecker %End }; // class QgsRasterChecker + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/raster/qgsrasterdataprovider.sip b/python/core/raster/qgsrasterdataprovider.sip index 8629765160ae..23397f56e4ab 100644 --- a/python/core/raster/qgsrasterdataprovider.sip +++ b/python/core/raster/qgsrasterdataprovider.sip @@ -467,6 +467,8 @@ Copy member variables from other raster data provider. Useful for implementation }; + + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/raster/qgsrasterlayer.sip b/python/core/raster/qgsrasterlayer.sip index 4ef1655a6413..954903950d23 100644 --- a/python/core/raster/qgsrasterlayer.sip +++ b/python/core/raster/qgsrasterlayer.sip @@ -452,6 +452,7 @@ Time stamp of data source in the moment when data/metadata were loaded by provid }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/raster/qgsrasterrenderer.sip b/python/core/raster/qgsrasterrenderer.sip index 9dd0d245ffcd..157ac85f6471 100644 --- a/python/core/raster/qgsrasterrenderer.sip +++ b/python/core/raster/qgsrasterrenderer.sip @@ -25,7 +25,7 @@ class QgsRasterRenderer : QgsRasterInterface static const QRgb NODATA_COLOR; - QgsRasterRenderer( QgsRasterInterface *input = 0, const QString &type = "" ); + QgsRasterRenderer( QgsRasterInterface *input = 0, const QString &type = QString() ); virtual ~QgsRasterRenderer(); diff --git a/python/core/symbology/qgscolorbrewerpalette.sip b/python/core/symbology/qgscolorbrewerpalette.sip index c09943cd5460..9e941a0c8de0 100644 --- a/python/core/symbology/qgscolorbrewerpalette.sip +++ b/python/core/symbology/qgscolorbrewerpalette.sip @@ -33,6 +33,7 @@ class QgsColorBrewerPalette static const char *BREWER_STRING; }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/symbology/qgscptcityarchive.sip b/python/core/symbology/qgscptcityarchive.sip index 2fecb7ef677f..da15475c862a 100644 --- a/python/core/symbology/qgscptcityarchive.sip +++ b/python/core/symbology/qgscptcityarchive.sip @@ -470,6 +470,7 @@ return index of a path }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/symbology/qgsellipsesymbollayer.sip b/python/core/symbology/qgsellipsesymbollayer.sip index c39b747e3e2a..5781782e6207 100644 --- a/python/core/symbology/qgsellipsesymbollayer.sip +++ b/python/core/symbology/qgsellipsesymbollayer.sip @@ -181,6 +181,7 @@ class QgsEllipseSymbolLayer: QgsMarkerSymbolLayer + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgsbusyindicatordialog.sip b/python/gui/qgsbusyindicatordialog.sip index e3d454fba9f0..e52bccd00b81 100644 --- a/python/gui/qgsbusyindicatordialog.sip +++ b/python/gui/qgsbusyindicatordialog.sip @@ -22,7 +22,7 @@ class QgsBusyIndicatorDialog : QDialog %End public: - QgsBusyIndicatorDialog( const QString &message = "", QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags ); + QgsBusyIndicatorDialog( const QString &message = QString(), QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags ); %Docstring Constructor Modal busy indicator dialog with no buttons. @@ -39,6 +39,7 @@ class QgsBusyIndicatorDialog : QDialog }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgscodeeditor.sip b/python/gui/qgscodeeditor.sip index 3282d75c6e41..861b5021683b 100644 --- a/python/gui/qgscodeeditor.sip +++ b/python/gui/qgscodeeditor.sip @@ -27,7 +27,7 @@ class QgsCodeEditor : QsciScintilla %End public: - QgsCodeEditor( QWidget *parent /TransferThis/ = 0, const QString &title = "", bool folding = false, bool margin = false ); + QgsCodeEditor( QWidget *parent /TransferThis/ = 0, const QString &title = QString(), bool folding = false, bool margin = false ); %Docstring Construct a new code editor. @@ -90,6 +90,7 @@ class QgsCodeEditor : QsciScintilla }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgscolorbutton.sip b/python/gui/qgscolorbutton.sip index 76dae3ef70b6..cc85a4fbce41 100644 --- a/python/gui/qgscolorbutton.sip +++ b/python/gui/qgscolorbutton.sip @@ -35,7 +35,7 @@ class QgsColorButton : QToolButton SignalOnly }; - QgsColorButton( QWidget *parent /TransferThis/ = 0, const QString &cdt = "", QgsColorSchemeRegistry *registry = 0 ); + QgsColorButton( QWidget *parent /TransferThis/ = 0, const QString &cdt = QString(), QgsColorSchemeRegistry *registry = 0 ); %Docstring Construct a new color ramp button. Use ``parent`` to attach a parent QWidget to the dialog. diff --git a/python/gui/qgsexpressionbuilderdialog.sip b/python/gui/qgsexpressionbuilderdialog.sip index 35d6a3cdb36d..b3ca059bfa78 100644 --- a/python/gui/qgsexpressionbuilderdialog.sip +++ b/python/gui/qgsexpressionbuilderdialog.sip @@ -76,6 +76,7 @@ Sets geometry calculator used in distance/area calculations. }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgsexpressionbuilderwidget.sip b/python/gui/qgsexpressionbuilderwidget.sip index 7a0d0dc8b35e..a211ecf8b917 100644 --- a/python/gui/qgsexpressionbuilderwidget.sip +++ b/python/gui/qgsexpressionbuilderwidget.sip @@ -180,7 +180,7 @@ Sets the expression string for the widget %End void registerItem( const QString &group, const QString &label, const QString &expressionText, - const QString &helpText = "", + const QString &helpText = QString(), QgsExpressionItem::ItemType type = QgsExpressionItem::ExpressionNode, bool highlightedItem = false, int sortOrder = 1 ); %Docstring @@ -299,6 +299,7 @@ Sets the expression string for the widget }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgsfieldvalidator.sip b/python/gui/qgsfieldvalidator.sip index 6d20afdf91de..bbdbcb0c1d79 100644 --- a/python/gui/qgsfieldvalidator.sip +++ b/python/gui/qgsfieldvalidator.sip @@ -29,6 +29,7 @@ class QgsFieldValidator : QValidator }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgsmanageconnectionsdialog.sip b/python/gui/qgsmanageconnectionsdialog.sip index 0c7114c31e30..3a41bc6e2a35 100644 --- a/python/gui/qgsmanageconnectionsdialog.sip +++ b/python/gui/qgsmanageconnectionsdialog.sip @@ -34,7 +34,7 @@ class QgsManageConnectionsDialog : QDialog GeoNode }; - QgsManageConnectionsDialog( QWidget *parent /TransferThis/ = 0, Mode mode = Export, Type type = WMS, const QString &fileName = "" ); + QgsManageConnectionsDialog( QWidget *parent /TransferThis/ = 0, Mode mode = Export, Type type = WMS, const QString &fileName = QString() ); public slots: void doExportImport(); @@ -45,6 +45,7 @@ class QgsManageConnectionsDialog : QDialog }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgsmapcanvas.sip b/python/gui/qgsmapcanvas.sip index 4d4ee376371e..f569e70f3fd5 100644 --- a/python/gui/qgsmapcanvas.sip +++ b/python/gui/qgsmapcanvas.sip @@ -889,7 +889,6 @@ called on resize or changed extent to notify canvas items to change their rectan }; // class QgsMapCanvas - /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgsnewhttpconnection.sip b/python/gui/qgsnewhttpconnection.sip index 54ed29c32027..0ec87ace1bb7 100644 --- a/python/gui/qgsnewhttpconnection.sip +++ b/python/gui/qgsnewhttpconnection.sip @@ -121,6 +121,7 @@ QFlags operator|(QgsNewHttpConnection::Con QFlags operator|(QgsNewHttpConnection::Flag f1, QFlags f2); + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgsrasterformatsaveoptionswidget.sip b/python/gui/qgsrasterformatsaveoptionswidget.sip index a29026d86901..5ccb5ffde9a1 100644 --- a/python/gui/qgsrasterformatsaveoptionswidget.sip +++ b/python/gui/qgsrasterformatsaveoptionswidget.sip @@ -169,6 +169,7 @@ class QgsRasterFormatSaveOptionsWidget: QWidget %End }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgsrasterpyramidsoptionswidget.sip b/python/gui/qgsrasterpyramidsoptionswidget.sip index b9d360fa82b7..27fabe43255a 100644 --- a/python/gui/qgsrasterpyramidsoptionswidget.sip +++ b/python/gui/qgsrasterpyramidsoptionswidget.sip @@ -65,6 +65,7 @@ class QgsRasterPyramidsOptionsWidget: QWidget }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgsshortcutsmanager.sip b/python/gui/qgsshortcutsmanager.sip index 2a9db430af34..8542bc455b4a 100644 --- a/python/gui/qgsshortcutsmanager.sip +++ b/python/gui/qgsshortcutsmanager.sip @@ -251,6 +251,7 @@ Returns the root settings path used to store shortcut customisation. }; + /************************************************************************ * This file has been generated automatically from * * * From 270f167829c9a5ee06b507fb9eb6c2a74fc58834 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 15:16:05 +1000 Subject: [PATCH 14/15] Fix doctest --- python/core/raster/qgsrasterrenderer.sip | 3 +++ python/gui/qgsmanageconnectionsdialog.sip | 3 +++ src/core/raster/qgsrasterrenderer.h | 3 +++ src/gui/qgsmanageconnectionsdialog.h | 6 +++--- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/python/core/raster/qgsrasterrenderer.sip b/python/core/raster/qgsrasterrenderer.sip index 157ac85f6471..348620ec833f 100644 --- a/python/core/raster/qgsrasterrenderer.sip +++ b/python/core/raster/qgsrasterrenderer.sip @@ -26,6 +26,9 @@ class QgsRasterRenderer : QgsRasterInterface static const QRgb NODATA_COLOR; QgsRasterRenderer( QgsRasterInterface *input = 0, const QString &type = QString() ); +%Docstring + Constructor for QgsRasterRenderer. +%End virtual ~QgsRasterRenderer(); diff --git a/python/gui/qgsmanageconnectionsdialog.sip b/python/gui/qgsmanageconnectionsdialog.sip index 3a41bc6e2a35..cd965bdb3392 100644 --- a/python/gui/qgsmanageconnectionsdialog.sip +++ b/python/gui/qgsmanageconnectionsdialog.sip @@ -35,6 +35,9 @@ class QgsManageConnectionsDialog : QDialog }; QgsManageConnectionsDialog( QWidget *parent /TransferThis/ = 0, Mode mode = Export, Type type = WMS, const QString &fileName = QString() ); +%Docstring + Constructor for QgsManageConnectionsDialog. +%End public slots: void doExportImport(); diff --git a/src/core/raster/qgsrasterrenderer.h b/src/core/raster/qgsrasterrenderer.h index 46e3f13ed2d4..8532132a0e75 100644 --- a/src/core/raster/qgsrasterrenderer.h +++ b/src/core/raster/qgsrasterrenderer.h @@ -42,6 +42,9 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface static const QRgb NODATA_COLOR; + /** + * Constructor for QgsRasterRenderer. + */ QgsRasterRenderer( QgsRasterInterface *input = nullptr, const QString &type = QString() ); virtual ~QgsRasterRenderer(); diff --git a/src/gui/qgsmanageconnectionsdialog.h b/src/gui/qgsmanageconnectionsdialog.h index af483e010f58..7430d7271f07 100644 --- a/src/gui/qgsmanageconnectionsdialog.h +++ b/src/gui/qgsmanageconnectionsdialog.h @@ -50,9 +50,9 @@ class GUI_EXPORT QgsManageConnectionsDialog : public QDialog, private Ui::QgsMan GeoNode }; - // constructor - // mode argument must be 0 for export and 1 for import - // type argument must be 0 for WMS and 1 for PostGIS + /** + * Constructor for QgsManageConnectionsDialog. + */ QgsManageConnectionsDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Mode mode = Export, Type type = WMS, const QString &fileName = QString() ); public slots: From b0b1714e98bac74b5153d08276ec010d65fe84ce Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Sep 2017 16:08:57 +1000 Subject: [PATCH 15/15] Fix build --- python/core/symbology/qgsgraduatedsymbolrenderer.sip | 2 +- src/core/auth/qgsauthmethodregistry.cpp | 2 +- src/core/symbology/qgsgraduatedsymbolrenderer.cpp | 2 +- src/core/symbology/qgsgraduatedsymbolrenderer.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/core/symbology/qgsgraduatedsymbolrenderer.sip b/python/core/symbology/qgsgraduatedsymbolrenderer.sip index aa26d2dc4d6d..d1a299e34509 100644 --- a/python/core/symbology/qgsgraduatedsymbolrenderer.sip +++ b/python/core/symbology/qgsgraduatedsymbolrenderer.sip @@ -75,7 +75,7 @@ class QgsRendererRange void swap( QgsRendererRange &other ); }; -typedef QVector QgsRangeList; +typedef QList QgsRangeList; class QgsRendererRangeLabelFormat diff --git a/src/core/auth/qgsauthmethodregistry.cpp b/src/core/auth/qgsauthmethodregistry.cpp index b368a1357528..e60a30355ad9 100644 --- a/src/core/auth/qgsauthmethodregistry.cpp +++ b/src/core/auth/qgsauthmethodregistry.cpp @@ -78,7 +78,7 @@ QgsAuthMethodRegistry::QgsAuthMethodRegistry( const QString &pluginPath ) } // auth method file regex pattern, only files matching the pattern are loaded if the variable is defined - QString filePattern = getenv( QStringLiteral( "QGIS_AUTHMETHOD_FILE" ) ); + QString filePattern = getenv( "QGIS_AUTHMETHOD_FILE" ); QRegExp fileRegexp; if ( !filePattern.isEmpty() ) { diff --git a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp index ecc2f45d7908..a00021b3bacd 100644 --- a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp +++ b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp @@ -1390,7 +1390,7 @@ void QgsGraduatedSymbolRenderer::addClass( double lower, double upper ) void QgsGraduatedSymbolRenderer::addBreak( double breakValue, bool updateSymbols ) { - QMutableVectorIterator< QgsRendererRange > it( mRanges ); + QMutableListIterator< QgsRendererRange > it( mRanges ); while ( it.hasNext() ) { QgsRendererRange range = it.next(); diff --git a/src/core/symbology/qgsgraduatedsymbolrenderer.h b/src/core/symbology/qgsgraduatedsymbolrenderer.h index 149656aaa296..4af3dbf8904e 100644 --- a/src/core/symbology/qgsgraduatedsymbolrenderer.h +++ b/src/core/symbology/qgsgraduatedsymbolrenderer.h @@ -78,7 +78,7 @@ class CORE_EXPORT QgsRendererRange void swap( QgsRendererRange &other ); }; -typedef QVector QgsRangeList; +typedef QList QgsRangeList; /** \ingroup core