Skip to content

Commit

Permalink
Move wms/wfs exclude legacy attributes reading after field flags reading
Browse files Browse the repository at this point in the history
so they don't get overriden
  • Loading branch information
troopa81 authored and nyalldawson committed Sep 24, 2020
1 parent 9f2b50b commit 94fd3d9
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -2311,28 +2311,6 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
}

updateFields();

// Legacy reading for QGIS 3.14 and older projects
// Attributes excluded from WMS and WFS
const QList<QPair<QString, QgsField::ConfigurationFlag>> legacyConfig
{
qMakePair( QStringLiteral( "excludeAttributesWMS" ), QgsField::ConfigurationFlag::HideFromWms ),
qMakePair( QStringLiteral( "excludeAttributesWFS" ), QgsField::ConfigurationFlag::HideFromWfs )
};
for ( const auto &config : legacyConfig )
{
QDomNode excludeNode = layerNode.namedItem( config.first );
if ( !excludeNode.isNull() )
{
QDomNodeList attributeNodeList = excludeNode.toElement().elementsByTagName( QStringLiteral( "attribute" ) );
for ( int i = 0; i < attributeNodeList.size(); ++i )
{
QString fieldName = attributeNodeList.at( i ).toElement().text();
int index = mFields.indexFromName( fieldName );
setFieldConfigurationFlag( index, config.second, true );
}
}
}
}

// load field configuration
Expand Down Expand Up @@ -2367,6 +2345,31 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
}
}

// Legacy reading for QGIS 3.14 and older projects
// Attributes excluded from WMS and WFS
if ( categories.testFlag( Fields ) )
{
const QList<QPair<QString, QgsField::ConfigurationFlag>> legacyConfig
{
qMakePair( QStringLiteral( "excludeAttributesWMS" ), QgsField::ConfigurationFlag::HideFromWms ),
qMakePair( QStringLiteral( "excludeAttributesWFS" ), QgsField::ConfigurationFlag::HideFromWfs )
};
for ( const auto &config : legacyConfig )
{
QDomNode excludeNode = layerNode.namedItem( config.first );
if ( !excludeNode.isNull() )
{
QDomNodeList attributeNodeList = excludeNode.toElement().elementsByTagName( QStringLiteral( "attribute" ) );
for ( int i = 0; i < attributeNodeList.size(); ++i )
{
QString fieldName = attributeNodeList.at( i ).toElement().text();
int index = mFields.indexFromName( fieldName );
setFieldConfigurationFlag( index, config.second, true );
}
}
}
}

if ( categories.testFlag( GeometryOptions ) )
mGeometryOptions->readXml( layerNode.namedItem( QStringLiteral( "geometryOptions" ) ) );

Expand Down

0 comments on commit 94fd3d9

Please sign in to comment.