diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index feb47c10f..13107fa28 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -636,7 +636,7 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const QVector &li QList scenes = CreateScenes(papers, shadows, details); const bool ignorePrinterFields = false; - const qreal margin = ToPixel(1, Unit::Cm); + Q_RELAXED_CONSTEXPR qreal margin = ToPixel(1, Unit::Cm); ExportFlatLayout(scenes, papers, shadows, details, ignorePrinterFields, QMarginsF(margin, margin, margin, margin)); qDeleteAll(scenes); // Scene will clear all other items diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 0157b16be..7dd0f2857 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -758,14 +758,13 @@ Q_DECL_RELAXED_CONSTEXPR static inline auto VFuzzyComparePossibleNulls(double p1 { return qFuzzyIsNull(p2); } - else if (qFuzzyIsNull(p2)) + + if (qFuzzyIsNull(p2)) { return false; } - else - { - return qFuzzyCompare(p1, p2); - } + + return qFuzzyCompare(p1, p2); } /** diff --git a/src/libs/vtools/dialogs/tools/dialogalongline.cpp b/src/libs/vtools/dialogs/tools/dialogalongline.cpp index 3926cb42d..1e3efaea9 100644 --- a/src/libs/vtools/dialogs/tools/dialogalongline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogalongline.cpp @@ -44,9 +44,9 @@ #include "../../visualization/line/vistoolalongline.h" #include "../../visualization/visualization.h" +#include "../ifc/ifcdef.h" #include "../ifc/xml/vabstractpattern.h" #include "../support/dialogeditwrongformula.h" -#include "../vgeometry/../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" #include "../vmisc/theme/vtheme.h" #include "../vmisc/vabstractapplication.h" @@ -57,6 +57,12 @@ #include "../vwidgets/vabstractmainwindow.h" #include "ui_dialogalongline.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogAlongLine create dialog @@ -297,7 +303,7 @@ void DialogAlongLine::ChosenSecondPoint(quint32 id, const QString &toolTip) line->SetPoint2Id(id); if (m_buildMidpoint) { - SetFormula(currentLength + QStringLiteral("/2")); + SetFormula(currentLength + "/2"_L1); line->SetMode(Mode::Show); } else diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index 305290d79..9c1ae99b3 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -162,7 +162,7 @@ void DialogCurveIntersectAxis::SetAngle(const QString &value) } ui->plainTextEditFormula->setPlainText(formulaAngle); - VisToolCurveIntersectAxis *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->SetAngle(formulaAngle); @@ -180,7 +180,7 @@ void DialogCurveIntersectAxis::SetBasePointId(quint32 value) { setCurrentPointId(ui->comboBoxAxisPoint, value); - VisToolCurveIntersectAxis *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->setAxisPointId(value); } @@ -196,7 +196,7 @@ void DialogCurveIntersectAxis::setCurveId(quint32 value) { setCurrentCurveId(ui->comboBoxCurve, value); - VisToolCurveIntersectAxis *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->SetCurveId(value); } @@ -268,7 +268,7 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { number++; line->VisualMode(id); - VAbstractMainWindow *window = + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(line, &VisToolCurveIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip); @@ -323,7 +323,7 @@ void DialogCurveIntersectAxis::DeployAngleTextEdit() //--------------------------------------------------------------------------------------------------------------------- void DialogCurveIntersectAxis::FXAngle() { - DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); + auto *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit angle")); dialog->SetFormula(GetAngle()); dialog->setPostfix(degreeSymbol); @@ -346,7 +346,7 @@ void DialogCurveIntersectAxis::SaveData() pointName = ui->lineEditNamePoint->text(); formulaAngle = ui->plainTextEditFormula->toPlainText(); - VisToolCurveIntersectAxis *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->SetCurveId(getCurveId()); diff --git a/src/libs/vtools/dialogs/tools/dialogendline.cpp b/src/libs/vtools/dialogs/tools/dialogendline.cpp index cec46af14..fd244ba7f 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogendline.cpp @@ -175,7 +175,7 @@ void DialogEndLine::DeployAngleTextEdit() //--------------------------------------------------------------------------------------------------------------------- void DialogEndLine::FXAngle() { - DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); + auto *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit angle")); dialog->SetFormula(GetAngle()); dialog->setPostfix(degreeSymbol); @@ -189,7 +189,7 @@ void DialogEndLine::FXAngle() //--------------------------------------------------------------------------------------------------------------------- void DialogEndLine::FXLength() { - DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); + auto *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); @@ -381,7 +381,7 @@ void DialogEndLine::SaveData() formulaLength = ui->plainTextEditFormula->toPlainText(); formulaAngle = ui->plainTextEditAngle->toPlainText(); - VisToolEndLine *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->SetBasePointId(GetBasePointId()); diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index 003c19418..7376562b1 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -77,7 +77,7 @@ auto GetOriginPoint(const QVector &objects, const VContainer *data, { QPolygonF originObjects; - for (auto object : objects) + for (const auto &object : objects) { const QSharedPointer obj = data->GetGObject(object.id); @@ -193,7 +193,7 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove * initData.id = initData.data->getNextId(); // Just reserve id for tool - for (auto object : qAsConst(initData.source)) + for (const auto &object : qAsConst(initData.source)) { const QSharedPointer obj = initData.data->GetGObject(object.id); @@ -314,7 +314,7 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove * } VAbstractTool::AddRecord(initData.id, Tool::Move, initData.doc); - VToolMove *tool = new VToolMove(initData); + auto *tool = new VToolMove(initData); initData.scene->addItem(tool); InitOperationToolConnections(initData.scene, tool); VAbstractPattern::AddTool(initData.id, tool); @@ -324,7 +324,7 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove * initData.doc->IncrementReferens(originPoint->getIdTool()); } - for (auto object : qAsConst(initData.source)) + for (const auto &object : qAsConst(initData.source)) { initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool()); } @@ -354,7 +354,7 @@ auto VToolMove::GetFormulaAngle() const -> VFormula //--------------------------------------------------------------------------------------------------------------------- void VToolMove::SetFormulaAngle(const VFormula &value) { - if (value.error() == false) + if (!value.error()) { formulaAngle = value.GetFormula(FormulaType::FromUser); @@ -377,7 +377,7 @@ auto VToolMove::GetFormulaRotationAngle() const -> VFormula //--------------------------------------------------------------------------------------------------------------------- void VToolMove::SetFormulaRotationAngle(const VFormula &value) { - if (value.error() == false) + if (!value.error()) { formulaRotationAngle = value.GetFormula(FormulaType::FromUser); @@ -493,10 +493,10 @@ void VToolMove::ReadToolAttributes(const QDomElement &domElement) { VAbstractOperation::ReadToolAttributes(domElement); - origPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); - formulaAngle = doc->GetParametrString(domElement, AttrAngle, QChar('0')); - formulaRotationAngle = doc->GetParametrString(domElement, AttrRotationAngle, QChar('0')); - formulaLength = doc->GetParametrString(domElement, AttrLength, QChar('0')); + origPointId = VDomDocument::GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); + formulaAngle = VDomDocument::GetParametrString(domElement, AttrAngle, QChar('0')); + formulaRotationAngle = VDomDocument::GetParametrString(domElement, AttrRotationAngle, QChar('0')); + formulaLength = VDomDocument::GetParametrString(domElement, AttrLength, QChar('0')); } //--------------------------------------------------------------------------------------------------------------------- @@ -527,8 +527,8 @@ auto VToolMove::MakeToolTip() const -> QString tr("Rotation angle")) // 6 .arg(GetFormulaRotationAngle().getDoubleValue()) // 7 .arg(tr("Rotation origin point"), // 8 - OriginPointName()) // 9 - .arg(VisibilityGroupToolTip()); // 10 + OriginPointName(), // 9 + VisibilityGroupToolTip()); // 10 } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp index 689d0d1a3..7012221e9 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp @@ -216,7 +216,7 @@ auto VToolEllipticalArc::GetFormulaRadius1() const -> VFormula //--------------------------------------------------------------------------------------------------------------------- void VToolEllipticalArc::SetFormulaRadius1(const VFormula &value) { - if (value.error() == false) + if (!value.error()) { if (value.getDoubleValue() > 0) // Formula don't check this, but radius1 can't be 0 or negative { @@ -245,7 +245,7 @@ auto VToolEllipticalArc::GetFormulaRadius2() const -> VFormula //--------------------------------------------------------------------------------------------------------------------- void VToolEllipticalArc::SetFormulaRadius2(const VFormula &value) { - if (value.error() == false) + if (!value.error()) { if (value.getDoubleValue() > 0) // Formula don't check this, but radius2 can't be 0 or negative { @@ -274,7 +274,7 @@ auto VToolEllipticalArc::GetFormulaF1() const -> VFormula //--------------------------------------------------------------------------------------------------------------------- void VToolEllipticalArc::SetFormulaF1(const VFormula &value) { - if (value.error() == false) + if (!value.error()) { QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer elArc = qSharedPointerDynamicCast(obj); @@ -300,7 +300,7 @@ auto VToolEllipticalArc::GetFormulaF2() const -> VFormula //--------------------------------------------------------------------------------------------------------------------- void VToolEllipticalArc::SetFormulaF2(const VFormula &value) { - if (value.error() == false) + if (!value.error()) { QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer elArc = qSharedPointerDynamicCast(obj); @@ -326,7 +326,7 @@ auto VToolEllipticalArc::GetFormulaRotationAngle() const -> VFormula //--------------------------------------------------------------------------------------------------------------------- void VToolEllipticalArc::SetFormulaRotationAngle(const VFormula &value) { - if (value.error() == false) + if (!value.error()) { QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer elArc = qSharedPointerDynamicCast(obj); diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.h b/src/libs/vtools/visualization/line/operation/vistoolmove.h index 79c3d0d65..6fd9306ad 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.h +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.h @@ -29,7 +29,6 @@ #ifndef VISTOOLMOVE_H #define VISTOOLMOVE_H - #include #include #include @@ -45,6 +44,7 @@ class VisToolMove : public VisOperation { Q_OBJECT // NOLINT + public: explicit VisToolMove(const VContainer *data, QGraphicsItem *parent = nullptr); ~VisToolMove() override = default; @@ -63,24 +63,27 @@ public: void SetRotationOriginPointId(quint32 value); - auto type() const -> int override {return Type;} - enum {Type = UserType + static_cast(Vis::ToolMove)}; + auto type() const -> int override { return Type; } + enum + { + Type = UserType + static_cast(Vis::ToolMove) + }; + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolMove) // NOLINT - qreal m_angle{0}; - qreal m_rotationAngle{INT_MIN}; - qreal m_length{0}; + qreal m_angle{0}; + qreal m_rotationAngle{INT_MIN}; + qreal m_length{0}; VScaledEllipse *m_pointOrigin{nullptr}; VScaledEllipse *m_pointRotationOrigin{nullptr}; VScaledEllipse *m_pointFinish{nullptr}; VCurvePathItem *m_angleArc{nullptr}; - VScaledLine *m_rotationLine{nullptr}; - VScaledLine *m_xAxis{nullptr}; - quint32 m_rotationOriginId{NULL_ID}; + VScaledLine *m_rotationLine{nullptr}; + VScaledLine *m_xAxis{nullptr}; + quint32 m_rotationOriginId{NULL_ID}; - template - auto AddOriginCurve(quint32 id, int &i) -> QGraphicsPathItem *; + template auto AddOriginCurve(quint32 id, int &i) -> QGraphicsPathItem *; template auto AddMovedRotatedCurve(qreal angle, qreal length, quint32 id, int i, qreal rotationAngle, diff --git a/src/libs/vtools/visualization/visualization.cpp b/src/libs/vtools/visualization/visualization.cpp index 38a570fe6..29e46e4da 100644 --- a/src/libs/vtools/visualization/visualization.cpp +++ b/src/libs/vtools/visualization/visualization.cpp @@ -288,14 +288,13 @@ auto Visualization::GetCurveItem(QVector &curves, quint32 i, V //--------------------------------------------------------------------------------------------------------------------- auto Visualization::LengthToUser(qreal value) -> QString { - return VAbstractApplication::VApp()->TrVars()->FormulaToUser( - QString::number(VAbstractValApplication::VApp()->fromPixel(value)), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + auto *app = VAbstractValApplication::VApp(); + return app->TrVars()->FormulaToUser(QString::number(app->fromPixel(value)), app->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- auto Visualization::AngleToUser(qreal value) -> QString { - return VAbstractApplication::VApp()->TrVars()->FormulaToUser( - QString::number(value), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + auto *app = VAbstractApplication::VApp(); + return app->TrVars()->FormulaToUser(QString::number(value), app->Settings()->GetOsSeparator()); } diff --git a/src/test/ValentinaTest/qttestmainlambda.cpp b/src/test/ValentinaTest/qttestmainlambda.cpp index 28ade2488..f568dccbf 100644 --- a/src/test/ValentinaTest/qttestmainlambda.cpp +++ b/src/test/ValentinaTest/qttestmainlambda.cpp @@ -76,7 +76,7 @@ auto main(int argc, char **argv) -> int int status = 0; auto ASSERT_TEST = [&status, argc, argv](QObject *obj) { - status |= QTest::qExec(obj, argc, argv); + status |= QTest::qExec(obj, argc, argv); // NOLINT(hicpp-signed-bitwise) delete obj; }; diff --git a/src/test/ValentinaTest/tst_varc.h b/src/test/ValentinaTest/tst_varc.h index 998924c45..039643e29 100644 --- a/src/test/ValentinaTest/tst_varc.h +++ b/src/test/ValentinaTest/tst_varc.h @@ -34,6 +34,7 @@ class TST_VArc : public AbstractTest { Q_OBJECT // NOLINT + public: explicit TST_VArc(QObject *parent = nullptr);