at() instead operator[].

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-09 22:11:33 +03:00
parent 970d4d1f00
commit c35930db3a
13 changed files with 70 additions and 72 deletions

View File

@ -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"

View File

@ -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());

View File

@ -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());

View File

@ -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

View File

@ -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<quint32> 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<VNodeDetail> VDetail::listNodePoint() const
QVector<VNodeDetail> 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<VNodeDetail> &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;
}

View File

@ -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<QPointF> VEquidistant::CorrectEquidistantPoints(const QVector<QPointF> &
QPointF point;
for (qint32 i = 1; i <correctPoints.size()-1; ++i)
{
QLineF l1(correctPoints[i-1], correctPoints[i]);
QLineF l2(correctPoints[i], correctPoints[i+1]);
QLineF l1(correctPoints.at(i-1), correctPoints.at(i));
QLineF l2(correctPoints.at(i), correctPoints.at(i+1));
QLineF::IntersectType intersect = l1.intersect(l2, &point);
if (intersect == QLineF::NoIntersection)
{
@ -241,8 +241,7 @@ QVector<QPointF> VEquidistant::CorrectEquidistantPoints(const QVector<QPointF> &
}
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VEquidistant::Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv,
const qreal &width)
QPainterPath VEquidistant::Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, const qreal &width)
{
QPainterPath ekv;
QVector<QPointF> ekvPoints;
@ -255,14 +254,14 @@ QPainterPath VEquidistant::Equidistant(QVector<QPointF> 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<QPointF> points, const Detail::Eq
{
if ( i == 0 && eqv == Detail::CloseEquidistant)
{//first point, polyline closed
ekvPoints<<EkvPoint(QLineF(points[points.size()-2], points[points.size()-1]), QLineF(points[1], points[0]),
width);
ekvPoints<<EkvPoint(QLineF(points.at(points.size()-2), points.at(points.size()-1)),
QLineF(points.at(1), points.at(0)), width);
continue;
}
else if (i == 0 && eqv == Detail::OpenEquidistant)
{//first point, polyline doesn't closed
ekvPoints.append(SingleParallelPoint(QLineF(points[0], points[1]), 90, width));
ekvPoints.append(SingleParallelPoint(QLineF(points.at(0), points.at(1)), 90, width));
continue;
}
if (i == points.size()-1 && eqv == Detail::CloseEquidistant)
@ -292,18 +291,18 @@ QPainterPath VEquidistant::Equidistant(QVector<QPointF> 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<<EkvPoint(QLineF(points[i-1], points[i]), QLineF(points[i+1], points[i]), width);
ekvPoints<<EkvPoint(QLineF(points.at(i-1), points.at(i)), QLineF(points.at(i+1), points.at(i)), width);
}
ekvPoints = CheckLoops(ekvPoints);
ekv.moveTo(ekvPoints[0]);
ekv.moveTo(ekvPoints.at(0));
for (qint32 i = 1; i < ekvPoints.count(); ++i)
{
ekv.lineTo(ekvPoints[i]);
ekv.lineTo(ekvPoints.at(i));
}
return ekv;
}

View File

@ -170,8 +170,8 @@ QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *in
QLineF::IntersectType type = QLineF::NoIntersection;
for ( i = 0; i < px.count()-1; ++i )
{
type = line.intersect(QLineF ( QPointF ( px[i], py[i] ),
QPointF ( px[i+1], py[i+1] )), &crosPoint);
type = line.intersect(QLineF ( QPointF ( px.at(i), py.at(i) ),
QPointF ( px.at(i+1), py.at(i+1) )), &crosPoint);
if ( type == QLineF::BoundedIntersection )
{
*intersectionPoint = crosPoint;
@ -320,7 +320,7 @@ QVector<QPointF> 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<QPointF> 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

View File

@ -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<QPointF> VSplinePath::GetPathPoints() const
QVector<QPointF> 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)
{

View File

@ -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)

View File

@ -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<const VSplinePath *>(id);
for (qint32 i = 0; i < splPath.Count(); ++i)
{
doc->DecrementReferens(splPath[i].P().id());
doc->DecrementReferens(splPath.at(i).P().id());
}
}

View File

@ -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<VNodePoint>(scene, detail[i]);
InitTool<VNodePoint>(scene, detail.at(i));
break;
case (Valentina::NodeArc):
InitTool<VNodeArc>(scene, detail[i]);
InitTool<VNodeArc>(scene, detail.at(i));
break;
case (Valentina::NodeSpline):
InitTool<VNodeSpline>(scene, detail[i]);
InitTool<VNodeSpline>(scene, detail.at(i));
break;
case (Valentina::NodeSplinePath):
InitTool<VNodeSplinePath>(scene, detail[i]);
InitTool<VNodeSplinePath>(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<VPointF>(data, detail[i].getId());
VNodePoint::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui);
id = CreateNode<VPointF>(data, detail.at(i).getId());
VNodePoint::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Valentina::FromGui);
}
break;
case (Valentina::NodeArc):
{
id = CreateNode<VArc>(data, detail[i].getId());
VNodeArc::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui);
id = CreateNode<VArc>(data, detail.at(i).getId());
VNodeArc::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Valentina::FromGui);
}
break;
case (Valentina::NodeSpline):
{
id = CreateNode<VSpline>(data, detail[i].getId());
VNodeSpline::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui);
id = CreateNode<VSpline>(data, detail.at(i).getId());
VNodeSpline::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Valentina::FromGui);
}
break;
case (Valentina::NodeSplinePath):
{
id = CreateNode<VSplinePath>(data, detail[i].getId());
VNodeSplinePath::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui);
id = CreateNode<VSplinePath>(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."<<Q_FUNC_INFO;
break;
}
VNodeDetail node(id, detail[i].getTypeTool(), NodeDetail::Contour);
VNodeDetail node(id, detail.at(i).getTypeTool(), NodeDetail::Contour);
det.append(node);
}
det.setName(detail.getName());
@ -219,7 +219,7 @@ void VToolDetail::FullUpdateFromGui(int result)
RemoveAllChild(domElement);
for (ptrdiff_t i = 0; i < det.CountNode(); ++i)
{
AddNode(domElement, det[i]);
AddNode(domElement, det.at(i));
}
VDetail detail = VAbstractTool::data.GetDetail(id);
QList<quint32> 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<VAbstractNode *>(tools->value(list[i]));
VAbstractNode *node = qobject_cast<VAbstractNode *>(tools->value(list.at(i)));
node->DeleteNode();
}
}

View File

@ -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);

View File

@ -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;