@@ -40,6 +40,16 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field
40
40
41
41
QString result;
42
42
43
+ // Prepare locale
44
+ std::function<QLocale ()> f_locale = [ ]
45
+ {
46
+ QLocale locale ( QgsApplication::instance ()->locale () );
47
+ QLocale::NumberOptions options ( locale.numberOptions () );
48
+ options |= QLocale::NumberOption::OmitGroupSeparator;
49
+ locale.setNumberOptions ( options );
50
+ return locale;
51
+ };
52
+
43
53
const QgsField field = layer->fields ().at ( fieldIndex );
44
54
45
55
if ( field.type () == QVariant::Double &&
@@ -54,11 +64,7 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field
54
64
if ( ok )
55
65
{
56
66
// TODO: make the format configurable!
57
- QLocale locale ( QgsApplication::instance ()->locale () );
58
- QLocale::NumberOptions options ( locale.numberOptions () );
59
- options |= QLocale::NumberOption::OmitGroupSeparator;
60
- locale.setNumberOptions ( options );
61
- result = locale.toString ( val, ' f' , precision );
67
+ result = f_locale ().toString ( val, ' f' , precision );
62
68
}
63
69
}
64
70
}
@@ -69,11 +75,7 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field
69
75
double val ( value.toInt ( &ok ) );
70
76
if ( ok )
71
77
{
72
- QLocale locale ( QgsApplication::instance ()->locale () );
73
- QLocale::NumberOptions options ( locale.numberOptions () );
74
- options |= QLocale::NumberOption::OmitGroupSeparator;
75
- locale.setNumberOptions ( options );
76
- result = locale.toString ( val );
78
+ result = f_locale ().toString ( val );
77
79
}
78
80
}
79
81
else
0 commit comments