diff options
author | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-09-14 13:15:58 (GMT) |
---|---|---|
committer | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-09-14 13:15:58 (GMT) |
commit | 4361fd12d8111b362c3a9ee2d8addc76d055d7c2 (patch) | |
tree | 0d735256d222042c292bed227cc8c2036a0aff5e | |
parent | 97594601ca84ae11f30bb35e6cbc7e3f70e0624d (diff) | |
parent | adb6eea3a135707a220c0b1c1cf8266321af9309 (diff) | |
download | Qt-4361fd12d8111b362c3a9ee2d8addc76d055d7c2.zip Qt-4361fd12d8111b362c3a9ee2d8addc76d055d7c2.tar.gz Qt-4361fd12d8111b362c3a9ee2d8addc76d055d7c2.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 619c08c..a1f0712 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -125,7 +125,7 @@ static qulonglong qstrtoull(const char *nptr, const char **endptr, register int #if defined(Q_CC_MWERKS) && defined(Q_OS_WIN32) inline bool isascii(int c) { - return (c >= 0 && c <=127); + return (c >= 0 && c <=127); } #endif @@ -1149,6 +1149,23 @@ static QLocale::MeasurementSystem macMeasurementSystem() } } +static void getMacPreferredLanguageAndCountry(QString *language, QString *country) +{ + QCFType<CFArrayRef> languages = (CFArrayRef)CFPreferencesCopyValue( + CFSTR("AppleLanguages"), + kCFPreferencesAnyApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + if (CFArrayGetCount(languages) > 0) { + QCFType<CFLocaleRef> locale = CFLocaleCreate(kCFAllocatorDefault, + CFStringRef(CFArrayGetValueAtIndex(languages, 0))); + if (language) + *language = QCFString::toQString(CFStringRef(CFLocaleGetValue(locale, kCFLocaleLanguageCode))); + if (country) + *country = QCFString::toQString(CFStringRef(CFLocaleGetValue(locale, kCFLocaleCountryCode))); + } +} + QLocale QSystemLocale::fallbackLocale() const { return QLocale(QString::fromUtf8(getMacLocaleName().constData())); @@ -1193,9 +1210,16 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const case NegativeSign: case PositiveSign: case ZeroDigit: - case LanguageId: - case CountryId: break; + case LanguageId: + case CountryId: { + QString preferredLanguage; + QString preferredCountry; + getMacPreferredLanguageAndCountry(&preferredLanguage, &preferredCountry); + if (type == LanguageId) + return codeToLanguage(preferredLanguage.data()); + return codeToCountry(preferredCountry.data()); + } case MeasurementSystem: return QVariant(static_cast<int>(macMeasurementSystem())); @@ -7181,8 +7205,8 @@ Q_CORE_EXPORT double qstrtod(const char *s00, const char **se, bool *ok) double ret = strtod((char*)s00, (char**)se); if (ok) { if((ret == 0.0l && errno == ERANGE) - || ret == HUGE_VAL || ret == -HUGE_VAL) - *ok = false; + || ret == HUGE_VAL || ret == -HUGE_VAL) + *ok = false; else *ok = true; // the result will be that we don't report underflow in this case } |