Skip to content

Commit

Permalink
Use system locale for number representation
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 3, 2018
1 parent b0d5506 commit 88f36cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
16 changes: 3 additions & 13 deletions src/core/fieldformatter/qgsrangefieldformatter.cpp
Expand Up @@ -40,16 +40,6 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field

QString result;

// Prepare locale
std::function<QLocale()> f_locale = [ ]
{
QLocale locale( QgsApplication::instance()->locale() );
QLocale::NumberOptions options( locale.numberOptions() );
options |= QLocale::NumberOption::OmitGroupSeparator;
locale.setNumberOptions( options );
return locale;
};

const QgsField field = layer->fields().at( fieldIndex );

if ( field.type() == QVariant::Double &&
Expand All @@ -64,7 +54,7 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field
if ( ok )
{
// TODO: make the format configurable!
result = f_locale().toString( val, 'f', precision );
result = QLocale::system().toString( val, 'f', precision );
}
}
}
Expand All @@ -75,7 +65,7 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field
double val( value.toInt( &ok ) );
if ( ok )
{
result = f_locale().toString( val, 'f', 0 );
result = QLocale::system().toString( val, 'f', 0 );
}
}
else if ( ( field.type() == QVariant::LongLong ) &&
Expand All @@ -85,7 +75,7 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field
double val( value.toLongLong( &ok ) );
if ( ok )
{
result = f_locale().toString( val, 'f', 0 );
result = QLocale::system().toString( val, 'f', 0 );
}
}
else
Expand Down
1 change: 0 additions & 1 deletion src/gui/editorwidgets/qgsdoublespinbox.cpp
Expand Up @@ -32,7 +32,6 @@ QgsDoubleSpinBox::QgsDoubleSpinBox( QWidget *parent )
mLineEdit = new QgsSpinBoxLineEdit();

// By default, group separator is off
setLocale( QLocale( QgsApplication::locale( ) ) );
setLineEdit( mLineEdit );

QSize msz = minimumSizeHint();
Expand Down

0 comments on commit 88f36cd

Please sign in to comment.