diff --git a/src/3d/chunks/qgschunkedentity_p.cpp b/src/3d/chunks/qgschunkedentity_p.cpp index e12067df7462..bdd7a273d9b4 100644 --- a/src/3d/chunks/qgschunkedentity_p.cpp +++ b/src/3d/chunks/qgschunkedentity_p.cpp @@ -131,7 +131,7 @@ void QgsChunkedEntity::update( const SceneState &state ) int oldJobsCount = pendingJobsCount(); - QSet activeBefore = QSet::fromList( mActiveNodes ); + QSet activeBefore = qgis::listToSet( mActiveNodes ); mActiveNodes.clear(); mFrustumCulled = 0; mCurrentTime = QTime::currentTime(); diff --git a/src/3d/qgs3dmapscene.cpp b/src/3d/qgs3dmapscene.cpp index cf3041896db2..dc09be0a487a 100644 --- a/src/3d/qgs3dmapscene.cpp +++ b/src/3d/qgs3dmapscene.cpp @@ -516,7 +516,7 @@ void Qgs3DMapScene::onLayerRenderer3DChanged() void Qgs3DMapScene::onLayersChanged() { - QSet layersBefore = QSet::fromList( mLayerEntities.keys() ); + QSet layersBefore = qgis::listToSet( mLayerEntities.keys() ); QList layersAdded; Q_FOREACH ( QgsMapLayer *layer, mMap.layers() ) { diff --git a/src/analysis/network/qgsvectorlayerdirector.cpp b/src/analysis/network/qgsvectorlayerdirector.cpp index d020adde8fb9..13b3883fc660 100644 --- a/src/analysis/network/qgsvectorlayerdirector.cpp +++ b/src/analysis/network/qgsvectorlayerdirector.cpp @@ -85,7 +85,7 @@ QgsAttributeList QgsVectorLayerDirector::requiredAttributes() const { attrs.unite( strategy->requiredAttributes() ); } - return attrs.toList(); + return qgis::setToList( attrs ); } QgsVectorLayerDirector::Direction QgsVectorLayerDirector::directionForFeature( const QgsFeature &feature ) const diff --git a/src/analysis/processing/qgsalgorithmcategorizeusingstyle.cpp b/src/analysis/processing/qgsalgorithmcategorizeusingstyle.cpp index 83f987106d1d..96879699e004 100644 --- a/src/analysis/processing/qgsalgorithmcategorizeusingstyle.cpp +++ b/src/analysis/processing/qgsalgorithmcategorizeusingstyle.cpp @@ -204,7 +204,7 @@ QVariantMap QgsCategorizeUsingStyleAlgorithm::processAlgorithm( const QVariantMa uniqueVals << value; } - QVariantList sortedUniqueVals = uniqueVals.toList(); + QVariantList sortedUniqueVals = qgis::setToList( uniqueVals ); std::sort( sortedUniqueVals.begin(), sortedUniqueVals.end() ); QgsCategoryList cats; diff --git a/src/analysis/processing/qgsalgorithmdeleteduplicategeometries.cpp b/src/analysis/processing/qgsalgorithmdeleteduplicategeometries.cpp index 20f8e25b832a..d0c22258afed 100644 --- a/src/analysis/processing/qgsalgorithmdeleteduplicategeometries.cpp +++ b/src/analysis/processing/qgsalgorithmdeleteduplicategeometries.cpp @@ -164,7 +164,7 @@ QVariantMap QgsDeleteDuplicateGeometriesAlgorithm::processAlgorithm( const QVari // now, fetch all the feature attributes for the unique features only // be super-smart and don't re-fetch geometries - QSet< QgsFeatureId > outputFeatureIds = uniqueFeatures.keys().toSet(); + QSet< QgsFeatureId > outputFeatureIds = qgis::listToSet( uniqueFeatures.keys() ); outputFeatureIds.unite( nullGeometryFeatures ); step = outputFeatureIds.empty() ? 1 : 100.0 / outputFeatureIds.size(); diff --git a/src/analysis/processing/qgsalgorithmlineintersection.cpp b/src/analysis/processing/qgsalgorithmlineintersection.cpp index 3380cb403663..9f6fd8287fcf 100644 --- a/src/analysis/processing/qgsalgorithmlineintersection.cpp +++ b/src/analysis/processing/qgsalgorithmlineintersection.cpp @@ -125,7 +125,7 @@ QVariantMap QgsLineIntersectionAlgorithm::processAlgorithm( const QVariantMap &p continue; QgsGeometry inGeom = inFeatureA.geometry(); - QgsFeatureIds lines = spatialIndex.intersects( inGeom.boundingBox() ).toSet(); + QgsFeatureIds lines = qgis::listToSet( spatialIndex.intersects( inGeom.boundingBox() ) ); if ( !lines.empty() ) { // use prepared geometries for faster intersection tests diff --git a/src/analysis/processing/qgsalgorithmrandomextract.cpp b/src/analysis/processing/qgsalgorithmrandomextract.cpp index 9be79992481c..23825a306285 100644 --- a/src/analysis/processing/qgsalgorithmrandomextract.cpp +++ b/src/analysis/processing/qgsalgorithmrandomextract.cpp @@ -121,7 +121,7 @@ QVariantMap QgsRandomExtractAlgorithm::processAlgorithm( const QVariantMap ¶ idsCount[ id ] += 1; } - QgsFeatureIds ids = QSet< QgsFeatureId >::fromList( idsCount.keys() ); + QgsFeatureIds ids = qgis::listToSet( idsCount.keys() ); QgsFeatureIterator fit = source->getFeatures( QgsFeatureRequest().setFilterFids( ids ), QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks ); QgsFeature f; diff --git a/src/analysis/processing/qgsalgorithmserviceareafromlayer.cpp b/src/analysis/processing/qgsalgorithmserviceareafromlayer.cpp index a06b8ba410ad..b36507a681c3 100644 --- a/src/analysis/processing/qgsalgorithmserviceareafromlayer.cpp +++ b/src/analysis/processing/qgsalgorithmserviceareafromlayer.cpp @@ -199,7 +199,7 @@ QVariantMap QgsServiceAreaFromLayerAlgorithm::processAlgorithm( const QVariantMa } // costs // convert to list and sort to maintain same order of points between algorithm runs - QList< int > verticesList = vertices.toList(); + QList< int > verticesList = qgis::setToList( vertices ); areaPoints.reserve( verticesList.size() ); std::sort( verticesList.begin(), verticesList.end() ); for ( int v : verticesList ) diff --git a/src/analysis/processing/qgsalgorithmserviceareafrompoint.cpp b/src/analysis/processing/qgsalgorithmserviceareafrompoint.cpp index 4d40a7595d50..2431727e9342 100644 --- a/src/analysis/processing/qgsalgorithmserviceareafrompoint.cpp +++ b/src/analysis/processing/qgsalgorithmserviceareafrompoint.cpp @@ -164,7 +164,7 @@ QVariantMap QgsServiceAreaFromPointAlgorithm::processAlgorithm( const QVariantMa } // costs // convert to list and sort to maintain same order of points between algorithm runs - QList< int > verticesList = vertices.toList(); + QList< int > verticesList = qgis::setToList( vertices ); points.reserve( verticesList.size() ); std::sort( verticesList.begin(), verticesList.end() ); for ( int v : verticesList ) diff --git a/src/analysis/processing/qgsalgorithmsplitwithlines.cpp b/src/analysis/processing/qgsalgorithmsplitwithlines.cpp index d7047ae22f47..fa9abdc77c41 100644 --- a/src/analysis/processing/qgsalgorithmsplitwithlines.cpp +++ b/src/analysis/processing/qgsalgorithmsplitwithlines.cpp @@ -146,7 +146,7 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par QVector< QgsGeometry > inGeoms = inGeom.asGeometryCollection(); - const QgsFeatureIds lines = spatialIndex.intersects( inGeom.boundingBox() ).toSet(); + const QgsFeatureIds lines = qgis::listToSet( spatialIndex.intersects( inGeom.boundingBox() ) ); if ( !lines.empty() ) // has intersection of bounding boxes { QVector< QgsGeometry > splittingLines; diff --git a/src/analysis/processing/qgsoverlayutils.cpp b/src/analysis/processing/qgsoverlayutils.cpp index 46d6cdb69cd8..4a9667368f3a 100644 --- a/src/analysis/processing/qgsoverlayutils.cpp +++ b/src/analysis/processing/qgsoverlayutils.cpp @@ -104,7 +104,7 @@ void QgsOverlayUtils::difference( const QgsFeatureSource &sourceA, const QgsFeat if ( featA.hasGeometry() ) { QgsGeometry geom( featA.geometry() ); - QgsFeatureIds intersects = indexB.intersects( geom.boundingBox() ).toSet(); + QgsFeatureIds intersects = qgis::listToSet( indexB.intersects( geom.boundingBox() ) ); QgsFeatureRequest request; request.setFilterFids( intersects ); @@ -209,7 +209,7 @@ void QgsOverlayUtils::intersection( const QgsFeatureSource &sourceA, const QgsFe continue; QgsGeometry geom( featA.geometry() ); - QgsFeatureIds intersects = indexB.intersects( geom.boundingBox() ).toSet(); + QgsFeatureIds intersects = qgis::listToSet( indexB.intersects( geom.boundingBox() ) ); QgsFeatureRequest request; request.setFilterFids( intersects ); diff --git a/src/analysis/vector/geometry_checker/qgsfeaturepool.cpp b/src/analysis/vector/geometry_checker/qgsfeaturepool.cpp index 2ed81964f1da..63ad27929049 100644 --- a/src/analysis/vector/geometry_checker/qgsfeaturepool.cpp +++ b/src/analysis/vector/geometry_checker/qgsfeaturepool.cpp @@ -100,7 +100,7 @@ QgsFeatureIds QgsFeaturePool::allFeatureIds() const QgsFeatureIds QgsFeaturePool::getIntersects( const QgsRectangle &rect ) const { QgsReadWriteLocker locker( mCacheLock, QgsReadWriteLocker::Read ); - QgsFeatureIds ids = QgsFeatureIds::fromList( mIndex.intersects( rect ) ); + QgsFeatureIds ids = qgis::listToSet( mIndex.intersects( rect ) ); return ids; } diff --git a/src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp b/src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp index c17e9d1923d8..95dfd2e8b140 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp +++ b/src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp @@ -62,7 +62,7 @@ void QgsGeometryFollowBoundariesCheck::collectErrors( const QMapboundingBox(); searchBounds.grow( mContext->tolerance ); - QgsFeatureIds refFeatureIds = mIndex->intersects( searchBounds ).toSet(); + QgsFeatureIds refFeatureIds = qgis::listToSet( mIndex->intersects( searchBounds ) ); QgsFeatureRequest refFeatureRequest = QgsFeatureRequest().setFilterFids( refFeatureIds ).setNoAttributes(); QgsFeatureIterator refFeatureIt = mCheckLayer->getFeatures( refFeatureRequest ); diff --git a/src/analysis/vector/qgsgeometrysnapper.cpp b/src/analysis/vector/qgsgeometrysnapper.cpp index 66a768ccb17c..60c90216b747 100644 --- a/src/analysis/vector/qgsgeometrysnapper.cpp +++ b/src/analysis/vector/qgsgeometrysnapper.cpp @@ -485,7 +485,7 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry &geometry, doubl mIndexMutex.lock(); QgsRectangle searchBounds = geometry.boundingBox(); searchBounds.grow( snapTolerance ); - QgsFeatureIds refFeatureIds = mIndex.intersects( searchBounds ).toSet(); + QgsFeatureIds refFeatureIds = qgis::listToSet( mIndex.intersects( searchBounds ) ); mIndexMutex.unlock(); QgsFeatureRequest refFeatureRequest = QgsFeatureRequest().setFilterFids( refFeatureIds ).setNoAttributes(); @@ -758,7 +758,7 @@ QgsGeometry QgsInternalGeometrySnapper::snapFeature( const QgsFeature &feature ) // Get potential reference features and construct snap index QgsRectangle searchBounds = geometry.boundingBox(); searchBounds.grow( mSnapTolerance ); - QgsFeatureIds refFeatureIds = mProcessedIndex.intersects( searchBounds ).toSet(); + QgsFeatureIds refFeatureIds = qgis::listToSet( mProcessedIndex.intersects( searchBounds ) ); if ( !refFeatureIds.isEmpty() ) { QList< QgsGeometry > refGeometries; diff --git a/src/app/dwg/qgsdwgimporter.cpp b/src/app/dwg/qgsdwgimporter.cpp index 28345ed8e65f..1b8a1c35ad2c 100644 --- a/src/app/dwg/qgsdwgimporter.cpp +++ b/src/app/dwg/qgsdwgimporter.cpp @@ -834,7 +834,11 @@ void QgsDwgImporter::addLType( const DRW_LType &data ) setString( dfn, f.get(), QStringLiteral( "name" ), name ); SETSTRINGPTR( desc ); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QVector path( QVector::fromStdVector( data.path ) ); +#else + QVector path( data.path.begin(), data.path.end() ); +#endif OGR_F_SetFieldDoubleList( f.get(), OGR_FD_GetFieldIndex( dfn, "path" ), path.size(), path.data() ); QVector upath; diff --git a/src/app/locator/qgsinbuiltlocatorfilters.cpp b/src/app/locator/qgsinbuiltlocatorfilters.cpp index f4de8668ef50..d007c06b2a7c 100644 --- a/src/app/locator/qgsinbuiltlocatorfilters.cpp +++ b/src/app/locator/qgsinbuiltlocatorfilters.cpp @@ -379,7 +379,7 @@ void QgsAllLayersFeaturesLocatorFilter::prepare( const QString &string, const Qg expression.prepare( &context ); QgsFeatureRequest req; - req.setSubsetOfAttributes( expression.referencedAttributeIndexes( layer->fields() ).toList() ); + req.setSubsetOfAttributes( qgis::setToList( expression.referencedAttributeIndexes( layer->fields() ) ) ); if ( !expression.needsGeometry() ) req.setFlags( QgsFeatureRequest::NoGeometry ); QString enhancedSearch = string; diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 372be2c54028..eee98c67f216 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -12889,7 +12889,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( QStringLiteral( "\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( qgis::setToList( activeTaskDescriptions ).join( QStringLiteral( "\n" ) ) ) ); return true; } return false; diff --git a/src/app/qgsattributetabledialog.cpp b/src/app/qgsattributetabledialog.cpp index d4423e3f7f31..8ba731a4933a 100644 --- a/src/app/qgsattributetabledialog.cpp +++ b/src/app/qgsattributetabledialog.cpp @@ -636,7 +636,7 @@ void QgsAttributeTableDialog::mActionCopySelectedRows_triggered() } featureStore.setFields( fields ); - QgsFeatureIterator it = mLayer->getFeatures( QgsFeatureRequest( featureIds.toSet() ) + QgsFeatureIterator it = mLayer->getFeatures( QgsFeatureRequest( qgis::listToSet( featureIds ) ) .setSubsetOfAttributes( fieldNames, mLayer->fields() ) ); QgsFeatureMap featureMap; QgsFeature feature; diff --git a/src/app/qgsbookmarkeditordialog.cpp b/src/app/qgsbookmarkeditordialog.cpp index c957b663ab58..d06522e736ea 100644 --- a/src/app/qgsbookmarkeditordialog.cpp +++ b/src/app/qgsbookmarkeditordialog.cpp @@ -39,8 +39,8 @@ QgsBookmarkEditorDialog::QgsBookmarkEditorDialog( QgsBookmark bookmark, bool inP mName->setText( mBookmark.name() ); - QSet groups = QSet::fromList( QgsProject::instance()->bookmarkManager()->groups() << QgsApplication::instance()->bookmarkManager()->groups() ); - QStringList groupsList = groups.toList(); + QSet groups = qgis::listToSet( QgsProject::instance()->bookmarkManager()->groups() << QgsApplication::instance()->bookmarkManager()->groups() ); + QStringList groupsList = qgis::setToList( groups ); groupsList.removeOne( QString() ); groupsList.sort(); mGroup->addItems( groupsList ); diff --git a/src/app/qgsdxfexportdialog.cpp b/src/app/qgsdxfexportdialog.cpp index 1c54816ed977..0ff5aa45fcd1 100644 --- a/src/app/qgsdxfexportdialog.cpp +++ b/src/app/qgsdxfexportdialog.cpp @@ -350,7 +350,7 @@ void QgsVectorLayerAndAttributeModel::applyVisibilityPreset( const QString &name } else { - visibleLayers = QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayerIds( name ).toSet(); + visibleLayers = qgis::listToSet( QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayerIds( name ) ); } if ( visibleLayers.isEmpty() ) diff --git a/src/app/qgsgeometryvalidationmodel.cpp b/src/app/qgsgeometryvalidationmodel.cpp index 45a8a543a0b7..47505ff337f0 100644 --- a/src/app/qgsgeometryvalidationmodel.cpp +++ b/src/app/qgsgeometryvalidationmodel.cpp @@ -246,7 +246,7 @@ void QgsGeometryValidationModel::setCurrentLayer( QgsVectorLayer *currentLayer ) mDisplayExpression = mCurrentLayer ? mCurrentLayer->displayExpression() : QString(); mExpressionContext = QgsExpressionContext( QgsExpressionContextUtils::globalProjectLayerScopes( mCurrentLayer ) ); mDisplayExpression.prepare( &mExpressionContext ); - mRequiredAttributes = mDisplayExpression.referencedColumns().toList(); + mRequiredAttributes = qgis::setToList( mDisplayExpression.referencedColumns() ); } else { diff --git a/src/app/qgsgeometryvalidationservice.cpp b/src/app/qgsgeometryvalidationservice.cpp index 2eb2764938ca..5c9546132b55 100644 --- a/src/app/qgsgeometryvalidationservice.cpp +++ b/src/app/qgsgeometryvalidationservice.cpp @@ -414,8 +414,8 @@ void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer QgsFeatureIds affectedFeatureIds; if ( layer->editBuffer() ) { - affectedFeatureIds = layer->editBuffer()->changedGeometries().keys().toSet(); - affectedFeatureIds.unite( layer->editBuffer()->addedFeatures().keys().toSet() ); + affectedFeatureIds = qgis::listToSet( layer->editBuffer()->changedGeometries().keys() ); + affectedFeatureIds.unite( qgis::listToSet( layer->editBuffer()->addedFeatures().keys() ) ); } const QString layerId = layer->id(); diff --git a/src/app/qgsidentifyresultsdialog.cpp b/src/app/qgsidentifyresultsdialog.cpp index 34b0d5f946ee..44a58e0b9527 100644 --- a/src/app/qgsidentifyresultsdialog.cpp +++ b/src/app/qgsidentifyresultsdialog.cpp @@ -601,7 +601,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat QTreeWidgetItem *twi = new QTreeWidgetItem( QStringList() << QString() << action->text() ); twi->setIcon( 0, QgsApplication::getThemeIcon( QStringLiteral( "/mAction.svg" ) ) ); twi->setData( 0, Qt::UserRole, "map_layer_action" ); - twi->setData( 0, Qt::UserRole + 1, qVariantFromValue( qobject_cast( action ) ) ); + twi->setData( 0, Qt::UserRole + 1, QVariant::fromValue( qobject_cast( action ) ) ); actionItem->addChild( twi ); connect( action, &QObject::destroyed, this, &QgsIdentifyResultsDialog::mapLayerActionDestroyed ); @@ -851,7 +851,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, if ( !( QgsRasterDataProvider::identifyFormatToCapability( f ) & capabilities ) ) continue; formatCombo->addItem( QgsRasterDataProvider::identifyFormatLabel( f ), f ); - formatCombo->setItemData( formatCombo->count() - 1, qVariantFromValue( qobject_cast( layer ) ), Qt::UserRole + 1 ); + formatCombo->setItemData( formatCombo->count() - 1, QVariant::fromValue( qobject_cast( layer ) ), Qt::UserRole + 1 ); if ( currentFormat == f ) formatCombo->setCurrentIndex( formatCombo->count() - 1 ); } diff --git a/src/app/qgsmaptoolrotatepointsymbols.cpp b/src/app/qgsmaptoolrotatepointsymbols.cpp index eb35db0eb20c..ecdd0f2c08c6 100644 --- a/src/app/qgsmaptoolrotatepointsymbols.cpp +++ b/src/app/qgsmaptoolrotatepointsymbols.cpp @@ -77,7 +77,7 @@ void QgsMapToolRotatePointSymbols::canvasPressEvent( QgsMapMouseEvent *e ) void QgsMapToolRotatePointSymbols::canvasPressOnFeature( QgsMapMouseEvent *e, const QgsFeature &feature, const QgsPointXY &snappedPoint ) { //find out initial arrow direction - QVariant attrVal = feature.attribute( mCurrentRotationAttributes.toList().at( 0 ) ); + QVariant attrVal = feature.attribute( qgis::setToList( mCurrentRotationAttributes ).at( 0 ) ); mCurrentRotationFeature = attrVal.toDouble(); createPixmapItem( mMarkerSymbol.get() ); diff --git a/src/app/vertextool/qgsvertextool.cpp b/src/app/vertextool/qgsvertextool.cpp index 4f496134533f..0a9e530f795f 100644 --- a/src/app/vertextool/qgsvertextool.cpp +++ b/src/app/vertextool/qgsvertextool.cpp @@ -1005,7 +1005,7 @@ void QgsVertexTool::tryToSelectFeature( QgsMapMouseEvent *e ) mLockedFeatureAlternatives->alternatives.append( firstChoice ); alternatives.remove( firstChoice ); } - mLockedFeatureAlternatives->alternatives.append( alternatives.toList() ); + mLockedFeatureAlternatives->alternatives.append( qgis::setToList( alternatives ) ); if ( mLockedFeature ) { @@ -2222,13 +2222,13 @@ void QgsVertexTool::deleteVertex() QSet toDelete; if ( !mSelectedVertices.isEmpty() ) { - toDelete = QSet::fromList( mSelectedVertices ); + toDelete = qgis::listToSet( mSelectedVertices ); } else { bool addingVertex = mDraggingVertexType == AddingVertex || mDraggingVertexType == AddingEndpoint; toDelete << *mDraggingVertex; - toDelete += QSet::fromList( mDraggingExtraVertices ); + toDelete += qgis::listToSet( mDraggingExtraVertices ); if ( addingVertex ) { diff --git a/src/core/auth/qgsauthmanager.cpp b/src/core/auth/qgsauthmanager.cpp index 6bca38a1c510..5c7be41f0613 100644 --- a/src/core/auth/qgsauthmanager.cpp +++ b/src/core/auth/qgsauthmanager.cpp @@ -2266,7 +2266,7 @@ bool QgsAuthManager::updateIgnoredSslErrorsCacheFromConfig( const QgsAuthConfigS QList errenums( config.sslIgnoredErrorEnums() ); if ( !errenums.isEmpty() ) { - mIgnoredSslErrorsCache.insert( shahostport, QSet::fromList( errenums ) ); + mIgnoredSslErrorsCache.insert( shahostport, qgis::listToSet( errenums ) ); QgsDebugMsg( QStringLiteral( "Update of ignored SSL errors cache SUCCEEDED for sha:host:port = %1" ).arg( shahostport ) ); dumpIgnoredSslErrorsCache_(); return true; @@ -2347,7 +2347,7 @@ bool QgsAuthManager::rebuildIgnoredSslErrorCache() QList errenums( config.sslIgnoredErrorEnums() ); if ( !errenums.isEmpty() ) { - nextcache.insert( shahostport, QSet::fromList( errenums ) ); + nextcache.insert( shahostport, qgis::listToSet( errenums ) ); } if ( prevcache.contains( shahostport ) ) { diff --git a/src/core/expression/qgsexpression.cpp b/src/core/expression/qgsexpression.cpp index 0aba59c6e7ff..5f99fb3879dc 100644 --- a/src/core/expression/qgsexpression.cpp +++ b/src/core/expression/qgsexpression.cpp @@ -250,7 +250,7 @@ QSet QgsExpression::referencedAttributeIndexes( const QgsFields &fields ) c { if ( fieldName == QgsFeatureRequest::ALL_ATTRIBUTES ) { - referencedIndexes = fields.allAttributesList().toSet(); + referencedIndexes = qgis::listToSet( fields.allAttributesList() ); break; } const int idx = fields.lookupField( fieldName ); diff --git a/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp b/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp index bb74f79778ee..c6e03b56cbac 100644 --- a/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp +++ b/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp @@ -147,7 +147,7 @@ QVariant QgsRelationReferenceFieldFormatter::createCache( QgsVectorLayer *layer, QgsFeatureRequest request; request.setFlags( QgsFeatureRequest::NoGeometry ); - QgsAttributeList requiredAttributes = expr.referencedAttributeIndexes( referencedLayer->fields() ).toList(); + QgsAttributeList requiredAttributes = qgis::setToList( expr.referencedAttributeIndexes( referencedLayer->fields() ) ); requiredAttributes << referencedFieldIdx; request.setSubsetOfAttributes( requiredAttributes ); QgsFeature feature; @@ -196,7 +196,7 @@ QVariantList QgsRelationReferenceFieldFormatter::availableValues( const QVariant if ( referencedLayer ) { int fieldIndex = context.project()->relationManager()->relation( config[QStringLiteral( "Relation" )].toString() ).referencedFields().first(); - values = referencedLayer->uniqueValues( fieldIndex, countLimit ).toList(); + values = qgis::setToList( referencedLayer->uniqueValues( fieldIndex, countLimit ) ); } } return values; diff --git a/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp b/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp index 8e0a601fbde9..d348780c22e9 100644 --- a/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp +++ b/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp @@ -147,7 +147,7 @@ QgsValueRelationFieldFormatter::ValueRelationCache QgsValueRelationFieldFormatte QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) ); descriptionExpression.prepare( &context ); subsetOfAttributes += descriptionExpression.referencedAttributeIndexes( layer->fields() ); - request.setSubsetOfAttributes( subsetOfAttributes.toList() ); + request.setSubsetOfAttributes( qgis::setToList( subsetOfAttributes ) ); const QString filterExpression = config.value( QStringLiteral( "FilterExpression" ) ).toString(); @@ -219,7 +219,7 @@ QVariantList QgsValueRelationFieldFormatter::availableValues( const QVariantMap if ( referencedLayer ) { int fieldIndex = referencedLayer->fields().indexOf( config.value( QStringLiteral( "Key" ) ).toString() ); - values = referencedLayer->uniqueValues( fieldIndex, countLimit ).toList(); + values = qgis::setToList( referencedLayer->uniqueValues( fieldIndex, countLimit ) ); } } return values; @@ -291,7 +291,7 @@ QStringList QgsValueRelationFieldFormatter::valueToStringList( const QVariant &v QSet QgsValueRelationFieldFormatter::expressionFormVariables( const QString &expression ) { std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::formScope() ); - QSet< QString > formVariables = scope->variableNames().toSet(); + QSet< QString > formVariables = qgis::listToSet( scope->variableNames() ); const QSet< QString > usedVariables = QgsExpression( expression ).referencedVariables(); formVariables.intersect( usedVariables ); return formVariables; @@ -300,7 +300,7 @@ QSet QgsValueRelationFieldFormatter::expressionFormVariables( const QSt QSet QgsValueRelationFieldFormatter::expressionParentFormVariables( const QString &expression ) { std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::parentFormScope() ); - QSet< QString > formVariables = scope->variableNames().toSet(); + QSet< QString > formVariables = qgis::listToSet( scope->variableNames() ); const QSet< QString > usedVariables = QgsExpression( expression ).referencedVariables(); formVariables.intersect( usedVariables ); return formVariables; @@ -322,8 +322,7 @@ QSet QgsValueRelationFieldFormatter::expressionParentFormAttributes( co QgsExpression exp( expression ); std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::parentFormScope() ); // List of form function names used in the expression - const QSet formFunctions( scope->functionNames() - .toSet() + const QSet formFunctions( qgis::listToSet( scope->functionNames() ) .intersect( exp.referencedFunctions( ) ) ); const QList expFunctions( exp.findNodes() ); QgsExpressionContext context; @@ -347,8 +346,7 @@ QSet QgsValueRelationFieldFormatter::expressionFormAttributes( const QS QgsExpression exp( expression ); std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::formScope() ); // List of form function names used in the expression - const QSet formFunctions( scope->functionNames() - .toSet() + const QSet formFunctions( qgis::listToSet( scope->functionNames() ) .intersect( exp.referencedFunctions( ) ) ); const QList expFunctions( exp.findNodes() ); QgsExpressionContext context; diff --git a/src/core/gps/qgsgpsconnectionregistry.cpp b/src/core/gps/qgsgpsconnectionregistry.cpp index 98ee67c5eac4..0369d7e92a00 100644 --- a/src/core/gps/qgsgpsconnectionregistry.cpp +++ b/src/core/gps/qgsgpsconnectionregistry.cpp @@ -35,5 +35,5 @@ void QgsGpsConnectionRegistry::unregisterConnection( QgsGpsConnection *c ) QList< QgsGpsConnection * > QgsGpsConnectionRegistry::connectionList() const { - return mConnections.toList(); + return qgis::setToList( mConnections ); } diff --git a/src/core/layout/qgslayoutmodel.cpp b/src/core/layout/qgslayoutmodel.cpp index ae98042cc3df..2c085ef8eaee 100644 --- a/src/core/layout/qgslayoutmodel.cpp +++ b/src/core/layout/qgslayoutmodel.cpp @@ -170,7 +170,7 @@ QVariant QgsLayoutModel::data( const QModelIndex &index, int role ) const return item->uuid(); case Qt::UserRole+1: //user role stores reference in column object - return qVariantFromValue( qobject_cast( item ) ); + return QVariant::fromValue( qobject_cast( item ) ); case Qt::TextAlignmentRole: return Qt::AlignLeft & Qt::AlignVCenter; @@ -244,11 +244,11 @@ QVariant QgsLayoutModel::headerData( int section, Qt::Orientation orientation, i { if ( section == Visibility ) { - return qVariantFromValue( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowAllLayersGray.svg" ) ) ); + return QVariant::fromValue( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowAllLayersGray.svg" ) ) ); } else if ( section == LockStatus ) { - return qVariantFromValue( QgsApplication::getThemeIcon( QStringLiteral( "/lockedGray.svg" ) ) ); + return QVariant::fromValue( QgsApplication::getThemeIcon( QStringLiteral( "/lockedGray.svg" ) ) ); } return QVariant(); diff --git a/src/core/providers/memory/qgsmemoryfeatureiterator.cpp b/src/core/providers/memory/qgsmemoryfeatureiterator.cpp index 6a420eee53c6..20b041e866ee 100644 --- a/src/core/providers/memory/qgsmemoryfeatureiterator.cpp +++ b/src/core/providers/memory/qgsmemoryfeatureiterator.cpp @@ -75,7 +75,7 @@ QgsMemoryFeatureIterator::QgsMemoryFeatureIterator( QgsMemoryFeatureSource *sour else if ( mRequest.filterType() == QgsFeatureRequest::FilterFids ) { mUsingFeatureIdList = true; - mFeatureIdList = mRequest.filterFids().toList(); + mFeatureIdList = qgis::setToList( mRequest.filterFids() ); } else { diff --git a/src/core/providers/memory/qgsmemoryprovider.cpp b/src/core/providers/memory/qgsmemoryprovider.cpp index a741adeb33ae..390e43719dae 100644 --- a/src/core/providers/memory/qgsmemoryprovider.cpp +++ b/src/core/providers/memory/qgsmemoryprovider.cpp @@ -523,7 +523,7 @@ bool QgsMemoryProvider::renameAttributes( const QgsFieldNameMap &renamedAttribut bool QgsMemoryProvider::deleteAttributes( const QgsAttributeIds &attributes ) { - QList attrIdx = attributes.toList(); + QList attrIdx = qgis::setToList( attributes ); std::sort( attrIdx.begin(), attrIdx.end(), std::greater() ); // delete attributes one-by-one with decreasing index diff --git a/src/core/providers/ogr/qgsogrfeatureiterator.cpp b/src/core/providers/ogr/qgsogrfeatureiterator.cpp index ef229ee8fd5e..2d69538fc10f 100644 --- a/src/core/providers/ogr/qgsogrfeatureiterator.cpp +++ b/src/core/providers/ogr/qgsogrfeatureiterator.cpp @@ -130,8 +130,8 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool { //ensure that all fields required for filter expressions are prepared QSet attributeIndexes = request.filterExpression()->referencedAttributeIndexes( mSource->mFields ); - attributeIndexes += attrs.toSet(); - attrs = attributeIndexes.toList(); + attributeIndexes += qgis::listToSet( attrs ); + attrs = qgis::setToList( attributeIndexes ); mRequest.setSubsetOfAttributes( attrs ); } // also need attributes required by order by @@ -143,8 +143,8 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool { attributeIndexes << attrIdx; } - attributeIndexes += attrs.toSet(); - attrs = attributeIndexes.toList(); + attributeIndexes += qgis::listToSet( attrs ); + attrs = qgis::setToList( attributeIndexes ); mRequest.setSubsetOfAttributes( attrs ); } diff --git a/src/core/providers/ogr/qgsogrprovider.cpp b/src/core/providers/ogr/qgsogrprovider.cpp index f3953cd837d9..35e0c719ddc3 100644 --- a/src/core/providers/ogr/qgsogrprovider.cpp +++ b/src/core/providers/ogr/qgsogrprovider.cpp @@ -1998,7 +1998,7 @@ bool QgsOgrProvider::deleteAttributes( const QgsAttributeIds &attributes ) return false; bool res = true; - QList attrsLst = attributes.toList(); + QList attrsLst = qgis::setToList( attributes ); // sort in descending order std::sort( attrsLst.begin(), attrsLst.end(), std::greater() ); const auto constAttrsLst = attrsLst; diff --git a/src/core/qgis.h b/src/core/qgis.h index 0097e9979cc5..c8090fa0d770 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -465,6 +465,16 @@ namespace qgis return list.toSet(); #else return QSet( list.begin(), list.end() ); +#endif + } + + template + QList setToList( const QSet &set ) + { +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + return set.toList(); +#else + return QList( set.begin(), set.end() ); #endif } } diff --git a/src/core/qgscachedfeatureiterator.cpp b/src/core/qgscachedfeatureiterator.cpp index 9164ec97b634..8c2c4d385559 100644 --- a/src/core/qgscachedfeatureiterator.cpp +++ b/src/core/qgscachedfeatureiterator.cpp @@ -53,7 +53,7 @@ QgsCachedFeatureIterator::QgsCachedFeatureIterator( QgsVectorLayerCache *vlCache break; default: - mFeatureIds = mVectorLayerCache->mCache.keys().toSet(); + mFeatureIds = qgis::listToSet( mVectorLayerCache->mCache.keys() ); break; } diff --git a/src/core/qgsdataitem.cpp b/src/core/qgsdataitem.cpp index d446afa994c4..9590b7792a07 100644 --- a/src/core/qgsdataitem.cpp +++ b/src/core/qgsdataitem.cpp @@ -1133,11 +1133,11 @@ QgsDirectoryParamWidget::QgsDirectoryParamWidget( const QString &path, QWidget * QString size; if ( fi.size() > 1024 ) { - size = size.sprintf( "%.1f KiB", fi.size() / 1024.0 ); + size = QStringLiteral( "%1 KiB" ).arg( QString::number( fi.size() / 1024.0, 'f', 1 ) ); } else if ( fi.size() > 1.048576e6 ) { - size = size.sprintf( "%.1f MiB", fi.size() / 1.048576e6 ); + size = QStringLiteral( "%1 MiB" ).arg( QString::number( fi.size() / 1.048576e6, 'f', 1 ) ); } else { diff --git a/src/core/qgsexpressioncontext.cpp b/src/core/qgsexpressioncontext.cpp index 30a9b690ff53..07b85a867789 100644 --- a/src/core/qgsexpressioncontext.cpp +++ b/src/core/qgsexpressioncontext.cpp @@ -408,7 +408,7 @@ QStringList QgsExpressionContext::variableNames() const { names << scope->variableNames(); } - return names.toSet().toList(); + return qgis::setToList( qgis::listToSet( names ) ); } QStringList QgsExpressionContext::filteredVariableNames() const @@ -464,7 +464,7 @@ QStringList QgsExpressionContext::functionNames() const { result << scope->functionNames(); } - result = result.toSet().toList(); + result = qgis::setToList( qgis::listToSet( result ) ); result.sort(); return result; } diff --git a/src/core/qgsmaprendererjob.cpp b/src/core/qgsmaprendererjob.cpp index bde376085d09..829732e50cdf 100644 --- a/src/core/qgsmaprendererjob.cpp +++ b/src/core/qgsmaprendererjob.cpp @@ -111,7 +111,7 @@ bool QgsMapRendererJob::prepareLabelCache() const // we may need to clear label cache and re-register labeled features - check for that here // can we reuse the cached label solution? - bool canUseCache = canCache && mCache->dependentLayers( LABEL_CACHE_ID ).toSet() == labeledLayers; + bool canUseCache = canCache && qgis::listToSet( mCache->dependentLayers( LABEL_CACHE_ID ) ) == labeledLayers; if ( !canUseCache ) { // no - participating layers have changed diff --git a/src/core/qgsmapsettingsutils.cpp b/src/core/qgsmapsettingsutils.cpp index 216bd4e5d85c..c5c9d046c564 100644 --- a/src/core/qgsmapsettingsutils.cpp +++ b/src/core/qgsmapsettingsutils.cpp @@ -77,7 +77,7 @@ QStringList QgsMapSettingsUtils::containsAdvancedEffects( const QgsMapSettings & } } - return layers.toList(); + return qgis::setToList( layers ); } void QgsMapSettingsUtils::worldFileParameters( const QgsMapSettings &mapSettings, double &a, double &b, double &c, double &d, double &e, double &f ) diff --git a/src/core/qgsmapthemecollection.cpp b/src/core/qgsmapthemecollection.cpp index 09e7d013721c..fed982ea831a 100644 --- a/src/core/qgsmapthemecollection.cpp +++ b/src/core/qgsmapthemecollection.cpp @@ -39,7 +39,7 @@ QgsMapThemeCollection::MapThemeLayerRecord QgsMapThemeCollection::createThemeLay layerRec.usingCurrentStyle = true; layerRec.currentStyle = nodeLayer->layer()->styleManager()->currentStyle(); layerRec.expandedLayerNode = nodeLayer->isExpanded(); - layerRec.expandedLegendItems = nodeLayer->customProperty( QStringLiteral( "expandedLegendNodes" ) ).toStringList().toSet(); + layerRec.expandedLegendItems = qgis::listToSet( nodeLayer->customProperty( QStringLiteral( "expandedLegendNodes" ) ).toStringList() ); // get checked legend items bool hasCheckableItems = false; @@ -176,7 +176,7 @@ void QgsMapThemeCollection::applyThemeToLayer( QgsLayerTreeLayer *nodeLayer, Qgs if ( rec.hasExpandedStateInfo() ) { nodeLayer->setExpanded( layerRec.expandedLayerNode ); - nodeLayer->setCustomProperty( QStringLiteral( "expandedLegendNodes" ), QStringList( layerRec.expandedLegendItems.toList() ) ); + nodeLayer->setCustomProperty( QStringLiteral( "expandedLegendNodes" ), QStringList( qgis::setToList( layerRec.expandedLegendItems ) ) ); } } diff --git a/src/core/qgstaskmanager.cpp b/src/core/qgstaskmanager.cpp index bc7ad5543173..ae71205ddbf9 100644 --- a/src/core/qgstaskmanager.cpp +++ b/src/core/qgstaskmanager.cpp @@ -511,7 +511,7 @@ QgsTask *QgsTaskManager::task( long id ) const QList QgsTaskManager::tasks() const { QMutexLocker ml( mTaskMutex ); - return mParentTasks.toList(); + return qgis::setToList( mParentTasks ); } int QgsTaskManager::count() const @@ -654,7 +654,7 @@ QList QgsTaskManager::activeTasks() const QMutexLocker ml( mTaskMutex ); QSet< QgsTask * > activeTasks = mActiveTasks; activeTasks.intersect( mParentTasks ); - return activeTasks.toList(); + return qgis::setToList( activeTasks ); } int QgsTaskManager::countActiveTasks() const diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index 5b579d604162..8c38285a6daf 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -3294,7 +3294,7 @@ QStringList QgsVectorFileWriter::supportedFormatExtensions( const VectorFormatOp } } - QStringList extensionList = extensions.toList(); + QStringList extensionList = qgis::setToList( extensions ); std::sort( extensionList.begin(), extensionList.end(), [options]( const QString & a, const QString & b ) -> bool { diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index 99282d1fe89d..516ba318854a 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -3170,7 +3170,7 @@ bool QgsVectorLayer::deleteAttributes( const QList &attrs ) bool deleted = false; // Remove multiple occurrences of same attribute - QList attrList = attrs.toSet().toList(); + QList attrList = qgis::setToList( qgis::listToSet( attrs ) ); std::sort( attrList.begin(), attrList.end(), std::greater() ); @@ -4045,7 +4045,7 @@ QSet QgsVectorLayer::uniqueValues( int index, int limit ) const } } - return val.values().toSet(); + return qgis::listToSet( val.values() ); } } diff --git a/src/core/qgsvectorlayercache.cpp b/src/core/qgsvectorlayercache.cpp index 180263139f70..2d1ddad09e36 100644 --- a/src/core/qgsvectorlayercache.cpp +++ b/src/core/qgsvectorlayercache.cpp @@ -353,7 +353,7 @@ bool QgsVectorLayerCache::canUseCacheForRequest( const QgsFeatureRequest &featur } case QgsFeatureRequest::FilterFids: { - if ( mCache.keys().toSet().contains( featureRequest.filterFids() ) ) + if ( qgis::listToSet( mCache.keys() ).contains( featureRequest.filterFids() ) ) { it = QgsFeatureIterator( new QgsCachedFeatureIterator( this, featureRequest ) ); return true; @@ -412,8 +412,8 @@ QgsFeatureIterator QgsVectorLayerCache::getFeatures( const QgsFeatureRequest &fe myRequest.setFlags( featureRequest.flags() & ~QgsFeatureRequest::NoGeometry ); // Make sure, all the cached attributes are requested as well - QSet attrs = featureRequest.subsetOfAttributes().toSet() + mCachedAttributes.toSet(); - myRequest.setSubsetOfAttributes( attrs.toList() ); + QSet attrs = qgis::listToSet( featureRequest.subsetOfAttributes() ) + qgis::listToSet( mCachedAttributes ); + myRequest.setSubsetOfAttributes( qgis::setToList( attrs ) ); it = QgsFeatureIterator( new QgsCachedFeatureWriterIterator( this, myRequest ) ); } diff --git a/src/core/qgsvectorlayereditbuffer.cpp b/src/core/qgsvectorlayereditbuffer.cpp index 28a898afee36..54ebfde6568a 100644 --- a/src/core/qgsvectorlayereditbuffer.cpp +++ b/src/core/qgsvectorlayereditbuffer.cpp @@ -397,7 +397,7 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList &commitErrors ) bool attributesChanged = false; if ( !mDeletedAttributeIds.isEmpty() ) { - if ( ( cap & QgsVectorDataProvider::DeleteAttributes ) && provider->deleteAttributes( mDeletedAttributeIds.toSet() ) ) + if ( ( cap & QgsVectorDataProvider::DeleteAttributes ) && provider->deleteAttributes( qgis::listToSet( mDeletedAttributeIds ) ) ) { commitErrors << tr( "SUCCESS: %n attribute(s) deleted.", "deleted attributes count", mDeletedAttributeIds.size() ); diff --git a/src/core/qgsvectorlayerfeatureiterator.cpp b/src/core/qgsvectorlayerfeatureiterator.cpp index 05f610e30263..f1fedcca0f58 100644 --- a/src/core/qgsvectorlayerfeatureiterator.cpp +++ b/src/core/qgsvectorlayerfeatureiterator.cpp @@ -149,8 +149,8 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat { //ensure that all fields required for filter expressions are prepared QSet attributeIndexes = mRequest.filterExpression()->referencedAttributeIndexes( mSource->mFields ); - attributeIndexes += mRequest.subsetOfAttributes().toSet(); - mRequest.setSubsetOfAttributes( attributeIndexes.toList() ); + attributeIndexes += qgis::listToSet( mRequest.subsetOfAttributes() ); + mRequest.setSubsetOfAttributes( qgis::setToList( attributeIndexes ) ); } } @@ -196,7 +196,7 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat } } - mProviderRequest.setSubsetOfAttributes( providerSubset.toList() ); + mProviderRequest.setSubsetOfAttributes( qgis::setToList( providerSubset ) ); } if ( mProviderRequest.filterType() == QgsFeatureRequest::FilterExpression ) @@ -723,7 +723,7 @@ void QgsVectorLayerFeatureIterator::prepareExpression( int fieldIdx ) exp->prepare( mExpressionContext.get() ); const QSet referencedColumns = exp->referencedAttributeIndexes( mSource->fields() ); - QSet requestedAttributes = mRequest.subsetOfAttributes().toSet(); + QSet requestedAttributes = qgis::listToSet( mRequest.subsetOfAttributes() ); for ( int dependentFieldIdx : referencedColumns ) { @@ -738,7 +738,7 @@ void QgsVectorLayerFeatureIterator::prepareExpression( int fieldIdx ) if ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) { - mRequest.setSubsetOfAttributes( requestedAttributes.toList() ); + mRequest.setSubsetOfAttributes( qgis::setToList( requestedAttributes ) ); } if ( exp->needsGeometry() ) diff --git a/src/core/qgsvectorlayerjoinbuffer.cpp b/src/core/qgsvectorlayerjoinbuffer.cpp index bd8a04ae3674..15029017c1f8 100644 --- a/src/core/qgsvectorlayerjoinbuffer.cpp +++ b/src/core/qgsvectorlayerjoinbuffer.cpp @@ -221,7 +221,7 @@ void QgsVectorLayerJoinBuffer::updateFields( QgsFields &fields ) if ( joinIt->hasSubset() ) { const QStringList subsetNames = QgsVectorLayerJoinInfo::joinFieldNamesSubset( *joinIt ); - subset = QSet::fromList( subsetNames ); + subset = qgis::listToSet( subsetNames ); } if ( joinIt->prefix().isNull() ) diff --git a/src/core/symbology/qgscategorizedsymbolrenderer.cpp b/src/core/symbology/qgscategorizedsymbolrenderer.cpp index 1fd94bc98133..6acf6def579e 100644 --- a/src/core/symbology/qgscategorizedsymbolrenderer.cpp +++ b/src/core/symbology/qgscategorizedsymbolrenderer.cpp @@ -1121,7 +1121,7 @@ int QgsCategorizedSymbolRenderer::matchToSymbols( QgsStyle *style, const QgsSymb int matched = 0; unmatchedSymbols = style->symbolNames(); - const QSet< QString > allSymbolNames = unmatchedSymbols.toSet(); + const QSet< QString > allSymbolNames = qgis::listToSet( unmatchedSymbols ); const QRegularExpression tolerantMatchRe( QStringLiteral( "[^\\w\\d ]" ), QRegularExpression::UseUnicodePropertiesOption ); diff --git a/src/core/symbology/qgsrulebasedrenderer.cpp b/src/core/symbology/qgsrulebasedrenderer.cpp index d318889bec07..96c3d8ab7dd9 100644 --- a/src/core/symbology/qgsrulebasedrenderer.cpp +++ b/src/core/symbology/qgsrulebasedrenderer.cpp @@ -951,7 +951,7 @@ void QgsRuleBasedRenderer::startRender( QgsRenderContext &context, const QgsFiel mRootRule->startRender( context, fields, mFilter ); QSet symbolZLevelsSet = mRootRule->collectZLevels(); - QList symbolZLevels = symbolZLevelsSet.toList(); + QList symbolZLevels = qgis::setToList( symbolZLevelsSet ); std::sort( symbolZLevels.begin(), symbolZLevels.end() ); // create mapping from unnormalized levels [unlimited range] to normalized levels [0..N-1] diff --git a/src/core/symbology/qgsstyle.cpp b/src/core/symbology/qgsstyle.cpp index 170eb27cd407..1294b8e03d1f 100644 --- a/src/core/symbology/qgsstyle.cpp +++ b/src/core/symbology/qgsstyle.cpp @@ -1524,7 +1524,7 @@ QStringList QgsStyle::findSymbols( StyleEntity type, const QString &qword ) symbols << statement.columnAsText( 0 ); } - return symbols.toList(); + return qgis::setToList( symbols ); } bool QgsStyle::tagSymbol( StyleEntity type, const QString &symbol, const QStringList &tags ) @@ -2208,7 +2208,7 @@ QStringList QgsStyle::symbolsOfSmartgroup( StyleEntity type, int id ) } // return sorted, unique list - QStringList unique = symbols.toSet().toList(); + QStringList unique = qgis::setToList( qgis::listToSet( symbols ) ); std::sort( unique.begin(), unique.end() ); return unique; } diff --git a/src/core/symbology/qgssymbollayerutils.cpp b/src/core/symbology/qgssymbollayerutils.cpp index 8c51dead0ed9..978d0b50cc24 100644 --- a/src/core/symbology/qgssymbollayerutils.cpp +++ b/src/core/symbology/qgssymbollayerutils.cpp @@ -75,9 +75,7 @@ QColor QgsSymbolLayerUtils::decodeColor( const QString &str ) QString QgsSymbolLayerUtils::encodeSldAlpha( int alpha ) { - QString result; - result.sprintf( "%.2g", alpha / 255.0 ); - return result; + return QString::number( alpha / 255.0, 'g', 2 ); } int QgsSymbolLayerUtils::decodeSldAlpha( const QString &str ) diff --git a/src/core/vectortile/qgsvectortileutils.cpp b/src/core/vectortile/qgsvectortileutils.cpp index cd7bb747fa8e..b855bb1b3d94 100644 --- a/src/core/vectortile/qgsvectortileutils.cpp +++ b/src/core/vectortile/qgsvectortileutils.cpp @@ -51,7 +51,7 @@ QPolygon QgsVectorTileUtils::tilePolygon( QgsTileXYZ id, const QgsCoordinateTran QgsFields QgsVectorTileUtils::makeQgisFields( QSet flds ) { QgsFields fields; - QStringList fieldsSorted = flds.toList(); + QStringList fieldsSorted = qgis::setToList( flds ); std::sort( fieldsSorted.begin(), fieldsSorted.end() ); for ( const QString &fieldName : qgis::as_const( fieldsSorted ) ) { @@ -80,7 +80,7 @@ QgsVectorLayer *QgsVectorTileUtils::makeVectorLayerForTile( QgsVectorTileLayer * { QgsVectorTileMVTDecoder decoder; decoder.decode( tileID, mvt->getRawTile( tileID ) ); - QSet fieldNames = QSet::fromList( decoder.layerFieldNames( layerName ) ); + QSet fieldNames = qgis::listToSet( decoder.layerFieldNames( layerName ) ); fieldNames << QStringLiteral( "_geom_type" ); QMap perLayerFields; QgsFields fields = QgsVectorTileUtils::makeQgisFields( fieldNames ); diff --git a/src/gui/attributetable/qgsattributetableview.cpp b/src/gui/attributetable/qgsattributetableview.cpp index 605f4547240a..3740fb96127f 100644 --- a/src/gui/attributetable/qgsattributetableview.cpp +++ b/src/gui/attributetable/qgsattributetableview.cpp @@ -239,7 +239,7 @@ QWidget *QgsAttributeTableView::createActionWidget( QgsFeatureId fid ) action->setData( "map_layer_action" ); action->setToolTip( mapLayerAction->text() ); action->setProperty( "fid", fid ); - action->setProperty( "action", qVariantFromValue( qobject_cast( mapLayerAction ) ) ); + action->setProperty( "action", QVariant::fromValue( qobject_cast( mapLayerAction ) ) ); connect( action, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered ); actionList << action; diff --git a/src/gui/editorwidgets/qgsrelationreferencewidget.cpp b/src/gui/editorwidgets/qgsrelationreferencewidget.cpp index f87b06bf0f55..c337ac17f24d 100644 --- a/src/gui/editorwidgets/qgsrelationreferencewidget.cpp +++ b/src/gui/editorwidgets/qgsrelationreferencewidget.cpp @@ -516,7 +516,7 @@ void QgsRelationReferenceWidget::init() cb->setProperty( "Field", fieldName ); cb->setProperty( "FieldAlias", mReferencedLayer->attributeDisplayName( idx ) ); mFilterComboBoxes << cb; - QVariantList uniqueValues = mReferencedLayer->uniqueValues( idx ).toList(); + QVariantList uniqueValues = qgis::setToList( mReferencedLayer->uniqueValues( idx ) ); cb->addItem( mReferencedLayer->attributeDisplayName( idx ) ); QVariant nullValue = QgsApplication::nullRepresentation(); cb->addItem( nullValue.toString(), QVariant( mReferencedLayer->fields().at( idx ).type() ) ); diff --git a/src/gui/layertree/qgslayertreeview.cpp b/src/gui/layertree/qgslayertreeview.cpp index 10b3f90e9457..ce85562a76ea 100644 --- a/src/gui/layertree/qgslayertreeview.cpp +++ b/src/gui/layertree/qgslayertreeview.cpp @@ -299,7 +299,7 @@ void QgsLayerTreeView::onCustomPropertyChanged( QgsLayerTreeNode *node, const QS if ( key != QStringLiteral( "expandedLegendNodes" ) || !QgsLayerTree::isLayer( node ) ) return; - QSet expandedLegendNodes = node->customProperty( QStringLiteral( "expandedLegendNodes" ) ).toStringList().toSet(); + QSet expandedLegendNodes = qgis::listToSet( node->customProperty( QStringLiteral( "expandedLegendNodes" ) ).toStringList() ); const QList legendNodes = layerTreeModel()->layerLegendNodes( QgsLayerTree::toLayer( node ), true ); for ( QgsLayerTreeModelLegendNode *legendNode : legendNodes ) @@ -412,7 +412,7 @@ QList QgsLayerTreeView::selectedLayersRecursive() const { const QList nodes = layerTreeModel()->indexes2nodes( selectionModel()->selectedIndexes(), false ); QSet layersSet = QgsLayerTreeUtils::collectMapLayersRecursive( nodes ); - return layersSet.toList(); + return qgis::setToList( layersSet ); } void QgsLayerTreeView::addIndicator( QgsLayerTreeNode *node, QgsLayerTreeViewIndicator *indicator ) diff --git a/src/gui/processing/qgsprocessingenummodelerwidget.cpp b/src/gui/processing/qgsprocessingenummodelerwidget.cpp index 7ac30ff9a831..699be7b1bc70 100644 --- a/src/gui/processing/qgsprocessingenummodelerwidget.cpp +++ b/src/gui/processing/qgsprocessingenummodelerwidget.cpp @@ -60,7 +60,7 @@ void QgsProcessingEnumModelerWidget::removeItems( const bool removeAll ) for ( const QModelIndex &i : selected ) rows << i.row(); - QList< int > rowsToDelete = rows.toList(); + QList< int > rowsToDelete = qgis::setToList( rows ); std::sort( rowsToDelete.begin(), rowsToDelete.end(), std::greater() ); mItemList->setUpdatesEnabled( false ); diff --git a/src/gui/processing/qgsprocessingmatrixparameterdialog.cpp b/src/gui/processing/qgsprocessingmatrixparameterdialog.cpp index 00ca298320a7..4ce5434817b8 100644 --- a/src/gui/processing/qgsprocessingmatrixparameterdialog.cpp +++ b/src/gui/processing/qgsprocessingmatrixparameterdialog.cpp @@ -102,7 +102,7 @@ void QgsProcessingMatrixParameterPanelWidget::deleteRow() for ( const QModelIndex &i : selected ) rows << i.row(); - QList< int > rowsToDelete = rows.toList(); + QList< int > rowsToDelete = qgis::setToList( rows ); std::sort( rowsToDelete.begin(), rowsToDelete.end(), std::greater() ); mTblView->setUpdatesEnabled( false ); for ( int i : qgis::as_const( rowsToDelete ) ) diff --git a/src/gui/qgscolorschemelist.cpp b/src/gui/qgscolorschemelist.cpp index 408ff0fecd57..d6abd35a402f 100644 --- a/src/gui/qgscolorschemelist.cpp +++ b/src/gui/qgscolorschemelist.cpp @@ -81,7 +81,7 @@ void QgsColorSchemeList::removeSelection() rows << index.row(); } //remove duplicates - QList rowsToRemove = QList::fromSet( rows.toSet() ); + QList rowsToRemove = qgis::setToList( qgis::listToSet( rows ) ); //remove rows in descending order std::sort( rowsToRemove.begin(), rowsToRemove.end(), std::greater() ); @@ -124,7 +124,7 @@ void QgsColorSchemeList::copyColors() rows << index.row(); } //remove duplicates - QList rowsToCopy = QList::fromSet( rows.toSet() ); + QList rowsToCopy = qgis::setToList( qgis::listToSet( rows ) ); QgsNamedColorList colorsToCopy; const auto constRowsToCopy = rowsToCopy; @@ -208,7 +208,7 @@ void QgsColorSchemeList::keyPressEvent( QKeyEvent *event ) rows << index.row(); } //remove duplicates - QList rowsToRemove = QList::fromSet( rows.toSet() ); + QList rowsToRemove = qgis::setToList( qgis::listToSet( rows ) ); //remove rows in descending order std::sort( rowsToRemove.begin(), rowsToRemove.end(), std::greater() ); diff --git a/src/gui/qgsconfigureshortcutsdialog.cpp b/src/gui/qgsconfigureshortcutsdialog.cpp index 288571458efe..fc514c19e436 100644 --- a/src/gui/qgsconfigureshortcutsdialog.cpp +++ b/src/gui/qgsconfigureshortcutsdialog.cpp @@ -93,7 +93,7 @@ void QgsConfigureShortcutsDialog::populateActions() lst << actionText << sequence; QTreeWidgetItem *item = new QTreeWidgetItem( lst ); item->setIcon( 0, icon ); - item->setData( 0, Qt::UserRole, qVariantFromValue( obj ) ); + item->setData( 0, Qt::UserRole, QVariant::fromValue( obj ) ); items.append( item ); } diff --git a/src/gui/qgsexpressionbuilderwidget.cpp b/src/gui/qgsexpressionbuilderwidget.cpp index 84d20f2d8e3c..8e124d3dc579 100644 --- a/src/gui/qgsexpressionbuilderwidget.cpp +++ b/src/gui/qgsexpressionbuilderwidget.cpp @@ -524,7 +524,7 @@ void QgsExpressionBuilderWidget::fillFieldValues( const QString &fieldName, int } else { - values = mLayer->uniqueValues( fieldIndex, countLimit ).toList(); + values = qgis::setToList( mLayer->uniqueValues( fieldIndex, countLimit ) ); } std::sort( values.begin(), values.end() ); diff --git a/src/gui/qgsfieldmappingmodel.cpp b/src/gui/qgsfieldmappingmodel.cpp index 27e08a638623..2ba69f1d2214 100644 --- a/src/gui/qgsfieldmappingmodel.cpp +++ b/src/gui/qgsfieldmappingmodel.cpp @@ -359,9 +359,9 @@ void QgsFieldMappingModel::setDestinationFields( const QgsFields &destinationFie const QgsExpression exp { f.expression }; // if it's source field if ( exp.isField() && - mSourceFields.names().contains( exp.referencedColumns().toList().first() ) ) + mSourceFields.names().contains( qgis::setToList( exp.referencedColumns() ).first() ) ) { - usedFields.push_back( exp.referencedColumns().toList().first() ); + usedFields.push_back( qgis::setToList( exp.referencedColumns() ).first() ); } } else diff --git a/src/gui/qgsmaptoolidentify.cpp b/src/gui/qgsmaptoolidentify.cpp index eadb6b603495..a59915ce4317 100644 --- a/src/gui/qgsmaptoolidentify.cpp +++ b/src/gui/qgsmaptoolidentify.cpp @@ -408,7 +408,7 @@ bool QgsMapToolIdentify::identifyVectorTileLayer( QList fieldNames = QSet::fromList( decoder.layerFieldNames( layerName ) ); + QSet fieldNames = qgis::listToSet( decoder.layerFieldNames( layerName ) ); perLayerFields[layerName] = QgsVectorTileUtils::makeQgisFields( fieldNames ); } diff --git a/src/gui/qgsowssourceselect.cpp b/src/gui/qgsowssourceselect.cpp index 6bf01e4ed528..a6ca03af9bd9 100644 --- a/src/gui/qgsowssourceselect.cpp +++ b/src/gui/qgsowssourceselect.cpp @@ -421,7 +421,7 @@ void QgsOWSSourceSelect::mLayersTreeWidget_itemSelectionChanged() void QgsOWSSourceSelect::populateCrs() { clearCrs(); - mSelectedLayersCRSs = selectedLayersCrses().toSet(); + mSelectedLayersCRSs = qgis::listToSet( selectedLayersCrses() ); mCRSLabel->setText( tr( "Coordinate Reference System (%n available)", "crs count", mSelectedLayersCRSs.count() ) + ':' ); mChangeCRSButton->setDisabled( mSelectedLayersCRSs.isEmpty() ); diff --git a/src/gui/qgsquerybuilder.cpp b/src/gui/qgsquerybuilder.cpp index 69d3dd27c256..350272457c70 100644 --- a/src/gui/qgsquerybuilder.cpp +++ b/src/gui/qgsquerybuilder.cpp @@ -141,7 +141,7 @@ void QgsQueryBuilder::fillValues( int idx, int limit ) mModelValues->clear(); // determine the field type - QList values = mLayer->uniqueValues( idx, limit ).toList(); + QList values = qgis::setToList( mLayer->uniqueValues( idx, limit ) ); std::sort( values.begin(), values.end() ); QString nullValue = QgsApplication::nullRepresentation(); diff --git a/src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp b/src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp index c5dae69f7956..d41109d71bac 100644 --- a/src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp +++ b/src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp @@ -786,7 +786,7 @@ void QgsCategorizedSymbolRendererWidget::addCategories() } else { - uniqueValues = mLayer->uniqueValues( idx ).toList(); + uniqueValues = qgis::setToList( mLayer->uniqueValues( idx ) ); } // ask to abort if too many classes diff --git a/src/gui/vector/qgsattributeactiondialog.cpp b/src/gui/vector/qgsattributeactiondialog.cpp index 35b5f1250e0d..1833864e6434 100644 --- a/src/gui/vector/qgsattributeactiondialog.cpp +++ b/src/gui/vector/qgsattributeactiondialog.cpp @@ -133,7 +133,7 @@ void QgsAttributeActionDialog::insertRow( int row, const QgsAction &action ) // Scopes item = new QTableWidgetItem(); item->setFlags( item->flags() & ~( Qt::ItemIsEditable ) ); - QStringList actionScopes = action.actionScopes().toList(); + QStringList actionScopes = qgis::setToList( action.actionScopes() ); std::sort( actionScopes.begin(), actionScopes.end() ); item->setText( actionScopes.join( QStringLiteral( ", " ) ) ); item->setData( Qt::UserRole, QVariant::fromValue>( action.actionScopes() ) ); @@ -355,7 +355,7 @@ void QgsAttributeActionDialog::itemDoubleClicked( QTableWidgetItem *item ) mAttributeActionTable->item( row, EnabledOnlyWhenEditable )->setCheckState( actionProperties.isEnabledOnlyWhenEditable() ? Qt::Checked : Qt::Unchecked ); QTableWidgetItem *item = mAttributeActionTable->item( row, ActionScopes ); - QStringList actionScopes = actionProperties.actionScopes().toList(); + QStringList actionScopes = qgis::setToList( actionProperties.actionScopes() ); std::sort( actionScopes.begin(), actionScopes.end() ); item->setText( actionScopes.join( QStringLiteral( ", " ) ) ); item->setData( Qt::UserRole, QVariant::fromValue>( actionProperties.actionScopes() ) ); diff --git a/src/gui/vector/qgswmsdimensiondialog.cpp b/src/gui/vector/qgswmsdimensiondialog.cpp index c9032574ec91..44e130087c63 100644 --- a/src/gui/vector/qgswmsdimensiondialog.cpp +++ b/src/gui/vector/qgswmsdimensiondialog.cpp @@ -192,7 +192,7 @@ void QgsWmsDimensionDialog::fieldChanged() int currentEndFieldIndexOf = mLayer->fields().indexOf( currentEndFieldName ); uniqueValues.unite( mLayer->uniqueValues( currentEndFieldIndexOf ) ); } - QList values = uniqueValues.toList(); + QList values = qgis::setToList( uniqueValues ); std::sort( values.begin(), values.end() ); mReferenceValueComboBox->clear(); diff --git a/src/providers/arcgisrest/qgsafsfeatureiterator.cpp b/src/providers/arcgisrest/qgsafsfeatureiterator.cpp index e0bb07b6038e..db71e90ec374 100644 --- a/src/providers/arcgisrest/qgsafsfeatureiterator.cpp +++ b/src/providers/arcgisrest/qgsafsfeatureiterator.cpp @@ -83,7 +83,7 @@ QgsAfsFeatureIterator::QgsAfsFeatureIterator( QgsAfsFeatureSource *source, bool mDeferredFeaturesInFilterRectCheck = true; } - mFeatureIdList = requestIds.toList(); + mFeatureIdList = qgis::setToList( requestIds ); std::sort( mFeatureIdList.begin(), mFeatureIdList.end() ); mRemainingFeatureIds = mFeatureIdList; if ( !mRemainingFeatureIds.empty() ) @@ -113,13 +113,13 @@ bool QgsAfsFeatureIterator::fetchFeature( QgsFeature &f ) QgsFeatureIds featuresInRect = mSource->sharedData()->getFeatureIdsInExtent( mFilterRect, mInterruptionChecker ); if ( !mFeatureIdList.isEmpty() ) { - QgsFeatureIds requestIds = mFeatureIdList.toSet(); + QgsFeatureIds requestIds = qgis::listToSet( mFeatureIdList ); requestIds.intersect( featuresInRect ); - mFeatureIdList = requestIds.toList(); + mFeatureIdList = qgis::setToList( requestIds ); } else { - mFeatureIdList = featuresInRect.toList(); + mFeatureIdList = qgis::setToList( featuresInRect ); } if ( mFeatureIdList.empty() ) { diff --git a/src/providers/arcgisrest/qgsamsprovider.cpp b/src/providers/arcgisrest/qgsamsprovider.cpp index 176904557118..8df422fc6275 100644 --- a/src/providers/arcgisrest/qgsamsprovider.cpp +++ b/src/providers/arcgisrest/qgsamsprovider.cpp @@ -883,7 +883,7 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPointXY &point, QgsRa params[QStringLiteral( "featureType" )] = attributesMap[resultMap[QStringLiteral( "displayFieldName" )].toString()].toString(); store.setParams( params ); store.addFeature( feature ); - entries.insert( entries.size(), qVariantFromValue( QList() << store ) ); + entries.insert( entries.size(), QVariant::fromValue( QList() << store ) ); } } return QgsRasterIdentifyResult( format, entries ); diff --git a/src/providers/db2/qgsdb2featureiterator.cpp b/src/providers/db2/qgsdb2featureiterator.cpp index a01cfdae371b..b0b488604f68 100644 --- a/src/providers/db2/qgsdb2featureiterator.cpp +++ b/src/providers/db2/qgsdb2featureiterator.cpp @@ -89,8 +89,8 @@ void QgsDb2FeatureIterator::BuildStatement( const QgsFeatureRequest &request ) { //ensure that all fields required for filter expressions are prepared QSet attributeIndexes = request.filterExpression()->referencedAttributeIndexes( mSource->mFields ); - attributeIndexes += attrs.toSet(); - attrs = attributeIndexes.toList(); + attributeIndexes += qgis::listToSet( attrs ); + attrs = qgis::setToList( attributeIndexes ); } const auto constAttrs = attrs; diff --git a/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp b/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp index 2348f2abac81..abaaddede92b 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp +++ b/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp @@ -154,8 +154,8 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe QgsAttributeList attrs = request.subsetOfAttributes(); //ensure that all fields required for filter expressions are prepared QSet attributeIndexes = request.filterExpression()->referencedAttributeIndexes( mSource->mFields ); - attributeIndexes += attrs.toSet(); - mRequest.setSubsetOfAttributes( attributeIndexes.toList() ); + attributeIndexes += qgis::listToSet( attrs ); + mRequest.setSubsetOfAttributes( qgis::setToList( attributeIndexes ) ); } // also need attributes required by order by if ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes && !mRequest.orderBy().isEmpty() ) diff --git a/src/providers/gpx/gpsdata.cpp b/src/providers/gpx/gpsdata.cpp index 332bfa42e9f4..ae45feec7edf 100644 --- a/src/providers/gpx/gpsdata.cpp +++ b/src/providers/gpx/gpsdata.cpp @@ -288,7 +288,7 @@ QgsGpsData::TrackIterator QgsGpsData::addTrack( const QgsTrack &trk ) void QgsGpsData::removeWaypoints( const QgsFeatureIds &ids ) { - QList ids2 = ids.toList(); + QList ids2 = qgis::setToList( ids ); std::sort( ids2.begin(), ids2.end() ); QList::const_iterator iter = ids2.constBegin(); WaypointIterator wIter; @@ -309,7 +309,7 @@ void QgsGpsData::removeWaypoints( const QgsFeatureIds &ids ) void QgsGpsData::removeRoutes( const QgsFeatureIds &ids ) { - QList ids2 = ids.toList(); + QList ids2 = qgis::setToList( ids ); std::sort( ids2.begin(), ids2.end() ); QList::const_iterator iter = ids2.constBegin(); RouteIterator rIter; @@ -329,7 +329,7 @@ void QgsGpsData::removeRoutes( const QgsFeatureIds &ids ) void QgsGpsData::removeTracks( const QgsFeatureIds &ids ) { - QList ids2 = ids.toList(); + QList ids2 = qgis::setToList( ids ); std::sort( ids2.begin(), ids2.end() ); QList::const_iterator iter = ids2.constBegin(); TrackIterator tIter; diff --git a/src/providers/mssql/qgsmssqlfeatureiterator.cpp b/src/providers/mssql/qgsmssqlfeatureiterator.cpp index d97d10c35128..4f4235fb0f55 100644 --- a/src/providers/mssql/qgsmssqlfeatureiterator.cpp +++ b/src/providers/mssql/qgsmssqlfeatureiterator.cpp @@ -108,8 +108,8 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest &request ) { //ensure that all fields required for filter expressions are prepared QSet attributeIndexes = request.filterExpression()->referencedAttributeIndexes( mSource->mFields ); - attributeIndexes += attrs.toSet(); - attrs = attributeIndexes.toList(); + attributeIndexes += qgis::listToSet( attrs ); + attrs = qgis::setToList( attributeIndexes ); } // ensure that all attributes required for order by are fetched diff --git a/src/providers/postgres/qgspgtablemodel.cpp b/src/providers/postgres/qgspgtablemodel.cpp index bd6cf3c5df24..d006ce163988 100644 --- a/src/providers/postgres/qgspgtablemodel.cpp +++ b/src/providers/postgres/qgspgtablemodel.cpp @@ -353,8 +353,8 @@ bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, in QStringList pkCols = idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 1 ).toStringList(); if ( tip.isEmpty() && !pkCols.isEmpty() ) { - QSet s0( idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 2 ).toStringList().toSet() ); - QSet s1( pkCols.toSet() ); + QSet s0( qgis::listToSet( idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 2 ).toStringList() ) ); + QSet s1( qgis::listToSet( pkCols ) ); if ( !s0.intersects( s1 ) ) tip = tr( "Select columns in the '%1' column that uniquely identify features of this layer" ).arg( tr( "Feature id" ) ); } @@ -430,8 +430,8 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString &conn } QStandardItem *pkItem = itemFromIndex( index.sibling( index.row(), DbtmPkCol ) ); - QSet s0( pkItem->data( Qt::UserRole + 1 ).toStringList().toSet() ); - QSet s1( pkItem->data( Qt::UserRole + 2 ).toStringList().toSet() ); + QSet s0( qgis::listToSet( pkItem->data( Qt::UserRole + 1 ).toStringList() ) ); + QSet s1( qgis::listToSet( pkItem->data( Qt::UserRole + 2 ).toStringList() ) ); if ( !s0.isEmpty() && !s0.intersects( s1 ) ) { // no valid primary candidate selected @@ -471,7 +471,7 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString &conn cols << QgsPostgresConn::quotedIdentifier( col ); } - QgsSettings().setValue( QStringLiteral( "/PostgreSQL/connections/%1/keys/%2/%3" ).arg( mConnName, schemaName, tableName ), QVariant( s1.toList() ) ); + QgsSettings().setValue( QStringLiteral( "/PostgreSQL/connections/%1/keys/%2/%3" ).arg( mConnName, schemaName, tableName ), QVariant( qgis::setToList( s1 ) ) ); uri.setDataSource( schemaName, tableName, geomColumnName, sql, cols.join( ',' ) ); uri.setUseEstimatedMetadata( useEstimatedMetadata ); diff --git a/src/providers/postgres/qgspostgresfeatureiterator.cpp b/src/providers/postgres/qgspostgresfeatureiterator.cpp index 1f0a4a1c0fa5..aebd7b42bfba 100644 --- a/src/providers/postgres/qgspostgresfeatureiterator.cpp +++ b/src/providers/postgres/qgspostgresfeatureiterator.cpp @@ -108,8 +108,8 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource QgsAttributeList attrs = mRequest.subsetOfAttributes(); //ensure that all fields required for filter expressions are prepared QSet attributeIndexes = request.filterExpression()->referencedAttributeIndexes( mSource->mFields ); - attributeIndexes += attrs.toSet(); - mRequest.setSubsetOfAttributes( attributeIndexes.toList() ); + attributeIndexes += qgis::listToSet( attrs ); + mRequest.setSubsetOfAttributes( qgis::setToList( attributeIndexes ) ); } mFilterRequiresGeometry = request.filterExpression()->needsGeometry(); diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index bb1e0a296de0..b53fb688aea7 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -3284,8 +3284,8 @@ bool QgsPostgresProvider::changeFeatures( const QgsChangedAttributesMap &attr_ma { conn->begin(); - QgsFeatureIds ids( attr_map.keys().toSet() ); - ids |= geometry_map.keys().toSet(); + QgsFeatureIds ids( qgis::listToSet( attr_map.keys() ) ); + ids |= qgis::listToSet( geometry_map.keys() ); // cycle through the features const auto constIds = ids; diff --git a/src/providers/spatialite/qgsspatialitefeatureiterator.cpp b/src/providers/spatialite/qgsspatialitefeatureiterator.cpp index be65bd462bfe..2ba6bd04076c 100644 --- a/src/providers/spatialite/qgsspatialitefeatureiterator.cpp +++ b/src/providers/spatialite/qgsspatialitefeatureiterator.cpp @@ -115,8 +115,8 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeature QgsAttributeList attrs = request.subsetOfAttributes(); //ensure that all fields required for filter expressions are prepared QSet attributeIndexes = request.filterExpression()->referencedAttributeIndexes( mSource->mFields ); - attributeIndexes += attrs.toSet(); - mRequest.setSubsetOfAttributes( attributeIndexes.toList() ); + attributeIndexes += qgis::listToSet( attrs ); + mRequest.setSubsetOfAttributes( qgis::setToList( attributeIndexes ) ); } if ( request.filterExpression()->needsGeometry() ) { @@ -211,8 +211,8 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeature { attributeIndexes << attrIdx; } - attributeIndexes += mRequest.subsetOfAttributes().toSet(); - mRequest.setSubsetOfAttributes( attributeIndexes.toList() ); + attributeIndexes += qgis::listToSet( mRequest.subsetOfAttributes() ); + mRequest.setSubsetOfAttributes( qgis::setToList( attributeIndexes ) ); } // preparing the SQL statement diff --git a/src/providers/wcs/qgswcscapabilities.cpp b/src/providers/wcs/qgswcscapabilities.cpp index 2481e9c84687..d52f74e6891e 100644 --- a/src/providers/wcs/qgswcscapabilities.cpp +++ b/src/providers/wcs/qgswcscapabilities.cpp @@ -1122,7 +1122,7 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom11( QByteArray const &xml, QgsW } if ( !authids.isEmpty() ) { - coverage->supportedCrs = authids.toList(); + coverage->supportedCrs = qgis::setToList( authids ); } coverage->described = true; diff --git a/src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp b/src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp index c9bbdf3c3d3c..be86dd982320 100644 --- a/src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp +++ b/src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp @@ -524,8 +524,7 @@ void QgsBackgroundCachedFeatureIterator::featureReceivedSynchronous( const QVect } if ( !mWriterFile && mWriterByteArray.size() > mWriteTransferThreshold ) { - QString thisStr; - thisStr.sprintf( "%p", this ); + const QString thisStr = QStringLiteral( "%1" ).arg( reinterpret_cast< quintptr >( this ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); ++ mCounter; mWriterFilename = QDir( mShared->acquireCacheDirectory() ).filePath( QStringLiteral( "iterator_%1_%2.bin" ).arg( thisStr ).arg( mCounter ) ); QgsDebugMsgLevel( QStringLiteral( "Transferring feature iterator cache to %1" ).arg( mWriterFilename ), 4 ); diff --git a/src/providers/wfs/qgsbackgroundcachedshareddata.cpp b/src/providers/wfs/qgsbackgroundcachedshareddata.cpp index 929b5ce35363..2e329777205e 100644 --- a/src/providers/wfs/qgsbackgroundcachedshareddata.cpp +++ b/src/providers/wfs/qgsbackgroundcachedshareddata.cpp @@ -212,8 +212,7 @@ bool QgsBackgroundCachedSharedData::createCache() logMessageWithReason( QStringLiteral( "GDAL SQLite driver not available" ) ); return false; } - QString vsimemFilename; - vsimemFilename.sprintf( "/vsimem/qgis_cache_template_%p/features.sqlite", this ); + const QString vsimemFilename = QStringLiteral( "/vsimem/qgis_cache_template_%1/features.sqlite" ).arg( reinterpret_cast< quintptr >( this ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); mCacheTablename = CPLGetBasename( vsimemFilename.toStdString().c_str() ); VSIUnlink( vsimemFilename.toStdString().c_str() ); const char *apszOptions[] = { "INIT_WITH_EPSG=NO", "SPATIALITE=YES", nullptr }; diff --git a/src/providers/wfs/qgsoapifitemsrequest.cpp b/src/providers/wfs/qgsoapifitemsrequest.cpp index 3645f5710dde..52e91fbf7fdb 100644 --- a/src/providers/wfs/qgsoapifitemsrequest.cpp +++ b/src/providers/wfs/qgsoapifitemsrequest.cpp @@ -84,8 +84,7 @@ void QgsOapifItemsRequest::processReply() return; } - QString vsimemFilename; - vsimemFilename.sprintf( "/vsimem/oaipf_%p.json", &buffer ); + const QString vsimemFilename = QStringLiteral( "/vsimem/oaipf_%1.json" ).arg( reinterpret_cast< quintptr >( &buffer ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); VSIFCloseL( VSIFileFromMemBuffer( vsimemFilename.toUtf8().constData(), const_cast( reinterpret_cast( buffer.constData() ) ), buffer.size(), diff --git a/src/providers/wfs/qgswfsprovider.cpp b/src/providers/wfs/qgswfsprovider.cpp index a99f11ce212a..29195e5d4961 100644 --- a/src/providers/wfs/qgswfsprovider.cpp +++ b/src/providers/wfs/qgswfsprovider.cpp @@ -1078,9 +1078,7 @@ QString QgsWFSProvider::convertToXML( const QVariant &value ) QDateTime dt = value.toDateTime().toUTC(); if ( !dt.isNull() ) { - valueStr.sprintf( "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", - dt.date().year(), dt.date().month(), dt.date().day(), - dt.time().hour(), dt.time().minute(), dt.time().second(), dt.time().msec() ); + valueStr = dt.toString( QStringLiteral( "yyyy-MM-ddThh:mm:ss.zzzZ" ) ); } else { diff --git a/src/providers/wfs/qgswfssourceselect.cpp b/src/providers/wfs/qgswfssourceselect.cpp index 7f78024c804f..6fb524fbd2a0 100644 --- a/src/providers/wfs/qgswfssourceselect.cpp +++ b/src/providers/wfs/qgswfssourceselect.cpp @@ -837,7 +837,7 @@ void QgsWFSSourceSelect::changeCRSFilter() QMap::const_iterator crsIterator = mAvailableCRS.constFind( currentTypename ); if ( crsIterator != mAvailableCRS.constEnd() ) { - QSet crsNames( crsIterator->toSet() ); + QSet crsNames( qgis::listToSet( *crsIterator ) ); if ( mProjectionSelector ) { diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index fab4c2c3804d..dfd8834d203c 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -581,7 +581,7 @@ void QgsWmsProvider::fetchOtherResTiles( QgsTileMode tileMode, const QgsRectangl } // get URLs of tiles because their URLs are used as keys in the tile cache - TilePositions tiles = tilesSet.toList(); + TilePositions tiles = qgis::setToList( tilesSet ); TileRequests requests; switch ( tileMode ) { @@ -3296,7 +3296,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa QgsDebugMsg( "parsing GML error: " + err.message() ); return QgsRasterIdentifyResult( err ); } - results.insert( results.size(), qVariantFromValue( featureStoreList ) ); + results.insert( results.size(), QVariant::fromValue( featureStoreList ) ); } else if ( jsonPart != -1 ) { @@ -3423,7 +3423,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa results.insert( results.size(), err ); // string returned for format type "feature" means error } - results.insert( results.size(), qVariantFromValue( featureStoreList ) ); + results.insert( results.size(), QVariant::fromValue( featureStoreList ) ); } } } diff --git a/src/providers/wms/qgswmssourceselect.cpp b/src/providers/wms/qgswmssourceselect.cpp index 81bcc4f0d7f5..99118d359beb 100644 --- a/src/providers/wms/qgswmssourceselect.cpp +++ b/src/providers/wms/qgswmssourceselect.cpp @@ -786,9 +786,9 @@ void QgsWMSSourceSelect::collectNamedLayers( QTreeWidgetItem *item, QStringList titles << titleName; if ( mCRSs.isEmpty() ) - mCRSs = item->data( 0, Qt::UserRole + 2 ).toStringList().toSet(); + mCRSs = qgis::listToSet( item->data( 0, Qt::UserRole + 2 ).toStringList() ); else - mCRSs.intersect( item->data( 0, Qt::UserRole + 2 ).toStringList().toSet() ); + mCRSs.intersect( qgis::listToSet( item->data( 0, Qt::UserRole + 2 ).toStringList() ) ); } } @@ -832,9 +832,9 @@ void QgsWMSSourceSelect::lstLayers_itemSelectionChanged() styles << QString(); titles << titleName; if ( mCRSs.isEmpty() ) - mCRSs = item->data( 0, Qt::UserRole + 2 ).toStringList().toSet(); + mCRSs = qgis::listToSet( item->data( 0, Qt::UserRole + 2 ).toStringList() ); else - mCRSs.intersect( item->data( 0, Qt::UserRole + 2 ).toStringList().toSet() ); + mCRSs.intersect( qgis::listToSet( item->data( 0, Qt::UserRole + 2 ).toStringList() ) ); } else { @@ -843,9 +843,9 @@ void QgsWMSSourceSelect::lstLayers_itemSelectionChanged() styles << styleName; titles << titleName; if ( mCRSs.isEmpty() ) - mCRSs = item->parent()->data( 0, Qt::UserRole + 2 ).toStringList().toSet(); + mCRSs = qgis::listToSet( item->parent()->data( 0, Qt::UserRole + 2 ).toStringList() ); else - mCRSs.intersect( item->parent()->data( 0, Qt::UserRole + 2 ).toStringList().toSet() ); + mCRSs.intersect( qgis::listToSet( item->parent()->data( 0, Qt::UserRole + 2 ).toStringList() ) ); } } @@ -1149,13 +1149,13 @@ void QgsWMSSourceSelect::filterLayers( const QString &searchText ) // hide all setChildrenVisible( lstLayers->invisibleRootItem(), false ); // find and show matching items in name and title columns - QSet items = lstLayers->findItems( searchText, Qt::MatchContains | Qt::MatchRecursive, 1 ).toSet(); - items.unite( lstLayers->findItems( searchText, Qt::MatchContains | Qt::MatchRecursive, 2 ).toSet() ); + QSet items = qgis::listToSet( lstLayers->findItems( searchText, Qt::MatchContains | Qt::MatchRecursive, 1 ) ); + items.unite( qgis::listToSet( lstLayers->findItems( searchText, Qt::MatchContains | Qt::MatchRecursive, 2 ) ) ); // if nothing found, search in abstract too if ( items.isEmpty() ) { - items = lstLayers->findItems( searchText, Qt::MatchContains | Qt::MatchRecursive, 3 ).toSet(); + items = qgis::listToSet( lstLayers->findItems( searchText, Qt::MatchContains | Qt::MatchRecursive, 3 ) ); } mTreeInitialExpand.clear(); diff --git a/src/server/services/wms/qgswmsgetcapabilities.cpp b/src/server/services/wms/qgswmsgetcapabilities.cpp index d3ab7d09894e..81f40185afc7 100644 --- a/src/server/services/wms/qgswmsgetcapabilities.cpp +++ b/src/server/services/wms/qgswmsgetcapabilities.cpp @@ -1258,7 +1258,7 @@ namespace QgsWms uniqueValues.unite( vl->uniqueValues( endFieldIndex ) ); } // sort unique values - QList values = uniqueValues.toList(); + QList values = qgis::setToList( uniqueValues ); std::sort( values.begin(), values.end() ); QDomElement dimElem = doc.createElement( QStringLiteral( "Dimension" ) ); @@ -1771,7 +1771,7 @@ namespace QgsWms } QStringList outputCrsList = QgsServerProjectUtils::wmsOutputCrsList( *project ); - appendCrsElementsToLayer( doc, groupElem, combinedCRSSet.toList(), outputCrsList ); + appendCrsElementsToLayer( doc, groupElem, qgis::setToList( combinedCRSSet ), outputCrsList ); QgsCoordinateReferenceSystem groupCRS = project->crs(); if ( considerMapExtent ) @@ -1782,7 +1782,7 @@ namespace QgsWms combinedBBox = mapRect; } } - appendLayerBoundingBoxes( doc, groupElem, combinedBBox, groupCRS, combinedCRSSet.toList(), outputCrsList, project ); + appendLayerBoundingBoxes( doc, groupElem, combinedBBox, groupCRS, qgis::setToList( combinedCRSSet ), outputCrsList, project ); } diff --git a/src/server/services/wms/qgswmsrenderer.cpp b/src/server/services/wms/qgswmsrenderer.cpp index d3b52aeffac5..dca06759e412 100644 --- a/src/server/services/wms/qgswmsrenderer.cpp +++ b/src/server/services/wms/qgswmsrenderer.cpp @@ -2885,7 +2885,7 @@ namespace QgsWms uniqueValues.unite( layer->uniqueValues( endFieldIndex ) ); } // sort unique values - QList values = uniqueValues.toList(); + QList values = qgis::setToList( uniqueValues ); std::sort( values.begin(), values.end() ); if ( dim.defaultDisplayType == QgsVectorLayerServerProperties::WmsDimensionInfo::MinValue ) { diff --git a/tests/bench/qgsbench.h b/tests/bench/qgsbench.h index 357055ea3eea..ed4d29856b1b 100644 --- a/tests/bench/qgsbench.h +++ b/tests/bench/qgsbench.h @@ -83,7 +83,7 @@ class QgsBench : public QObject double mUserStart; double mSysStart; - QTime mWallTime; // 'wall clock' time + QElapsedTimer mWallTime; // 'wall clock' time // user, sys, total times QVector mTimes; diff --git a/tests/src/analysis/testqgsprocessing.cpp b/tests/src/analysis/testqgsprocessing.cpp index 2584d55665ff..99e45110da9d 100644 --- a/tests/src/analysis/testqgsprocessing.cpp +++ b/tests/src/analysis/testqgsprocessing.cpp @@ -691,20 +691,20 @@ void TestQgsProcessing::addProvider() //try adding another provider DummyProvider *p2 = new DummyProvider( "p2" ); QVERIFY( r.addProvider( p2 ) ); - QCOMPARE( r.providers().toSet(), QSet< QgsProcessingProvider * >() << p << p2 ); + QCOMPARE( qgis::listToSet( r.providers() ), QSet< QgsProcessingProvider * >() << p << p2 ); QCOMPARE( spyProviderAdded.count(), 2 ); QCOMPARE( spyProviderAdded.last().at( 0 ).toString(), QString( "p2" ) ); //try adding a provider with duplicate id DummyProvider *p3 = new DummyProvider( "p2" ); QVERIFY( !r.addProvider( p3 ) ); - QCOMPARE( r.providers().toSet(), QSet< QgsProcessingProvider * >() << p << p2 ); + QCOMPARE( qgis::listToSet( r.providers() ), QSet< QgsProcessingProvider * >() << p << p2 ); QCOMPARE( spyProviderAdded.count(), 2 ); // test that adding a provider which does not load means it is not added to registry DummyProviderNoLoad *p4 = new DummyProviderNoLoad( "p4" ); QVERIFY( !r.addProvider( p4 ) ); - QCOMPARE( r.providers().toSet(), QSet< QgsProcessingProvider * >() << p << p2 ); + QCOMPARE( qgis::listToSet( r.providers() ), QSet< QgsProcessingProvider * >() << p << p2 ); QCOMPARE( spyProviderAdded.count(), 2 ); } diff --git a/tests/src/app/testqgsmaptooladdfeatureline.cpp b/tests/src/app/testqgsmaptooladdfeatureline.cpp index b744fb1422b0..d83459e7443a 100644 --- a/tests/src/app/testqgsmaptooladdfeatureline.cpp +++ b/tests/src/app/testqgsmaptooladdfeatureline.cpp @@ -561,7 +561,7 @@ void TestQgsMapToolAddFeatureLine::testTopologicalEditingZ() QString wkt = "LineStringZ (6 6.5 5, 6.25 6.5 333, 6.75 6.5 333, 7.25 6.5 333, 7.5 6.5 333)"; QCOMPARE( mLayerTopoZ->getFeature( newFid ).geometry(), QgsGeometry::fromWkt( wkt ) ); wkt = "MultiLineStringZ ((7.25 6 0, 7.25 6.5 333, 7.25 7 0, 7.5 7 0, 7.5 6.5 333, 7.5 6 0, 7.25 6 0),(6 6 0, 6 6.5 5, 6 7 10, 7 7 0, 7 6 0, 6 6 0),(6.25 6.25 0, 6.75 6.25 0, 6.75 6.5 333, 6.75 6.75 0, 6.25 6.75 0, 6.25 6.5 333, 6.25 6.25 0))"; - QCOMPARE( mLayerTopoZ->getFeature( oldFids.toList().last() ).geometry(), QgsGeometry::fromWkt( wkt ) ); + QCOMPARE( mLayerTopoZ->getFeature( qgis::setToList( oldFids ).last() ).geometry(), QgsGeometry::fromWkt( wkt ) ); mLayerLine->undoStack()->undo(); diff --git a/tests/src/core/testqgsexpressioncontext.cpp b/tests/src/core/testqgsexpressioncontext.cpp index e08fe92645ef..097bf161da76 100644 --- a/tests/src/core/testqgsexpressioncontext.cpp +++ b/tests/src/core/testqgsexpressioncontext.cpp @@ -939,7 +939,7 @@ void TestQgsExpressionContext::readWriteScope() // valid element s2.readXml( e, QgsReadWriteContext() ); QCOMPARE( s2.variableCount(), 2 ); - QCOMPARE( s2.variableNames().toSet(), QSet< QString >() << QStringLiteral( "v1" ) << QStringLiteral( "v2" ) ); + QCOMPARE( qgis::listToSet( s2.variableNames() ), QSet< QString >() << QStringLiteral( "v1" ) << QStringLiteral( "v2" ) ); QCOMPARE( s2.variable( QStringLiteral( "v1" ) ).toString(), QStringLiteral( "t1" ) ); QCOMPARE( s2.variable( QStringLiteral( "v2" ) ).toInt(), 55 ); } diff --git a/tests/src/core/testqgslabelingengine.cpp b/tests/src/core/testqgslabelingengine.cpp index b41020258b94..514590fc5ab4 100644 --- a/tests/src/core/testqgslabelingengine.cpp +++ b/tests/src/core/testqgslabelingengine.cpp @@ -752,7 +752,7 @@ void TestQgsLabelingEngine::testParticipatingLayers() QgsPalLayerSettings settings2; QgsVectorLayerLabelProvider *provider2 = new QgsVectorLayerLabelProvider( layer2, QStringLiteral( "test2" ), true, &settings2 ); engine.addProvider( provider2 ); - QCOMPARE( engine.participatingLayers().toSet(), QSet< QgsMapLayer * >() << vl << layer2 ); + QCOMPARE( qgis::listToSet( engine.participatingLayers() ), QSet< QgsMapLayer * >() << vl << layer2 ); // add a rule-based labeling node QgsRuleBasedLabeling::Rule *root = new QgsRuleBasedLabeling::Rule( nullptr ); @@ -764,7 +764,7 @@ void TestQgsLabelingEngine::testParticipatingLayers() QgsVectorLayer *layer3 = new QgsVectorLayer( QStringLiteral( "Point?field=col1:integer" ), QStringLiteral( "layer3" ), QStringLiteral( "memory" ) ); QgsRuleBasedLabelProvider *ruleProvider = new QgsRuleBasedLabelProvider( QgsRuleBasedLabeling( root ), layer3 ); engine.addProvider( ruleProvider ); - QCOMPARE( engine.participatingLayers().toSet(), QSet< QgsMapLayer * >() << vl << layer2 << layer3 ); + QCOMPARE( qgis::listToSet( engine.participatingLayers() ), QSet< QgsMapLayer * >() << vl << layer2 << layer3 ); } bool TestQgsLabelingEngine::imageCheck( const QString &testName, QImage &image, int mismatchCount ) diff --git a/tests/src/core/testqgslayoutmap.cpp b/tests/src/core/testqgslayoutmap.cpp index ce126a4f090a..aa7e3abbeb3f 100644 --- a/tests/src/core/testqgslayoutmap.cpp +++ b/tests/src/core/testqgslayoutmap.cpp @@ -424,32 +424,32 @@ void TestQgsLayoutMap::dataDefinedStyles() // test following of preset map->setFollowVisibilityPreset( true ); map->setFollowVisibilityPresetName( QStringLiteral( "test preset" ) ); - QSet result = map->layersToRender().toSet(); + QSet result = qgis::listToSet( map->layersToRender() ); QCOMPARE( result.count(), 2 ); map->setFollowVisibilityPresetName( QString() ); //test malformed style string map->dataDefinedProperties().setProperty( QgsLayoutObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "5" ) ) ); - result = map->layersToRender().toSet(); - QCOMPARE( result, layers.toSet() ); + result = qgis::listToSet( map->layersToRender() ); + QCOMPARE( result, qgis::listToSet( layers ) ); //test valid preset map->dataDefinedProperties().setProperty( QgsLayoutObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'test preset'" ) ) ); - result = map->layersToRender().toSet(); + result = qgis::listToSet( map->layersToRender() ); QCOMPARE( result.count(), 2 ); QVERIFY( result.contains( mLinesLayer ) ); QVERIFY( result.contains( mPointsLayer ) ); //test non-existent preset map->dataDefinedProperties().setProperty( QgsLayoutObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'bad preset'" ) ) ); - result = map->layersToRender().toSet(); - QCOMPARE( result, layers.toSet() ); + result = qgis::listToSet( map->layersToRender() ); + QCOMPARE( result, qgis::listToSet( layers ) ); //test that dd layer set overrides style layers map->dataDefinedProperties().setProperty( QgsLayoutObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'test preset'" ) ) ); map->dataDefinedProperties().setProperty( QgsLayoutObject::MapLayers, QgsProperty::fromExpression( QStringLiteral( "'%1'" ).arg( mPolysLayer->name() ) ) ); - result = map->layersToRender().toSet(); + result = qgis::listToSet( map->layersToRender() ); QCOMPARE( result.count(), 1 ); QVERIFY( result.contains( mPolysLayer ) ); map->dataDefinedProperties().setProperty( QgsLayoutObject::MapLayers, QgsProperty() ); diff --git a/tests/src/core/testqgsspatialindex.cpp b/tests/src/core/testqgsspatialindex.cpp index c359964d9450..5b23a463bf40 100644 --- a/tests/src/core/testqgsspatialindex.cpp +++ b/tests/src/core/testqgsspatialindex.cpp @@ -24,6 +24,7 @@ #include #include #include "qgslinestring.h" +#include "qgslogger.h" static QgsFeature _pointFeature( QgsFeatureId id, qreal x, qreal y ) { @@ -188,7 +189,7 @@ class TestQgsSpatialIndex : public QObject vl->dataProvider()->addFeatures( flist ); } - QTime t; + QElapsedTimer t; QgsSpatialIndex *indexBulk = nullptr; QgsSpatialIndex *indexInsert = nullptr; @@ -199,14 +200,14 @@ class TestQgsSpatialIndex : public QObject while ( fi.nextFeature( f ) ) ; } - qDebug( "iter only: %d ms", t.elapsed() ); + QgsDebugMsg( QStringLiteral( "iter only: %1 ms" ).arg( t.elapsed() ) ); t.start(); { QgsFeatureIterator fi = vl->getFeatures(); indexBulk = new QgsSpatialIndex( fi ); } - qDebug( "bulk load: %d ms", t.elapsed() ); + QgsDebugMsg( QStringLiteral( "bulk load: %1 ms" ).arg( t.elapsed() ) ); t.start(); { @@ -216,7 +217,7 @@ class TestQgsSpatialIndex : public QObject while ( fi.nextFeature( f ) ) indexInsert->addFeature( f ); } - qDebug( "insert: %d ms", t.elapsed() ); + QgsDebugMsg( QStringLiteral( "insert: %1 ms" ).arg( t.elapsed() ) ); // test whether a query will give us the same results QgsRectangle rect( 4.9, 4.9, 5.1, 5.1 ); diff --git a/tests/src/core/testqgstaskmanager.cpp b/tests/src/core/testqgstaskmanager.cpp index 304549a75f0e..a66ce1aa4bf6 100644 --- a/tests/src/core/testqgstaskmanager.cpp +++ b/tests/src/core/testqgstaskmanager.cpp @@ -1215,7 +1215,7 @@ void TestQgsTaskManager::activeTasks() QCoreApplication::processEvents(); } flushEvents(); - QCOMPARE( manager.activeTasks().toSet(), ( QList< QgsTask * >() << task ).toSet() ); + QCOMPARE( qgis::listToSet( manager.activeTasks() ), qgis::listToSet( QList< QgsTask * >() << task ) ); QCOMPARE( manager.countActiveTasks(), 1 ); QCOMPARE( spy.count(), 1 ); QCOMPARE( spy.last().at( 0 ).toInt(), 1 ); @@ -1225,7 +1225,7 @@ void TestQgsTaskManager::activeTasks() QCoreApplication::processEvents(); } flushEvents(); - QCOMPARE( manager.activeTasks().toSet(), ( QList< QgsTask * >() << task << task2 ).toSet() ); + QCOMPARE( qgis::listToSet( manager.activeTasks() ), qgis::listToSet( QList< QgsTask * >() << task << task2 ) ); QCOMPARE( manager.countActiveTasks(), 2 ); QCOMPARE( spy.count(), 2 ); QCOMPARE( spy.last().at( 0 ).toInt(), 2 ); @@ -1235,7 +1235,7 @@ void TestQgsTaskManager::activeTasks() QCoreApplication::processEvents(); } flushEvents(); - QCOMPARE( manager.activeTasks().toSet(), ( QList< QgsTask * >() << task2 ).toSet() ); + QCOMPARE( qgis::listToSet( manager.activeTasks() ), qgis::listToSet( QList< QgsTask * >() << task2 ) ); QCOMPARE( manager.countActiveTasks(), 1 ); QCOMPARE( spy.count(), 3 ); QCOMPARE( spy.last().at( 0 ).toInt(), 1 ); diff --git a/tests/src/core/testziplayer.cpp b/tests/src/core/testziplayer.cpp index 70c72477a090..de54b027faa5 100644 --- a/tests/src/core/testziplayer.cpp +++ b/tests/src/core/testziplayer.cpp @@ -155,7 +155,7 @@ bool TestZipLayer::testZipItem( const QString &myFileName, const QString &myChil QgsZipItem *myZipItem = new QgsZipItem( nullptr, myFileInfo.fileName(), myFileName ); myZipItem->populate(); // wait until populated in separate thread - QTime time; + QElapsedTimer time; time.start(); while ( myZipItem->state() != QgsDataItem::Populated && time.elapsed() < 5000 ) { diff --git a/tests/src/gui/testqgsdualview.cpp b/tests/src/gui/testqgsdualview.cpp index 05904af97e94..8a1555aaca12 100644 --- a/tests/src/gui/testqgsdualview.cpp +++ b/tests/src/gui/testqgsdualview.cpp @@ -143,7 +143,7 @@ void TestQgsDualView::testFilterSelected() // select some features QList< QgsFeatureId > selected; selected << ids.at( 1 ) << ids.at( 3 ); - mPointsLayer->selectByIds( selected.toSet() ); + mPointsLayer->selectByIds( qgis::listToSet( selected ) ); mDualView->setFilterMode( QgsAttributeTableFilterModel::ShowSelected ); QCOMPARE( mDualView->tableView()->model()->rowCount(), 2 ); diff --git a/tests/src/providers/testqgswcspublicservers.cpp b/tests/src/providers/testqgswcspublicservers.cpp index d5b552c30055..6defd4fc02be 100644 --- a/tests/src/providers/testqgswcspublicservers.cpp +++ b/tests/src/providers/testqgswcspublicservers.cpp @@ -404,7 +404,7 @@ void TestQgsWcsPublicServers::test() Q_FOREACH ( const QString &provider, providers ) { - QTime time; + QElapsedTimer time; time.start(); QString uri; if ( provider == QLatin1String( "wcs" ) )