Use QCollator in QString and remove it from qlocale_icu
authorLars Knoll <lars.knoll@nokia.com>
Fri, 1 Jun 2012 22:38:48 +0000 (00:38 +0200)
committerQt by Nokia <qt-info@nokia.com>
Sun, 10 Jun 2012 17:09:04 +0000 (19:09 +0200)
Change-Id: Ic94439943999382f8050668edfb67d3b75ac1df4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qlocale_icu.cpp
src/corelib/tools/qlocale_p.h
src/corelib/tools/qstring.cpp

index 97ce821..af6b6e2 100644 (file)
@@ -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<const UChar *>(source), int32_t(sourceLength),
-                           reinterpret_cast<const UChar *>(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)
 {
index 1902e4e..09a3e0e 100644 (file)
@@ -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
 
index 4f8d0e5..493661b 100644 (file)
@@ -59,6 +59,7 @@
 #include "qhash.h"
 #include "qdebug.h"
 #include "qendian.h"
+#include "qcollator_p.h"
 
 #ifdef Q_OS_MAC
 #include <private/qcore_mac_p.h>
@@ -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 <string.h>
     int delta = strcoll(toLocal8Bit_helper(data1, length1).constData(), toLocal8Bit_helper(data2, length2).constData());
     if (delta == 0)