diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-06-01 17:51:06 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-10 19:08:49 +0200 |
commit | 97e177e58d195f78ac103b3dd0b8ecedb1e07d4c (patch) | |
tree | eda9251fd21110f048acd8d5a32d0b32959e642c /src/corelib/tools/qlocale_p.h | |
parent | c631927b764133ea3c90613262c5a1587b0937a8 (diff) |
Refactor the ICU code for QLocale
Clean up the ICU code and make it thread-safe. Add a
QIcuData structure to QLocalePrivate, that contains
ICU specific data.
Link against ICU directly, greatly simplifying the
code.
Also fix a bug in the locale specific case conversion
code that would cause it to fail and fall back to the
QString code if the output string was larger than the
input.
Change-Id: Ie67e5ea14fa204ebc5887d7aaeb1a4f3ecaf8697
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qlocale_p.h')
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index c2c1488966..1902e4e5af 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -126,6 +126,16 @@ private: }; #endif +#ifdef QT_USE_ICU +namespace QIcu { + QString toUpper(const QByteArray &localeId, const QString &str, bool *ok); + QString toLower(const QByteArray &localeId, const QString &str, bool *ok); + + bool strcoll(const QByteArray &localeID, const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result); +} +#endif + + struct QLocaleData { public: @@ -178,7 +188,17 @@ public: class Q_CORE_EXPORT QLocalePrivate : public QSharedData { public: - QLocalePrivate() : m_index(0), m_numberOptions(0), m_data(0) {} + QLocalePrivate(int index, int numberOptions = 0) + : m_index(index), m_numberOptions(numberOptions) + { + m_data = dataPointerForIndex(index); + m_localeID = bcp47Name().toLatin1(); + m_localeID.replace('-','_'); + } + + ~QLocalePrivate() + { + } QChar decimal() const { return QChar(m_data->m_decimal); } QChar group() const { return QChar(m_data->m_group); } @@ -203,6 +223,7 @@ public: static QLocale::Country codeToCountry(const QString &code); static void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Script &script, QLocale::Country &cntry); + static const QLocaleData *dataPointerForIndex(quint16 index); QLocale::MeasurementSystem measurementSystem() const; @@ -285,11 +306,11 @@ public: QString dateTimeToString(const QString &format, const QDate *date, const QTime *time, const QLocale *q) const; -private: friend class QLocale; quint16 m_index; quint16 m_numberOptions; const QLocaleData *m_data; + QByteArray m_localeID; }; inline char QLocalePrivate::digitToCLocale(QChar in) const |