diff --git a/src/app/tape/dialogs/dialogmdatabase.cpp b/src/app/tape/dialogs/dialogmdatabase.cpp index f6452facd..33b03712d 100644 --- a/src/app/tape/dialogs/dialogmdatabase.cpp +++ b/src/app/tape/dialogs/dialogmdatabase.cpp @@ -438,9 +438,9 @@ void DialogMDataBase::InitGroup(QTreeWidgetItem **group, const QString &groupNam const QStringList &list) { *group = AddGroup(groupName); - for (int i=0; i < mList.size(); ++i) + for (auto &m : mList) { - AddMeasurement(*group, mList.at(i), list); + AddMeasurement(*group, m, list); } } diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index fff4a658d..16a63bc24 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -252,11 +252,7 @@ MApplication::MApplication(int &argc, char **argv) //--------------------------------------------------------------------------------------------------------------------- MApplication::~MApplication() { - for (int i = 0; i < mainWindows.size(); ++i) - { - TMainWindow *window = mainWindows.at(i); - delete window; - } + qDeleteAll(mainWindows); delete trVars; if (not dataBase.isNull()) @@ -368,9 +364,9 @@ QList MApplication::MainWindows() { Clean(); QList list; - for (int i = 0; i < mainWindows.count(); ++i) + for (auto &w : mainWindows) { - list.append(mainWindows.at(i)); + list.append(w); } return list; } @@ -536,10 +532,10 @@ void MApplication::RetranslateGroups() //--------------------------------------------------------------------------------------------------------------------- void MApplication::RetranslateTables() { - QList list = MainWindows(); - for (int i=0; i < list.size(); ++i) + const QList list = MainWindows(); + for (auto w : list) { - list.at(i)->RetranslateTable(); + w->RetranslateTable(); } } @@ -689,10 +685,10 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS parser.showHelp(V_EX_USAGE); } - for (int i = 0; i < args.size(); ++i) + for (auto &arg : args) { NewMainWindow(); - if (not MainWindow()->LoadFile(args.at(i))) + if (not MainWindow()->LoadFile(arg)) { if (testMode) { diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index d529556ef..223899ddd 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -226,12 +226,12 @@ bool TMainWindow::LoadFile(const QString &path) } // Check if file already opened - QListlist = qApp->MainWindows(); - for (int i = 0; i < list.size(); ++i) + const QList list = qApp->MainWindows(); + for (auto w : list) { - if (list.at(i)->CurrentFile() == path) + if (w->CurrentFile() == path) { - list.at(i)->activateWindow(); + w->activateWindow(); close(); return false; } @@ -1347,15 +1347,15 @@ void TMainWindow::AddKnown() if (ui->tableWidget->currentRow() == -1) { currentRow = ui->tableWidget->rowCount() + list.size() - 1; - for (int i = 0; i < list.size(); ++i) + for (auto &name : list) { if (mType == MeasurementsType::Individual) { - m->AddEmpty(list.at(i), qApp->TrVars()->MFormula(list.at(i))); + m->AddEmpty(name, qApp->TrVars()->MFormula(name)); } else { - m->AddEmpty(list.at(i)); + m->AddEmpty(name); } search->AddRow(currentRow); @@ -1366,18 +1366,18 @@ void TMainWindow::AddKnown() currentRow = ui->tableWidget->currentRow() + list.size(); const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); QString after = nameField->data(Qt::UserRole).toString(); - for (int i = 0; i < list.size(); ++i) + for (auto &name : list) { if (mType == MeasurementsType::Individual) { - m->AddEmptyAfter(after, list.at(i), qApp->TrVars()->MFormula(list.at(i))); + m->AddEmptyAfter(after, name, qApp->TrVars()->MFormula(name)); } else { - m->AddEmptyAfter(after, list.at(i)); + m->AddEmptyAfter(after, name); } search->AddRow(currentRow); - after = list.at(i); + after = name; } } @@ -1441,9 +1441,9 @@ void TMainWindow::ImportFromPattern() if (ui->tableWidget->currentRow() == -1) { currentRow = ui->tableWidget->rowCount() + measurements.size() - 1; - for (int i = 0; i < measurements.size(); ++i) + for (auto &mName : measurements) { - m->AddEmpty(measurements.at(i)); + m->AddEmpty(mName); } } else @@ -1451,10 +1451,10 @@ void TMainWindow::ImportFromPattern() currentRow = ui->tableWidget->currentRow() + measurements.size(); const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); QString after = nameField->data(Qt::UserRole).toString(); - for (int i = 0; i < measurements.size(); ++i) + for (auto &mName : measurements) { - m->AddEmptyAfter(after, measurements.at(i)); - after = measurements.at(i); + m->AddEmptyAfter(after, mName); + after = mName; } } @@ -2836,12 +2836,12 @@ bool TMainWindow::LoadFromExistingFile(const QString &path) } // Check if file already opened - QListlist = qApp->MainWindows(); - for (int i = 0; i < list.size(); ++i) + const QList list = qApp->MainWindows(); + for (auto w : list) { - if (list.at(i)->CurrentFile() == path) + if (w->CurrentFile() == path) { - list.at(i)->activateWindow(); + w->activateWindow(); close(); return false; } diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index f2b814315..998f5ded8 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -513,9 +513,8 @@ void VApplication::ClearOldLogs() const if (allFiles.isEmpty() == false) { qCDebug(vApp, "Clearing old logs"); - for (int i = 0, sz = allFiles.size(); i < sz; ++i) + for (auto &fn : allFiles) { - auto fn = allFiles.at(i); QFileInfo info(fn); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) const QDateTime created = info.birthTime(); diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 2030fd2a2..e3cc53600 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -765,9 +765,9 @@ void VToolOptionsPropertyBrowser::SetOperationSuffix(const QString &suffix) QRegularExpression rx(NameRegExp()); const QStringList uniqueNames = VContainer::AllUniqueNames(); - for (int i=0; i < uniqueNames.size(); ++i) + for (auto &uniqueName : uniqueNames) { - const QString name = uniqueNames.at(i) + suffix; + const QString name = uniqueName + suffix; if (not rx.match(name).hasMatch() || not VContainer::IsUnique(name)) { idToProperty[AttrSuffix]->setValue(item->Suffix()); diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index e244b7f92..607bd2367 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -179,10 +179,9 @@ void PreferencesConfigurationPage::changeEvent(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list) { - for (int i = 0; i < list.size(); ++i) + for (auto &name : list) { - QLocale loc = QLocale(list.at(i)); - ui->labelCombo->addItem(loc.nativeLanguageName(), list.at(i)); + ui->labelCombo->addItem(QLocale(name).nativeLanguageName(), name); } } diff --git a/src/app/valentina/dialogs/dialogdatetimeformats.cpp b/src/app/valentina/dialogs/dialogdatetimeformats.cpp index 48b31ed57..2e44ac1da 100644 --- a/src/app/valentina/dialogs/dialogdatetimeformats.cpp +++ b/src/app/valentina/dialogs/dialogdatetimeformats.cpp @@ -165,14 +165,14 @@ void DialogDateTimeFormats::SetFormatLines(const QStringList &predefined, const int row = -1; - for (int i=0; ilistWidget->insertItem(++row, AddListLine(predefined.at(i))); + ui->listWidget->insertItem(++row, AddListLine(item)); } - for (int i=0; ilistWidget->insertItem(++row, AddListLine(userDefined.at(i))); + ui->listWidget->insertItem(++row, AddListLine(item)); } ui->listWidget->blockSignals(false); diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index d623a1cec..efaf75fbd 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -727,9 +727,9 @@ void DialogIncrements::RefreshPattern() if (hasChanges) { QVector expressions = doc->ListExpressions(); - for (int i = 0; i < renameList.size(); ++i) + for (auto &item : renameList) { - doc->ReplaceNameInFormula(expressions, renameList.at(i).first, renameList.at(i).second); + doc->ReplaceNameInFormula(expressions, item.first, item.second); } renameList.clear(); diff --git a/src/app/valentina/dialogs/dialogknownmaterials.cpp b/src/app/valentina/dialogs/dialogknownmaterials.cpp index ae6c1a104..f162363d6 100644 --- a/src/app/valentina/dialogs/dialogknownmaterials.cpp +++ b/src/app/valentina/dialogs/dialogknownmaterials.cpp @@ -62,12 +62,11 @@ void DialogKnownMaterials::SetList(const QStringList &list) int row = -1; - for (int i=0; ilistWidget->insertItem(++row, item); + ui->listWidget->insertItem(++row, new QListWidgetItem(m)); } } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 6fdf87025..1dd0a0923 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -4624,29 +4624,29 @@ QStringList MainWindow::GetUnlokedRestoreFileList() const QStringList files = qApp->ValentinaSettings()->GetRestoreFileList(); if (files.size() > 0) { - for (int i = 0; i < files.size(); ++i) + for (auto &file : files) { // Seeking file that realy need reopen - VLockGuard tmp(files.at(i)); + VLockGuard tmp(file); if (tmp.IsLocked()) { - restoreFiles.append(files.at(i)); + restoreFiles.append(file); } } // Clearing list after filtering - for (int i = 0; i < restoreFiles.size(); ++i) + for (auto &file : restoreFiles) { - files.removeAll(restoreFiles.at(i)); + files.removeAll(file); } // Clear all files that do not exist. QStringList filtered; - for (int i = 0; i < files.size(); ++i) + for (auto &file : files) { - if (QFileInfo::exists(files.at(i))) + if (QFileInfo::exists(file)) { - filtered.append(files.at(i)); + filtered.append(file); } } @@ -4852,21 +4852,21 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args) { qCDebug(vMainWindow, "User said Yes."); - for (int i = 0; i < restoreFiles.size(); ++i) + for (auto &file : restoreFiles) { QString error; - if (VDomDocument::SafeCopy(restoreFiles.at(i) + *autosavePrefix, restoreFiles.at(i), error)) + if (VDomDocument::SafeCopy(file + *autosavePrefix, file, error)) { - QFile autoFile(restoreFiles.at(i) + *autosavePrefix); + QFile autoFile(file + *autosavePrefix); autoFile.remove(); - LoadPattern(restoreFiles.at(i)); - args.removeAll(restoreFiles.at(i));// Do not open file twice after we restore him. + LoadPattern(file); + args.removeAll(file);// Do not open file twice after we restore him. } else { qCDebug(vMainWindow, "Could not copy %s%s to %s %s", - qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(*autosavePrefix), - qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(error)); + qUtf8Printable(file), qUtf8Printable(*autosavePrefix), + qUtf8Printable(file), qUtf8Printable(error)); } } } @@ -5369,9 +5369,9 @@ void MainWindow::ProcessCMD() { ReopenFilesAfterCrash(args); - for (int i=0, sz = args.size(); i < sz; ++i) + for (auto &arg : args) { - LoadPattern(args.at(i)); + LoadPattern(arg); } } else diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index a3cdf3d29..06f913970 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -372,9 +372,8 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const QVector &li QScopedPointer scene(new QGraphicsScene()); QList list; - for (int i=0; i < listDetails.count(); ++i) + for (auto piece : listDetails) { - VLayoutPiece piece = listDetails.at(i); QGraphicsItem *item = piece.GetItem(m_dialogSaveLayout->IsTextAsPaths()); qreal diff = 0; if (piece.IsForceFlipping()) @@ -396,9 +395,9 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const QVector &li list.append(item); } - for (int i=0; i < list.size(); ++i) + for (auto item : list) { - scene->addItem(list.at(i)); + scene->addItem(item); } QList papers;// Blank sheets @@ -410,9 +409,9 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const QVector &li QTransform matrix; matrix = matrix.translate(-mx, -my); - for (int i=0; i < list.size(); ++i) + for (auto item : list) { - list.at(i)->setTransform(matrix); + item->setTransform(matrix); } rect = scene->itemsBoundingRect().toRect(); @@ -537,9 +536,9 @@ void MainWindowsNoGUI::ExportDetailsAsApparelLayout(QVector listDe list.append(item); } - for (int i=0; i < list.size(); ++i) + for (auto item : list) { - scene->addItem(list.at(i)); + scene->addItem(item); } QRect rect = scene->itemsBoundingRect().toRect(); @@ -550,9 +549,9 @@ void MainWindowsNoGUI::ExportDetailsAsApparelLayout(QVector listDe QTransform matrix; matrix = matrix.translate(-mx, -my); - for (int i=0; i < list.size(); ++i) + for (auto item : list) { - list.at(i)->setTransform(matrix); + item->setTransform(matrix); } rect = scene->itemsBoundingRect().toRect(); @@ -853,11 +852,10 @@ QList MainWindowsNoGUI::CreateShadows(const QList shadows; - for (int i=0; i< papers.size(); ++i) + for (auto paper : papers) { qreal x1=0, y1=0, x2=0, y2=0; - QGraphicsRectItem *item = qgraphicsitem_cast(papers.at(i)); - if (item) + if (QGraphicsRectItem *item = qgraphicsitem_cast(paper)) { item->rect().getCoords(&x1, &y1, &x2, &y2); QGraphicsRectItem *shadowPaper = new QGraphicsRectItem(QRectF(x1+4, y1+4, x2+4, y2+4)); @@ -886,10 +884,10 @@ QList MainWindowsNoGUI::CreateScenes(const QListaddItem(shadows.at(i)); scene->addItem(papers.at(i)); - QList paperDetails = details.at(i); - for (int i=0; i < paperDetails.size(); ++i) + const QList paperDetails = details.at(i); + for (auto &detail : paperDetails) { - scene->addItem(paperDetails.at(i)); + scene->addItem(detail); } scenes.append(scene); @@ -1182,18 +1180,16 @@ void MainWindowsNoGUI::RestorePaper(int index) const void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder, const QList > &details) const { - for (int i = 0; i < details.size(); ++i) + for (auto &paperItems : details) { - const QList &paperItems = details.at(i); - for (int j = 0; j < paperItems.size(); ++j) + for (auto item : paperItems) { - QList pieceChildren = paperItems.at(j)->childItems(); - for (int k = 0; k < pieceChildren.size(); ++k) + QList pieceChildren = item->childItems(); + for (auto child : pieceChildren) { - QGraphicsItem *item = pieceChildren.at(k); - if (item->type() == QGraphicsSimpleTextItem::Type) + if (child->type() == QGraphicsSimpleTextItem::Type) { - if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast(item)) + if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast(child)) { textItem->setText(textItem->text() + placeholder); } @@ -1215,18 +1211,16 @@ void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder, void MainWindowsNoGUI::RestoreTextAfterDXF(const QString &placeholder, const QList > &details) const { - for (int i = 0; i < details.size(); ++i) + for (auto &paperItems : details) { - const QList &paperItems = details.at(i); - for (int j = 0; j < paperItems.size(); ++j) + for (auto item : paperItems) { - QList pieceChildren = paperItems.at(i)->childItems(); - for (int k = 0; k < pieceChildren.size(); ++k) + QList pieceChildren = item->childItems(); + for (auto child : pieceChildren) { - QGraphicsItem *item = pieceChildren.at(k); - if (item->type() == QGraphicsSimpleTextItem::Type) + if (child->type() == QGraphicsSimpleTextItem::Type) { - if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast(item)) + if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast(child)) { QString text = textItem->text(); text.replace(placeholder, QString()); @@ -1432,8 +1426,7 @@ bool MainWindowsNoGUI::IsLayoutGrayscale() const for (int i=0; i < scenes.size(); ++i) { - auto *paper = qgraphicsitem_cast(papers.at(i)); - if (paper) + if (auto *paper = qgraphicsitem_cast(papers.at(i))) { // Hide shadow and paper border PreparePaper(i); @@ -1513,9 +1506,9 @@ bool MainWindowsNoGUI::isPagesUniform() const { auto *paper = qgraphicsitem_cast(papers.at(0)); SCASSERT(paper != nullptr) - for (int i=1; i < papers.size(); ++i) + for (auto paperItem : papers) { - auto *p = qgraphicsitem_cast(papers.at(i)); + auto *p = qgraphicsitem_cast(paperItem); SCASSERT(p != nullptr) if (paper->rect() != p->rect()) { diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index 40117e24d..11e0d788b 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -209,9 +209,9 @@ QMap LineStylesPics() QMap map; const QStringList styles = StylesList(); - for (int i=0; i < styles.size(); ++i) + for (auto &s : styles) { - const Qt::PenStyle style = LineStyleToPenStyle(styles.at(i)); + const Qt::PenStyle style = LineStyleToPenStyle(s); QPixmap pix(80, 14); pix.fill(Qt::white); @@ -222,7 +222,7 @@ QMap LineStylesPics() painter.setPen(pen); painter.drawLine(2, 7, 78, 7); - map.insert(styles.at(i), QIcon(pix)); + map.insert(s, QIcon(pix)); } return map; } diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 15eed4779..00d149259 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -2023,13 +2023,13 @@ QVector VAbstractPattern::ListFinalMeasurementsExpressions() cons //--------------------------------------------------------------------------------------------------------------------- bool VAbstractPattern::IsVariable(const QString &token) const { - for (int i = 0; i < builInVariables.size(); ++i) + for (auto &var : builInVariables) { - if (token.indexOf( builInVariables.at(i) ) == 0) + if (token.indexOf( var ) == 0) { - if (builInVariables.at(i) == currentLength || builInVariables.at(i) == currentSeamAllowance) + if (var == currentLength || var == currentSeamAllowance) { - return token == builInVariables.at(i); + return token == var; } else { @@ -2049,9 +2049,9 @@ bool VAbstractPattern::IsVariable(const QString &token) const //--------------------------------------------------------------------------------------------------------------------- bool VAbstractPattern::IsFunction(const QString &token) const { - for (int i = 0; i < builInFunctions.size(); ++i) + for (auto &fn : builInFunctions) { - if (token.indexOf( builInFunctions.at(i) ) == 0) + if (token.indexOf(fn) == 0) { return true; } @@ -2176,13 +2176,13 @@ void VAbstractPattern::SetFMeasurements(QDomElement &element, const QVector names = OldNamesToNewNames_InV0_3_0(); const QList keys = names.uniqueKeys(); - for (int i = 0; i < keys.size(); ++i) + for (auto &key : keys) { qreal resValue = 0; // This has the same effect as a .values(), just isn't as elegant - const QList list = names.values( keys.at(i) ); + const QList list = names.values( key ); for(const auto &val : list) { const QDomNodeList nodeList = this->elementsByTagName(val); @@ -223,7 +223,7 @@ void VVITConverter::ConvertMeasurementsToV0_3_0() } } - bm.appendChild(AddMV0_3_0(keys.at(i), resValue)); + bm.appendChild(AddMV0_3_0(key, resValue)); } QDomElement rootElement = this->documentElement(); diff --git a/src/libs/ifc/xml/vvstconverter.cpp b/src/libs/ifc/xml/vvstconverter.cpp index 152818858..c84978e90 100644 --- a/src/libs/ifc/xml/vvstconverter.cpp +++ b/src/libs/ifc/xml/vvstconverter.cpp @@ -214,14 +214,14 @@ void VVSTConverter::ConvertMeasurementsToV0_4_0() const QMultiMap names = OldNamesToNewNames_InV0_3_0(); const QList keys = names.uniqueKeys(); - for (int i = 0; i < keys.size(); ++i) + for (auto &key : keys) { qreal resValue = 0; qreal resSizeIncrease = 0; qreal resHeightIncrease = 0; // This has the same effect as a .values(), just isn't as elegant - const QList list = names.values( keys.at(i) ); + const QList list = names.values( key ); for(const auto &val : list) { const QDomNodeList nodeList = this->elementsByTagName(val); @@ -243,7 +243,7 @@ void VVSTConverter::ConvertMeasurementsToV0_4_0() } } - bm.appendChild(AddMV0_4_0(keys.at(i), resValue, resSizeIncrease, resHeightIncrease)); + bm.appendChild(AddMV0_4_0(key, resValue, resSizeIncrease, resHeightIncrease)); } QDomElement rootElement = this->documentElement(); diff --git a/src/libs/qmuparser/qmuformulabase.cpp b/src/libs/qmuparser/qmuformulabase.cpp index 8d8019fa4..36a2d3fc4 100644 --- a/src/libs/qmuparser/qmuformulabase.cpp +++ b/src/libs/qmuparser/qmuformulabase.cpp @@ -145,9 +145,9 @@ void QmuFormulaBase::SetSepForEval() void QmuFormulaBase::RemoveAll(QMap &map, const QString &val) { const QList listKeys = map.keys(val);//Take all keys that contain token. - for (int i = 0; i < listKeys.size(); ++i) + for (auto key : listKeys) { - map.remove(listKeys.at(i)); + map.remove(key); } } diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index aaac5abb5..493a67423 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -143,9 +143,8 @@ void VDxfEngine::drawPath(const QPainterPath &path) { const QList subpaths = path.toSubpathPolygons(matrix); - for (int j=0; j < subpaths.size(); ++j) + for (auto polygon : subpaths) { - const QPolygonF polygon = subpaths.at(j); if (polygon.isEmpty()) { continue; @@ -166,10 +165,10 @@ void VDxfEngine::drawPath(const QPainterPath &path) poly->flags |= 0x80; // plinegen - for (int i=0; i < polygon.count(); ++i) + for (auto p : polygon) { - poly->addVertex(DRW_Vertex2D(FromPixel(polygon.at(i).x(), varInsunits), - FromPixel(getSize().height() - polygon.at(i).y(), varInsunits), 0)); + poly->addVertex(DRW_Vertex2D(FromPixel(p.x(), varInsunits), + FromPixel(getSize().height() - p.y(), varInsunits), 0)); } input->AddEntity(poly); @@ -188,10 +187,10 @@ void VDxfEngine::drawPath(const QPainterPath &path) poly->flags |= 0x80; // plinegen - for (int i=0; i < polygon.count(); ++i) + for (auto p : polygon) { - poly->addVertex(DRW_Vertex(FromPixel(polygon.at(i).x(), varInsunits), - FromPixel(getSize().height() - polygon.at(i).y(), varInsunits), 0, 0)); + poly->addVertex(DRW_Vertex(FromPixel(p.x(), varInsunits), + FromPixel(getSize().height() - p.y(), varInsunits), 0, 0)); } input->AddEntity(poly); @@ -770,9 +769,9 @@ void VDxfEngine::ExportAAMAText(dx_ifaceBlock *detailBlock, const VLayoutPiece & //--------------------------------------------------------------------------------------------------------------------- void VDxfEngine::ExportAAMAGlobalText(const QSharedPointer &input, const QVector &details) { - for(int i = 0; i < details.size(); ++i) + for(auto &detail : details) { - const QStringList strings = details.at(i).GetPatternText(); + const QStringList strings = detail.GetPatternText(); if (not strings.isEmpty()) { for (int j = 0; j < strings.size(); ++j) @@ -870,10 +869,10 @@ P *VDxfEngine::CreateAAMAPolygon(const QVector &polygon, const QString } } - for (int i=0; i < polygon.count(); ++i) + for (auto p : polygon) { - poly->addVertex(V(FromPixel(polygon.at(i).x(), varInsunits), - FromPixel(getSize().height() - polygon.at(i).y(), varInsunits))); + poly->addVertex(V(FromPixel(p.x(), varInsunits), + FromPixel(getSize().height() - p.y(), varInsunits))); } return poly; diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index b9186f479..2fe372621 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -376,9 +376,8 @@ QPainterPath VAbstractCurve::ShowDirection(const QVector &arrows { QPainterPath path; - for (int i = 0; i < arrows.size(); ++i) + for (auto arrow : arrows) { - const DirectionArrow arrow = arrows.at(i); if (not arrow.first.isNull() && not arrow.second.isNull()) { QPainterPath arrowPath; diff --git a/src/libs/vgeometry/vspline.cpp b/src/libs/vgeometry/vspline.cpp index d9ced421d..dc4c7c20b 100644 --- a/src/libs/vgeometry/vspline.cpp +++ b/src/libs/vgeometry/vspline.cpp @@ -527,9 +527,8 @@ qreal VSpline::ParamT (const QPointF &pBt) const // In morst case we will have 6 result in interval [0; 1]. // Here we try find closest to our point. - for (int i=0; i< ts.size(); ++i) + for (auto t : qAsConst(ts)) { - const qreal t = ts.at(i); const QPointF p0 = static_cast(GetP1()); const QPointF p1 = static_cast(GetP2()); const QPointF p2 = static_cast(GetP3()); diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index 2ad6d3454..192f4cd88 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -208,9 +208,9 @@ LayoutErrors VLayoutGenerator::State() const QList VLayoutGenerator::GetPapersItems() const { QList list; - for (int i=0; i < papers.count(); ++i) + for (auto &paper : papers) { - list.append(papers.at(i).GetPaperItem(autoCrop, IsTestAsPaths())); + list.append(paper.GetPaperItem(autoCrop, IsTestAsPaths())); } return list; } @@ -219,9 +219,9 @@ QList VLayoutGenerator::GetPapersItems() const QList > VLayoutGenerator::GetAllDetailsItems() const { QList > list; - for (int i=0; i < papers.count(); ++i) + for (auto &paper : papers) { - list.append(papers.at(i).GetItemDetails(IsTestAsPaths())); + list.append(paper.GetItemDetails(IsTestAsPaths())); } return list; } @@ -230,9 +230,9 @@ QList > VLayoutGenerator::GetAllDetailsItems() const QVector > VLayoutGenerator::GetAllDetails() const { QVector > list; - for (int i=0; i < papers.count(); ++i) + for (auto &paper : papers) { - list.append(papers.at(i).GetDetails()); + list.append(paper.GetDetails()); } return list; } @@ -458,9 +458,8 @@ QList VLayoutGenerator::MoveDetails(qreal length, const QVector newDetails; - for (int i = 0; i < details.size(); ++i) + for (auto d : details) { - VLayoutPiece d = details.at(i); d.Translate(0, length); newDetails.append(d); } diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index f90ca628f..57fe0bc48 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -275,9 +275,9 @@ bool VLayoutPaper::AddToSheet(const VLayoutPiece &detail, std::atomic_bool &stop return false; } - for (int i=0; i < threads.size(); ++i) + for (auto thread : threads) { - bestResult.NewResult(threads.at(i)->getBestResult()); + bestResult.NewResult(thread->getBestResult()); } qDeleteAll(threads.begin(), threads.end()); @@ -322,9 +322,9 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c { QScopedPointer scene(new QGraphicsScene()); QList list = GetItemDetails(textAsPaths); - for (int i=0; i < list.size(); ++i) + for (auto item : list) { - scene->addItem(list.at(i)); + scene->addItem(item); } const int height = scene->itemsBoundingRect().toRect().height(); if (d->globalContour.GetHeight() > height) //-V807 @@ -349,9 +349,9 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c QList VLayoutPaper::GetItemDetails(bool textAsPaths) const { QList list; - for (int i=0; i < d->details.count(); ++i) + for (auto &detail : d->details) { - list.append(d->details.at(i).GetItem(textAsPaths)); + list.append(detail.GetItem(textAsPaths)); } return list; } @@ -372,9 +372,9 @@ void VLayoutPaper::SetDetails(const QList &details) QRectF VLayoutPaper::DetailsBoundingRect() const { QRectF rec; - for (int i=0; i < d->details.count(); ++i) + for (auto &detail : d->details) { - rec = rec.united(d->details.at(i).DetailBoundingRect()); + rec = rec.united(detail.DetailBoundingRect()); } return rec; diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index d478d6df2..b942a069b 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -66,9 +66,9 @@ QVector ConvertInternalPaths(const VPiece &piece, const VConta QVector paths; const QVector pathsId = piece.GetInternalPaths(); - for (int i = 0; i < pathsId.size(); ++i) + for (auto id : pathsId) { - const VPiecePath path = pattern->GetPiecePath(pathsId.at(i)); + const VPiecePath path = pattern->GetPiecePath(id); if (path.GetType() == PiecePathType::InternalPath && path.IsVisible(pattern->DataVariables())) { paths.append(VLayoutPiecePath(path.PathPoints(pattern), path.IsCutPath(), path.GetPenType())); @@ -246,28 +246,28 @@ bool IsItemContained(const QRectF &parentBoundingRect, const QVector &s // single point differences bool bInside = true; - for (int i = 0; i < shape.size(); ++i) + for (auto p : shape) { qreal dPtX = 0; qreal dPtY = 0; - if (not parentBoundingRect.contains(shape.at(i))) + if (not parentBoundingRect.contains(p)) { - if (shape.at(i).x() < parentBoundingRect.left()) + if (p.x() < parentBoundingRect.left()) { - dPtX = parentBoundingRect.left() - shape.at(i).x(); + dPtX = parentBoundingRect.left() - p.x(); } - else if (shape.at(i).x() > parentBoundingRect.right()) + else if (p.x() > parentBoundingRect.right()) { - dPtX = parentBoundingRect.right() - shape.at(i).x(); + dPtX = parentBoundingRect.right() - p.x(); } - if (shape.at(i).y() < parentBoundingRect.top()) + if (p.y() < parentBoundingRect.top()) { - dPtY = parentBoundingRect.top() - shape.at(i).y(); + dPtY = parentBoundingRect.top() - p.y(); } - else if (shape.at(i).y() > parentBoundingRect.bottom()) + else if (p.y() > parentBoundingRect.bottom()) { - dPtY = parentBoundingRect.bottom() - shape.at(i).y(); + dPtY = parentBoundingRect.bottom() - p.y(); } if (fabs(dPtX) > fabs(dX)) @@ -448,9 +448,9 @@ template QVector VLayoutPiece::Map(const QVector &points) const { QVector p; - for (int i = 0; i < points.size(); ++i) + for (auto point : points) { - p.append(d->matrix.map(points.at(i))); + p.append(d->matrix.map(point)); } if (d->mirror) @@ -949,11 +949,11 @@ QVector > VLayoutPiece::InternalPathsForCut(bool cut) const { QVector > paths; - for (int i=0;i < d->m_internalPaths.count(); ++i) + for (auto &path : d->m_internalPaths) { - if (d->m_internalPaths.at(i).IsCutPath() == cut) + if (path.IsCutPath() == cut) { - paths.append(Map(d->m_internalPaths.at(i).Points())); + paths.append(Map(path.Points())); } } @@ -1051,20 +1051,20 @@ QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const { QGraphicsPathItem *item = GetMainItem(); - for (int i = 0; i < d->m_internalPaths.count(); ++i) + for (auto &path : d->m_internalPaths) { QGraphicsPathItem* pathItem = new QGraphicsPathItem(item); - pathItem->setPath(d->matrix.map(d->m_internalPaths.at(i).GetPainterPath())); + pathItem->setPath(d->matrix.map(path.GetPainterPath())); QPen pen = pathItem->pen(); - pen.setStyle(d->m_internalPaths.at(i).PenStyle()); + pen.setStyle(path.PenStyle()); pathItem->setPen(pen); } - for (int i = 0; i < d->m_placeLabels.count(); ++i) + for (auto &label : d->m_placeLabels) { QGraphicsPathItem* pathItem = new QGraphicsPathItem(item); - pathItem->setPath(d->matrix.map(PlaceLabelImgPath(d->m_placeLabels.at(i).shape))); + pathItem->setPath(d->matrix.map(PlaceLabelImgPath(label.shape))); } CreateLabelStrings(item, d->detailLabel, d->m_tmDetail, textAsPaths); @@ -1199,9 +1199,9 @@ void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const QVector gPoints = GetGrainline(); path.moveTo(gPoints.at(0)); - for (int i = 1; i < gPoints.count(); ++i) + for (auto p : gPoints) { - path.lineTo(gPoints.at(i)); + path.lineTo(p); } item->setPath(path); } diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 1312a6be8..c8d59617a 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -571,9 +571,9 @@ QPainterPath VPosition::DrawDetails(const QVector &details) path.setFillRule(Qt::WindingFill); if (details.count() > 0) { - for (int i = 0; i < details.size(); ++i) + for (auto &detail : details) { - path.addPath(details.at(i).ContourPath()); + path.addPath(detail.ContourPath()); } } return path; diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index 8fadf1fcf..abac50719 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -180,16 +180,16 @@ QList PrepareLines(const QVector &lines) { QList textLines; - for (int i=0; i < lines.size(); ++i) + for (auto &line : lines) { - if (not lines.at(i).line.isEmpty()) + if (not line.line.isEmpty()) { TextLine tl; - tl.m_qsText = lines.at(i).line; - tl.m_eAlign = static_cast(lines.at(i).alignment); - tl.m_iFontSize = lines.at(i).fontSizeIncrement; - tl.bold = lines.at(i).bold; - tl.italic = lines.at(i).italic; + tl.m_qsText = line.line; + tl.m_eAlign = static_cast(line.alignment); + tl.m_iFontSize = line.fontSizeIncrement; + tl.bold = line.bold; + tl.italic = line.italic; textLines << tl; } diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 12a8ab66c..d3f1ef8bc 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -817,11 +817,9 @@ void InitLanguages(QComboBox *combobox) bool englishUS = false; const QString en_US = QStringLiteral("en_US"); - for (int i = 0; i < fileNames.size(); ++i) + for (auto locale : fileNames) { - // get locale extracted by filename - QString locale; - locale = fileNames.at(i); // "valentina_de_De.qm" + // get locale extracted by filename "valentina_de_De.qm" locale.truncate(locale.lastIndexOf('.')); // "valentina_de_De" locale.remove(0, locale.indexOf('_') + 1); // "de_De" diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index f418ed5b9..e4f83e00f 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -105,9 +105,9 @@ qreal lineWidthCached = 0; //--------------------------------------------------------------------------------------------------------------------- QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats) { - for (int i = 0; i < predefinedFormats.size(); ++i) + for (auto &f : predefinedFormats) { - formats.removeAll(predefinedFormats.at(i)); + formats.removeAll(f); } return formats; } @@ -550,11 +550,11 @@ QStringList VCommonSettings::GetRecentFileList() const const QStringList files = value(*settingGeneralRecentFileList).toStringList(); QStringList cleared; - for (int i = 0; i < files.size(); ++i) + for (auto &f : files) { - if (QFileInfo::exists(files.at(i))) + if (QFileInfo::exists(f)) { - cleared.append(files.at(i)); + cleared.append(f); } } diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp index bdfff6801..3371ee77c 100644 --- a/src/libs/vobj/vobjengine.cpp +++ b/src/libs/vobj/vobjengine.cpp @@ -172,12 +172,12 @@ void VObjEngine::drawPath(const QPainterPath &path) quint32 num_points = 0; - for (int i=0; i < polygon.count(); i++) + for (auto &p : polygon) { if ( num_points < MAX_POINTS ) { - points[num_points].x = polygon.at(i).x(); - points[num_points].y = polygon.at(i).y(); + points[num_points].x = p.x(); + points[num_points].y = p.y(); num_points++; } } @@ -326,12 +326,12 @@ QPolygonF VObjEngine::MakePointsUnique(const QPolygonF &polygon) const { QVector set; QPolygonF uniquePolygon; - for (int i=0; i < polygon.count(); i++) + for (auto p : polygon) { - if (set.contains(polygon.at(i)) == false) + if (set.contains(p) == false) { - set.append(polygon.at(i)); - uniquePolygon.append(polygon.at(i)); + set.append(p); + uniquePolygon.append(p); } } return uniquePolygon; diff --git a/src/libs/vpatterndb/measurements.cpp b/src/libs/vpatterndb/measurements.cpp index 2b3d9e325..9db8acd8d 100644 --- a/src/libs/vpatterndb/measurements.cpp +++ b/src/libs/vpatterndb/measurements.cpp @@ -671,9 +671,9 @@ QStringList ListNumbers(const VTranslateMeasurements *trM, const QStringList &li SCASSERT(trM != nullptr) QStringList numbers; - for (int i=0; i < listMeasurements.size(); ++i) + for (auto &m : listMeasurements) { - numbers.append(trM->MNumber(listMeasurements.at(i))); + numbers.append(trM->MNumber(m)); } return numbers; } diff --git a/src/libs/vpatterndb/pmsystems.cpp b/src/libs/vpatterndb/pmsystems.cpp index beb52f15a..e53d9c554 100644 --- a/src/libs/vpatterndb/pmsystems.cpp +++ b/src/libs/vpatterndb/pmsystems.cpp @@ -159,9 +159,9 @@ void InitPMSystems(QComboBox *systemCombo) { const QStringList listSystems = ListPMSystems(); QMap systems; - for (int i = 0; i < listSystems.size()-1; ++i) + for (auto &sys : listSystems) { - systems.insert(qApp->TrVars()->PMSystemName(listSystems.at(i)) + " ("+listSystems.at(i)+")", listSystems.at(i)); + systems.insert(qApp->TrVars()->PMSystemName(sys) + QLatin1String(" (") + sys + QLatin1String(")"), sys); } // * The default option (blank field or 'None') should appear at the top of the list. diff --git a/src/libs/vpatterndb/vnodedetail.cpp b/src/libs/vpatterndb/vnodedetail.cpp index 1d676b532..cad66a5b3 100644 --- a/src/libs/vpatterndb/vnodedetail.cpp +++ b/src/libs/vpatterndb/vnodedetail.cpp @@ -224,9 +224,8 @@ QVector VNodeDetail::Convert(const VContainer *data, const QVector &path) int countPointNodes = 0; int countOthers = 0; - for (int i = 0; i< path.size(); ++i) + for (auto &node : path) { - const VPieceNode &node = path.at(i); if (node.IsExcluded()) { continue;// skip node @@ -895,9 +894,8 @@ QVector VPiece::GetUnitedPath(const VContainer *data) const QVector VPiece::GetValidRecords() const { QVector records; - for (int i = 0; i < d->m_customSARecords.size(); ++i) + for (auto &record : d->m_customSARecords) { - const CustomSARecord &record = d->m_customSARecords.at(i); const int indexStartPoint = d->m_path.indexOfNode(record.startPoint); const int indexEndPoint = d->m_path.indexOfNode(record.endPoint); @@ -948,13 +946,13 @@ QVector VPiece::FilterRecords(QVector records) c records.remove(startIndex); QVector secondRound; - for (int i = 0; i < records.size(); ++i) + for (auto &record : records) { - const int indexStartPoint = d->m_path.indexOfNode(records.at(i).startPoint); + const int indexStartPoint = d->m_path.indexOfNode(record.startPoint); const int indexEndPoint = d->m_path.indexOfNode(filter.endPoint); if (indexStartPoint > indexEndPoint) { - secondRound.append(records.at(i)); + secondRound.append(record); } } @@ -1149,12 +1147,12 @@ bool VPiece::IsPassmarkVisible(const QVector &path, int passmarkInde return true; } - for (int i = 0; i < records.size(); ++i) + for (auto &record : records) { - if (records.at(i).includeType == PiecePathIncludeType::AsCustomSA) + if (record.includeType == PiecePathIncludeType::AsCustomSA) { - const int indexStartPoint = VPiecePath::indexOfNode(path, records.at(i).startPoint); - const int indexEndPoint = VPiecePath::indexOfNode(path, records.at(i).endPoint); + const int indexStartPoint = VPiecePath::indexOfNode(path, record.startPoint); + const int indexEndPoint = VPiecePath::indexOfNode(path, record.endPoint); if (passmarkIndex > indexStartPoint && passmarkIndex < indexEndPoint) { return false; diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 6c9881ef3..d276c7047 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -581,9 +581,9 @@ void VPiecePath::NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const //--------------------------------------------------------------------------------------------------------------------- bool VPiecePath::Contains(quint32 id) const { - for (int i = 0; i < d->m_nodes.size(); ++i) + for (auto &node : d->m_nodes) { - if (d->m_nodes.at(i).GetId() == id) + if (node.GetId() == id) { return true; } @@ -676,11 +676,11 @@ int VPiecePath::Edge(quint32 p1, quint32 p2) const QVector VPiecePath::ListNodePoint() const { QVector list; - for (int i = 0; i < d->m_nodes.size(); ++i) //-V807 + for (auto &node : d->m_nodes) //-V807 { - if (d->m_nodes.at(i).GetTypeTool() == Tool::NodePoint) + if (node.GetTypeTool() == Tool::NodePoint) { - list.append(d->m_nodes.at(i)); + list.append(node); } } return list; diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index f7d948e39..83a964ba3 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -574,16 +574,16 @@ void DialogEditLabel::SetTemplate(const QVector &lines) int row = -1; - for (int i=0; iTrVars()->PlaceholderToUserText(lines.at(i).line)); - item->setTextAlignment(lines.at(i).alignment); - item->setData(Qt::UserRole, lines.at(i).fontSizeIncrement); + QListWidgetItem *item = new QListWidgetItem(qApp->TrVars()->PlaceholderToUserText(line.line)); + item->setTextAlignment(line.alignment); + item->setData(Qt::UserRole, line.fontSizeIncrement); QFont font = item->font(); - font.setBold(lines.at(i).bold); - font.setItalic(lines.at(i).italic); - font.setPointSize(font.pointSize() + lines.at(i).fontSizeIncrement); + font.setBold(line.bold); + font.setItalic(line.italic); + font.setPointSize(font.pointSize() + line.fontSizeIncrement); item->setFont(font); ui->listWidgetEdit->insertItem(++row, item); @@ -622,16 +622,16 @@ void DialogEditLabel::InitPreviewLines(const QVector &lines) int row = -1; - for (int i=0; isetTextAlignment(lines.at(i).alignment); - item->setData(Qt::UserRole, lines.at(i).fontSizeIncrement); + QListWidgetItem *item = new QListWidgetItem(ReplacePlaceholders(line.line)); + item->setTextAlignment(line.alignment); + item->setData(Qt::UserRole, line.fontSizeIncrement); QFont font = item->font(); - font.setBold(lines.at(i).bold); - font.setItalic(lines.at(i).italic); - font.setPointSize(font.pointSize() + lines.at(i).fontSizeIncrement); + font.setBold(line.bold); + font.setItalic(line.italic); + font.setPointSize(font.pointSize() + line.fontSizeIncrement); item->setFont(font); ui->listWidgetPreview->insertItem(++row, item); diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp index 8b2790822..8ac04c5c2 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp @@ -254,9 +254,9 @@ void DialogFlippingByAxis::SuffixChanged() { QRegularExpression rx(NameRegExp()); const QStringList uniqueNames = VContainer::AllUniqueNames(); - for (int i=0; i < uniqueNames.size(); ++i) + for (auto &uniqueName : uniqueNames) { - const QString name = uniqueNames.at(i) + suffix; + const QString name = uniqueName + suffix; if (not rx.match(name).hasMatch() || not data->IsUnique(name)) { flagName = false; diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp index e2dcef62e..0131c55ff 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp @@ -281,9 +281,9 @@ void DialogFlippingByLine::SuffixChanged() { QRegularExpression rx(NameRegExp()); const QStringList uniqueNames = VContainer::AllUniqueNames(); - for (int i=0; i < uniqueNames.size(); ++i) + for (auto &uniqueName : uniqueNames) { - const QString name = uniqueNames.at(i) + suffix; + const QString name = uniqueName + suffix; if (not rx.match(name).hasMatch() || not data->IsUnique(name)) { flagName = false; diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp index 984f71293..58fcda56f 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.cpp +++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp @@ -474,9 +474,9 @@ void DialogMove::SuffixChanged() { QRegularExpression rx(NameRegExp()); const QStringList uniqueNames = VContainer::AllUniqueNames(); - for (int i=0; i < uniqueNames.size(); ++i) + for (auto &uniqueName : uniqueNames) { - const QString name = uniqueNames.at(i) + suffix; + const QString name = uniqueName + suffix; if (not rx.match(name).hasMatch() || not data->IsUnique(name)) { flagName = false; diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index c0525f9b5..7caafe2d1 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -336,9 +336,9 @@ void DialogRotation::SuffixChanged() { QRegularExpression rx(NameRegExp()); const QStringList uniqueNames = VContainer::AllUniqueNames(); - for (int i=0; i < uniqueNames.size(); ++i) + for (auto &uniqueName : uniqueNames) { - const QString name = uniqueNames.at(i) + suffix; + const QString name = uniqueName + suffix; if (not rx.match(name).hasMatch() || not data->IsUnique(name)) { flagName = false; diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 4735497c4..d49ce8812 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -218,9 +218,9 @@ void DialogTool::FillComboBoxPiecesList(QComboBox *box, const QVector & SCASSERT(box != nullptr) box->blockSignals(true); box->clear(); - for (int i=0; i < list.size(); ++i) + for (auto id : list) { - box->addItem(data->GetPiece(list.at(i)).GetName(), list.at(i)); + box->addItem(data->GetPiece(id).GetName(), id); } box->blockSignals(false); box->setCurrentIndex(-1); // Force a user to choose diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp index e207b2718..8066d8667 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp @@ -1022,9 +1022,8 @@ void DialogPiecePath::InitPassmarksList() const QVector nodes = GetListInternals(ui->listWidget); - for (int i = 0; i < nodes.size(); ++i) + for (auto &node : nodes) { - const VPieceNode node = nodes.at(i); if (node.GetTypeTool() == Tool::NodePoint && node.IsPassmark()) { const QString name = GetNodeName(node); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 67de20401..b3907c4e1 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -223,9 +223,9 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) uiTabPaths->checkBoxHideMainPath->setChecked(piece.IsHideMainPath()); uiTabPaths->listWidgetCustomSA->blockSignals(true); uiTabPaths->listWidgetCustomSA->clear(); - for (int i = 0; i < piece.GetCustomSARecords().size(); ++i) + QVector records = piece.GetCustomSARecords(); + for (auto record : records) { - const CustomSARecord &record = piece.GetCustomSARecords().at(i); if (record.path > NULL_ID) { const QString name = GetPathName(record.path, record.reverse); @@ -240,9 +240,9 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) uiTabPaths->listWidgetCustomSA->blockSignals(false); uiTabPaths->listWidgetInternalPaths->clear(); - for (int i = 0; i < piece.GetInternalPaths().size(); ++i) + const QVector paths = piece.GetInternalPaths(); + for (auto path : paths) { - const quint32 path = piece.GetInternalPaths().at(i); if (path > NULL_ID) { const QString name = GetPathName(path); @@ -277,17 +277,19 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) }; uiTabPins->listWidgetPins->clear(); - for (int i = 0; i < piece.GetPins().size(); ++i) + const QVector pins = piece.GetPins(); + for (auto pin : pins) { - NewSpecialPoint(uiTabPins->listWidgetPins, piece.GetPins().at(i)); + NewSpecialPoint(uiTabPins->listWidgetPins, pin); } InitAllPinComboboxes(); uiTabPlaceLabels->listWidgetPlaceLabels->clear(); - for (int i = 0; i < piece.GetPlaceLabels().size(); ++i) + const QVector labels = piece.GetPlaceLabels(); + for (auto label : labels) { - NewSpecialPoint(uiTabPlaceLabels->listWidgetPlaceLabels, piece.GetPlaceLabels().at(i)); + NewSpecialPoint(uiTabPlaceLabels->listWidgetPlaceLabels, label); } if (piece.GetPlaceLabels().size() > 0) @@ -2471,9 +2473,8 @@ void DialogSeamAllowance::InitNodesList() const QVector nodes = GetListInternals(uiTabPaths->listWidgetMainPath); - for (int i = 0; i < nodes.size(); ++i) + for (auto &node : nodes) { - const VPieceNode node = nodes.at(i); if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded()) { const QString name = GetNodeName(node); @@ -2505,9 +2506,8 @@ void DialogSeamAllowance::InitPassmarksList() const QVector nodes = GetListInternals(uiTabPaths->listWidgetMainPath); - for (int i = 0; i < nodes.size(); ++i) + for (auto &node : nodes) { - const VPieceNode node = nodes.at(i); if (node.GetTypeTool() == Tool::NodePoint && node.IsPassmark()) { const QString name = GetNodeName(node); @@ -2775,9 +2775,8 @@ void DialogSeamAllowance::InitCSAPoint(QComboBox *box) const QVector nodes = GetListInternals(uiTabPaths->listWidgetMainPath); - for (int i = 0; i < nodes.size(); ++i) + for (auto &node : nodes) { - const VPieceNode &node = nodes.at(i); if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded()) { const QString name = GetNodeName(node); @@ -2802,10 +2801,9 @@ void DialogSeamAllowance::InitPinPoint(QComboBox *box) const QVector pins = GetListInternals(uiTabPins->listWidgetPins); - for (int i = 0; i < pins.size(); ++i) + for (auto pin : pins) { - const QSharedPointer pin = data->GetGObject(pins.at(i)); - box->addItem(pin->name(), pins.at(i)); + box->addItem(data->GetGObject(pin)->name(), pin); } const int index = uiTabPaths->comboBoxNodes->findData(currentId); @@ -3301,9 +3299,9 @@ QString DialogSeamAllowance::GetDefaultPieceName() const QList pieces = data->DataPieces()->values(); QSet names; - for (int i = 0; i < pieces.size(); ++i) + for (auto &piece : pieces) { - names.insert(pieces.at(i).GetName()); + names.insert(piece.GetName()); } const QString defName = tr("Detail"); diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp index fec1953b8..4ca9cfdb4 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp @@ -55,9 +55,8 @@ void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData, initData.id = VContainer::getNextId();//Just reserve id for tool - for (int i = 0; i < initData.source.size(); ++i) + for (auto idObject : qAsConst(initData.source)) { - const quint32 idObject = initData.source.at(i); const QSharedPointer obj = initData.data->GetGObject(idObject); // This check helps to find missed objects in the switch diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp index bb1b11022..e9831fc36 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp @@ -130,9 +130,9 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini InitOperationToolConnections(initData.scene, tool); VAbstractPattern::AddTool(initData.id, tool); initData.doc->IncrementReferens(originPoint.getIdTool()); - for (int i = 0; i < initData.source.size(); ++i) + for (auto idObject : qAsConst(initData.source)) { - initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); + initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool()); } return tool; } diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp index 7167e607e..c1df9ce0a 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp @@ -124,9 +124,9 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini VAbstractPattern::AddTool(initData.id, tool); initData.doc->IncrementReferens(firstPoint.getIdTool()); initData.doc->IncrementReferens(secondPoint.getIdTool()); - for (int i = 0; i < initData.source.size(); ++i) + for (auto idObject : qAsConst(initData.source)) { - initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); + initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool()); } return tool; } diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index ce40b422b..478b032af 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -519,26 +519,26 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag) doc->RemoveAllChildren(tag); QDomElement tagObjects = doc->createElement(TagSource); - for (int i = 0; i < source.size(); ++i) + for (auto id : qAsConst(source)) { QDomElement item = doc->createElement(TagItem); - doc->SetAttribute(item, AttrIdObject, source.at(i)); + doc->SetAttribute(item, AttrIdObject, id); tagObjects.appendChild(item); } tag.appendChild(tagObjects); tagObjects = doc->createElement(TagDestination); - for (int i = 0; i < destination.size(); ++i) + for (auto dItem : qAsConst(destination)) { QDomElement item = doc->createElement(TagItem); - doc->SetAttribute(item, AttrIdObject, destination.at(i).id); + doc->SetAttribute(item, AttrIdObject, dItem.id); - if (not VFuzzyComparePossibleNulls(destination.at(i).mx, INT_MAX) && - not VFuzzyComparePossibleNulls(destination.at(i).my, INT_MAX)) + if (not VFuzzyComparePossibleNulls(dItem.mx, INT_MAX) && + not VFuzzyComparePossibleNulls(dItem.my, INT_MAX)) { - doc->SetAttribute(item, AttrMx, qApp->fromPixel(destination.at(i).mx)); - doc->SetAttribute(item, AttrMy, qApp->fromPixel(destination.at(i).my)); - doc->SetAttribute(item, AttrShowLabel, destination.at(i).showLabel); + doc->SetAttribute(item, AttrMx, qApp->fromPixel(dItem.mx)); + doc->SetAttribute(item, AttrMy, qApp->fromPixel(dItem.my)); + doc->SetAttribute(item, AttrShowLabel, dItem.showLabel); } tagObjects.appendChild(item); @@ -609,9 +609,8 @@ void VAbstractOperation::AllowCurveSelecting(bool enabled, GOType type) //--------------------------------------------------------------------------------------------------------------------- void VAbstractOperation::InitOperatedObjects() { - for (int i = 0; i < destination.size(); ++i) + for (auto object : qAsConst(destination)) { - const DestinationItem object = destination.at(i); const QSharedPointer obj = VAbstractTool::data.GetGObject(object.id); // This check helps to find missed objects in the switch diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index cb4d7cbcd..f2c58688a 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -82,9 +82,8 @@ QPointF GetOriginPoint(const QVector objects, const VContainer *data, q { QPolygonF originObjects; - for (int i = 0; i < objects.size(); ++i) + for (auto id : objects) { - const quint32 id = objects.at(i); const QSharedPointer obj = data->GetGObject(id); // This check helps to find missed objects in the switch @@ -200,9 +199,8 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData) initData.id = VContainer::getNextId();//Just reserve id for tool - for (int i = 0; i < initData.source.size(); ++i) + for (auto idObject : qAsConst(initData.source)) { - const quint32 idObject = initData.source.at(i); const QSharedPointer obj = initData.data->GetGObject(idObject); // This check helps to find missed objects in the switch @@ -332,9 +330,9 @@ QT_WARNING_POP initData.doc->IncrementReferens(originPoint->getIdTool()); } - for (int i = 0; i < initData.source.size(); ++i) + for (auto idObject : qAsConst(initData.source)) { - initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); + initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool()); } return tool; } diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index a96a8f83f..bf0317612 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -144,9 +144,8 @@ VToolRotation *VToolRotation::Create(VToolRotationInitData &initData) initData.id = VContainer::getNextId();//Just reserve id for tool - for (int i = 0; i < initData.source.size(); ++i) + for (auto idObject : qAsConst(initData.source)) { - const quint32 idObject = initData.source.at(i); const QSharedPointer obj = initData.data->GetGObject(idObject); // This check helps to find missed objects in the switch @@ -259,9 +258,9 @@ QT_WARNING_POP InitOperationToolConnections(initData.scene, tool); VAbstractPattern::AddTool(initData.id, tool); initData.doc->IncrementReferens(originPoint.getIdTool()); - for (int i = 0; i < initData.source.size(); ++i) + for (auto idObject : qAsConst(initData.source)) { - initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); + initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool()); } return tool; } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index 639205179..8260beb7d 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -442,9 +442,9 @@ void VAbstractSpline::InitDefShape() //--------------------------------------------------------------------------------------------------------------------- void VAbstractSpline::ShowHandles(bool show) { - for (int i = 0; i < controlPoints.size(); ++i) + for (auto point : qAsConst(controlPoints)) { - controlPoints.at(i)->setVisible(show); + point->setVisible(show); } update();// Show direction } diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 0ff72cf84..cda38b259 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -300,9 +300,9 @@ void VToolSeamAllowance::AddCSARecords(VAbstractPattern *doc, QDomElement &domEl if (records.size() > 0) { QDomElement csaRecordsElement = doc->createElement(VToolSeamAllowance::TagCSA); - for (int i = 0; i < records.size(); ++i) + for (auto record : records) { - AddCSARecord(doc, csaRecordsElement, records.at(i)); + AddCSARecord(doc, csaRecordsElement, record); } domElement.appendChild(csaRecordsElement); } @@ -314,10 +314,10 @@ void VToolSeamAllowance::AddInternalPaths(VAbstractPattern *doc, QDomElement &do if (paths.size() > 0) { QDomElement iPathsElement = doc->createElement(VToolSeamAllowance::TagIPaths); - for (int i = 0; i < paths.size(); ++i) + for (auto path : paths) { QDomElement recordNode = doc->createElement(VToolSeamAllowance::TagRecord); - doc->SetAttribute(recordNode, VAbstractPattern::AttrPath, paths.at(i)); + doc->SetAttribute(recordNode, VAbstractPattern::AttrPath, path); iPathsElement.appendChild(recordNode); } domElement.appendChild(iPathsElement); @@ -1332,12 +1332,12 @@ void VToolSeamAllowance::UpdateExcludeState() //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::UpdateInternalPaths() { - const VPiece detail = VAbstractTool::data.GetPiece(m_id); - for (int i = 0; i < detail.GetInternalPaths().size(); ++i) + const QVector paths = VAbstractTool::data.GetPiece(m_id).GetInternalPaths(); + for (auto path : paths) { try { - if (auto *tool = qobject_cast(VAbstractPattern::getTool(detail.GetInternalPaths().at(i)))) + if (auto *tool = qobject_cast(VAbstractPattern::getTool(path))) { tool->RefreshGeometry(); } @@ -1766,18 +1766,20 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::InitCSAPaths(const VPiece &detail) const { - for (int i = 0; i < detail.GetCustomSARecords().size(); ++i) + const QVector records = detail.GetCustomSARecords(); + for (auto record : records) { - doc->IncrementReferens(detail.GetCustomSARecords().at(i).path); + doc->IncrementReferens(record.path); } } //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::InitInternalPaths(const VPiece &detail) { - for (int i = 0; i < detail.GetInternalPaths().size(); ++i) + const QVector paths = detail.GetInternalPaths(); + for (auto path : paths) { - auto *tool = qobject_cast(VAbstractPattern::getTool(detail.GetInternalPaths().at(i))); + auto *tool = qobject_cast(VAbstractPattern::getTool(path)); SCASSERT(tool != nullptr); if (tool->parent() != this) @@ -1786,16 +1788,16 @@ void VToolSeamAllowance::InitInternalPaths(const VPiece &detail) tool->SetParentType(ParentType::Item); } tool->show(); - doc->IncrementReferens(detail.GetInternalPaths().at(i)); + doc->IncrementReferens(path); } } //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::InitSpecialPoints(const QVector &points) const { - for (int i = 0; i < points.size(); ++i) + for (auto point : points) { - doc->IncrementReferens(points.at(i)); + doc->IncrementReferens(point); } } @@ -1913,10 +1915,10 @@ void VToolSeamAllowance::AddPointRecords(VAbstractPattern *doc, QDomElement &dom if (records.size() > 0) { QDomElement pinsElement = doc->createElement(tag); - for (int i = 0; i < records.size(); ++i) + for (auto record : records) { QDomElement recordNode = doc->createElement(VToolSeamAllowance::TagRecord); - recordNode.appendChild(doc->createTextNode(QString().setNum(records.at(i)))); + recordNode.appendChild(doc->createTextNode(QString().setNum(record))); pinsElement.appendChild(recordNode); } domElement.appendChild(pinsElement); diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 9acbee524..214025956 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -813,10 +813,10 @@ void SaveChildren(VAbstractPattern *doc, quint32 id, QDomElement section, const { if (children.size() > 0) { - for (int i=0; icreateElement(VToolUnionDetails::TagChild); - tagChild.appendChild(doc->createTextNode(QString().setNum(children.at(i)))); + tagChild.appendChild(doc->createTextNode(QString().setNum(child))); section.appendChild(tagChild); } @@ -1131,21 +1131,20 @@ void CreateUnitedNodes(VPiece &newDetail, const VPiece &d1, const VPiece &d2, co const VPiecePath d1Path = d1.GetPath().RemoveEdge(initData.indexD1); const VPiecePath d2Path = d2.GetPath().RemoveEdge(initData.indexD2); - const QVector > unitedPath = VToolUnionDetails::CalcUnitedPath(d1Path, d2Path, - initData.indexD2, pRotate); + const auto unitedPath = VToolUnionDetails::CalcUnitedPath(d1Path, d2Path, initData.indexD2, pRotate); QVector children; VPiecePath newPath; - for (int i=0; i < unitedPath.size(); ++i) + for (auto &path : unitedPath) { - if (unitedPath.at(i).first) + if (path.first) {// first piece - AddNodeToNewPath(initData, newPath, unitedPath.at(i).second, children, drawName); + AddNodeToNewPath(initData, newPath, path.second, children, drawName); } else {// second piece - AddNodeToNewPath(initData, newPath, unitedPath.at(i).second, children, drawName, dx, dy, pRotate, angle); + AddNodeToNewPath(initData, newPath, path.second, children, drawName, dx, dy, pRotate, angle); } } @@ -1204,9 +1203,10 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector void CreateUnitedCSA(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle) { - for (int i = 0; i < d1.GetCustomSARecords().size(); ++i) + const QVector records = d1.GetCustomSARecords(); + for (auto record : records) { - newDetail.GetCustomSARecords().append(d1.GetCustomSARecords().at(i)); + newDetail.GetCustomSARecords().append(record); } QVector children; @@ -1264,9 +1264,10 @@ void CreateUnitedInternalPaths(VPiece &newDetail, const VPiece &d1, const VPiece const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle) { - for (int i = 0; i < d1.GetInternalPaths().size(); ++i) + const QVector paths = d1.GetInternalPaths(); + for (auto path : paths) { - newDetail.GetInternalPaths().append(d1.GetInternalPaths().at(i)); + newDetail.GetInternalPaths().append(path); } QVector children; @@ -1309,9 +1310,10 @@ void CreateUnitedDetailPlaceLabels(VPiece &newDetail, const VPiece &d, QVector children; @@ -1324,9 +1326,10 @@ void CreateUnitedPlaceLabels(VPiece &newDetail, const VPiece &d1, const VPiece & const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle) { - for (int i = 0; i < d1.GetPlaceLabels().size(); ++i) + const auto labels = d1.GetPlaceLabels(); + for (auto label : labels) { - newDetail.GetPlaceLabels().append(d1.GetPlaceLabels().at(i)); + newDetail.GetPlaceLabels().append(label); } QVector children; @@ -1352,19 +1355,17 @@ void UpdateUnitedNodes(const VToolUnionDetailsInitData &initData, qreal dx, qrea "Time to refactor the code."); if (children.size() == countNodeD1 + countNodeD2-1) { - const QVector > unitedPath = VToolUnionDetails::CalcUnitedPath(d1REPath, d2REPath, - initData.indexD2, - pRotate); + const auto unitedPath = VToolUnionDetails::CalcUnitedPath(d1REPath, d2REPath, initData.indexD2, pRotate); - for (int i=0; i < unitedPath.size(); ++i) + for (auto path : unitedPath) { - if (unitedPath.at(i).first) + if (path.first) {// first piece - UpdatePathNode(initData.data, unitedPath.at(i).second, children); + UpdatePathNode(initData.data, path.second, children); } else {// second piece - UpdatePathNode(initData.data, unitedPath.at(i).second, children, dx, dy, pRotate, angle); + UpdatePathNode(initData.data, path.second, children, dx, dy, pRotate, angle); } } } @@ -1402,9 +1403,9 @@ void UpdateUnitedNodes(const VToolUnionDetailsInitData &initData, qreal dx, qrea void UpdateUnitedDetailPaths(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle, const QVector &records, QVector children) { - for (int i=0; i < records.size(); ++i) + for (auto record : records) { - const VPiecePath path = initData.data->GetPiecePath(records.at(i)); + const VPiecePath path = initData.data->GetPiecePath(record); if (initData.version == 1) { @@ -1444,9 +1445,9 @@ void UpdateUnitedDetailCSA(const VToolUnionDetailsInitData &initData, qreal dx, qreal angle, const QVector &records) { QVector idRecords; - for (int i = 0; i < records.size(); ++i) + for (auto record : records) { - idRecords.append(records.at(i).path); + idRecords.append(record.path); } UpdateUnitedDetailPaths(initData, dx, dy, pRotate, angle, idRecords, GetCSAChildren(initData.doc, initData.id)); } @@ -1465,9 +1466,9 @@ void UpdateUnitedDetailPins(const VToolUnionDetailsInitData &initData, qreal dx, { QVector children = GetPinChildren(initData.doc, initData.id); - for (int i = 0; i < records.size(); ++i) + for (auto record : records) { - QScopedPointer point(new VPointF(*initData.data->GeometricObject(records.at(i)))); + QScopedPointer point(new VPointF(*initData.data->GeometricObject(record))); point->setMode(Draw::Modeling); if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) { @@ -1484,9 +1485,9 @@ void UpdateUnitedDetailPlaceLabels(const VToolUnionDetailsInitData &initData, qr { QVector children = GetPlaceLabelChildren(initData.doc, initData.id); - for (int i = 0; i < records.size(); ++i) + for (auto record : records) { - QSharedPointer parentLabel = initData.data->GeometricObject(records.at(i)); + QSharedPointer parentLabel = initData.data->GeometricObject(record); if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) { BiasRotatePoint(parentLabel.data(), dx, dy, diff --git a/src/libs/vtools/visualization/line/operation/visoperation.cpp b/src/libs/vtools/visualization/line/operation/visoperation.cpp index 5f60f42bc..2ddec7859 100644 --- a/src/libs/vtools/visualization/line/operation/visoperation.cpp +++ b/src/libs/vtools/visualization/line/operation/visoperation.cpp @@ -104,9 +104,8 @@ void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPoint { int iPoint = -1; int iCurve = -1; - for (int i = 0; i < objects.size(); ++i) + for (auto id : qAsConst(objects)) { - const quint32 id = objects.at(i); const QSharedPointer obj = Visualization::data->GetGObject(id); // This check helps to find missed objects in the switch diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp index 8a27c9ad7..40dd9cdc5 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp @@ -271,9 +271,8 @@ int VisToolMove::AddMovedRotatedCurve(qreal angle, qreal length, quint32 id, int QPointF VisToolMove::GetOriginPoint(const QVector &objects) { QRectF boundingRect; - for (int i=0; i < objects.size(); ++i) + for (auto object : qAsConst(objects)) { - QGraphicsItem *object = objects.at(i); if (object) { QRectF childrenRect = object->childrenBoundingRect(); @@ -300,9 +299,8 @@ QVector VisToolMove::CreateOriginObjects(int &iPoint, int &iCur { QVector originObjects; - for (int i = 0; i < objects.size(); ++i) + for (auto id : qAsConst(objects)) { - const quint32 id = objects.at(i); const QSharedPointer obj = Visualization::data->GetGObject(id); // This check helps to find missed objects in the switch @@ -358,9 +356,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") void VisToolMove::CreateMovedRotatedObjects(int &iPoint, int &iCurve, qreal length, qreal angle, qreal rotationAngle, const QPointF &rotationOrigin) { - for (int i = 0; i < objects.size(); ++i) + for (auto id : qAsConst(objects)) { - const quint32 id = objects.at(i); const QSharedPointer obj = Visualization::data->GetGObject(id); // This check helps to find missed objects in the switch diff --git a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp index 11f9fa258..c2d33636b 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp @@ -125,9 +125,8 @@ void VisToolRotation::RefreshGeometry() int iPoint = -1; int iCurve = -1; - for (int i = 0; i < objects.size(); ++i) + for (auto id : qAsConst(objects)) { - const quint32 id = objects.at(i); const QSharedPointer obj = Visualization::data->GetGObject(id); // This check helps to find missed objects in the switch diff --git a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp index 78e1b2fb6..99353a129 100644 --- a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp @@ -87,9 +87,9 @@ VSimplePoint *VisPieceSpecialPoints::GetPoint(quint32 i, const QColor &color) //--------------------------------------------------------------------------------------------------------------------- void VisPieceSpecialPoints::HideAllItems() { - for (int i=0; i < m_points.size(); ++i) + for (auto item : qAsConst(m_points)) { - if (QGraphicsEllipseItem *item = m_points.at(i)) + if (item) { item->setVisible(false); } diff --git a/src/libs/vtools/visualization/path/vistoolpiecepath.cpp b/src/libs/vtools/visualization/path/vistoolpiecepath.cpp index 25aa6ab14..9e73cc653 100644 --- a/src/libs/vtools/visualization/path/vistoolpiecepath.cpp +++ b/src/libs/vtools/visualization/path/vistoolpiecepath.cpp @@ -99,9 +99,9 @@ void VisToolPiecePath::HideAllItems() m_line->setVisible(false); } - for (int i=0; i < m_points.size(); ++i) + for (auto item : qAsConst(m_points)) { - if (QGraphicsEllipseItem *item = m_points.at(i)) + if (item) { item->setVisible(false); } diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index febf9707d..18f058e0a 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -486,14 +486,13 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *event) emit itemClicked(nullptr); break; } - for (int i = 0; i < list.size(); ++i) + for (auto item : list) { - if (this->scene()->items().contains(list.at(i))) + if (this->scene()->items().contains(item)) { - if (list.at(i)->type() > QGraphicsItem::UserType && - list.at(i)->type() <= VSimpleCurve::Type) + if (item->type() > QGraphicsItem::UserType && item->type() <= VSimpleCurve::Type) { - emit itemClicked(list.at(i)); + emit itemClicked(item); break; } else diff --git a/src/test/TranslationsTest/tst_buitinregexp.cpp b/src/test/TranslationsTest/tst_buitinregexp.cpp index b55386dc9..89a572ec3 100644 --- a/src/test/TranslationsTest/tst_buitinregexp.cpp +++ b/src/test/TranslationsTest/tst_buitinregexp.cpp @@ -231,10 +231,10 @@ void TST_BuitInRegExp::TestTemplatePlaceholders() QSet originals; QSet translations; - for (int i = 0; i < labelTemplatePlaceholders.size(); ++i) + for (auto &placeholder : labelTemplatePlaceholders) { - originals.insert(labelTemplatePlaceholders.at(i)); - translations.insert(m_trMs->PlaceholderToUser(labelTemplatePlaceholders.at(i))); + originals.insert(placeholder); + translations.insert(m_trMs->PlaceholderToUser(placeholder)); } QCOMPARE(originals.size(), labelTemplatePlaceholders.size()); // All tags are unique diff --git a/src/test/TranslationsTest/tst_tslocaletranslation.cpp b/src/test/TranslationsTest/tst_tslocaletranslation.cpp index 6577365d3..f6674907e 100644 --- a/src/test/TranslationsTest/tst_tslocaletranslation.cpp +++ b/src/test/TranslationsTest/tst_tslocaletranslation.cpp @@ -299,19 +299,19 @@ void TST_TSLocaleTranslation::TestHTMLTags() << QLatin1String("html") << QLatin1String("body"); static const QString pattern("{1}.*>"); - for (int i=0; i < tags.size(); ++i) + for (auto &tag : tags) { - const QRegularExpression openRegex(QLatin1String("<") + tags.at(i) + pattern, + const QRegularExpression openRegex(QLatin1String("<") + tag + pattern, QRegularExpression::DotMatchesEverythingOption); if (source.contains(openRegex)) { const int countOpenTag = source.count(openRegex); - const QRegularExpression closeRegex(QLatin1String("'. ").arg(tags.at(i)) + + const QString message = QString("Tag mismatch. Tag: '<%1>'. ").arg(tag) + QString("Original name:'%1'").arg(source) + QString(", translated name:'%1'").arg(translation); QFAIL(qUtf8Printable(message)); } diff --git a/src/test/ValentinaTest/tst_varc.cpp b/src/test/ValentinaTest/tst_varc.cpp index 260829313..1dec7d3d5 100644 --- a/src/test/ValentinaTest/tst_varc.cpp +++ b/src/test/ValentinaTest/tst_varc.cpp @@ -180,9 +180,9 @@ void TST_VArc::TestGetPoints() { const qreal epsRadius = 1.5; // computing error - for (int i=0; i < points.size(); ++i) + for (auto point : points) { - QLineF rLine(static_cast(center), points.at(i)); + QLineF rLine(static_cast(center), point); const qreal value = qAbs(rLine.length() - radius); const QString errorMsg = QString("Broken the first rule. All points should be on the same distance from " "the center. Error ='%1'.").arg(value); diff --git a/src/test/ValentinaTest/tst_vellipticalarc.cpp b/src/test/ValentinaTest/tst_vellipticalarc.cpp index 3e9936b41..8d591d822 100644 --- a/src/test/ValentinaTest/tst_vellipticalarc.cpp +++ b/src/test/ValentinaTest/tst_vellipticalarc.cpp @@ -281,9 +281,8 @@ void TST_VEllipticalArc::TestGetPoints1() { // equation of ellipse will be different when rotation angle isn't 0 so we can't use this test in this case const qreal eps = 0.05; - for (int i=0; i < points.size(); ++i) + for (auto p : points) { - QPointF p = points.at(i); const qreal equationRes = p.rx()*p.rx()/(radius1*radius1) + p.ry()*p.ry()/(radius2*radius2); const qreal diff = qAbs(equationRes - 1); const QString errorMsg = QString("Broken the first rule. Any point must satisfy the equation of ellipse." diff --git a/src/test/ValentinaTest/tst_vposter.cpp b/src/test/ValentinaTest/tst_vposter.cpp index 8dbc4afe6..1feb0ea3a 100644 --- a/src/test/ValentinaTest/tst_vposter.cpp +++ b/src/test/ValentinaTest/tst_vposter.cpp @@ -65,9 +65,9 @@ void TST_VPoster::BigPoster() QCOMPARE(poster.size(), 12); - for (int i=0; i < poster.size(); i++) + for (auto p : poster) { - QCOMPARE(poster.at(i).rect.size(), PageRect(printer).size()); + QCOMPARE(p.rect.size(), PageRect(printer).size()); } }