Fixes unit tests

This commit is contained in:
Blottiere Paul 2019-02-25 09:55:10 +00:00
parent 58c38f2fb2
commit 0a76d7c108
4 changed files with 9 additions and 7 deletions

View File

@ -43,9 +43,10 @@ Returns the type of the parameter as a string.
Returns true if the parameter is valid, false otherwise.
%End
QString toString() const;
QString toString( bool defaultValue = false ) const;
%Docstring
Converts the parameter into a string.
Converts the parameter into a string. If ``defaultValue`` is true
and current value is empty, then the default value is returned.
%End
QStringList toStringList( char delimiter = ',' ) const;

View File

@ -62,11 +62,11 @@ QColor QgsServerParameterDefinition::toColor( bool &ok ) const
return color;
}
QString QgsServerParameterDefinition::toString() const
QString QgsServerParameterDefinition::toString( const bool defaultValue ) const
{
QString value = mValue.toString();
if ( value.isEmpty() )
if ( value.isEmpty() && defaultValue )
value = mDefaultValue.toString();
return value;

View File

@ -59,9 +59,10 @@ class SERVER_EXPORT QgsServerParameterDefinition
virtual bool isValid() const;
/**
* Converts the parameter into a string.
* Converts the parameter into a string. If \a defaultValue is true
* and current value is empty, then the default value is returned.
*/
QString toString() const;
QString toString( bool defaultValue = false ) const;
/**
* Converts the parameter into a list of strings.

View File

@ -715,7 +715,7 @@ namespace QgsWms
QString QgsWmsParameters::formatAsString() const
{
return mWmsParameters[ QgsWmsParameter::FORMAT ].toString();
return mWmsParameters[ QgsWmsParameter::FORMAT ].toString( true );
}
QString QgsWmsParameters::formatAsString( const QgsWmsParameters::Format format )