diff --git a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp index d05e2122d..585e69e8f 100644 --- a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp @@ -117,7 +117,7 @@ void VPCarrouselPieceList::mouseMoveEvent(QMouseEvent *event) if (((event->buttons() & Qt::LeftButton) != 0U) && ((event->pos() - m_dragStart).manhattanLength() >= QApplication::startDragDistance()) && (selectedItems().count() > 0) && - (not m_pieceList.isEmpty() && m_pieceList.first()->Sheet() == nullptr)) // only if it's from unplaced pieces + (not m_pieceList.isEmpty() && ConstFirst(m_pieceList)->Sheet() == nullptr)) // only if it's from unplaced pieces { startDrag(Qt::MoveAction); } @@ -229,13 +229,13 @@ void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event) QAction *removeAction = menu.addAction(tr("Remove from Sheet")); removeAction->setVisible(false); - if(not m_pieceList.isEmpty() && m_pieceList.first()->Sheet() == nullptr) + if(not m_pieceList.isEmpty() && ConstFirst(m_pieceList)->Sheet() == nullptr) { moveAction->setVisible(true); deleteAction->setVisible(true); } - if(not m_pieceList.isEmpty() && m_pieceList.first()->Sheet() != nullptr) + if(not m_pieceList.isEmpty() && ConstFirst(m_pieceList)->Sheet() != nullptr) { removeAction->setVisible(true); } diff --git a/src/app/puzzle/layout/vplayout.cpp b/src/app/puzzle/layout/vplayout.cpp index 79e381090..c2e203a90 100644 --- a/src/app/puzzle/layout/vplayout.cpp +++ b/src/app/puzzle/layout/vplayout.cpp @@ -185,7 +185,7 @@ auto VPLayout::IsSheetsUniform() const -> bool return true; } - VPSheetPtr sheet = sheets.first(); + const VPSheetPtr &sheet = ConstFirst(sheets); if (sheet.isNull()) { return false; @@ -299,7 +299,7 @@ void VPLayout::SetFocusedSheet(const VPSheetPtr &focusedSheet) } else { - m_focusedSheet = focusedSheet.isNull() ? m_sheets.first() : focusedSheet; + m_focusedSheet = focusedSheet.isNull() ? ConstFirst(m_sheets) : focusedSheet; } emit ActiveSheetChanged(m_focusedSheet); diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index 748d6c851..bdc220e38 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -218,10 +218,10 @@ void VPPiece::RotateToGrainline(const VPTransformationOrigon &origin) return; } - QLineF grainline(grainlinePoints.first(), grainlinePoints.last()); + QLineF grainline(ConstFirst(grainlinePoints), ConstLast(grainlinePoints)); - QLineF canonical(grainlinePoints.first().x(), grainlinePoints.first().y(), - grainlinePoints.first().x()+100, grainlinePoints.first().y()); + QLineF canonical(ConstFirst(grainlinePoints).x(), ConstFirst(grainlinePoints).y(), + ConstFirst(grainlinePoints).x()+100, ConstFirst(grainlinePoints).y()); GrainlineType grainlineType = sheet->GrainlineOrientation(); diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index b9535575d..36d5f24c3 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -416,7 +416,7 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) QVector seamLinePoints = piece->GetMappedContourPoints(); if(!seamLinePoints.isEmpty()) { - m_seamLine.moveTo(seamLinePoints.first()); + m_seamLine.moveTo(ConstFirst(seamLinePoints)); for (int i = 1; i < seamLinePoints.size(); i++) { m_seamLine.lineTo(seamLinePoints.at(i)); @@ -438,7 +438,7 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) QVector cuttingLinepoints = piece->GetMappedSeamAllowancePoints(); if(!cuttingLinepoints.isEmpty()) { - m_cuttingLine.moveTo(cuttingLinepoints.first()); + m_cuttingLine.moveTo(ConstFirst(cuttingLinepoints)); for (int i = 1; i < cuttingLinepoints.size(); i++) { m_cuttingLine.lineTo(cuttingLinepoints.at(i)); @@ -460,7 +460,7 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) QVector grainLinepoints = piece->GetMappedGrainline(); if(!grainLinepoints.isEmpty()) { - m_grainline.moveTo(grainLinepoints.first()); + m_grainline.moveTo(ConstFirst(grainLinepoints)); for (int i = 1; i < grainLinepoints.size(); i++) { m_grainline.lineTo(grainLinepoints.at(i)); @@ -539,7 +539,7 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) if (not m_stickyPoints.isEmpty()) { - m_stickyPath.moveTo(m_stickyPoints.first()); + m_stickyPath.moveTo(ConstFirst(m_stickyPoints)); for (int i = 1; i < m_stickyPoints.size(); i++) { m_stickyPath.lineTo(m_stickyPoints.at(i)); @@ -599,7 +599,7 @@ void VPGraphicsPiece::GroupMove(const QPointF &pos) if (pieces.size() == 1) { - VPPiecePtr p = pieces.first(); + const VPPiecePtr &p = ConstFirst(pieces); auto *command = new VPUndoPieceMove(piece, newPos.x(), newPos.y(), allowChangeMerge); layout->UndoStack()->push(command); diff --git a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp index 684686e92..5404a606a 100644 --- a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp +++ b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp @@ -532,7 +532,7 @@ void VPGraphicsPieceControls::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if (pieces.size() == 1) { - auto *command = new VPUndoPieceRotate(pieces.first(), rotationOrigin, rotateOn, m_rotationSum, + auto *command = new VPUndoPieceRotate(ConstFirst(pieces), rotationOrigin, rotateOn, m_rotationSum, allowChangeMerge); layout->UndoStack()->push(command); } diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index 9b1656320..93cce9622 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -357,7 +357,7 @@ void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event) QList pieces = PreparePieces(); if (pieces.size() == 1) { - VPPiecePtr p = pieces.first(); + const VPPiecePtr &p = ConstFirst(pieces); auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge); @@ -555,7 +555,7 @@ void VPMainGraphicsView::RotatePiecesByAngle(qreal angle) if (pieces.size() == 1) { - auto *command = new VPUndoPieceRotate(pieces.first(), origin, angle, m_rotationSum, m_allowChangeMerge); + auto *command = new VPUndoPieceRotate(ConstFirst(pieces), origin, angle, m_rotationSum, m_allowChangeMerge); layout->UndoStack()->push(command); } else if (pieces.size() > 1) @@ -589,7 +589,7 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy) return; } - VPPiecePtr piece = graphicsPieces.first()->GetPiece(); + VPPiecePtr piece = ConstFirst(graphicsPieces)->GetPiece(); if (piece.isNull()) { return; @@ -614,7 +614,7 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy) QList pieces = PreparePieces(); if (pieces.size() == 1) { - VPPiecePtr p = pieces.first(); + const VPPiecePtr &p = ConstFirst(pieces); auto *command = new VPUndoPieceMove(p, dx, dy, m_allowChangeMerge); layout->UndoStack()->push(command); diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 1d4e507dc..833b0b90b 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -166,7 +166,7 @@ auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSh return QSharedPointer(); } - tmpInfo = QPrinterInfo::printerInfo(list.first()); + tmpInfo = QPrinterInfo::printerInfo(ConstFirst(list)); } auto printer = QSharedPointer(new QPrinter(tmpInfo, mode)); @@ -735,7 +735,7 @@ void VPMainWindow::InitPropertyTabCurrentPiece() QList selectedPieces = SelectedPieces(); if (selectedPieces.size() == 1) { - VPPiecePtr selectedPiece = selectedPieces.first(); + const VPPiecePtr &selectedPiece = ConstFirst(selectedPieces); if (not selectedPiece.isNull()) { selectedPiece->SetHideMainPath(not checked); @@ -751,7 +751,7 @@ void VPMainWindow::InitPropertyTabCurrentPiece() QList selectedPieces = SelectedPieces(); if (selectedPieces.size() == 1) { - VPPiecePtr selectedPiece = selectedPieces.first(); + const VPPiecePtr &selectedPiece = ConstFirst(selectedPieces); if (not selectedPiece.isNull()) { if (selectedPiece->IsMirror() != checked) @@ -1284,7 +1284,7 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() ui-> groupBoxCurrentPieceSeamline->setVisible(true); ui->groupBoxCurrentPieceGeometry->setVisible(true); - VPPiecePtr selectedPiece = selectedPieces.first(); + const VPPiecePtr &selectedPiece = ConstFirst(selectedPieces); // set the value to the current piece SetLineEditValue(ui->lineEditCurrentPieceName, selectedPiece->GetName()); @@ -3749,7 +3749,7 @@ void VPMainWindow::on_ApplyPieceTransformation() if (selectedPieces.size() == 1) { - auto *command = new VPUndoPieceMove(selectedPieces.first(), pieceDx, pieceDy); + auto *command = new VPUndoPieceMove(ConstFirst(selectedPieces), pieceDx, pieceDy); m_layout->UndoStack()->push(command); } else @@ -4133,7 +4133,7 @@ void VPMainWindow::on_actionPrintLayout_triggered() QCoreApplication::applicationVersion()); QList sheets = m_layout->GetSheets(); - VPSheetPtr firstSheet = sheets.first(); + const VPSheetPtr &firstSheet = ConstFirst(sheets); if (firstSheet.isNull()) { qCritical() << tr("Unable to get sheet page settings"); @@ -4184,7 +4184,7 @@ void VPMainWindow::on_actionPrintPreviewLayout_triggered() QCoreApplication::applicationVersion()); QList sheets = m_layout->GetSheets(); - VPSheetPtr firstSheet = sheets.first(); + const VPSheetPtr &firstSheet = ConstFirst(sheets); if (firstSheet.isNull()) { qCritical() << tr("Unable to get sheet page settings"); @@ -4219,7 +4219,7 @@ void VPMainWindow::on_actionPrintTiledLayout_triggered() QCoreApplication::applicationVersion()); QList sheets = m_layout->GetSheets(); - VPSheetPtr firstSheet = sheets.first(); + const VPSheetPtr &firstSheet = ConstFirst(sheets); if (firstSheet.isNull()) { qCritical() << tr("Unable to get sheet page settings"); @@ -4258,7 +4258,7 @@ void VPMainWindow::on_actionPrintPreviewTiledLayout_triggered() QList sheets = m_layout->GetSheets(); - VPSheetPtr firstSheet = sheets.first(); + const VPSheetPtr &firstSheet = ConstFirst(sheets); if (firstSheet.isNull()) { qCritical() << tr("Unable to get sheet page settings"); diff --git a/src/app/tape/dialogs/dialogmdatabase.cpp b/src/app/tape/dialogs/dialogmdatabase.cpp index d8f4e4f9a..418baca62 100644 --- a/src/app/tape/dialogs/dialogmdatabase.cpp +++ b/src/app/tape/dialogs/dialogmdatabase.cpp @@ -30,6 +30,7 @@ #include "ui_dialogmdatabase.h" #include "../mapplication.h" #include "../vpatterndb/measurements.h" +#include "../vmisc/compatibility.h" #include #include @@ -409,7 +410,7 @@ void DialogMDataBase::FilterMeasurements(const QString &search) FilterGroup(groupQ, search); const QList list = ui->treeWidget->selectedItems(); - list.isEmpty() ? ShowDescription(nullptr, -1) : ShowDescription(list.first(), 0); + list.isEmpty() ? ShowDescription(nullptr, -1) : ShowDescription(ConstFirst(list), 0); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/core/vcmdexport.cpp b/src/app/valentina/core/vcmdexport.cpp index 7ca6add8a..b64a92bc7 100644 --- a/src/app/valentina/core/vcmdexport.cpp +++ b/src/app/valentina/core/vcmdexport.cpp @@ -528,7 +528,7 @@ QMap VCommandLine::OptUserMaterials() const } bool ok = false; - const int number = parts.first().toInt(&ok); + const int number = ConstFirst(parts).toInt(&ok); if (not ok or number < 1 or number > userMaterialPlaceholdersQuantity) { @@ -537,7 +537,7 @@ QMap VCommandLine::OptUserMaterials() const const_cast(this)->parser.showHelp(V_EX_USAGE); } - userMaterials.insert(number, parts.last()); + userMaterials.insert(number, ConstLast(parts)); } return userMaterials; diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 52551e5d0..2f5a5b020 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -3503,7 +3503,7 @@ void MainWindow::on_actionOpen_triggered() else { //Absolute path to last open file - dir = QFileInfo(files.first()).absolutePath(); + dir = QFileInfo(ConstFirst(files)).absolutePath(); } qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr, @@ -6691,7 +6691,7 @@ void MainWindow::ProcessCMD() VAbstractValApplication::VApp()->SetUserMaterials(cmd->OptUserMaterials()); - const bool loaded = LoadPattern(args.first(), cmd->OptMeasurePath()); + const bool loaded = LoadPattern(ConstFirst(args), cmd->OptMeasurePath()); if (not loaded) { diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index d21d64849..c5bdc2c06 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -269,7 +269,7 @@ void VPattern::setCurrentData() return; } - const quint32 id = localHistory.last().getId(); + const quint32 id = ConstLast(localHistory).getId(); qCDebug(vXML, "Resoring data from tool with id %u", id); if (tools.size() > 0) @@ -325,7 +325,7 @@ VContainer VPattern::GetCompleteData() const return (data != nullptr ? *data : VContainer(nullptr, nullptr, VContainer::UniqueNamespace())); } - const quint32 id = (countPP == 1 ? history.last().getId() : LastToolId()); + const quint32 id = (countPP == 1 ? ConstLast(history).getId() : LastToolId()); if (id == NULL_ID) { @@ -360,7 +360,7 @@ VContainer VPattern::GetCompletePPData(const QString &name) const return (data != nullptr ? *data : VContainer(nullptr, nullptr, VContainer::UniqueNamespace())); } - const quint32 id = (countPP == 1 ? history.last().getId() : PPLastToolId(name)); + const quint32 id = (countPP == 1 ? ConstLast(history).getId() : PPLastToolId(name)); if (id == NULL_ID) { @@ -3689,7 +3689,7 @@ quint32 VPattern::PPLastToolId(const QString &name) const { const QVector localHistory = getLocalHistory(name); - return (not localHistory.isEmpty() ? localHistory.last().getId() : NULL_ID); + return (not localHistory.isEmpty() ? ConstLast(localHistory).getId() : NULL_ID); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/utils.cpp b/src/libs/ifc/xml/utils.cpp index 9ec56c910..2c4a591c1 100644 --- a/src/libs/ifc/xml/utils.cpp +++ b/src/libs/ifc/xml/utils.cpp @@ -35,6 +35,8 @@ #include #include +#include "../vmisc/compatibility.h" + //--------------------------------------------------------------------------------------------------------------------- auto IsMimeTypeImage(const QMimeType &mime) -> bool { @@ -66,7 +68,7 @@ auto MimeTypeFromByteArray(const QByteArray &data) -> QMimeType { QMimeType mime = QMimeDatabase().mimeTypeForData(data); - QSet aliases = mime.aliases().toSet(); + QSet aliases = ConvertToSet(mime.aliases()); aliases.insert(mime.name()); QSet gzipMime {"application/gzip", "application/x-gzip"}; diff --git a/src/libs/ifc/xml/vbackgroundpatternimage.cpp b/src/libs/ifc/xml/vbackgroundpatternimage.cpp index c0230363d..17dd9f635 100644 --- a/src/libs/ifc/xml/vbackgroundpatternimage.cpp +++ b/src/libs/ifc/xml/vbackgroundpatternimage.cpp @@ -28,6 +28,7 @@ #include "vbackgroundpatternimage.h" #include "utils.h" +#include "../vmisc/compatibility.h" #include #include @@ -131,7 +132,7 @@ auto VBackgroundPatternImage::IsValid() const -> bool } QMimeType mime = MimeTypeFromData(); - QSet aliases = mime.aliases().toSet(); + QSet aliases = ConvertToSet(mime.aliases()); aliases.insert(mime.name()); if (not aliases.contains(m_contentType)) diff --git a/src/libs/ifc/xml/vpatternimage.cpp b/src/libs/ifc/xml/vpatternimage.cpp index 6bc21c0ae..ecb49d458 100644 --- a/src/libs/ifc/xml/vpatternimage.cpp +++ b/src/libs/ifc/xml/vpatternimage.cpp @@ -40,6 +40,7 @@ #include #include "utils.h" +#include "../vmisc/compatibility.h" //--------------------------------------------------------------------------------------------------------------------- @@ -110,7 +111,7 @@ auto VPatternImage::IsValid() const -> bool } QMimeType mime = MimeTypeFromData(); - QSet aliases = mime.aliases().toSet(); + QSet aliases = ConvertToSet(mime.aliases()); aliases.insert(mime.name()); if (not aliases.contains(m_contentType)) diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 6fab0f9c1..d1cb5e566 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -177,7 +177,7 @@ void VDxfEngine::drawPath(const QPainterPath &path) poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lineType = getPenStyle(); - if (polygon.size() > 1 && polygon.first() == polygon.last()) + if (polygon.size() > 1 && ConstFirst(polygon) == ConstLast(polygon)) { poly->flags |= 0x1; // closed } @@ -199,7 +199,7 @@ void VDxfEngine::drawPath(const QPainterPath &path) poly->color = getPenColor(); poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lineType = getPenStyle(); - if (polygon.size() > 1 && polygon.first() == polygon.last()) + if (polygon.size() > 1 && ConstFirst(polygon) == ConstLast(polygon)) { poly->flags |= 0x1; // closed } @@ -791,7 +791,7 @@ void VDxfEngine::ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPi const QVector grainline = detail.GetMappedGrainline(); if (grainline.count() > 1) { - if (DRW_Entity *e = AAMALine(QLineF(grainline.first(), grainline.last()), QChar('7'))) + if (DRW_Entity *e = AAMALine(QLineF(ConstFirst(grainline), ConstLast(grainline)), QChar('7'))) { detailBlock->ent.push_back(e); } @@ -1072,22 +1072,22 @@ void VDxfEngine::ExportASTMNotch(dx_ifaceBlock *detailBlock, const VLayoutPiece } else if (passmark.type == PassmarkLineType::VMark || passmark.type == PassmarkLineType::VMark2) { - QLineF boundaryLine = QLineF(passmark.lines.first().p2(), passmark.lines.last().p2()); + QLineF boundaryLine(ConstFirst(passmark.lines).p2(), ConstLast(passmark.lines).p2()); notch->thickness = FromPixel(boundaryLine.length(), varInsunits); // width notch->layer = "4"; } else if (passmark.type == PassmarkLineType::TMark) { - qreal width = FromPixel(passmark.lines.last().length(), varInsunits); + qreal width = FromPixel(ConstLast(passmark.lines).length(), varInsunits); notch->thickness = FromPixel(width, varInsunits); notch->layer = "80"; } else if (passmark.type == PassmarkLineType::BoxMark) { - QPointF start = passmark.lines.first().p1(); - QPointF end = passmark.lines.last().p2(); + QPointF start = ConstFirst(passmark.lines).p1(); + QPointF end = ConstLast(passmark.lines).p2(); notch->layer = "81"; @@ -1095,8 +1095,8 @@ void VDxfEngine::ExportASTMNotch(dx_ifaceBlock *detailBlock, const VLayoutPiece } else if (passmark.type == PassmarkLineType::UMark) { - QPointF start = passmark.lines.first().p1(); - QPointF end = passmark.lines.last().p2(); + QPointF start = ConstFirst(passmark.lines).p1(); + QPointF end = ConstLast(passmark.lines).p2(); notch->thickness = FromPixel(QLineF(start, end).length(), varInsunits); @@ -1184,7 +1184,7 @@ P *VDxfEngine::CreateAAMAPolygon(const QVector &polygon, const QString } else { - if (polygon.size() > 1 && polygon.first() == polygon.last()) + if (polygon.size() > 1 && ConstFirst(polygon) == ConstLast(polygon)) { poly->flags |= 0x1; // closed } diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index af660a77e..a19650a76 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -95,8 +95,8 @@ QVector VAbstractCurve::GetSegmentPoints(const QVector &points if (begin == end) { - start = segment.first(); - finish = segment.last(); + start = ConstFirst(segment); + finish = ConstLast(segment); } bool ok = false; @@ -157,7 +157,7 @@ QVector VAbstractCurve::FromBegin(const QVector &points, const { if (points.count() >= 2) { - if (points.first().toPoint() == begin.toPoint()) + if (ConstFirst(points).toPoint() == begin.toPoint()) { if (ok != nullptr) { @@ -258,7 +258,7 @@ qreal VAbstractCurve::GetLengthByPoint(const QPointF &point) const return -1; } - if (points.first().toPoint() == point.toPoint()) + if (ConstFirst(points).toPoint() == point.toPoint()) { return 0; } diff --git a/src/libs/vgeometry/vcubicbezierpath.cpp b/src/libs/vgeometry/vcubicbezierpath.cpp index ca94123a7..27f14548c 100644 --- a/src/libs/vgeometry/vcubicbezierpath.cpp +++ b/src/libs/vgeometry/vcubicbezierpath.cpp @@ -37,6 +37,7 @@ #include "vcubicbezierpath_p.h" #include "vspline.h" #include "vsplinepoint.h" +#include "../vmisc/compatibility.h" //--------------------------------------------------------------------------------------------------------------------- VCubicBezierPath::VCubicBezierPath(quint32 idObject, Draw mode) @@ -361,7 +362,7 @@ VPointF VCubicBezierPath::FirstPoint() const { if (not d->path.isEmpty()) { - return d->path.first(); + return ConstFirst(d->path); } else { diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp index 284d5ea2c..ed47e56dc 100644 --- a/src/libs/vgeometry/vplacelabelitem.cpp +++ b/src/libs/vgeometry/vplacelabelitem.cpp @@ -364,7 +364,7 @@ PlaceLabelImg VPlaceLabelItem::LabelShape() const QPolygonF shape3(arc.GetPoints()); if (not shape3.isClosed() && not shape3.isEmpty()) { - shape3 << shape3.first(); + shape3 << ConstFirst(shape3); } return PlaceLabelImg({t.map(shape1), t.map(shape2), t.map(shape3)}); @@ -378,7 +378,7 @@ PlaceLabelImg VPlaceLabelItem::LabelShape() const QPolygonF circle(arc.GetPoints()); if (not circle.isClosed() && not circle.isEmpty()) { - circle << circle.first(); + circle << ConstFirst(circle); } return PlaceLabelImg({t.map(circle)}); @@ -428,7 +428,7 @@ QPainterPath VPlaceLabelItem::LabelShapePath(const PlaceLabelImg &shape) { if (not p.isEmpty()) { - path.moveTo(p.first()); + path.moveTo(ConstFirst(p)); path.addPolygon(p); } } diff --git a/src/libs/vgeometry/vsplinepath.cpp b/src/libs/vgeometry/vsplinepath.cpp index e3ec4e726..cbd8a2735 100644 --- a/src/libs/vgeometry/vsplinepath.cpp +++ b/src/libs/vgeometry/vsplinepath.cpp @@ -207,7 +207,7 @@ VSplinePath::~VSplinePath() */ void VSplinePath::append(const VSplinePoint &point) { - if (d->path.size() > 0 && static_cast(d->path.last().P()) == static_cast(point.P())) //-V807 + if (d->path.size() > 0 && static_cast(ConstLast(d->path).P()) == static_cast(point.P())) //-V807 { return; } diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index c52219852..e4098f4f7 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -607,7 +607,7 @@ QVector AngleBySecondRightAngle(QVector points, QPoint if (success) { points = temp; - px = points.last(); + px = ConstLast(points); } if (countBefore > 0) @@ -747,9 +747,9 @@ bool Rollback(QVector &points, const QLineF &edge) if (not points.isEmpty()) { - if (points.last().toPoint() != points.first().toPoint()) + if (ConstLast(points).toPoint() != ConstFirst(points).toPoint()) { - points.append(points.first());// Should be always closed + points.append(ConstFirst(points));// Should be always closed } } } @@ -812,7 +812,7 @@ void RollbackByPointsIntersection(QVector &ekvPoints, const QVector const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width); QVector temp = ekvPoints; temp.insert(ekvPoints.size()-1, bigLine1.p2()); - bool success = Rollback(temp, QLineF(points.last(), points.at(1))); + bool success = Rollback(temp, QLineF(ConstLast(points), points.at(1))); if (success) { @@ -831,7 +831,7 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect { if (not ekvPoints.isEmpty()) { - const QLineF edge(points.last(), points.at(1)); + const QLineF edge(ConstLast(points), points.at(1)); const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width); QPointF px; @@ -843,7 +843,7 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect { if (ekvPoints.size() > 3) { - const QLineF edge1(ekvPoints.at(ekvPoints.size()-2), ekvPoints.last()); + const QLineF edge1(ekvPoints.at(ekvPoints.size()-2), ConstLast(ekvPoints)); const QLineF edge2(ekvPoints.at(0), ekvPoints.at(1)); QPointF crosPoint; @@ -868,7 +868,7 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect if (success) { ekvPoints = temp; - px = ekvPoints.last(); + px = ConstLast(ekvPoints); } QLineF seam(px, points.at(1)); @@ -878,15 +878,15 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect if (not ekvPoints.isEmpty()) { - ekvPoints.append(ekvPoints.first()); + ekvPoints.append(ConstFirst(ekvPoints)); } } if (not ekvPoints.isEmpty()) { - if (ekvPoints.last().toPoint() != ekvPoints.first().toPoint()) + if (ConstLast(ekvPoints).toPoint() != ConstFirst(ekvPoints).toPoint()) { - ekvPoints.append(ekvPoints.first());// Should be always closed + ekvPoints.append(ConstFirst(ekvPoints));// Should be always closed } } } @@ -1081,7 +1081,7 @@ QVector VAbstractPiece::Equidistant(QVector points, qreal wid return QVector(); } - if (points.last().toPoint() != points.first().toPoint()) + if (ConstLast(points).toPoint() != ConstFirst(points).toPoint()) { points.append(points.at(0));// Should be always closed } @@ -1101,7 +1101,7 @@ QVector VAbstractPiece::Equidistant(QVector points, qreal wid {//last point if (not ekvPoints.isEmpty()) { - ekvPoints.append(ekvPoints.first()); + ekvPoints.append(ConstFirst(ekvPoints)); } continue; } @@ -1115,7 +1115,7 @@ QVector VAbstractPiece::Equidistant(QVector points, qreal wid QT_WARNING_DISABLE_GCC("-Wswitch-default") // This check helps to find missed angle types in the switch Q_STATIC_ASSERT_X(static_cast(PieceNodeAngle::LAST_ONE_DO_NOT_USE) == 7, "Not all types were handled."); - switch (points.last().GetAngleType()) + switch (ConstLast(points).GetAngleType()) { case PieceNodeAngle::LAST_ONE_DO_NOT_USE: case PieceNodeAngle::ByFirstEdgeRightAngle: @@ -1229,7 +1229,7 @@ auto VAbstractPiece::CheckLoops(const QVector &points) -> QVector ekvPoints; ekvPoints.reserve(points.size()); diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index eae275ae8..12ce118e0 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -222,9 +222,9 @@ QVector VAbstractPiece::CorrectEquidistantPoints(const QVector &points, bo } } - if (not buf2.isEmpty() && buf2.first() != buf2.last()) + if (not buf2.isEmpty() && ConstFirst(buf2) != ConstLast(buf2)) { - buf2.append(buf2.first()); + buf2.append(ConstFirst(buf2)); } buf2 = RemoveDublicates(buf2, false); @@ -245,7 +245,7 @@ QVector VAbstractPiece::RemoveDublicates(const QVector &points, bool remov QVector p; p.reserve(points.size()); - p.append(points.first()); + p.append(ConstFirst(points)); for (int i = 0; i < points.size(); ++i) { @@ -266,7 +266,7 @@ QVector VAbstractPiece::RemoveDublicates(const QVector &points, bool remov { // Path can't be closed // See issue #686 - if (VFuzzyComparePoints(p.first(), p.last())) + if (VFuzzyComparePoints(ConstFirst(p), ConstLast(p))) { p.removeLast(); } diff --git a/src/libs/vlayout/vcontour.cpp b/src/libs/vlayout/vcontour.cpp index 76fb6adce..fc47b945d 100644 --- a/src/libs/vlayout/vcontour.cpp +++ b/src/libs/vlayout/vcontour.cpp @@ -49,7 +49,7 @@ void AppendToContour(QVector &contour, QPointF point) { if (not contour.isEmpty()) { - if (not VFuzzyComparePoints(contour.last(), point)) + if (not VFuzzyComparePoints(ConstLast(contour), point)) { contour.append(point); } @@ -68,7 +68,7 @@ QVector OptimizeCombining(const QVector &contour, const QPoint return contour; } - QPointF withdrawFirst = contour.last(); + QPointF withdrawFirst = ConstLast(contour); bool optimize = false; int count = 0; int cutIndex = -1; @@ -148,7 +148,7 @@ void VContour::CeateEmptySheetContour() if (d->globalContour.isEmpty()) { d->globalContour = CutEmptySheetEdge(); - d->globalContour.append(d->globalContour.first()); // Close path + d->globalContour.append(ConstFirst(d->globalContour)); // Close path ResetAttributes(); } diff --git a/src/libs/vlayout/vlayoutexporter.cpp b/src/libs/vlayout/vlayoutexporter.cpp index 8e93de220..c4b440719 100644 --- a/src/libs/vlayout/vlayoutexporter.cpp +++ b/src/libs/vlayout/vlayoutexporter.cpp @@ -402,10 +402,11 @@ void VLayoutExporter::PdfToPs(const QStringList ¶ms) QGuiApplication::restoreOverrideCursor(); #endif - QFile f(params.last()); + QFile f(ConstLast(params)); if (not f.exists()) { - qCritical() << qUtf8Printable(tr("Creating file '%1' failed! %2").arg(params.last(), proc.errorString())); + qCritical() << qUtf8Printable(tr("Creating file '%1' failed! %2") + .arg(ConstLast(params), proc.errorString())); } } diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index 2810a953b..68492af0b 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -695,7 +695,7 @@ VLayoutPaper VLayoutGenerator::MasterPage() const { if (papers.size() < 2) { - return papers.first(); + return ConstFirst(papers); } QList > nDetails; diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 767b8f195..c727980b3 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -339,11 +339,11 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer if (side == PassmarkSide::All || side == PassmarkSide::Right) { - layoutPassmark.baseLine = baseLines.first(); + layoutPassmark.baseLine = ConstFirst(baseLines); } else if (side == PassmarkSide::Right) { - layoutPassmark.baseLine = baseLines.last(); + layoutPassmark.baseLine = ConstLast(baseLines); } const QVector lines = passmark.SAPassmark(piece, pattern, side); @@ -761,7 +761,7 @@ QPointF VLayoutPiece::GetPieceTextPosition() const { if (d->detailLabel.count() > 2) { - return d->matrix.map(d->detailLabel.first()); + return d->matrix.map(ConstFirst(d->detailLabel)); } else { @@ -843,7 +843,7 @@ QPointF VLayoutPiece::GetPatternTextPosition() const { if (d->patternInfo.count() > 2) { - return d->matrix.map(d->patternInfo.first()); + return d->matrix.map(ConstFirst(d->patternInfo)); } else { @@ -1335,7 +1335,7 @@ QPainterPath VLayoutPiece::ContourPath() const // Draw seam allowance QVectorpoints = GetSeamAllowancePoints(); - if (points.last().toPoint() != points.first().toPoint()) + if (ConstLast(points).toPoint() != ConstFirst(points).toPoint()) { points.append(points.at(0));// Should be always closed } @@ -1475,7 +1475,7 @@ qreal VLayoutPiece::BiggestEdge() const //--------------------------------------------------------------------------------------------------------------------- QRectF VLayoutPiece::BoundingRect(QVector points) { - points.append(points.first()); + points.append(ConstFirst(points)); return QPolygonF(points).boundingRect(); } diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index c13cdb22c..5fe6e682f 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -297,7 +297,7 @@ void VPosition::SaveCandidate(VBestSquare &bestResult, const VLayoutPiece &detai } QVector newGContour = m_data.gContour.UniteWithContour(detail, globalI, detJ, type); - newGContour.append(newGContour.first()); + newGContour.append(ConstFirst(newGContour)); const QSizeF size = QPolygonF(newGContour).boundingRect().size(); const QRectF boundingRect = detail.MappedDetailBoundingRect(); const qreal depthPosition = m_data.isOriginPaperOrientationPortrait ? boundingRect.y() : boundingRect.x(); diff --git a/src/libs/vlayout/vprintlayout.cpp b/src/libs/vlayout/vprintlayout.cpp index 635ac770c..a38668426 100644 --- a/src/libs/vlayout/vprintlayout.cpp +++ b/src/libs/vlayout/vprintlayout.cpp @@ -51,6 +51,7 @@ #include "../ifc/exception/vexception.h" #include "../vmisc/vmath.h" #include "../vpropertyexplorer/checkablemessagebox.h" +#include "../vmisc/compatibility.h" namespace { @@ -125,10 +126,10 @@ auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSh const QStringList list = QPrinterInfo::availablePrinterNames(); if(list.isEmpty()) { - return QSharedPointer(); + return {}; } - tmpInfo = QPrinterInfo::printerInfo(list.first()); + tmpInfo = QPrinterInfo::printerInfo(ConstFirst(list)); } auto printer = QSharedPointer(new QPrinter(tmpInfo, mode)); diff --git a/src/libs/vmisc/vtablesearch.cpp b/src/libs/vmisc/vtablesearch.cpp index d63d402a7..8d01bcf05 100644 --- a/src/libs/vmisc/vtablesearch.cpp +++ b/src/libs/vmisc/vtablesearch.cpp @@ -35,6 +35,7 @@ #include #include "../vmisc/def.h" +#include "../vmisc/compatibility.h" const int VTableSearch::MaxHistoryRecords = 10; @@ -161,7 +162,7 @@ auto VTableSearch::FindCurrentMatchIndex() const -> int return 0; } - QTableWidgetItem* selectedItem = selectedItems.first(); + QTableWidgetItem* selectedItem = ConstFirst(selectedItems); for (int i=0; i 2) { - point = ekvPoints.first(); + point = ConstFirst(ekvPoints); } else if (ekvPoints.size() == 2) { if(passmarkData.passmarkSAPoint.GetAngleType() == PieceNodeAngle::ByFirstEdgeSymmetry || passmarkData.passmarkSAPoint.GetAngleType() == PieceNodeAngle::ByFirstEdgeRightAngle) { - point = ekvPoints.first(); + point = ConstFirst(ekvPoints); } else { @@ -135,7 +135,7 @@ bool FixNotchPoint(const QVector &seamAllowance, const QPointF ¬chBa const QVector points = VAbstractCurve::CurveIntersectLine(seamAllowance, axis); if (points.size() == 1) { - *notch = points.first(); + *notch = ConstFirst(points); } } @@ -441,18 +441,18 @@ QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType { if (angleType == PassmarkAngleType::Straightforward) { - passmarksLines += (*create)(lines.first(), seamAllowance); + passmarksLines += (*create)(ConstFirst(lines), seamAllowance); } else { if (side == PassmarkSide::All || side == PassmarkSide::Left) { - passmarksLines += (*create)(lines.first(), seamAllowance); + passmarksLines += (*create)(ConstFirst(lines), seamAllowance); } if (side == PassmarkSide::All || side == PassmarkSide::Right) { - passmarksLines += (*create)(lines.last(), seamAllowance); + passmarksLines += (*create)(ConstLast(lines), seamAllowance); } } }; @@ -461,18 +461,18 @@ QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType { if (angleType == PassmarkAngleType::Straightforward) { - passmarksLines += (*create)(lines.first()); + passmarksLines += (*create)(ConstFirst(lines)); } else { if (side == PassmarkSide::All || side == PassmarkSide::Left) { - passmarksLines += (*create)(lines.first()); + passmarksLines += (*create)(ConstFirst(lines)); } if (side == PassmarkSide::All || side == PassmarkSide::Right) { - passmarksLines += (*create)(lines.last()); + passmarksLines += (*create)(ConstLast(lines)); } } }; @@ -519,7 +519,7 @@ QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType switch (lineType) { case PassmarkLineType::TMark: - passmarksLines += CreateTMarkPassmark(lines.first()); + passmarksLines += CreateTMarkPassmark(ConstFirst(lines)); break; case PassmarkLineType::OneLine: case PassmarkLineType::TwoLines: @@ -529,7 +529,7 @@ QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType case PassmarkLineType::UMark: case PassmarkLineType::BoxMark: default: - passmarksLines.append(lines.first()); + passmarksLines.append(ConstFirst(lines)); break; } } @@ -764,7 +764,7 @@ QLineF VPassmark::FindIntersection(const QLineF &line, const QVector &s QVector intersections = VAbstractCurve::CurveIntersectLine(seamAllowance, testLine); if (not intersections.isEmpty()) { - return QLineF(line.p1(), intersections.last()); + return QLineF(line.p1(), ConstLast(intersections)); } return line; @@ -924,9 +924,9 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa if (not intersections.isEmpty()) { - if (intersections.last() != m_data.passmarkSAPoint) + if (ConstLast(intersections) != m_data.passmarkSAPoint) { - line = QLineF(intersections.last(), m_data.passmarkSAPoint); + line = QLineF(ConstLast(intersections), m_data.passmarkSAPoint); bool ok = false; const qreal length = PassmarkLength(m_data, width, ok); diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 27b893372..0efdca90e 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -933,7 +933,7 @@ bool VPiece::GetPassmarkSAPoint(const QVector &path, int index, cons return false; } - point = points.first(); + point = ConstFirst(points); return true; } diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index b5263a753..ebff04b19 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -76,7 +76,7 @@ VSAPoint CurveStartPoint(VSAPoint candidate, const VContainer *data, const VPiec if (not points.isEmpty()) { QPointF end; // Last point for this curve show start of next segment - node.GetReverse() ? end = points.first() : end = points.last(); + node.GetReverse() ? end = ConstFirst(points) : end = ConstLast(points); if (VAbstractCurve::IsPointOnCurve(curvePoints, end)) { candidate = VSAPoint(end); @@ -103,7 +103,7 @@ VSAPoint CurveEndPoint(VSAPoint candidate, const VContainer *data, const VPieceN if (not points.isEmpty()) { QPointF begin;// First point for this curve show finish of previous segment - node.GetReverse() ? begin = points.last() : begin = points.first(); + node.GetReverse() ? begin = ConstLast(points) : begin = ConstFirst(points); if (VAbstractCurve::IsPointOnCurve(curvePoints, begin)) { candidate = VSAPoint(begin); @@ -155,7 +155,7 @@ qreal FindTipDirection(const QVector &points) return 0; } - const QPointF first = points.first(); + const QPointF &first = ConstFirst(points); for(int i = 1; i < points.size(); ++i) { @@ -179,7 +179,7 @@ bool IntersectionWithCuttingCountour(const QVector &cuttingPath, const return false; } - const QPointF first = points.first(); + const QPointF &first = ConstFirst(points); if (VAbstractCurve::IsPointOnCurve(cuttingPath, first)) { // Point is already part of a cutting countour @@ -552,7 +552,7 @@ VSAPoint VPiecePath::StartSegment(const VContainer *data, const QVector 1) { @@ -583,7 +583,7 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector 2) { diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 23a68d068..2de6a133b 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -258,7 +258,7 @@ auto VToolSeamAllowance::Duplicate(VToolSeamAllowanceInitData &initData) -> VToo dupDetail.SetUUID(QUuid::createUuid()); const QMap mappedPins = DuplicatePins(initData.detail.GetPins(), initData); - dupDetail.SetPins(mappedPins.values().toVector()); + dupDetail.SetPins(ConvertToVector(mappedPins.values())); dupDetail.SetPatternPieceData(FixLabelPins(initData.detail.GetPatternPieceData(), mappedPins)); dupDetail.SetPatternInfo(FixLabelPins(initData.detail.GetPatternInfo(), mappedPins)); dupDetail.SetGrainlineGeometry(FixGrainlinePins(initData.detail.GetGrainlineGeometry(), mappedPins)); diff --git a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp index 010f717b8..776d987b3 100644 --- a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp +++ b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp @@ -43,6 +43,7 @@ #include "vispath.h" #include "../vwidgets/scalesceneitems.h" #include "../vmisc/vmodifierkey.h" +#include "../vmisc/compatibility.h" //--------------------------------------------------------------------------------------------------------------------- VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent) @@ -193,7 +194,7 @@ void VisToolCubicBezierPath::Creating(const QVector &pathPoints, int po { case 0: { - const VPointF p1 = pathPoints.last(); + const VPointF &p1 = ConstLast(pathPoints); if (pathPoints.size() >= 4) { QLineF p1p2(static_cast(p1), Visualization::scenePos); diff --git a/src/libs/vtools/visualization/path/vistoolpiece.cpp b/src/libs/vtools/visualization/path/vistoolpiece.cpp index 88dbd2164..1510e4091 100644 --- a/src/libs/vtools/visualization/path/vistoolpiece.cpp +++ b/src/libs/vtools/visualization/path/vistoolpiece.cpp @@ -88,12 +88,12 @@ void VisToolPiece::RefreshGeometry() DrawPath(path, m_cachedCurvesPath.at(i), supportColor); } - DrawLine(m_line1, QLineF(m_cachedMainPathPoints.first(), Visualization::scenePos), supportColor, + DrawLine(m_line1, QLineF(ConstFirst(m_cachedMainPathPoints), Visualization::scenePos), supportColor, Qt::DashLine); if (m_cachedMainPathPoints.size() > 1) { - DrawLine(m_line2, QLineF(m_cachedMainPathPoints.last(), Visualization::scenePos), supportColor, + DrawLine(m_line2, QLineF(ConstLast(m_cachedMainPathPoints), Visualization::scenePos), supportColor, Qt::DashLine); } } diff --git a/src/libs/vtools/visualization/path/vistoolpiecepath.cpp b/src/libs/vtools/visualization/path/vistoolpiecepath.cpp index 98b10bcce..c810468db 100644 --- a/src/libs/vtools/visualization/path/vistoolpiecepath.cpp +++ b/src/libs/vtools/visualization/path/vistoolpiecepath.cpp @@ -30,6 +30,7 @@ #include "../vwidgets/vsimplepoint.h" #include "../vgeometry/vpointf.h" #include "../vwidgets/scalesceneitems.h" +#include "../vmisc/compatibility.h" #include @@ -69,7 +70,7 @@ void VisToolPiecePath::RefreshGeometry() const QVector points = m_path.PathPoints(Visualization::data); if (points.size() > 0) { - DrawLine(m_line, QLineF(points.last(), Visualization::scenePos), supportColor, Qt::DashLine); + DrawLine(m_line, QLineF(ConstLast(points), Visualization::scenePos), supportColor, Qt::DashLine); } } } diff --git a/src/libs/vwidgets/global.cpp b/src/libs/vwidgets/global.cpp index bf033e730..100fe95cd 100644 --- a/src/libs/vwidgets/global.cpp +++ b/src/libs/vwidgets/global.cpp @@ -29,6 +29,7 @@ #include "global.h" #include "../vmisc/def.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/compatibility.h" #include #include @@ -52,7 +53,7 @@ qreal SceneScale(QGraphicsScene *scene) const QList views = scene->views(); if (not views.isEmpty()) { - scale = views.first()->transform().m11(); + scale = ConstFirst(views)->transform().m11(); } } diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp index 0eb3f564a..fc511c7f9 100644 --- a/src/libs/vwidgets/vabstractmainwindow.cpp +++ b/src/libs/vwidgets/vabstractmainwindow.cpp @@ -76,7 +76,7 @@ QStringList RecentFiles(const QStringList &paths) QVector table; table.reserve(paths.size()); - for(auto &path : paths) + for(const auto &path : paths) { table.append(SplitFilePaths(path)); } @@ -84,7 +84,7 @@ QStringList RecentFiles(const QStringList &paths) auto CreateOptimized = [table](int tableRow) { QStringList optimized; - QStringList path = table.at(tableRow); + const QStringList& path = table.at(tableRow); for (int count = 1; count <= path.size(); ++count) { bool isUnique = true; @@ -113,7 +113,8 @@ QStringList RecentFiles(const QStringList &paths) if (optimized.size() >= 3) { - optimized = QStringList({optimized.first(), QStringLiteral("…"), optimized.last()}); + optimized = QStringList({ConstFirst(optimized), QStringLiteral("…"), + ConstLast(optimized)}); } return optimized; diff --git a/src/test/ValentinaTest/tst_varc.cpp b/src/test/ValentinaTest/tst_varc.cpp index f3a916530..5a57d26a0 100644 --- a/src/test/ValentinaTest/tst_varc.cpp +++ b/src/test/ValentinaTest/tst_varc.cpp @@ -45,11 +45,11 @@ void PrepareTestCase(const QPointF ¢er, qreal startAngle, qreal endAngle) const QString testStartAngle = QString("Test start angel. Arc radius %1, start angle %2, end angle %3") .arg(radius).arg(startAngle).arg(endAngle); - QTest::newRow(qUtf8Printable(testStartAngle)) << center << startAngle << points << points.first() << true; + QTest::newRow(qUtf8Printable(testStartAngle)) << center << startAngle << points << ConstFirst(points) << true; const QString testEndAngle = QString("Test end angel. Arc radius %1, start angle %2, end angle %3") .arg(radius).arg(startAngle).arg(endAngle); - QTest::newRow(qUtf8Printable(testEndAngle)) << center << endAngle << points << points.last() << true; + QTest::newRow(qUtf8Printable(testEndAngle)) << center << endAngle << points << ConstLast(points) << true; radius += UnitConvertor(5, Unit::Cm, Unit::Px); }