00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QLOCALE_H
00043 #define QLOCALE_H
00044
00045 #include <QtCore/qstring.h>
00046 #include <QtCore/qobjectdefs.h>
00047
00048 QT_BEGIN_HEADER
00049
00050 QT_BEGIN_NAMESPACE
00051
00052 QT_MODULE(Core)
00053
00054 class QDataStream;
00055 class QDate;
00056 class QDateTime;
00057 class QTime;
00058 class QVariant;
00059 class QTextStream;
00060 class QTextStreamPrivate;
00061
00062 class QLocale;
00063
00064 #ifndef QT_NO_SYSTEMLOCALE
00065 class Q_CORE_EXPORT QSystemLocale
00066 {
00067 public:
00068 QSystemLocale();
00069 virtual ~QSystemLocale();
00070
00071 enum QueryType {
00072 LanguageId,
00073 CountryId,
00074 DecimalPoint,
00075 GroupSeparator,
00076 ZeroDigit,
00077 NegativeSign,
00078 DateFormatLong,
00079 DateFormatShort,
00080 TimeFormatLong,
00081 TimeFormatShort,
00082 DayNameLong,
00083 DayNameShort,
00084 MonthNameLong,
00085 MonthNameShort,
00086 DateToStringLong,
00087 DateToStringShort,
00088 TimeToStringLong,
00089 TimeToStringShort,
00090 DateTimeFormatLong,
00091 DateTimeFormatShort,
00092 DateTimeToStringLong,
00093 DateTimeToStringShort,
00094 MeasurementSystem,
00095 PositiveSign,
00096 AMText,
00097 PMText
00098 };
00099 virtual QVariant query(QueryType type, QVariant in) const;
00100 virtual QLocale fallbackLocale() const;
00101
00102 private:
00103 QSystemLocale(bool);
00104 friend QSystemLocale *QSystemLocale_globalSystemLocale();
00105 };
00106 #endif
00107
00108 struct QLocalePrivate;
00109 class Q_CORE_EXPORT QLocale
00110 {
00111 Q_GADGET
00112 Q_ENUMS(Language)
00113 Q_ENUMS(Country)
00114 friend class QString;
00115 friend class QByteArray;
00116 friend class QIntValidator;
00117 friend class QDoubleValidator;
00118 friend class QTextStream;
00119 friend class QTextStreamPrivate;
00120
00121 public:
00122 enum Language {
00123 C = 1,
00124 Abkhazian = 2,
00125 Afan = 3,
00126 Afar = 4,
00127 Afrikaans = 5,
00128 Albanian = 6,
00129 Amharic = 7,
00130 Arabic = 8,
00131 Armenian = 9,
00132 Assamese = 10,
00133 Aymara = 11,
00134 Azerbaijani = 12,
00135 Bashkir = 13,
00136 Basque = 14,
00137 Bengali = 15,
00138 Bhutani = 16,
00139 Bihari = 17,
00140 Bislama = 18,
00141 Breton = 19,
00142 Bulgarian = 20,
00143 Burmese = 21,
00144 Byelorussian = 22,
00145 Cambodian = 23,
00146 Catalan = 24,
00147 Chinese = 25,
00148 Corsican = 26,
00149 Croatian = 27,
00150 Czech = 28,
00151 Danish = 29,
00152 Dutch = 30,
00153 English = 31,
00154 Esperanto = 32,
00155 Estonian = 33,
00156 Faroese = 34,
00157 FijiLanguage = 35,
00158 Finnish = 36,
00159 French = 37,
00160 Frisian = 38,
00161 Gaelic = 39,
00162 Galician = 40,
00163 Georgian = 41,
00164 German = 42,
00165 Greek = 43,
00166 Greenlandic = 44,
00167 Guarani = 45,
00168 Gujarati = 46,
00169 Hausa = 47,
00170 Hebrew = 48,
00171 Hindi = 49,
00172 Hungarian = 50,
00173 Icelandic = 51,
00174 Indonesian = 52,
00175 Interlingua = 53,
00176 Interlingue = 54,
00177 Inuktitut = 55,
00178 Inupiak = 56,
00179 Irish = 57,
00180 Italian = 58,
00181 Japanese = 59,
00182 Javanese = 60,
00183 Kannada = 61,
00184 Kashmiri = 62,
00185 Kazakh = 63,
00186 Kinyarwanda = 64,
00187 Kirghiz = 65,
00188 Korean = 66,
00189 Kurdish = 67,
00190 Kurundi = 68,
00191 Laothian = 69,
00192 Latin = 70,
00193 Latvian = 71,
00194 Lingala = 72,
00195 Lithuanian = 73,
00196 Macedonian = 74,
00197 Malagasy = 75,
00198 Malay = 76,
00199 Malayalam = 77,
00200 Maltese = 78,
00201 Maori = 79,
00202 Marathi = 80,
00203 Moldavian = 81,
00204 Mongolian = 82,
00205 NauruLanguage = 83,
00206 Nepali = 84,
00207 Norwegian = 85,
00208 NorwegianBokmal = Norwegian,
00209 Occitan = 86,
00210 Oriya = 87,
00211 Pashto = 88,
00212 Persian = 89,
00213 Polish = 90,
00214 Portuguese = 91,
00215 Punjabi = 92,
00216 Quechua = 93,
00217 RhaetoRomance = 94,
00218 Romanian = 95,
00219 Russian = 96,
00220 Samoan = 97,
00221 Sangho = 98,
00222 Sanskrit = 99,
00223 Serbian = 100,
00224 SerboCroatian = 101,
00225 Sesotho = 102,
00226 Setswana = 103,
00227 Shona = 104,
00228 Sindhi = 105,
00229 Singhalese = 106,
00230 Siswati = 107,
00231 Slovak = 108,
00232 Slovenian = 109,
00233 Somali = 110,
00234 Spanish = 111,
00235 Sundanese = 112,
00236 Swahili = 113,
00237 Swedish = 114,
00238 Tagalog = 115,
00239 Tajik = 116,
00240 Tamil = 117,
00241 Tatar = 118,
00242 Telugu = 119,
00243 Thai = 120,
00244 Tibetan = 121,
00245 Tigrinya = 122,
00246 TongaLanguage = 123,
00247 Tsonga = 124,
00248 Turkish = 125,
00249 Turkmen = 126,
00250 Twi = 127,
00251 Uigur = 128,
00252 Ukrainian = 129,
00253 Urdu = 130,
00254 Uzbek = 131,
00255 Vietnamese = 132,
00256 Volapuk = 133,
00257 Welsh = 134,
00258 Wolof = 135,
00259 Xhosa = 136,
00260 Yiddish = 137,
00261 Yoruba = 138,
00262 Zhuang = 139,
00263 Zulu = 140,
00264 NorwegianNynorsk = 141,
00265 Nynorsk = NorwegianNynorsk,
00266 Bosnian = 142,
00267 Divehi = 143,
00268 Manx = 144,
00269 Cornish = 145,
00270 Akan = 146,
00271 Konkani = 147,
00272 Ga = 148,
00273 Igbo = 149,
00274 Kamba = 150,
00275 Syriac = 151,
00276 Blin = 152,
00277 Geez = 153,
00278 Koro = 154,
00279 Sidamo = 155,
00280 Atsam = 156,
00281 Tigre = 157,
00282 Jju = 158,
00283 Friulian = 159,
00284 Venda = 160,
00285 Ewe = 161,
00286 Walamo = 162,
00287 Hawaiian = 163,
00288 Tyap = 164,
00289 Chewa = 165,
00290 Filipino = 166,
00291 SwissGerman = 167,
00292 SichuanYi = 168,
00293 Kpelle = 169,
00294 LowGerman = 170,
00295 SouthNdebele = 171,
00296 NorthernSotho = 172,
00297 NorthernSami = 173,
00298 Taroko = 174,
00299 Gusii = 175,
00300 Taita = 176,
00301 Fulah = 177,
00302 Kikuyu = 178,
00303 Samburu = 179,
00304 Sena = 180,
00305 NorthNdebele = 181,
00306 Rombo = 182,
00307 Tachelhit = 183,
00308 Kabyle = 184,
00309 Nyankole = 185,
00310 Bena = 186,
00311 Vunjo = 187,
00312 Bambara = 188,
00313 Embu = 189,
00314 Cherokee = 190,
00315 Morisyen = 191,
00316 Makonde = 192,
00317 Langi = 193,
00318 Ganda = 194,
00319 Bemba = 195,
00320 Kabuverdianu = 196,
00321 Meru = 197,
00322 Kalenjin = 198,
00323 Nama = 199,
00324 Machame = 200,
00325 Colognian = 201,
00326 Masai = 202,
00327 Soga = 203,
00328 Luyia = 204,
00329 Asu = 205,
00330 Teso = 206,
00331 Saho = 207,
00332 KoyraChiini = 208,
00333 Rwa = 209,
00334 Luo = 210,
00335 Chiga = 211,
00336 CentralMoroccoTamazight = 212,
00337 KoyraboroSenni = 213,
00338 Shambala = 214,
00339 LastLanguage = Shambala
00340 };
00341
00342 enum Country {
00343 AnyCountry = 0,
00344 Afghanistan = 1,
00345 Albania = 2,
00346 Algeria = 3,
00347 AmericanSamoa = 4,
00348 Andorra = 5,
00349 Angola = 6,
00350 Anguilla = 7,
00351 Antarctica = 8,
00352 AntiguaAndBarbuda = 9,
00353 Argentina = 10,
00354 Armenia = 11,
00355 Aruba = 12,
00356 Australia = 13,
00357 Austria = 14,
00358 Azerbaijan = 15,
00359 Bahamas = 16,
00360 Bahrain = 17,
00361 Bangladesh = 18,
00362 Barbados = 19,
00363 Belarus = 20,
00364 Belgium = 21,
00365 Belize = 22,
00366 Benin = 23,
00367 Bermuda = 24,
00368 Bhutan = 25,
00369 Bolivia = 26,
00370 BosniaAndHerzegowina = 27,
00371 Botswana = 28,
00372 BouvetIsland = 29,
00373 Brazil = 30,
00374 BritishIndianOceanTerritory = 31,
00375 BruneiDarussalam = 32,
00376 Bulgaria = 33,
00377 BurkinaFaso = 34,
00378 Burundi = 35,
00379 Cambodia = 36,
00380 Cameroon = 37,
00381 Canada = 38,
00382 CapeVerde = 39,
00383 CaymanIslands = 40,
00384 CentralAfricanRepublic = 41,
00385 Chad = 42,
00386 Chile = 43,
00387 China = 44,
00388 ChristmasIsland = 45,
00389 CocosIslands = 46,
00390 Colombia = 47,
00391 Comoros = 48,
00392 DemocraticRepublicOfCongo = 49,
00393 PeoplesRepublicOfCongo = 50,
00394 CookIslands = 51,
00395 CostaRica = 52,
00396 IvoryCoast = 53,
00397 Croatia = 54,
00398 Cuba = 55,
00399 Cyprus = 56,
00400 CzechRepublic = 57,
00401 Denmark = 58,
00402 Djibouti = 59,
00403 Dominica = 60,
00404 DominicanRepublic = 61,
00405 EastTimor = 62,
00406 Ecuador = 63,
00407 Egypt = 64,
00408 ElSalvador = 65,
00409 EquatorialGuinea = 66,
00410 Eritrea = 67,
00411 Estonia = 68,
00412 Ethiopia = 69,
00413 FalklandIslands = 70,
00414 FaroeIslands = 71,
00415 FijiCountry = 72,
00416 Finland = 73,
00417 France = 74,
00418 MetropolitanFrance = 75,
00419 FrenchGuiana = 76,
00420 FrenchPolynesia = 77,
00421 FrenchSouthernTerritories = 78,
00422 Gabon = 79,
00423 Gambia = 80,
00424 Georgia = 81,
00425 Germany = 82,
00426 Ghana = 83,
00427 Gibraltar = 84,
00428 Greece = 85,
00429 Greenland = 86,
00430 Grenada = 87,
00431 Guadeloupe = 88,
00432 Guam = 89,
00433 Guatemala = 90,
00434 Guinea = 91,
00435 GuineaBissau = 92,
00436 Guyana = 93,
00437 Haiti = 94,
00438 HeardAndMcDonaldIslands = 95,
00439 Honduras = 96,
00440 HongKong = 97,
00441 Hungary = 98,
00442 Iceland = 99,
00443 India = 100,
00444 Indonesia = 101,
00445 Iran = 102,
00446 Iraq = 103,
00447 Ireland = 104,
00448 Israel = 105,
00449 Italy = 106,
00450 Jamaica = 107,
00451 Japan = 108,
00452 Jordan = 109,
00453 Kazakhstan = 110,
00454 Kenya = 111,
00455 Kiribati = 112,
00456 DemocraticRepublicOfKorea = 113,
00457 RepublicOfKorea = 114,
00458 Kuwait = 115,
00459 Kyrgyzstan = 116,
00460 Lao = 117,
00461 Latvia = 118,
00462 Lebanon = 119,
00463 Lesotho = 120,
00464 Liberia = 121,
00465 LibyanArabJamahiriya = 122,
00466 Liechtenstein = 123,
00467 Lithuania = 124,
00468 Luxembourg = 125,
00469 Macau = 126,
00470 Macedonia = 127,
00471 Madagascar = 128,
00472 Malawi = 129,
00473 Malaysia = 130,
00474 Maldives = 131,
00475 Mali = 132,
00476 Malta = 133,
00477 MarshallIslands = 134,
00478 Martinique = 135,
00479 Mauritania = 136,
00480 Mauritius = 137,
00481 Mayotte = 138,
00482 Mexico = 139,
00483 Micronesia = 140,
00484 Moldova = 141,
00485 Monaco = 142,
00486 Mongolia = 143,
00487 Montserrat = 144,
00488 Morocco = 145,
00489 Mozambique = 146,
00490 Myanmar = 147,
00491 Namibia = 148,
00492 NauruCountry = 149,
00493 Nepal = 150,
00494 Netherlands = 151,
00495 NetherlandsAntilles = 152,
00496 NewCaledonia = 153,
00497 NewZealand = 154,
00498 Nicaragua = 155,
00499 Niger = 156,
00500 Nigeria = 157,
00501 Niue = 158,
00502 NorfolkIsland = 159,
00503 NorthernMarianaIslands = 160,
00504 Norway = 161,
00505 Oman = 162,
00506 Pakistan = 163,
00507 Palau = 164,
00508 PalestinianTerritory = 165,
00509 Panama = 166,
00510 PapuaNewGuinea = 167,
00511 Paraguay = 168,
00512 Peru = 169,
00513 Philippines = 170,
00514 Pitcairn = 171,
00515 Poland = 172,
00516 Portugal = 173,
00517 PuertoRico = 174,
00518 Qatar = 175,
00519 Reunion = 176,
00520 Romania = 177,
00521 RussianFederation = 178,
00522 Rwanda = 179,
00523 SaintKittsAndNevis = 180,
00524 StLucia = 181,
00525 StVincentAndTheGrenadines = 182,
00526 Samoa = 183,
00527 SanMarino = 184,
00528 SaoTomeAndPrincipe = 185,
00529 SaudiArabia = 186,
00530 Senegal = 187,
00531 Seychelles = 188,
00532 SierraLeone = 189,
00533 Singapore = 190,
00534 Slovakia = 191,
00535 Slovenia = 192,
00536 SolomonIslands = 193,
00537 Somalia = 194,
00538 SouthAfrica = 195,
00539 SouthGeorgiaAndTheSouthSandwichIslands = 196,
00540 Spain = 197,
00541 SriLanka = 198,
00542 StHelena = 199,
00543 StPierreAndMiquelon = 200,
00544 Sudan = 201,
00545 Suriname = 202,
00546 SvalbardAndJanMayenIslands = 203,
00547 Swaziland = 204,
00548 Sweden = 205,
00549 Switzerland = 206,
00550 SyrianArabRepublic = 207,
00551 Taiwan = 208,
00552 Tajikistan = 209,
00553 Tanzania = 210,
00554 Thailand = 211,
00555 Togo = 212,
00556 Tokelau = 213,
00557 TongaCountry = 214,
00558 TrinidadAndTobago = 215,
00559 Tunisia = 216,
00560 Turkey = 217,
00561 Turkmenistan = 218,
00562 TurksAndCaicosIslands = 219,
00563 Tuvalu = 220,
00564 Uganda = 221,
00565 Ukraine = 222,
00566 UnitedArabEmirates = 223,
00567 UnitedKingdom = 224,
00568 UnitedStates = 225,
00569 UnitedStatesMinorOutlyingIslands = 226,
00570 Uruguay = 227,
00571 Uzbekistan = 228,
00572 Vanuatu = 229,
00573 VaticanCityState = 230,
00574 Venezuela = 231,
00575 VietNam = 232,
00576 BritishVirginIslands = 233,
00577 USVirginIslands = 234,
00578 WallisAndFutunaIslands = 235,
00579 WesternSahara = 236,
00580 Yemen = 237,
00581 Yugoslavia = 238,
00582 Zambia = 239,
00583 Zimbabwe = 240,
00584 SerbiaAndMontenegro = 241,
00585 Montenegro = 242,
00586 Serbia = 243,
00587 SaintBarthelemy = 244,
00588 SaintMartin = 245,
00589 LatinAmericaAndTheCaribbean = 246,
00590 LastCountry = LatinAmericaAndTheCaribbean
00591 };
00592
00593 enum MeasurementSystem { MetricSystem, ImperialSystem };
00594
00595 enum FormatType { LongFormat, ShortFormat, NarrowFormat };
00596 enum NumberOption {
00597 OmitGroupSeparator = 0x01,
00598 RejectGroupSeparator = 0x02
00599 };
00600 Q_DECLARE_FLAGS(NumberOptions, NumberOption)
00601
00602 QLocale();
00603 QLocale(const QString &name);
00604 QLocale(Language language, Country country = AnyCountry);
00605 QLocale(const QLocale &other);
00606
00607 QLocale &operator=(const QLocale &other);
00608
00609 Language language() const;
00610 Country country() const;
00611 QString name() const;
00612
00613 short toShort(const QString &s, bool *ok = 0, int base = 0) const;
00614 ushort toUShort(const QString &s, bool *ok = 0, int base = 0) const;
00615 int toInt(const QString &s, bool *ok = 0, int base = 0) const;
00616 uint toUInt(const QString &s, bool *ok = 0, int base = 0) const;
00617 qlonglong toLongLong(const QString &s, bool *ok = 0, int base = 0) const;
00618 qlonglong toULongLong(const QString &s, bool *ok = 0, int base = 0) const;
00619 float toFloat(const QString &s, bool *ok = 0) const;
00620 double toDouble(const QString &s, bool *ok = 0) const;
00621
00622 QString toString(qlonglong i) const;
00623 QString toString(qulonglong i) const;
00624 inline QString toString(short i) const;
00625 inline QString toString(ushort i) const;
00626 inline QString toString(int i) const;
00627 inline QString toString(uint i) const;
00628 QString toString(double i, char f = 'g', int prec = 6) const;
00629 inline QString toString(float i, char f = 'g', int prec = 6) const;
00630 QString toString(const QDate &date, const QString &formatStr) const;
00631 QString toString(const QDate &date, FormatType format = LongFormat) const;
00632 QString toString(const QTime &time, const QString &formatStr) const;
00633 QString toString(const QTime &time, FormatType format = LongFormat) const;
00634 QString toString(const QDateTime &dateTime, FormatType format = LongFormat) const;
00635 QString toString(const QDateTime &dateTime, const QString &format) const;
00636
00637 QString dateFormat(FormatType format = LongFormat) const;
00638 QString timeFormat(FormatType format = LongFormat) const;
00639 QString dateTimeFormat(FormatType format = LongFormat) const;
00640 #ifndef QT_NO_DATESTRING
00641 QDate toDate(const QString &string, FormatType = LongFormat) const;
00642 QTime toTime(const QString &string, FormatType = LongFormat) const;
00643 QDateTime toDateTime(const QString &string, FormatType format = LongFormat) const;
00644 QDate toDate(const QString &string, const QString &format) const;
00645 QTime toTime(const QString &string, const QString &format) const;
00646 QDateTime toDateTime(const QString &string, const QString &format) const;
00647 #endif
00648
00649
00650
00651 QChar decimalPoint() const;
00652 QChar groupSeparator() const;
00653 QChar percent() const;
00654 QChar zeroDigit() const;
00655 QChar negativeSign() const;
00656 QChar positiveSign() const;
00657 QChar exponential() const;
00658
00659 QString monthName(int, FormatType format = LongFormat) const;
00660 QString standaloneMonthName(int, FormatType format = LongFormat) const;
00661 QString dayName(int, FormatType format = LongFormat) const;
00662 QString standaloneDayName(int, FormatType format = LongFormat) const;
00663
00664 QString amText() const;
00665 QString pmText() const;
00666
00667 MeasurementSystem measurementSystem() const;
00668
00669 Qt::LayoutDirection textDirection() const;
00670
00671 inline bool operator==(const QLocale &other) const;
00672 inline bool operator!=(const QLocale &other) const;
00673
00674 static QString languageToString(Language language);
00675 static QString countryToString(Country country);
00676 static void setDefault(const QLocale &locale);
00677
00678 static QLocale c() { return QLocale(C); }
00679 static QLocale system();
00680
00681 static QList<Country> countriesForLanguage(Language lang);
00682
00683 void setNumberOptions(NumberOptions options);
00684 NumberOptions numberOptions() const;
00685
00686
00687 struct Data {
00688 quint16 index;
00689 quint16 numberOptions;
00690 };
00691 private:
00692 friend struct QLocalePrivate;
00693
00694
00695 union {
00696 void *v;
00697 Data p;
00698 };
00699 const QLocalePrivate *d() const;
00700 };
00701 Q_DECLARE_TYPEINFO(QLocale, Q_MOVABLE_TYPE);
00702 Q_DECLARE_OPERATORS_FOR_FLAGS(QLocale::NumberOptions)
00703
00704 inline QString QLocale::toString(short i) const
00705 { return toString(qlonglong(i)); }
00706 inline QString QLocale::toString(ushort i) const
00707 { return toString(qulonglong(i)); }
00708 inline QString QLocale::toString(int i) const
00709 { return toString(qlonglong(i)); }
00710 inline QString QLocale::toString(uint i) const
00711 { return toString(qulonglong(i)); }
00712 inline QString QLocale::toString(float i, char f, int prec) const
00713 { return toString(double(i), f, prec); }
00714 inline bool QLocale::operator==(const QLocale &other) const
00715 { return d() == other.d() && numberOptions() == other.numberOptions(); }
00716 inline bool QLocale::operator!=(const QLocale &other) const
00717 { return d() != other.d() || numberOptions() != other.numberOptions(); }
00718
00719 #ifndef QT_NO_DATASTREAM
00720 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QLocale &);
00721 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QLocale &);
00722 #endif
00723
00724 QT_END_NAMESPACE
00725
00726 QT_END_HEADER
00727
00728 #endif // QLOCALE_H