[locale] Refactor setting of LC entries

This commit is contained in:
Adriaan de Groot 2019-09-07 17:02:59 +02:00
parent 5cac3ac6ad
commit d70d418d92

View File

@ -289,61 +289,31 @@ LocaleConfiguration::isEmpty() const
&& lc_identification.isEmpty(); && lc_identification.isEmpty();
} }
/// @brief Sets @p value on @p key in the @p map if @p value is non-empty
static inline void
add_lc( QMap< QString, QString >& map, const char* key, const QString& value )
{
if ( !value.isEmpty() )
{
map.insert( key, value );
}
}
QMap< QString, QString > QMap< QString, QString >
LocaleConfiguration::toMap() const LocaleConfiguration::toMap() const
{ {
QMap< QString, QString > map; QMap< QString, QString > map;
if ( !m_lang.isEmpty() ) add_lc( map, "LANG", m_lang );
{ add_lc( map, "LC_NUMERIC", lc_numeric );
map.insert( "LANG", m_lang ); add_lc( map, "LC_TIME", lc_time );
} add_lc( map, "LC_MONETARY", lc_monetary );
add_lc( map, "LC_PAPER", lc_paper );
if ( !lc_numeric.isEmpty() ) add_lc( map, "LC_NAME", lc_name );
{ add_lc( map, "LC_ADDRESS", lc_address );
map.insert( "LC_NUMERIC", lc_numeric ); add_lc( map, "LC_TELEPHONE", lc_telephone );
} add_lc( map, "LC_MEASUREMENT", lc_measurement );
add_lc( map, "LC_IDENTIFICATION", lc_identification );
if ( !lc_time.isEmpty() )
{
map.insert( "LC_TIME", lc_time );
}
if ( !lc_monetary.isEmpty() )
{
map.insert( "LC_MONETARY", lc_monetary );
}
if ( !lc_paper.isEmpty() )
{
map.insert( "LC_PAPER", lc_paper );
}
if ( !lc_name.isEmpty() )
{
map.insert( "LC_NAME", lc_name );
}
if ( !lc_address.isEmpty() )
{
map.insert( "LC_ADDRESS", lc_address );
}
if ( !lc_telephone.isEmpty() )
{
map.insert( "LC_TELEPHONE", lc_telephone );
}
if ( !lc_measurement.isEmpty() )
{
map.insert( "LC_MEASUREMENT", lc_measurement );
}
if ( !lc_identification.isEmpty() )
{
map.insert( "LC_IDENTIFICATION", lc_identification );
}
return map; return map;
} }