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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,6 +33,10 @@
//Same regexp in pattern.xsd shema file. Don't forget synchronize. //Same regexp in pattern.xsd shema file. Don't forget synchronize.
const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,]){1,1}([^-*/^+=\\s\\(\\)%:;!.,]){0,}$"); 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!!!!! // Keep synchronize all names with initialization in VApllication class!!!!!
//measurements //measurements
//head and neck //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. #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 nameRegExp;
extern const QString degreeSymbol;
enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown }; enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown };
enum class Tool : unsigned char enum class Tool : unsigned char

View File

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

View File

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

View File

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

View File

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