Convert number to string according to locale options.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-02-10 22:09:44 +02:00
parent 0056ec49e0
commit 0459fccee0
3 changed files with 12 additions and 20 deletions

View File

@ -239,17 +239,8 @@ void VFormula::Eval()
} }
else else
{ {
QLocale loc;
if (qApp->getSettings()->GetOsSeparator())
{
loc = QLocale::system();
}
else
{
loc = QLocale(QLocale::C);
}
dValue = result; dValue = result;
value = QString(loc.toString(result) + " " + postfix); value = QString(qApp->LocaleToString(result) + " " + postfix);
_error = false; _error = false;
} }
} }

View File

@ -81,8 +81,18 @@ public:
QString GuiText(const QString &measurement) const; QString GuiText(const QString &measurement) const;
QString Description(const QString &measurement) const; QString Description(const QString &measurement) const;
QString PostfixOperator(const QString &name) const; QString PostfixOperator(const QString &name) const;
QString FormulaFromUser(const QString &formula); QString FormulaFromUser(const QString &formula);
QString FormulaToUser(const QString &formula); QString FormulaToUser(const QString &formula);
template <typename T>
QString LocaleToString(const T &value)
{
QLocale loc;
qApp->getSettings()->GetOsSeparator() ? loc = QLocale::system() : loc = QLocale(QLocale::C);
return loc.toString(value);
}
QUndoStack *getUndoStack() const; QUndoStack *getUndoStack() const;
VMainGraphicsView *getSceneView() const; VMainGraphicsView *getSceneView() const;
void setSceneView(VMainGraphicsView *value); void setSceneView(VMainGraphicsView *value);

View File

@ -500,16 +500,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
} }
else else
{ {
QLocale loc; label->setText(qApp->LocaleToString(result) + " " +postfix);
if (qApp->getSettings()->GetOsSeparator())
{
loc = QLocale::system();
}
else
{
loc = QLocale(QLocale::C);
}
label->setText(loc.toString(result) + " " +postfix);
flag = true; flag = true;
ChangeColor(labelEditFormula, okColor); ChangeColor(labelEditFormula, okColor);
label->setToolTip(tr("Value")); label->setToolTip(tr("Value"));