From: Lars Knoll Date: Fri, 1 Jun 2012 22:38:48 +0000 (+0200) Subject: Use QCollator in QString and remove it from qlocale_icu X-Git-Tag: 071012110112~474 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2c1550564b6cdf2b1cce262355c6b7f8b9b425a;p=profile%2Fivi%2Fqtbase.git Use QCollator in QString and remove it from qlocale_icu Change-Id: Ic94439943999382f8050668edfb67d3b75ac1df4 Reviewed-by: Thiago Macieira --- diff --git a/src/corelib/tools/qlocale_icu.cpp b/src/corelib/tools/qlocale_icu.cpp index 97ce821..af6b6e2 100644 --- a/src/corelib/tools/qlocale_icu.cpp +++ b/src/corelib/tools/qlocale_icu.cpp @@ -45,8 +45,6 @@ #include "qlocale_p.h" #include "qmutex.h" -#include "unicode/uversion.h" -#include "unicode/ucol.h" #include "unicode/uloc.h" #include "unicode/ustring.h" @@ -54,28 +52,6 @@ QT_BEGIN_NAMESPACE typedef int32_t (*Ptr_u_strToCase)(UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, const char *locale, UErrorCode *pErrorCode); -bool QIcu::strcoll(const QByteArray &localeID, - const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result) -{ - Q_ASSERT(result); - Q_ASSERT(source); - Q_ASSERT(target); - - UErrorCode icuStatus = U_ZERO_ERROR; - UCollator *collator = ucol_open(localeID, &icuStatus); - - if (U_FAILURE((icuStatus))) - return false; - - *result = ucol_strcoll(collator, - reinterpret_cast(source), int32_t(sourceLength), - reinterpret_cast(target), int32_t(targetLength)); - - ucol_close(collator); - - return true; -} - // caseFunc can either be u_strToUpper or u_strToLower static bool qt_u_strToCase(const QString &str, QString *out, const char *localeID, Ptr_u_strToCase caseFunc) { diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 1902e4e..09a3e0e 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -130,8 +130,6 @@ private: 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 diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 4f8d0e5..493661b 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -59,6 +59,7 @@ #include "qhash.h" #include "qdebug.h" #include "qendian.h" +#include "qcollator_p.h" #ifdef Q_OS_MAC #include @@ -5003,14 +5004,10 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, CFRelease(thisString); CFRelease(otherString); return result; +#elif defined(QT_USE_ICU) + QCollator collator; + return collator.compare(data1, length1, data2, length2); #elif defined(Q_OS_UNIX) -# if defined(QT_USE_ICU) - QLocale locale; - int res; - if (QIcu::strcoll(locale.d.constData()->m_localeID, data1, length1, data2, length2, &res)) - return res; - // else fall through -# endif // declared in int delta = strcoll(toLocal8Bit_helper(data1, length1).constData(), toLocal8Bit_helper(data2, length2).constData()); if (delta == 0)