]> git.lyx.org Git - features.git/blobdiff - src/support/qstring_helpers.cpp
Revert "WIP: refactor Systemcall"
[features.git] / src / support / qstring_helpers.cpp
index d34e455640d012c13d660c6e67f0bd4374b384d3..fadca76a657eb5cdfa13b3738dd59269d4911e8d 100644 (file)
@@ -19,6 +19,7 @@
 #include "support/qstring_helpers.h"
 
 #include <QRegExp>
+#include <QLocale>
 #include <QString>
 #include <QVector>
 
@@ -47,13 +48,21 @@ QString toqstr(docstring const & ucs4)
        // need to be superfast.
        if (ucs4.empty())
                return QString();
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+       return QString::fromStdU32String(reinterpret_cast<std::u32string const &>(ucs4));
+#else
        return QString::fromUcs4((uint const *)ucs4.data(), ucs4.length());
+#endif
 }
 
 QString toqstr(char_type ucs4)
 {
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+       return QString::fromStdU32String(std::u32string(1, ucs4));
+#else
        union { char_type c; uint i; } u = { ucs4 };
        return QString::fromUcs4(&u.i, 1);
+#endif
 }
 
 docstring qstring_to_ucs4(QString const & qstr)
@@ -93,6 +102,26 @@ QString charFilterRegExpC(QString const & filter)
        return re + ")";
 }
 
+QString locLengthString(QString const & str)
+{
+       QLocale loc;
+       QString res = str;
+       return res.replace(QString("."), loc.decimalPoint());
+}
+
+
+docstring locLengthDocString(docstring const str)
+{
+       return qstring_to_ucs4(locLengthString(toqstr(str)));
+}
+
+
+QString unlocLengthString(QString const & str)
+{
+       QLocale loc;
+       QString res = str;
+       return res.replace(loc.decimalPoint(), QString("."));
+}
 
 
 } // namespace lyx