Skip to content
Permalink
Browse files

Move wms/wfs exclude legacy attributes reading after field flags reading

so they don't get overriden
  • Loading branch information
troopa81 authored and nyalldawson committed Sep 24, 2020
1 parent 9f2b50b commit 94fd3d9723c77c2f9fe4f79d1cb210566261ef0e
Showing with 25 additions and 22 deletions.
  1. +25 −22 src/core/qgsvectorlayer.cpp
@@ -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
@@ -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" ) ) );

0 comments on commit 94fd3d9

Please sign in to comment.
You can’t perform that action at this time.