From 4192af811762aa05fd51a514dcd27d06195d822b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 8 May 2019 15:17:34 +0300 Subject: [PATCH] Refactoring. --HG-- branch : develop --- src/libs/vgeometry/vplacelabelitem_p.h | 33 ++++-------- src/libs/vpatterndb/vpiecenode_p.h | 51 +++++-------------- src/libs/vpatterndb/vpiecepath_p.h | 33 ++++-------- .../tools/nodeDetails/vtoolplacelabel.h | 19 +++---- src/libs/vwidgets/vscenepoint.cpp | 6 +-- 5 files changed, 42 insertions(+), 100 deletions(-) diff --git a/src/libs/vgeometry/vplacelabelitem_p.h b/src/libs/vgeometry/vplacelabelitem_p.h index 3eccc3965..4e25784d3 100644 --- a/src/libs/vgeometry/vplacelabelitem_p.h +++ b/src/libs/vgeometry/vplacelabelitem_p.h @@ -41,17 +41,6 @@ class VPlaceLabelItemData : public QSharedData { public: VPlaceLabelItemData() - : width(), - height(), - angle('0'), - visibilityTrigger('1'), - type(PlaceLabelType::Button), - centerPoint(0), - wValue(0), - hValue(0), - aValue(0), - correctionAngle(0), - isVisible(1) {} VPlaceLabelItemData(const VPlaceLabelItemData &item) @@ -71,18 +60,18 @@ public: virtual ~VPlaceLabelItemData(); - QString width; - QString height; - QString angle; - QString visibilityTrigger; - PlaceLabelType type; - quint32 centerPoint; + QString width{}; + QString height{}; + QString angle{'0'}; + QString visibilityTrigger{'1'}; + PlaceLabelType type{PlaceLabelType::Button}; + quint32 centerPoint{0}; - qreal wValue; - qreal hValue; - qreal aValue; - qreal correctionAngle; - qreal isVisible; + qreal wValue{0}; + qreal hValue{0}; + qreal aValue{0}; + qreal correctionAngle{0}; + qreal isVisible{1}; private: VPlaceLabelItemData &operator=(const VPlaceLabelItemData &) Q_DECL_EQ_DELETE; diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h index 86875bfcb..f68b2bfb6 100644 --- a/src/libs/vpatterndb/vpiecenode_p.h +++ b/src/libs/vpatterndb/vpiecenode_p.h @@ -43,35 +43,12 @@ class VPieceNodeData : public QSharedData { public: VPieceNodeData() - : m_id(NULL_ID), - m_typeTool(Tool::NodePoint), - m_reverse(false), - m_excluded(false), - m_isPassmark(false), - m_isMainPathNode(true), - m_formulaWidthBefore(currentSeamAllowance), - m_formulaWidthAfter(currentSeamAllowance), - m_angleType(PieceNodeAngle::ByLength), - m_passmarkLineType(PassmarkLineType::OneLine), - m_passmarkAngleType(PassmarkAngleType::Straightforward), - m_isShowSecondPassmark(true), - m_checkUniqueness(true) {} VPieceNodeData(quint32 id, Tool typeTool, bool reverse) : m_id(id), m_typeTool(typeTool), - m_reverse(reverse), - m_excluded(false), - m_isPassmark(false), - m_isMainPathNode(true), - m_formulaWidthBefore(currentSeamAllowance), - m_formulaWidthAfter(currentSeamAllowance), - m_angleType(PieceNodeAngle::ByLength), - m_passmarkLineType(PassmarkLineType::OneLine), - m_passmarkAngleType(PassmarkAngleType::Straightforward), - m_isShowSecondPassmark(true), - m_checkUniqueness(true) + m_reverse(reverse) { if (m_typeTool == Tool::NodePoint) { @@ -104,39 +81,39 @@ public: friend QDataStream& operator>>(QDataStream& in, VPieceNodeData& p); /** @brief id object id. */ - quint32 m_id; + quint32 m_id{NULL_ID}; /** @brief typeTool type of tool */ - Tool m_typeTool; + Tool m_typeTool{Tool::NodePoint}; /** @brief reverse true if need reverse points list for node. */ - bool m_reverse; + bool m_reverse{false}; /** @brief m_excluded true if item excluded from main path. Excluded item is not visible and also will not has * affect on main path. Also include to exist path items automatically setted excluded. */ - bool m_excluded; + bool m_excluded{false}; /** @brief m_isPassmark has sense only for points. If true to seam allowance should be added a passmark. */ - bool m_isPassmark; + bool m_isPassmark{false}; /** @brief m_isMainPathNode need fin know if allowed for this passmakr to be double. */ - bool m_isMainPathNode; + bool m_isMainPathNode{true}; - QString m_formulaWidthBefore; - QString m_formulaWidthAfter; + QString m_formulaWidthBefore{currentSeamAllowance}; + QString m_formulaWidthAfter{currentSeamAllowance}; QString m_formulaPassmarkLength{}; - PieceNodeAngle m_angleType; + PieceNodeAngle m_angleType{PieceNodeAngle::ByLength}; - PassmarkLineType m_passmarkLineType; - PassmarkAngleType m_passmarkAngleType; + PassmarkLineType m_passmarkLineType{PassmarkLineType::OneLine}; + PassmarkAngleType m_passmarkAngleType{PassmarkAngleType::Straightforward}; - bool m_isShowSecondPassmark; + bool m_isShowSecondPassmark{true}; /** @brief m_checkUniqueness need in cases where different points have the same coordinates, become one point. * By default the check enabled. Disable it only if in a path cannot be used just one point. For example if * gradation change a piece shape and the seond point should be remaind.*/ - bool m_checkUniqueness; + bool m_checkUniqueness{true}; bool m_manualPassmarkLength{false}; diff --git a/src/libs/vpatterndb/vpiecepath_p.h b/src/libs/vpatterndb/vpiecepath_p.h index 5ee4303b4..e0b2b12bc 100644 --- a/src/libs/vpatterndb/vpiecepath_p.h +++ b/src/libs/vpatterndb/vpiecepath_p.h @@ -43,25 +43,10 @@ class VPiecePathData : public QSharedData { public: VPiecePathData() - : m_nodes(), - m_type(PiecePathType::Unknown), - m_name(), - m_penType(Qt::SolidLine), - m_cut(false), - m_visibilityTrigger('1'), - m_firstToCuttingCountour(false), - m_lastToCuttingCountour(false) {} explicit VPiecePathData(PiecePathType type) - : m_nodes(), - m_type(type), - m_name(), - m_penType(Qt::SolidLine), - m_cut(false), - m_visibilityTrigger('1'), - m_firstToCuttingCountour(false), - m_lastToCuttingCountour(false) + : m_type(type) {} VPiecePathData(const VPiecePathData &path) @@ -78,14 +63,14 @@ public: ~VPiecePathData(); - QVector m_nodes; - PiecePathType m_type; - QString m_name; - Qt::PenStyle m_penType; - bool m_cut; - QString m_visibilityTrigger; - bool m_firstToCuttingCountour; - bool m_lastToCuttingCountour; + QVector m_nodes{}; + PiecePathType m_type{PiecePathType::Unknown}; + QString m_name{}; + Qt::PenStyle m_penType{Qt::SolidLine}; + bool m_cut{false}; + QString m_visibilityTrigger{'1'}; + bool m_firstToCuttingCountour{false}; + bool m_lastToCuttingCountour{false}; private: VPiecePathData &operator=(const VPiecePathData &) Q_DECL_EQ_DELETE; diff --git a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h index 008867e4e..f66678ecf 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h +++ b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h @@ -38,21 +38,14 @@ class DialogTool; struct VToolPlaceLabelInitData : VAbstractNodeInitData { VToolPlaceLabelInitData() - : VAbstractNodeInitData(), - width('0'), - height('0'), - angle('0'), - type(PlaceLabelType::Button), - centerPoint(NULL_ID), - visibilityTrigger('1') {} - QString width; - QString height; - QString angle; - PlaceLabelType type; - quint32 centerPoint; - QString visibilityTrigger; + QString width{'0'}; + QString height{'0'}; + QString angle{'0'}; + PlaceLabelType type{PlaceLabelType::Button}; + quint32 centerPoint{NULL_ID}; + QString visibilityTrigger{'1'}; }; class VToolPlaceLabel : public VAbstractNode diff --git a/src/libs/vwidgets/vscenepoint.cpp b/src/libs/vwidgets/vscenepoint.cpp index 26316ce37..1cb493134 100644 --- a/src/libs/vwidgets/vscenepoint.cpp +++ b/src/libs/vwidgets/vscenepoint.cpp @@ -44,16 +44,14 @@ //--------------------------------------------------------------------------------------------------------------------- VScenePoint::VScenePoint(QGraphicsItem *parent) : QGraphicsEllipseItem(parent), - m_namePoint(nullptr), - m_lineName(nullptr), + m_namePoint(new VGraphicsSimpleTextItem(this)), + m_lineName(new VScaledLine(this)), m_onlyPoint(false), m_isHovered(false), m_showLabel(true), m_baseColor(Qt::black), m_selectedFromChild(false) { - m_namePoint = new VGraphicsSimpleTextItem(this); - m_lineName = new VScaledLine(this); m_lineName->SetBoldLine(false); m_lineName->setLine(QLineF(0, 0, 1, 0)); m_lineName->setVisible(false);