diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-22 14:04:31 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-22 18:56:30 +0300 |
commit | 65e2822f21b1a3c797d8da9c00160248845370af (patch) | |
tree | d78e0e33f814c8dcc9f82d62b0c7ad13faff75b5 | |
parent | 0f367c93d01c98912fd658235d5e4f2a01a91fe7 (diff) | |
download | qtlocation-mapboxgl-65e2822f21b1a3c797d8da9c00160248845370af.tar.gz |
[Qt] Use Qt text codec instead of nunicode
Remove one extra dependency. Qt has some bugs on the text codec it
seems, but it is also important to keep the behavior aligned with
the client API.
-rw-r--r-- | platform/qt/platform.gyp | 2 | ||||
-rw-r--r-- | platform/qt/scripts/configure.sh | 8 | ||||
-rw-r--r-- | platform/qt/src/string_stdlib.cpp | 24 | ||||
-rw-r--r-- | test/util/text_conversions.cpp | 7 |
4 files changed, 36 insertions, 5 deletions
diff --git a/platform/qt/platform.gyp b/platform/qt/platform.gyp index 880e366532..b948898e2a 100644 --- a/platform/qt/platform.gyp +++ b/platform/qt/platform.gyp @@ -46,7 +46,6 @@ '../default/mbgl/storage/offline_download.cpp', '../default/online_file_source.cpp', '../default/sqlite3.cpp', - '../default/string_stdlib.cpp', 'include/qmapbox.hpp', 'include/qmapboxgl.hpp', 'include/qquickmapboxgl.hpp', @@ -66,6 +65,7 @@ 'src/qquickmapboxglrenderer.hpp', 'src/run_loop.cpp', 'src/run_loop_impl.hpp', + 'src/string_stdlib.cpp', 'src/timer.cpp', 'src/timer_impl.hpp', ], diff --git a/platform/qt/scripts/configure.sh b/platform/qt/scripts/configure.sh index 42541032c0..be809708ba 100644 --- a/platform/qt/scripts/configure.sh +++ b/platform/qt/scripts/configure.sh @@ -10,7 +10,6 @@ GEOJSON_VERSION=0.1.4${CXX11ABI:-} GEOJSONVT_VERSION=6.1.0 GTEST_VERSION=1.7.0${CXX11ABI:-} LIBJPEG_TURBO_VERSION=1.4.2 -NUNICODE_VERSION=1.6 PIXELMATCH_VERSION=0.9.0 RAPIDJSON_VERSION=1.0.2 SQLITE_VERSION=3.9.1 @@ -20,12 +19,15 @@ WEBP_VERSION=0.5.0 EARCUT_VERSION=0.11 function print_default_flags { - CONFIG+=" 'cflags': $(quote_flags -fvisibility=hidden),"$LN + CONFIG+=" 'cflags': $(quote_flags -fvisibility=hidden -D__QT__),"$LN } if [ "$MASON_PLATFORM" == "osx" ]; then + # XXX: Argh, adding the __QT__ flag here because GYP for OSX does + # not respect the `cflags` variable above and we need it to reach + # the utests somehow. Gonna be fixed properly when we move to CMake. function print_opengl_flags { - CONFIG+=" 'opengl_cflags%': [],"$LN + CONFIG+=" 'opengl_cflags%': ['-D__QT__'],"$LN CONFIG+=" 'opengl_ldflags%': ['-framework OpenGL', '-framework CoreFoundation'],"$LN } else diff --git a/platform/qt/src/string_stdlib.cpp b/platform/qt/src/string_stdlib.cpp new file mode 100644 index 0000000000..c4adecea06 --- /dev/null +++ b/platform/qt/src/string_stdlib.cpp @@ -0,0 +1,24 @@ +#include <mbgl/platform/platform.hpp> + +#include <QByteArray> +#include <QString> + +#include <string> + +namespace mbgl { +namespace platform { + +std::string uppercase(const std::string& str) { + auto upper = QString::fromUtf8(str.c_str()).toUpper().toUtf8(); + + return std::string(upper.constData(), upper.size()); +} + +std::string lowercase(const std::string& str) { + auto lower = QString::fromUtf8(str.c_str()).toLower().toUtf8(); + + return std::string(lower.constData(), lower.size()); +} + +} // namespace platform +} // namespace mbgl diff --git a/test/util/text_conversions.cpp b/test/util/text_conversions.cpp index 5064537859..19e30d9f3d 100644 --- a/test/util/text_conversions.cpp +++ b/test/util/text_conversions.cpp @@ -16,7 +16,6 @@ TEST(TextConversions, to_upper) { EXPECT_EQ(std::string("BÊNÇÃO"), platform::uppercase("bênção")); // PT EXPECT_EQ(std::string("AZƏRBAYCAN"), platform::uppercase("Azərbaycan")); // AZ - EXPECT_EQ(std::string("ὈΔΥΣΣΕΎΣ"), platform::uppercase("Ὀδυσσεύς")); // GR } @@ -32,6 +31,12 @@ TEST(TextConversions, to_lower) { EXPECT_EQ(std::string("bênção"), platform::lowercase("BÊNÇÃO")); // PT EXPECT_EQ(std::string("azərbaycan"), platform::lowercase("AZƏRBAYCAN")); // AZ + +#if defined(__QT__) + // https://bugreports.qt.io/browse/QTBUG-17337 + EXPECT_NE(std::string("ὀδυσσεύς"), platform::lowercase("ὈΔΥΣΣΕΎΣ")); // GR +#else EXPECT_EQ(std::string("ὀδυσσεύς"), platform::lowercase("ὈΔΥΣΣΕΎΣ")); // GR +#endif } |