From 9214f925992d61d0471e8ab401a07e2aeb8db750 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 9 Aug 2022 17:27:53 +0200 Subject: [PATCH] Mode [un]locLengthString() methods to support/qstring_helpers --- src/frontends/qt/qt_helpers.cpp | 16 ---------------- src/frontends/qt/qt_helpers.h | 6 ------ src/support/qstring_helpers.cpp | 21 +++++++++++++++++++++ src/support/qstring_helpers.h | 9 +++++++++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp index db39b4c5f0..0431c042ad 100644 --- a/src/frontends/qt/qt_helpers.cpp +++ b/src/frontends/qt/qt_helpers.cpp @@ -214,22 +214,6 @@ QString formatLocFPNumber(double d) } -QString locLengthString(QString const & str) -{ - QLocale loc; - QString res = str; - return res.replace(QString("."), loc.decimalPoint()); -} - - -QString unlocLengthString(QString const & str) -{ - QLocale loc; - QString res = str; - return res.replace(loc.decimalPoint(), QString(".")); -} - - bool SortLocaleAware(QString const & lhs, QString const & rhs) { return QString::localeAwareCompare(lhs, rhs) < 0; diff --git a/src/frontends/qt/qt_helpers.h b/src/frontends/qt/qt_helpers.h index 07812c3d92..08d50fa582 100644 --- a/src/frontends/qt/qt_helpers.h +++ b/src/frontends/qt/qt_helpers.h @@ -72,12 +72,6 @@ void doubleToWidget(QLineEdit * input, std::string const & value, */ QString formatLocFPNumber(double d); -/// Method to replace dot with localized decimal separator -QString locLengthString(QString const & str); - -/// Method to replace localized decimal separator by dot -QString unlocLengthString(QString const & str); - /// Method to sort QStrings locale-aware (e.g. in combo widgets) bool SortLocaleAware(QString const & lhs, QString const & rhs); diff --git a/src/support/qstring_helpers.cpp b/src/support/qstring_helpers.cpp index bb800f3c67..fadca76a65 100644 --- a/src/support/qstring_helpers.cpp +++ b/src/support/qstring_helpers.cpp @@ -19,6 +19,7 @@ #include "support/qstring_helpers.h" #include +#include #include #include @@ -101,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 diff --git a/src/support/qstring_helpers.h b/src/support/qstring_helpers.h index e33131caa5..905343e77d 100644 --- a/src/support/qstring_helpers.h +++ b/src/support/qstring_helpers.h @@ -92,6 +92,15 @@ QString charFilterRegExp(QString const & filter); */ QString charFilterRegExpC(QString const & filter); +/// Method to replace dot with localized decimal separator +QString locLengthString(QString const & str); + +/// Same for doscstring +docstring locLengthDocString(docstring const str); + +/// Method to replace localized decimal separator by dot +QString unlocLengthString(QString const & str); + } // namespace lyx #endif // QSTRING_HELPERS_H