Skip to content
Permalink
Browse files

Move logic into owsServiceTitle

  • Loading branch information
pathmapper authored and nyalldawson committed Jan 4, 2021
1 parent 118ba4d commit 6c21d935c6134e84b3b6ee7e17258ac1125cd4a5
@@ -37,7 +37,24 @@ bool QgsServerProjectUtils::owsServiceCapabilities( const QgsProject &project )

QString QgsServerProjectUtils::owsServiceTitle( const QgsProject &project )
{
return project.readEntry( QStringLiteral( "WMSServiceTitle" ), QStringLiteral( "/" ) );
QString title;
QString serviceTitle = project.readEntry( QStringLiteral( "WMSServiceTitle" ), QStringLiteral( "/" ) );
if ( !serviceTitle.isEmpty() )
{
title = serviceTitle;
}
else
{
if ( !project.title().isEmpty() )
{
title = project.title();
}
else
{
title = QStringLiteral( "untitled" );
}
}
return title;
}

QString QgsServerProjectUtils::owsServiceAbstract( const QgsProject &project )
@@ -68,7 +68,7 @@ namespace QgsServerProjectUtils
/**
* Returns the owsService title defined in project.
* \param project the QGIS project
* \returns the owsService title if defined in project.
* \returns the owsService title if defined in project with project title as fallback, "untitled" otherwise.
*/
SERVER_EXPORT QString owsServiceTitle( const QgsProject &project );

@@ -266,24 +266,9 @@ namespace QgsWms
nameElem.appendChild( nameText );
serviceElem.appendChild( nameElem );

QDomText titleText;
QString title = QgsServerProjectUtils::owsServiceTitle( *project );
// Service title
QDomElement titleElem = doc.createElement( QStringLiteral( "Title" ) );
if ( !title.isEmpty() )
{
titleText = doc.createTextNode( title );
}
else
{
if ( !project->title().isEmpty() )
{
titleText = doc.createTextNode( project->title() );
}
else
{
titleText = doc.createTextNode( QStringLiteral( "untitled" ) );
}
}
QDomText titleText = doc.createTextNode( QgsServerProjectUtils::owsServiceTitle( *project ) );
titleElem.appendChild( titleText );
serviceElem.appendChild( titleElem );

@@ -847,24 +832,8 @@ namespace QgsWms
}

// Root Layer title
QDomText layerParentTitleText;
QString rootLayerTitle = QgsServerProjectUtils::owsServiceTitle( *project );
QDomElement layerParentTitleElem = doc.createElement( QStringLiteral( "Title" ) );
if ( !rootLayerTitle.isEmpty() )
{
layerParentTitleText = doc.createTextNode( rootLayerTitle );
}
else
{
if ( !project->title().isEmpty() )
{
layerParentTitleText = doc.createTextNode( project->title() );
}
else
{
layerParentTitleText = doc.createTextNode( QStringLiteral( "untitled" ) );
}
}
QDomText layerParentTitleText = doc.createTextNode( QgsServerProjectUtils::owsServiceTitle( *project ) );
layerParentTitleElem.appendChild( layerParentTitleText );
layerParentElem.appendChild( layerParentTitleElem );

@@ -2066,6 +2035,3 @@ namespace QgsWms


} // namespace QgsWms



0 comments on commit 6c21d93

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