Refactoring.

Fix code style.
This commit is contained in:
Roman Telezhynskyi 2023-05-17 16:24:27 +03:00
parent 0eaf1a6b66
commit 9c0fe9131a
9 changed files with 270 additions and 271 deletions

View File

@ -27,12 +27,13 @@
*************************************************************************/ *************************************************************************/
#include "vabstractlayoutdialog.h" #include "vabstractlayoutdialog.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/def.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
//must be the same order as PaperSizeTemplate constants #include <QApplication>
const VAbstractLayoutDialog::FormatsVector VAbstractLayoutDialog::pageFormatNames
{ // must be the same order as PaperSizeTemplate constants
const VAbstractLayoutDialog::FormatsVector VAbstractLayoutDialog::pageFormatNames{
QStringLiteral("A0"), QStringLiteral("A0"),
QStringLiteral("A1"), QStringLiteral("A1"),
QStringLiteral("A2"), QStringLiteral("A2"),
@ -49,13 +50,13 @@ const VAbstractLayoutDialog::FormatsVector VAbstractLayoutDialog::pageFormatName
QApplication::translate("VAbstractLayoutDialog", "Roll 48in", "Paper format"), QApplication::translate("VAbstractLayoutDialog", "Roll 48in", "Paper format"),
QApplication::translate("VAbstractLayoutDialog", "Roll 62in", "Paper format"), QApplication::translate("VAbstractLayoutDialog", "Roll 62in", "Paper format"),
QApplication::translate("VAbstractLayoutDialog", "Roll 72in", "Paper format"), QApplication::translate("VAbstractLayoutDialog", "Roll 72in", "Paper format"),
QApplication::translate("VAbstractLayoutDialog", "Custom", "Paper format") QApplication::translate("VAbstractLayoutDialog", "Custom", "Paper format")};
};
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractLayoutDialog::VAbstractLayoutDialog(QWidget *parent) VAbstractLayoutDialog::VAbstractLayoutDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates) void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates)
@ -66,19 +67,19 @@ void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates)
const QString pdi = QStringLiteral("(%1ppi)").arg(PrintDPI); const QString pdi = QStringLiteral("(%1ppi)").arg(PrintDPI);
auto cntr = static_cast<VIndexType>(PaperSizeTemplate::A0); auto cntr = static_cast<VIndexType>(PaperSizeTemplate::A0);
for(const auto& v : pageFormatNames) for (const auto &v : pageFormatNames)
{ {
if (cntr <= static_cast<int>(PaperSizeTemplate::Tabloid)) if (cntr <= static_cast<int>(PaperSizeTemplate::Tabloid))
{ {
comboBoxTemplates->addItem(icoPaper, v+QChar(QChar::Space)+pdi, QVariant(cntr++)); comboBoxTemplates->addItem(icoPaper, v + QChar(QChar::Space) + pdi, QVariant(cntr++));
} }
else if (cntr <= static_cast<int>(PaperSizeTemplate::Roll72in)) else if (cntr <= static_cast<int>(PaperSizeTemplate::Roll72in))
{ {
comboBoxTemplates->addItem(icoRoll, v+QChar(QChar::Space)+pdi, QVariant(cntr++)); comboBoxTemplates->addItem(icoRoll, v + QChar(QChar::Space) + pdi, QVariant(cntr++));
} }
else else
{ {
comboBoxTemplates->addItem(v+QChar(QChar::Space)+pdi, QVariant(cntr++)); comboBoxTemplates->addItem(v + QChar(QChar::Space) + pdi, QVariant(cntr++));
} }
} }
comboBoxTemplates->setCurrentIndex(-1); comboBoxTemplates->setCurrentIndex(-1);

View File

@ -36,17 +36,17 @@
#include <QtDebug> #include <QtDebug>
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include "../qmuparser/qmudef.h"
#include "../qmuparser/qmuparsererror.h" #include "../qmuparser/qmuparsererror.h"
#include "../qmuparser/qmutokenparser.h" #include "../qmuparser/qmutokenparser.h"
#include "../qmuparser/qmutranslation.h" #include "../qmuparser/qmutranslation.h"
#include "../qmuparser/qmudef.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/def.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/literals.h"
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "vtranslatemeasurements.h" #include "../vmisc/def.h"
#include "../vmisc/literals.h"
#include "../vmisc/vabstractapplication.h"
#include "../vpatterndb/vtranslatevars.h"
#include "pmsystems.h" #include "pmsystems.h"
#include "vtranslatemeasurements.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VTranslateVars::VTranslateVars() VTranslateVars::VTranslateVars()
@ -63,8 +63,8 @@ VTranslateVars::VTranslateVars()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VTranslateVars::InitPatternMakingSystems() void VTranslateVars::InitPatternMakingSystems()
{ {
//Note. We can't use here function and variables because lupdate tool doesn't see string in variables and doesn't // Note. We can't use here function and variables because lupdate tool doesn't see string in variables and doesn't
//mark such string to translation. // mark such string to translation.
qmu::QmuTranslation name; qmu::QmuTranslation name;
qmu::QmuTranslation author; qmu::QmuTranslation author;
qmu::QmuTranslation book; qmu::QmuTranslation book;
@ -203,8 +203,10 @@ void VTranslateVars::InitPatternMakingSystems()
//================================================================================================================= //=================================================================================================================
name = translate("VTranslateVars", "Fukomoto", "System name"); name = translate("VTranslateVars", "Fukomoto", "System name");
author = translate("VTranslateVars", "Sue S. Fukomoto", "Author name"); author = translate("VTranslateVars", "Sue S. Fukomoto", "Author name");
book = translate("VTranslateVars", "Scientific Pattern Drafting as taught at Style Center School of Costume " book = translate("VTranslateVars",
"Design, Dressmaking and Millinery", "Book name"); "Scientific Pattern Drafting as taught at Style Center School of Costume "
"Design, Dressmaking and Millinery",
"Book name");
InitSystem(p26_S, name, author, book); InitSystem(p26_S, name, author, book);
//================================================================================================================= //=================================================================================================================
name = translate("VTranslateVars", "Dressmaking International", "System name"); name = translate("VTranslateVars", "Dressmaking International", "System name");
@ -266,8 +268,10 @@ void VTranslateVars::InitPatternMakingSystems()
//================================================================================================================= //=================================================================================================================
name = translate("VTranslateVars", "Supreme System", "System name"); name = translate("VTranslateVars", "Supreme System", "System name");
author = translate("VTranslateVars", "Frederick T. Croonberg", "Author name"); author = translate("VTranslateVars", "Frederick T. Croonberg", "Author name");
book = translate("VTranslateVars", "The Blue Book of Men's Tailoring, Grand Edition of Supreme System for " book = translate("VTranslateVars",
"Producing Mens Garments (1907)", "Book name"); "The Blue Book of Men's Tailoring, Grand Edition of Supreme System for "
"Producing Mens Garments (1907)",
"Book name");
InitSystem(p38_S, name, author, book); InitSystem(p38_S, name, author, book);
//================================================================================================================= //=================================================================================================================
name = translate("VTranslateVars", "Sugino", "System name"); name = translate("VTranslateVars", "Sugino", "System name");
@ -328,8 +332,10 @@ void VTranslateVars::InitPatternMakingSystems()
//================================================================================================================= //=================================================================================================================
name = translate("VTranslateVars", "Mitchell", "System name"); name = translate("VTranslateVars", "Mitchell", "System name");
author = translate("VTranslateVars", "Jno. J. Mitchell", "Author name"); author = translate("VTranslateVars", "Jno. J. Mitchell", "Author name");
book = translate("VTranslateVars", "\"Standard\" Work on Cutting (Men's Garments) 1886: The Art and Science of " book = translate("VTranslateVars",
"Garment Cutting", "Book name"); "\"Standard\" Work on Cutting (Men's Garments) 1886: The Art and Science of "
"Garment Cutting",
"Book name");
InitSystem(p50_S, name, author, book); InitSystem(p50_S, name, author, book);
//================================================================================================================= //=================================================================================================================
name = translate("VTranslateVars", "GOST 17917-86", "System name"); name = translate("VTranslateVars", "GOST 17917-86", "System name");
@ -344,8 +350,10 @@ void VTranslateVars::InitPatternMakingSystems()
//================================================================================================================= //=================================================================================================================
name = translate("VTranslateVars", "Knowles/Women", "System name"); name = translate("VTranslateVars", "Knowles/Women", "System name");
author = translate("VTranslateVars", "Lori A. Knowles", "Author name"); author = translate("VTranslateVars", "Lori A. Knowles", "Author name");
book = translate("VTranslateVars", "Practical Guide to Patternmaking for Fashion Designers: Juniors, Misses, and " book = translate("VTranslateVars",
"Women", "Book name"); "Practical Guide to Patternmaking for Fashion Designers: Juniors, Misses, and "
"Women",
"Book name");
InitSystem(p53_S, name, author, book); InitSystem(p53_S, name, author, book);
//================================================================================================================= //=================================================================================================================
name = translate("VTranslateVars", "American Garment Cutter", "System name"); name = translate("VTranslateVars", "American Garment Cutter", "System name");
@ -380,24 +388,24 @@ void VTranslateVars::InitVariables()
variables.insert(angle2ElArc_, translate("VTranslateVars", "Angle2ElArc_", "Left symbol _ in the name")); variables.insert(angle2ElArc_, translate("VTranslateVars", "Angle2ElArc_", "Left symbol _ in the name"));
variables.insert(angle1Spl_, translate("VTranslateVars", "Angle1Spl_", "Left symbol _ in the name")); variables.insert(angle1Spl_, translate("VTranslateVars", "Angle1Spl_", "Left symbol _ in the name"));
variables.insert(angle2Spl_, translate("VTranslateVars", "Angle2Spl_", "Left symbol _ in the name")); variables.insert(angle2Spl_, translate("VTranslateVars", "Angle2Spl_", "Left symbol _ in the name"));
variables.insert(angle1SplPath, translate("VTranslateVars", "Angle1SplPath", variables.insert(angle1SplPath,
"Do not add symbol _ to the end of the name")); translate("VTranslateVars", "Angle1SplPath", "Do not add symbol _ to the end of the name"));
variables.insert(angle2SplPath, translate("VTranslateVars", "Angle2SplPath", variables.insert(angle2SplPath,
"Do not add symbol _ to the end of the name")); translate("VTranslateVars", "Angle2SplPath", "Do not add symbol _ to the end of the name"));
variables.insert(seg_, translate("VTranslateVars", "Seg_", "Segment. Left symbol _ in the name")); variables.insert(seg_, translate("VTranslateVars", "Seg_", "Segment. Left symbol _ in the name"));
variables.insert(currentLength, translate("VTranslateVars", "CurrentLength", "Do not add space between words")); variables.insert(currentLength, translate("VTranslateVars", "CurrentLength", "Do not add space between words"));
variables.insert(currentSeamAllowance, translate("VTranslateVars", "CurrentSeamAllowance", variables.insert(currentSeamAllowance,
"Do not add space between words")); translate("VTranslateVars", "CurrentSeamAllowance", "Do not add space between words"));
variables.insert(c1LengthSpl_, translate("VTranslateVars", "C1LengthSpl_", "Left symbol _ in the name")); variables.insert(c1LengthSpl_, translate("VTranslateVars", "C1LengthSpl_", "Left symbol _ in the name"));
variables.insert(c2LengthSpl_, translate("VTranslateVars", "C2LengthSpl_", "Left symbol _ in the name")); variables.insert(c2LengthSpl_, translate("VTranslateVars", "C2LengthSpl_", "Left symbol _ in the name"));
variables.insert(c1LengthSplPath, translate("VTranslateVars", "C1LengthSplPath", variables.insert(c1LengthSplPath,
"Do not add symbol _ to the end of the name")); translate("VTranslateVars", "C1LengthSplPath", "Do not add symbol _ to the end of the name"));
variables.insert(c2LengthSplPath, translate("VTranslateVars", "C2LengthSplPath", variables.insert(c2LengthSplPath,
"Do not add symbol _ to the end of the name")); translate("VTranslateVars", "C2LengthSplPath", "Do not add symbol _ to the end of the name"));
variables.insert(rotationElArc_, translate("VTranslateVars", "RotationElArc_", "Left symbol _ in the name")); variables.insert(rotationElArc_, translate("VTranslateVars", "RotationElArc_", "Left symbol _ in the name"));
variables.insert(pieceArea_, translate("VTranslateVars", "PieceArea_", "Left symbol _ in the name")); variables.insert(pieceArea_, translate("VTranslateVars", "PieceArea_", "Left symbol _ in the name"));
variables.insert(pieceSeamLineArea_, translate("VTranslateVars", "PieceSeamLineArea_", variables.insert(pieceSeamLineArea_,
"Left symbol _ in the name")); translate("VTranslateVars", "PieceSeamLineArea_", "Left symbol _ in the name"));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -408,43 +416,43 @@ void VTranslateVars::InitFunctions()
const QString threeArguments = QStringLiteral("(;;)"); const QString threeArguments = QStringLiteral("(;;)");
functions.insert(degTorad_F, translate("VTranslateVars", "degTorad", "converts degrees to radian")); functions.insert(degTorad_F, translate("VTranslateVars", "degTorad", "converts degrees to radian"));
functionsDescriptions.insert(degTorad_F, translate("VTranslateVars", "converts degrees to radian", functionsDescriptions.insert(degTorad_F,
"function degTorad")); translate("VTranslateVars", "converts degrees to radian", "function degTorad"));
functionsArguments.insert(degTorad_F, oneArgument); functionsArguments.insert(degTorad_F, oneArgument);
functions.insert(radTodeg_F, translate("VTranslateVars", "radTodeg", "converts radian to degrees")); functions.insert(radTodeg_F, translate("VTranslateVars", "radTodeg", "converts radian to degrees"));
functionsDescriptions.insert(radTodeg_F, translate("VTranslateVars", "converts radian to degrees", functionsDescriptions.insert(radTodeg_F,
"function radTodeg")); translate("VTranslateVars", "converts radian to degrees", "function radTodeg"));
functionsArguments.insert(radTodeg_F, oneArgument); functionsArguments.insert(radTodeg_F, oneArgument);
functions.insert(sin_F, translate("VTranslateVars", "sin", "sine function working with radians")); functions.insert(sin_F, translate("VTranslateVars", "sin", "sine function working with radians"));
functionsDescriptions.insert(sin_F, translate("VTranslateVars", "sine function working with radians", functionsDescriptions.insert(sin_F,
"function sin")); translate("VTranslateVars", "sine function working with radians", "function sin"));
functionsArguments.insert(sin_F, oneArgument); functionsArguments.insert(sin_F, oneArgument);
functions.insert(cos_F, translate("VTranslateVars", "cos", "cosine function working with radians")); functions.insert(cos_F, translate("VTranslateVars", "cos", "cosine function working with radians"));
functionsDescriptions.insert(cos_F, translate("VTranslateVars", "cosine function working with radians", functionsDescriptions.insert(cos_F,
"function cos")); translate("VTranslateVars", "cosine function working with radians", "function cos"));
functionsArguments.insert(cos_F, oneArgument); functionsArguments.insert(cos_F, oneArgument);
functions.insert(tan_F, translate("VTranslateVars", "tan", "tangens function working with radians")); functions.insert(tan_F, translate("VTranslateVars", "tan", "tangens function working with radians"));
functionsDescriptions.insert(tan_F, translate("VTranslateVars", "tangens function working with radians", functionsDescriptions.insert(tan_F,
"function tan")); translate("VTranslateVars", "tangens function working with radians", "function tan"));
functionsArguments.insert(tan_F, oneArgument); functionsArguments.insert(tan_F, oneArgument);
functions.insert(asin_F, translate("VTranslateVars", "asin", "arcus sine function working with radians")); functions.insert(asin_F, translate("VTranslateVars", "asin", "arcus sine function working with radians"));
functionsDescriptions.insert(asin_F, translate("VTranslateVars", "arcus sine function working with radians", functionsDescriptions.insert(
"function asin")); asin_F, translate("VTranslateVars", "arcus sine function working with radians", "function asin"));
functionsArguments.insert(asin_F, oneArgument); functionsArguments.insert(asin_F, oneArgument);
functions.insert(acos_F, translate("VTranslateVars", "acos", "arcus cosine function working with radians")); functions.insert(acos_F, translate("VTranslateVars", "acos", "arcus cosine function working with radians"));
functionsDescriptions.insert(acos_F, translate("VTranslateVars", "arcus cosine function working with radians", functionsDescriptions.insert(
"function acos")); acos_F, translate("VTranslateVars", "arcus cosine function working with radians", "function acos"));
functionsArguments.insert(acos_F, oneArgument); functionsArguments.insert(acos_F, oneArgument);
functions.insert(atan_F, translate("VTranslateVars", "atan", "arcus tangens function working with radians")); functions.insert(atan_F, translate("VTranslateVars", "atan", "arcus tangens function working with radians"));
functionsDescriptions.insert(atan_F, translate("VTranslateVars", "arcus tangens function working with radians", functionsDescriptions.insert(
"function atan")); atan_F, translate("VTranslateVars", "arcus tangens function working with radians", "function atan"));
functionsArguments.insert(atan_F, oneArgument); functionsArguments.insert(atan_F, oneArgument);
functions.insert(sinh_F, translate("VTranslateVars", "sinh", "hyperbolic sine function")); functions.insert(sinh_F, translate("VTranslateVars", "sinh", "hyperbolic sine function"));
@ -460,48 +468,48 @@ void VTranslateVars::InitFunctions()
functionsArguments.insert(tanh_F, oneArgument); functionsArguments.insert(tanh_F, oneArgument);
functions.insert(asinh_F, translate("VTranslateVars", "asinh", "hyperbolic arcus sine function")); functions.insert(asinh_F, translate("VTranslateVars", "asinh", "hyperbolic arcus sine function"));
functionsDescriptions.insert(asinh_F, translate("VTranslateVars", "hyperbolic arcus sine function", functionsDescriptions.insert(asinh_F,
"function asinh")); translate("VTranslateVars", "hyperbolic arcus sine function", "function asinh"));
functionsArguments.insert(asinh_F, oneArgument); functionsArguments.insert(asinh_F, oneArgument);
functions.insert(acosh_F, translate("VTranslateVars", "acosh", "hyperbolic arcus cosine function")); functions.insert(acosh_F, translate("VTranslateVars", "acosh", "hyperbolic arcus cosine function"));
functionsDescriptions.insert(acosh_F, translate("VTranslateVars", "hyperbolic arcus cosine function", functionsDescriptions.insert(acosh_F,
"function acosh")); translate("VTranslateVars", "hyperbolic arcus cosine function", "function acosh"));
functionsArguments.insert(acosh_F, oneArgument); functionsArguments.insert(acosh_F, oneArgument);
functions.insert(atanh_F, translate("VTranslateVars", "atanh", "hyperbolic arcur tangens function")); functions.insert(atanh_F, translate("VTranslateVars", "atanh", "hyperbolic arcur tangens function"));
functionsDescriptions.insert(atanh_F, translate("VTranslateVars", "hyperbolic arcur tangens function", functionsDescriptions.insert(atanh_F,
"function atanh")); translate("VTranslateVars", "hyperbolic arcur tangens function", "function atanh"));
functionsArguments.insert(atanh_F, oneArgument); functionsArguments.insert(atanh_F, oneArgument);
functions.insert(sinD_F, translate("VTranslateVars", "sinD", "sine function working with degrees")); functions.insert(sinD_F, translate("VTranslateVars", "sinD", "sine function working with degrees"));
functionsDescriptions.insert(sinD_F, translate("VTranslateVars", "sine function working with degrees", functionsDescriptions.insert(sinD_F,
"function sinD")); translate("VTranslateVars", "sine function working with degrees", "function sinD"));
functionsArguments.insert(sinD_F, oneArgument); functionsArguments.insert(sinD_F, oneArgument);
functions.insert(cosD_F, translate("VTranslateVars", "cosD", "cosine function working with degrees")); functions.insert(cosD_F, translate("VTranslateVars", "cosD", "cosine function working with degrees"));
functionsDescriptions.insert(cosD_F, translate("VTranslateVars", "cosine function working with degrees", functionsDescriptions.insert(cosD_F,
"function cosD")); translate("VTranslateVars", "cosine function working with degrees", "function cosD"));
functionsArguments.insert(cosD_F, oneArgument); functionsArguments.insert(cosD_F, oneArgument);
functions.insert(tanD_F, translate("VTranslateVars", "tanD", "tangens function working with degrees")); functions.insert(tanD_F, translate("VTranslateVars", "tanD", "tangens function working with degrees"));
functionsDescriptions.insert(tanD_F, translate("VTranslateVars", "tangens function working with degrees", functionsDescriptions.insert(tanD_F,
"function tanD")); translate("VTranslateVars", "tangens function working with degrees", "function tanD"));
functionsArguments.insert(tanD_F, oneArgument); functionsArguments.insert(tanD_F, oneArgument);
functions.insert(asinD_F, translate("VTranslateVars", "asinD", "arcus sine function working with degrees")); functions.insert(asinD_F, translate("VTranslateVars", "asinD", "arcus sine function working with degrees"));
functionsDescriptions.insert(asinD_F, translate("VTranslateVars", "arcus sine function working with degrees", functionsDescriptions.insert(
"function asinD")); asinD_F, translate("VTranslateVars", "arcus sine function working with degrees", "function asinD"));
functionsArguments.insert(asinD_F, oneArgument); functionsArguments.insert(asinD_F, oneArgument);
functions.insert(acosD_F, translate("VTranslateVars", "acosD", "arcus cosine function working with degrees")); functions.insert(acosD_F, translate("VTranslateVars", "acosD", "arcus cosine function working with degrees"));
functionsDescriptions.insert(acosD_F, translate("VTranslateVars", "arcus cosine function working with degrees", functionsDescriptions.insert(
"function acosD")); acosD_F, translate("VTranslateVars", "arcus cosine function working with degrees", "function acosD"));
functionsArguments.insert(acosD_F, oneArgument); functionsArguments.insert(acosD_F, oneArgument);
functions.insert(atanD_F, translate("VTranslateVars", "atanD", "arcus tangens function working with degrees")); functions.insert(atanD_F, translate("VTranslateVars", "atanD", "arcus tangens function working with degrees"));
functionsDescriptions.insert(atanD_F, translate("VTranslateVars", "arcus tangens function working with degrees", functionsDescriptions.insert(
"function atanD")); atanD_F, translate("VTranslateVars", "arcus tangens function working with degrees", "function atanD"));
functionsArguments.insert(atanD_F, oneArgument); functionsArguments.insert(atanD_F, oneArgument);
functions.insert(log2_F, translate("VTranslateVars", "log2", "logarithm to the base 2")); functions.insert(log2_F, translate("VTranslateVars", "log2", "logarithm to the base 2"));
@ -529,8 +537,8 @@ void VTranslateVars::InitFunctions()
functionsArguments.insert(sqrt_F, oneArgument); functionsArguments.insert(sqrt_F, oneArgument);
functions.insert(sign_F, translate("VTranslateVars", "sign", "sign function -1 if x<0; 1 if x>0")); functions.insert(sign_F, translate("VTranslateVars", "sign", "sign function -1 if x<0; 1 if x>0"));
functionsDescriptions.insert(sign_F, translate("VTranslateVars", "sign function -1 if x<0; 1 if x>0", functionsDescriptions.insert(sign_F,
"function sign")); translate("VTranslateVars", "sign function -1 if x<0; 1 if x>0", "function sign"));
functionsArguments.insert(sign_F, oneArgument); functionsArguments.insert(sign_F, oneArgument);
functions.insert(rint_F, translate("VTranslateVars", "rint", "round to nearest integer")); functions.insert(rint_F, translate("VTranslateVars", "rint", "round to nearest integer"));
@ -541,16 +549,22 @@ void VTranslateVars::InitFunctions()
functionsDescriptions.insert(r2cm_F, translate("VTranslateVars", "round to up to 1 decimal", "function r2cm")); functionsDescriptions.insert(r2cm_F, translate("VTranslateVars", "round to up to 1 decimal", "function r2cm"));
functionsArguments.insert(r2cm_F, oneArgument); functionsArguments.insert(r2cm_F, oneArgument);
functions.insert(csrCm_F, translate("VTranslateVars", "csrCm", "cut, split and rotate modeling operation. Takes" functions.insert(csrCm_F, translate("VTranslateVars", "csrCm",
"cut, split and rotate modeling operation. Takes"
" cm units.")); " cm units."));
functionsDescriptions.insert(csrCm_F, translate("VTranslateVars", "cut, split and rotate modeling operation. Takes " functionsDescriptions.insert(csrCm_F, translate("VTranslateVars",
"cm units.", "function csrCm")); "cut, split and rotate modeling operation. Takes "
"cm units.",
"function csrCm"));
functionsArguments.insert(csrCm_F, threeArguments); functionsArguments.insert(csrCm_F, threeArguments);
functions.insert(csrInch_F, translate("VTranslateVars", "csrInch", "cut, split and rotate modeling operation. Takes" functions.insert(csrInch_F, translate("VTranslateVars", "csrInch",
"cut, split and rotate modeling operation. Takes"
" inch units.")); " inch units."));
functionsDescriptions.insert(csrInch_F, translate("VTranslateVars", "cut, split and rotate modeling operation. " functionsDescriptions.insert(csrInch_F, translate("VTranslateVars",
"Takes inch units.", "function csrInch")); "cut, split and rotate modeling operation. "
"Takes inch units.",
"function csrInch"));
functionsArguments.insert(csrInch_F, threeArguments); functionsArguments.insert(csrInch_F, threeArguments);
functions.insert(abs_F, translate("VTranslateVars", "abs", "absolute value")); functions.insert(abs_F, translate("VTranslateVars", "abs", "absolute value"));
@ -575,14 +589,15 @@ void VTranslateVars::InitFunctions()
functions.insert(fmod_F, translate("VTranslateVars", "fmod", functions.insert(fmod_F, translate("VTranslateVars", "fmod",
"Returns the floating-point remainder of numer/denom (rounded towards zero)")); "Returns the floating-point remainder of numer/denom (rounded towards zero)"));
functionsDescriptions.insert(fmod_F, translate("VTranslateVars", "Returns the floating-point remainder of " functionsDescriptions.insert(fmod_F, translate("VTranslateVars",
"Returns the floating-point remainder of "
"numer/denom (rounded towards zero)", "numer/denom (rounded towards zero)",
"function fmod")); "function fmod"));
functionsArguments.insert(fmod_F, twoArguments); functionsArguments.insert(fmod_F, twoArguments);
functions.insert(warning_F, translate("VTranslateVars", "warning", "Calculation warning")); functions.insert(warning_F, translate("VTranslateVars", "warning", "Calculation warning"));
functionsDescriptions.insert(warning_F, translate("VTranslateVars", "Show a warning in calculations", functionsDescriptions.insert(warning_F,
"function warning")); translate("VTranslateVars", "Show a warning in calculations", "function warning"));
functionsArguments.insert(warning_F, twoArguments); functionsArguments.insert(warning_F, twoArguments);
} }
@ -630,7 +645,7 @@ void VTranslateVars::CorrectionsPositions(vsizetype position, vsizetype bias, QM
{ {
if (bias == 0) if (bias == 0)
{ {
return;// Nothing to correct; return; // Nothing to correct;
} }
BiasTokens(position, bias, tokens); BiasTokens(position, bias, tokens);
@ -641,7 +656,7 @@ void VTranslateVars::CorrectionsPositions(vsizetype position, vsizetype bias, QM
void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap<vsizetype, QString> &tokens, void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap<vsizetype, QString> &tokens,
QMap<vsizetype, QString> &numbers) const QMap<vsizetype, QString> &numbers) const
{ {
QList<vsizetype> tKeys = tokens.keys();// Take all tokens positions QList<vsizetype> tKeys = tokens.keys(); // Take all tokens positions
QList<QString> tValues = tokens.values(); QList<QString> tValues = tokens.values();
for (vsizetype i = 0; i < tKeys.size(); ++i) for (vsizetype i = 0; i < tKeys.size(); ++i)
{ {
@ -649,7 +664,7 @@ void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap<vsizetype,
if (MeasurementsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) if (MeasurementsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias))
{ {
if (bias != 0) if (bias != 0)
{// Translated token has different length than original. Position of next tokens need to be corrected. { // Translated token has different length than original. Position of next tokens need to be corrected.
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
tKeys = tokens.keys(); tKeys = tokens.keys();
tValues = tokens.values(); tValues = tokens.values();
@ -660,7 +675,7 @@ void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap<vsizetype,
if (VariablesFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) if (VariablesFromUser(newFormula, tKeys.at(i), tValues.at(i), bias))
{ {
if (bias != 0) if (bias != 0)
{// Translated token has different length than original. Position of next tokens need to be corrected. { // Translated token has different length than original. Position of next tokens need to be corrected.
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
tKeys = tokens.keys(); tKeys = tokens.keys();
tValues = tokens.values(); tValues = tokens.values();
@ -671,7 +686,7 @@ void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap<vsizetype,
if (FunctionsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) if (FunctionsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias))
{ {
if (bias != 0) if (bias != 0)
{// Translated token has different length than original. Position of next tokens need to be corrected. { // Translated token has different length than original. Position of next tokens need to be corrected.
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
tKeys = tokens.keys(); tKeys = tokens.keys();
tValues = tokens.values(); tValues = tokens.values();
@ -680,7 +695,7 @@ void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap<vsizetype,
} }
if (tValues.at(i) == LocaleNegativeSign(QLocale())) if (tValues.at(i) == LocaleNegativeSign(QLocale()))
{// unary minus { // unary minus
newFormula.replace(tKeys.at(i), 1, '-'); newFormula.replace(tKeys.at(i), 1, '-');
} }
} }
@ -692,26 +707,26 @@ void VTranslateVars::TranslateNumbersFromUser(QString &newFormula, QMap<vsizetyp
{ {
QLocale loc = QLocale(); // User locale QLocale loc = QLocale(); // User locale
if (loc != QLocale::c() && osSeparator) if (loc != QLocale::c() && osSeparator)
{// User want use Os separator { // User want use Os separator
QList<vsizetype> nKeys = numbers.keys();// Positions for all numbers in expression QList<vsizetype> nKeys = numbers.keys(); // Positions for all numbers in expression
QList<QString> nValues = numbers.values(); QList<QString> nValues = numbers.values();
for (int i = 0; i < nKeys.size(); ++i) for (int i = 0; i < nKeys.size(); ++i)
{ {
loc = QLocale();// From system locale loc = QLocale(); // From system locale
bool ok = false; bool ok = false;
const qreal d = loc.toDouble(nValues.at(i), &ok); const qreal d = loc.toDouble(nValues.at(i), &ok);
if (not ok) if (not ok)
{ {
qDebug()<<"Can't convert to double token"<<nValues.at(i); qDebug() << "Can't convert to double token" << nValues.at(i);
continue;//Leave with out translation continue; // Leave with out translation
} }
loc = QLocale::c();// To internal locale loc = QLocale::c(); // To internal locale
const QString dStr = loc.toString(d);// Internal look for number const QString dStr = loc.toString(d); // Internal look for number
newFormula.replace(nKeys.at(i), nValues.at(i).length(), dStr); newFormula.replace(nKeys.at(i), nValues.at(i).length(), dStr);
const auto bias = nValues.at(i).length() - dStr.length(); const auto bias = nValues.at(i).length() - dStr.length();
if (bias != 0) if (bias != 0)
{// Translated number has different length than original. Position next tokens need to be corrected. { // Translated number has different length than original. Position next tokens need to be corrected.
CorrectionsPositions(nKeys.at(i), bias, tokens, numbers); CorrectionsPositions(nKeys.at(i), bias, tokens, numbers);
nKeys = numbers.keys(); nKeys = numbers.keys();
nValues = numbers.values(); nValues = numbers.values();
@ -730,14 +745,14 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap<vsizetype, QS
{ {
if (measurements.contains(tValues.at(i))) if (measurements.contains(tValues.at(i)))
{ {
newFormula.replace(tKeys.at(i), tValues.at(i).length(), newFormula.replace(
measurements.value(tValues.at(i)) tKeys.at(i), tValues.at(i).length(),
.translate(VAbstractApplication::VApp()->Settings()->GetLocale())); measurements.value(tValues.at(i)).translate(VAbstractApplication::VApp()->Settings()->GetLocale()));
auto bias = tValues.at(i).length() - auto bias = tValues.at(i).length() - measurements.value(tValues.at(i))
measurements.value(tValues.at(i)) .translate(VAbstractApplication::VApp()->Settings()->GetLocale())
.translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); .length();
if (bias != 0) if (bias != 0)
{// Translated token has different length than original. Position next tokens need to be corrected. { // Translated token has different length than original. Position next tokens need to be corrected.
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
tKeys = tokens.keys(); tKeys = tokens.keys();
tValues = tokens.values(); tValues = tokens.values();
@ -747,14 +762,14 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap<vsizetype, QS
if (functions.contains(tValues.at(i))) if (functions.contains(tValues.at(i)))
{ {
newFormula.replace(tKeys.at(i), tValues.at(i).length(), newFormula.replace(
functions.value(tValues.at(i)) tKeys.at(i), tValues.at(i).length(),
.translate(VAbstractApplication::VApp()->Settings()->GetLocale())); functions.value(tValues.at(i)).translate(VAbstractApplication::VApp()->Settings()->GetLocale()));
auto bias = tValues.at(i).length() - auto bias = tValues.at(i).length() - functions.value(tValues.at(i))
functions.value(tValues.at(i)) .translate(VAbstractApplication::VApp()->Settings()->GetLocale())
.translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); .length();
if (bias != 0) if (bias != 0)
{// Translated token has different length than original. Position next tokens need to be corrected. { // Translated token has different length than original. Position next tokens need to be corrected.
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
tKeys = tokens.keys(); tKeys = tokens.keys();
tValues = tokens.values(); tValues = tokens.values();
@ -766,7 +781,7 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap<vsizetype, QS
if (VariablesToUser(newFormula, tKeys.at(i), tValues.at(i), bias)) if (VariablesToUser(newFormula, tKeys.at(i), tValues.at(i), bias))
{ {
if (bias != 0) if (bias != 0)
{// Translated token has different length than original. Position next tokens need to be corrected. { // Translated token has different length than original. Position next tokens need to be corrected.
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
tKeys = tokens.keys(); tKeys = tokens.keys();
tValues = tokens.values(); tValues = tokens.values();
@ -775,7 +790,7 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap<vsizetype, QS
} }
if (tValues.at(i) == QChar('-')) if (tValues.at(i) == QChar('-'))
{// unary minus { // unary minus
newFormula.replace(tKeys.at(i), 1, LocaleNegativeSign(QLocale())); newFormula.replace(tKeys.at(i), 1, LocaleNegativeSign(QLocale()));
} }
} }
@ -785,24 +800,24 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap<vsizetype, QS
void VTranslateVars::TranslateNumbersToUser(QString &newFormula, QMap<vsizetype, QString> &tokens, void VTranslateVars::TranslateNumbersToUser(QString &newFormula, QMap<vsizetype, QString> &tokens,
QMap<vsizetype, QString> &numbers, bool osSeparator) QMap<vsizetype, QString> &numbers, bool osSeparator)
{ {
QLocale loc = QLocale();// User locale QLocale loc = QLocale(); // User locale
if (loc != QLocale::C && osSeparator) if (loc != QLocale::C && osSeparator)
{// User want use Os separator { // User want use Os separator
QList<vsizetype> nKeys = numbers.keys();// Positions for all numbers in expression QList<vsizetype> nKeys = numbers.keys(); // Positions for all numbers in expression
QList<QString> nValues = numbers.values(); QList<QString> nValues = numbers.values();
for (int i = 0; i < nKeys.size(); ++i) for (int i = 0; i < nKeys.size(); ++i)
{ {
loc = QLocale::c();// From pattern locale loc = QLocale::c(); // From pattern locale
bool ok = false; bool ok = false;
const qreal d = loc.toDouble(nValues.at(i), &ok); const qreal d = loc.toDouble(nValues.at(i), &ok);
if (not ok) if (not ok)
{ {
qDebug()<<"Can't convert to double token"<<nValues.at(i); qDebug() << "Can't convert to double token" << nValues.at(i);
continue;//Leave with out translation continue; // Leave with out translation
} }
loc = QLocale();// To user locale loc = QLocale(); // To user locale
QString dStr = loc.toString(d);// Number string in user locale QString dStr = loc.toString(d); // Number string in user locale
if (VLocaleCharacter(LocaleGroupSeparator(loc)).isSpace()) if (VLocaleCharacter(LocaleGroupSeparator(loc)).isSpace())
{ {
dStr.replace(LocaleGroupSeparator(loc), QString()); dStr.replace(LocaleGroupSeparator(loc), QString());
@ -810,7 +825,7 @@ void VTranslateVars::TranslateNumbersToUser(QString &newFormula, QMap<vsizetype,
newFormula.replace(nKeys.at(i), nValues.at(i).length(), dStr); newFormula.replace(nKeys.at(i), nValues.at(i).length(), dStr);
const auto bias = nValues.at(i).length() - dStr.length(); const auto bias = nValues.at(i).length() - dStr.length();
if (bias != 0) if (bias != 0)
{// Translated number has different length than original. Position next tokens need to be corrected. { // Translated number has different length than original. Position next tokens need to be corrected.
CorrectionsPositions(nKeys.at(i), bias, tokens, numbers); CorrectionsPositions(nKeys.at(i), bias, tokens, numbers);
nKeys = numbers.keys(); nKeys = numbers.keys();
nValues = numbers.values(); nValues = numbers.values();
@ -832,21 +847,19 @@ void VTranslateVars::BiasTokens(vsizetype position, vsizetype bias, QMap<vsizety
QMap<vsizetype, QString>::const_iterator i = tokens.constBegin(); QMap<vsizetype, QString>::const_iterator i = tokens.constBegin();
while (i != tokens.constEnd()) while (i != tokens.constEnd())
{ {
if (i.key()<= position) if (i.key() <= position)
{ // Tokens before position "position" did not change his positions. { // Tokens before position "position" did not change his positions.
newTokens.insert(i.key(), i.value()); newTokens.insert(i.key(), i.value());
} }
else else
{ {
newTokens.insert(i.key()-bias, i.value()); newTokens.insert(i.key() - bias, i.value());
} }
++i; ++i;
} }
tokens = newTokens; tokens = newTokens;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief VariablesFromUser translate variable to internal look. * @brief VariablesFromUser translate variable to internal look.
@ -861,8 +874,8 @@ auto VTranslateVars::VariablesFromUser(QString &newFormula, vsizetype position,
{ {
const QString currentLengthTr = const QString currentLengthTr =
variables.value(currentLength).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); variables.value(currentLength).translate(VAbstractApplication::VApp()->Settings()->GetLocale());
const QString currentSeamAllowanceTr = variables.value(currentSeamAllowance) const QString currentSeamAllowanceTr =
.translate(VAbstractApplication::VApp()->Settings()->GetLocale()); variables.value(currentSeamAllowance).translate(VAbstractApplication::VApp()->Settings()->GetLocale());
QMap<QString, qmu::QmuTranslation>::const_iterator i = variables.constBegin(); QMap<QString, qmu::QmuTranslation>::const_iterator i = variables.constBegin();
while (i != variables.constEnd()) while (i != variables.constEnd())
@ -930,7 +943,7 @@ auto VTranslateVars::VariablesToUser(QString &newFormula, vsizetype position, co
QMap<QString, qmu::QmuTranslation>::const_iterator i = variables.constBegin(); QMap<QString, qmu::QmuTranslation>::const_iterator i = variables.constBegin();
while (i != variables.constEnd()) while (i != variables.constEnd())
{ {
if (token.indexOf( i.key() ) == 0) if (token.indexOf(i.key()) == 0)
{ {
if ((i.key() == currentLength || i.key() == currentSeamAllowance) && token != i.key()) if ((i.key() == currentLength || i.key() == currentSeamAllowance) && token != i.key())
{ {
@ -1049,11 +1062,11 @@ auto VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator) c
// Eval formula // Eval formula
QScopedPointer<qmu::QmuTokenParser> cal( QScopedPointer<qmu::QmuTokenParser> cal(
new qmu::QmuTokenParser(formula, osSeparator, true, GetTranslatedFunctions())); new qmu::QmuTokenParser(formula, osSeparator, true, GetTranslatedFunctions()));
QMap<vsizetype, QString> tokens = cal->GetTokens();// Tokens (variables, measurements) QMap<vsizetype, QString> tokens = cal->GetTokens(); // Tokens (variables, measurements)
QMap<vsizetype, QString> numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator QMap<vsizetype, QString> numbers = cal->GetNumbers(); // All numbers in expression for changing decimal separator
cal.reset(); cal.reset();
QString newFormula = formula;// Local copy for making changes QString newFormula = formula; // Local copy for making changes
TranslateVarsFromUser(newFormula, tokens, numbers); TranslateVarsFromUser(newFormula, tokens, numbers);
TranslateNumbersFromUser(newFormula, tokens, numbers, osSeparator); TranslateNumbersFromUser(newFormula, tokens, numbers, osSeparator);
@ -1069,7 +1082,7 @@ auto VTranslateVars::TryFormulaFromUser(const QString &formula, bool osSeparator
SCASSERT(VAbstractApplication::VApp()->TrVars() != nullptr) SCASSERT(VAbstractApplication::VApp()->TrVars() != nullptr)
return VAbstractApplication::VApp()->TrVars()->FormulaFromUser(formula, osSeparator); return VAbstractApplication::VApp()->TrVars()->FormulaFromUser(formula, osSeparator);
} }
catch (qmu::QmuParserError &e)// In case something bad will happen catch (qmu::QmuParserError &e) // In case something bad will happen
{ {
Q_UNUSED(e) Q_UNUSED(e)
return formula; return formula;
@ -1090,15 +1103,15 @@ auto VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator) con
return formula; return formula;
} }
QString newFormula = formula;// Local copy for making changes QString newFormula = formula; // Local copy for making changes
QMap<vsizetype, QString> tokens; QMap<vsizetype, QString> tokens;
QMap<vsizetype, QString> numbers; QMap<vsizetype, QString> numbers;
try try
{ {
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula, false, false));// Eval formula QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula, false, false)); // Eval formula
tokens = cal->GetTokens();// Tokens (variables, measurements) tokens = cal->GetTokens(); // Tokens (variables, measurements)
numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator numbers = cal->GetNumbers(); // All numbers in expression for changing decimal separator
} }
catch (qmu::QmuParserError &e) catch (qmu::QmuParserError &e)
{ {
@ -1123,7 +1136,7 @@ auto VTranslateVars::TryFormulaToUser(const QString &formula, bool osSeparator)
{ {
return VAbstractApplication::VApp()->TrVars()->FormulaToUser(formula, osSeparator); return VAbstractApplication::VApp()->TrVars()->FormulaToUser(formula, osSeparator);
} }
catch (qmu::QmuParserError &e)// In case something bad will happen catch (qmu::QmuParserError &e) // In case something bad will happen
{ {
Q_UNUSED(e) Q_UNUSED(e)
return formula; return formula;

View File

@ -29,25 +29,25 @@
#ifndef ABSTRACTTEST_H #ifndef ABSTRACTTEST_H
#define ABSTRACTTEST_H #define ABSTRACTTEST_H
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMetaObject> #include <QMetaObject>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QJsonDocument> #include <QtCore/qcontainerfwd.h>
#include <QJsonObject>
#include <QJsonArray>
#include <qtestcase.h> #include <qtestcase.h>
#include <typeinfo> #include <typeinfo>
#include <QtCore/qcontainerfwd.h>
#include "../vgeometry/vpointf.h"
#include "../vlayout/vsapoint.h"
#include "../vlayout/vrawsapoint.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../vgeometry/vpointf.h"
#include "../vlayout/vrawsapoint.h"
#include "../vlayout/vsapoint.h"
#include <ciso646> #include <ciso646>
#ifdef __GNUC__ #ifdef __GNUC__
#define V_UNUSED __attribute__ ((unused)) #define V_UNUSED __attribute__((unused))
#else #else
#define V_UNUSED #define V_UNUSED
#endif #endif
@ -60,7 +60,13 @@ static const auto V_UNUSED TST_EX_CRASH = -4; // Program crashed.
#undef V_UNUSED #undef V_UNUSED
enum ErrorState {ErrorLoad = 0, ErrorInstall, ErrorSize, NoError}; enum ErrorState
{
ErrorLoad = 0,
ErrorInstall,
ErrorSize,
NoError
};
class VPiece; class VPiece;
class VContainer; class VContainer;
@ -74,15 +80,13 @@ class VRawSAPoint;
class AbstractTest : public QObject class AbstractTest : public QObject
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public : explicit AbstractTest(QObject *parent = nullptr);
explicit AbstractTest(QObject *parent = nullptr);
template <class T> template <class T> static auto VectorFromJson(const QString &json) -> QVector<T>;
static auto VectorFromJson(const QString &json) -> QVector<T>;
void PieceFromJson(const QString &json, VPiece &piece, QSharedPointer<VContainer> &data); void PieceFromJson(const QString &json, VPiece &piece, QSharedPointer<VContainer> &data);
void PassmarkDataFromJson(const QString &json, VPiecePassmarkData& data); void PassmarkDataFromJson(const QString &json, VPiecePassmarkData &data);
void PassmarkShapeFromJson(const QString &json, QVector<QLineF> &shape); void PassmarkShapeFromJson(const QString &json, QVector<QLineF> &shape);
protected: protected:
@ -104,13 +108,13 @@ protected:
static void PrepareDocument(const QString &json, QByteArray &data); static void PrepareDocument(const QString &json, QByteArray &data);
static void TestRoot(const QJsonObject &root, const QString &attribute, const QString &file); static void TestRoot(const QJsonObject &root, const QString &attribute, const QString &file);
template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr> template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type * = nullptr>
static void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value, static void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value,
const QString &defaultValue = QString()); const QString &defaultValue = QString());
template <typename T, typename std::enable_if<std::is_enum<T>::value>::type* = nullptr> template <typename T, typename std::enable_if<std::is_enum<T>::value>::type * = nullptr>
static void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value, static void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value,
const QString &defaultValue = QString()); const QString &defaultValue = QString());
template <typename T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr> template <typename T, typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
static void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value, static void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value,
const QString &defaultValue = QString()); const QString &defaultValue = QString());
static void ReadStringValue(const QJsonObject &itemObject, const QString &attribute, QString &value, static void ReadStringValue(const QJsonObject &itemObject, const QString &attribute, QString &value,
@ -122,14 +126,11 @@ protected:
void ReadSplinePointValue(const QJsonObject &itemObject, VSplinePoint &point); void ReadSplinePointValue(const QJsonObject &itemObject, VSplinePoint &point);
void ReadPieceNodeValue(const QJsonObject &itemObject, VPieceNode &node); void ReadPieceNodeValue(const QJsonObject &itemObject, VPieceNode &node);
template <class T> template <class T> static void CheckClassType(const QJsonObject &itemObject);
static void CheckClassType(const QJsonObject &itemObject);
template <class T> template <class T> static auto ReadPointData(const QJsonObject &pointObject) -> T;
static auto ReadPointData(const QJsonObject &pointObject) -> T;
template <class T> template <class T> static auto PointFromJson(const QJsonObject &pointObject, T &point) -> void;
static auto PointFromJson(const QJsonObject &pointObject, T &point) -> void;
auto QLineFromJson(const QJsonObject &itemObject) -> QLineF; auto QLineFromJson(const QJsonObject &itemObject) -> QLineF;
void SplineFromJson(const QJsonObject &itemObject, QSharedPointer<VContainer> &data); void SplineFromJson(const QJsonObject &itemObject, QSharedPointer<VContainer> &data);
@ -140,8 +141,7 @@ protected:
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<class T> template <class T> inline auto AbstractTest::VectorFromJson(const QString &json) -> QVector<T>
inline auto AbstractTest::VectorFromJson(const QString &json) -> QVector<T>
{ {
QByteArray saveData; QByteArray saveData;
PrepareDocument(json, saveData); PrepareDocument(json, saveData);
@ -174,16 +174,14 @@ inline auto AbstractTest::VectorFromJson(const QString &json) -> QVector<T>
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<class T> template <class T> inline void AbstractTest::CheckClassType(const QJsonObject &itemObject)
inline void AbstractTest::CheckClassType(const QJsonObject &itemObject)
{ {
const QString typeKey = QStringLiteral("type"); const QString typeKey = QStringLiteral("type");
QString type; QString type;
AbstractTest::ReadStringValue(itemObject, typeKey, type); AbstractTest::ReadStringValue(itemObject, typeKey, type);
const QStringList types const QStringList types{
{
QStringLiteral("QPointF"), // 0 QStringLiteral("QPointF"), // 0
QStringLiteral("VLayoutPoint"), // 1 QStringLiteral("VLayoutPoint"), // 1
QStringLiteral("VRawSAPoint"), // 2 QStringLiteral("VRawSAPoint"), // 2
@ -216,8 +214,7 @@ inline void AbstractTest::CheckClassType(const QJsonObject &itemObject)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<class T> template <class T> inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> T
inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> T
{ {
T point; T point;
qreal x = 0; qreal x = 0;
@ -232,16 +229,14 @@ inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> T
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<class T> template <class T> inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, T &point) -> void
inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, T &point) -> void
{ {
CheckClassType<T>(pointObject); CheckClassType<T>(pointObject);
point = ReadPointData<T>(pointObject); point = ReadPointData<T>(pointObject);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<> template <> inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VPointF &point) -> void
inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VPointF &point) -> void
{ {
vidtype id = NULL_ID; vidtype id = NULL_ID;
AbstractTest::ReadDoubleValue(pointObject, QStringLiteral("id"), id); AbstractTest::ReadDoubleValue(pointObject, QStringLiteral("id"), id);
@ -266,8 +261,7 @@ inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VPointF
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<> template <> inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> VLayoutPoint
inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> VLayoutPoint
{ {
VLayoutPoint point(ReadPointData<QPointF>(pointObject)); VLayoutPoint point(ReadPointData<QPointF>(pointObject));
@ -283,16 +277,14 @@ inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> VLayo
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<> template <> inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VLayoutPoint &point) -> void
inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VLayoutPoint &point) -> void
{ {
CheckClassType<VLayoutPoint>(pointObject); CheckClassType<VLayoutPoint>(pointObject);
point = ReadPointData<VLayoutPoint>(pointObject); point = ReadPointData<VLayoutPoint>(pointObject);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<> template <> inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VSAPoint &point) -> void
inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VSAPoint &point) -> void
{ {
CheckClassType<VSAPoint>(pointObject); CheckClassType<VSAPoint>(pointObject);
@ -357,8 +349,7 @@ inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VSAPoint
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<> template <> inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VRawSAPoint &point) -> void
inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VRawSAPoint &point) -> void
{ {
CheckClassType<VRawSAPoint>(pointObject); CheckClassType<VRawSAPoint>(pointObject);

View File

@ -28,21 +28,21 @@
#include <QtTest> #include <QtTest>
#include "tst_measurementregexp.h"
#include "tst_buitinregexp.h" #include "tst_buitinregexp.h"
#include "tst_measurementregexp.h"
#include "tst_qmuparsererrormsg.h" #include "tst_qmuparsererrormsg.h"
#include "tst_tstranslation.h"
#include "tst_tslocaletranslation.h" #include "tst_tslocaletranslation.h"
#include "tst_tstranslation.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/testvapplication.h" #include "../vmisc/testvapplication.h"
auto main(int argc, char **argv) -> int auto main(int argc, char **argv) -> int
{ {
TestVApplication app( argc, argv );// For QPrinter TestVApplication app(argc, argv); // For QPrinter
int status = 0; int status = 0;
auto ASSERT_TEST = [&status, argc, argv](QObject* obj) auto ASSERT_TEST = [&status, argc, argv](QObject *obj)
{ {
status |= QTest::qExec(obj, argc, argv); status |= QTest::qExec(obj, argc, argv);
delete obj; delete obj;
@ -51,7 +51,7 @@ auto main(int argc, char **argv) -> int
ASSERT_TEST(new TST_TSTranslation()); ASSERT_TEST(new TST_TSTranslation());
const QStringList locales = SupportedLocales(); const QStringList locales = SupportedLocales();
for(const auto &locale : locales) for (const auto &locale : locales)
{ {
for(quint32 s = 0; s < TST_MeasurementRegExp::systemCounts; ++s) for(quint32 s = 0; s < TST_MeasurementRegExp::systemCounts; ++s)
{ {

View File

@ -29,12 +29,11 @@
#include "tst_abstractregexp.h" #include "tst_abstractregexp.h"
#include "../qmuparser/qmudef.h" #include "../qmuparser/qmudef.h"
#include "../qmuparser/qmuformulabase.h" #include "../qmuparser/qmuformulabase.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../ifc/ifcdef.h"
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "../vpatterndb/vtranslatevars.h"
#include <QtTest>
#include <QTranslator> #include <QTranslator>
#include <QtTest>
namespace namespace
{ {
@ -69,7 +68,7 @@ auto TST_AbstractRegExp::LoadVariables(const QString &checkedLocale) -> int
const QString path = TranslationsPath(); const QString path = TranslationsPath();
const QString file = QString("valentina_%1.qm").arg(checkedLocale); const QString file = QString("valentina_%1.qm").arg(checkedLocale);
if (QFileInfo(path+QLatin1String("/")+file).size() <= 34) if (QFileInfo(path + QLatin1String("/") + file).size() <= 34)
{ {
const QString message = QString("Translation variables for locale = %1 is empty. \nFull path: %2/%3") const QString message = QString("Translation variables for locale = %1 is empty. \nFull path: %2/%3")
.arg(checkedLocale, path, file); .arg(checkedLocale, path, file);
@ -114,8 +113,7 @@ void TST_AbstractRegExp::RemoveTrVariables(const QString &checkedLocale)
if (result == false) if (result == false)
{ {
const QString message = QString("Can't remove translation variables for locale = %1") const QString message = QString("Can't remove translation variables for locale = %1").arg(checkedLocale);
.arg(checkedLocale);
QWARN(qUtf8Printable(message)); QWARN(qUtf8Printable(message));
} }
delete m_vTranslator; delete m_vTranslator;
@ -143,8 +141,7 @@ void TST_AbstractRegExp::CallTestCheckNoEndLine()
const QString translated = m_trMs->VarToUser(originalName); const QString translated = m_trMs->VarToUser(originalName);
if (translated.endsWith(QLatin1String("\n"))) if (translated.endsWith(QLatin1String("\n")))
{ {
const QString message = QString("Translated string '%1' shouldn't contain new line character.") const QString message = QString("Translated string '%1' shouldn't contain new line character.").arg(translated);
.arg(translated);
QFAIL(qUtf8Printable(message)); QFAIL(qUtf8Printable(message));
} }
} }
@ -193,8 +190,8 @@ void TST_AbstractRegExp::CallTestForValidCharacters()
if (QLocale() == QLocale(QStringLiteral("zh_CN")) || QLocale() == QLocale(QStringLiteral("he_IL"))) if (QLocale() == QLocale(QStringLiteral("zh_CN")) || QLocale() == QLocale(QStringLiteral("he_IL")))
{ {
const QString message = QStringLiteral("We do not support translation of variables for locale %1") const QString message =
.arg(QLocale().name()); QStringLiteral("We do not support translation of variables for locale %1").arg(QLocale().name());
QSKIP(qUtf8Printable(message)); QSKIP(qUtf8Printable(message));
} }
@ -203,7 +200,10 @@ void TST_AbstractRegExp::CallTestForValidCharacters()
if (pos != -1) if (pos != -1)
{ {
const QString message = QStringLiteral("Translated string '%1' contains invalid character '%2' at " const QString message = QStringLiteral("Translated string '%1' contains invalid character '%2' at "
"position '%3'.").arg(translated).arg(translated.at(pos)).arg(pos); "position '%3'.")
.arg(translated)
.arg(translated.at(pos))
.arg(pos);
QFAIL(qUtf8Printable(message)); QFAIL(qUtf8Printable(message));
} }
} }

View File

@ -27,13 +27,11 @@
*************************************************************************/ *************************************************************************/
#include "tst_measurementregexp.h" #include "tst_measurementregexp.h"
#include "../qmuparser/qmudef.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vpatterndb/measurements.h" #include "../vpatterndb/measurements.h"
#include "../ifc/ifcdef.h" #include "../vpatterndb/vtranslatevars.h"
#include "abstracttest.h"
#include <QtTest>
#include <QTranslator> #include <QTranslator>
const quint32 TST_MeasurementRegExp::systemCounts = 56; // count of pattern making systems const quint32 TST_MeasurementRegExp::systemCounts = 56; // count of pattern making systems
@ -93,7 +91,7 @@ void TST_MeasurementRegExp::initTestCase()
QLocale::setDefault(QLocale(m_locale)); QLocale::setDefault(QLocale(m_locale));
InitTrMs();//Very important do this after loading QM files. InitTrMs(); // Very important do this after loading QM files.
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -202,8 +200,8 @@ void TST_MeasurementRegExp::TestCombinations(int systemCounts, const QStringList
const QStringList fileNames = dir.entryList(QStringList("measurements_p*_*.qm")); const QStringList fileNames = dir.entryList(QStringList("measurements_p*_*.qm"));
// cppcheck-suppress unreadVariable // cppcheck-suppress unreadVariable
const QString error = QString("Unexpected count of files. Excpected %1, got %2.") const QString error =
.arg(combinations).arg(fileNames.size()); QString("Unexpected count of files. Excpected %1, got %2.").arg(combinations).arg(fileNames.size());
QVERIFY2(combinations == fileNames.size(), qUtf8Printable(error)); QVERIFY2(combinations == fileNames.size(), qUtf8Printable(error));
} }
@ -233,7 +231,7 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const
const QString path = TranslationsPath(); const QString path = TranslationsPath();
const QString file = QString("measurements_%1_%2.qm").arg(checkedSystem, checkedLocale); const QString file = QString("measurements_%1_%2.qm").arg(checkedSystem, checkedLocale);
if (QFileInfo(path+QLatin1String("/")+file).size() <= 34) if (QFileInfo(path + QLatin1String("/") + file).size() <= 34)
{ {
const QString message = QString("Translation for system = %1 and locale = %2 is empty. \nFull path: %3/%4") const QString message = QString("Translation for system = %1 and locale = %2 is empty. \nFull path: %3/%4")
.arg(checkedSystem, checkedLocale, path, file); .arg(checkedSystem, checkedLocale, path, file);
@ -279,8 +277,8 @@ void TST_MeasurementRegExp::RemoveTrMeasurements(const QString &checkedSystem, c
if (result == false) if (result == false)
{ {
const QString message = QString("Can't remove translation for system = %1 and locale = %2") const QString message =
.arg(checkedSystem, checkedLocale); QString("Can't remove translation for system = %1 and locale = %2").arg(checkedSystem, checkedLocale);
QWARN(qUtf8Printable(message)); QWARN(qUtf8Printable(message));
} }
delete m_pmsTranslator; delete m_pmsTranslator;

View File

@ -29,8 +29,8 @@
#ifndef TST_MEASUREMENTREGEXP_H #ifndef TST_MEASUREMENTREGEXP_H
#define TST_MEASUREMENTREGEXP_H #define TST_MEASUREMENTREGEXP_H
#include "tst_abstractregexp.h"
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
#include "tst_abstractregexp.h"
#include <QPointer> #include <QPointer>
@ -72,7 +72,7 @@ private:
QString m_system; QString m_system;
QPointer<QTranslator> m_pmsTranslator; QPointer<QTranslator> m_pmsTranslator;
void TestCombinations(int systemCounts, const QStringList &locales) const; void TestCombinations(const QStringList &locales) const;
auto LoadMeasurements(const QString &checkedSystem, const QString &checkedLocale) -> int; auto LoadMeasurements(const QString &checkedSystem, const QString &checkedLocale) -> int;
void RemoveTrMeasurements(const QString &checkedSystem, const QString &checkedLocale); void RemoveTrMeasurements(const QString &checkedSystem, const QString &checkedLocale);

View File

@ -38,7 +38,8 @@ Q_DECLARE_METATYPE(Qt::LayoutDirection)
TST_TSLocaleTranslation::TST_TSLocaleTranslation(const QString &locale, QObject *parent) TST_TSLocaleTranslation::TST_TSLocaleTranslation(const QString &locale, QObject *parent)
: TST_AbstractTranslation(parent), : TST_AbstractTranslation(parent),
m_locale(locale) m_locale(locale)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TST_TSLocaleTranslation::CheckPlaceMarkerExist_data() void TST_TSLocaleTranslation::CheckPlaceMarkerExist_data()
@ -82,8 +83,8 @@ void TST_TSLocaleTranslation::CheckPlaceMarkerExist_data()
continue; continue;
} }
const QString caseName = QStringLiteral("File '%1'. Check place holder source message '%2'") const QString caseName =
.arg(filename, source); QStringLiteral("File '%1'. Check place holder source message '%2'").arg(filename, source);
QTest::newRow(qUtf8Printable(caseName)) << source << translation << locale.textDirection(); QTest::newRow(qUtf8Printable(caseName)) << source << translation << locale.textDirection();
} }
else else
@ -116,9 +117,8 @@ void TST_TSLocaleTranslation::CheckPlaceMarkerExist()
++sourceMarkCount; ++sourceMarkCount;
if (sourceMarkCount != i) if (sourceMarkCount != i)
{ {
const QString message = QString("In source string '%1' was missed place marker ") const QString message = QString("In source string '%1' was missed place marker ").arg(source) +
.arg(source) + QLatin1String("'%") + QString().setNum(sourceMarkCount) + QLatin1String("'%") + QString().setNum(sourceMarkCount) + QLatin1String("'.");
QLatin1String("'.");
QFAIL(qUtf8Printable(message)); QFAIL(qUtf8Printable(message));
} }
} }
@ -129,9 +129,9 @@ void TST_TSLocaleTranslation::CheckPlaceMarkerExist()
++translationMarkCount; ++translationMarkCount;
if (translationMarkCount != i) if (translationMarkCount != i)
{ {
const QString message = QString("In translation string '%1' was missed place marker ") const QString message =
.arg(translation) + QLatin1String("'%") + QString().setNum(translationMarkCount) + QString("In translation string '%1' was missed place marker ").arg(translation) +
QLatin1String("'."); QLatin1String("'%") + QString().setNum(translationMarkCount) + QLatin1String("'.");
QFAIL(qUtf8Printable(message)); QFAIL(qUtf8Printable(message));
} }
} }
@ -207,26 +207,19 @@ void TST_TSLocaleTranslation::TestPunctuation()
QFETCH(QString, translation); QFETCH(QString, translation);
static const QStringList punctuation{ static const QStringList punctuation{
QChar('.'), QChar('.'), QChar(':'), QChar(QChar::Space), QChar('\n'), QChar('!'), QChar('?'), QChar(';'),
QChar(':'), QChar(0x2026) // …
QChar(QChar::Space),
QChar('\n'),
QChar('!'),
QChar('?'),
QChar(';'),
QChar(0x2026)//…
}; };
if (QLocale(locale).textDirection() != Qt::LeftToRight) if (QLocale(locale).textDirection() != Qt::LeftToRight)
{ {
QSKIP("Not supported text direction"); QSKIP("Not supported text direction");
} }
bool testFail = false; bool testFail = false;
const QChar cSource = source.at(source.length()-1); const QChar cSource = source.at(source.length() - 1);
QChar cPunctuation = cSource; QChar cPunctuation = cSource;
const QChar cTranslation = translation.at(translation.length()-1); const QChar cTranslation = translation.at(translation.length() - 1);
if (punctuation.contains(cSource)) if (punctuation.contains(cSource))
{ {
if (not translation.endsWith(cSource)) if (not translation.endsWith(cSource))
@ -261,7 +254,9 @@ void TST_TSLocaleTranslation::TestPunctuation()
if (testFail) if (testFail)
{ {
const QString message = QString("Translation string does not end with the same punctuation character '%1' or " const QString message = QString("Translation string does not end with the same punctuation character '%1' or "
"vice versa. ").arg(cPunctuation) + QString("Original name:'%1'").arg(source) + "vice versa. ")
.arg(cPunctuation) +
QString("Original name:'%1'").arg(source) +
QString(", translated name:'%1'").arg(translation); QString(", translated name:'%1'").arg(translation);
QFAIL(qUtf8Printable(message)); QFAIL(qUtf8Printable(message));
} }
@ -324,9 +319,8 @@ void TST_TSLocaleTranslation::TestHTMLTags()
QFETCH(QString, source); QFETCH(QString, source);
QFETCH(QString, translation); QFETCH(QString, translation);
static const QStringList tags = QStringList() << QLatin1String("p") static const QStringList tags = QStringList()
<< QLatin1String("html") << QLatin1String("p") << QLatin1String("html") << QLatin1String("body");
<< QLatin1String("body");
static const QString pattern("{1}.*>"); static const QString pattern("{1}.*>");
for (const auto &tag : tags) for (const auto &tag : tags)
{ {
@ -341,7 +335,8 @@ void TST_TSLocaleTranslation::TestHTMLTags()
if (not translation.contains(closeRegex) || countCloseTag != countOpenTag) if (not translation.contains(closeRegex) || countCloseTag != countOpenTag)
{ {
const QString message = QString("Tag mismatch. Tag: '<%1>'. ").arg(tag) + const QString message = QString("Tag mismatch. Tag: '<%1>'. ").arg(tag) +
QString("Original name:'%1'").arg(source) + QString(", translated name:'%1'").arg(translation); QString("Original name:'%1'").arg(source) +
QString(", translated name:'%1'").arg(translation);
QFAIL(qUtf8Printable(message)); QFAIL(qUtf8Printable(message));
} }
} }

View File

@ -27,7 +27,6 @@
*************************************************************************/ *************************************************************************/
#include "tst_tstranslation.h" #include "tst_tstranslation.h"
#include "../vmisc/def.h"
#include <QDomDocument> #include <QDomDocument>
#include <QtTest> #include <QtTest>
@ -37,7 +36,8 @@ Q_DECLARE_METATYPE(QDomElement) // Need for testing
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
TST_TSTranslation::TST_TSTranslation(QObject *parent) TST_TSTranslation::TST_TSTranslation(QObject *parent)
: TST_AbstractTranslation(parent) : TST_AbstractTranslation(parent)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TST_TSTranslation::CheckEnglishLocalization_data() void TST_TSTranslation::CheckEnglishLocalization_data()
@ -78,8 +78,8 @@ void TST_TSTranslation::CheckEnglishLocalization_data()
continue; continue;
} }
const QString caseName = QStringLiteral("File '%1'. Check modification source message '%2'.") const QString caseName =
.arg(fileName, source); QStringLiteral("File '%1'. Check modification source message '%2'.").arg(fileName, source);
QTest::newRow(qUtf8Printable(caseName)) << source << translation; QTest::newRow(qUtf8Printable(caseName)) << source << translation;
} }
else else
@ -166,8 +166,8 @@ void TST_TSTranslation::CheckEllipsis()
} }
const QString contextName = context.firstChildElement(TagName).text(); const QString contextName = context.firstChildElement(TagName).text();
const QString error = QString("String '%1' ends with '...' in context '%2'. Repalce it with '…'.") const QString error =
.arg(source, contextName); QString("String '%1' ends with '...' in context '%2'. Repalce it with '…'.").arg(source, contextName);
QFAIL(qUtf8Printable(error)); QFAIL(qUtf8Printable(error));
} }
} }
@ -224,7 +224,8 @@ void TST_TSTranslation::PrepareOriginalStrings()
continue; continue;
} }
const QString tag = QStringLiteral("File '%1'. Check modification source message '%2'.").arg(fileName, source); const QString tag =
QStringLiteral("File '%1'. Check modification source message '%2'.").arg(fileName, source);
QTest::newRow(qUtf8Printable(tag)) << source << message; QTest::newRow(qUtf8Printable(tag)) << source << message;
} }
else else