Skip to content

Commit

Permalink
Add project setting if attribute form should be considered for featur…
Browse files Browse the repository at this point in the history
…e info
  • Loading branch information
mhugent committed Jan 15, 2021
1 parent e28fb7f commit 090cd5c
Show file tree
Hide file tree
Showing 7 changed files with 418 additions and 355 deletions.
9 changes: 9 additions & 0 deletions python/server/auto_generated/qgsserverprojectutils.sip.in
Expand Up @@ -212,6 +212,15 @@ Returns if the geometry is displayed as Well Known Text in GetFeatureInfo reques
:param project: the QGIS project

:return: if the geometry is displayed as Well Known Text in GetFeatureInfo request.
%End

bool wmsFeatureInfoUseAttributeFormSettings( const QgsProject &project );
%Docstring
Returns if feature form settings should be considered for the format of the feature info response

:param project: the QGIS project

:return: true if the feature form settings shall be considered for the feature info response
%End

bool wmsFeatureInfoSegmentizeWktGeometry( const QgsProject &project );
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -665,6 +665,9 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mLayerRestrictionsListWidget->addItems( values );
}

bool useAttributeFormSettings = QgsProject::instance()->readBoolEntry( QStringLiteral( "WMSFeatureInfoUseAttributeFormSettings" ), QStringLiteral( "/" ) );
mUseAttributeFormSettingsCheckBox->setChecked( useAttributeFormSettings );

bool addWktGeometry = QgsProject::instance()->readBoolEntry( QStringLiteral( "WMSAddWktGeometry" ), QStringLiteral( "/" ) );
mAddWktGeometryCheckBox->setChecked( addWktGeometry );

Expand Down Expand Up @@ -1393,6 +1396,7 @@ void QgsProjectProperties::apply()
QgsProject::instance()->removeEntry( QStringLiteral( "WMSRestrictedLayers" ), QStringLiteral( "/" ) );
}

QgsProject::instance()->writeEntry( QStringLiteral( "WMSFeatureInfoUseAttributeFormSettings" ), QStringLiteral( "/" ), mUseAttributeFormSettingsCheckBox->isChecked() );
QgsProject::instance()->writeEntry( QStringLiteral( "WMSAddWktGeometry" ), QStringLiteral( "/" ), mAddWktGeometryCheckBox->isChecked() );
QgsProject::instance()->writeEntry( QStringLiteral( "WMSSegmentizeFeatureInfoGeometry" ), QStringLiteral( "/" ), mSegmentizeFeatureInfoGeometryCheckBox->isChecked() );
QgsProject::instance()->writeEntry( QStringLiteral( "WMSUseLayerIDs" ), QStringLiteral( "/" ), mWmsUseLayerIDs->isChecked() );
Expand Down
7 changes: 7 additions & 0 deletions src/server/qgsserverprojectutils.cpp
Expand Up @@ -172,6 +172,13 @@ bool QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( const QgsProject &proj
|| wktGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
}

bool QgsServerProjectUtils::wmsFeatureInfoUseAttributeFormSettings( const QgsProject &project )
{
QString useFormSettings = project.readEntry( QStringLiteral( "WMSFeatureInfoUseAttributeFormSettings" ), QStringLiteral( "/" ), "" );
return useFormSettings.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| useFormSettings.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
}

bool QgsServerProjectUtils::wmsFeatureInfoSegmentizeWktGeometry( const QgsProject &project )
{
QString segmGeom = project.readEntry( QStringLiteral( "WMSSegmentizeFeatureInfoGeometry" ), QStringLiteral( "/" ), "" );
Expand Down
7 changes: 7 additions & 0 deletions src/server/qgsserverprojectutils.h
Expand Up @@ -207,6 +207,13 @@ namespace QgsServerProjectUtils
*/
SERVER_EXPORT bool wmsFeatureInfoAddWktGeometry( const QgsProject &project );

/**
* Returns if feature form settings should be considered for the format of the feature info response
* \param project the QGIS project
* \returns true if the feature form settings shall be considered for the feature info response
*/
SERVER_EXPORT bool wmsFeatureInfoUseAttributeFormSettings( const QgsProject &project );

/**
* Returns if the geometry has to be segmentize in GetFeatureInfo request.
* \param project the QGIS project
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -1566,7 +1566,7 @@ namespace QgsWms

featureAttributes = feature.attributes();
QgsEditFormConfig editConfig = layer->editFormConfig();
if ( editConfig.layout() == QgsEditFormConfig::TabLayout )
if ( QgsServerProjectUtils::wmsFeatureInfoUseAttributeFormSettings( *mProject ) && editConfig.layout() == QgsEditFormConfig::TabLayout )
{
writeAttributesTabLayout( editConfig, layer, fields, featureAttributes, infoDocument, featureElement, renderContext );
}
Expand Down
35 changes: 32 additions & 3 deletions src/server/services/wms/qgswmsrenderer.h
Expand Up @@ -223,11 +223,40 @@ namespace QgsWms
QgsRectangle *featureBBox = nullptr,
QgsGeometry *filterGeom = nullptr ) const;

//!Recursively called to write tab layout groups to XML
/**
* Recursively called to write tab layout groups to XML
* \param group the tab layout group
* \param layer The vector layer
* \param fields attribute fields
* \param featureAttributes the feature attributes
* \param doc Feature info XML document
* \param featureElem the feature XML element
* \param renderContext Context to use for feature rendering
*/
void writeAttributesTabGroup( const QgsAttributeEditorElement *group, QgsVectorLayer *layer, const QgsFields &fields, QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &featureElem, QgsRenderContext &renderContext ) const;
//!Writes attributes to XML document using the group/attribute layout defined in the tab layout

/**
* Writes attributes to XML document using the group/attribute layout defined in the tab layout
* \param config editor config object
* \param layer The vector layer
* \param fields attribute fields
* \param featureAttributes the feature attributes
* \param doc Feature info XML document
* \param featureElem the feature XML element
* \param renderContext Context to use for feature rendering
*/
void writeAttributesTabLayout( QgsEditFormConfig &config, QgsVectorLayer *layer, const QgsFields &fields, QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &featureElem, QgsRenderContext &renderContext ) const;
//! Writes a vectorlayer attribute into the XML document

/**
* Writes a vectorlayer attribute into the XML document
* \param index of attribute to be written
* \param layer The vector layer
* \param fields attribute fields
* \param featureAttributes the feature attributes
* \param doc Feature info XML document
* \param featureElem the feature XML element
* \param renderContext Context to use for feature rendering
*/
void writeVectorLayerAttribute( int attributeIndex, QgsVectorLayer *layer, const QgsFields &fields, QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &featureElem, QgsRenderContext &renderContext ) const;

//! Appends feature info xml for the layer to the layer element of the dom document
Expand Down

0 comments on commit 090cd5c

Please sign in to comment.