From 850d51adac4b3cc9be97ecf25d0f8437a892b164 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 2 Mar 2015 19:54:33 +0200 Subject: [PATCH] cppcheck. --HG-- branch : release --- src/app/geometry/vspline.cpp | 4 ++-- src/app/geometry/vspline.h | 4 ++-- src/app/tools/drawTools/vtoolspline.cpp | 2 +- src/app/tools/drawTools/vtoolspline.h | 2 +- src/app/version.cpp | 5 +++-- src/app/xml/vpattern.cpp | 4 ++-- src/libs/vlayout/vlayoutdetail.cpp | 2 +- src/libs/vlayout/vlayoutdetail.h | 2 +- src/libs/vlayout/vlayoutpaper.cpp | 11 ----------- src/libs/vlayout/vlayoutpaper.h | 1 - src/libs/vlayout/vposition.cpp | 2 +- 11 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/app/geometry/vspline.cpp b/src/app/geometry/vspline.cpp index 4f891af4d..8e5f4c5a5 100644 --- a/src/app/geometry/vspline.cpp +++ b/src/app/geometry/vspline.cpp @@ -746,7 +746,7 @@ void VSpline::SetKcurve(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- -int VSpline::Sign(long double ld) const +int VSpline::Sign(long double ld) { if (qAbs(ld)<0.00000000001) { @@ -774,7 +774,7 @@ int VSpline::Sign(long double ld) const * 1 - 1 real root + 2 complex; * 2 - 1 real root + complex roots imaginary part is zero (i.e. 2 real roots). */ -qint32 VSpline::Cubic(QVector &x, qreal a, qreal b, qreal c) const +qint32 VSpline::Cubic(QVector &x, qreal a, qreal b, qreal c) { //To find cubic equation roots in the case of real coefficients, calculated at the beginning const qreal q = (pow(a, 2) - 3*b)/9.; diff --git a/src/app/geometry/vspline.h b/src/app/geometry/vspline.h index 4e55b1d65..1e4ee833d 100644 --- a/src/app/geometry/vspline.h +++ b/src/app/geometry/vspline.h @@ -83,8 +83,8 @@ private: void CreateName(); QVector CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4, qreal pointCoord) const; - qint32 Cubic(QVector &x, qreal a, qreal b, qreal c) const; - int Sign(long double ld) const; + static qint32 Cubic(QVector &x, qreal a, qreal b, qreal c); + static int Sign(long double ld); }; #endif // VSPLINE_H diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index f097b1129..310c2e567 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -45,7 +45,7 @@ const QString VToolSpline::ToolType = QStringLiteral("simple"); * @param typeCreation way we create this tool. * @param parent parent object. */ -VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QString color, const Source &typeCreation, +VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QString &color, const Source &typeCreation, QGraphicsItem *parent) :VAbstractSpline(doc, data, id, parent), oldPosition() { diff --git a/src/app/tools/drawTools/vtoolspline.h b/src/app/tools/drawTools/vtoolspline.h index 7d6d5acfb..39d2e67ab 100644 --- a/src/app/tools/drawTools/vtoolspline.h +++ b/src/app/tools/drawTools/vtoolspline.h @@ -38,7 +38,7 @@ class VToolSpline:public VAbstractSpline { Q_OBJECT public: - VToolSpline (VPattern *doc, VContainer *data, quint32 id, const QString color, const Source &typeCreation, + VToolSpline (VPattern *doc, VContainer *data, quint32 id, const QString &color, const Source &typeCreation, QGraphicsItem * parent = nullptr ); virtual ~VToolSpline(); virtual void setDialog(); diff --git a/src/app/version.cpp b/src/app/version.cpp index 631b100c1..f80d99b43 100644 --- a/src/app/version.cpp +++ b/src/app/version.cpp @@ -53,14 +53,15 @@ QString compilerString() #elif defined(Q_CC_MSVC) if (_MSC_VER >= 1800) // 1800: MSVC 2013 (yearly release cycle) { - return QLatin1String("MSVC ") + QString::number(2008 + ((_MSC_VER / 100) - 13)); + compiler = QLatin1String("MSVC ") + QString::number(2008 + ((_MSC_VER / 100) - 13)); } if (_MSC_VER >= 1500) // 1500: MSVC 2008, 1600: MSVC 2010, ... (2-year release cycle) { return QLatin1String("MSVC ") + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15)); } -#endif +#else return QLatin1String(""); +#endif } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 56d637832..a09250938 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -1647,9 +1647,9 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do { SCASSERT(scene != nullptr); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - quint32 id = 0; try { + quint32 id = 0; ToolsCommonAttributes(domElement, id); const quint32 firstPoint = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); const quint32 secondPoint = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); @@ -2065,7 +2065,6 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - quint32 id = 0; QStringList tools{VToolUnionDetails::ToolType}; switch (tools.indexOf(type)) @@ -2073,6 +2072,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d case 0: //VToolUnionDetails::ToolType try { + quint32 id = 0; ToolsCommonAttributes(domElement, id); const quint32 indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1"); const quint32 indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1"); diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 55c7a3d29..b0d249425 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -366,7 +366,7 @@ QVector VLayoutDetail::Map(const QVector &points) const } //--------------------------------------------------------------------------------------------------------------------- -QVector VLayoutDetail::RoundPoints(const QVector &points) const +QVector VLayoutDetail::RoundPoints(const QVector &points) { QVector p; for (int i=0; i < points.size(); ++i) diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutdetail.h index 58dbfc85b..591cf12cd 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutdetail.h @@ -82,7 +82,7 @@ private: QSharedDataPointer d; QVector Map(const QVector &points) const; - QVector RoundPoints(const QVector &points) const; + static QVector RoundPoints(const QVector &points); }; #endif // VLAYOUTDETAIL_H diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 258a94604..dbdcbe15f 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -258,17 +258,6 @@ bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutDetail return bestResult.ValideResult(); // Do we have the best result? } -//--------------------------------------------------------------------------------------------------------------------- -void VLayoutPaper::SaveCandidate(VBestSquare &bestResult, const VLayoutDetail &detail, int globalI, int detJ, - BestFrom type) -{ - QVector newGContour = d->globalContour.UniteWithContour(detail, globalI, detJ, type); - newGContour.append(newGContour.first()); - const QRectF rec = QPolygonF(newGContour).boundingRect(); - bestResult.NewResult(static_cast(rec.width()*rec.height()), globalI, detJ, - detail.GetMatrix(), detail.IsMirror(), type); -} - //--------------------------------------------------------------------------------------------------------------------- QGraphicsRectItem *VLayoutPaper::GetPaperItem() const { diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h index 5bbac84d1..8ff7d0698 100644 --- a/src/libs/vlayout/vlayoutpaper.h +++ b/src/libs/vlayout/vlayoutpaper.h @@ -78,7 +78,6 @@ private: bool AddToSheet(const VLayoutDetail &detail, bool &stop); bool SaveResult(const VBestSquare &bestResult, const VLayoutDetail &detail); - void SaveCandidate(VBestSquare &bestResult, const VLayoutDetail &detail, int globalI, int detJ, BestFrom type); }; diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index c28dc3f6c..de0472f01 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -47,7 +47,7 @@ VPosition::VPosition(const VContour &gContour, int j, const VLayoutDetail &detai { if ((rotationIncrease >= 1 && rotationIncrease <= 180 && 360 % rotationIncrease == 0) == false) { - rotationIncrease = 180; + this->rotationIncrease = 180; } }