diff --git a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp index 3e4232387..3cbfa578d 100644 --- a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp +++ b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp @@ -27,12 +27,13 @@ *************************************************************************/ #include "vabstractlayoutdialog.h" -#include "../vmisc/vabstractapplication.h" +#include "../vmisc/def.h" #include "../vmisc/vmath.h" -//must be the same order as PaperSizeTemplate constants -const VAbstractLayoutDialog::FormatsVector VAbstractLayoutDialog::pageFormatNames -{ +#include + +// must be the same order as PaperSizeTemplate constants +const VAbstractLayoutDialog::FormatsVector VAbstractLayoutDialog::pageFormatNames{ QStringLiteral("A0"), QStringLiteral("A1"), QStringLiteral("A2"), @@ -49,13 +50,13 @@ const VAbstractLayoutDialog::FormatsVector VAbstractLayoutDialog::pageFormatName QApplication::translate("VAbstractLayoutDialog", "Roll 48in", "Paper format"), QApplication::translate("VAbstractLayoutDialog", "Roll 62in", "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) - : QDialog(parent) -{} + : QDialog(parent) +{ +} //--------------------------------------------------------------------------------------------------------------------- void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates) @@ -66,19 +67,19 @@ void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates) const QString pdi = QStringLiteral("(%1ppi)").arg(PrintDPI); auto cntr = static_cast(PaperSizeTemplate::A0); - for(const auto& v : pageFormatNames) + for (const auto &v : pageFormatNames) { if (cntr <= static_cast(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(PaperSizeTemplate::Roll72in)) { - comboBoxTemplates->addItem(icoRoll, v+QChar(QChar::Space)+pdi, QVariant(cntr++)); + comboBoxTemplates->addItem(icoRoll, v + QChar(QChar::Space) + pdi, QVariant(cntr++)); } else { - comboBoxTemplates->addItem(v+QChar(QChar::Space)+pdi, QVariant(cntr++)); + comboBoxTemplates->addItem(v + QChar(QChar::Space) + pdi, QVariant(cntr++)); } } comboBoxTemplates->setCurrentIndex(-1); diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index e1e058c04..e579b6e5f 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -36,17 +36,17 @@ #include #include "../ifc/ifcdef.h" +#include "../qmuparser/qmudef.h" #include "../qmuparser/qmuparsererror.h" #include "../qmuparser/qmutokenparser.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 "vtranslatemeasurements.h" +#include "../vmisc/def.h" +#include "../vmisc/literals.h" +#include "../vmisc/vabstractapplication.h" +#include "../vpatterndb/vtranslatevars.h" #include "pmsystems.h" +#include "vtranslatemeasurements.h" //--------------------------------------------------------------------------------------------------------------------- VTranslateVars::VTranslateVars() @@ -63,8 +63,8 @@ VTranslateVars::VTranslateVars() //--------------------------------------------------------------------------------------------------------------------- void VTranslateVars::InitPatternMakingSystems() { - //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. + // 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. qmu::QmuTranslation name; qmu::QmuTranslation author; qmu::QmuTranslation book; @@ -203,8 +203,10 @@ void VTranslateVars::InitPatternMakingSystems() //================================================================================================================= name = translate("VTranslateVars", "Fukomoto", "System name"); author = translate("VTranslateVars", "Sue S. Fukomoto", "Author name"); - book = translate("VTranslateVars", "Scientific Pattern Drafting as taught at Style Center School of Costume " - "Design, Dressmaking and Millinery", "Book name"); + book = translate("VTranslateVars", + "Scientific Pattern Drafting as taught at Style Center School of Costume " + "Design, Dressmaking and Millinery", + "Book name"); InitSystem(p26_S, name, author, book); //================================================================================================================= name = translate("VTranslateVars", "Dressmaking International", "System name"); @@ -266,8 +268,10 @@ void VTranslateVars::InitPatternMakingSystems() //================================================================================================================= name = translate("VTranslateVars", "Supreme System", "System 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 " - "Producing Mens Garments (1907)", "Book name"); + book = translate("VTranslateVars", + "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); //================================================================================================================= name = translate("VTranslateVars", "Sugino", "System name"); @@ -328,8 +332,10 @@ void VTranslateVars::InitPatternMakingSystems() //================================================================================================================= name = translate("VTranslateVars", "Mitchell", "System 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 " - "Garment Cutting", "Book name"); + book = translate("VTranslateVars", + "\"Standard\" Work on Cutting (Men's Garments) 1886: The Art and Science of " + "Garment Cutting", + "Book name"); InitSystem(p50_S, name, author, book); //================================================================================================================= name = translate("VTranslateVars", "GOST 17917-86", "System name"); @@ -344,8 +350,10 @@ void VTranslateVars::InitPatternMakingSystems() //================================================================================================================= name = translate("VTranslateVars", "Knowles/Women", "System name"); author = translate("VTranslateVars", "Lori A. Knowles", "Author name"); - book = translate("VTranslateVars", "Practical Guide to Patternmaking for Fashion Designers: Juniors, Misses, and " - "Women", "Book name"); + book = translate("VTranslateVars", + "Practical Guide to Patternmaking for Fashion Designers: Juniors, Misses, and " + "Women", + "Book name"); InitSystem(p53_S, name, author, book); //================================================================================================================= 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(angle1Spl_, translate("VTranslateVars", "Angle1Spl_", "Left symbol _ in the name")); variables.insert(angle2Spl_, translate("VTranslateVars", "Angle2Spl_", "Left symbol _ in the name")); - variables.insert(angle1SplPath, translate("VTranslateVars", "Angle1SplPath", - "Do not add symbol _ to the end of the name")); - variables.insert(angle2SplPath, translate("VTranslateVars", "Angle2SplPath", - "Do not add symbol _ to the end of the name")); + variables.insert(angle1SplPath, + translate("VTranslateVars", "Angle1SplPath", "Do not add symbol _ to the end of the name")); + variables.insert(angle2SplPath, + 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(currentLength, translate("VTranslateVars", "CurrentLength", "Do not add space between words")); - variables.insert(currentSeamAllowance, translate("VTranslateVars", "CurrentSeamAllowance", - "Do not add space between words")); + variables.insert(currentSeamAllowance, + translate("VTranslateVars", "CurrentSeamAllowance", "Do not add space between words")); variables.insert(c1LengthSpl_, translate("VTranslateVars", "C1LengthSpl_", "Left symbol _ in the name")); variables.insert(c2LengthSpl_, translate("VTranslateVars", "C2LengthSpl_", "Left symbol _ in the name")); - variables.insert(c1LengthSplPath, translate("VTranslateVars", "C1LengthSplPath", - "Do not add symbol _ to the end of the name")); - variables.insert(c2LengthSplPath, translate("VTranslateVars", "C2LengthSplPath", - "Do not add symbol _ to the end of the name")); + variables.insert(c1LengthSplPath, + translate("VTranslateVars", "C1LengthSplPath", "Do not add symbol _ to the end of the name")); + variables.insert(c2LengthSplPath, + 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(pieceArea_, translate("VTranslateVars", "PieceArea_", "Left symbol _ in the name")); - variables.insert(pieceSeamLineArea_, translate("VTranslateVars", "PieceSeamLineArea_", - "Left symbol _ in the name")); + variables.insert(pieceSeamLineArea_, + translate("VTranslateVars", "PieceSeamLineArea_", "Left symbol _ in the name")); } //--------------------------------------------------------------------------------------------------------------------- @@ -408,43 +416,43 @@ void VTranslateVars::InitFunctions() const QString threeArguments = QStringLiteral("(;;)"); functions.insert(degTorad_F, translate("VTranslateVars", "degTorad", "converts degrees to radian")); - functionsDescriptions.insert(degTorad_F, translate("VTranslateVars", "converts degrees to radian", - "function degTorad")); + functionsDescriptions.insert(degTorad_F, + translate("VTranslateVars", "converts degrees to radian", "function degTorad")); functionsArguments.insert(degTorad_F, oneArgument); functions.insert(radTodeg_F, translate("VTranslateVars", "radTodeg", "converts radian to degrees")); - functionsDescriptions.insert(radTodeg_F, translate("VTranslateVars", "converts radian to degrees", - "function radTodeg")); + functionsDescriptions.insert(radTodeg_F, + translate("VTranslateVars", "converts radian to degrees", "function radTodeg")); functionsArguments.insert(radTodeg_F, oneArgument); functions.insert(sin_F, translate("VTranslateVars", "sin", "sine function working with radians")); - functionsDescriptions.insert(sin_F, translate("VTranslateVars", "sine function working with radians", - "function sin")); + functionsDescriptions.insert(sin_F, + translate("VTranslateVars", "sine function working with radians", "function sin")); functionsArguments.insert(sin_F, oneArgument); functions.insert(cos_F, translate("VTranslateVars", "cos", "cosine function working with radians")); - functionsDescriptions.insert(cos_F, translate("VTranslateVars", "cosine function working with radians", - "function cos")); + functionsDescriptions.insert(cos_F, + translate("VTranslateVars", "cosine function working with radians", "function cos")); functionsArguments.insert(cos_F, oneArgument); functions.insert(tan_F, translate("VTranslateVars", "tan", "tangens function working with radians")); - functionsDescriptions.insert(tan_F, translate("VTranslateVars", "tangens function working with radians", - "function tan")); + functionsDescriptions.insert(tan_F, + translate("VTranslateVars", "tangens function working with radians", "function tan")); functionsArguments.insert(tan_F, oneArgument); 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", - "function asin")); + functionsDescriptions.insert( + asin_F, translate("VTranslateVars", "arcus sine function working with radians", "function asin")); functionsArguments.insert(asin_F, oneArgument); 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", - "function acos")); + functionsDescriptions.insert( + acos_F, translate("VTranslateVars", "arcus cosine function working with radians", "function acos")); functionsArguments.insert(acos_F, oneArgument); 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", - "function atan")); + functionsDescriptions.insert( + atan_F, translate("VTranslateVars", "arcus tangens function working with radians", "function atan")); functionsArguments.insert(atan_F, oneArgument); functions.insert(sinh_F, translate("VTranslateVars", "sinh", "hyperbolic sine function")); @@ -460,52 +468,52 @@ void VTranslateVars::InitFunctions() functionsArguments.insert(tanh_F, oneArgument); functions.insert(asinh_F, translate("VTranslateVars", "asinh", "hyperbolic arcus sine function")); - functionsDescriptions.insert(asinh_F, translate("VTranslateVars", "hyperbolic arcus sine function", - "function asinh")); + functionsDescriptions.insert(asinh_F, + translate("VTranslateVars", "hyperbolic arcus sine function", "function asinh")); functionsArguments.insert(asinh_F, oneArgument); functions.insert(acosh_F, translate("VTranslateVars", "acosh", "hyperbolic arcus cosine function")); - functionsDescriptions.insert(acosh_F, translate("VTranslateVars", "hyperbolic arcus cosine function", - "function acosh")); + functionsDescriptions.insert(acosh_F, + translate("VTranslateVars", "hyperbolic arcus cosine function", "function acosh")); functionsArguments.insert(acosh_F, oneArgument); functions.insert(atanh_F, translate("VTranslateVars", "atanh", "hyperbolic arcur tangens function")); - functionsDescriptions.insert(atanh_F, translate("VTranslateVars", "hyperbolic arcur tangens function", - "function atanh")); + functionsDescriptions.insert(atanh_F, + translate("VTranslateVars", "hyperbolic arcur tangens function", "function atanh")); functionsArguments.insert(atanh_F, oneArgument); functions.insert(sinD_F, translate("VTranslateVars", "sinD", "sine function working with degrees")); - functionsDescriptions.insert(sinD_F, translate("VTranslateVars", "sine function working with degrees", - "function sinD")); + functionsDescriptions.insert(sinD_F, + translate("VTranslateVars", "sine function working with degrees", "function sinD")); functionsArguments.insert(sinD_F, oneArgument); functions.insert(cosD_F, translate("VTranslateVars", "cosD", "cosine function working with degrees")); - functionsDescriptions.insert(cosD_F, translate("VTranslateVars", "cosine function working with degrees", - "function cosD")); + functionsDescriptions.insert(cosD_F, + translate("VTranslateVars", "cosine function working with degrees", "function cosD")); functionsArguments.insert(cosD_F, oneArgument); functions.insert(tanD_F, translate("VTranslateVars", "tanD", "tangens function working with degrees")); - functionsDescriptions.insert(tanD_F, translate("VTranslateVars", "tangens function working with degrees", - "function tanD")); + functionsDescriptions.insert(tanD_F, + translate("VTranslateVars", "tangens function working with degrees", "function tanD")); functionsArguments.insert(tanD_F, oneArgument); 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", - "function asinD")); + functionsDescriptions.insert( + asinD_F, translate("VTranslateVars", "arcus sine function working with degrees", "function asinD")); functionsArguments.insert(asinD_F, oneArgument); 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", - "function acosD")); + functionsDescriptions.insert( + acosD_F, translate("VTranslateVars", "arcus cosine function working with degrees", "function acosD")); functionsArguments.insert(acosD_F, oneArgument); 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", - "function atanD")); + functionsDescriptions.insert( + atanD_F, translate("VTranslateVars", "arcus tangens function working with degrees", "function atanD")); functionsArguments.insert(atanD_F, oneArgument); functions.insert(log2_F, translate("VTranslateVars", "log2", "logarithm to the base 2")); - functionsDescriptions.insert(log2_F, translate("VTranslateVars", "logarithm to the base 2", "function log2")); + functionsDescriptions.insert(log2_F, translate("VTranslateVars", "logarithm to the base 2", "function log2")); functionsArguments.insert(log2_F, oneArgument); functions.insert(log10_F, translate("VTranslateVars", "log10", "logarithm to the base 10")); @@ -529,8 +537,8 @@ void VTranslateVars::InitFunctions() functionsArguments.insert(sqrt_F, oneArgument); 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", - "function sign")); + functionsDescriptions.insert(sign_F, + translate("VTranslateVars", "sign function -1 if x<0; 1 if x>0", "function sign")); functionsArguments.insert(sign_F, oneArgument); 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")); functionsArguments.insert(r2cm_F, oneArgument); - functions.insert(csrCm_F, translate("VTranslateVars", "csrCm", "cut, split and rotate modeling operation. Takes" - " cm units.")); - functionsDescriptions.insert(csrCm_F, translate("VTranslateVars", "cut, split and rotate modeling operation. Takes " - "cm units.", "function csrCm")); + functions.insert(csrCm_F, translate("VTranslateVars", "csrCm", + "cut, split and rotate modeling operation. Takes" + " cm units.")); + functionsDescriptions.insert(csrCm_F, translate("VTranslateVars", + "cut, split and rotate modeling operation. Takes " + "cm units.", + "function csrCm")); functionsArguments.insert(csrCm_F, threeArguments); - functions.insert(csrInch_F, translate("VTranslateVars", "csrInch", "cut, split and rotate modeling operation. Takes" - " inch units.")); - functionsDescriptions.insert(csrInch_F, translate("VTranslateVars", "cut, split and rotate modeling operation. " - "Takes inch units.", "function csrInch")); + functions.insert(csrInch_F, translate("VTranslateVars", "csrInch", + "cut, split and rotate modeling operation. Takes" + " inch units.")); + functionsDescriptions.insert(csrInch_F, translate("VTranslateVars", + "cut, split and rotate modeling operation. " + "Takes inch units.", + "function csrInch")); functionsArguments.insert(csrInch_F, threeArguments); functions.insert(abs_F, translate("VTranslateVars", "abs", "absolute value")); @@ -575,14 +589,15 @@ void VTranslateVars::InitFunctions() functions.insert(fmod_F, translate("VTranslateVars", "fmod", "Returns the floating-point remainder of numer/denom (rounded towards zero)")); - functionsDescriptions.insert(fmod_F, translate("VTranslateVars", "Returns the floating-point remainder of " - "numer/denom (rounded towards zero)", - "function fmod")); + functionsDescriptions.insert(fmod_F, translate("VTranslateVars", + "Returns the floating-point remainder of " + "numer/denom (rounded towards zero)", + "function fmod")); functionsArguments.insert(fmod_F, twoArguments); functions.insert(warning_F, translate("VTranslateVars", "warning", "Calculation warning")); - functionsDescriptions.insert(warning_F, translate("VTranslateVars", "Show a warning in calculations", - "function warning")); + functionsDescriptions.insert(warning_F, + translate("VTranslateVars", "Show a warning in calculations", "function warning")); functionsArguments.insert(warning_F, twoArguments); } @@ -630,7 +645,7 @@ void VTranslateVars::CorrectionsPositions(vsizetype position, vsizetype bias, QM { if (bias == 0) { - return;// Nothing to correct; + return; // Nothing to correct; } BiasTokens(position, bias, tokens); @@ -641,7 +656,7 @@ void VTranslateVars::CorrectionsPositions(vsizetype position, vsizetype bias, QM void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap &tokens, QMap &numbers) const { - QList tKeys = tokens.keys();// Take all tokens positions + QList tKeys = tokens.keys(); // Take all tokens positions QList tValues = tokens.values(); for (vsizetype i = 0; i < tKeys.size(); ++i) { @@ -649,7 +664,7 @@ void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap nKeys = numbers.keys();// Positions for all numbers in expression + { // User want use Os separator + QList nKeys = numbers.keys(); // Positions for all numbers in expression QList nValues = numbers.values(); for (int i = 0; i < nKeys.size(); ++i) { - loc = QLocale();// From system locale + loc = QLocale(); // From system locale bool ok = false; const qreal d = loc.toDouble(nValues.at(i), &ok); if (not ok) { - qDebug()<<"Can't convert to double token"<Settings()->GetLocale())); - auto bias = tValues.at(i).length() - - measurements.value(tValues.at(i)) - .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); + newFormula.replace( + tKeys.at(i), tValues.at(i).length(), + measurements.value(tValues.at(i)).translate(VAbstractApplication::VApp()->Settings()->GetLocale())); + auto bias = tValues.at(i).length() - measurements.value(tValues.at(i)) + .translate(VAbstractApplication::VApp()->Settings()->GetLocale()) + .length(); 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); tKeys = tokens.keys(); tValues = tokens.values(); @@ -747,14 +762,14 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMapSettings()->GetLocale())); - auto bias = tValues.at(i).length() - - functions.value(tValues.at(i)) - .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); + newFormula.replace( + tKeys.at(i), tValues.at(i).length(), + functions.value(tValues.at(i)).translate(VAbstractApplication::VApp()->Settings()->GetLocale())); + auto bias = tValues.at(i).length() - functions.value(tValues.at(i)) + .translate(VAbstractApplication::VApp()->Settings()->GetLocale()) + .length(); 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); tKeys = tokens.keys(); tValues = tokens.values(); @@ -766,7 +781,7 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap &tokens, QMap &numbers, bool osSeparator) { - QLocale loc = QLocale();// User locale + QLocale loc = QLocale(); // User locale if (loc != QLocale::C && osSeparator) - {// User want use Os separator - QList nKeys = numbers.keys();// Positions for all numbers in expression + { // User want use Os separator + QList nKeys = numbers.keys(); // Positions for all numbers in expression QList nValues = numbers.values(); for (int i = 0; i < nKeys.size(); ++i) { - loc = QLocale::c();// From pattern locale + loc = QLocale::c(); // From pattern locale bool ok = false; const qreal d = loc.toDouble(nValues.at(i), &ok); if (not ok) { - qDebug()<<"Can't convert to double token"<::const_iterator i = tokens.constBegin(); while (i != tokens.constEnd()) { - if (i.key()<= position) + if (i.key() <= position) { // Tokens before position "position" did not change his positions. newTokens.insert(i.key(), i.value()); } else { - newTokens.insert(i.key()-bias, i.value()); + newTokens.insert(i.key() - bias, i.value()); } ++i; } tokens = newTokens; } - - //--------------------------------------------------------------------------------------------------------------------- /** * @brief VariablesFromUser translate variable to internal look. @@ -860,9 +873,9 @@ auto VTranslateVars::VariablesFromUser(QString &newFormula, vsizetype position, vsizetype &bias) const -> bool { const QString currentLengthTr = - variables.value(currentLength).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); - const QString currentSeamAllowanceTr = variables.value(currentSeamAllowance) - .translate(VAbstractApplication::VApp()->Settings()->GetLocale()); + variables.value(currentLength).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); + const QString currentSeamAllowanceTr = + variables.value(currentSeamAllowance).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); QMap::const_iterator i = variables.constBegin(); while (i != variables.constEnd()) @@ -930,7 +943,7 @@ auto VTranslateVars::VariablesToUser(QString &newFormula, vsizetype position, co QMap::const_iterator i = variables.constBegin(); 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()) { @@ -1049,11 +1062,11 @@ auto VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator) c // Eval formula QScopedPointer cal( new qmu::QmuTokenParser(formula, osSeparator, true, GetTranslatedFunctions())); - QMap tokens = cal->GetTokens();// Tokens (variables, measurements) - QMap numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator + QMap tokens = cal->GetTokens(); // Tokens (variables, measurements) + QMap numbers = cal->GetNumbers(); // All numbers in expression for changing decimal separator cal.reset(); - QString newFormula = formula;// Local copy for making changes + QString newFormula = formula; // Local copy for making changes TranslateVarsFromUser(newFormula, tokens, numbers); TranslateNumbersFromUser(newFormula, tokens, numbers, osSeparator); @@ -1069,7 +1082,7 @@ auto VTranslateVars::TryFormulaFromUser(const QString &formula, bool osSeparator SCASSERT(VAbstractApplication::VApp()->TrVars() != nullptr) 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) return formula; @@ -1090,21 +1103,21 @@ auto VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator) con return formula; } - QString newFormula = formula;// Local copy for making changes + QString newFormula = formula; // Local copy for making changes QMap tokens; QMap numbers; try { - QScopedPointer cal(new qmu::QmuTokenParser(formula, false, false));// Eval formula - tokens = cal->GetTokens();// Tokens (variables, measurements) - numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator + QScopedPointer cal(new qmu::QmuTokenParser(formula, false, false)); // Eval formula + tokens = cal->GetTokens(); // Tokens (variables, measurements) + numbers = cal->GetNumbers(); // All numbers in expression for changing decimal separator } catch (qmu::QmuParserError &e) { qDebug() << "\nMath parser error:\n" << "--------------------------------------\n" - << "Message: " << e.GetMsg() << "\n" + << "Message: " << e.GetMsg() << "\n" << "Expression: " << e.GetExpr() << "\n" << "--------------------------------------"; return newFormula; @@ -1123,7 +1136,7 @@ auto VTranslateVars::TryFormulaToUser(const QString &formula, bool 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) return formula; diff --git a/src/libs/vtest/abstracttest.h b/src/libs/vtest/abstracttest.h index 65204b65a..40b457a27 100644 --- a/src/libs/vtest/abstracttest.h +++ b/src/libs/vtest/abstracttest.h @@ -29,38 +29,44 @@ #ifndef ABSTRACTTEST_H #define ABSTRACTTEST_H +#include +#include +#include #include #include #include -#include -#include -#include +#include #include #include -#include -#include "../vgeometry/vpointf.h" -#include "../vlayout/vsapoint.h" -#include "../vlayout/vrawsapoint.h" #include "../ifc/exception/vexception.h" +#include "../vgeometry/vpointf.h" +#include "../vlayout/vrawsapoint.h" +#include "../vlayout/vsapoint.h" #include #ifdef __GNUC__ -#define V_UNUSED __attribute__ ((unused)) +#define V_UNUSED __attribute__((unused)) #else #define V_UNUSED #endif // Return codes for testing run application -static const auto V_UNUSED TST_EX_BIN = -1; // Can't find binary. +static const auto V_UNUSED TST_EX_BIN = -1; // Can't find binary. static const auto V_UNUSED TST_EX_FINISH_TIME_OUT = -2; // The operation timed out or an error occurred. -static const auto V_UNUSED TST_EX_START_TIME_OUT = -3; // The operation timed out or an error occurred. -static const auto V_UNUSED TST_EX_CRASH = -4; // Program crashed. +static const auto V_UNUSED TST_EX_START_TIME_OUT = -3; // The operation timed out or an error occurred. +static const auto V_UNUSED TST_EX_CRASH = -4; // Program crashed. #undef V_UNUSED -enum ErrorState {ErrorLoad = 0, ErrorInstall, ErrorSize, NoError}; +enum ErrorState +{ + ErrorLoad = 0, + ErrorInstall, + ErrorSize, + NoError +}; class VPiece; class VContainer; @@ -74,15 +80,13 @@ class VRawSAPoint; class AbstractTest : public QObject { Q_OBJECT // NOLINT -public: - explicit AbstractTest(QObject *parent = nullptr); + public : explicit AbstractTest(QObject *parent = nullptr); - template - static auto VectorFromJson(const QString &json) -> QVector; + template static auto VectorFromJson(const QString &json) -> QVector; void PieceFromJson(const QString &json, VPiece &piece, QSharedPointer &data); - void PassmarkDataFromJson(const QString &json, VPiecePassmarkData& data); + void PassmarkDataFromJson(const QString &json, VPiecePassmarkData &data); void PassmarkShapeFromJson(const QString &json, QVector &shape); protected: @@ -104,15 +108,15 @@ protected: static void PrepareDocument(const QString &json, QByteArray &data); static void TestRoot(const QJsonObject &root, const QString &attribute, const QString &file); - template ::value>::type* = nullptr> + template ::value>::type * = nullptr> static void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value, const QString &defaultValue = QString()); - template ::value>::type* = nullptr> + template ::value>::type * = nullptr> static void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value, const QString &defaultValue = QString()); - template ::value>::type* = nullptr> + template ::value>::type * = nullptr> 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, const QString &defaultValue = QString()); static void ReadBooleanValue(const QJsonObject &itemObject, const QString &attribute, bool &value, @@ -122,14 +126,11 @@ protected: void ReadSplinePointValue(const QJsonObject &itemObject, VSplinePoint &point); void ReadPieceNodeValue(const QJsonObject &itemObject, VPieceNode &node); - template - static void CheckClassType(const QJsonObject &itemObject); + template static void CheckClassType(const QJsonObject &itemObject); - template - static auto ReadPointData(const QJsonObject &pointObject) -> T; + template static auto ReadPointData(const QJsonObject &pointObject) -> T; - template - static auto PointFromJson(const QJsonObject &pointObject, T &point) -> void; + template static auto PointFromJson(const QJsonObject &pointObject, T &point) -> void; auto QLineFromJson(const QJsonObject &itemObject) -> QLineF; void SplineFromJson(const QJsonObject &itemObject, QSharedPointer &data); @@ -140,8 +141,7 @@ protected: }; //--------------------------------------------------------------------------------------------------------------------- -template -inline auto AbstractTest::VectorFromJson(const QString &json) -> QVector +template inline auto AbstractTest::VectorFromJson(const QString &json) -> QVector { QByteArray saveData; PrepareDocument(json, saveData); @@ -174,16 +174,14 @@ inline auto AbstractTest::VectorFromJson(const QString &json) -> QVector } //--------------------------------------------------------------------------------------------------------------------- -template -inline void AbstractTest::CheckClassType(const QJsonObject &itemObject) +template inline void AbstractTest::CheckClassType(const QJsonObject &itemObject) { const QString typeKey = QStringLiteral("type"); QString type; AbstractTest::ReadStringValue(itemObject, typeKey, type); - const QStringList types - { + const QStringList types{ QStringLiteral("QPointF"), // 0 QStringLiteral("VLayoutPoint"), // 1 QStringLiteral("VRawSAPoint"), // 2 @@ -216,8 +214,7 @@ inline void AbstractTest::CheckClassType(const QJsonObject &itemObject) } //--------------------------------------------------------------------------------------------------------------------- -template -inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> T +template inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> T { T point; qreal x = 0; @@ -232,16 +229,14 @@ inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> T } //--------------------------------------------------------------------------------------------------------------------- -template -inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, T &point) -> void +template inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, T &point) -> void { CheckClassType(pointObject); point = ReadPointData(pointObject); } //--------------------------------------------------------------------------------------------------------------------- -template<> -inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VPointF &point) -> void +template <> inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VPointF &point) -> void { vidtype id = NULL_ID; AbstractTest::ReadDoubleValue(pointObject, QStringLiteral("id"), id); @@ -266,8 +261,7 @@ inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VPointF } //--------------------------------------------------------------------------------------------------------------------- -template<> -inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> VLayoutPoint +template <> inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> VLayoutPoint { VLayoutPoint point(ReadPointData(pointObject)); @@ -283,16 +277,14 @@ inline auto AbstractTest::ReadPointData(const QJsonObject &pointObject) -> VLayo } //--------------------------------------------------------------------------------------------------------------------- -template<> -inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VLayoutPoint &point) -> void +template <> inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VLayoutPoint &point) -> void { CheckClassType(pointObject); point = ReadPointData(pointObject); } //--------------------------------------------------------------------------------------------------------------------- -template<> -inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VSAPoint &point) -> void +template <> inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VSAPoint &point) -> void { CheckClassType(pointObject); @@ -357,8 +349,7 @@ inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VSAPoint } //--------------------------------------------------------------------------------------------------------------------- -template<> -inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VRawSAPoint &point) -> void +template <> inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VRawSAPoint &point) -> void { CheckClassType(pointObject); diff --git a/src/test/TranslationsTest/qttestmainlambda.cpp b/src/test/TranslationsTest/qttestmainlambda.cpp index 1e5b0a421..1de29a34b 100644 --- a/src/test/TranslationsTest/qttestmainlambda.cpp +++ b/src/test/TranslationsTest/qttestmainlambda.cpp @@ -28,21 +28,21 @@ #include -#include "tst_measurementregexp.h" #include "tst_buitinregexp.h" +#include "tst_measurementregexp.h" #include "tst_qmuparsererrormsg.h" -#include "tst_tstranslation.h" #include "tst_tslocaletranslation.h" +#include "tst_tstranslation.h" #include "../vmisc/def.h" #include "../vmisc/testvapplication.h" auto main(int argc, char **argv) -> int { - TestVApplication app( argc, argv );// For QPrinter + TestVApplication app(argc, argv); // For QPrinter 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); delete obj; @@ -51,7 +51,7 @@ auto main(int argc, char **argv) -> int ASSERT_TEST(new TST_TSTranslation()); const QStringList locales = SupportedLocales(); - for(const auto &locale : locales) + for (const auto &locale : locales) { for(quint32 s = 0; s < TST_MeasurementRegExp::systemCounts; ++s) { diff --git a/src/test/TranslationsTest/tst_abstractregexp.cpp b/src/test/TranslationsTest/tst_abstractregexp.cpp index 6591c2eb4..6cbf81a13 100644 --- a/src/test/TranslationsTest/tst_abstractregexp.cpp +++ b/src/test/TranslationsTest/tst_abstractregexp.cpp @@ -29,12 +29,11 @@ #include "tst_abstractregexp.h" #include "../qmuparser/qmudef.h" #include "../qmuparser/qmuformulabase.h" -#include "../vpatterndb/vtranslatevars.h" -#include "../ifc/ifcdef.h" #include "../vmisc/compatibility.h" +#include "../vpatterndb/vtranslatevars.h" -#include #include +#include namespace { @@ -49,7 +48,7 @@ auto PrepareValidNameChars() -> QString //--------------------------------------------------------------------------------------------------------------------- TST_AbstractRegExp::TST_AbstractRegExp(const QString &locale, QObject *parent) - : AbstractTest(parent), + : AbstractTest(parent), m_locale(locale), m_vTranslator(nullptr), m_trMs(nullptr) @@ -69,10 +68,10 @@ auto TST_AbstractRegExp::LoadVariables(const QString &checkedLocale) -> int const QString path = TranslationsPath(); 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") - .arg(checkedLocale, path, file); + .arg(checkedLocale, path, file); QWARN(qUtf8Printable(message)); return ErrorSize; @@ -83,7 +82,7 @@ auto TST_AbstractRegExp::LoadVariables(const QString &checkedLocale) -> int if (not m_vTranslator->load(file, path)) { const QString message = QString("Can't load translation variables for locale = %1. \nFull path: %2/%3") - .arg(checkedLocale, path, file); + .arg(checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete m_vTranslator; @@ -94,7 +93,7 @@ auto TST_AbstractRegExp::LoadVariables(const QString &checkedLocale) -> int if (not QCoreApplication::installTranslator(m_vTranslator)) { const QString message = QString("Can't install translation variables for locale = %1. \nFull path: %2/%3") - .arg(checkedLocale, path, file); + .arg(checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete m_vTranslator; @@ -114,8 +113,7 @@ void TST_AbstractRegExp::RemoveTrVariables(const QString &checkedLocale) if (result == false) { - const QString message = QString("Can't remove translation variables for locale = %1") - .arg(checkedLocale); + const QString message = QString("Can't remove translation variables for locale = %1").arg(checkedLocale); QWARN(qUtf8Printable(message)); } delete m_vTranslator; @@ -143,8 +141,7 @@ void TST_AbstractRegExp::CallTestCheckNoEndLine() const QString translated = m_trMs->VarToUser(originalName); if (translated.endsWith(QLatin1String("\n"))) { - const QString message = QString("Translated string '%1' shouldn't contain new line character.") - .arg(translated); + const QString message = QString("Translated string '%1' shouldn't contain new line character.").arg(translated); QFAIL(qUtf8Printable(message)); } } @@ -178,7 +175,7 @@ void TST_AbstractRegExp::CallTestCheckNoOriginalNamesInTranslation() { const QString message = QString("Translation repeat original name from other place. " "Original name:'%1', translated name:'%2'") - .arg(originalName, translated); + .arg(originalName, translated); QFAIL(qUtf8Printable(message)); } } @@ -193,8 +190,8 @@ void TST_AbstractRegExp::CallTestForValidCharacters() 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") - .arg(QLocale().name()); + const QString message = + QStringLiteral("We do not support translation of variables for locale %1").arg(QLocale().name()); QSKIP(qUtf8Printable(message)); } @@ -203,7 +200,10 @@ void TST_AbstractRegExp::CallTestForValidCharacters() if (pos != -1) { 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)); } } diff --git a/src/test/TranslationsTest/tst_measurementregexp.cpp b/src/test/TranslationsTest/tst_measurementregexp.cpp index a3411af71..2764c6dee 100644 --- a/src/test/TranslationsTest/tst_measurementregexp.cpp +++ b/src/test/TranslationsTest/tst_measurementregexp.cpp @@ -27,13 +27,11 @@ *************************************************************************/ #include "tst_measurementregexp.h" -#include "../qmuparser/qmudef.h" -#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/measurements.h" -#include "../ifc/ifcdef.h" +#include "../vpatterndb/vtranslatevars.h" +#include "abstracttest.h" -#include #include const quint32 TST_MeasurementRegExp::systemCounts = 56; // count of pattern making systems @@ -93,7 +91,7 @@ void TST_MeasurementRegExp::initTestCase() QLocale::setDefault(QLocale(m_locale)); - InitTrMs();//Very important do this after loading QM files. + InitTrMs(); // Very important do this after loading QM files. } //--------------------------------------------------------------------------------------------------------------------- @@ -157,7 +155,7 @@ void TST_MeasurementRegExp::TestCheckIsNamesUnique() if (originalNames.size() > 1) { const QString message = QString("Name is not unique. Translated name:'%1' also assosiated with: %2.") - .arg(translatedName, originalNames.join(", ")); + .arg(translatedName, originalNames.join(", ")); QFAIL(qUtf8Printable(message)); } } @@ -202,8 +200,8 @@ void TST_MeasurementRegExp::TestCombinations(int systemCounts, const QStringList const QStringList fileNames = dir.entryList(QStringList("measurements_p*_*.qm")); // cppcheck-suppress unreadVariable - const QString error = QString("Unexpected count of files. Excpected %1, got %2.") - .arg(combinations).arg(fileNames.size()); + const QString error = + QString("Unexpected count of files. Excpected %1, got %2.").arg(combinations).arg(fileNames.size()); QVERIFY2(combinations == fileNames.size(), qUtf8Printable(error)); } @@ -233,10 +231,10 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const const QString path = TranslationsPath(); 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") - .arg(checkedSystem, checkedLocale, path, file); + .arg(checkedSystem, checkedLocale, path, file); QWARN(qUtf8Printable(message)); return ErrorSize; @@ -248,7 +246,7 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const if (not m_pmsTranslator->load(file, path)) { const QString message = QString("Can't load translation for system = %1 and locale = %2. \nFull path: %3/%4") - .arg(checkedSystem, checkedLocale, path, file); + .arg(checkedSystem, checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete m_pmsTranslator; @@ -259,7 +257,7 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const if (not QCoreApplication::installTranslator(m_pmsTranslator)) { const QString message = QString("Can't install translation for system = %1 and locale = %2. \nFull path: %3/%4") - .arg(checkedSystem, checkedLocale, path, file); + .arg(checkedSystem, checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete m_pmsTranslator; @@ -279,8 +277,8 @@ void TST_MeasurementRegExp::RemoveTrMeasurements(const QString &checkedSystem, c if (result == false) { - const QString message = QString("Can't remove translation for system = %1 and locale = %2") - .arg(checkedSystem, checkedLocale); + const QString message = + QString("Can't remove translation for system = %1 and locale = %2").arg(checkedSystem, checkedLocale); QWARN(qUtf8Printable(message)); } delete m_pmsTranslator; diff --git a/src/test/TranslationsTest/tst_measurementregexp.h b/src/test/TranslationsTest/tst_measurementregexp.h index 77b681f11..0d87ace56 100644 --- a/src/test/TranslationsTest/tst_measurementregexp.h +++ b/src/test/TranslationsTest/tst_measurementregexp.h @@ -29,8 +29,8 @@ #ifndef TST_MEASUREMENTREGEXP_H #define TST_MEASUREMENTREGEXP_H -#include "tst_abstractregexp.h" #include "../vmisc/defglobal.h" +#include "tst_abstractregexp.h" #include @@ -72,10 +72,10 @@ private: QString m_system; QPointer 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; - void RemoveTrMeasurements(const QString &checkedSystem, const QString &checkedLocale); + void RemoveTrMeasurements(const QString &checkedSystem, const QString &checkedLocale); }; #endif // TST_MEASUREMENTREGEXP_H diff --git a/src/test/TranslationsTest/tst_tslocaletranslation.cpp b/src/test/TranslationsTest/tst_tslocaletranslation.cpp index 9e505163c..bfb8a0807 100644 --- a/src/test/TranslationsTest/tst_tslocaletranslation.cpp +++ b/src/test/TranslationsTest/tst_tslocaletranslation.cpp @@ -36,9 +36,10 @@ Q_DECLARE_METATYPE(Qt::LayoutDirection) //--------------------------------------------------------------------------------------------------------------------- TST_TSLocaleTranslation::TST_TSLocaleTranslation(const QString &locale, QObject *parent) - : TST_AbstractTranslation(parent), - m_locale(locale) -{} + : TST_AbstractTranslation(parent), + m_locale(locale) +{ +} //--------------------------------------------------------------------------------------------------------------------- void TST_TSLocaleTranslation::CheckPlaceMarkerExist_data() @@ -82,8 +83,8 @@ void TST_TSLocaleTranslation::CheckPlaceMarkerExist_data() continue; } - const QString caseName = QStringLiteral("File '%1'. Check place holder source message '%2'") - .arg(filename, source); + const QString caseName = + QStringLiteral("File '%1'. Check place holder source message '%2'").arg(filename, source); QTest::newRow(qUtf8Printable(caseName)) << source << translation << locale.textDirection(); } else @@ -116,9 +117,8 @@ void TST_TSLocaleTranslation::CheckPlaceMarkerExist() ++sourceMarkCount; if (sourceMarkCount != i) { - const QString message = QString("In source string '%1' was missed place marker ") - .arg(source) + QLatin1String("'%") + QString().setNum(sourceMarkCount) + - QLatin1String("'."); + const QString message = QString("In source string '%1' was missed place marker ").arg(source) + + QLatin1String("'%") + QString().setNum(sourceMarkCount) + QLatin1String("'."); QFAIL(qUtf8Printable(message)); } } @@ -129,9 +129,9 @@ void TST_TSLocaleTranslation::CheckPlaceMarkerExist() ++translationMarkCount; if (translationMarkCount != i) { - const QString message = QString("In translation string '%1' was missed place marker ") - .arg(translation) + QLatin1String("'%") + QString().setNum(translationMarkCount) + - QLatin1String("'."); + const QString message = + QString("In translation string '%1' was missed place marker ").arg(translation) + + QLatin1String("'%") + QString().setNum(translationMarkCount) + QLatin1String("'."); QFAIL(qUtf8Printable(message)); } } @@ -207,26 +207,19 @@ void TST_TSLocaleTranslation::TestPunctuation() QFETCH(QString, translation); static const QStringList punctuation{ - QChar('.'), - QChar(':'), - QChar(QChar::Space), - QChar('\n'), - QChar('!'), - QChar('?'), - QChar(';'), - QChar(0x2026)//… + QChar('.'), QChar(':'), QChar(QChar::Space), QChar('\n'), QChar('!'), QChar('?'), QChar(';'), + QChar(0x2026) // … }; - if (QLocale(locale).textDirection() != Qt::LeftToRight) { QSKIP("Not supported text direction"); } bool testFail = false; - const QChar cSource = source.at(source.length()-1); + const QChar cSource = source.at(source.length() - 1); QChar cPunctuation = cSource; - const QChar cTranslation = translation.at(translation.length()-1); + const QChar cTranslation = translation.at(translation.length() - 1); if (punctuation.contains(cSource)) { if (not translation.endsWith(cSource)) @@ -234,9 +227,9 @@ void TST_TSLocaleTranslation::TestPunctuation() testFail = true; if (locale == QLatin1String("el_GR") - // Greek question mark - // https://en.wikipedia.org/wiki/Question_mark#Greek_question_mark - && (cSource == QLatin1Char('?') && cTranslation == QLatin1Char(';'))) + // Greek question mark + // https://en.wikipedia.org/wiki/Question_mark#Greek_question_mark + && (cSource == QLatin1Char('?') && cTranslation == QLatin1Char(';'))) { testFail = false; } @@ -261,8 +254,10 @@ void TST_TSLocaleTranslation::TestPunctuation() if (testFail) { 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) + - QString(", translated name:'%1'").arg(translation); + "vice versa. ") + .arg(cPunctuation) + + QString("Original name:'%1'").arg(source) + + QString(", translated name:'%1'").arg(translation); QFAIL(qUtf8Printable(message)); } } @@ -324,9 +319,8 @@ void TST_TSLocaleTranslation::TestHTMLTags() QFETCH(QString, source); QFETCH(QString, translation); - static const QStringList tags = QStringList() << QLatin1String("p") - << QLatin1String("html") - << QLatin1String("body"); + static const QStringList tags = QStringList() + << QLatin1String("p") << QLatin1String("html") << QLatin1String("body"); static const QString pattern("{1}.*>"); for (const auto &tag : tags) { @@ -341,7 +335,8 @@ void TST_TSLocaleTranslation::TestHTMLTags() if (not translation.contains(closeRegex) || countCloseTag != countOpenTag) { 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)); } } diff --git a/src/test/TranslationsTest/tst_tstranslation.cpp b/src/test/TranslationsTest/tst_tstranslation.cpp index 00193bcbb..85d3971b0 100644 --- a/src/test/TranslationsTest/tst_tstranslation.cpp +++ b/src/test/TranslationsTest/tst_tstranslation.cpp @@ -27,7 +27,6 @@ *************************************************************************/ #include "tst_tstranslation.h" -#include "../vmisc/def.h" #include #include @@ -36,8 +35,9 @@ Q_DECLARE_METATYPE(QDomElement) // Need for testing //--------------------------------------------------------------------------------------------------------------------- TST_TSTranslation::TST_TSTranslation(QObject *parent) - : TST_AbstractTranslation(parent) -{} + : TST_AbstractTranslation(parent) +{ +} //--------------------------------------------------------------------------------------------------------------------- void TST_TSTranslation::CheckEnglishLocalization_data() @@ -78,8 +78,8 @@ void TST_TSTranslation::CheckEnglishLocalization_data() continue; } - const QString caseName = QStringLiteral("File '%1'. Check modification source message '%2'.") - .arg(fileName, source); + const QString caseName = + QStringLiteral("File '%1'. Check modification source message '%2'.").arg(fileName, source); QTest::newRow(qUtf8Printable(caseName)) << source << translation; } else @@ -166,8 +166,8 @@ void TST_TSTranslation::CheckEllipsis() } const QString contextName = context.firstChildElement(TagName).text(); - const QString error = QString("String '%1' ends with '...' in context '%2'. Repalce it with '…'.") - .arg(source, contextName); + const QString error = + QString("String '%1' ends with '...' in context '%2'. Repalce it with '…'.").arg(source, contextName); QFAIL(qUtf8Printable(error)); } } @@ -224,7 +224,8 @@ void TST_TSTranslation::PrepareOriginalStrings() 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; } else