diff --git a/CMakeLists.txt b/CMakeLists.txt index a5864ffdcbb..a2324cd8d7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -624,6 +624,9 @@ ADD_DEFINITIONS(-DQT_DEPRECATED_WARNINGS) # Unfortunately Qwt uses deprecated QString::null in headers, preventing this being raised above 5.8 ADD_DEFINITIONS(-DQT_DISABLE_DEPRECATED_BEFORE=0x050800) +# For fast string concatenation +ADD_DEFINITIONS(-DQT_USE_QSTRINGBUILDER) + IF (WITH_GEOREFERENCER) FIND_PACKAGE(GSL REQUIRED) SET(HAVE_GEOREFERENCER TRUE) diff --git a/src/analysis/processing/qgsalgorithmlayouttoimage.cpp b/src/analysis/processing/qgsalgorithmlayouttoimage.cpp index 1f2dc530389..d99dd614123 100644 --- a/src/analysis/processing/qgsalgorithmlayouttoimage.cpp +++ b/src/analysis/processing/qgsalgorithmlayouttoimage.cpp @@ -92,7 +92,7 @@ void QgsLayoutToImageAlgorithm::initAlgorithm( const QVariantMap & ) continue; QString longName = format.toUpper() + QObject::tr( " format" ); - QString glob = "*." + format; + QString glob = QStringLiteral( "*." ) + format; if ( format == "png" && !imageFilters.empty() ) imageFilters.insert( 0, QStringLiteral( "%1 (%2 %3)" ).arg( longName, glob.toLower(), glob.toUpper() ) ); diff --git a/src/analysis/processing/qgsalgorithmstringconcatenation.cpp b/src/analysis/processing/qgsalgorithmstringconcatenation.cpp index 97579d7f257..8a9dda63575 100644 --- a/src/analysis/processing/qgsalgorithmstringconcatenation.cpp +++ b/src/analysis/processing/qgsalgorithmstringconcatenation.cpp @@ -72,7 +72,7 @@ QVariantMap QgsStringConcatenationAlgorithm::processAlgorithm( const QVariantMap QString input_2 = parameterAsString( parameters, QStringLiteral( "INPUT_2" ), context ); QVariantMap outputs; - outputs.insert( QStringLiteral( "CONCATENATION" ), input_1 + input_2 ); + outputs.insert( QStringLiteral( "CONCATENATION" ), QString( input_1 + input_2 ) ); return outputs; } diff --git a/src/analysis/processing/qgsprojectstylealgorithms.cpp b/src/analysis/processing/qgsprojectstylealgorithms.cpp index dd79d0c7982..730c7b0f09b 100644 --- a/src/analysis/processing/qgsprojectstylealgorithms.cpp +++ b/src/analysis/processing/qgsprojectstylealgorithms.cpp @@ -34,7 +34,7 @@ bool QgsSaveToStyleVisitor::visit( const QgsStyleEntityVisitorInterface::StyleLe { if ( mObjects.empty() || mObjects.contains( entity.entity->type() ) ) { - const QString name = ( mParentNames.join( ' ' ) + ' ' + entity.description ).trimmed(); + const QString name = QString( mParentNames.join( ' ' ) + ' ' + entity.description ).trimmed(); QString candidate = name; int i = 1; bool exists = true; diff --git a/src/app/options/qgsoptions.cpp b/src/app/options/qgsoptions.cpp index 4fd17b8df3e..cb3e1289c42 100644 --- a/src/app/options/qgsoptions.cpp +++ b/src/app/options/qgsoptions.cpp @@ -793,7 +793,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetChecked( mSettings->value( QStringLiteral( "/qgis/newProjectDefault" ), QVariant( false ) ).toBool() ); QString templateDirName = mSettings->value( QStringLiteral( "/qgis/projectTemplateDir" ), - QgsApplication::qgisSettingsDirPath() + "project_templates" ).toString(); + QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); // make dir if it doesn't exist - should just be called once QDir templateDir; if ( ! templateDir.exists( templateDirName ) ) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 9b9f9244e79..1542183a5b3 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1117,7 +1117,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh mSaveRollbackInProgress = false; QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), - QgsApplication::qgisSettingsDirPath() + "project_templates" ).toString(); + QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); if ( !QFileInfo::exists( templateDirName ) ) { // create default template directory @@ -5049,7 +5049,7 @@ void QgisApp::saveRecentProjectPath( bool savePreviewImage, const QIcon &iconOve QgsRecentProjectItemsModel::RecentProjectData projectData; projectData.path = QgsProject::instance()->absoluteFilePath(); QString templateDirName = QgsSettings().value( QStringLiteral( "qgis/projectTemplateDir" ), - QgsApplication::qgisSettingsDirPath() + "project_templates" ).toString(); + QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); // We don't want the template path to appear in the recent projects list. Never. if ( projectData.path.startsWith( templateDirName ) ) @@ -5160,7 +5160,7 @@ void QgisApp::updateProjectFromTemplates() // get list of project files in template dir QgsSettings settings; QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), - QgsApplication::qgisSettingsDirPath() + "project_templates" ).toString(); + QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); QDir templateDir( templateDirName ); QStringList filters( QStringLiteral( "*.qgs" ) ); filters << QStringLiteral( "*.qgz" ); @@ -6672,7 +6672,7 @@ void QgisApp::fileNewFromTemplateAction( QAction *qAction ) { QgsSettings settings; QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), - QgsApplication::qgisSettingsDirPath() + "project_templates" ).toString(); + QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); fileNewFromTemplate( templateDirName + QDir::separator() + qAction->text() ); } } @@ -7243,7 +7243,7 @@ void QgisApp::fileSaveAs() // Retrieve last used project dir from persistent settings QgsSettings settings; defaultPath = settings.value( QStringLiteral( "UI/lastProjectDir" ), QDir::homePath() ).toString(); - defaultPath += + '/' + QgsProject::instance()->title(); + defaultPath += QString( '/' + QgsProject::instance()->title() ); } const QString qgsExt = tr( "QGIS files" ) + " (*.qgs *.QGS)"; @@ -16484,7 +16484,7 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, const bool saving ) { QgsSettings settings; QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), - QgsApplication::qgisSettingsDirPath() + "project_templates" ).toString(); + QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); const QString originalFilename = QgsProject::instance()->fileName(); QString templateName = QFileInfo( originalFilename ).baseName(); diff --git a/src/app/qgsabout.cpp b/src/app/qgsabout.cpp index 94c4693f236..932faa53af0 100644 --- a/src/app/qgsabout.cpp +++ b/src/app/qgsabout.cpp @@ -233,7 +233,7 @@ void QgsAbout::setWhatsNew() if ( !QFile::exists( QgsApplication::pkgDataPath() + "/doc/NEWS.html" ) ) return; - txtWhatsNew->setSource( "file:///" + QgsApplication::pkgDataPath() + "/doc/NEWS.html" ); + txtWhatsNew->setSource( QString( "file:///" + QgsApplication::pkgDataPath() + "/doc/NEWS.html" ) ); } void QgsAbout::setPluginInfo() diff --git a/src/app/qgsidentifyresultsdialog.cpp b/src/app/qgsidentifyresultsdialog.cpp index 14c553aed94..984818d42a6 100644 --- a/src/app/qgsidentifyresultsdialog.cpp +++ b/src/app/qgsidentifyresultsdialog.cpp @@ -574,7 +574,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat item = new QTableWidgetItem( QString::number( i ) ); if ( fields.at( i ).name() == vlayer->displayField() ) - item->setData( Qt::DisplayRole, vlayer->attributeDisplayName( i ) + " *" ); + item->setData( Qt::DisplayRole, QString( vlayer->attributeDisplayName( i ) + " *" ) ); else item->setData( Qt::DisplayRole, vlayer->attributeDisplayName( i ) ); item->setData( Qt::UserRole, fields.at( i ).name() ); diff --git a/src/app/qgstemplateprojectsmodel.cpp b/src/app/qgstemplateprojectsmodel.cpp index b6a8e82b802..5b0102f8885 100644 --- a/src/app/qgstemplateprojectsmodel.cpp +++ b/src/app/qgstemplateprojectsmodel.cpp @@ -34,7 +34,7 @@ QgsTemplateProjectsModel::QgsTemplateProjectsModel( QObject *parent ) { const QStringList paths = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ); QString templateDirName = QgsSettings().value( QStringLiteral( "qgis/projectTemplateDir" ), - QgsApplication::qgisSettingsDirPath() + QStringLiteral( "project_templates" ) ).toString(); + QString( QgsApplication::qgisSettingsDirPath() + QStringLiteral( "project_templates" ) ) ).toString(); for ( const QString &templatePath : paths ) { diff --git a/src/core/layout/qgslayoutitemhtml.cpp b/src/core/layout/qgslayoutitemhtml.cpp index 5bf72963559..1980bcc6bef 100644 --- a/src/core/layout/qgslayoutitemhtml.cpp +++ b/src/core/layout/qgslayoutitemhtml.cpp @@ -198,7 +198,7 @@ void QgsLayoutItemHtml::loadHtml( const bool useCache, const QgsExpressionContex { QByteArray ba; ba.append( mUserStylesheet.toUtf8() ); - QUrl cssFileURL = QUrl( "data:text/css;charset=utf-8;base64," + ba.toBase64() ); + QUrl cssFileURL = QUrl( QString( "data:text/css;charset=utf-8;base64," + ba.toBase64() ) ); settings->setUserStyleSheetUrl( cssFileURL ); } else diff --git a/src/core/layout/qgslayoutitemlabel.cpp b/src/core/layout/qgslayoutitemlabel.cpp index 4ee7f74d539..e43874f9329 100644 --- a/src/core/layout/qgslayoutitemlabel.cpp +++ b/src/core/layout/qgslayoutitemlabel.cpp @@ -611,7 +611,7 @@ QUrl QgsLayoutItemLabel::createStylesheetUrl() const QByteArray ba; ba.append( stylesheet.toUtf8() ); - QUrl cssFileURL = QUrl( "data:text/css;charset=utf-8;base64," + ba.toBase64() ); + QUrl cssFileURL = QUrl( QString( "data:text/css;charset=utf-8;base64," + ba.toBase64() ) ); return cssFileURL; } diff --git a/src/core/processing/qgsprocessingutils.cpp b/src/core/processing/qgsprocessingutils.cpp index 46fbcf97e92..6198194dd69 100644 --- a/src/core/processing/qgsprocessingutils.cpp +++ b/src/core/processing/qgsprocessingutils.cpp @@ -908,14 +908,14 @@ QVariant QgsProcessingUtils::generateIteratingDestination( const QVariant &input } else if ( res.startsWith( QLatin1String( "memory:" ) ) ) { - return res + '_' + id.toString(); + return QString( res + '_' + id.toString() ); } else { // assume a filename type output for now // TODO - uris? int lastIndex = res.lastIndexOf( '.' ); - return res.left( lastIndex ) + '_' + id.toString() + res.mid( lastIndex ); + return QString( res.left( lastIndex ) + '_' + id.toString() + res.mid( lastIndex ) ); } } } diff --git a/src/core/qgsnetworkaccessmanager.h b/src/core/qgsnetworkaccessmanager.h index f5f22963cb8..97ca9ee06cb 100644 --- a/src/core/qgsnetworkaccessmanager.h +++ b/src/core/qgsnetworkaccessmanager.h @@ -38,8 +38,8 @@ class QgsFeedback; #include "qgsconfig.h" constexpr int sFilePrefixLength = CMAKE_SOURCE_DIR[sizeof( CMAKE_SOURCE_DIR ) - 1] == '/' ? sizeof( CMAKE_SOURCE_DIR ) + 1 : sizeof( CMAKE_SOURCE_DIR ); -#define QgsSetRequestInitiatorClass(request, _class) request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorClass ), _class ); request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), QString( __FILE__ ).mid( sFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" ); -#define QgsSetRequestInitiatorId(request, str) request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), QString( __FILE__ ).mid( sFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + "): " + str ); +#define QgsSetRequestInitiatorClass(request, _class) request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorClass ), _class ); request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), QString(QString( __FILE__ ).mid( sFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") ); +#define QgsSetRequestInitiatorId(request, str) request.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), QString(QString( __FILE__ ).mid( sFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + "): " + str) ); #endif /** diff --git a/src/core/symbology/qgscptcityarchive.cpp b/src/core/symbology/qgscptcityarchive.cpp index 7c0abe344a7..5b20320163d 100644 --- a/src/core/symbology/qgscptcityarchive.cpp +++ b/src/core/symbology/qgscptcityarchive.cpp @@ -138,7 +138,7 @@ QString QgsCptCityArchive::defaultBaseDir() // use CptCity/baseDir setting if set, default is user dir baseDir = settings.value( QStringLiteral( "CptCity/baseDir" ), - QgsApplication::pkgDataPath() + "/resources" ).toString(); + QString( QgsApplication::pkgDataPath() + "/resources" ) ).toString(); // sub-dir defaults to cpt-city archiveName = settings.value( QStringLiteral( "CptCity/archiveName" ), DEFAULT_CPTCITY_ARCHIVE ).toString(); @@ -447,7 +447,7 @@ void QgsCptCityArchive::initDefaultArchive() QgsSettings settings; // use CptCity/baseDir setting if set, default is user dir QString baseDir = settings.value( QStringLiteral( "CptCity/baseDir" ), - QgsApplication::pkgDataPath() + "/resources" ).toString(); + QString( QgsApplication::pkgDataPath() + "/resources" ) ).toString(); // sub-dir defaults to QString defArchiveName = settings.value( QStringLiteral( "CptCity/archiveName" ), DEFAULT_CPTCITY_ARCHIVE ).toString(); @@ -463,7 +463,7 @@ void QgsCptCityArchive::initArchives( bool loadAll ) // use CptCity/baseDir setting if set, default is user dir baseDir = settings.value( QStringLiteral( "CptCity/baseDir" ), - QgsApplication::pkgDataPath() + "/resources" ).toString(); + QString( QgsApplication::pkgDataPath() + "/resources" ) ).toString(); // sub-dir defaults to defArchiveName = settings.value( QStringLiteral( "CptCity/archiveName" ), DEFAULT_CPTCITY_ARCHIVE ).toString(); @@ -1312,7 +1312,7 @@ QgsCptCityBrowserModel::QgsCptCityBrowserModel( QObject *parent, , mViewType( viewType ) { Q_ASSERT( mArchive ); - QgsDebugMsg( "archiveName = " + archive->archiveName() + " viewType=" + static_cast< int >( viewType ) ); + QgsDebugMsg( QLatin1String( "archiveName = " ) + archive->archiveName() + " viewType=" + QString::number( static_cast< int >( viewType ) ) ); // keep iconsize for now, but not effectively used mIconSize = QSize( 100, 15 ); addRootItems(); @@ -1381,7 +1381,7 @@ QVariant QgsCptCityBrowserModel::data( const QModelIndex &index, int role ) cons { if ( item->type() == QgsCptCityDataItem::ColorRamp && mViewType == List ) - return item->path() + '\n' + item->info(); + return QString( item->path() + '\n' + item->info() ); return item->toolTip(); } else if ( role == Qt::DecorationRole && index.column() == 1 && diff --git a/src/core/vectortile/qgsmapboxglstyleconverter.cpp b/src/core/vectortile/qgsmapboxglstyleconverter.cpp index 782f6c3d121..2c6d75c7653 100644 --- a/src/core/vectortile/qgsmapboxglstyleconverter.cpp +++ b/src/core/vectortile/qgsmapboxglstyleconverter.cpp @@ -2303,7 +2303,7 @@ QString QgsMapBoxGlStyleConverter::parseExpression( const QVariantList &expressi { // ! inverts next expression's meaning QVariantList contraJsonExpr = expression.value( 1 ).toList(); - contraJsonExpr[0] = op + contraJsonExpr[0].toString(); + contraJsonExpr[0] = QString( op + contraJsonExpr[0].toString() ); // ['!', ['has', 'level']] -> ['!has', 'level'] return parseKey( contraJsonExpr ); } diff --git a/src/gui/locator/qgslocatorwidget.cpp b/src/gui/locator/qgslocatorwidget.cpp index 7192a2d0d2e..657fe5a833b 100644 --- a/src/gui/locator/qgslocatorwidget.cpp +++ b/src/gui/locator/qgslocatorwidget.cpp @@ -439,7 +439,7 @@ void QgsLocatorFilterFilter::fetchResults( const QString &string, const QgsLocat QgsLocatorResult result; result.displayString = filter->activePrefix(); result.description = filter->displayName(); - result.userData = filter->activePrefix() + ' '; + result.userData = QString( filter->activePrefix() + ' ' ); result.icon = QgsApplication::getThemeIcon( QStringLiteral( "/search.svg" ) ); emit resultFetched( result ); } diff --git a/src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp b/src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp index 717911cbcfa..338620756b9 100644 --- a/src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp +++ b/src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp @@ -165,7 +165,7 @@ QVariant QgsGraduatedSymbolRendererModel::data( const QModelIndex &index, int ro { int decimalPlaces = mRenderer->classificationMethod()->labelPrecision() + 2; if ( decimalPlaces < 0 ) decimalPlaces = 0; - return QLocale().toString( range.lowerValue(), 'f', decimalPlaces ) + " - " + QLocale().toString( range.upperValue(), 'f', decimalPlaces ); + return QString( QLocale().toString( range.lowerValue(), 'f', decimalPlaces ) + " - " + QLocale().toString( range.upperValue(), 'f', decimalPlaces ) ); } case 2: return range.label(); diff --git a/src/plugins/grass/qgsgrassmoduleinput.cpp b/src/plugins/grass/qgsgrassmoduleinput.cpp index 55e38baacb3..9487c56724c 100644 --- a/src/plugins/grass/qgsgrassmoduleinput.cpp +++ b/src/plugins/grass/qgsgrassmoduleinput.cpp @@ -332,7 +332,7 @@ QVariant QgsGrassModuleInputModel::data( const QModelIndex &index, int role ) co QString mapset = QStandardItemModel::data( index, QgsGrassModuleInputModel::MapsetRole ).toString(); if ( mapset != QgsGrass::getDefaultMapset() ) { - data = data.toString() + "@" + mapset; + data = QString( data.toString() + "@" + mapset ); } } } diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index c391627ae1d..b5471600355 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -4935,9 +4935,9 @@ QList QgsPostgresProvider::discoverRelations( const QgsVectorLayer " FROM pg_constraint c " " WHERE contype = 'f' " " AND c.conrelid::regclass = " + - QgsPostgresConn::quotedValue( QgsPostgresConn::quotedIdentifier( mSchemaName ) + + QgsPostgresConn::quotedValue( QString( QgsPostgresConn::quotedIdentifier( mSchemaName ) + '.' + - QgsPostgresConn::quotedIdentifier( mTableName ) ) + + QgsPostgresConn::quotedIdentifier( mTableName ) ) ) + "::regclass ) " "SELECT fk.conname as constraint_name, " " a.attname as column_name, " diff --git a/src/providers/wfs/qgswfsprovider.cpp b/src/providers/wfs/qgswfsprovider.cpp index b8a6a8b0992..541e342a079 100644 --- a/src/providers/wfs/qgswfsprovider.cpp +++ b/src/providers/wfs/qgswfsprovider.cpp @@ -185,7 +185,7 @@ void QgsWFSProviderSQLFunctionValidator::visit( const QgsSQLStatement::NodeFunct for ( const QgsWfsCapabilities::Function &f : constMSpatialPredicatesList ) { if ( n.name().compare( f.name, Qt::CaseInsensitive ) == 0 || - ( "ST_" + n.name() ).compare( f.name, Qt::CaseInsensitive ) == 0 ) + QString( "ST_" + n.name() ).compare( f.name, Qt::CaseInsensitive ) == 0 ) { foundMatch = true; } diff --git a/src/server/qgsserverogcapihandler.cpp b/src/server/qgsserverogcapihandler.cpp index 982146ede7a..3880508a4ef 100644 --- a/src/server/qgsserverogcapihandler.cpp +++ b/src/server/qgsserverogcapihandler.cpp @@ -287,7 +287,7 @@ void QgsServerOgcApiHandler::htmlDump( const json &data, const QgsServerApiConte { // Get the template directory and the file name QFileInfo pathInfo { path }; - Environment env { ( pathInfo.dir().path() + QDir::separator() ).toStdString() }; + Environment env { QString( pathInfo.dir().path() + QDir::separator() ).toStdString() }; // For template debugging: env.add_callback( "json_dump", 0, [ = ]( Arguments & ) diff --git a/tests/src/analysis/testqgsprocessing.cpp b/tests/src/analysis/testqgsprocessing.cpp index 60c16136e99..487e0618d48 100644 --- a/tests/src/analysis/testqgsprocessing.cpp +++ b/tests/src/analysis/testqgsprocessing.cpp @@ -2183,7 +2183,7 @@ void TestQgsProcessing::parameters() QVERIFY( context.temporaryLayerStore()->mapLayers().isEmpty() ); QString testDataDir = QStringLiteral( TEST_DATA_DIR ) + '/'; //defined in CmakeLists.txt - f.setAttribute( 0, testDataDir + "/raster/band1_float32_noct_epsg4326.tif" ); + f.setAttribute( 0, QString( testDataDir + "/raster/band1_float32_noct_epsg4326.tif" ) ); context.expressionContext().setFeature( f ); def->setName( QStringLiteral( "prop" ) ); QVERIFY( QgsProcessingParameters::parameterAsLayer( def.get(), params, context ) ); @@ -2648,8 +2648,8 @@ void TestQgsProcessing::parameterCrs() QCOMPARE( def->valueAsPythonString( "EPSG:12003", context ), QStringLiteral( "'EPSG:12003'" ) ); QCOMPARE( def->valueAsPythonString( "ProjectCrs", context ), QStringLiteral( "'ProjectCrs'" ) ); QCOMPARE( def->valueAsPythonString( QStringLiteral( "c:\\test\\new data\\test.dat" ), context ), QStringLiteral( "'c:\\\\test\\\\new data\\\\test.dat'" ) ); - QCOMPARE( def->valueAsPythonString( raster1, context ), QString( "'" ) + testDataDir + QStringLiteral( "landsat_4326.tif'" ) ); - QCOMPARE( def->valueAsPythonString( r1->id(), context ), QString( "'" ) + testDataDir + QStringLiteral( "landsat_4326.tif'" ) ); + QCOMPARE( def->valueAsPythonString( raster1, context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "landsat_4326.tif'" ) ) ); + QCOMPARE( def->valueAsPythonString( r1->id(), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "landsat_4326.tif'" ) ) ); QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) ); QCOMPARE( def->valueAsPythonString( "uri='complex' username=\"complex\"", context ), QStringLiteral( "'uri=\\'complex\\' username=\\\"complex\\\"'" ) ); @@ -2771,9 +2771,9 @@ void TestQgsProcessing::parameterMapLayer() QCOMPARE( QgsProcessingParameters::parameterAsLayer( def.get(), params, context ), v1 ); QCOMPARE( def->valueAsPythonString( QVariant(), context ), QStringLiteral( "None" ) ); - QCOMPARE( def->valueAsPythonString( raster1, context ), QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ); - QCOMPARE( def->valueAsPythonString( r1->id(), context ), QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ); - QCOMPARE( def->valueAsPythonString( QVariant::fromValue( r1 ), context ), QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ); + QCOMPARE( def->valueAsPythonString( raster1, context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ) ); + QCOMPARE( def->valueAsPythonString( r1->id(), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ) ); + QCOMPARE( def->valueAsPythonString( QVariant::fromValue( r1 ), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ) ); QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) ); QCOMPARE( def->valueAsPythonString( QStringLiteral( "c:\\test\\new data\\test.dat" ), context ), QStringLiteral( "'c:\\\\test\\\\new data\\\\test.dat'" ) ); @@ -2850,10 +2850,10 @@ void TestQgsProcessing::parameterMapLayer() QVERIFY( def->checkValueIsAcceptable( QVariant::fromValue( v1 ) ) ); pythonCode = def->asPythonString(); - QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMapLayer('optional', '', optional=True, defaultValue='" ) + v1->id() + "')" ); + QCOMPARE( pythonCode, QString( QStringLiteral( "QgsProcessingParameterMapLayer('optional', '', optional=True, defaultValue='" ) + v1->id() + "')" ) ); code = def->asScriptCode(); - QCOMPARE( code, QStringLiteral( "##optional=optional layer " ) + v1->id() ); + QCOMPARE( code, QString( QStringLiteral( "##optional=optional layer " ) + v1->id() ) ); fromCode.reset( dynamic_cast< QgsProcessingParameterMapLayer * >( QgsProcessingParameters::parameterFromScriptCode( code ) ) ); QVERIFY( fromCode.get() ); QCOMPARE( fromCode->name(), def->name() ); @@ -3139,9 +3139,9 @@ void TestQgsProcessing::parameterExtent() QCOMPARE( def->valueAsPythonString( QVariant(), context ), QStringLiteral( "None" ) ); QCOMPARE( def->valueAsPythonString( "1,2,3,4", context ), QStringLiteral( "'1,2,3,4'" ) ); - QCOMPARE( def->valueAsPythonString( r1->id(), context ), QString( "'" ) + testDataDir + QStringLiteral( "landsat_4326.tif'" ) ); - QCOMPARE( def->valueAsPythonString( QVariant::fromValue( r1 ), context ), QString( "'" ) + testDataDir + QStringLiteral( "landsat_4326.tif'" ) ); - QCOMPARE( def->valueAsPythonString( raster2, context ), QString( "'" ) + testDataDir + QStringLiteral( "landsat.tif'" ) ); + QCOMPARE( def->valueAsPythonString( r1->id(), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "landsat_4326.tif'" ) ) ); + QCOMPARE( def->valueAsPythonString( QVariant::fromValue( r1 ), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "landsat_4326.tif'" ) ) ); + QCOMPARE( def->valueAsPythonString( raster2, context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "landsat.tif'" ) ) ); QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) ); QCOMPARE( def->valueAsPythonString( QgsRectangle( 11, 12, 13, 14 ), context ), QStringLiteral( "'11, 13, 12, 14'" ) ); QCOMPARE( def->valueAsPythonString( QgsReferencedRectangle( QgsRectangle( 11, 12, 13, 14 ), QgsCoordinateReferenceSystem( "epsg:4326" ) ), context ), QStringLiteral( "'11, 13, 12, 14 [EPSG:4326]'" ) ); @@ -3929,9 +3929,9 @@ void TestQgsProcessing::parameterLayerList() QCOMPARE( def->valueAsPythonString( QVariant(), context ), QStringLiteral( "None" ) ); QCOMPARE( def->valueAsPythonString( "layer12312312", context ), QStringLiteral( "'layer12312312'" ) ); - QCOMPARE( def->valueAsPythonString( QVariant::fromValue( r1 ), context ), QStringLiteral( "['" ) + testDataDir + QStringLiteral( "tenbytenraster.asc']" ) ); - QCOMPARE( def->valueAsPythonString( r1->id(), context ), QStringLiteral( "['" ) + testDataDir + QStringLiteral( "tenbytenraster.asc']" ) ); - QCOMPARE( def->valueAsPythonString( QStringList() << r1->id() << raster2, context ), QStringLiteral( "['" ) + testDataDir + QStringLiteral( "tenbytenraster.asc','" ) + testDataDir + QStringLiteral( "landsat.tif']" ) ); + QCOMPARE( def->valueAsPythonString( QVariant::fromValue( r1 ), context ), QString( QStringLiteral( "['" ) + testDataDir + QStringLiteral( "tenbytenraster.asc']" ) ) ); + QCOMPARE( def->valueAsPythonString( r1->id(), context ), QString( QStringLiteral( "['" ) + testDataDir + QStringLiteral( "tenbytenraster.asc']" ) ) ); + QCOMPARE( def->valueAsPythonString( QStringList() << r1->id() << raster2, context ), QString( QStringLiteral( "['" ) + testDataDir + QStringLiteral( "tenbytenraster.asc','" ) + testDataDir + QStringLiteral( "landsat.tif']" ) ) ); QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) ); QCOMPARE( def->valueAsPythonString( "uri='complex' username=\"complex\"", context ), QStringLiteral( "'uri=\\'complex\\' username=\\\"complex\\\"'" ) ); @@ -3986,10 +3986,10 @@ void TestQgsProcessing::parameterLayerList() QCOMPARE( QgsProcessingParameters::parameterAsLayerList( def.get(), params, context ), QList< QgsMapLayer *>() << r1 ); pythonCode = def->asPythonString(); - QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMultipleLayers('optional', '', optional=True, layerType=QgsProcessing.TypeMapLayer, defaultValue='" ) + v1->id() + "')" ); + QCOMPARE( pythonCode, QString( QStringLiteral( "QgsProcessingParameterMultipleLayers('optional', '', optional=True, layerType=QgsProcessing.TypeMapLayer, defaultValue='" ) + v1->id() + "')" ) ); code = def->asScriptCode(); - QCOMPARE( code, QStringLiteral( "##optional=optional multiple vector " ) + v1->id() ); + QCOMPARE( code, QString( QStringLiteral( "##optional=optional multiple vector " ) + v1->id() ) ); fromCode.reset( dynamic_cast< QgsProcessingParameterMultipleLayers * >( QgsProcessingParameters::parameterFromScriptCode( code ) ) ); QVERIFY( fromCode.get() ); QCOMPARE( fromCode->name(), def->name() ); @@ -4008,16 +4008,16 @@ void TestQgsProcessing::parameterLayerList() QVERIFY( def->createFileFilter().contains( QStringLiteral( "*.*" ) ) ); pythonCode = def->asPythonString(); - QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMultipleLayers('optional', '', optional=True, layerType=QgsProcessing.TypeMapLayer, defaultValue=['" ) + r1->publicSource() + "'])" ); + QCOMPARE( pythonCode, QString( QStringLiteral( "QgsProcessingParameterMultipleLayers('optional', '', optional=True, layerType=QgsProcessing.TypeMapLayer, defaultValue=['" ) + r1->publicSource() + "'])" ) ); code = def->asScriptCode(); - QCOMPARE( code, QStringLiteral( "##optional=optional multiple vector " ) + v1->id() + "," + r1->publicSource() ); + QCOMPARE( code, QString( QStringLiteral( "##optional=optional multiple vector " ) + v1->id() + "," + r1->publicSource() ) ); fromCode.reset( dynamic_cast< QgsProcessingParameterMultipleLayers * >( QgsProcessingParameters::parameterFromScriptCode( code ) ) ); QVERIFY( fromCode.get() ); QCOMPARE( fromCode->name(), def->name() ); QCOMPARE( fromCode->description(), QStringLiteral( "optional" ) ); QCOMPARE( fromCode->flags(), def->flags() ); - QCOMPARE( fromCode->defaultValue().toString(), v1->id() + "," + r1->publicSource() ); + QCOMPARE( fromCode->defaultValue().toString(), QString( v1->id() + "," + r1->publicSource() ) ); QCOMPARE( fromCode->layerType(), QgsProcessing::TypeVectorAnyGeometry ); // optional with one default direct layer @@ -4676,9 +4676,9 @@ void TestQgsProcessing::parameterRasterLayer() QVERIFY( !QgsProcessingParameters::parameterAsRasterLayer( def.get(), params, context ) ); QCOMPARE( def->valueAsPythonString( QVariant(), context ), QStringLiteral( "None" ) ); - QCOMPARE( def->valueAsPythonString( raster1, context ), QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ); - QCOMPARE( def->valueAsPythonString( r1->id(), context ), QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ); - QCOMPARE( def->valueAsPythonString( QVariant::fromValue( r1 ), context ), QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ); + QCOMPARE( def->valueAsPythonString( raster1, context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ) ); + QCOMPARE( def->valueAsPythonString( r1->id(), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ) ); + QCOMPARE( def->valueAsPythonString( QVariant::fromValue( r1 ), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "tenbytenraster.asc'" ) ) ); QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) ); QCOMPARE( def->valueAsPythonString( QStringLiteral( "c:\\test\\new data\\test.dat" ), context ), QStringLiteral( "'c:\\\\test\\\\new data\\\\test.dat'" ) ); @@ -4709,10 +4709,10 @@ void TestQgsProcessing::parameterRasterLayer() QCOMPARE( QgsProcessingParameters::parameterAsRasterLayer( def.get(), params, context )->id(), r1->id() ); pythonCode = def->asPythonString(); - QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterRasterLayer('optional', '', optional=True, defaultValue='" ) + r1->id() + "')" ); + QCOMPARE( pythonCode, QString( QStringLiteral( "QgsProcessingParameterRasterLayer('optional', '', optional=True, defaultValue='" ) + r1->id() + "')" ) ); code = def->asScriptCode(); - QCOMPARE( code, QStringLiteral( "##optional=optional raster " ) + r1->id() ); + QCOMPARE( code, QString( QStringLiteral( "##optional=optional raster " ) + r1->id() ) ); fromCode.reset( dynamic_cast< QgsProcessingParameterRasterLayer * >( QgsProcessingParameters::parameterFromScriptCode( code ) ) ); QVERIFY( fromCode.get() ); QCOMPARE( fromCode->name(), def->name() ); @@ -5635,9 +5635,9 @@ void TestQgsProcessing::parameterVectorLayer() QVERIFY( !QgsProcessingParameters::parameterAsVectorLayer( def.get(), params, context ) ); QCOMPARE( def->valueAsPythonString( QVariant(), context ), QStringLiteral( "None" ) ); - QCOMPARE( def->valueAsPythonString( vector1, context ), QString( "'" ) + testDataDir + QStringLiteral( "multipoint.shp'" ) ); - QCOMPARE( def->valueAsPythonString( v1->id(), context ), QString( "'" ) + testDataDir + QStringLiteral( "multipoint.shp'" ) ); - QCOMPARE( def->valueAsPythonString( QVariant::fromValue( v1 ), context ), QString( "'" ) + testDataDir + QStringLiteral( "multipoint.shp'" ) ); + QCOMPARE( def->valueAsPythonString( vector1, context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "multipoint.shp'" ) ) ); + QCOMPARE( def->valueAsPythonString( v1->id(), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "multipoint.shp'" ) ) ); + QCOMPARE( def->valueAsPythonString( QVariant::fromValue( v1 ), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "multipoint.shp'" ) ) ); QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) ); QCOMPARE( def->valueAsPythonString( QStringLiteral( "c:\\test\\new data\\test.dat" ), context ), QStringLiteral( "'c:\\\\test\\\\new data\\\\test.dat'" ) ); @@ -5677,10 +5677,10 @@ void TestQgsProcessing::parameterVectorLayer() QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSourceDefinition( "layer1231123" ) ) ); pythonCode = def->asPythonString(); - QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterVectorLayer('optional', '', optional=True, defaultValue='" ) + v1->id() + "')" ); + QCOMPARE( pythonCode, QString( QStringLiteral( "QgsProcessingParameterVectorLayer('optional', '', optional=True, defaultValue='" ) + v1->id() + "')" ) ); code = def->asScriptCode(); - QCOMPARE( code, QStringLiteral( "##optional=optional vector " ) + v1->id() ); + QCOMPARE( code, QString( QStringLiteral( "##optional=optional vector " ) + v1->id() ) ); fromCode.reset( dynamic_cast< QgsProcessingParameterVectorLayer * >( QgsProcessingParameters::parameterFromScriptCode( code ) ) ); QVERIFY( fromCode.get() ); QCOMPARE( fromCode->name(), def->name() ); @@ -5764,9 +5764,9 @@ void TestQgsProcessing::parameterMeshLayer() QVERIFY( !QgsProcessingParameters::parameterAsVectorLayer( def.get(), params, context ) ); QCOMPARE( def->valueAsPythonString( QVariant(), context ), QStringLiteral( "None" ) ); - QCOMPARE( def->valueAsPythonString( mesh, context ), QString( "'" ) + testDataDir + QStringLiteral( "mesh/quad_and_triangle.2dm'" ) ); - QCOMPARE( def->valueAsPythonString( m1->id(), context ), QString( "'" ) + testDataDir + QStringLiteral( "mesh/quad_and_triangle.2dm'" ) ); - QCOMPARE( def->valueAsPythonString( QVariant::fromValue( m1 ), context ), QString( "'" ) + testDataDir + QStringLiteral( "mesh/quad_and_triangle.2dm'" ) ); + QCOMPARE( def->valueAsPythonString( mesh, context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "mesh/quad_and_triangle.2dm'" ) ) ); + QCOMPARE( def->valueAsPythonString( m1->id(), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "mesh/quad_and_triangle.2dm'" ) ) ); + QCOMPARE( def->valueAsPythonString( QVariant::fromValue( m1 ), context ), QString( QString( "'" ) + testDataDir + QStringLiteral( "mesh/quad_and_triangle.2dm'" ) ) ); QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) ); QCOMPARE( def->valueAsPythonString( QStringLiteral( "c:\\test\\new data\\test.2dm" ), context ), QStringLiteral( "'c:\\\\test\\\\new data\\\\test.2dm'" ) ); @@ -5806,10 +5806,10 @@ void TestQgsProcessing::parameterMeshLayer() QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSourceDefinition( "layer1231123" ) ) ); pythonCode = def->asPythonString(); - QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMeshLayer('optional', '', optional=True, defaultValue='" ) + m1->id() + "')" ); + QCOMPARE( pythonCode, QString( QStringLiteral( "QgsProcessingParameterMeshLayer('optional', '', optional=True, defaultValue='" ) + m1->id() + "')" ) ); code = def->asScriptCode(); - QCOMPARE( code, QStringLiteral( "##optional=optional mesh " ) + m1->id() ); + QCOMPARE( code, QString( QStringLiteral( "##optional=optional mesh " ) + m1->id() ) ); fromCode.reset( dynamic_cast< QgsProcessingParameterMeshLayer * >( QgsProcessingParameters::parameterFromScriptCode( code ) ) ); QVERIFY( fromCode.get() ); QCOMPARE( fromCode->name(), def->name() ); @@ -5977,9 +5977,9 @@ void TestQgsProcessing::parameterFeatureSource() QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSourceDefinition( "layer1231123" ) ) ); pythonCode = def->asPythonString(); - QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterFeatureSource('optional', '', optional=True, types=[QgsProcessing.TypeVectorAnyGeometry], defaultValue='" ) + v1->id() + "')" ); + QCOMPARE( pythonCode, QString( QStringLiteral( "QgsProcessingParameterFeatureSource('optional', '', optional=True, types=[QgsProcessing.TypeVectorAnyGeometry], defaultValue='" ) + v1->id() + "')" ) ); code = def->asScriptCode(); - QCOMPARE( code, QStringLiteral( "##optional=optional source " ) + v1->id() ); + QCOMPARE( code, QString( QStringLiteral( "##optional=optional source " ) + v1->id() ) ); fromCode.reset( dynamic_cast< QgsProcessingParameterFeatureSource * >( QgsProcessingParameters::parameterFromScriptCode( code ) ) ); QVERIFY( fromCode.get() ); QCOMPARE( fromCode->name(), def->name() ); @@ -8643,13 +8643,13 @@ void TestQgsProcessing::modelScope() pc.setProject( &p ); p.setFileName( TEST_DATA_DIR + QStringLiteral( "/test_file.qgs" ) ); scope.reset( QgsExpressionContextUtils::processingModelAlgorithmScope( &alg, params, pc ) ); - QCOMPARE( scope->variable( QStringLiteral( "model_path" ) ).toString(), QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/test_file.qgs" ) ); + QCOMPARE( scope->variable( QStringLiteral( "model_path" ) ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/test_file.qgs" ) ) ); QCOMPARE( scope->variable( QStringLiteral( "model_folder" ) ).toString(), QStringLiteral( TEST_DATA_DIR ) ); alg.setSourceFilePath( TEST_DATA_DIR + QStringLiteral( "/processing/my_model.model3" ) ); scope.reset( QgsExpressionContextUtils::processingModelAlgorithmScope( &alg, params, pc ) ); - QCOMPARE( scope->variable( QStringLiteral( "model_path" ) ).toString(), QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/processing/my_model.model3" ) ); - QCOMPARE( scope->variable( QStringLiteral( "model_folder" ) ).toString(), QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/processing" ) ); + QCOMPARE( scope->variable( QStringLiteral( "model_path" ) ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/processing/my_model.model3" ) ) ); + QCOMPARE( scope->variable( QStringLiteral( "model_folder" ) ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/processing" ) ) ); QgsExpressionContext ctx = alg.createExpressionContext( QVariantMap(), pc ); QVERIFY( scope->hasVariable( QStringLiteral( "model_path" ) ) ); @@ -10536,7 +10536,7 @@ void TestQgsProcessing::modelValidate() QCOMPARE( errors.at( 0 ), QStringLiteral( "Model input cc used for parameter INPUT does not exist" ) ); goodSource.setSource( QgsProcessingModelChildParameterSource::StaticValue ); - goodSource.setStaticValue( QStringLiteral( TEST_DATA_DIR ) + "/polys.shp" ); + goodSource.setStaticValue( QString( QStringLiteral( TEST_DATA_DIR ) + "/polys.shp" ) ); m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << goodSource ); QVERIFY( m.validateChildAlgorithm( QStringLiteral( "cx1" ), errors ) ); @@ -10836,7 +10836,7 @@ void TestQgsProcessing::convertCompatible() QVERIFY( gpkgLayer->isValid() ); out = QgsProcessingUtils::convertToCompatibleFormat( gpkgLayer.get(), false, QStringLiteral( "test" ), QStringList() << "gpkg" << "shp", QString( "shp" ), context, &feedback ); // layer must be translated -- we do not know if external tool can handle picking the correct layer automatically - QCOMPARE( out, testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ); + QCOMPARE( out, QString( testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ) ); gpkgPath = testDataDir + "points_gpkg.gpkg|layername=points_small"; gpkgLayer = qgis::make_unique< QgsVectorLayer >( gpkgPath, "vl" ); QVERIFY( gpkgLayer->isValid() ); @@ -10849,13 +10849,13 @@ void TestQgsProcessing::convertCompatible() QVERIFY( gpkgLayer->isValid() ); out = QgsProcessingUtils::convertToCompatibleFormatAndLayerName( gpkgLayer.get(), false, QStringLiteral( "test" ), QStringList() << "gpkg" << "shp", QString( "shp" ), context, &feedback, layerName ); // layer SHOULD NOT be translated -- in this case we know that the external tool can handle specifying the correct layer - QCOMPARE( out, testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ); + QCOMPARE( out, QString( testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ) ); QCOMPARE( layerName, QStringLiteral( "points_gpkg" ) ); gpkgPath = testDataDir + "points_gpkg.gpkg|layername=points_small"; gpkgLayer = qgis::make_unique< QgsVectorLayer >( gpkgPath, "vl" ); QVERIFY( gpkgLayer->isValid() ); out = QgsProcessingUtils::convertToCompatibleFormatAndLayerName( gpkgLayer.get(), false, QStringLiteral( "test" ), QStringList() << "gpkg" << "shp", QString( "shp" ), context, &feedback, layerName ); - QCOMPARE( out, testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ); + QCOMPARE( out, QString( testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ) ); QCOMPARE( layerName, QStringLiteral( "points_small" ) ); // also test evaluating parameter to compatible format @@ -10863,9 +10863,9 @@ void TestQgsProcessing::convertCompatible() QVariantMap params; params.insert( QStringLiteral( "source" ), QgsProcessingFeatureSourceDefinition( layer->id(), false ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath( def.get(), params, context, QStringList() << "shp", QString( "shp" ), &feedback ); - QCOMPARE( out, testDataDir + "points.shp" ); + QCOMPARE( out, QString( testDataDir + "points.shp" ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerName( def.get(), params, context, QStringList() << "shp", QString( "shp" ), &feedback, &layerName ); - QCOMPARE( out, testDataDir + "points.shp" ); + QCOMPARE( out, QString( testDataDir + "points.shp" ) ); QCOMPARE( layerName, QString() ); // incompatible format, will be converted @@ -10882,9 +10882,9 @@ void TestQgsProcessing::convertCompatible() // layer as input params.insert( QStringLiteral( "source" ), QVariant::fromValue( layer ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath( def.get(), params, context, QStringList() << "shp", QString( "shp" ), &feedback ); - QCOMPARE( out, testDataDir + "points.shp" ); + QCOMPARE( out, QString( testDataDir + "points.shp" ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerName( def.get(), params, context, QStringList() << "shp", QString( "shp" ), &feedback, &layerName ); - QCOMPARE( out, testDataDir + "points.shp" ); + QCOMPARE( out, QString( testDataDir + "points.shp" ) ); QCOMPARE( layerName, QString() ); // incompatible format, will be converted @@ -10935,9 +10935,9 @@ void TestQgsProcessing::convertCompatible() def.reset( new QgsProcessingParameterFeatureSource( QStringLiteral( "source" ), QString(), QList(), QVariant::fromValue( layer ) ) ); params.remove( QStringLiteral( "source" ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath( def.get(), params, context, QStringList() << "shp", QString( "shp" ), &feedback ); - QCOMPARE( out, testDataDir + "points.shp" ); + QCOMPARE( out, QString( testDataDir + "points.shp" ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerName( def.get(), params, context, QStringList() << "shp", QString( "shp" ), &feedback, &layerName ); - QCOMPARE( out, testDataDir + "points.shp" ); + QCOMPARE( out, QString( testDataDir + "points.shp" ) ); QCOMPARE( layerName, QString() ); // geopackage with layer @@ -10947,7 +10947,7 @@ void TestQgsProcessing::convertCompatible() params.insert( QStringLiteral( "source" ), QVariant::fromValue( gpkgLayer.get() ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath( def.get(), params, context, QStringList() << "gpkg" << "shp", QString( "shp" ), &feedback ); // layer must be translated -- we do not know if external tool can handle picking the correct layer automatically - QCOMPARE( out, testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ); + QCOMPARE( out, QString( testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ) ); gpkgPath = testDataDir + "points_gpkg.gpkg|layername=points_small"; gpkgLayer = qgis::make_unique< QgsVectorLayer >( gpkgPath, "vl" ); QVERIFY( gpkgLayer->isValid() ); @@ -10962,22 +10962,22 @@ void TestQgsProcessing::convertCompatible() params.insert( QStringLiteral( "source" ), QVariant::fromValue( gpkgLayer.get() ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerName( def.get(), params, context, QStringList() << "gpkg" << "shp", QString( "shp" ), &feedback, &layerName ); // layer SHOULD NOT be translated -- in this case we know that the external tool can handle specifying the correct layer - QCOMPARE( out, testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ); + QCOMPARE( out, QString( testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ) ); QCOMPARE( layerName, QStringLiteral( "points_gpkg" ) ); gpkgPath = testDataDir + "points_gpkg.gpkg|layername=points_small"; gpkgLayer = qgis::make_unique< QgsVectorLayer >( gpkgPath, "vl" ); QVERIFY( gpkgLayer->isValid() ); params.insert( QStringLiteral( "source" ), QVariant::fromValue( gpkgLayer.get() ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerName( def.get(), params, context, QStringList() << "gpkg" << "shp", QString( "shp" ), &feedback, &layerName ); - QCOMPARE( out, testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ); + QCOMPARE( out, QString( testDataDir + QStringLiteral( "points_gpkg.gpkg" ) ) ); QCOMPARE( layerName, QStringLiteral( "points_small" ) ); // output layer as input - e.g. from a previous model child params.insert( QStringLiteral( "source" ), QgsProcessingOutputLayerDefinition( layer->id() ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath( def.get(), params, context, QStringList() << "shp", QString( "shp" ), &feedback ); - QCOMPARE( out, testDataDir + "points.shp" ); + QCOMPARE( out, QString( testDataDir + "points.shp" ) ); out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerName( def.get(), params, context, QStringList() << "shp", QString( "shp" ), &feedback, &layerName ); - QCOMPARE( out, testDataDir + "points.shp" ); + QCOMPARE( out, QString( testDataDir + "points.shp" ) ); QCOMPARE( layerName, QString() ); } diff --git a/tests/src/analysis/testqgsprocessingalgs.cpp b/tests/src/analysis/testqgsprocessingalgs.cpp index a8555a03308..dff5ccd4482 100644 --- a/tests/src/analysis/testqgsprocessingalgs.cpp +++ b/tests/src/analysis/testqgsprocessingalgs.cpp @@ -261,7 +261,7 @@ void TestQgsProcessingAlgs::saveFeaturesAlg() QString dataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt QVariantMap parameters; - parameters.insert( QStringLiteral( "INPUT" ), dataDir + "/points.shp" ); + parameters.insert( QStringLiteral( "INPUT" ), QString( dataDir + "/points.shp" ) ); parameters.insert( QStringLiteral( "LAYER_NAME" ), layerName ); parameters.insert( QStringLiteral( "LAYER_OPTIONS" ), QStringLiteral( "COORDINATE_PRECISION=1" ) ); parameters.insert( QStringLiteral( "OUTPUT" ), outputGeoJson ); @@ -1667,7 +1667,7 @@ void TestQgsProcessingAlgs::fillNoData() QVariantMap parameters; - parameters.insert( QStringLiteral( "INPUT" ), myDataPath + inputRaster ); + parameters.insert( QStringLiteral( "INPUT" ), QString( myDataPath + inputRaster ) ); parameters.insert( QStringLiteral( "BAND" ), inputBand ); parameters.insert( QStringLiteral( "FILL_VALUE" ), fillValue ); parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); @@ -2337,7 +2337,7 @@ void TestQgsProcessingAlgs::cellStatistics() parameters.insert( QStringLiteral( "INPUT" ), inputDatasetPaths ); parameters.insert( QStringLiteral( "STATISTIC" ), statistic ); parameters.insert( QStringLiteral( "IGNORE_NODATA" ), ignoreNoData ); - parameters.insert( QStringLiteral( "REFERENCE_LAYER" ), myDataPath + referenceLayer ); + parameters.insert( QStringLiteral( "REFERENCE_LAYER" ), QString( myDataPath + referenceLayer ) ); parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster @@ -2578,7 +2578,7 @@ void TestQgsProcessingAlgs::rasterFrequencyByComparisonOperator() QVariantMap parameters; - parameters.insert( QStringLiteral( "INPUT_VALUE_RASTER" ), myDataPath + inputValueRaster ); + parameters.insert( QStringLiteral( "INPUT_VALUE_RASTER" ), QString( myDataPath + inputValueRaster ) ); parameters.insert( QStringLiteral( "INPUT_VALUE_RASTER_BAND" ), inputValueRasterBand ); parameters.insert( QStringLiteral( "INPUT_RASTERS" ), inputDatasetPaths ); parameters.insert( QStringLiteral( "IGNORE_NODATA" ), ignoreNoData ); @@ -2724,7 +2724,7 @@ void TestQgsProcessingAlgs::rasterLocalPosition() QVariantMap parameters; parameters.insert( QStringLiteral( "INPUT_RASTERS" ), inputDatasetPaths ); - parameters.insert( QStringLiteral( "REFERENCE_LAYER" ), myDataPath + referenceRaster ); + parameters.insert( QStringLiteral( "REFERENCE_LAYER" ), QString( myDataPath + referenceRaster ) ); parameters.insert( QStringLiteral( "IGNORE_NODATA" ), ignoreNoData ); parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); @@ -2946,7 +2946,7 @@ void TestQgsProcessingAlgs::roundRasterValues() QVariantMap parameters; - parameters.insert( QStringLiteral( "INPUT" ), myDataPath + inputRaster ); + parameters.insert( QStringLiteral( "INPUT" ), QString( myDataPath + inputRaster ) ); parameters.insert( QStringLiteral( "BAND" ), inputBand ); parameters.insert( QStringLiteral( "ROUNDING_DIRECTION" ), roundingDirection ); parameters.insert( QStringLiteral( "DECIMAL_PLACES" ), decimals ); @@ -3761,21 +3761,21 @@ void TestQgsProcessingAlgs::shapefileEncoding() QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); - parameters.insert( QStringLiteral( "INPUT" ), QStringLiteral( TEST_DATA_DIR ) + "/shapefile/iso-8859-1.shp" ); + parameters.insert( QStringLiteral( "INPUT" ), QString( QStringLiteral( TEST_DATA_DIR ) + "/shapefile/iso-8859-1.shp" ) ); results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QCOMPARE( results.value( QStringLiteral( "ENCODING" ) ).toString(), QStringLiteral( "ISO-8859-1" ) ); QCOMPARE( results.value( QStringLiteral( "CPG_ENCODING" ) ).toString(), QStringLiteral( "ISO-8859-1" ) ); QCOMPARE( results.value( QStringLiteral( "LDID_ENCODING" ) ).toString(), QString() ); - parameters.insert( QStringLiteral( "INPUT" ), QStringLiteral( TEST_DATA_DIR ) + "/shapefile/windows-1252_ldid.shp" ); + parameters.insert( QStringLiteral( "INPUT" ), QString( QStringLiteral( TEST_DATA_DIR ) + "/shapefile/windows-1252_ldid.shp" ) ); results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QCOMPARE( results.value( QStringLiteral( "ENCODING" ) ).toString(), QStringLiteral( "CP1252" ) ); QCOMPARE( results.value( QStringLiteral( "CPG_ENCODING" ) ).toString(), QString() ); QCOMPARE( results.value( QStringLiteral( "LDID_ENCODING" ) ).toString(), QStringLiteral( "CP1252" ) ); - parameters.insert( QStringLiteral( "INPUT" ), QStringLiteral( TEST_DATA_DIR ) + "/shapefile/system_encoding.shp" ); + parameters.insert( QStringLiteral( "INPUT" ), QString( QStringLiteral( TEST_DATA_DIR ) + "/shapefile/system_encoding.shp" ) ); results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QCOMPARE( results.value( QStringLiteral( "ENCODING" ) ).toString(), QString() ); @@ -4722,7 +4722,7 @@ void TestQgsProcessingAlgs::exportAtlasLayoutPng() QVariantMap parameters; parameters.insert( QStringLiteral( "LAYOUT" ), QStringLiteral( "my layout" ) ); parameters.insert( QStringLiteral( "COVERAGE_LAYER" ), QVariant::fromValue( polygonLayer ) ); - parameters.insert( QStringLiteral( "FOLDER" ), QDir::tempPath() + "/my_atlas" ); + parameters.insert( QStringLiteral( "FOLDER" ), QString( QDir::tempPath() + "/my_atlas" ) ); parameters.insert( QStringLiteral( "FILENAME_EXPRESSION" ), QStringLiteral( "'export_'||@atlas_featurenumber" ) ); parameters.insert( QStringLiteral( "DPI" ), 96 ); @@ -4774,7 +4774,7 @@ void TestQgsProcessingAlgs::tinMeshCreation() QVariantMap parameters; parameters.insert( QStringLiteral( "SOURCE_DATA" ), inputLayers ); - parameters.insert( QStringLiteral( "OUTPUT_MESH" ), QDir::tempPath() + "/meshLayer.2dm" ); + parameters.insert( QStringLiteral( "OUTPUT_MESH" ), QString( QDir::tempPath() + "/meshLayer.2dm" ) ); parameters.insert( QStringLiteral( "MESH_FORMAT" ), 0 ); std::unique_ptr< QgsProcessingContext > context = qgis::make_unique< QgsProcessingContext >(); diff --git a/tests/src/core/testqgslayoutmapgrid.cpp b/tests/src/core/testqgslayoutmapgrid.cpp index 31e03721e4a..f438548eb59 100644 --- a/tests/src/core/testqgslayoutmapgrid.cpp +++ b/tests/src/core/testqgslayoutmapgrid.cpp @@ -1225,23 +1225,23 @@ void TestQgsLayoutMapGrid::annotationFormats() QgsExpressionContext expressionContext = gridGeographic.createExpressionContext(); //normal e/w - QCOMPARE( gridGeographic.gridAnnotationString( 90, QgsLayoutItemMapGrid::Longitude, expressionContext ), QString( "90.0" ) + QChar( 176 ) + QString( "E" ) ); + QCOMPARE( gridGeographic.gridAnnotationString( 90, QgsLayoutItemMapGrid::Longitude, expressionContext ), QString( "90.0°E" ) ); QCOMPARE( gridProjected.gridAnnotationString( 90, QgsLayoutItemMapGrid::Longitude, expressionContext ), QString( "90.0E" ) ); //0 degrees - QCOMPARE( gridGeographic.gridAnnotationString( 0, QgsLayoutItemMapGrid::Longitude, expressionContext ), QString( "0.0" ) + QChar( 176 ) ); + QCOMPARE( gridGeographic.gridAnnotationString( 0, QgsLayoutItemMapGrid::Longitude, expressionContext ), QString( "0.0°" ) ); QCOMPARE( gridProjected.gridAnnotationString( 0, QgsLayoutItemMapGrid::Longitude, expressionContext ), QString( "0.0E" ) ); //180 degrees - QCOMPARE( gridGeographic.gridAnnotationString( 180, QgsLayoutItemMapGrid::Longitude, expressionContext ), QString( "180.0" ) + QChar( 176 ) ); + QCOMPARE( gridGeographic.gridAnnotationString( 180, QgsLayoutItemMapGrid::Longitude, expressionContext ), QString( "180.0°" ) ); QCOMPARE( gridProjected.gridAnnotationString( 180, QgsLayoutItemMapGrid::Longitude, expressionContext ), QString( "180.0E" ) ); //normal n/s - QCOMPARE( gridGeographic.gridAnnotationString( 45, QgsLayoutItemMapGrid::Latitude, expressionContext ), QString( "45.0" ) + QChar( 176 ) + QString( "N" ) ); + QCOMPARE( gridGeographic.gridAnnotationString( 45, QgsLayoutItemMapGrid::Latitude, expressionContext ), QString( "45.0°N" ) ); QCOMPARE( gridProjected.gridAnnotationString( 45, QgsLayoutItemMapGrid::Latitude, expressionContext ), QString( "45.0N" ) ); //0 north/south - QCOMPARE( gridGeographic.gridAnnotationString( 0, QgsLayoutItemMapGrid::Latitude, expressionContext ), QString( "0.0" ) + QChar( 176 ) ); + QCOMPARE( gridGeographic.gridAnnotationString( 0, QgsLayoutItemMapGrid::Latitude, expressionContext ), QString( "0.0°" ) ); QCOMPARE( gridProjected.gridAnnotationString( 0, QgsLayoutItemMapGrid::Latitude, expressionContext ), QString( "0.0N" ) ); //Custom format annotations diff --git a/tests/src/core/testqgsproject.cpp b/tests/src/core/testqgsproject.cpp index fc18d1b3c69..9b82c5c8109 100644 --- a/tests/src/core/testqgsproject.cpp +++ b/tests/src/core/testqgsproject.cpp @@ -150,7 +150,7 @@ void TestQgsProject::testPathResolver() QVERIFY( testFile.open( QIODevice::WriteOnly | QIODevice::Text ) ); testFile.close(); QVERIFY( QFile::exists( fi.path() + QStringLiteral( "/file1.txt" ) ) ); - QCOMPARE( tempRel.readPath( "file1.txt" ), fi.path() + QStringLiteral( "/file1.txt" ) ); + QCOMPARE( tempRel.readPath( "file1.txt" ), QString( fi.path() + QStringLiteral( "/file1.txt" ) ) ); QgsPathResolver resolverAbs; QCOMPARE( resolverAbs.writePath( "/home/qgis/file1.txt" ), QString( "/home/qgis/file1.txt" ) ); @@ -269,7 +269,7 @@ void TestQgsProject::testPathResolverSvg() project.write( projectFilename ); // make sure the path resolver works with relative paths (enabled by default) - QCOMPARE( project.pathResolver().readPath( "./a.txt" ), dirPath + "/a.txt" ); + QCOMPARE( project.pathResolver().readPath( "./a.txt" ), QString( dirPath + "/a.txt" ) ); QCOMPARE( project.pathResolver().writePath( dirPath + "/a.txt" ), QString( "./a.txt" ) ); // check that the saved paths are relative diff --git a/tests/src/core/testqgsziputils.cpp b/tests/src/core/testqgsziputils.cpp index 11fad10d1e7..f17daa29d80 100644 --- a/tests/src/core/testqgsziputils.cpp +++ b/tests/src/core/testqgsziputils.cpp @@ -113,7 +113,7 @@ void TestQgsZipUtils::testZip() QVERIFY( QgsZipUtils::zip( zipDirPath + "/special_zip æì.zip", QStringList() << txtFile ) ); QVERIFY( QgsZipUtils::unzip( zipDirPath + "/special_zip æì.zip", zipDirPath, files ) ); QCOMPARE( files.count(), 1 ); - QCOMPARE( files.at( 0 ), zipDirPath + "/aæýì.txt" ); + QCOMPARE( files.at( 0 ), QString( zipDirPath + "/aæýì.txt" ) ); QVERIFY( QFile::exists( zipDirPath + "/aæýì.txt" ) ); } diff --git a/tests/src/gui/testprocessinggui.cpp b/tests/src/gui/testprocessinggui.cpp index a7e700f9cd3..13fdd83ad19 100644 --- a/tests/src/gui/testprocessinggui.cpp +++ b/tests/src/gui/testprocessinggui.cpp @@ -1144,10 +1144,10 @@ void TestProcessingGui::testFileWrapper() QWidget *w = wrapper.createWrappedWidget( context ); QSignalSpy spy( &wrapper, &QgsProcessingFileWidgetWrapper::widgetValueHasChanged ); - wrapper.setWidgetValue( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), context ); + wrapper.setWidgetValue( QString( TEST_DATA_DIR + QStringLiteral( "/points.shp" ) ), context ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().toString(), TEST_DATA_DIR + QStringLiteral( "/points.shp" ) ); - QCOMPARE( static_cast< QgsFileWidget * >( wrapper.wrappedWidget() )->filePath(), TEST_DATA_DIR + QStringLiteral( "/points.shp" ) ); + QCOMPARE( wrapper.widgetValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/points.shp" ) ) ); + QCOMPARE( static_cast< QgsFileWidget * >( wrapper.wrappedWidget() )->filePath(), QString( TEST_DATA_DIR + QStringLiteral( "/points.shp" ) ) ); QCOMPARE( static_cast< QgsFileWidget * >( wrapper.wrappedWidget() )->filter(), QStringLiteral( "All files (*.*)" ) ); QCOMPARE( static_cast< QgsFileWidget * >( wrapper.wrappedWidget() )->storageMode(), QgsFileWidget::GetFile ); wrapper.setWidgetValue( QString(), context ); @@ -3213,27 +3213,27 @@ void TestProcessingGui::testMultipleFileSelectionDialog() QCOMPARE( dlg->selectedOptions().size(), 1 ); QCOMPARE( dlg->selectedOptions().at( 0 ).toString(), raster->source() ); // existing value using full layer path not matching a project layer should work - dlg = qgis::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList() << raster->source() << QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif", QList() ); + dlg = qgis::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList() << raster->source() << QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 2 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "raster [EPSG:4326]" ) ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), raster->source() ); - QCOMPARE( dlg->mModel->data( dlg->mModel->index( 1, 0 ) ).toString(), QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ); - QCOMPARE( dlg->mModel->data( dlg->mModel->index( 1, 0 ), Qt::UserRole ).toString(), QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ); + QCOMPARE( dlg->mModel->data( dlg->mModel->index( 1, 0 ) ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) ); + QCOMPARE( dlg->mModel->data( dlg->mModel->index( 1, 0 ), Qt::UserRole ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) ); QCOMPARE( dlg->selectedOptions().size(), 2 ); QCOMPARE( dlg->selectedOptions().at( 0 ).toString(), raster->source() ); - QCOMPARE( dlg->selectedOptions().at( 1 ).toString(), QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ); + QCOMPARE( dlg->selectedOptions().at( 1 ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) ); // should remember layer order - dlg = qgis::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList() << QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" << raster->source(), QList() ); + dlg = qgis::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList() << QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) << raster->source(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 2 ); - QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ); - QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ); + QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) ); + QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 1, 0 ) ).toString(), QStringLiteral( "raster [EPSG:4326]" ) ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 1, 0 ), Qt::UserRole ).toString(), raster->source() ); QCOMPARE( dlg->selectedOptions().size(), 2 ); - QCOMPARE( dlg->selectedOptions().at( 0 ).toString(), QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ); + QCOMPARE( dlg->selectedOptions().at( 0 ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) ); QCOMPARE( dlg->selectedOptions().at( 1 ).toString(), raster->source() ); // mesh @@ -7866,7 +7866,7 @@ void TestProcessingGui::testOutputDefinitionWidget() v = panel.value(); QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() ); QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), TEST_DATA_DIR + QStringLiteral( "/test.shp" ) ); + QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.shp" ) ) ); // optional, test skipping sink.setFlags( sink.flags() | QgsProcessingParameterDefinition::FlagOptional ); @@ -8041,7 +8041,7 @@ void TestProcessingGui::testOutputDefinitionWidgetVectorOut() v = panel.value(); QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() ); QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "System" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), TEST_DATA_DIR + QStringLiteral( "/test.shp" ) ); + QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.shp" ) ) ); // optional, test skipping vector.setFlags( vector.flags() | QgsProcessingParameterDefinition::FlagOptional ); @@ -8154,7 +8154,7 @@ void TestProcessingGui::testOutputDefinitionWidgetRasterOut() v = panel.value(); QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() ); QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "System" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), TEST_DATA_DIR + QStringLiteral( "/test.tif" ) ); + QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.tif" ) ) ); // optional, test skipping raster.setFlags( raster.flags() | QgsProcessingParameterDefinition::FlagOptional ); @@ -8260,7 +8260,7 @@ void TestProcessingGui::testOutputDefinitionWidgetFolder() settings.setValue( QStringLiteral( "/Processing/Configuration/OUTPUTS_FOLDER" ), TEST_DATA_DIR ); panel.setValue( QStringLiteral( "mystuff" ) ); v = panel.value(); - QCOMPARE( v.toString(), TEST_DATA_DIR + QStringLiteral( "/mystuff" ) ); + QCOMPARE( v.toString(), QString( TEST_DATA_DIR + QStringLiteral( "/mystuff" ) ) ); // optional, test skipping folder.setFlags( folder.flags() | QgsProcessingParameterDefinition::FlagOptional ); @@ -8361,7 +8361,7 @@ void TestProcessingGui::testOutputDefinitionWidgetFileOut() settings.setValue( QStringLiteral( "/Processing/Configuration/OUTPUTS_FOLDER" ), TEST_DATA_DIR ); panel.setValue( QStringLiteral( "test.tif" ) ); v = panel.value(); - QCOMPARE( v.toString(), TEST_DATA_DIR + QStringLiteral( "/test.tif" ) ); + QCOMPARE( v.toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.tif" ) ) ); // optional, test skipping file.setFlags( file.flags() | QgsProcessingParameterDefinition::FlagOptional ); diff --git a/tests/src/gui/testqgsfilewidget.cpp b/tests/src/gui/testqgsfilewidget.cpp index d2d5debd308..6717d761966 100644 --- a/tests/src/gui/testqgsfilewidget.cpp +++ b/tests/src/gui/testqgsfilewidget.cpp @@ -104,7 +104,7 @@ void TestQgsFileWidget::testDroppedFiles() mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ); + QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) ); // also should support files dragged from browser mime->setUrls( QList() ); @@ -115,7 +115,7 @@ void TestQgsFileWidget::testDroppedFiles() mime.reset( QgsMimeDataUtils::encodeUriList( uriList ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ); + QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ) ); QgsBrowserModel m; m.initialize(); @@ -124,14 +124,14 @@ void TestQgsFileWidget::testDroppedFiles() mime.reset( m.mimeData( QModelIndexList() << m.findItem( layerItem ) ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh/quad_and_triangle.txt" ) ); + QCOMPARE( w->lineEdit()->text(), QString( QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh/quad_and_triangle.txt" ) ) ); // plain text should also be permitted mime = qgis::make_unique< QMimeData >(); mime->setText( TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ); + QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ) ); mime.reset( new QMimeData() ); mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) ); @@ -140,7 +140,7 @@ void TestQgsFileWidget::testDroppedFiles() w->setFilter( QStringLiteral( "Data (*.shp)" ) ); w->setFilePath( QString() ); qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ); + QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) ); w->setFilePath( QString() ); // should be rejected, not compatible with filter mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/encoded_html.html" ) ) ); @@ -150,14 +150,14 @@ void TestQgsFileWidget::testDroppedFiles() // new filter, should be allowed now w->setFilter( QStringLiteral( "Data (*.shp);;HTML (*.HTML)" ) ); qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), TEST_DATA_DIR + QStringLiteral( "/encoded_html.html" ) ); + QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/encoded_html.html" ) ) ); //try with wildcard filter w->setFilter( QStringLiteral( "All files (*.*);;Data (*.shp);;HTML (*.HTML)" ) ); mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.prj" ) ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), TEST_DATA_DIR + QStringLiteral( "/bug5598.prj" ) ); + QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/bug5598.prj" ) ) ); // try with folders w->setStorageMode( QgsFileWidget::GetDirectory ); @@ -166,7 +166,7 @@ void TestQgsFileWidget::testDroppedFiles() mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh" ) ); + QCOMPARE( w->lineEdit()->text(), QString( QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh" ) ) ); // but dropping a folder should work mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR ) ); @@ -180,7 +180,7 @@ void TestQgsFileWidget::testDroppedFiles() mime.reset( m.mimeData( QModelIndexList() << m.findItem( dirItem ) ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh" ) ); + QCOMPARE( w->lineEdit()->text(), QString( QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh" ) ) ); } void TestQgsFileWidget::testMultipleFiles() diff --git a/tests/src/gui/testqgsnewdatabasetablewidget.cpp b/tests/src/gui/testqgsnewdatabasetablewidget.cpp index 72666c18743..82c7d892aa9 100644 --- a/tests/src/gui/testqgsnewdatabasetablewidget.cpp +++ b/tests/src/gui/testqgsnewdatabasetablewidget.cpp @@ -273,7 +273,7 @@ void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsGeopackage() QCOMPARE( w->table(), QString( "newTableName" ) ); QCOMPARE( w->schema(), mGpkgPath ); QCOMPARE( w->dataProviderKey(), QString( "ogr" ) ); - QCOMPARE( w->uri(), mGpkgPath + QStringLiteral( "|layername=newTableName" ) ); + QCOMPARE( w->uri(), QString( mGpkgPath + QStringLiteral( "|layername=newTableName" ) ) ); #endif }