From 4c73ab529a4389f7e60c6e7cbf3042823e21a0ff Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 18 Feb 2022 10:15:34 +0200 Subject: [PATCH] Code style. --- src/app/puzzle/layout/vppiece.cpp | 2 +- src/app/puzzle/layout/vppiece.h | 13 ++++++++----- src/app/puzzle/layout/vpsheet.cpp | 15 ++++++++------- src/app/puzzle/layout/vpsheet.h | 22 +++++++++++++--------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index bdc220e38..280532ddb 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -503,7 +503,7 @@ auto VPPiece::IsValid() const -> bool } //--------------------------------------------------------------------------------------------------------------------- -quint16 VPPiece::CopyNumber() const +auto VPPiece::CopyNumber() const -> quint16 { return m_copyNumber; } diff --git a/src/app/puzzle/layout/vppiece.h b/src/app/puzzle/layout/vppiece.h index 03b7d60d2..55a3f7b8f 100644 --- a/src/app/puzzle/layout/vppiece.h +++ b/src/app/puzzle/layout/vppiece.h @@ -36,6 +36,10 @@ #include "../vlayout/vlayoutpiece.h" #include "../layout/layoutdef.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#include "../vmisc/defglobal.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) + class VPLayout; class VPSheet; @@ -44,12 +48,11 @@ class VPPiece : public VLayoutPiece public: VPPiece() = default; explicit VPPiece(const VLayoutPiece &layoutPiece); - virtual ~VPPiece() = default; + ~VPPiece() override = default; void Update(const VPPiecePtr &piece); - virtual auto GetUniqueID() const -> QString override; - + auto GetUniqueID() const -> QString override; void ClearTransformations(); @@ -126,7 +129,7 @@ public: void SetCopyNumber(quint16 newCopyNumber); private: - Q_DISABLE_COPY(VPPiece) + Q_DISABLE_COPY_MOVE(VPPiece) // NOLINT VPLayoutWeakPtr m_layout{}; @@ -200,6 +203,6 @@ inline void VPPiece::SetHasSuperpositionWithPieces(bool newHasSuperpositionWithP m_hasSuperpositionWithPieces = newHasSuperpositionWithPieces; } -Q_DECLARE_METATYPE(VPPiecePtr) +Q_DECLARE_METATYPE(VPPiecePtr) // NOLINT #endif // VPPIECE_H diff --git a/src/app/puzzle/layout/vpsheet.cpp b/src/app/puzzle/layout/vpsheet.cpp index 2e2d1a5b1..dce19f0db 100644 --- a/src/app/puzzle/layout/vpsheet.cpp +++ b/src/app/puzzle/layout/vpsheet.cpp @@ -140,7 +140,7 @@ void VPSheetSceneData::PrepareForExport() VPSheetPtr sheet = layout->GetSheet(m_sheetUuid); m_slectedPiecesTmp = sheet->GetSelectedPieces(); - for (const auto& piece : m_slectedPiecesTmp) + for (const auto& piece : qAsConst(m_slectedPiecesTmp)) { if (not piece.isNull()) { @@ -171,7 +171,7 @@ void VPSheetSceneData::CleanAfterExport() layout->LayoutSettings().SetShowGrid(m_showGridTmp); layout->LayoutSettings().SetShowTiles(m_showTilesTmp); - for (const auto& piece : m_slectedPiecesTmp) + for (const auto& piece : qAsConst(m_slectedPiecesTmp)) { if (not piece.isNull()) { @@ -319,9 +319,10 @@ void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece) // VPSheet //--------------------------------------------------------------------------------------------------------------------- -VPSheet::VPSheet(const VPLayoutPtr &layout) : - m_layout(layout), - m_sceneData(new VPSheetSceneData(layout, Uuid())) +VPSheet::VPSheet(const VPLayoutPtr &layout, QObject *parent) + : QObject(parent), + m_layout(layout), + m_sceneData(new VPSheetSceneData(layout, Uuid())) { SCASSERT(not layout.isNull()) @@ -574,7 +575,7 @@ void VPSheet::ValidatePiecesOutOfBound() const //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetSheetRect() const -> QRectF { - return QRectF(QPoint(0, 0), m_size); + return {QPoint(0, 0), m_size}; } //--------------------------------------------------------------------------------------------------------------------- @@ -587,7 +588,7 @@ auto VPSheet::GetMarginsRect() const -> QRectF return rect; } - return QRectF(0, 0, m_size.width(), m_size.height()); + return {0, 0, m_size.width(), m_size.height()}; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/layout/vpsheet.h b/src/app/puzzle/layout/vpsheet.h index 8a138ff98..f9e39da78 100644 --- a/src/app/puzzle/layout/vpsheet.h +++ b/src/app/puzzle/layout/vpsheet.h @@ -37,6 +37,10 @@ #include "def.h" #include "layoutdef.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#include "../vmisc/defglobal.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) + class VPLayout; class VPPiece; class VMainGraphicsScene; @@ -53,7 +57,7 @@ public: explicit VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheetUuid); ~VPSheetSceneData(); - VMainGraphicsScene *Scene() const; + auto Scene() const -> VMainGraphicsScene *; /** * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin @@ -90,7 +94,7 @@ public: void RefreshSheetSize(); private: - Q_DISABLE_COPY(VPSheetSceneData) + Q_DISABLE_COPY_MOVE(VPSheetSceneData) // NOLINT VPLayoutWeakPtr m_layout{}; @@ -130,11 +134,11 @@ private: class VPSheet : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: - explicit VPSheet(const VPLayoutPtr &layout); + explicit VPSheet(const VPLayoutPtr &layout, QObject *parent = nullptr); - virtual ~VPSheet() = default; + ~VPSheet() override = default; /** * @brief GetLayout Returns the Layout of the sheet @@ -162,7 +166,7 @@ public: auto Uuid() const -> const QUuid &; - bool IsVisible() const; + auto IsVisible() const -> bool; void SetVisible(bool visible); auto GrainlineOrientation() const -> GrainlineType; @@ -268,7 +272,7 @@ public: auto IgnoreMargins() const -> bool; void SetIgnoreMargins(bool newIgnoreMargins); - VPSheetSceneData *SceneData() const; + auto SceneData() const -> VPSheetSceneData *; void ClearSelection() const; @@ -278,7 +282,7 @@ public slots: void CheckPiecePositionValidity(const VPPiecePtr &piece) const; private: - Q_DISABLE_COPY(VPSheet) + Q_DISABLE_COPY_MOVE(VPSheet) // NOLINT VPLayoutWeakPtr m_layout{}; @@ -312,6 +316,6 @@ private: }; -Q_DECLARE_METATYPE(VPSheetPtr) +Q_DECLARE_METATYPE(VPSheetPtr) // NOLINT #endif // VPSHEET_H