diff options
Diffstat (limited to 'src/corelib/tools/qlocale.h')
-rw-r--r-- | src/corelib/tools/qlocale.h | 98 |
1 files changed, 94 insertions, 4 deletions
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 6bb9f79..9f44e30 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -42,6 +42,7 @@ #ifndef QLOCALE_H #define QLOCALE_H +#include <QtCore/qvariant.h> #include <QtCore/qstring.h> #include <QtCore/qobjectdefs.h> @@ -68,6 +69,15 @@ public: QSystemLocale(); virtual ~QSystemLocale(); + struct CurrencyToStringArgument + { + CurrencyToStringArgument() { } + CurrencyToStringArgument(const QVariant &v, const QString &s) + : value(v), symbol(s) { } + QVariant value; + QString symbol; + }; + enum QueryType { LanguageId, // uint CountryId, // uint @@ -94,7 +104,19 @@ public: MeasurementSystem, // uint PositiveSign, // QString AMText, // QString - PMText // QString + PMText, // QString + FirstDayOfWeek, // Qt::DayOfWeek + Weekdays, // QList<Qt::DayOfWeek> + CurrencySymbol, // QString in: CurrencyToStringArgument + CurrencyToString, // QString in: qlonglong, qulonglong or double + UILanguages, // QStringList + StringToStandardQuotation, // QString in: QStringRef to quote + StringToAlternateQuotation, // QString in: QStringRef to quote + ScriptId, // uint + ListToSeparatedString, // QString + LocaleChanged, // system locale changed + NativeLanguageName, // QString + NativeCountryName // QString }; virtual QVariant query(QueryType type, QVariant in) const; virtual QLocale fallbackLocale() const; @@ -119,7 +141,10 @@ class Q_CORE_EXPORT QLocale friend class QTextStreamPrivate; public: +// GENERATED PART STARTS HERE +// see qlocale_data_p.h for more info on generated data enum Language { + AnyLanguage = 0, C = 1, Abkhazian = 2, Afan = 3, @@ -205,7 +230,6 @@ public: NauruLanguage = 83, Nepali = 84, Norwegian = 85, - NorwegianBokmal = Norwegian, Occitan = 86, Oriya = 87, Pashto = 88, @@ -261,8 +285,7 @@ public: Yoruba = 138, Zhuang = 139, Zulu = 140, - NorwegianNynorsk = 141, - Nynorsk = NorwegianNynorsk, // ### obsolete + Nynorsk = 141, Bosnian = 142, Divehi = 143, Manx = 144, @@ -336,9 +359,26 @@ public: CentralMoroccoTamazight = 212, KoyraboroSenni = 213, Shambala = 214, + NorwegianBokmal = Norwegian, + NorwegianNynorsk = Nynorsk, LastLanguage = Shambala }; + enum Script { + AnyScript = 0, + ArabicScript = 1, + CyrillicScript = 2, + DeseretScript = 3, + GurmukhiScript = 4, + SimplifiedHanScript = 5, + TraditionalHanScript = 6, + LatinScript = 7, + MongolianScript = 8, + TifinaghScript = 9, + SimplifiedChineseScript = SimplifiedHanScript, + TraditionalChineseScript = TraditionalHanScript, + LastScript = TifinaghScript + }; enum Country { AnyCountry = 0, Afghanistan = 1, @@ -589,6 +629,7 @@ public: LatinAmericaAndTheCaribbean = 246, LastCountry = LatinAmericaAndTheCaribbean }; +// GENERATED PART ENDS HERE enum MeasurementSystem { MetricSystem, ImperialSystem }; @@ -599,17 +640,29 @@ public: }; Q_DECLARE_FLAGS(NumberOptions, NumberOption) + enum CurrencySymbolFormat { + CurrencyIsoCode, + CurrencySymbol, + CurrencyDisplayName + }; + QLocale(); QLocale(const QString &name); QLocale(Language language, Country country = AnyCountry); + QLocale(Language language, Script script, Country country); QLocale(const QLocale &other); QLocale &operator=(const QLocale &other); Language language() const; + Script script() const; Country country() const; QString name() const; + QString bcp47Name() const; + QString nativeLanguageName() const; + QString nativeCountryName() const; + short toShort(const QString &s, bool *ok = 0, int base = 0) const; ushort toUShort(const QString &s, bool *ok = 0, int base = 0) const; int toInt(const QString &s, bool *ok = 0, int base = 0) const; @@ -661,6 +714,9 @@ public: QString dayName(int, FormatType format = LongFormat) const; QString standaloneDayName(int, FormatType format = LongFormat) const; + Qt::DayOfWeek firstDayOfWeek() const; + QList<Qt::DayOfWeek> weekdays() const; + QString amText() const; QString pmText() const; @@ -668,21 +724,40 @@ public: Qt::LayoutDirection textDirection() const; + QString currencySymbol(CurrencySymbolFormat = CurrencySymbol) const; + QString toCurrencyString(qlonglong, const QString &symbol = QString()) const; + QString toCurrencyString(qulonglong, const QString &symbol = QString()) const; + inline QString toCurrencyString(short, const QString &symbol = QString()) const; + inline QString toCurrencyString(ushort, const QString &symbol = QString()) const; + inline QString toCurrencyString(int, const QString &symbol = QString()) const; + inline QString toCurrencyString(uint, const QString &symbol = QString()) const; + QString toCurrencyString(double, const QString &symbol = QString()) const; + inline QString toCurrencyString(float, const QString &symbol = QString()) const; + + QStringList uiLanguages() const; + inline bool operator==(const QLocale &other) const; inline bool operator!=(const QLocale &other) const; static QString languageToString(Language language); static QString countryToString(Country country); + static QString scriptToString(Script script); static void setDefault(const QLocale &locale); static QLocale c() { return QLocale(C); } static QLocale system(); + static QList<QLocale> matchingLocales(QLocale::Language language, QLocale::Script script, QLocale::Country country); static QList<Country> countriesForLanguage(Language lang); void setNumberOptions(NumberOptions options); NumberOptions numberOptions() const; + enum QuotationStyle { StandardQuotation, AlternateQuotation }; + QString quoteString(const QString &str, QuotationStyle style = StandardQuotation) const; + QString quoteString(const QStringRef &str, QuotationStyle style = StandardQuotation) const; + + QString createSeparatedList(const QStringList &strl) const; //private: // this should be private, but can't be struct Data { quint16 index; @@ -716,6 +791,17 @@ inline bool QLocale::operator==(const QLocale &other) const inline bool QLocale::operator!=(const QLocale &other) const { return d() != other.d() || numberOptions() != other.numberOptions(); } +inline QString QLocale::toCurrencyString(short i, const QString &symbol) const + { return toCurrencyString(qlonglong(i), symbol); } +inline QString QLocale::toCurrencyString(ushort i, const QString &symbol) const + { return toCurrencyString(qulonglong(i), symbol); } +inline QString QLocale::toCurrencyString(int i, const QString &symbol) const +{ return toCurrencyString(qlonglong(i), symbol); } +inline QString QLocale::toCurrencyString(uint i, const QString &symbol) const +{ return toCurrencyString(qulonglong(i), symbol); } +inline QString QLocale::toCurrencyString(float i, const QString &symbol) const +{ return toCurrencyString(double(i), symbol); } + #ifndef QT_NO_DATASTREAM Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QLocale &); Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QLocale &); @@ -723,6 +809,10 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QLocale &); QT_END_NAMESPACE +#ifndef QT_NO_SYSTEMLOCALE +Q_DECLARE_METATYPE(QSystemLocale::CurrencyToStringArgument) +#endif + QT_END_HEADER #endif // QLOCALE_H |