Refactoring function MapDiagrams(). ref #576.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-10-17 16:55:58 +03:00
parent fdc1eac734
commit 5c821e331d
3 changed files with 26 additions and 23 deletions

View File

@ -168,7 +168,7 @@ void DialogMDataBase::RetranslateGroups()
QString DialogMDataBase::ImgTag(const QString &number) QString DialogMDataBase::ImgTag(const QString &number)
{ {
QString imgUrl("<img src=\"wrong.png\" align=\"center\"/>"); // In case of error QString imgUrl("<img src=\"wrong.png\" align=\"center\"/>"); // In case of error
const QString filePath = QString("://diagrams/%1.svg").arg(MapDiagrams(number)); const QString filePath = QString("://diagrams/%1.svg").arg(MapDiagrams(qApp->TrVars(), number));
if (QFileInfo(filePath).exists()) if (QFileInfo(filePath).exists())
{ {
// Load your SVG // Load your SVG

View File

@ -1147,20 +1147,22 @@ QStringList ListPMSystems()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList ListNumbers(const QStringList &listMeasurements) QStringList ListNumbers(const VTranslateMeasurements *trM, const QStringList &listMeasurements)
{ {
SCASSERT(trM != nullptr);
QStringList numbers; QStringList numbers;
for (int i=0; i < listMeasurements.size(); ++i) for (int i=0; i < listMeasurements.size(); ++i)
{ {
numbers.append(qApp->TrVars()->MNumber(listMeasurements.at(i))); numbers.append(trM->MNumber(listMeasurements.at(i)));
} }
return numbers; return numbers;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString MapDiagrams(const QString &number) QString MapDiagrams(const VTranslateMeasurements *trM, const QString &number)
{ {
switch (ListNumbers(ListGroupA()).indexOf(number)) switch (ListNumbers(trM, ListGroupA()).indexOf(number))
{ {
// A // A
case 0: // A01 case 0: // A01
@ -1213,7 +1215,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupB()).indexOf(number)) switch (ListNumbers(trM, ListGroupB()).indexOf(number))
{ {
// B // B
case 0: // B01 case 0: // B01
@ -1230,7 +1232,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupC()).indexOf(number)) switch (ListNumbers(trM, ListGroupC()).indexOf(number))
{ {
// C // C
case 0: // C01 case 0: // C01
@ -1243,7 +1245,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupD()).indexOf(number)) switch (ListNumbers(trM, ListGroupD()).indexOf(number))
{ {
// D // D
case 0: // D01 case 0: // D01
@ -1260,7 +1262,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupE()).indexOf(number)) switch (ListNumbers(trM, ListGroupE()).indexOf(number))
{ {
// E // E
case 0: // E01 case 0: // E01
@ -1275,7 +1277,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupF()).indexOf(number)) switch (ListNumbers(trM, ListGroupF()).indexOf(number))
{ {
// F // F
case 0: // F01 case 0: // F01
@ -1294,7 +1296,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupG()).indexOf(number)) switch (ListNumbers(trM, ListGroupG()).indexOf(number))
{ {
// G // G
case 0: // G01 case 0: // G01
@ -1393,7 +1395,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupH()).indexOf(number)) switch (ListNumbers(trM, ListGroupH()).indexOf(number))
{ {
// H // H
case 0: // H01 case 0: // H01
@ -1484,7 +1486,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupI()).indexOf(number)) switch (ListNumbers(trM, ListGroupI()).indexOf(number))
{ {
// I // I
case 0: // I01 case 0: // I01
@ -1519,7 +1521,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupJ()).indexOf(number)) switch (ListNumbers(trM, ListGroupJ()).indexOf(number))
{ {
// J // J
case 0: // J01 case 0: // J01
@ -1546,7 +1548,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupK()).indexOf(number)) switch (ListNumbers(trM, ListGroupK()).indexOf(number))
{ {
// K // K
case 0: // K01 case 0: // K01
@ -1579,7 +1581,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupL()).indexOf(number)) switch (ListNumbers(trM, ListGroupL()).indexOf(number))
{ {
// L // L
case 0: // L01 case 0: // L01
@ -1630,7 +1632,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupM()).indexOf(number)) switch (ListNumbers(trM, ListGroupM()).indexOf(number))
{ {
// M // M
case 0: // M01 case 0: // M01
@ -1665,7 +1667,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupN()).indexOf(number)) switch (ListNumbers(trM, ListGroupN()).indexOf(number))
{ {
// N // N
case 0: // N01 case 0: // N01
@ -1688,7 +1690,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupO()).indexOf(number)) switch (ListNumbers(trM, ListGroupO()).indexOf(number))
{ {
// O // O
case 0: // O01 case 0: // O01
@ -1723,7 +1725,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupP()).indexOf(number)) switch (ListNumbers(trM, ListGroupP()).indexOf(number))
{ {
// P // P
case 0: // P01 case 0: // P01
@ -1754,7 +1756,7 @@ QString MapDiagrams(const QString &number)
break; break;
} }
switch (ListNumbers(ListGroupQ()).indexOf(number)) switch (ListNumbers(trM, ListGroupQ()).indexOf(number))
{ {
// Q // Q
case 0: // Q01 case 0: // Q01

View File

@ -51,6 +51,7 @@ template <class T> class QSharedPointer;
class QComboBox; class QComboBox;
class QMarginsF; class QMarginsF;
class VTranslateMeasurements;
#define SceneSize 50000 #define SceneSize 50000
#define DefPointRadius 1.5//mm #define DefPointRadius 1.5//mm
@ -499,8 +500,8 @@ QStringList ListGroupO();
QStringList ListGroupP(); QStringList ListGroupP();
QStringList ListGroupQ(); QStringList ListGroupQ();
QStringList ListNumbers(const QStringList & listMeasurements); QStringList ListNumbers(const VTranslateMeasurements *trM, const QStringList & listMeasurements);
QString MapDiagrams(const QString &number); QString MapDiagrams(const VTranslateMeasurements *trM, const QString &number);
// pattern making systems codes // pattern making systems codes
extern const QString p0_S; extern const QString p0_S;