Refactoring VAbstractPieceData class.

This commit is contained in:
Roman Telezhynskyi 2022-11-04 16:12:58 +02:00
parent fbe81aac36
commit acc8d73271
2 changed files with 20 additions and 37 deletions

View File

@ -50,9 +50,6 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QtMath> #include <QtMath>
const quint32 VAbstractPieceData::streamHeader = 0x05CDD73A; // CRC-32Q string "VAbstractPieceData"
const quint16 VAbstractPieceData::classVersion = 3;
const qreal maxL = 3.5; const qreal maxL = 3.5;
namespace namespace

View File

@ -51,54 +51,40 @@ class VAbstractPieceData : public QSharedData
{ {
Q_DECLARE_TR_FUNCTIONS(VAbstractPieceData) // NOLINT Q_DECLARE_TR_FUNCTIONS(VAbstractPieceData) // NOLINT
public: public:
VAbstractPieceData() VAbstractPieceData() = default;
{}
VAbstractPieceData(const VAbstractPieceData &piece) VAbstractPieceData(const VAbstractPieceData &piece) = default;
: QSharedData(piece),
m_name(piece.m_name),
m_forbidFlipping(piece.m_forbidFlipping),
m_forceFlipping(piece.m_forceFlipping),
m_seamAllowance(piece.m_seamAllowance),
m_seamAllowanceBuiltIn(piece.m_seamAllowanceBuiltIn),
m_hideMainPath(piece.m_hideMainPath),
m_width(piece.m_width),
m_mx(piece.m_mx),
m_my(piece.m_my),
m_priority(piece.m_priority),
m_uuid(piece.m_uuid)
{}
~VAbstractPieceData() = default; ~VAbstractPieceData() = default;
friend QDataStream& operator<<(QDataStream& dataStream, const VAbstractPieceData& piece); friend auto operator<<(QDataStream& dataStream, const VAbstractPieceData& piece) -> QDataStream&;
friend QDataStream& operator>>(QDataStream& dataStream, VAbstractPieceData& piece); friend auto operator>>(QDataStream& dataStream, VAbstractPieceData& piece) -> QDataStream&;
QString m_name{tr("Detail")}; QString m_name{tr("Detail")}; // NOLINT (misc-non-private-member-variables-in-classes)
/** @brief forbidFlipping forbid piece be mirrored in a layout. */ /** @brief forbidFlipping forbid piece be mirrored in a layout. */
bool m_forbidFlipping{false}; bool m_forbidFlipping{false}; // NOLINT (misc-non-private-member-variables-in-classes)
bool m_forceFlipping{false}; bool m_forceFlipping{false}; // NOLINT (misc-non-private-member-variables-in-classes)
bool m_seamAllowance{false}; bool m_seamAllowance{false}; // NOLINT (misc-non-private-member-variables-in-classes)
bool m_seamAllowanceBuiltIn{false}; bool m_seamAllowanceBuiltIn{false}; // NOLINT (misc-non-private-member-variables-in-classes)
bool m_hideMainPath{false}; bool m_hideMainPath{false}; // NOLINT (misc-non-private-member-variables-in-classes)
qreal m_width{0}; qreal m_width{0}; // NOLINT (misc-non-private-member-variables-in-classes)
qreal m_mx{0}; qreal m_mx{0}; // NOLINT (misc-non-private-member-variables-in-classes)
qreal m_my{0}; qreal m_my{0}; // NOLINT (misc-non-private-member-variables-in-classes)
uint m_priority{0}; uint m_priority{0}; // NOLINT (misc-non-private-member-variables-in-classes)
QUuid m_uuid{QUuid::createUuid()}; QUuid m_uuid{QUuid::createUuid()}; // NOLINT (misc-non-private-member-variables-in-classes)
private: private:
Q_DISABLE_ASSIGN(VAbstractPieceData) Q_DISABLE_ASSIGN_MOVE(VAbstractPieceData) // NOLINT
static const quint32 streamHeader; static constexpr quint32 streamHeader = 0x05CDD73A; // CRC-32Q string "VAbstractPieceData"
static const quint16 classVersion; static constexpr quint16 classVersion = 3;
}; };
QT_WARNING_POP QT_WARNING_POP
// Friend functions // Friend functions
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline QDataStream &operator<<(QDataStream &dataStream, const VAbstractPieceData &piece) inline auto operator<<(QDataStream &dataStream, const VAbstractPieceData &piece) -> QDataStream &
{ {
dataStream << VAbstractPieceData::streamHeader << VAbstractPieceData::classVersion; dataStream << VAbstractPieceData::streamHeader << VAbstractPieceData::classVersion;
@ -123,7 +109,7 @@ inline QDataStream &operator<<(QDataStream &dataStream, const VAbstractPieceData
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline QDataStream &operator>>(QDataStream &dataStream, VAbstractPieceData &piece) inline auto operator>>(QDataStream &dataStream, VAbstractPieceData &piece) -> QDataStream &
{ {
quint32 actualStreamHeader = 0; quint32 actualStreamHeader = 0;
dataStream >> actualStreamHeader; dataStream >> actualStreamHeader;