@@ -137,11 +137,11 @@ void QgsVectorLayerJoinBuffer::cacheJoinLayer( QgsVectorLayerJoinInfo &joinInfo
137137 request.setFlags ( QgsFeatureRequest::NoGeometry );
138138 // maybe user requested just a subset of layer's attributes
139139 // so we do not have to cache everything
140- bool hasSubset = joinInfo.joinFieldNamesSubset ();
141140 QVector<int > subsetIndices;
142- if ( hasSubset )
141+ if ( joinInfo. hasSubset () )
143142 {
144- subsetIndices = joinSubsetIndices ( cacheLayer, *joinInfo.joinFieldNamesSubset () );
143+ const QStringList subsetNames = QgsVectorLayerJoinInfo::joinFieldNamesSubset ( joinInfo );
144+ subsetIndices = joinSubsetIndices ( cacheLayer, subsetNames );
145145
146146 // we need just subset of attributes - but make sure to include join field name
147147 QgsAttributeList cacheLayerAttrs = subsetIndices.toList ();
@@ -156,7 +156,7 @@ void QgsVectorLayerJoinBuffer::cacheJoinLayer( QgsVectorLayerJoinInfo &joinInfo
156156 {
157157 QgsAttributes attrs = f.attributes ();
158158 QString key = attrs.at ( joinFieldIndex ).toString ();
159- if ( hasSubset )
159+ if ( joinInfo. hasSubset () )
160160 {
161161 QgsAttributes subsetAttrs ( subsetIndices.count () );
162162 for ( int i = 0 ; i < subsetIndices.count (); ++i )
@@ -213,11 +213,10 @@ void QgsVectorLayerJoinBuffer::updateFields( QgsFields &fields )
213213 QString joinFieldName = joinIt->joinFieldName ();
214214
215215 QSet<QString> subset;
216- bool hasSubset = false ;
217- if ( joinIt->joinFieldNamesSubset () )
216+ if ( joinIt->hasSubset () )
218217 {
219- hasSubset = true ;
220- subset = QSet<QString>::fromList ( *joinIt-> joinFieldNamesSubset () );
218+ const QStringList subsetNames = QgsVectorLayerJoinInfo::joinFieldNamesSubset ( *joinIt ) ;
219+ subset = QSet<QString>::fromList ( subsetNames );
221220 }
222221
223222 if ( joinIt->prefix ().isNull () )
@@ -232,12 +231,12 @@ void QgsVectorLayerJoinBuffer::updateFields( QgsFields &fields )
232231 for ( int idx = 0 ; idx < joinFields.count (); ++idx )
233232 {
234233 // if using just a subset of fields, filter some of them out
235- if ( hasSubset && !subset.contains ( joinFields.at ( idx ).name () ) )
234+ if ( joinIt-> hasSubset () && !subset.contains ( joinFields.at ( idx ).name () ) )
236235 continue ;
237236
238237 // skip the join field to avoid double field names (fields often have the same name)
239238 // when using subset of field, use all the selected fields
240- if ( hasSubset || joinFields.at ( idx ).name () != joinFieldName )
239+ if ( joinIt-> hasSubset () || joinFields.at ( idx ).name () != joinFieldName )
241240 {
242241 QgsField f = joinFields.at ( idx );
243242 f.setName ( prefix + f.name () );
@@ -279,10 +278,12 @@ void QgsVectorLayerJoinBuffer::writeXml( QDomNode &layer_node, QDomDocument &doc
279278 joinElem.setAttribute ( QStringLiteral ( " upsertOnEdit" ), joinIt->hasUpsertOnEdit () );
280279 joinElem.setAttribute ( QStringLiteral ( " cascadedDelete" ), joinIt->hasCascadedDelete () );
281280
282- if ( joinIt->joinFieldNamesSubset () )
281+ if ( joinIt->hasSubset () )
283282 {
284283 QDomElement subsetElem = document.createElement ( QStringLiteral ( " joinFieldsSubset" ) );
285- Q_FOREACH ( const QString &fieldName, *joinIt->joinFieldNamesSubset () )
284+ const QStringList subsetNames = QgsVectorLayerJoinInfo::joinFieldNamesSubset ( *joinIt );
285+
286+ Q_FOREACH ( const QString &fieldName, subsetNames )
286287 {
287288 QDomElement fieldElem = document.createElement ( QStringLiteral ( " field" ) );
288289 fieldElem.setAttribute ( QStringLiteral ( " name" ), fieldName );
@@ -552,10 +553,10 @@ bool QgsVectorLayerJoinBuffer::addFeatures( QgsFeatureList &features, QgsFeature
552553
553554 if ( existingFeature.isValid () )
554555 {
555- const QStringList *subsetFields = info.joinFieldNamesSubset ();
556- if ( subsetFields )
556+ if ( info.hasSubset () )
557557 {
558- Q_FOREACH ( const QString &field, *subsetFields )
558+ const QStringList subsetNames = QgsVectorLayerJoinInfo::joinFieldNamesSubset ( info );
559+ Q_FOREACH ( const QString &field, subsetNames )
559560 {
560561 QVariant newValue = joinFeature.attribute ( field );
561562 int fieldIndex = joinLayer->fields ().indexOf ( field );
0 commit comments