Refactoring. Avoid declaring the same literal in multiple places.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-24 17:23:41 +03:00
parent fa24b86d32
commit 7687a04ded
11 changed files with 23 additions and 21 deletions

View file

@ -216,13 +216,14 @@ QString VApplication::pathToTables() const
}
else
{
const QString stPath = QStringLiteral("/tables/standard");
#ifdef Q_OS_WIN
return QApplication::applicationDirPath() + QStringLiteral("/tables/standard");
return QApplication::applicationDirPath() + stPath;
#else
#ifdef QT_DEBUG
return QApplication::applicationDirPath() + QStringLiteral("/tables/standard");
return QApplication::applicationDirPath() + stPath;
#else
QDir dir(QApplication::applicationDirPath() + QStringLiteral("/tables/standard"));
QDir dir(QApplication::applicationDirPath() + stPath);
if (dir.exists())
{
return dir.absolutePath();
@ -239,13 +240,14 @@ QString VApplication::pathToTables() const
//---------------------------------------------------------------------------------------------------------------------
QString VApplication::translationsPath() const
{
const QString trPath = QStringLiteral("/translations");
#ifdef Q_OS_WIN
return QApplication::applicationDirPath() + QStringLiteral("/translations");
return QApplication::applicationDirPath() + trPath;
#else
#ifdef QT_DEBUG
return QApplication::applicationDirPath() + QStringLiteral("/translations");
return QApplication::applicationDirPath() + trPath;
#else
QDir dir(QApplication::applicationDirPath() + QStringLiteral("/translations"));
QDir dir(QApplication::applicationDirPath() + trPath);
if (dir.exists())
{
return dir.absolutePath();

View file

@ -354,8 +354,7 @@ void DialogArc::EvalRadius()
void DialogArc::EvalF1()
{
labelEditFormula = ui->labelEditF1;
const QString postfix = QStringLiteral("°");
Eval(ui->plainTextEditF1->toPlainText(), flagF1, ui->labelResultF1, postfix, false);
Eval(ui->plainTextEditF1->toPlainText(), flagF1, ui->labelResultF1, degreeSymbol, false);
}
//---------------------------------------------------------------------------------------------------------------------
@ -365,8 +364,7 @@ void DialogArc::EvalF1()
void DialogArc::EvalF2()
{
labelEditFormula = ui->labelEditF2;
const QString postfix = QStringLiteral("°");
Eval(ui->plainTextEditF2->toPlainText(), flagF2, ui->labelResultF2, postfix, false);
Eval(ui->plainTextEditF2->toPlainText(), flagF2, ui->labelResultF2, degreeSymbol, false);
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -220,8 +220,7 @@ void DialogCurveIntersectAxis::PutAngle()
//---------------------------------------------------------------------------------------------------------------------
void DialogCurveIntersectAxis::EvalAngle()
{
const QString postfix = QStringLiteral("°");
Eval(ui->plainTextEditFormula->toPlainText(), flagError, ui->labelResultCalculation, postfix, false);
Eval(ui->plainTextEditFormula->toPlainText(), flagError, ui->labelResultCalculation, degreeSymbol, false);
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -97,8 +97,7 @@ void DialogEndLine::PutAngle()
void DialogEndLine::EvalAngle()
{
labelEditFormula = ui->labelEditAngle;
const QString postfix = QStringLiteral("°");
Eval(ui->plainTextEditAngle->toPlainText(), flagError, ui->labelResultCalculationAngle, postfix, false);
Eval(ui->plainTextEditAngle->toPlainText(), flagError, ui->labelResultCalculationAngle, degreeSymbol, false);
labelEditFormula = ui->labelEditFormula;
}

View file

@ -239,8 +239,7 @@ void DialogLineIntersectAxis::PutAngle()
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::EvalAngle()
{
const QString postfix = QStringLiteral("°");
Eval(ui->plainTextEditFormula->toPlainText(), flagError, ui->labelResultCalculation, postfix, false);
Eval(ui->plainTextEditFormula->toPlainText(), flagError, ui->labelResultCalculation, degreeSymbol, false);
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -33,6 +33,10 @@
//Same regexp in pattern.xsd shema file. Don't forget synchronize.
const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,]){1,1}([^-*/^+=\\s\\(\\)%:;!.,]){0,}$");
// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This
// furthermore blows up the binary sizes.
const QString degreeSymbol = QStringLiteral("°");
// Keep synchronize all names with initialization in VApllication class!!!!!
//measurements
//head and neck

View file

@ -53,6 +53,7 @@ static const quint32 null_id = 0;
#define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value.
extern const QString nameRegExp;
extern const QString degreeSymbol;
enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown };
enum class Tool : unsigned char

View file

@ -230,7 +230,7 @@ VFormula VToolArc::getFormulaF1() const
VFormula f1(arc->GetFormulaF1(), getData());
f1.setCheckZero(false);
f1.setToolId(id);
f1.setPostfix(QStringLiteral("°"));
f1.setPostfix(degreeSymbol);
return f1;
}
@ -255,7 +255,7 @@ VFormula VToolArc::getFormulaF2() const
VFormula f2(arc->GetFormulaF2(), getData());
f2.setCheckZero(false);
f2.setToolId(id);
f2.setPostfix(QStringLiteral("°"));
f2.setPostfix(degreeSymbol);
return f2;
}

View file

@ -178,7 +178,7 @@ VFormula VToolCurveIntersectAxis::getFormulaAngle() const
VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(id);
fAngle.setPostfix(QStringLiteral("°"));
fAngle.setPostfix(degreeSymbol);
return fAngle;
}

View file

@ -262,7 +262,7 @@ VFormula VToolEndLine::getFormulaAngle() const
VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(id);
fAngle.setPostfix(QStringLiteral("°"));
fAngle.setPostfix(degreeSymbol);
return fAngle;
}

View file

@ -175,7 +175,7 @@ VFormula VToolLineIntersectAxis::getFormulaAngle() const
VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(id);
fAngle.setPostfix(QStringLiteral("°"));
fAngle.setPostfix(degreeSymbol);
return fAngle;
}