From c35930db3a788cf4c5ed45e3c3153f464616a1d8 Mon Sep 17 00:00:00 2001 From: dismine Date: Mon, 9 Jun 2014 22:11:33 +0300 Subject: [PATCH] at() instead operator[]. --HG-- branch : feature --- src/app/dialogs/app/pages.cpp | 2 +- src/app/dialogs/tools/dialogdetail.cpp | 4 +-- src/app/dialogs/tools/dialogsplinepath.cpp | 2 +- src/app/geometry/varc.cpp | 4 +-- src/app/geometry/vdetail.cpp | 14 ++++---- src/app/geometry/vequidistant.cpp | 31 +++++++++--------- src/app/geometry/vspline.cpp | 14 ++++---- src/app/geometry/vsplinepath.cpp | 20 ++++++------ src/app/mainwindow.cpp | 4 +-- src/app/tools/drawTools/vtoolsplinepath.cpp | 6 ++-- src/app/tools/vtooldetail.cpp | 36 ++++++++++----------- src/app/tools/vtooluniondetails.cpp | 2 +- src/app/widgets/vcontrolpointspline.cpp | 3 +- 13 files changed, 70 insertions(+), 72 deletions(-) diff --git a/src/app/dialogs/app/pages.cpp b/src/app/dialogs/app/pages.cpp index 13dfcb629..458d242cb 100644 --- a/src/app/dialogs/app/pages.cpp +++ b/src/app/dialogs/app/pages.cpp @@ -143,7 +143,7 @@ QGroupBox *ConfigurationPage::LangGroup() { // get locale extracted by filename QString locale; - locale = fileNames[i]; // "valentina_de.qm" + locale = fileNames.at(i); // "valentina_de.qm" locale.truncate(locale.lastIndexOf('.')); // "valentina_de" locale.remove(0, locale.indexOf('_') + 1); // "de" diff --git a/src/app/dialogs/tools/dialogdetail.cpp b/src/app/dialogs/tools/dialogdetail.cpp index 6d75f1ef4..96b8be0eb 100644 --- a/src/app/dialogs/tools/dialogdetail.cpp +++ b/src/app/dialogs/tools/dialogdetail.cpp @@ -198,8 +198,8 @@ void DialogDetail::setDetails(const VDetail &value) ui.listWidget->clear(); for (ptrdiff_t i = 0; i < details.CountNode(); ++i) { - NewItem(details[i].getId(), details[i].getTypeTool(), details[i].getTypeNode(), details[i].getMx(), - details[i].getMy()); + NewItem(details.at(i).getId(), details.at(i).getTypeTool(), details.at(i).getTypeNode(), details.at(i).getMx(), + details.at(i).getMy()); } ui.lineEditNameDetail->setText(details.getName()); ui.checkBoxSeams->setChecked(details.getSeamAllowance()); diff --git a/src/app/dialogs/tools/dialogsplinepath.cpp b/src/app/dialogs/tools/dialogsplinepath.cpp index 066786ebe..7dbf8e54c 100644 --- a/src/app/dialogs/tools/dialogsplinepath.cpp +++ b/src/app/dialogs/tools/dialogsplinepath.cpp @@ -76,7 +76,7 @@ void DialogSplinePath::SetPath(const VSplinePath &value) ui->listWidget->clear(); for (qint32 i = 0; i < path.CountPoint(); ++i) { - NewItem(path[i].P().id(), path[i].KAsm1(), path[i].Angle1(), path[i].KAsm2(), path[i].Angle2()); + NewItem(path.at(i).P().id(), path.at(i).KAsm1(), path.at(i).Angle1(), path.at(i).KAsm2(), path.at(i).Angle2()); } ui->listWidget->setFocus(Qt::OtherFocusReason); ui->doubleSpinBoxKcurve->setValue(path.getKCurve()); diff --git a/src/app/geometry/varc.cpp b/src/app/geometry/varc.cpp index 53afc19ff..0cc8e6be8 100644 --- a/src/app/geometry/varc.cpp +++ b/src/app/geometry/varc.cpp @@ -139,8 +139,8 @@ QPainterPath VArc::GetPath() const { for (qint32 i = 0; i < points.count()-1; ++i) { - path.moveTo(points[i]); - path.lineTo(points[i+1]); + path.moveTo(points.at(i)); + path.lineTo(points.at(i+1)); } } else diff --git a/src/app/geometry/vdetail.cpp b/src/app/geometry/vdetail.cpp index 8363d860d..14bbda395 100644 --- a/src/app/geometry/vdetail.cpp +++ b/src/app/geometry/vdetail.cpp @@ -87,7 +87,7 @@ bool VDetail::Containes(const quint32 &id) const { for (ptrdiff_t i = 0; i < nodes.size(); ++i) { - VNodeDetail node = nodes[i]; + VNodeDetail node = nodes.at(i); if (node.getId() == id) { return true; @@ -105,7 +105,7 @@ VNodeDetail &VDetail::operator [](ptrdiff_t indx) //--------------------------------------------------------------------------------------------------------------------- const VNodeDetail &VDetail::at(ptrdiff_t indx) const { - return nodes[indx]; + return nodes.at(indx); } //--------------------------------------------------------------------------------------------------------------------- @@ -264,13 +264,13 @@ QList VDetail::Missing(const VDetail &det) const qint32 j = 0; for (qint32 i = 0; i < nodes.size(); ++i) { - if (nodes[i].getId() == det.at(j).getId()) + if (nodes.at(i).getId() == det.at(j).getId()) { ++j; } else { - list.append(nodes[i].getId()); + list.append(nodes.at(i).getId()); } } return list; @@ -282,9 +282,9 @@ QVector VDetail::listNodePoint() const QVector list; for (ptrdiff_t i = 0; i < nodes.size(); ++i) { - if (nodes[i].getTypeTool() == Valentina::NodePoint) + if (nodes.at(i).getTypeTool() == Valentina::NodePoint) { - list.append(nodes[i]); + list.append(nodes.at(i)); } } return list; @@ -295,7 +295,7 @@ ptrdiff_t VDetail::indexOfNode(const QVector &list, const quint32 & { for (ptrdiff_t i = 0; i < list.size(); ++i) { - if (list[i].getId() == id) + if (list.at(i).getId() == id) { return i; } diff --git a/src/app/geometry/vequidistant.cpp b/src/app/geometry/vequidistant.cpp index c6ea4def8..a3f7268e4 100644 --- a/src/app/geometry/vequidistant.cpp +++ b/src/app/geometry/vequidistant.cpp @@ -142,9 +142,9 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer path.moveTo(points[0]); for (qint32 i = 1; i < points.count(); ++i) { - path.lineTo(points[i]); + path.lineTo(points.at(i)); } - path.lineTo(points[0]); + path.lineTo(points.at(0)); pointsEkv = CorrectEquidistantPoints(pointsEkv); pointsEkv = CheckLoops(pointsEkv); @@ -229,8 +229,8 @@ QVector VEquidistant::CorrectEquidistantPoints(const QVector & QPointF point; for (qint32 i = 1; i VEquidistant::CorrectEquidistantPoints(const QVector & } //--------------------------------------------------------------------------------------------------------------------- -QPainterPath VEquidistant::Equidistant(QVector points, const Detail::Equidistant &eqv, - const qreal &width) +QPainterPath VEquidistant::Equidistant(QVector points, const Detail::Equidistant &eqv, const qreal &width) { QPainterPath ekv; QVector ekvPoints; @@ -255,14 +254,14 @@ QPainterPath VEquidistant::Equidistant(QVector points, const Detail::Eq { if (i != points.size()-1) { - if (points[i] == points[i+1]) + if (points.at(i) == points.at(i+1)) { points.remove(i+1); } } else { - if (points[i] == points[0]) + if (points.at(i) == points.at(0)) { points.remove(i); } @@ -276,13 +275,13 @@ QPainterPath VEquidistant::Equidistant(QVector points, const Detail::Eq { if ( i == 0 && eqv == Detail::CloseEquidistant) {//first point, polyline closed - ekvPoints< points, const Detail::Eq } else if (i == points.size()-1 && eqv == Detail::OpenEquidistant) {//last point, polyline doesn't closed - ekvPoints.append(SingleParallelPoint(QLineF(points[points.size()-1], points[points.size()-2]), -90, - width)); + ekvPoints.append(SingleParallelPoint(QLineF(points.at(points.size()-1), points.at(points.size()-2)), + -90, width)); continue; } //points in the middle of polyline - ekvPoints< VSpline::GetPoints (const QPointF &p1, const QPointF &p2, const y.append ( p4.y () ); for ( qint32 i = 0; i < x.count(); ++i ) { - pvector.append( QPointF ( x[i], y[i] ) ); + pvector.append( QPointF ( x.at(i), y.at(i)) ); } return pvector; } @@ -338,10 +338,10 @@ qreal VSpline::LengthBezier ( const QPointF &p1, const QPointF &p2, const QPoint { QPainterPath splinePath; QVector points = GetPoints (p1, p2, p3, p4); - splinePath.moveTo(points[0]); + splinePath.moveTo(points.at(0)); for (qint32 i = 1; i < points.count(); ++i) { - splinePath.lineTo(points[i]); + splinePath.lineTo(points.at(i)); } return splinePath.length(); } @@ -677,8 +677,8 @@ QPainterPath VSpline::GetPath() const { for (qint32 i = 0; i < points.count()-1; ++i) { - splinePath.moveTo(points[i]); - splinePath.lineTo(points[i+1]); + splinePath.moveTo(points.at(i)); + splinePath.lineTo(points.at(i+1)); } } else diff --git a/src/app/geometry/vsplinepath.cpp b/src/app/geometry/vsplinepath.cpp index b403fc283..78001fab5 100644 --- a/src/app/geometry/vsplinepath.cpp +++ b/src/app/geometry/vsplinepath.cpp @@ -76,8 +76,8 @@ VSpline VSplinePath::GetSpline(qint32 index) const { throw VException(tr("This spline does not exist.")); } - VSpline spl(path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(), - path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve); + VSpline spl(path.at(index-1).P(), path.at(index).P(), path.at(index-1).Angle2(), path.at(index).Angle1(), + path.at(index-1).KAsm2(), path.at(index).KAsm1(), this->kCurve); return spl; } @@ -87,8 +87,8 @@ QPainterPath VSplinePath::GetPath() const QPainterPath painterPath; for (qint32 i = 1; i <= Count(); ++i) { - VSpline spl(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), - path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve); + VSpline spl(path.at(i-1).P(), path.at(i).P(), path.at(i-1).Angle2(), path.at(i).Angle1(), + path.at(i-1).KAsm2(), path.at(i).KAsm1(), this->kCurve); painterPath.addPath(spl.GetPath()); } return painterPath; @@ -100,8 +100,8 @@ QVector VSplinePath::GetPathPoints() const QVector pathPoints; for (qint32 i = 1; i <= Count(); ++i) { - VSpline spl(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), - path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve); + VSpline spl(path.at(i-1).P(), path.at(i).P(), path.at(i-1).Angle2(), path.at(i).Angle1(), + path.at(i-1).KAsm2(), path.at(i).KAsm1(), this->kCurve); pathPoints += spl.GetPoints(); } return pathPoints; @@ -113,8 +113,8 @@ qreal VSplinePath::GetLength() const qreal length = 0; for (qint32 i = 1; i <= Count(); ++i) { - VSpline spl(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), - path[i].KAsm1(), kCurve); + VSpline spl(path.at(i-1).P(), path.at(i).P(), path.at(i-1).Angle2(), path.at(i).Angle1(), path.at(i-1).KAsm2(), + path.at(i).KAsm1(), kCurve); length += spl.GetLength(); } return length; @@ -199,8 +199,8 @@ QPointF VSplinePath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF fullLength = 0; for (qint32 i = 1; i <= Count(); ++i) { - VSpline spl = VSpline(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), - path[i].KAsm1(), kCurve); + VSpline spl = VSpline(path.at(i-1).P(), path.at(i).P(), path.at(i-1).Angle2(), path.at(i).Angle1(), + path.at(i-1).KAsm2(), path.at(i).KAsm1(), kCurve); fullLength += spl.GetLength(); if (fullLength > length) { diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 5b9ddee3f..dfedb197b 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -1789,9 +1789,9 @@ void MainWindow::UpdateRecentFileActions() for (int i = 0; i < numRecentFiles; ++i) { - QString text = QString("&%1 %2").arg(i + 1).arg(strippedName(files[i])); + QString text = QString("&%1 %2").arg(i + 1).arg(strippedName(files.at(i))); recentFileActs[i]->setText(text); - recentFileActs[i]->setData(files[i]); + recentFileActs[i]->setData(files.at(i)); recentFileActs[i]->setVisible(true); } for (int j = numRecentFiles; j < MaxRecentFiles; ++j) diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index 6d18d81a0..337d5c869 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -203,7 +203,7 @@ void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path) QDomElement domElement = nodeList.at(i).toElement(); if (domElement.isNull() == false) { - VSplinePoint p = path[i]; + VSplinePoint p = path.at(i); doc->SetAttribute(domElement, AttrPSpline, p.P().id()); doc->SetAttribute(domElement, AttrKAsm1, p.KAsm1()); doc->SetAttribute(domElement, AttrKAsm2, p.KAsm2()); @@ -230,7 +230,7 @@ void VToolSplinePath::AddToFile() for (qint32 i = 0; i < splPath.CountPoint(); ++i) { - AddPathPoint(domElement, splPath[i]); + AddPathPoint(domElement, splPath.at(i)); } AddToCalculation(domElement); @@ -280,7 +280,7 @@ void VToolSplinePath::RemoveReferens() VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); for (qint32 i = 0; i < splPath.Count(); ++i) { - doc->DecrementReferens(splPath[i].P().id()); + doc->DecrementReferens(splPath.at(i).P().id()); } } diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index 6c69b88b2..c61acc61e 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -64,25 +64,25 @@ VToolDetail::VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, con VDetail detail = data->GetDetail(id); for (ptrdiff_t i = 0; i< detail.CountNode(); ++i) { - switch (detail[i].getTypeTool()) + switch (detail.at(i).getTypeTool()) { case (Valentina::NodePoint): - InitTool(scene, detail[i]); + InitTool(scene, detail.at(i)); break; case (Valentina::NodeArc): - InitTool(scene, detail[i]); + InitTool(scene, detail.at(i)); break; case (Valentina::NodeSpline): - InitTool(scene, detail[i]); + InitTool(scene, detail.at(i)); break; case (Valentina::NodeSplinePath): - InitTool(scene, detail[i]); + InitTool(scene, detail.at(i)); break; default: qDebug()<<"Get wrong tool type. Ignore."; break; } - doc->IncrementReferens(detail[i].getId()); + doc->IncrementReferens(detail.at(i).getId()); } this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true); @@ -123,37 +123,37 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern for (ptrdiff_t i = 0; i< detail.CountNode(); ++i) { quint32 id = 0; - switch (detail[i].getTypeTool()) + switch (detail.at(i).getTypeTool()) { case (Valentina::NodePoint): { - id = CreateNode(data, detail[i].getId()); - VNodePoint::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui); + id = CreateNode(data, detail.at(i).getId()); + VNodePoint::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Valentina::FromGui); } break; case (Valentina::NodeArc): { - id = CreateNode(data, detail[i].getId()); - VNodeArc::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui); + id = CreateNode(data, detail.at(i).getId()); + VNodeArc::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Valentina::FromGui); } break; case (Valentina::NodeSpline): { - id = CreateNode(data, detail[i].getId()); - VNodeSpline::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui); + id = CreateNode(data, detail.at(i).getId()); + VNodeSpline::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Valentina::FromGui); } break; case (Valentina::NodeSplinePath): { - id = CreateNode(data, detail[i].getId()); - VNodeSplinePath::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui); + id = CreateNode(data, detail.at(i).getId()); + VNodeSplinePath::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Valentina::FromGui); } break; default: qDebug()<<"May be wrong tool type!!! Ignoring."< list = detail.Missing(det); @@ -228,7 +228,7 @@ void VToolDetail::FullUpdateFromGui(int result) { for (qint32 i = 0; i < list.size(); ++i) { - VAbstractNode *node = qobject_cast(tools->value(list[i])); + VAbstractNode *node = qobject_cast(tools->value(list.at(i))); node->DeleteNode(); } } diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp index 50245d1c7..cadcaf981 100644 --- a/src/app/tools/vtooluniondetails.cpp +++ b/src/app/tools/vtooluniondetails.cpp @@ -662,7 +662,7 @@ void VToolUnionDetails::AddDetail(QDomElement &domElement, VDetail &d) for (ptrdiff_t i = 0; i < d.CountNode(); ++i) { - AddNode(det, d[i]); + AddNode(det, d.at(i)); } domElement.appendChild(det); diff --git a/src/app/widgets/vcontrolpointspline.cpp b/src/app/widgets/vcontrolpointspline.cpp index ec28865bd..505e50b82 100644 --- a/src/app/widgets/vcontrolpointspline.cpp +++ b/src/app/widgets/vcontrolpointspline.cpp @@ -36,8 +36,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position, const QPointF &controlPoint, const QPointF &splinePoint, QGraphicsItem *parent) - :QGraphicsEllipseItem(parent), radius(0), controlLine(nullptr), indexSpline(indexSpline), - position(position) + :QGraphicsEllipseItem(parent), radius(0), controlLine(nullptr), indexSpline(indexSpline), position(position) { //create circle radius = (1.5/*mm*/ / 25.4) * VApplication::PrintDPI;