From 55217e352c5dd1e2f912ed0b6e565002b16cfcc1 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 15 Nov 2007 12:51:03 +0000 Subject: [PATCH] Remove support for Qt < 4.2 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21624 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/qstring_helpers.cpp | 51 --------------------------------- src/support/qstring_helpers.h | 4 --- 2 files changed, 55 deletions(-) diff --git a/src/support/qstring_helpers.cpp b/src/support/qstring_helpers.cpp index 01c5de4b97..27b740e6ca 100644 --- a/src/support/qstring_helpers.cpp +++ b/src/support/qstring_helpers.cpp @@ -21,61 +21,10 @@ namespace lyx { using std::string; -#if QT_VERSION < 0x040200 -// We use QString::fromUcs4 in Qt 4.2 and higher -QString const toqstr(docstring const & str) -{ - QString s; - int i = static_cast(str.size()); - s.resize(i); - for (; --i >= 0;) { - char_type const c = str[i]; - if (is_utf16(c)) - // Use a simple cast in the common case for speed - // reasons - s[i] = static_cast(c); - else { - // A simple cast is not possible, so we need to use - // the full blown conversion. - std::vector const utf16 = - ucs4_to_utf16(str.data(), str.size()); - // Enable the compiler to do NRVO - s = QString::fromUtf16(&utf16[0], utf16.size()); - break; - } - } - return s; -} -#endif - - docstring const qstring_to_ucs4(QString const & qstr) { -#if QT_VERSION >= 0x040200 QVector const ucs4 = qstr.toUcs4(); return docstring(ucs4.begin(), ucs4.end()); -#else - int const ls = qstr.size(); - docstring ucs4; - for (int i = 0; i < ls; ++i) { - char_type const c = static_cast(qstr[i].unicode()); - if (is_utf16(c)) - // Use a simple cast in the common case for speed - // reasons - ucs4 += c; - else { - // A simple cast is not possible, so we need to use - // the full blown conversion. - std::vector const v = utf16_to_ucs4( - reinterpret_cast(qstr.utf16()), - qstr.size()); - // Enable the compiler to do NRVO - ucs4 = docstring(v.begin(), v.end()); - break; - } - } - return ucs4; -#endif } diff --git a/src/support/qstring_helpers.h b/src/support/qstring_helpers.h index b53a13a7a5..b47f5fe5fe 100644 --- a/src/support/qstring_helpers.h +++ b/src/support/qstring_helpers.h @@ -56,16 +56,12 @@ inline bool is_utf16(char_type c) * This is the preferred method of converting anything that possibly * contains non-ASCII stuff to QString. */ -#if QT_VERSION >= 0x040200 inline QString const toqstr(docstring const & ucs4) { // If possible we let qt do the work, since this version does not // need to be superfast. return QString::fromUcs4(reinterpret_cast(ucs4.data()), ucs4.length()); } -#else -QString const toqstr(docstring const & ucs4); -#endif /** -- 2.39.5