Fix measurement system for the UK
THe UK still uses the Imperial system at least for distances and many other things. Change-Id: I99379de35620114328ad6a7fc9b226a46692bedd Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
This commit is contained in:
parent
bc0b37d6b6
commit
8660f6e385
@ -2080,7 +2080,7 @@ QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const
|
||||
for (int i = 0; i < ImperialMeasurementSystemsCount; ++i) {
|
||||
if (ImperialMeasurementSystems[i].languageId == m_language_id
|
||||
&& ImperialMeasurementSystems[i].countryId == m_country_id) {
|
||||
return QLocale::ImperialSystem;
|
||||
return ImperialMeasurementSystems[i].system;
|
||||
}
|
||||
}
|
||||
return QLocale::MetricSystem;
|
||||
|
@ -565,7 +565,12 @@ public:
|
||||
};
|
||||
// GENERATED PART ENDS HERE
|
||||
|
||||
enum MeasurementSystem { MetricSystem, ImperialSystem };
|
||||
enum MeasurementSystem {
|
||||
MetricSystem,
|
||||
ImperialUSSystem,
|
||||
ImperialUKSystem,
|
||||
ImperialSystem = ImperialUSSystem // Qt 4 compatibility
|
||||
};
|
||||
|
||||
enum FormatType { LongFormat, ShortFormat, NarrowFormat };
|
||||
enum NumberOption {
|
||||
|
@ -672,9 +672,11 @@
|
||||
|
||||
\value MetricSystem This value indicates metric units, such as meters,
|
||||
centimeters and millimeters.
|
||||
\value ImperialSystem This value indicates imperial units, such as inches and
|
||||
miles. There are several distinct imperial systems in the world; this
|
||||
value stands for the official United States imperial units.
|
||||
\value ImperialUSSystem This value indicates imperial units, such as inches and
|
||||
miles as they are used in the United States.
|
||||
\value ImperialUKSystem This value indicates imperial units, such as inches and
|
||||
miles as they are used in the United Kingdom.
|
||||
\value ImperialSystem Provided for compatibility. Same as ImperialUSSystem
|
||||
|
||||
\since 4.4
|
||||
*/
|
||||
|
@ -62,12 +62,14 @@ struct CountryLanguage
|
||||
{
|
||||
quint16 languageId;
|
||||
quint16 countryId;
|
||||
QLocale::MeasurementSystem system;
|
||||
};
|
||||
static const CountryLanguage ImperialMeasurementSystems[] = {
|
||||
{ 31, 225 },
|
||||
{ 31, 226 },
|
||||
{ 111, 225 },
|
||||
{ 163, 225 }
|
||||
{ QLocale::English, QLocale::UnitedStates, QLocale::ImperialUSSystem },
|
||||
{ QLocale::English, QLocale::UnitedStatesMinorOutlyingIslands, QLocale::ImperialUSSystem },
|
||||
{ QLocale::Spanish, QLocale::UnitedStates, QLocale::ImperialUSSystem },
|
||||
{ QLocale::Hawaiian, QLocale::UnitedStates, QLocale::ImperialUSSystem },
|
||||
{ QLocale::English, QLocale::UnitedKingdom, QLocale::ImperialUKSystem }
|
||||
};
|
||||
static const int ImperialMeasurementSystemsCount =
|
||||
sizeof(ImperialMeasurementSystems)/sizeof(ImperialMeasurementSystems[0]);
|
||||
|
@ -133,6 +133,8 @@ private slots:
|
||||
void weekendDays();
|
||||
void listPatterns();
|
||||
|
||||
void measurementSystems();
|
||||
|
||||
private:
|
||||
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
|
||||
QString m_sysapp;
|
||||
@ -2034,5 +2036,20 @@ void tst_QLocale::listPatterns()
|
||||
QCOMPARE(zh_CN.createSeparatedList(sl5), QString::fromUtf8("aaa" "\xe3\x80\x81" "bbb" "\xe3\x80\x81" "ccc" "\xe5\x92\x8c" "ddd"));
|
||||
}
|
||||
|
||||
void tst_QLocale::measurementSystems()
|
||||
{
|
||||
QLocale locale(QLocale::English, QLocale::UnitedStates);
|
||||
QCOMPARE(locale.measurementSystem(), QLocale::ImperialUSSystem);
|
||||
|
||||
locale = QLocale(QLocale::English, QLocale::UnitedKingdom);
|
||||
QCOMPARE(locale.measurementSystem(), QLocale::ImperialUKSystem);
|
||||
|
||||
locale = QLocale(QLocale::English, QLocale::Australia);
|
||||
QCOMPARE(locale.measurementSystem(), QLocale::MetricSystem);
|
||||
|
||||
locale = QLocale(QLocale::German);
|
||||
QCOMPARE(locale.measurementSystem(), QLocale::MetricSystem);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QLocale)
|
||||
#include "tst_qlocale.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user