From fe5a58beefc70985076d6199f864127a05ad63a1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 2 Apr 2018 16:43:02 +0300 Subject: [PATCH 01/11] Fix unused lambda capture. --HG-- branch : develop --- src/app/tape/tmainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index ab49b7ef7..a32825a03 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -2977,7 +2977,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) SCASSERT(menu != nullptr) QAction *action = menu->addAction(tr("&New Window")); - connect(action, &QAction::triggered, this, [this]() + connect(action, &QAction::triggered, this, []() { qApp->NewMainWindow(); qApp->MainWindow()->activateWindow(); @@ -3237,7 +3237,7 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv) return; } - auto ConverToDouble = [this](QString text, const QString &error) + auto ConverToDouble = [](QString text, const QString &error) { text = VTranslateVars::TryFormulaFromUser(text, qApp->Settings()->GetOsSeparator()); bool ok = false; From 218c2cc51822fe9d28814680fe916d874fe53631 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 2 Apr 2018 16:49:53 +0300 Subject: [PATCH 02/11] Resolved issue #830. Seam allowance tool - object selection and preview. --HG-- branch : develop --- src/libs/vpatterndb/vpiece.cpp | 13 +++- src/libs/vpatterndb/vpiece.h | 3 + src/libs/vpatterndb/vpiecepath.cpp | 67 +++++++++++++++++-- src/libs/vpatterndb/vpiecepath.h | 10 +-- .../tools/piece/dialogseamallowance.cpp | 21 +++--- src/libs/vtools/tools/vtoolseamallowance.cpp | 4 +- .../visualization/path/vistoolpiece.cpp | 35 ++++++++-- .../vtools/visualization/path/vistoolpiece.h | 3 + .../vtools/visualization/visualization.cpp | 65 +++++++++++++----- src/libs/vtools/visualization/visualization.h | 4 +- 10 files changed, 182 insertions(+), 43 deletions(-) diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 3a8dd9c27..c6354948e 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -463,10 +463,21 @@ QVector VPiece::PlaceLabelPoints(const VContainer *data) const return points; } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::CurvesPainterPath(const VContainer *data) const +{ + return GetPath().CurvesPainterPath(data); +} + //--------------------------------------------------------------------------------------------------------------------- QPainterPath VPiece::MainPathPath(const VContainer *data) const { - const QVector points = MainPathPoints(data); + return MainPathPath(MainPathPoints(data)); +} + +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VPiece::MainPathPath(const QVector &points) const +{ QPainterPath path; if (not points.isEmpty()) diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index dbaa7c01b..b372c7056 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -74,7 +74,10 @@ public: const QVector &seamAllowance = QVector()) const; QVector PlaceLabelPoints(const VContainer *data) const; + QVector CurvesPainterPath(const VContainer *data) const; + QPainterPath MainPathPath(const VContainer *data) const; + QPainterPath MainPathPath(const QVector &points) const; QPainterPath SeamAllowancePath(const VContainer *data) const; QPainterPath SeamAllowancePath(const QVector &points) const; QPainterPath PassmarksPath(const VContainer *data, diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 24fbd649c..9b3723970 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -128,6 +128,20 @@ int IndexOfNode(const QVector &list, quint32 id) qDebug()<<"Can't find node."; return -1; } + +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath MakePainterPath(const QVector &points) +{ + QPainterPath path; + + if (not points.isEmpty()) + { + path.addPolygon(QPolygonF(points)); + path.setFillRule(Qt::WindingFill); + } + + return path; +} } //--------------------------------------------------------------------------------------------------------------------- @@ -332,6 +346,41 @@ QVector VPiecePath::PathNodePoints(const VContainer *data, bool showExc return points; } +//--------------------------------------------------------------------------------------------------------------------- +QVector > VPiecePath::PathCurvePoints(const VContainer *data) const +{ + QVector > curves; + for (int i = 0; i < CountNodes(); ++i) + { + if (at(i).IsExcluded()) + { + continue;// skip excluded node + } + + switch (at(i).GetTypeTool()) + { + case (Tool::NodeArc): + case (Tool::NodeElArc): + case (Tool::NodeSpline): + case (Tool::NodeSplinePath): + { + const QSharedPointer curve = data->GeometricObject(at(i).GetId()); + + const QPointF begin = StartSegment(data, i, at(i).GetReverse()); + const QPointF end = EndSegment(data, i, at(i).GetReverse()); + + curves.append(curve->GetSegmentPoints(begin, end, at(i).GetReverse())); + break; + } + case (Tool::NodePoint): + default: + break; + } + } + + return curves; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VPiecePath::SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const { @@ -374,16 +423,20 @@ QVector VPiecePath::SeamAllowancePoints(const VContainer *data, qreal //--------------------------------------------------------------------------------------------------------------------- QPainterPath VPiecePath::PainterPath(const VContainer *data) const { - const QVector points = PathPoints(data); - QPainterPath path; + return MakePainterPath(PathPoints(data)); +} - if (not points.isEmpty()) +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiecePath::CurvesPainterPath(const VContainer *data) const +{ + const QVector > curves = PathCurvePoints(data); + QVector paths(curves.size()); + + for(auto &curve : curves) { - path.addPolygon(QPolygonF(points)); - path.setFillRule(Qt::WindingFill); + paths.append(MakePainterPath(curve)); } - - return path; + return paths; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index 04fbb9b6e..a107a4eeb 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -85,11 +85,13 @@ public: QString GetVisibilityTrigger() const; void SetVisibilityTrigger(const QString &formula); - QVector PathPoints(const VContainer *data) const; - QVector PathNodePoints(const VContainer *data, bool showExcluded = true) const; - QVector SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const; + QVector PathPoints(const VContainer *data) const; + QVector PathNodePoints(const VContainer *data, bool showExcluded = true) const; + QVector > PathCurvePoints(const VContainer *data) const; + QVector SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const; - QPainterPath PainterPath(const VContainer *data) const; + QPainterPath PainterPath(const VContainer *data) const; + QVector CurvesPainterPath(const VContainer *data) const; QList Dependencies() const; QVector MissingNodes(const VPiecePath &path) const; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 9eb7daa91..67de20401 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -163,11 +163,6 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & flagMainPathIsValid = MainPathIsValid(); CheckState(); - if (not applyAllowed) - { - vis = new VisToolPiece(data); - } - m_ftb->SetCurrentIndex(TabOrder::Paths);// Show always first tab active on start. } @@ -203,6 +198,11 @@ void DialogSeamAllowance::EnableApply(bool enable) m_ftb->SetTabEnabled(TabOrder::Grainline, applyAllowed); m_ftb->SetTabEnabled(TabOrder::Passmarks, applyAllowed); m_ftb->SetTabEnabled(TabOrder::PlaceLabels, applyAllowed); + + if (not applyAllowed && vis.isNull()) + { + vis = new VisToolPiece(data); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -3028,10 +3028,13 @@ void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula) } uiTabPaths->plainTextEditFormulaWidth->setPlainText(width); - VisToolPiece *path = qobject_cast(vis); - SCASSERT(path != nullptr) - const VPiece p = CreatePiece(); - path->SetPiece(p); + if (not applyAllowed) + { + VisToolPiece *path = qobject_cast(vis); + SCASSERT(path != nullptr) + const VPiece p = CreatePiece(); + path->SetPiece(p); + } MoveCursorToEnd(uiTabPaths->plainTextEditFormulaWidth); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index e9c0ef4f0..edc784cb3 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1355,7 +1355,9 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); const VPiece detail = VAbstractTool::data.GetPiece(m_id); - QFuture futurePath = QtConcurrent::run(detail, &VPiece::MainPathPath, this->getData()); + QFuture futurePath = QtConcurrent::run(detail, + QOverload::of(&VPiece::MainPathPath), + this->getData()); QFuture > futureSeamAllowance; if (detail.IsSeamAllowance()) diff --git a/src/libs/vtools/visualization/path/vistoolpiece.cpp b/src/libs/vtools/visualization/path/vistoolpiece.cpp index 486e5afa3..256950208 100644 --- a/src/libs/vtools/visualization/path/vistoolpiece.cpp +++ b/src/libs/vtools/visualization/path/vistoolpiece.cpp @@ -35,13 +35,15 @@ VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent) : VisPath(data, parent), m_points(), + m_curves(), m_line1(nullptr), m_line2(nullptr), m_piece(), m_pieceCached(false), m_cachedMainPath(), m_cachedNodes(), - m_cachedMainPathPoints() + m_cachedMainPathPoints(), + m_cachedCurvesPath() { m_line1 = InitItem(supportColor, this); m_line2 = InitItem(supportColor, this); @@ -56,11 +58,16 @@ void VisToolPiece::RefreshGeometry() { if (not m_pieceCached) { - m_cachedMainPath = m_piece.MainPathPath(Visualization::data); m_cachedNodes = m_piece.MainPathNodePoints(Visualization::data); if (mode == Mode::Creation) { + m_cachedCurvesPath = m_piece.CurvesPainterPath(Visualization::data); m_cachedMainPathPoints = m_piece.MainPathPoints(Visualization::data); + m_cachedMainPath = m_piece.MainPathPath(m_cachedMainPathPoints); + } + else + { + m_cachedMainPath = m_piece.MainPathPath(Visualization::data); } m_pieceCached = true; } @@ -75,6 +82,12 @@ void VisToolPiece::RefreshGeometry() if (mode == Mode::Creation) { + for (int i = 0; i < m_cachedCurvesPath.size(); ++i) + { + VCurvePathItem *path = GetCurve(static_cast(i), supportColor); + DrawPath(path, m_cachedCurvesPath.at(i), supportColor); + } + DrawLine(m_line1, QLineF(m_cachedMainPathPoints.first(), Visualization::scenePos), supportColor, Qt::DashLine); @@ -100,6 +113,12 @@ VScaledEllipse *VisToolPiece::GetPoint(quint32 i, const QColor &color) return GetPointItem(m_points, i, color, this); } +//--------------------------------------------------------------------------------------------------------------------- +VCurvePathItem *VisToolPiece::GetCurve(quint32 i, const QColor &color) +{ + return GetCurveItem(m_curves, i, color, this); +} + //--------------------------------------------------------------------------------------------------------------------- void VisToolPiece::HideAllItems() { @@ -113,9 +132,17 @@ void VisToolPiece::HideAllItems() m_line2->setVisible(false); } - for (int i=0; i < m_points.size(); ++i) + for(QGraphicsEllipseItem *item : qAsConst(m_points)) { - if (QGraphicsEllipseItem *item = m_points.at(i)) + if (item) + { + item->setVisible(false); + } + } + + for(QGraphicsPathItem *item : qAsConst(m_curves)) + { + if (item) { item->setVisible(false); } diff --git a/src/libs/vtools/visualization/path/vistoolpiece.h b/src/libs/vtools/visualization/path/vistoolpiece.h index dae2be9a3..39eb52c04 100644 --- a/src/libs/vtools/visualization/path/vistoolpiece.h +++ b/src/libs/vtools/visualization/path/vistoolpiece.h @@ -50,6 +50,7 @@ public: private: Q_DISABLE_COPY(VisToolPiece) QVector m_points; + QVector m_curves; VScaledLine *m_line1; VScaledLine *m_line2; @@ -58,8 +59,10 @@ private: QPainterPath m_cachedMainPath; QVector m_cachedNodes; QVector m_cachedMainPathPoints; + QVector m_cachedCurvesPath; VScaledEllipse* GetPoint(quint32 i, const QColor &color); + VCurvePathItem *GetCurve(quint32 i, const QColor &color); void HideAllItems(); }; diff --git a/src/libs/vtools/visualization/visualization.cpp b/src/libs/vtools/visualization/visualization.cpp index 657b13ce2..d0f84bbf7 100644 --- a/src/libs/vtools/visualization/visualization.cpp +++ b/src/libs/vtools/visualization/visualization.cpp @@ -59,6 +59,44 @@ template class QHash; Q_LOGGING_CATEGORY(vVis, "v.visualization") +namespace +{ +//--------------------------------------------------------------------------------------------------------------------- +VScaledEllipse *InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0) +{ + VScaledEllipse *point = new VScaledEllipse(parent); + point->setZValue(1); + point->setBrush(QBrush(Qt::NoBrush)); + + QPen visPen = point->pen(); + visPen.setColor(color); + + point->setPen(visPen); + point->setRect(PointRect(ScaledRadius(SceneScale(qApp->getCurrentScene())))); + point->setPos(QPointF()); + point->setFlags(QGraphicsItem::ItemStacksBehindParent); + point->setZValue(z); + point->setVisible(false); + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +VCurvePathItem *InitCurveItem(const QColor &color, QGraphicsItem *parent, qreal z = 0) +{ + VCurvePathItem *curve = new VCurvePathItem(parent); + curve->setBrush(QBrush(Qt::NoBrush)); + + QPen visPen = curve->pen(); + visPen.setColor(color); + curve->setPen(visPen); + + curve->setFlags(QGraphicsItem::ItemStacksBehindParent); + curve->setZValue(z); + curve->setVisible(false); + return curve; +} +} + //--------------------------------------------------------------------------------------------------------------------- Visualization::Visualization(const VContainer *data) :QObject(), @@ -261,22 +299,19 @@ VScaledEllipse *Visualization::GetPointItem(QVector &points, q } //--------------------------------------------------------------------------------------------------------------------- -VScaledEllipse *Visualization::InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z) +VCurvePathItem *Visualization::GetCurveItem(QVector &curves, quint32 i, const QColor &color, + QGraphicsItem *parent) { - VScaledEllipse *point = new VScaledEllipse(parent); - point->setZValue(1); - point->setBrush(QBrush(Qt::NoBrush)); - - QPen visPen = point->pen(); - visPen.setColor(color); - - point->setPen(visPen); - point->setRect(PointRect(ScaledRadius(SceneScale(qApp->getCurrentScene())))); - point->setPos(QPointF()); - point->setFlags(QGraphicsItem::ItemStacksBehindParent); - point->setZValue(z); - point->setVisible(false); - return point; + if (not curves.isEmpty() && static_cast(curves.size() - 1) >= i) + { + return curves.at(static_cast(i)); + } + else + { + auto point = InitCurveItem(color, parent); + curves.append(point); + return point; + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/visualization.h b/src/libs/vtools/visualization/visualization.h index c10b7b4a9..106a7d557 100644 --- a/src/libs/vtools/visualization/visualization.h +++ b/src/libs/vtools/visualization/visualization.h @@ -114,10 +114,10 @@ protected: static VScaledEllipse *GetPointItem(QVector &points, quint32 i, const QColor &color, QGraphicsItem *parent); + static VCurvePathItem *GetCurveItem(QVector &curves, quint32 i, const QColor &color, + QGraphicsItem *parent); private: Q_DISABLE_COPY(Visualization) - - static VScaledEllipse* InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0); }; //--------------------------------------------------------------------------------------------------------------------- From 4eaf556342b1eeb2c6dd0e9388242f71ed7c99fb Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 2 Apr 2018 17:05:53 +0300 Subject: [PATCH 03/11] Cppcheck warning. --HG-- branch : develop --- src/libs/vpatterndb/vpiece.cpp | 4 ++-- src/libs/vpatterndb/vpiece.h | 5 +++-- src/libs/vtools/visualization/path/vistoolpiece.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index c6354948e..e7adc718a 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -472,11 +472,11 @@ QVector VPiece::CurvesPainterPath(const VContainer *data) const //--------------------------------------------------------------------------------------------------------------------- QPainterPath VPiece::MainPathPath(const VContainer *data) const { - return MainPathPath(MainPathPoints(data)); + return VPiece::MainPathPath(MainPathPoints(data)); } //--------------------------------------------------------------------------------------------------------------------- -QPainterPath VPiece::MainPathPath(const QVector &points) const +QPainterPath VPiece::MainPathPath(const QVector &points) { QPainterPath path; diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index b372c7056..9ea26cc95 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -76,8 +76,9 @@ public: QVector CurvesPainterPath(const VContainer *data) const; - QPainterPath MainPathPath(const VContainer *data) const; - QPainterPath MainPathPath(const QVector &points) const; + QPainterPath MainPathPath(const VContainer *data) const; + static QPainterPath MainPathPath(const QVector &points); + QPainterPath SeamAllowancePath(const VContainer *data) const; QPainterPath SeamAllowancePath(const QVector &points) const; QPainterPath PassmarksPath(const VContainer *data, diff --git a/src/libs/vtools/visualization/path/vistoolpiece.cpp b/src/libs/vtools/visualization/path/vistoolpiece.cpp index 256950208..2065e5ec5 100644 --- a/src/libs/vtools/visualization/path/vistoolpiece.cpp +++ b/src/libs/vtools/visualization/path/vistoolpiece.cpp @@ -63,7 +63,7 @@ void VisToolPiece::RefreshGeometry() { m_cachedCurvesPath = m_piece.CurvesPainterPath(Visualization::data); m_cachedMainPathPoints = m_piece.MainPathPoints(Visualization::data); - m_cachedMainPath = m_piece.MainPathPath(m_cachedMainPathPoints); + m_cachedMainPath = VPiece::MainPathPath(m_cachedMainPathPoints); } else { From 3252130f364bc98faf823535bb77d28a218be6dd Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 2 Apr 2018 20:38:56 +0300 Subject: [PATCH 04/11] Refactoring. Use C++11 range-based loop. --HG-- branch : develop --- src/app/tape/tmainwindow.cpp | 30 +++++++++---------- .../valentina/dialogs/dialogincrements.cpp | 7 ++--- .../dialogs/dialoglayoutsettings.cpp | 4 +-- .../dialogs/dialogpatternmaterials.cpp | 6 ++-- src/libs/qmuparser/qmudef.cpp | 18 +++++------ src/libs/vdxf/vdxfengine.cpp | 11 +++---- src/libs/vgeometry/vcubicbezierpath.cpp | 12 ++++---- src/libs/vlayout/vlayoutpiece.cpp | 9 +++--- src/libs/vpatterndb/vcontainer.cpp | 6 ++-- src/libs/vpatterndb/vpiece.cpp | 4 +-- src/libs/vpatterndb/vpiecepath.cpp | 8 ++--- src/libs/vtools/tools/vabstracttool.cpp | 8 ++--- src/libs/vtools/tools/vtoolseamallowance.cpp | 27 ++++++++--------- src/libs/vtools/tools/vtooluniondetails.cpp | 28 +++++++++-------- src/test/ValentinaTest/tst_nameregexp.cpp | 6 ++-- src/test/ValentinaTest/tst_qmutokenparser.cpp | 3 +- src/test/ValentinaTest/tst_readval.cpp | 3 +- src/test/ValentinaTest/tst_vtranslatevars.cpp | 12 ++++---- 18 files changed, 99 insertions(+), 103 deletions(-) diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index a32825a03..d529556ef 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -3207,18 +3207,18 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv) } } - for(int i=0; i < measurements.size(); ++i) + for(auto im : qAsConst(measurements)) { - m->AddEmpty(measurements.at(i).name, measurements.at(i).value); + m->AddEmpty(im.name, im.value); - if (not measurements.at(i).fullName.isEmpty()) + if (not im.fullName.isEmpty()) { - m->SetMFullName(measurements.at(i).name, measurements.at(i).fullName); + m->SetMFullName(im.name, im.fullName); } - if (not measurements.at(i).description.isEmpty()) + if (not im.description.isEmpty()) { - m->SetMDescription(measurements.at(i).name, measurements.at(i).description); + m->SetMDescription(im.name, im.description); } } @@ -3317,21 +3317,21 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv) } } - for(int i=0; i < measurements.size(); ++i) + for(auto mm : qAsConst(measurements)) { - m->AddEmpty(measurements.at(i).name); - m->SetMBaseValue(measurements.at(i).name, measurements.at(i).base); - m->SetMSizeIncrease(measurements.at(i).name, measurements.at(i).sizeIncrease); - m->SetMHeightIncrease(measurements.at(i).name, measurements.at(i).heightIncrease); + m->AddEmpty(mm.name); + m->SetMBaseValue(mm.name, mm.base); + m->SetMSizeIncrease(mm.name, mm.sizeIncrease); + m->SetMHeightIncrease(mm.name, mm.heightIncrease); - if (not measurements.at(i).fullName.isEmpty()) + if (not mm.fullName.isEmpty()) { - m->SetMFullName(measurements.at(i).name, measurements.at(i).fullName); + m->SetMFullName(mm.name, mm.fullName); } - if (not measurements.at(i).description.isEmpty()) + if (not mm.description.isEmpty()) { - m->SetMDescription(measurements.at(i).name, measurements.at(i).description); + m->SetMDescription(mm.name, mm.description); } } diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index e388b0946..d623a1cec 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -585,15 +585,14 @@ bool DialogIncrements::IncrementUsed(const QString &name) const { const QVector expressions = doc->ListExpressions(); - for(int i = 0; i < expressions.size(); ++i) + for(auto field : expressions) { - if (expressions.at(i).expression.indexOf(name) != -1) + if (field.expression.indexOf(name) != -1) { // Eval formula try { - QScopedPointer cal(new qmu::QmuTokenParser(expressions.at(i).expression, false, - false)); + QScopedPointer cal(new qmu::QmuTokenParser(field.expression, false, false)); // Tokens (variables, measurements) if (cal->GetTokens().values().contains(name)) diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 95fd20c3d..6324c1572 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -746,9 +746,9 @@ void DialogLayoutSettings::InitPrinter() QStringList printerNames; #if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) const QList printers = QPrinterInfo::availablePrinters(); - for(int i = 0; i < printers.size(); ++i) + for(auto printer : printers) { - const QString name = printers.at(i).printerName(); + const QString name = printer.printerName(); if (not name.isEmpty()) { printerNames.append(name); diff --git a/src/app/valentina/dialogs/dialogpatternmaterials.cpp b/src/app/valentina/dialogs/dialogpatternmaterials.cpp index 73e9a90fb..3db107744 100644 --- a/src/app/valentina/dialogs/dialogpatternmaterials.cpp +++ b/src/app/valentina/dialogs/dialogpatternmaterials.cpp @@ -44,11 +44,11 @@ QStringList PrepareKnowMaterials(const QStringList &patternMaterials, bool remem if (rememberPM) { - for(int i=0; i < patternMaterials.size(); ++i) + for(auto &patternMaterial : patternMaterials) { - if (not patternMaterials.at(i).isEmpty() && not knownMaterials.contains(patternMaterials.at(i))) + if (not patternMaterial.isEmpty() && not knownMaterials.contains(patternMaterial)) { - knownMaterials.append(patternMaterials.at(i)); + knownMaterials.append(patternMaterial); } } } diff --git a/src/libs/qmuparser/qmudef.cpp b/src/libs/qmuparser/qmudef.cpp index 92eee1476..0233e1d65 100644 --- a/src/libs/qmuparser/qmudef.cpp +++ b/src/libs/qmuparser/qmudef.cpp @@ -292,26 +292,26 @@ QString NameRegExp() QString decimalPoints; QString groupSeparators; - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - if (not positiveSigns.contains(allLocales.at(i).positiveSign())) + if (not positiveSigns.contains(locale.positiveSign())) { - positiveSigns.append(allLocales.at(i).positiveSign()); + positiveSigns.append(locale.positiveSign()); } - if (not negativeSigns.contains(allLocales.at(i).negativeSign())) + if (not negativeSigns.contains(locale.negativeSign())) { - negativeSigns.append(allLocales.at(i).negativeSign()); + negativeSigns.append(locale.negativeSign()); } - if (not decimalPoints.contains(allLocales.at(i).decimalPoint())) + if (not decimalPoints.contains(locale.decimalPoint())) { - decimalPoints.append(allLocales.at(i).decimalPoint()); + decimalPoints.append(locale.decimalPoint()); } - if (not groupSeparators.contains(allLocales.at(i).groupSeparator())) + if (not groupSeparators.contains(locale.groupSeparator())) { - groupSeparators.append(allLocales.at(i).groupSeparator()); + groupSeparators.append(locale.groupSeparator()); } } diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 41b6b5e52..37dc493fa 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -622,10 +622,8 @@ bool VDxfEngine::ExportToAAMA(const QVector &details) ExportAAMAGlobalText(input, details); - for(int i = 0; i < details.size(); ++i) + for(auto &detail : details) { - const VLayoutPiece &detail = details.at(i); - dx_ifaceBlock *detailBlock = new dx_ifaceBlock(); QString blockName = detail.GetName(); @@ -736,11 +734,10 @@ void VDxfEngine::ExportAAMANotch(dx_ifaceBlock *detailBlock, const VLayoutPiece { if (detail.IsSeamAllowance()) { - QVector passmarks = detail.GetPassmarks(); - for(int i = 0; i < passmarks.size(); ++i) + const QVector passmarks = detail.GetPassmarks(); + for(auto passmark : passmarks) { - DRW_Entity *e = AAMALine(passmarks.at(i), "4"); - if (e) + if (DRW_Entity *e = AAMALine(passmark, "4")) { detailBlock->ent.push_back(e); } diff --git a/src/libs/vgeometry/vcubicbezierpath.cpp b/src/libs/vgeometry/vcubicbezierpath.cpp index ed3b716ff..58d49913c 100644 --- a/src/libs/vgeometry/vcubicbezierpath.cpp +++ b/src/libs/vgeometry/vcubicbezierpath.cpp @@ -83,9 +83,9 @@ VCubicBezierPath VCubicBezierPath::Rotate(const QPointF &originPoint, qreal degr { const QVector points = GetCubicPath(); VCubicBezierPath curve; - for(int i=0; i < points.size(); ++i) + for(auto &point : points) { - curve.append(points.at(i).Rotate(originPoint, degrees)); + curve.append(point.Rotate(originPoint, degrees)); } curve.setName(name() + prefix); curve.SetColor(GetColor()); @@ -99,9 +99,9 @@ VCubicBezierPath VCubicBezierPath::Flip(const QLineF &axis, const QString &prefi { const QVector points = GetCubicPath(); VCubicBezierPath curve; - for(int i=0; i < points.size(); ++i) + for(auto &point : points) { - curve.append(points.at(i).Flip(axis)); + curve.append(point.Flip(axis)); } curve.setName(name() + prefix); curve.SetColor(GetColor()); @@ -115,9 +115,9 @@ VCubicBezierPath VCubicBezierPath::Move(qreal length, qreal angle, const QString { const QVector points = GetCubicPath(); VCubicBezierPath curve; - for(int i=0; i < points.size(); ++i) + for(auto &point : points) { - curve.append(points.at(i).Move(length, angle)); + curve.append(point.Move(length, angle)); } curve.setName(name() + prefix); curve.SetColor(GetColor()); diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 006ea75c2..7b5f8b4ba 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -305,9 +305,9 @@ QVector CorrectPosition(const QRectF &parentBoundingRect, QVector PrepareAllowance(const QVector &points) { QVector allowancePoints; - for(int i = 0; i < points.size(); ++i) + for(auto point : points) { - allowancePoints.append(VSAPoint(points.at(i))); + allowancePoints.append(VSAPoint(point)); } return allowancePoints; } @@ -348,9 +348,10 @@ QStringList PieceLabelText(const QVector &labelShape, const VTextManage QVector ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern) { QVector labels; - for(int i=0; i < piece.GetPlaceLabels().size(); ++i) + const QVector placeLabels = piece.GetPlaceLabels(); + for(auto placeLabel : placeLabels) { - const auto label = pattern->GeometricObject(piece.GetPlaceLabels().at(i)); + const auto label = pattern->GeometricObject(placeLabel); VLayoutPlaceLabel layoutLabel; layoutLabel.shape = label->LabelShape(); layoutLabel.center = label->toQPointF(); diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index 1ee71abfd..1d16a0491 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -591,11 +591,11 @@ void VContainer::ClearUniqueIncrementNames() const QList list = uniqueNames.toList(); ClearUniqueNames(); - for(int i = 0; i < list.size(); ++i) + for(auto &name : list) { - if (not list.at(i).startsWith('#')) + if (not name.startsWith('#')) { - uniqueNames.insert(list.at(i)); + uniqueNames.insert(name); } } } diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index e7adc718a..941583c24 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -448,11 +448,11 @@ QVector VPiece::PassmarksLines(const VContainer *data, const QVector VPiece::PlaceLabelPoints(const VContainer *data) const { QVector points; - for(int i=0; i < d->m_placeLabels.size(); ++i) + for(auto placeLabel : d->m_placeLabels) { try { - const auto label = data->GeometricObject(d->m_placeLabels.at(i)); + const auto label = data->GeometricObject(placeLabel); points.append(label->LabelShape()); } catch (const VExceptionBadId &e) diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 9b3723970..b629ad35d 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -995,9 +995,9 @@ QVector VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, qreal w2 = end.GetSABefore(); if (w1 < 0 && w2 < 0) {// no local widths - for(int i = 0; i < points.size(); ++i) + for(auto point : points) { - VSAPoint p(points.at(i)); + VSAPoint p(point); if (i == 0) { // first point p.SetSAAfter(begin.GetSAAfter()); @@ -1036,9 +1036,9 @@ QVector VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, qreal length = 0; // how much we handle - for(int i = 1; i < points.size(); ++i) + for(auto point : points) { - p = VSAPoint(points.at(i)); + p = VSAPoint(point); if (i == points.size() - 1) {// last point diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index b788279a8..efd09b52e 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -411,12 +411,12 @@ void VAbstractTool::ToolCreation(const Source &typeCreation) //--------------------------------------------------------------------------------------------------------------------- VToolRecord VAbstractTool::GetRecord(const quint32 id, const Tool &toolType, VAbstractPattern *doc) { - QVector *history = doc->getHistory(); - for(int i = 0; i < history->size(); ++i) + const QVector *history = doc->getHistory(); + for(auto &record : *history) { - if (history->at(i).getId() == id && history->at(i).getTypeTool() == toolType) + if (record.getId() == id && record.getTypeTool() == toolType) { - return history->at(i); + return record; } } return VToolRecord(); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index edc784cb3..a29575c49 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1240,9 +1240,9 @@ void VToolSeamAllowance::keyReleaseEvent(QKeyEvent *event) { qApp->getUndoStack()->beginMacro(tr("multi deletion")); - for(int i=0; i < toolList.size(); ++i) + for(auto tool : toolList) { - toolList.at(i)->RemoveWithConfirm(false); + tool->RemoveWithConfirm(false); } } DeleteToolWithConfirm(false); @@ -1892,9 +1892,9 @@ QList VToolSeamAllowance::SelectedTools() const if (not list.isEmpty()) { - for(int i=0; i < list.size(); ++i) + for(auto item : list) { - VToolSeamAllowance *tool = qgraphicsitem_cast(list.at(i)); + VToolSeamAllowance *tool = qgraphicsitem_cast(item); if (tool != nullptr && tool->getId() != m_id) { tools.append(tool); @@ -2011,9 +2011,8 @@ QVector VToolSeamAllowance::DuplicateCustomSARecords(const QVect const QMap &replacements) { QVector newRecords; - for(int i=0; i < records.size(); ++i) + for(auto record : records) { - CustomSARecord record = records.at(i); record.path = DuplicatePiecePath(record.path, initData); record.startPoint = replacements.value(record.startPoint, NULL_ID); record.endPoint = replacements.value(record.endPoint, NULL_ID); @@ -2027,9 +2026,9 @@ QVector VToolSeamAllowance::DuplicateInternalPaths(const QVector newPaths; - for(int i=0; i < iPaths.size(); ++i) + for(auto iPath : iPaths) { - newPaths.append(DuplicatePiecePath(iPaths.at(i), initData)); + newPaths.append(DuplicatePiecePath(iPath, initData)); } return newPaths; } @@ -2039,11 +2038,11 @@ QVector VToolSeamAllowance::DuplicatePins(const QVector &pins, const VToolSeamAllowanceInitData &initData) { QVector newPins; - for(int i=0; i < pins.size(); ++i) + for(auto p : pins) { - QSharedPointer pin = initData.data->GeometricObject(pins.at(i)); + QSharedPointer pin = initData.data->GeometricObject(p); - VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(pins.at(i))); + VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(p)); SCASSERT(tool != nullptr) VToolPinInitData initNodeData; @@ -2068,10 +2067,10 @@ QVector VToolSeamAllowance::DuplicatePlaceLabels(const QVector const VToolSeamAllowanceInitData &initData) { QVector newPlaceLabels; - for(int i=0; i < placeLabels.size(); ++i) + for(auto placeLabel : placeLabels) { - QSharedPointer label = initData.data->GeometricObject(placeLabels.at(i)); - VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(placeLabels.at(i))); + QSharedPointer label = initData.data->GeometricObject(placeLabel); + VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(placeLabel)); SCASSERT(tool != nullptr) VToolPlaceLabelInitData initNodeData; diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index bf3a395db..9acbee524 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -1161,9 +1161,9 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector quint32 pRotate, qreal angle) { QVector nodeChildren; - for(int i=0; i < d.GetCustomSARecords().size(); ++i) + const QVector records = d.GetCustomSARecords(); + for(auto record : records) { - CustomSARecord record = d.GetCustomSARecords().at(i); const VPiecePath path = initData.data->GetPiecePath(record.path); VPiecePath newPath = path; newPath.Clear();//Clear nodes @@ -1220,9 +1220,10 @@ void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector qreal dy, quint32 pRotate, qreal angle) { QVector nodeChildren; - for(int i=0; i < d.GetInternalPaths().size(); ++i) + const QVector internalPaths = d.GetInternalPaths(); + for(auto iPath : internalPaths) { - const VPiecePath path = initData.data->GetPiecePath(d.GetInternalPaths().at(i)); + const VPiecePath path = initData.data->GetPiecePath(iPath); VPiecePath newPath = path; newPath.Clear();//Clear nodes @@ -1280,9 +1281,10 @@ void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector quint32 pRotate, qreal angle) { QVector nodeChildren; - for(int i=0; i < d.GetPins().size(); ++i) + const QVector pins = d.GetPins(); + for(auto pin : pins) { - const quint32 id = AddPin(d.GetPins().at(i), initData, children, drawName, dx, dy, pRotate, angle); + const quint32 id = AddPin(pin, initData, children, drawName, dx, dy, pRotate, angle); newDetail.GetPins().append(id); } children += nodeChildren; @@ -1294,10 +1296,10 @@ void CreateUnitedDetailPlaceLabels(VPiece &newDetail, const VPiece &d, QVector nodeChildren; - for(int i=0; i < d.GetPlaceLabels().size(); ++i) + const QVector placeLabels = d.GetPlaceLabels(); + for(auto placeLabel : placeLabels) { - const quint32 id = AddPlaceLabel(d.GetPlaceLabels().at(i), initData, children, drawName, dx, dy, pRotate, - angle); + const quint32 id = AddPlaceLabel(placeLabel, initData, children, drawName, dx, dy, pRotate, angle); newDetail.GetPlaceLabels().append(id); } children += nodeChildren; @@ -1645,9 +1647,9 @@ void VToolUnionDetails::incrementReferens() if (_referens == 1) { const QVector objects = GetReferenceObjects(); - for(int i = 0; i < objects.size(); ++i) + for(auto object : objects) { - doc->IncrementReferens(objects.at(i)); + doc->IncrementReferens(object); } QDomElement domElement = doc->elementById(m_id, getTagName()); @@ -1665,9 +1667,9 @@ void VToolUnionDetails::decrementReferens() if (_referens == 0) { const QVector objects = GetReferenceObjects(); - for(int i = 0; i < objects.size(); ++i) + for(auto object : objects) { - doc->DecrementReferens(objects.at(i)); + doc->DecrementReferens(object); } QDomElement domElement = doc->elementById(m_id, getTagName()); diff --git a/src/test/ValentinaTest/tst_nameregexp.cpp b/src/test/ValentinaTest/tst_nameregexp.cpp index abd79e3a5..4432a3557 100644 --- a/src/test/ValentinaTest/tst_nameregexp.cpp +++ b/src/test/ValentinaTest/tst_nameregexp.cpp @@ -49,14 +49,14 @@ void TST_NameRegExp::TestNameRegExp_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - INIT_LOCALE_VARIABLES(allLocales.at(i)); + INIT_LOCALE_VARIABLES(locale); Q_UNUSED(positiveSign) Q_UNUSED(expUpper) Q_UNUSED(expLower) - const QString localeName = allLocales.at(i).name(); + const QString localeName = locale.name(); QString tag = localeName+QLatin1String(". First character can't be ")+sign0; QTest::newRow(qUtf8Printable(tag)) << sign0+QLatin1String("a") << false; diff --git a/src/test/ValentinaTest/tst_qmutokenparser.cpp b/src/test/ValentinaTest/tst_qmutokenparser.cpp index 8650b571d..693baf289 100644 --- a/src/test/ValentinaTest/tst_qmutokenparser.cpp +++ b/src/test/ValentinaTest/tst_qmutokenparser.cpp @@ -84,9 +84,8 @@ void TST_QmuTokenParser::TokenFromUser_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - const QLocale locale = allLocales.at(i); PrepareVal(1000.5, locale); PrepareVal(-1000.5, locale); } diff --git a/src/test/ValentinaTest/tst_readval.cpp b/src/test/ValentinaTest/tst_readval.cpp index 7e46024ef..88a3ddae4 100644 --- a/src/test/ValentinaTest/tst_readval.cpp +++ b/src/test/ValentinaTest/tst_readval.cpp @@ -50,9 +50,8 @@ void TST_ReadVal::TestReadVal_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - const QLocale locale = allLocales.at(i); PrepareVal(1., locale); PrepareVal(1.0, locale); PrepareVal(-1.0, locale); diff --git a/src/test/ValentinaTest/tst_vtranslatevars.cpp b/src/test/ValentinaTest/tst_vtranslatevars.cpp index ad0d15a5a..5d9bd414b 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.cpp +++ b/src/test/ValentinaTest/tst_vtranslatevars.cpp @@ -58,10 +58,10 @@ void TST_VTranslateVars::TestFormulaFromUser_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - PrepareValFromUser(1000.5, allLocales.at(i)); - PrepareValFromUser(-1000.5, allLocales.at(i)); + PrepareValFromUser(1000.5, locale); + PrepareValFromUser(-1000.5, locale); } } @@ -88,10 +88,10 @@ void TST_VTranslateVars::TestFormulaToUser_data() const QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(int i = 0; i < allLocales.size(); ++i) + for(auto &locale : allLocales) { - PrepareValToUser(1000.5, allLocales.at(i)); - PrepareValToUser(-1000.5, allLocales.at(i)); + PrepareValToUser(1000.5, locale); + PrepareValToUser(-1000.5, locale); } } From 6b6a2632a95a29114eb9aecd5021eb753533b139 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 3 Apr 2018 11:15:58 +0300 Subject: [PATCH 05/11] 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)); From 0e3a9533afdb168149f6f75237028220d9b03f98 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 3 Apr 2018 14:36:38 +0300 Subject: [PATCH 06/11] Refactoring. Use C++11 range-based loop. --HG-- branch : develop --- src/app/tape/dialogs/dialogmdatabase.cpp | 4 +- src/app/tape/mapplication.cpp | 20 +++--- src/app/tape/tmainwindow.cpp | 40 ++++++------ src/app/valentina/core/vapplication.cpp | 3 +- .../core/vtooloptionspropertybrowser.cpp | 4 +- .../preferencesconfigurationpage.cpp | 5 +- .../dialogs/dialogdatetimeformats.cpp | 8 +-- .../valentina/dialogs/dialogincrements.cpp | 4 +- .../dialogs/dialogknownmaterials.cpp | 7 +- src/app/valentina/mainwindow.cpp | 34 +++++----- src/app/valentina/mainwindowsnogui.cpp | 65 +++++++++---------- src/libs/ifc/ifcdef.cpp | 6 +- src/libs/ifc/xml/vabstractpattern.cpp | 20 +++--- src/libs/ifc/xml/vdomdocument.cpp | 12 ++-- src/libs/ifc/xml/vpatternconverter.cpp | 8 +-- src/libs/ifc/xml/vvitconverter.cpp | 6 +- src/libs/ifc/xml/vvstconverter.cpp | 6 +- src/libs/qmuparser/qmuformulabase.cpp | 4 +- src/libs/vdxf/vdxfengine.cpp | 25 ++++--- src/libs/vgeometry/vabstractcurve.cpp | 3 +- src/libs/vgeometry/vspline.cpp | 3 +- src/libs/vlayout/vlayoutgenerator.cpp | 15 ++--- src/libs/vlayout/vlayoutpaper.cpp | 16 ++--- src/libs/vlayout/vlayoutpiece.cpp | 48 +++++++------- src/libs/vlayout/vposition.cpp | 4 +- src/libs/vlayout/vtextmanager.cpp | 14 ++-- src/libs/vmisc/def.cpp | 6 +- src/libs/vmisc/vcommonsettings.cpp | 10 +-- src/libs/vobj/vobjengine.cpp | 14 ++-- src/libs/vpatterndb/measurements.cpp | 4 +- src/libs/vpatterndb/pmsystems.cpp | 4 +- src/libs/vpatterndb/vnodedetail.cpp | 3 +- src/libs/vpatterndb/vpiece.cpp | 20 +++--- src/libs/vpatterndb/vpiecepath.cpp | 10 +-- .../dialogs/support/dialogeditlabel.cpp | 28 ++++---- .../dialogs/tools/dialogflippingbyaxis.cpp | 4 +- .../dialogs/tools/dialogflippingbyline.cpp | 4 +- src/libs/vtools/dialogs/tools/dialogmove.cpp | 4 +- .../vtools/dialogs/tools/dialogrotation.cpp | 4 +- src/libs/vtools/dialogs/tools/dialogtool.cpp | 4 +- .../dialogs/tools/piece/dialogpiecepath.cpp | 3 +- .../tools/piece/dialogseamallowance.cpp | 36 +++++----- .../operation/flipping/vabstractflipping.cpp | 3 +- .../flipping/vtoolflippingbyaxis.cpp | 4 +- .../flipping/vtoolflippingbyline.cpp | 4 +- .../operation/vabstractoperation.cpp | 21 +++--- .../tools/drawTools/operation/vtoolmove.cpp | 10 ++- .../drawTools/operation/vtoolrotation.cpp | 7 +- .../drawTools/toolcurve/vabstractspline.cpp | 4 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 34 +++++----- src/libs/vtools/tools/vtooluniondetails.cpp | 63 +++++++++--------- .../line/operation/visoperation.cpp | 3 +- .../line/operation/vistoolmove.cpp | 9 +-- .../line/operation/vistoolrotation.cpp | 3 +- .../path/vispiecespecialpoints.cpp | 4 +- .../visualization/path/vistoolpiecepath.cpp | 4 +- src/libs/vwidgets/vmaingraphicsview.cpp | 9 ++- .../TranslationsTest/tst_buitinregexp.cpp | 6 +- .../tst_tslocaletranslation.cpp | 8 +-- src/test/ValentinaTest/tst_varc.cpp | 4 +- src/test/ValentinaTest/tst_vellipticalarc.cpp | 3 +- src/test/ValentinaTest/tst_vposter.cpp | 4 +- 62 files changed, 357 insertions(+), 392 deletions(-) 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()); } } From 5b63502b214aa651e86659ba48d2d2ac6157f6b5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 3 Apr 2018 14:54:57 +0300 Subject: [PATCH 07/11] Cppcheck warnings. --HG-- branch : develop --- .../vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp | 2 +- src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp index df2960a40..1eceddbcc 100644 --- a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp @@ -115,7 +115,7 @@ VPE::VProperty* VPE::QVector3DProperty::clone(bool include_children, VProperty* if (!include_children) { - const QList tmpChildren = container->getChildren(); + const QList &tmpChildren = container->getChildren(); for (auto tmpChild : tmpChildren) { container->removeChild(tmpChild); diff --git a/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp b/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp index 53836d1f1..41cf1ef0f 100644 --- a/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp @@ -114,7 +114,7 @@ VPE::VProperty *VPE::VPointFProperty::clone(bool include_children, VProperty *co if (!include_children) { - const QList tmpChildren = container->getChildren(); + const QList &tmpChildren = container->getChildren(); for(auto tmpChild : tmpChildren) { container->removeChild(tmpChild); From e880d5f0a326f22dff7acfa192f376cf47086bbe Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 3 Apr 2018 16:32:53 +0300 Subject: [PATCH 08/11] Clang warning. --HG-- branch : develop --- src/app/valentina/dialogs/dialogaboutapp.cpp | 2 +- src/app/valentina/dialogs/dialogpatternproperties.cpp | 2 +- src/app/valentina/mainwindow.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/valentina/dialogs/dialogaboutapp.cpp b/src/app/valentina/dialogs/dialogaboutapp.cpp index d5c323212..f5b7f10b5 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.cpp +++ b/src/app/valentina/dialogs/dialogaboutapp.cpp @@ -61,7 +61,7 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) : ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR)); - connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, [this]() + connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() { if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false) { diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 24aa3e8b8..1844cb65d 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -100,7 +100,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat } ui->lineEditPathToFile->setCursorPosition(0); - connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, [this]() + connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, []() { ShowInGraphicalShell(qApp->GetPPath()); }); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 1dd0a0923..caf47fbd4 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -4259,19 +4259,19 @@ void MainWindow::CreateActions() connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::Preferences); - connect(ui->actionReportBug, &QAction::triggered, this, [this]() + connect(ui->actionReportBug, &QAction::triggered, this, []() { qCDebug(vMainWindow, "Reporting bug"); QDesktopServices::openUrl(QUrl(QStringLiteral("https://bitbucket.org/dismine/valentina/issues/new"))); }); - connect(ui->actionWiki, &QAction::triggered, this, [this]() + connect(ui->actionWiki, &QAction::triggered, this, []() { qCDebug(vMainWindow, "Showing online help"); QDesktopServices::openUrl(QUrl(QStringLiteral("https://wiki.valentinaproject.org/wiki/Main_Page"))); }); - connect(ui->actionForum, &QAction::triggered, this, [this]() + connect(ui->actionForum, &QAction::triggered, this, []() { qCDebug(vMainWindow, "Opening forum"); QDesktopServices::openUrl(QUrl(QStringLiteral("http://valentinaproject.forumotion.me/"))); From c6e759003465bfa8b5193af3d49b0b0276615904 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 3 Apr 2018 17:41:39 +0300 Subject: [PATCH 09/11] Fix MacOS regression QWidget::closeEvent called twice. --HG-- branch : develop --- src/app/tape/tmainwindow.cpp | 9 +++++++++ src/app/valentina/mainwindow.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 223899ddd..bec1fb139 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -519,6 +519,15 @@ void TMainWindow::ToolBarStyles() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::closeEvent(QCloseEvent *event) { +#if defined(Q_OS_MAC) + // Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344 + static int numCalled = 0; + if (numCalled++ >= 1) + { + return; + } +#endif + if (MaybeSave()) { WriteSettings(); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index caf47fbd4..90ce9ca13 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1508,6 +1508,15 @@ void MainWindow::changeEvent(QEvent *event) */ void MainWindow::closeEvent(QCloseEvent *event) { +#if defined(Q_OS_MAC) + // Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344 + static int numCalled = 0; + if (numCalled++ >= 1) + { + return; + } +#endif + qCDebug(vMainWindow, "Closing main window"); if (MaybeSave()) { From 911a85d79b316ad6561e2071fbb2ad3b1959a94d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 3 Apr 2018 18:08:11 +0300 Subject: [PATCH 10/11] Fix property editor on Mac OS. --HG-- branch : develop --- src/app/valentina/core/vformulapropertyeditor.cpp | 9 ++++----- src/app/valentina/core/vformulapropertyeditor.h | 2 -- src/libs/vpropertyexplorer/vpropertyformwidget.cpp | 5 ++++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/valentina/core/vformulapropertyeditor.cpp b/src/app/valentina/core/vformulapropertyeditor.cpp index a607a806f..06b2dca77 100644 --- a/src/app/valentina/core/vformulapropertyeditor.cpp +++ b/src/app/valentina/core/vformulapropertyeditor.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "../vpropertyexplorer/vproperty.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h" @@ -42,7 +43,7 @@ // VFormulaPropertyEditor //--------------------------------------------------------------------------------------------------------------------- VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) - : QWidget(parent), formula(VFormula()), ToolButton(nullptr), TextLabel(nullptr), Spacer(nullptr) + : QWidget(parent), formula(VFormula()), ToolButton(nullptr), TextLabel(nullptr) { setAutoFillBackground(true); @@ -61,15 +62,13 @@ VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) TextLabel = new QLabel(this); TextLabel->setText(formula.getStringValue()); - // Spacer (this is needed for proper display of the label and button) - Spacer = new QSpacerItem(1, 0, QSizePolicy::Expanding, QSizePolicy::Ignored); - // The layout (a horizontal layout) QHBoxLayout* layout = new QHBoxLayout(this); layout->setSpacing(3); layout->setMargin(0); layout->addWidget(TextLabel); - layout->addItem(Spacer); + // Spacer (this is needed for proper display of the label and button) + layout->addSpacerItem(new QSpacerItem(1000000000, 0, QSizePolicy::Expanding, QSizePolicy::Expanding)); layout->addWidget(ToolButton); } diff --git a/src/app/valentina/core/vformulapropertyeditor.h b/src/app/valentina/core/vformulapropertyeditor.h index 6a3660432..98fe6b089 100644 --- a/src/app/valentina/core/vformulapropertyeditor.h +++ b/src/app/valentina/core/vformulapropertyeditor.h @@ -33,7 +33,6 @@ #include #include #include -#include #include "../vpatterndb/vformula.h" @@ -72,7 +71,6 @@ private: VFormula formula; QToolButton* ToolButton; QLabel* TextLabel; - QSpacerItem* Spacer; }; diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp index 88aac1571..3a502245d 100644 --- a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp @@ -103,6 +103,7 @@ void VPE::VPropertyFormWidget::build() } QFormLayout* tmpFormLayout = new QFormLayout(this); + tmpFormLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); setLayout(tmpFormLayout); for (int i = 0; i < d_ptr->Properties.count(); ++i) @@ -123,9 +124,11 @@ void VPE::VPropertyFormWidget::build() tmpFormLayout->addRow(group); QFormLayout* subFormLayout = new QFormLayout(group); + subFormLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); QMargins margins = subFormLayout->contentsMargins(); margins.setTop(0); - margins.setLeft(14); + margins.setLeft(18); + margins.setRight(0); subFormLayout->setContentsMargins(margins); group->setLayout(subFormLayout); From d8c3a0ac813e4dba2bc58869185e413ab7c32e0a Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 4 Apr 2018 08:34:48 +0300 Subject: [PATCH 11/11] Use native dialog on all platforms except Linux. We have a bug with native dialog on Linux that's why we cannot use it. --HG-- branch : develop --- src/app/tape/tmainwindow.cpp | 7 +++-- .../configpages/preferencespathpage.cpp | 5 +++- .../dialogs/dialogpatternproperties.cpp | 14 +++++++--- .../valentina/dialogs/dialogsavelayout.cpp | 5 +++- src/app/valentina/mainwindow.cpp | 27 ++++++++++++++----- .../plugins/vfilepropertyeditor.cpp | 12 ++++++--- .../dialogs/support/dialogeditlabel.cpp | 13 ++++++--- src/libs/vwidgets/vabstractmainwindow.cpp | 7 +++-- 8 files changed, 67 insertions(+), 23 deletions(-) diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index bec1fb139..d86868359 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -972,8 +972,11 @@ void TMainWindow::ImportDataFromCSV() const QString filters = tr("Comma-Separated Values") + QLatin1String(" (*.csv)"); const QString suffix("csv"); - QString fileName = QFileDialog::getOpenFileName(this, tr("Import from CSV"), QDir::homePath(), filters, nullptr, - QFileDialog::DontUseNativeDialog); + QString fileName = QFileDialog::getOpenFileName(this, tr("Import from CSV"), QDir::homePath(), filters, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); if (fileName.isEmpty()) { diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp index d4c6328d8..e7bd64380 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp @@ -148,7 +148,10 @@ void PreferencesPathPage::EditPath() const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks - | QFileDialog::DontUseNativeDialog); +#ifdef Q_OS_LINUX + | QFileDialog::DontUseNativeDialog +#endif + ); if (dir.isEmpty()) { if (usedNotExistedDir) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 1844cb65d..970fcf5c1 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -837,8 +837,11 @@ void DialogPatternProperties::InitImage() void DialogPatternProperties::ChangeImage() { const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)"); - const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), filter, nullptr, - QFileDialog::DontUseNativeDialog); + const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), filter, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); if (not fileName.isEmpty()) { QImage image; @@ -879,8 +882,11 @@ void DialogPatternProperties::SaveImage() QByteArray ba = QByteArray::fromBase64(byteArray); const QString extension = QLatin1String(".") + doc->GetImageExtension(); QString filter = tr("Images") + QLatin1String(" (*") + extension + QLatin1String(")"); - QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter, - QFileDialog::DontUseNativeDialog); + QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); if (not filename.isEmpty()) { if (not filename.endsWith(extension.toUpper())) diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index e198ed0ee..eb9e4e20a 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -129,7 +129,10 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"), dirPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks - | QFileDialog::DontUseNativeDialog); +#ifdef Q_OS_LINUX + | QFileDialog::DontUseNativeDialog +#endif + ); if (not dir.isEmpty()) {// If paths equal the signal will not be called, we will do this manually dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 90ce9ca13..461847f02 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1659,8 +1659,11 @@ void MainWindow::LoadIndividual() usedNotExistedDir = directory.mkpath("."); } - const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr, - QFileDialog::DontUseNativeDialog); + const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); if (not mPath.isEmpty()) { @@ -1697,8 +1700,11 @@ void MainWindow::LoadMultisize() //Use standard path to multisize measurements QString path = qApp->ValentinaSettings()->GetPathMultisizeMeasurements(); path = VCommonSettings::PrepareMultisizeTables(path); - const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr, - QFileDialog::DontUseNativeDialog); + const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); if (not mPath.isEmpty()) { @@ -2744,7 +2750,11 @@ bool MainWindow::SaveAs() QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QLatin1String("/") + tr("pattern") + QLatin1String(".val"), - filters, nullptr, QFileDialog::DontUseNativeDialog); + filters, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); auto RemoveTempDir = [usedNotExistedDir, dir]() { @@ -2935,8 +2945,11 @@ void MainWindow::Open() dir = QFileInfo(files.first()).absolutePath(); } qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); - const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr, - QFileDialog::DontUseNativeDialog); + const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); if (filePath.isEmpty()) { return; diff --git a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp index 373298be9..5e4731c4a 100644 --- a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp +++ b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp @@ -113,10 +113,16 @@ void VPE::VFileEditWidget::onToolButtonClicked() { QString filepath = (Directory ? QFileDialog::getExistingDirectory(nullptr, tr("Directory"), CurrentFilePath, QFileDialog::ShowDirsOnly - | QFileDialog::DontUseNativeDialog) +#ifdef Q_OS_LINUX + | QFileDialog::DontUseNativeDialog +#endif + ) : QFileDialog::getOpenFileName(nullptr, tr("Open File"), CurrentFilePath, - FileDialogFilter, nullptr, - QFileDialog::DontUseNativeDialog)); + FileDialogFilter, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + )); if (filepath.isNull() == false) { setFile(filepath, true); diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 83a964ba3..c50881b45 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -291,7 +291,11 @@ void DialogEditLabel::ExportTemplate() QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"), path + QLatin1String("/") + tr("template") + QLatin1String(".xml"), - filters, nullptr, QFileDialog::DontUseNativeDialog); + filters, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); if (fileName.isEmpty()) { @@ -340,8 +344,11 @@ void DialogEditLabel::ImportTemplate() QString filter(tr("Label template") + QLatin1String(" (*.xml)")); //Use standard path to label templates const QString path = VCommonSettings::PrepareLabelTemplates(qApp->Settings()->GetPathLabelTemplate()); - const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr, - QFileDialog::DontUseNativeDialog); + const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); if (fileName.isEmpty()) { return; diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp index 967e0b516..b513d0dc8 100644 --- a/src/libs/vwidgets/vabstractmainwindow.cpp +++ b/src/libs/vwidgets/vabstractmainwindow.cpp @@ -106,8 +106,11 @@ QString VAbstractMainWindow::CSVFilePath() const QString suffix("csv"); const QString path = QDir::homePath() + QLatin1String("/") + tr("values") + QLatin1String(".") + suffix; - QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr, - QFileDialog::DontUseNativeDialog); + QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr +#ifdef Q_OS_LINUX + , QFileDialog::DontUseNativeDialog +#endif + ); if (fileName.isEmpty()) {