Skip to content

Commit 0a76d7c

Browse files
committed
Fixes unit tests
1 parent 58c38f2 commit 0a76d7c

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

python/server/auto_generated/qgsserverparameters.sip.in

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ Returns the type of the parameter as a string.
4343
Returns true if the parameter is valid, false otherwise.
4444
%End
4545

46-
QString toString() const;
46+
QString toString( bool defaultValue = false ) const;
4747
%Docstring
48-
Converts the parameter into a string.
48+
Converts the parameter into a string. If ``defaultValue`` is true
49+
and current value is empty, then the default value is returned.
4950
%End
5051

5152
QStringList toStringList( char delimiter = ',' ) const;

src/server/qgsserverparameters.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ QColor QgsServerParameterDefinition::toColor( bool &ok ) const
6262
return color;
6363
}
6464

65-
QString QgsServerParameterDefinition::toString() const
65+
QString QgsServerParameterDefinition::toString( const bool defaultValue ) const
6666
{
6767
QString value = mValue.toString();
6868

69-
if ( value.isEmpty() )
69+
if ( value.isEmpty() && defaultValue )
7070
value = mDefaultValue.toString();
7171

7272
return value;

src/server/qgsserverparameters.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ class SERVER_EXPORT QgsServerParameterDefinition
5959
virtual bool isValid() const;
6060

6161
/**
62-
* Converts the parameter into a string.
62+
* Converts the parameter into a string. If \a defaultValue is true
63+
* and current value is empty, then the default value is returned.
6364
*/
64-
QString toString() const;
65+
QString toString( bool defaultValue = false ) const;
6566

6667
/**
6768
* Converts the parameter into a list of strings.

src/server/services/wms/qgswmsparameters.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ namespace QgsWms
715715

716716
QString QgsWmsParameters::formatAsString() const
717717
{
718-
return mWmsParameters[ QgsWmsParameter::FORMAT ].toString();
718+
return mWmsParameters[ QgsWmsParameter::FORMAT ].toString( true );
719719
}
720720

721721
QString QgsWmsParameters::formatAsString( const QgsWmsParameters::Format format )

0 commit comments

Comments
 (0)