From 3252130f364bc98faf823535bb77d28a218be6dd Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 2 Apr 2018 20:38:56 +0300 Subject: [PATCH] Refactoring. Use C++11 range-based loop. --HG-- branch : develop --- src/app/tape/tmainwindow.cpp | 30 +++++++++---------- .../valentina/dialogs/dialogincrements.cpp | 7 ++--- .../dialogs/dialoglayoutsettings.cpp | 4 +-- .../dialogs/dialogpatternmaterials.cpp | 6 ++-- src/libs/qmuparser/qmudef.cpp | 18 +++++------ src/libs/vdxf/vdxfengine.cpp | 11 +++---- src/libs/vgeometry/vcubicbezierpath.cpp | 12 ++++---- src/libs/vlayout/vlayoutpiece.cpp | 9 +++--- src/libs/vpatterndb/vcontainer.cpp | 6 ++-- src/libs/vpatterndb/vpiece.cpp | 4 +-- src/libs/vpatterndb/vpiecepath.cpp | 8 ++--- src/libs/vtools/tools/vabstracttool.cpp | 8 ++--- src/libs/vtools/tools/vtoolseamallowance.cpp | 27 ++++++++--------- src/libs/vtools/tools/vtooluniondetails.cpp | 28 +++++++++-------- src/test/ValentinaTest/tst_nameregexp.cpp | 6 ++-- src/test/ValentinaTest/tst_qmutokenparser.cpp | 3 +- src/test/ValentinaTest/tst_readval.cpp | 3 +- src/test/ValentinaTest/tst_vtranslatevars.cpp | 12 ++++---- 18 files changed, 99 insertions(+), 103 deletions(-) diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index a32825a03..d529556ef 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -3207,18 +3207,18 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv) } } - for(int i=0; i < measurements.size(); ++i) + for(auto im : qAsConst(measurements)) { - m->AddEmpty(measurements.at(i).name, measurements.at(i).value); + m->AddEmpty(im.name, im.value); - if (not measurements.at(i).fullName.isEmpty()) + if (not im.fullName.isEmpty()) { - m->SetMFullName(measurements.at(i).name, measurements.at(i).fullName); + m->SetMFullName(im.name, im.fullName); } - if (not measurements.at(i).description.isEmpty()) + if (not im.description.isEmpty()) { - m->SetMDescription(measurements.at(i).name, measurements.at(i).description); + m->SetMDescription(im.name, im.description); } } @@ -3317,21 +3317,21 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv) } } - for(int i=0; i < measurements.size(); ++i) + for(auto mm : qAsConst(measurements)) { - m->AddEmpty(measurements.at(i).name); - m->SetMBaseValue(measurements.at(i).name, measurements.at(i).base); - m->SetMSizeIncrease(measurements.at(i).name, measurements.at(i).sizeIncrease); - m->SetMHeightIncrease(measurements.at(i).name, measurements.at(i).heightIncrease); + m->AddEmpty(mm.name); + m->SetMBaseValue(mm.name, mm.base); + m->SetMSizeIncrease(mm.name, mm.sizeIncrease); + m->SetMHeightIncrease(mm.name, mm.heightIncrease); - if (not measurements.at(i).fullName.isEmpty()) + if (not mm.fullName.isEmpty()) { - m->SetMFullName(measurements.at(i).name, measurements.at(i).fullName); + m->SetMFullName(mm.name, mm.fullName); } - if (not measurements.at(i).description.isEmpty()) + if (not mm.description.isEmpty()) { - m->SetMDescription(measurements.at(i).name, measurements.at(i).description); + m->SetMDescription(mm.name, mm.description); } } diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index e388b0946..d623a1cec 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -585,15 +585,14 @@ bool DialogIncrements::IncrementUsed(const QString &name) const { const QVector expressions = doc->ListExpressions(); - for(int i = 0; i < expressions.size(); ++i) + for(auto field : expressions) { - if (expressions.at(i).expression.indexOf(name) != -1) + if (field.expression.indexOf(name) != -1) { // Eval formula try { - QScopedPointer cal(new qmu::QmuTokenParser(expressions.at(i).expression, false, - false)); + QScopedPointer cal(new qmu::QmuTokenParser(field.expression, false, false)); // Tokens (variables, measurements) if (cal->GetTokens().values().contains(name)) diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 95fd20c3d..6324c1572 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -746,9 +746,9 @@ void DialogLayoutSettings::InitPrinter() QStringList printerNames; #if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) const QList printers = QPrinterInfo::availablePrinters(); - for(int i = 0; i < printers.size(); ++i) + for(auto printer : printers) { - const QString name = printers.at(i).printerName(); + const QString name = printer.printerName(); if (not name.isEmpty()) { printerNames.append(name); diff --git a/src/app/valentina/dialogs/dialogpatternmaterials.cpp b/src/app/valentina/dialogs/dialogpatternmaterials.cpp index 73e9a90fb..3db107744 100644 --- a/src/app/valentina/dialogs/dialogpatternmaterials.cpp +++ b/src/app/valentina/dialogs/dialogpatternmaterials.cpp @@ -44,11 +44,11 @@ QStringList PrepareKnowMaterials(const QStringList &patternMaterials, bool remem if (rememberPM) { - for(int i=0; i < patternMaterials.size(); ++i) + for(auto &patternMaterial : patternMaterials) { - if (not patternMaterials.at(i).isEmpty() && not knownMaterials.contains(patternMaterials.at(i))) + if (not patternMaterial.isEmpty() && not knownMaterials.contains(patternMaterial)) { - knownMaterials.append(patternMaterials.at(i)); + knownMaterials.append(patternMaterial); } } } diff --git a/src/libs/qmuparser/qmudef.cpp b/src/libs/qmuparser/qmudef.cpp index 92eee1476..0233e1d65 100644 --- a/src/libs/qmuparser/qmudef.cpp +++ b/src/libs/qmuparser/qmudef.cpp @@ -292,26 +292,26 @@ QString NameRegExp() QString decimalPoints; QString groupSeparators; - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - if (not positiveSigns.contains(allLocales.at(i).positiveSign())) + if (not positiveSigns.contains(locale.positiveSign())) { - positiveSigns.append(allLocales.at(i).positiveSign()); + positiveSigns.append(locale.positiveSign()); } - if (not negativeSigns.contains(allLocales.at(i).negativeSign())) + if (not negativeSigns.contains(locale.negativeSign())) { - negativeSigns.append(allLocales.at(i).negativeSign()); + negativeSigns.append(locale.negativeSign()); } - if (not decimalPoints.contains(allLocales.at(i).decimalPoint())) + if (not decimalPoints.contains(locale.decimalPoint())) { - decimalPoints.append(allLocales.at(i).decimalPoint()); + decimalPoints.append(locale.decimalPoint()); } - if (not groupSeparators.contains(allLocales.at(i).groupSeparator())) + if (not groupSeparators.contains(locale.groupSeparator())) { - groupSeparators.append(allLocales.at(i).groupSeparator()); + groupSeparators.append(locale.groupSeparator()); } } diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 41b6b5e52..37dc493fa 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -622,10 +622,8 @@ bool VDxfEngine::ExportToAAMA(const QVector &details) ExportAAMAGlobalText(input, details); - for(int i = 0; i < details.size(); ++i) + for(auto &detail : details) { - const VLayoutPiece &detail = details.at(i); - dx_ifaceBlock *detailBlock = new dx_ifaceBlock(); QString blockName = detail.GetName(); @@ -736,11 +734,10 @@ void VDxfEngine::ExportAAMANotch(dx_ifaceBlock *detailBlock, const VLayoutPiece { if (detail.IsSeamAllowance()) { - QVector passmarks = detail.GetPassmarks(); - for(int i = 0; i < passmarks.size(); ++i) + const QVector passmarks = detail.GetPassmarks(); + for(auto passmark : passmarks) { - DRW_Entity *e = AAMALine(passmarks.at(i), "4"); - if (e) + if (DRW_Entity *e = AAMALine(passmark, "4")) { detailBlock->ent.push_back(e); } diff --git a/src/libs/vgeometry/vcubicbezierpath.cpp b/src/libs/vgeometry/vcubicbezierpath.cpp index ed3b716ff..58d49913c 100644 --- a/src/libs/vgeometry/vcubicbezierpath.cpp +++ b/src/libs/vgeometry/vcubicbezierpath.cpp @@ -83,9 +83,9 @@ VCubicBezierPath VCubicBezierPath::Rotate(const QPointF &originPoint, qreal degr { const QVector points = GetCubicPath(); VCubicBezierPath curve; - for(int i=0; i < points.size(); ++i) + for(auto &point : points) { - curve.append(points.at(i).Rotate(originPoint, degrees)); + curve.append(point.Rotate(originPoint, degrees)); } curve.setName(name() + prefix); curve.SetColor(GetColor()); @@ -99,9 +99,9 @@ VCubicBezierPath VCubicBezierPath::Flip(const QLineF &axis, const QString &prefi { const QVector points = GetCubicPath(); VCubicBezierPath curve; - for(int i=0; i < points.size(); ++i) + for(auto &point : points) { - curve.append(points.at(i).Flip(axis)); + curve.append(point.Flip(axis)); } curve.setName(name() + prefix); curve.SetColor(GetColor()); @@ -115,9 +115,9 @@ VCubicBezierPath VCubicBezierPath::Move(qreal length, qreal angle, const QString { const QVector points = GetCubicPath(); VCubicBezierPath curve; - for(int i=0; i < points.size(); ++i) + for(auto &point : points) { - curve.append(points.at(i).Move(length, angle)); + curve.append(point.Move(length, angle)); } curve.setName(name() + prefix); curve.SetColor(GetColor()); diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 006ea75c2..7b5f8b4ba 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -305,9 +305,9 @@ QVector CorrectPosition(const QRectF &parentBoundingRect, QVector PrepareAllowance(const QVector &points) { QVector allowancePoints; - for(int i = 0; i < points.size(); ++i) + for(auto point : points) { - allowancePoints.append(VSAPoint(points.at(i))); + allowancePoints.append(VSAPoint(point)); } return allowancePoints; } @@ -348,9 +348,10 @@ QStringList PieceLabelText(const QVector &labelShape, const VTextManage QVector ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern) { QVector labels; - for(int i=0; i < piece.GetPlaceLabels().size(); ++i) + const QVector placeLabels = piece.GetPlaceLabels(); + for(auto placeLabel : placeLabels) { - const auto label = pattern->GeometricObject(piece.GetPlaceLabels().at(i)); + const auto label = pattern->GeometricObject(placeLabel); VLayoutPlaceLabel layoutLabel; layoutLabel.shape = label->LabelShape(); layoutLabel.center = label->toQPointF(); diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index 1ee71abfd..1d16a0491 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -591,11 +591,11 @@ void VContainer::ClearUniqueIncrementNames() const QList list = uniqueNames.toList(); ClearUniqueNames(); - for(int i = 0; i < list.size(); ++i) + for(auto &name : list) { - if (not list.at(i).startsWith('#')) + if (not name.startsWith('#')) { - uniqueNames.insert(list.at(i)); + uniqueNames.insert(name); } } } diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index e7adc718a..941583c24 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -448,11 +448,11 @@ QVector VPiece::PassmarksLines(const VContainer *data, const QVector VPiece::PlaceLabelPoints(const VContainer *data) const { QVector points; - for(int i=0; i < d->m_placeLabels.size(); ++i) + for(auto placeLabel : d->m_placeLabels) { try { - const auto label = data->GeometricObject(d->m_placeLabels.at(i)); + const auto label = data->GeometricObject(placeLabel); points.append(label->LabelShape()); } catch (const VExceptionBadId &e) diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 9b3723970..b629ad35d 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -995,9 +995,9 @@ QVector VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, qreal w2 = end.GetSABefore(); if (w1 < 0 && w2 < 0) {// no local widths - for(int i = 0; i < points.size(); ++i) + for(auto point : points) { - VSAPoint p(points.at(i)); + VSAPoint p(point); if (i == 0) { // first point p.SetSAAfter(begin.GetSAAfter()); @@ -1036,9 +1036,9 @@ QVector VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, qreal length = 0; // how much we handle - for(int i = 1; i < points.size(); ++i) + for(auto point : points) { - p = VSAPoint(points.at(i)); + p = VSAPoint(point); if (i == points.size() - 1) {// last point diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index b788279a8..efd09b52e 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -411,12 +411,12 @@ void VAbstractTool::ToolCreation(const Source &typeCreation) //--------------------------------------------------------------------------------------------------------------------- VToolRecord VAbstractTool::GetRecord(const quint32 id, const Tool &toolType, VAbstractPattern *doc) { - QVector *history = doc->getHistory(); - for(int i = 0; i < history->size(); ++i) + const QVector *history = doc->getHistory(); + for(auto &record : *history) { - if (history->at(i).getId() == id && history->at(i).getTypeTool() == toolType) + if (record.getId() == id && record.getTypeTool() == toolType) { - return history->at(i); + return record; } } return VToolRecord(); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index edc784cb3..a29575c49 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1240,9 +1240,9 @@ void VToolSeamAllowance::keyReleaseEvent(QKeyEvent *event) { qApp->getUndoStack()->beginMacro(tr("multi deletion")); - for(int i=0; i < toolList.size(); ++i) + for(auto tool : toolList) { - toolList.at(i)->RemoveWithConfirm(false); + tool->RemoveWithConfirm(false); } } DeleteToolWithConfirm(false); @@ -1892,9 +1892,9 @@ QList VToolSeamAllowance::SelectedTools() const if (not list.isEmpty()) { - for(int i=0; i < list.size(); ++i) + for(auto item : list) { - VToolSeamAllowance *tool = qgraphicsitem_cast(list.at(i)); + VToolSeamAllowance *tool = qgraphicsitem_cast(item); if (tool != nullptr && tool->getId() != m_id) { tools.append(tool); @@ -2011,9 +2011,8 @@ QVector VToolSeamAllowance::DuplicateCustomSARecords(const QVect const QMap &replacements) { QVector newRecords; - for(int i=0; i < records.size(); ++i) + for(auto record : records) { - CustomSARecord record = records.at(i); record.path = DuplicatePiecePath(record.path, initData); record.startPoint = replacements.value(record.startPoint, NULL_ID); record.endPoint = replacements.value(record.endPoint, NULL_ID); @@ -2027,9 +2026,9 @@ QVector VToolSeamAllowance::DuplicateInternalPaths(const QVector newPaths; - for(int i=0; i < iPaths.size(); ++i) + for(auto iPath : iPaths) { - newPaths.append(DuplicatePiecePath(iPaths.at(i), initData)); + newPaths.append(DuplicatePiecePath(iPath, initData)); } return newPaths; } @@ -2039,11 +2038,11 @@ QVector VToolSeamAllowance::DuplicatePins(const QVector &pins, const VToolSeamAllowanceInitData &initData) { QVector newPins; - for(int i=0; i < pins.size(); ++i) + for(auto p : pins) { - QSharedPointer pin = initData.data->GeometricObject(pins.at(i)); + QSharedPointer pin = initData.data->GeometricObject(p); - VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(pins.at(i))); + VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(p)); SCASSERT(tool != nullptr) VToolPinInitData initNodeData; @@ -2068,10 +2067,10 @@ QVector VToolSeamAllowance::DuplicatePlaceLabels(const QVector const VToolSeamAllowanceInitData &initData) { QVector newPlaceLabels; - for(int i=0; i < placeLabels.size(); ++i) + for(auto placeLabel : placeLabels) { - QSharedPointer label = initData.data->GeometricObject(placeLabels.at(i)); - VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(placeLabels.at(i))); + QSharedPointer label = initData.data->GeometricObject(placeLabel); + VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(placeLabel)); SCASSERT(tool != nullptr) VToolPlaceLabelInitData initNodeData; diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index bf3a395db..9acbee524 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -1161,9 +1161,9 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector quint32 pRotate, qreal angle) { QVector nodeChildren; - for(int i=0; i < d.GetCustomSARecords().size(); ++i) + const QVector records = d.GetCustomSARecords(); + for(auto record : records) { - CustomSARecord record = d.GetCustomSARecords().at(i); const VPiecePath path = initData.data->GetPiecePath(record.path); VPiecePath newPath = path; newPath.Clear();//Clear nodes @@ -1220,9 +1220,10 @@ void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector qreal dy, quint32 pRotate, qreal angle) { QVector nodeChildren; - for(int i=0; i < d.GetInternalPaths().size(); ++i) + const QVector internalPaths = d.GetInternalPaths(); + for(auto iPath : internalPaths) { - const VPiecePath path = initData.data->GetPiecePath(d.GetInternalPaths().at(i)); + const VPiecePath path = initData.data->GetPiecePath(iPath); VPiecePath newPath = path; newPath.Clear();//Clear nodes @@ -1280,9 +1281,10 @@ void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector quint32 pRotate, qreal angle) { QVector nodeChildren; - for(int i=0; i < d.GetPins().size(); ++i) + const QVector pins = d.GetPins(); + for(auto pin : pins) { - const quint32 id = AddPin(d.GetPins().at(i), initData, children, drawName, dx, dy, pRotate, angle); + const quint32 id = AddPin(pin, initData, children, drawName, dx, dy, pRotate, angle); newDetail.GetPins().append(id); } children += nodeChildren; @@ -1294,10 +1296,10 @@ void CreateUnitedDetailPlaceLabels(VPiece &newDetail, const VPiece &d, QVector nodeChildren; - for(int i=0; i < d.GetPlaceLabels().size(); ++i) + const QVector placeLabels = d.GetPlaceLabels(); + for(auto placeLabel : placeLabels) { - const quint32 id = AddPlaceLabel(d.GetPlaceLabels().at(i), initData, children, drawName, dx, dy, pRotate, - angle); + const quint32 id = AddPlaceLabel(placeLabel, initData, children, drawName, dx, dy, pRotate, angle); newDetail.GetPlaceLabels().append(id); } children += nodeChildren; @@ -1645,9 +1647,9 @@ void VToolUnionDetails::incrementReferens() if (_referens == 1) { const QVector objects = GetReferenceObjects(); - for(int i = 0; i < objects.size(); ++i) + for(auto object : objects) { - doc->IncrementReferens(objects.at(i)); + doc->IncrementReferens(object); } QDomElement domElement = doc->elementById(m_id, getTagName()); @@ -1665,9 +1667,9 @@ void VToolUnionDetails::decrementReferens() if (_referens == 0) { const QVector objects = GetReferenceObjects(); - for(int i = 0; i < objects.size(); ++i) + for(auto object : objects) { - doc->DecrementReferens(objects.at(i)); + doc->DecrementReferens(object); } QDomElement domElement = doc->elementById(m_id, getTagName()); diff --git a/src/test/ValentinaTest/tst_nameregexp.cpp b/src/test/ValentinaTest/tst_nameregexp.cpp index abd79e3a5..4432a3557 100644 --- a/src/test/ValentinaTest/tst_nameregexp.cpp +++ b/src/test/ValentinaTest/tst_nameregexp.cpp @@ -49,14 +49,14 @@ void TST_NameRegExp::TestNameRegExp_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - INIT_LOCALE_VARIABLES(allLocales.at(i)); + INIT_LOCALE_VARIABLES(locale); Q_UNUSED(positiveSign) Q_UNUSED(expUpper) Q_UNUSED(expLower) - const QString localeName = allLocales.at(i).name(); + const QString localeName = locale.name(); QString tag = localeName+QLatin1String(". First character can't be ")+sign0; QTest::newRow(qUtf8Printable(tag)) << sign0+QLatin1String("a") << false; diff --git a/src/test/ValentinaTest/tst_qmutokenparser.cpp b/src/test/ValentinaTest/tst_qmutokenparser.cpp index 8650b571d..693baf289 100644 --- a/src/test/ValentinaTest/tst_qmutokenparser.cpp +++ b/src/test/ValentinaTest/tst_qmutokenparser.cpp @@ -84,9 +84,8 @@ void TST_QmuTokenParser::TokenFromUser_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - const QLocale locale = allLocales.at(i); PrepareVal(1000.5, locale); PrepareVal(-1000.5, locale); } diff --git a/src/test/ValentinaTest/tst_readval.cpp b/src/test/ValentinaTest/tst_readval.cpp index 7e46024ef..88a3ddae4 100644 --- a/src/test/ValentinaTest/tst_readval.cpp +++ b/src/test/ValentinaTest/tst_readval.cpp @@ -50,9 +50,8 @@ void TST_ReadVal::TestReadVal_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - const QLocale locale = allLocales.at(i); PrepareVal(1., locale); PrepareVal(1.0, locale); PrepareVal(-1.0, locale); diff --git a/src/test/ValentinaTest/tst_vtranslatevars.cpp b/src/test/ValentinaTest/tst_vtranslatevars.cpp index ad0d15a5a..5d9bd414b 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.cpp +++ b/src/test/ValentinaTest/tst_vtranslatevars.cpp @@ -58,10 +58,10 @@ void TST_VTranslateVars::TestFormulaFromUser_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - PrepareValFromUser(1000.5, allLocales.at(i)); - PrepareValFromUser(-1000.5, allLocales.at(i)); + PrepareValFromUser(1000.5, locale); + PrepareValFromUser(-1000.5, locale); } } @@ -88,10 +88,10 @@ void TST_VTranslateVars::TestFormulaToUser_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - PrepareValToUser(1000.5, allLocales.at(i)); - PrepareValToUser(-1000.5, allLocales.at(i)); + PrepareValToUser(1000.5, locale); + PrepareValToUser(-1000.5, locale); } }