From 6b6a2632a95a29114eb9aecd5021eb753533b139 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 3 Apr 2018 11:15:58 +0300 Subject: [PATCH] Refactoring. Replacing all Q_FOREACH/foreach loops with the c++ range-based loops. --HG-- branch : develop --- common.pri | 2 ++ src/app/valentina/core/vformulaproperty.cpp | 4 +-- .../valentina/dialogs/dialogsavelayout.cpp | 2 +- .../dialogs/vabstractlayoutdialog.cpp | 2 +- src/libs/ifc/xml/vabstractpattern.cpp | 2 +- src/libs/ifc/xml/vvitconverter.cpp | 2 +- src/libs/ifc/xml/vvstconverter.cpp | 2 +- src/libs/vdxf/vdxfengine.cpp | 27 ++++++++----------- src/libs/vformat/vmeasurements.cpp | 4 +-- src/libs/vlayout/vabstractpiece.cpp | 2 +- src/libs/vlayout/vlayoutpiece.cpp | 4 +-- src/libs/vmisc/dialogs/dialogexporttocsv.cpp | 3 ++- src/libs/vmisc/vtablesearch.cpp | 8 +++--- src/libs/vpatterndb/vpiece.cpp | 8 +++--- src/libs/vpatterndb/vpiecepath.cpp | 2 +- .../vpropertyexplorer/checkablemessagebox.cpp | 7 +++-- .../plugins/Vector3d/vvector3dproperty.cpp | 4 +-- .../plugins/vfilepropertyeditor.cpp | 2 +- .../plugins/vpointfproperty.cpp | 4 +-- src/libs/vpropertyexplorer/vproperty.cpp | 11 +++++--- .../vpropertyexplorer/vpropertyformview.cpp | 4 +-- .../vpropertyexplorer/vpropertyformwidget.cpp | 6 ++--- src/libs/vpropertyexplorer/vpropertyset.cpp | 20 +++++++++----- .../vpropertyexplorer/vserializedproperty.cpp | 2 +- src/libs/vtest/abstracttest.cpp | 6 ++--- .../tools/drawTools/operation/vtoolmove.cpp | 2 +- .../drawTools/toolcurve/vabstractspline.cpp | 6 ++--- .../tools/drawTools/toolcurve/vtoolspline.cpp | 6 ++--- .../drawTools/toolcurve/vtoolsplinepath.cpp | 6 ++--- src/libs/vtools/tools/vtoolseamallowance.cpp | 2 +- src/libs/vwidgets/fancytabbar/fancytabbar.cpp | 2 +- src/libs/vwidgets/fancytabbar/stylehelper.cpp | 3 ++- src/libs/vwidgets/vmaingraphicsscene.cpp | 5 ++-- src/libs/vwidgets/vmaingraphicsview.cpp | 3 ++- .../TranslationsTest/qttestmainlambda.cpp | 10 +++---- .../TranslationsTest/tst_buitinregexp.cpp | 6 ++--- .../tst_measurementregexp.cpp | 2 +- src/test/ValentinaTest/tst_nameregexp.cpp | 2 +- src/test/ValentinaTest/tst_vcommandline.cpp | 2 +- 39 files changed, 106 insertions(+), 91 deletions(-) diff --git a/common.pri b/common.pri index 9f4826b7c..f14d6c048 100644 --- a/common.pri +++ b/common.pri @@ -41,6 +41,8 @@ win32 { ../../../dist/win/msvcr120.dll } +DEFINES += QT_NO_FOREACH + macx{ # QTBUG-31034 qmake doesn't allow override QMAKE_CXX CONFIG+=no_ccache diff --git a/src/app/valentina/core/vformulaproperty.cpp b/src/app/valentina/core/vformulaproperty.cpp index fbaf85cc0..6f4fa61c8 100644 --- a/src/app/valentina/core/vformulaproperty.cpp +++ b/src/app/valentina/core/vformulaproperty.cpp @@ -139,8 +139,8 @@ VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *contai if (!include_children) { - QList tmpChildren = container->getChildren(); - foreach (VProperty* tmpChild, tmpChildren) + const QList tmpChildren = container->getChildren(); + for (auto tmpChild : tmpChildren) { container->removeChild(tmpChild); delete tmpChild; diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 70c621b82..e198ed0ee 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -95,7 +95,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName } } - foreach (auto& v, InitFormats()) + for (auto &v : InitFormats()) { ui->comboBoxFormat->addItem(v.first, QVariant(static_cast(v.second))); } diff --git a/src/app/valentina/dialogs/vabstractlayoutdialog.cpp b/src/app/valentina/dialogs/vabstractlayoutdialog.cpp index 1ab4fe6b8..18a3bd7f5 100644 --- a/src/app/valentina/dialogs/vabstractlayoutdialog.cpp +++ b/src/app/valentina/dialogs/vabstractlayoutdialog.cpp @@ -62,7 +62,7 @@ void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates) const QString pdi = QString("(%1ppi)").arg(PrintDPI); auto cntr = static_cast(PaperSizeTemplate::A0); - foreach(const auto& v, pageFormatNames) + for(const auto& v : pageFormatNames) { if (cntr <= static_cast(PaperSizeTemplate::Legal)) { diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index e712fe573..15eed4779 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -260,7 +260,7 @@ QStringList VAbstractPattern::ListMeasurements() const QSet measurements; QSet others = futureIncrements.result().toSet(); - foreach (const QString &token, tokens) + for (const auto &token : tokens) { if (token == QChar('-') || measurements.contains(token) || others.contains(token)) { diff --git a/src/libs/ifc/xml/vvitconverter.cpp b/src/libs/ifc/xml/vvitconverter.cpp index 7dc32b396..6d0cde2e5 100644 --- a/src/libs/ifc/xml/vvitconverter.cpp +++ b/src/libs/ifc/xml/vvitconverter.cpp @@ -207,7 +207,7 @@ void VVITConverter::ConvertMeasurementsToV0_3_0() // This has the same effect as a .values(), just isn't as elegant const QList list = names.values( keys.at(i) ); - foreach(const QString &val, list ) + for(const auto &val : list) { const QDomNodeList nodeList = this->elementsByTagName(val); if (nodeList.isEmpty()) diff --git a/src/libs/ifc/xml/vvstconverter.cpp b/src/libs/ifc/xml/vvstconverter.cpp index 0859a7581..152818858 100644 --- a/src/libs/ifc/xml/vvstconverter.cpp +++ b/src/libs/ifc/xml/vvstconverter.cpp @@ -222,7 +222,7 @@ void VVSTConverter::ConvertMeasurementsToV0_4_0() // This has the same effect as a .values(), just isn't as elegant const QList list = names.values( keys.at(i) ); - foreach(const QString &val, list ) + for(const auto &val : list) { const QDomNodeList nodeList = this->elementsByTagName(val); if (nodeList.isEmpty()) diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 37dc493fa..aaac5abb5 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -681,32 +681,29 @@ void VDxfEngine::ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece & if (not detail.IsHideMainPath()) { QVector poly = detail.GetContourPoints(); - DRW_Entity *e = AAMAPolygon(poly, "8", true); - if (e) + if (DRW_Entity *e = AAMAPolygon(poly, "8", true)) { detailBlock->ent.push_back(e); } } - QVector> drawIntCut = detail.InternalPathsForCut(false); - for(int j = 0; j < drawIntCut.size(); ++j) + const QVector> drawIntCut = detail.InternalPathsForCut(false); + for(auto &intCut : drawIntCut) { - DRW_Entity *e = AAMAPolygon(drawIntCut.at(j), "8", false); - if (e) + if (DRW_Entity *e = AAMAPolygon(intCut, "8", false)) { detailBlock->ent.push_back(e); } } const QVector labels = detail.GetPlaceLabels(); - foreach(const VLayoutPlaceLabel &label, labels) + for(auto &label : labels) { if (label.type != PlaceLabelType::Doubletree && label.type != PlaceLabelType::Button) { - foreach(const QPolygonF &p, label.shape) + for(auto &p : qAsConst(label.shape)) { - DRW_Entity *e = AAMAPolygon(p, "8", false); - if (e) + if (DRW_Entity *e = AAMAPolygon(p, "8", false)) { detailBlock->ent.push_back(e); } @@ -719,10 +716,9 @@ void VDxfEngine::ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece & void VDxfEngine::ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) { QVector> drawIntCut = detail.InternalPathsForCut(true); - for(int j = 0; j < drawIntCut.size(); ++j) + for(auto &intCut : drawIntCut) { - DRW_Entity *e = AAMAPolygon(drawIntCut.at(j), "11", false); - if (e) + if (DRW_Entity *e = AAMAPolygon(intCut, "11", false)) { detailBlock->ent.push_back(e); } @@ -751,8 +747,7 @@ void VDxfEngine::ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPi const QVector grainline = detail.GetGrainline(); if (grainline.count() > 1) { - DRW_Entity *e = AAMALine(QLineF(grainline.first(), grainline.last()), "7"); - if (e) + if (DRW_Entity *e = AAMALine(QLineF(grainline.first(), grainline.last()), "7")) { detailBlock->ent.push_back(e); } @@ -795,7 +790,7 @@ void VDxfEngine::ExportAAMADrill(dx_ifaceBlock *detailBlock, const VLayoutPiece { const QVector labels = detail.GetPlaceLabels(); - foreach(const VLayoutPlaceLabel &label, labels) + for(auto &label : labels) { if (label.type == PlaceLabelType::Doubletree || label.type == PlaceLabelType::Button) { diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index c1c4a49a2..316250b50 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -658,13 +658,13 @@ bool VMeasurements::IsDefinedKnownNamesValid() const QStringList names = AllGroupNames(); QSet set; - foreach (const QString &var, names) + for (const auto &var : names) { set.insert(var); } names = ListKnown(); - foreach (const QString &var, names) + for (const auto &var : qAsConst(names)) { if (not set.contains(var)) { diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index a9d3f184e..cd86bfb18 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1017,7 +1017,7 @@ bool VAbstractPiece::IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &pr QPainterPath VAbstractPiece::PlaceLabelImgPath(const PlaceLabelImg &img) { QPainterPath path; - foreach(const QPolygonF &p, img) + for (auto &p : img) { if (not p.isEmpty()) { diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 7b5f8b4ba..d478d6df2 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -470,12 +470,12 @@ template <> QVector VLayoutPiece::Map(const QVector &points) const { QVector p; - foreach (const VLayoutPlaceLabel &label, points) + for (auto &label : points) { VLayoutPlaceLabel mappedLabel; mappedLabel.type = label.type; mappedLabel.center = d->matrix.map(label.center); - foreach (const QPolygonF &p, label.shape) + for (const auto &p : label.shape) { mappedLabel.shape.append(d->matrix.map(p)); } diff --git a/src/libs/vmisc/dialogs/dialogexporttocsv.cpp b/src/libs/vmisc/dialogs/dialogexporttocsv.cpp index 0aa143f51..1c7761767 100644 --- a/src/libs/vmisc/dialogs/dialogexporttocsv.cpp +++ b/src/libs/vmisc/dialogs/dialogexporttocsv.cpp @@ -46,7 +46,8 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent) { ui->setupUi(this); - foreach (int mib, QTextCodec::availableMibs()) + const QList mibs = QTextCodec::availableMibs(); + for (auto mib : mibs) { ui->comboBoxCodec->addItem(QTextCodec::codecForMib(mib)->name(), mib); } diff --git a/src/libs/vmisc/vtablesearch.cpp b/src/libs/vmisc/vtablesearch.cpp index cb9f3658f..f683a2b8b 100644 --- a/src/libs/vmisc/vtablesearch.cpp +++ b/src/libs/vmisc/vtablesearch.cpp @@ -105,7 +105,7 @@ void VTableSearch::Find(const QString &term) if (not searchList.isEmpty()) { - foreach(QTableWidgetItem *item, searchList) + for (auto item : qAsConst(searchList)) { item->setBackground(Qt::yellow); } @@ -158,7 +158,7 @@ void VTableSearch::RemoveRow(int row) if (row <= indexRow) { - foreach(QTableWidgetItem *item, searchList) + for (auto item : qAsConst(searchList)) { if (item->row() == row) { @@ -180,7 +180,7 @@ void VTableSearch::AddRow(int row) if (row <= indexRow) { - foreach(QTableWidgetItem *item, searchList) + for (auto item : qAsConst(searchList)) { if (item->row() == row) { @@ -202,7 +202,7 @@ void VTableSearch::RefreshList(const QString &term) searchList = table->findItems(term, Qt::MatchContains); - foreach(QTableWidgetItem *item, searchList) + for (auto item : qAsConst(searchList)) { item->setBackground(Qt::yellow); } diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 941583c24..42eb3d96a 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -681,22 +681,22 @@ QList VPiece::Dependencies() const { QList list = d->m_path.Dependencies(); - foreach (const CustomSARecord &record, d->m_customSARecords) + for (auto &record : d->m_customSARecords) { list.append(record.path); } - foreach (const quint32 &value, d->m_internalPaths) + for (auto &value : d->m_internalPaths) { list.append(value); } - foreach (const quint32 &value, d->m_pins) + for (auto &value : d->m_pins) { list.append(value); } - foreach (const quint32 &value, d->m_placeLabels) + for (auto &value : d->m_placeLabels) { list.append(value); } diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index b629ad35d..6c9881ef3 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -505,7 +505,7 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector VPiecePath::Dependencies() const { QList list; - foreach (const VPieceNode &node, d->m_nodes) + for (auto &node : d->m_nodes) { list.append(node.GetId()); } diff --git a/src/libs/vpropertyexplorer/checkablemessagebox.cpp b/src/libs/vpropertyexplorer/checkablemessagebox.cpp index e8b802a90..9f35b5009 100644 --- a/src/libs/vpropertyexplorer/checkablemessagebox.cpp +++ b/src/libs/vpropertyexplorer/checkablemessagebox.cpp @@ -222,7 +222,9 @@ QPushButton *CheckableMessageBox::addButton(const QString &text, QDialogButtonBo QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const { - foreach (QAbstractButton *b, d->buttonBox->buttons()) + const QList buttons = d->buttonBox->buttons(); + for (auto b : buttons) + { if (QPushButton *pb = qobject_cast(b)) { if (pb->isDefault()) @@ -230,6 +232,7 @@ QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const return d->buttonBox->standardButton(pb); } } + } return QDialogButtonBox::NoButton; } @@ -429,7 +432,7 @@ bool CheckableMessageBox::hasSuppressedQuestions(QSettings *settings) //Q_ASSERT(settings, return false); bool hasSuppressed = false; settings->beginGroup(QLatin1String(kDoNotAskAgainKey)); - foreach (const QString &subKey, settings->childKeys()) + for (auto &subKey : settings->childKeys()) { if (settings->value(subKey, false).toBool()) { diff --git a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp index 18b2f2290..df2960a40 100644 --- a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp @@ -115,8 +115,8 @@ VPE::VProperty* VPE::QVector3DProperty::clone(bool include_children, VProperty* if (!include_children) { - QList tmpChildren = container->getChildren(); - foreach (VProperty* tmpChild, tmpChildren) + const QList tmpChildren = container->getChildren(); + for (auto tmpChild : tmpChildren) { container->removeChild(tmpChild); delete tmpChild; diff --git a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp index e335f048f..373298be9 100644 --- a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp +++ b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp @@ -245,7 +245,7 @@ bool VPE::VFileEditWidget::checkFileFilter(const QString& file) const return false; } - foreach(QString tmpFilter, FilterList) + for (auto &tmpFilter : FilterList) { QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard); if (tmpRegExpFilter.exactMatch(file)) diff --git a/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp b/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp index 7ca8d3d4d..53836d1f1 100644 --- a/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp @@ -114,8 +114,8 @@ VPE::VProperty *VPE::VPointFProperty::clone(bool include_children, VProperty *co if (!include_children) { - QList tmpChildren = container->getChildren(); - foreach(VProperty* tmpChild, tmpChildren) + const QList tmpChildren = container->getChildren(); + for(auto tmpChild : tmpChildren) { container->removeChild(tmpChild); delete tmpChild; diff --git a/src/libs/vpropertyexplorer/vproperty.cpp b/src/libs/vpropertyexplorer/vproperty.cpp index 7dde4ee8c..d215b53cf 100644 --- a/src/libs/vpropertyexplorer/vproperty.cpp +++ b/src/libs/vpropertyexplorer/vproperty.cpp @@ -350,9 +350,11 @@ QMap VPE::VProperty::getSettings() const { QMap tmpResult; - QStringList tmpKeyList = getSettingKeys(); - foreach(const QString& tmpKey, tmpKeyList) + const QStringList tmpKeyList = getSettingKeys(); + for(auto &tmpKey : tmpKeyList) + { tmpResult.insert(tmpKey, getSetting(tmpKey)); + } return tmpResult; } @@ -392,8 +394,11 @@ VPE::VProperty* VPE::VProperty::clone(bool include_children, VProperty* containe if (include_children) { - foreach(VProperty* tmpChild, d_ptr->Children) + const QList children = d_ptr->Children; + for (auto tmpChild : children) + { container->addChild(tmpChild->clone(true)); + } } return container; diff --git a/src/libs/vpropertyexplorer/vpropertyformview.cpp b/src/libs/vpropertyexplorer/vpropertyformview.cpp index cc67ff2e5..aa35ed96a 100644 --- a/src/libs/vpropertyexplorer/vpropertyformview.cpp +++ b/src/libs/vpropertyexplorer/vpropertyformview.cpp @@ -213,9 +213,9 @@ void VPE::VPropertyFormView::connectPropertyFormWidget(VPropertyFormWidget *widg connect(widget, &VPropertyFormWidget::propertyDataSubmitted, this, &VPropertyFormView::dataSubmitted, Qt::UniqueConnection); - QList tmpList = widget->getChildPropertyFormWidgets(); + const QList tmpList = widget->getChildPropertyFormWidgets(); - foreach(VPropertyFormWidget* tmpEditorWidget, tmpList) + for (auto tmpEditorWidget : tmpList) { connectPropertyFormWidget(tmpEditorWidget); } diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp index b5feaa446..88aac1571 100644 --- a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp @@ -268,8 +268,8 @@ void VPE::VPropertyFormWidget::setCommitBehaviour(bool auto_commit) { d_ptr->UpdateEditors = auto_commit; - QList tmpChildFormWidgets = getChildPropertyFormWidgets(); - foreach(VPropertyFormWidget* tmpChild, tmpChildFormWidgets) + const QList tmpChildFormWidgets = getChildPropertyFormWidgets(); + for (auto tmpChild : tmpChildFormWidgets) { if (tmpChild) { @@ -281,7 +281,7 @@ void VPE::VPropertyFormWidget::setCommitBehaviour(bool auto_commit) QList VPE::VPropertyFormWidget::getChildPropertyFormWidgets() const { QList tmpResult; - foreach(const VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget, d_ptr->EditorWidgets) + for (auto &tmpEditorWidget : d_ptr->EditorWidgets) { if (tmpEditorWidget.FormWidget) { diff --git a/src/libs/vpropertyexplorer/vpropertyset.cpp b/src/libs/vpropertyexplorer/vpropertyset.cpp index 0a7ca39d8..f1a1ca355 100644 --- a/src/libs/vpropertyexplorer/vpropertyset.cpp +++ b/src/libs/vpropertyexplorer/vpropertyset.cpp @@ -204,9 +204,11 @@ VPE::VPropertySet* VPE::VPropertySet::clone() const { VPropertySet* tmpResult = new VPropertySet(); - foreach(VProperty* tmpProperty, d_ptr->RootProperties) + const QList rootProperties = d_ptr->RootProperties; + for (auto tmpProperty : rootProperties) + { cloneProperty(tmpProperty, nullptr, tmpResult); - + } return tmpResult; } @@ -219,7 +221,7 @@ bool VPE::VPropertySet::hasProperty(VProperty *property, VProperty *parent) cons } const QList& tmpChildrenList = (parent != nullptr ? parent->getChildren() : d_ptr->RootProperties); - foreach(VProperty* tmpProp, tmpChildrenList) + for(auto tmpProp : tmpChildrenList) { if (tmpProp && (tmpProp == property || hasProperty(property, tmpProp))) { @@ -253,13 +255,17 @@ void VPE::VPropertySet::cloneProperty(VProperty* property_to_clone, VProperty *p void VPE::VPropertySet::removePropertyFromSet(VProperty *prop) { // Remove all the children - foreach(VProperty* tmpChild, prop->getChildren()) + const QList& children = prop->getChildren(); + for (auto tmpChild : children) + { removeProperty(tmpChild); + } - - QList tmpKeys = d_ptr->Properties.keys(prop); - foreach(const QString& tmpID, tmpKeys) + const QList tmpKeys = d_ptr->Properties.keys(prop); + for (auto &tmpID : tmpKeys) + { d_ptr->Properties.remove(tmpID); + } // Remove from list d_ptr->RootProperties.removeAll(prop); diff --git a/src/libs/vpropertyexplorer/vserializedproperty.cpp b/src/libs/vpropertyexplorer/vserializedproperty.cpp index 83361e2ce..0f74672ef 100644 --- a/src/libs/vpropertyexplorer/vserializedproperty.cpp +++ b/src/libs/vpropertyexplorer/vserializedproperty.cpp @@ -61,7 +61,7 @@ void VPE::VSerializedProperty::initChildren(const VProperty *property, const VPr if (property && set) { const QList& tmpChildren = property->getChildren(); - foreach(const VProperty* tmpChild, tmpChildren) + for (auto tmpChild : tmpChildren) { QString tmpChildID = set->getPropertyID(property); Children.append(VSerializedProperty(tmpChild, tmpChildID, set)); diff --git a/src/libs/vtest/abstracttest.cpp b/src/libs/vtest/abstracttest.cpp index 81560bf62..f815b3d53 100644 --- a/src/libs/vtest/abstracttest.cpp +++ b/src/libs/vtest/abstracttest.cpp @@ -163,9 +163,9 @@ bool AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg return false; } QDir sourceDir(srcFilePath); - QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | - QDir::System); - foreach (const QString &fileName, fileNames) + const QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | + QDir::Hidden | QDir::System); + for (auto &fileName : fileNames) { const QString newSrcFilePath = srcFilePath + QDir::separator() + fileName; const QString newTgtFilePath = tgtFilePath + QDir::separator() + fileName; diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index 6f4d388a5..cb4d7cbcd 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -106,7 +106,7 @@ QPointF GetOriginPoint(const QVector objects, const VContainer *data, q originObjects.append(data->GeometricObject(id)->GetPoints()); #else const QVector points = data->GeometricObject(id)->GetPoints(); - foreach (const QPointF &point, points) + for (auto &point : points) { originObjects.append(point); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index e0d011c2f..639205179 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -174,7 +174,7 @@ void VAbstractSpline::AllowHover(bool enabled) // Manually handle hover events. Need for setting cursor for not selectable paths. m_acceptHoverEvents = enabled; - foreach (auto *point, controlPoints) + for (auto point : qAsConst(controlPoints)) { point->setAcceptHoverEvents(enabled); } @@ -185,7 +185,7 @@ void VAbstractSpline::AllowSelecting(bool enabled) { setFlag(QGraphicsItem::ItemIsSelectable, enabled); - foreach (auto *point, controlPoints) + for (auto point : qAsConst(controlPoints)) { point->setFlag(QGraphicsItem::ItemIsSelectable, enabled); } @@ -424,7 +424,7 @@ void VAbstractSpline::CurveSelected(bool selected) { setSelected(selected); - foreach (auto *point, controlPoints) + for (auto point : qAsConst(controlPoints)) { point->blockSignals(true); point->setSelected(selected); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 13068ea6b..6720c7955 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -294,7 +294,7 @@ void VToolSpline::EnableToolMove(bool move) { this->setFlag(QGraphicsItem::ItemIsMovable, move); - foreach (auto *point, controlPoints) + for (auto point : qAsConst(controlPoints)) { point->setFlag(QGraphicsItem::ItemIsMovable, move); } @@ -562,7 +562,7 @@ bool VToolSpline::IsMovable() const void VToolSpline::RefreshCtrlPoints() { // Very important to disable control points. Without it the pogram can't move the curve. - foreach (auto *point, controlPoints) + for (auto point : qAsConst(controlPoints)) { point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); } @@ -595,7 +595,7 @@ void VToolSpline::RefreshCtrlPoints() controlPoints[0]->blockSignals(false); controlPoints[1]->blockSignals(false); - foreach (auto *point, controlPoints) + for (auto point : qAsConst(controlPoints)) { point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index 115b415d4..ea1c306a0 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -293,7 +293,7 @@ void VToolSplinePath::EnableToolMove(bool move) { this->setFlag(QGraphicsItem::ItemIsMovable, move); - foreach (auto *point, controlPoints) + for (auto point : qAsConst(controlPoints)) { point->setFlag(QGraphicsItem::ItemIsMovable, move); } @@ -727,7 +727,7 @@ bool VToolSplinePath::IsMovable(int index) const void VToolSplinePath::RefreshCtrlPoints() { // Very important to disable control points. Without it the pogram can't move the curve. - foreach (auto *point, controlPoints) + for (auto point : qAsConst(controlPoints)) { point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); } @@ -765,7 +765,7 @@ void VToolSplinePath::RefreshCtrlPoints() controlPoints[j-1]->blockSignals(false); } - foreach (auto *point, controlPoints) + for (auto point : qAsConst(controlPoints)) { point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index a29575c49..0ff72cf84 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1442,7 +1442,7 @@ void VToolSeamAllowance::SaveDialogChange(const QString &undoText) { qApp->getUndoStack()->beginMacro(undoText.isEmpty() ? saveCommand->text(): undoText); - foreach (QUndoCommand* command, undocommands) + for (auto command : undocommands) { qApp->getUndoStack()->push(command); } diff --git a/src/libs/vwidgets/fancytabbar/fancytabbar.cpp b/src/libs/vwidgets/fancytabbar/fancytabbar.cpp index 41779ecd9..de76c60ad 100644 --- a/src/libs/vwidgets/fancytabbar/fancytabbar.cpp +++ b/src/libs/vwidgets/fancytabbar/fancytabbar.cpp @@ -88,7 +88,7 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const if (words.size() > 1) { QString sentence; - foreach(const QString & word, words) + for (auto &word : words) { sentence = sentence.isEmpty() ? sentence = word : sentence + QLatin1Char(' ') + word; diff --git a/src/libs/vwidgets/fancytabbar/stylehelper.cpp b/src/libs/vwidgets/fancytabbar/stylehelper.cpp index 98c43c3ca..3e5b0660a 100644 --- a/src/libs/vwidgets/fancytabbar/stylehelper.cpp +++ b/src/libs/vwidgets/fancytabbar/stylehelper.cpp @@ -114,7 +114,8 @@ void StyleHelper::setBaseColor(const QColor &newcolor) if (color.isValid() && color != m_baseColor) { m_baseColor = color; - foreach (QWidget *w, QApplication::topLevelWidgets()) + const QWidgetList widgets = QApplication::topLevelWidgets(); + for (auto w : widgets) { w->update(); } diff --git a/src/libs/vwidgets/vmaingraphicsscene.cpp b/src/libs/vwidgets/vmaingraphicsscene.cpp index 1f4a59a4e..f8928304e 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.cpp +++ b/src/libs/vwidgets/vmaingraphicsscene.cpp @@ -209,7 +209,7 @@ void VMainGraphicsScene::InitOrigins() //--------------------------------------------------------------------------------------------------------------------- void VMainGraphicsScene::SetOriginsVisible(bool visible) { - foreach (QGraphicsItem *item, origins) + for (auto item : qAsConst(origins)) { item->setVisible(visible); } @@ -225,7 +225,8 @@ QPointF VMainGraphicsScene::getScenePos() const QRectF VMainGraphicsScene::VisibleItemsBoundingRect() const { QRectF rect; - foreach(QGraphicsItem *item, items()) + const QList qItems = items(); + for (auto item : qItems) { if(not item->isVisible()) { diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index fa4ce6629..febf9707d 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -692,7 +692,8 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG else { QRectF rect = item->sceneBoundingRect(); - foreach(QGraphicsItem *child, item->childItems()) + const QList children = item->childItems(); + for (auto child : children) { if(child->isVisible()) { diff --git a/src/test/TranslationsTest/qttestmainlambda.cpp b/src/test/TranslationsTest/qttestmainlambda.cpp index f6f28f2c7..7e41972bd 100644 --- a/src/test/TranslationsTest/qttestmainlambda.cpp +++ b/src/test/TranslationsTest/qttestmainlambda.cpp @@ -51,16 +51,16 @@ int main(int argc, char** argv) ASSERT_TEST(new TST_TSTranslation()); const QStringList locales = SupportedLocales(); - for(int l = 0, sz = locales.size(); l < sz; ++l) + for(auto &locale : locales) { for(quint32 s = 0; s < TST_MeasurementRegExp::systemCounts; ++s) { - ASSERT_TEST(new TST_MeasurementRegExp(s, locales.at(l))); + ASSERT_TEST(new TST_MeasurementRegExp(s, locale)); } - ASSERT_TEST(new TST_TSLocaleTranslation(locales.at(l))); - ASSERT_TEST(new TST_BuitInRegExp(locales.at(l))); - ASSERT_TEST(new TST_QmuParserErrorMsg(locales.at(l))); + ASSERT_TEST(new TST_TSLocaleTranslation(locale)); + ASSERT_TEST(new TST_BuitInRegExp(locale)); + ASSERT_TEST(new TST_QmuParserErrorMsg(locale)); } return status; diff --git a/src/test/TranslationsTest/tst_buitinregexp.cpp b/src/test/TranslationsTest/tst_buitinregexp.cpp index d5a817b24..b55386dc9 100644 --- a/src/test/TranslationsTest/tst_buitinregexp.cpp +++ b/src/test/TranslationsTest/tst_buitinregexp.cpp @@ -183,11 +183,11 @@ void TST_BuitInRegExp::TestCheckInternalVaribleRegExp_data() QTest::addColumn("var"); QTest::addColumn("originalName"); - foreach(const QString &var, builInVariables) + for (auto &var : qAsConst(builInVariables)) { const QString tag = QString("Locale: '%1'. Var '%2'").arg(m_locale, var); const QStringList originalNames = AllNames(); - foreach(const QString &str, originalNames) + for (auto &str : originalNames) { QTest::newRow(qUtf8Printable(tag)) << var << str; } @@ -254,7 +254,7 @@ void TST_BuitInRegExp::PrepareData() QTest::addColumn("originalName"); - foreach(const QString &str, originalNames) + for (auto &str : originalNames) { const QString tag = QString("Locale: '%1'. Name '%2'").arg(m_locale, str); QTest::newRow(qUtf8Printable(tag)) << str; diff --git a/src/test/TranslationsTest/tst_measurementregexp.cpp b/src/test/TranslationsTest/tst_measurementregexp.cpp index cdb2cb928..6ce6579f3 100644 --- a/src/test/TranslationsTest/tst_measurementregexp.cpp +++ b/src/test/TranslationsTest/tst_measurementregexp.cpp @@ -170,7 +170,7 @@ void TST_MeasurementRegExp::PrepareData() QTest::addColumn("originalName"); - foreach(const QString &str, originalNames) + for (auto &str : originalNames) { const QString tag = QString("System: '%1', locale: '%2'. Name '%3'").arg(m_system, m_locale, str); QTest::newRow(qUtf8Printable(tag)) << str; diff --git a/src/test/ValentinaTest/tst_nameregexp.cpp b/src/test/ValentinaTest/tst_nameregexp.cpp index 4432a3557..c4b199f2c 100644 --- a/src/test/ValentinaTest/tst_nameregexp.cpp +++ b/src/test/ValentinaTest/tst_nameregexp.cpp @@ -169,7 +169,7 @@ void TST_NameRegExp::TestOriginalMeasurementNamesRegExp_data() QTest::addColumn("str"); const QStringList originalNames = AllGroupNames(); - foreach(const QString &str, originalNames) + for (auto &str : originalNames) { const QString name = QString("Measurement '%1'").arg(str); QTest::newRow(qUtf8Printable(name)) << str; diff --git a/src/test/ValentinaTest/tst_vcommandline.cpp b/src/test/ValentinaTest/tst_vcommandline.cpp index e3d0ce402..3f7a995e3 100644 --- a/src/test/ValentinaTest/tst_vcommandline.cpp +++ b/src/test/ValentinaTest/tst_vcommandline.cpp @@ -48,7 +48,7 @@ void TST_VCommandLine::UniqueKeys() const QStringList options = AllKeys(); QSet unique; - foreach(const QString &str, options) + for (auto &str : options) { const QString message = QString("Options '%1' is not unique!").arg(str); QVERIFY2(not unique.contains(str), qUtf8Printable(message));