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;
};
// 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 {
\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
*/
{
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]);
void weekendDays();
void listPatterns();
+ void measurementSystems();
+
private:
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
QString m_sysapp;
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"