From 0459fccee0614cd2811d6a47a02da37ca34e047f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 10 Feb 2015 22:09:44 +0200 Subject: [PATCH] Convert number to string according to locale options. --HG-- branch : feature --- src/app/container/vformula.cpp | 11 +---------- src/app/core/vapplication.h | 10 ++++++++++ src/app/dialogs/tools/dialogtool.cpp | 11 +---------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/app/container/vformula.cpp b/src/app/container/vformula.cpp index 247ed1ab7..5b846bbad 100644 --- a/src/app/container/vformula.cpp +++ b/src/app/container/vformula.cpp @@ -239,17 +239,8 @@ void VFormula::Eval() } else { - QLocale loc; - if (qApp->getSettings()->GetOsSeparator()) - { - loc = QLocale::system(); - } - else - { - loc = QLocale(QLocale::C); - } dValue = result; - value = QString(loc.toString(result) + " " + postfix); + value = QString(qApp->LocaleToString(result) + " " + postfix); _error = false; } } diff --git a/src/app/core/vapplication.h b/src/app/core/vapplication.h index 25f44bf36..6ddbd683f 100644 --- a/src/app/core/vapplication.h +++ b/src/app/core/vapplication.h @@ -81,8 +81,18 @@ public: QString GuiText(const QString &measurement) const; QString Description(const QString &measurement) const; QString PostfixOperator(const QString &name) const; + QString FormulaFromUser(const QString &formula); QString FormulaToUser(const QString &formula); + + template + QString LocaleToString(const T &value) + { + QLocale loc; + qApp->getSettings()->GetOsSeparator() ? loc = QLocale::system() : loc = QLocale(QLocale::C); + return loc.toString(value); + } + QUndoStack *getUndoStack() const; VMainGraphicsView *getSceneView() const; void setSceneView(VMainGraphicsView *value); diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 043c49042..41be6369c 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -500,16 +500,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt } else { - QLocale loc; - if (qApp->getSettings()->GetOsSeparator()) - { - loc = QLocale::system(); - } - else - { - loc = QLocale(QLocale::C); - } - label->setText(loc.toString(result) + " " +postfix); + label->setText(qApp->LocaleToString(result) + " " +postfix); flag = true; ChangeColor(labelEditFormula, okColor); label->setToolTip(tr("Value"));