From 7a46b98f5b4224ea781986ddad7ac156c92032f3 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 23 Apr 2020 15:14:56 +0300 Subject: [PATCH] Use brace initialization to define default value for class members. Requires less code. --- src/app/puzzle/puzzlemainwindow.cpp | 2 -- src/app/puzzle/puzzlemainwindow.h | 4 ++-- src/app/puzzle/vpuzzlelayer.cpp | 5 +---- src/app/puzzle/vpuzzlelayer.h | 6 +++--- src/app/puzzle/vpuzzlelayout.cpp | 11 +---------- src/app/puzzle/vpuzzlelayout.h | 18 +++++++++--------- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index ff2ccd065..825700fb5 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -52,8 +52,6 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa QMainWindow(parent), ui(new Ui::PuzzleMainWindow), pieceCarrousel(new VPieceCarrousel), - m_layout (nullptr), - m_selectedPiece (nullptr), m_cmd(cmd) { ui->setupUi(this); diff --git a/src/app/puzzle/puzzlemainwindow.h b/src/app/puzzle/puzzlemainwindow.h index a3518f391..ed47a3e1c 100644 --- a/src/app/puzzle/puzzlemainwindow.h +++ b/src/app/puzzle/puzzlemainwindow.h @@ -80,9 +80,9 @@ private: VPieceCarrousel *pieceCarrousel; VPuzzleCommandLinePtr m_cmd; - VPuzzleLayout *m_layout; + VPuzzleLayout *m_layout{nullptr}; - VPuzzlePiece *m_selectedPiece; + VPuzzlePiece *m_selectedPiece{nullptr}; void InitMenuBar(); diff --git a/src/app/puzzle/vpuzzlelayer.cpp b/src/app/puzzle/vpuzzlelayer.cpp index 67b466279..e70e33255 100644 --- a/src/app/puzzle/vpuzzlelayer.cpp +++ b/src/app/puzzle/vpuzzlelayer.cpp @@ -28,10 +28,7 @@ #include "vpuzzlelayer.h" //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer::VPuzzleLayer() : - m_name(QString("")), - m_pieces(QList()), - m_isVisible(true) +VPuzzleLayer::VPuzzleLayer() { } diff --git a/src/app/puzzle/vpuzzlelayer.h b/src/app/puzzle/vpuzzlelayer.h index 01d94c174..978393e0d 100644 --- a/src/app/puzzle/vpuzzlelayer.h +++ b/src/app/puzzle/vpuzzlelayer.h @@ -51,11 +51,11 @@ public: bool GetIsVisible() const; private: - QString m_name; - QList m_pieces; + QString m_name{}; + QList m_pieces{}; // control - bool m_isVisible; + bool m_isVisible{true}; }; diff --git a/src/app/puzzle/vpuzzlelayout.cpp b/src/app/puzzle/vpuzzlelayout.cpp index 538a8f1c2..cebf0bf7f 100644 --- a/src/app/puzzle/vpuzzlelayout.cpp +++ b/src/app/puzzle/vpuzzlelayout.cpp @@ -30,16 +30,7 @@ //--------------------------------------------------------------------------------------------------------------------- VPuzzleLayout::VPuzzleLayout() : - m_unplacedPiecesLayer(new VPuzzleLayer()), - m_layers(QList()), - m_unit(Unit::Cm), - m_size(QSizeF()), - m_margins(QMarginsF()), - m_followGrainLine(FollowGrainline::No), - m_piecesGap(0), - m_warningSuperpositionOfPieces(false), - m_warningPiecesOutOfBound(false), - m_stickyEdges(false) + m_unplacedPiecesLayer(new VPuzzleLayer()) { } diff --git a/src/app/puzzle/vpuzzlelayout.h b/src/app/puzzle/vpuzzlelayout.h index 7c59579fe..04caf479b 100644 --- a/src/app/puzzle/vpuzzlelayout.h +++ b/src/app/puzzle/vpuzzlelayout.h @@ -173,31 +173,31 @@ public: private: Q_DISABLE_COPY(VPuzzleLayout) VPuzzleLayer *m_unplacedPiecesLayer; - QList m_layers; + QList m_layers{}; // format - Unit m_unit; + Unit m_unit{Unit::Cm}; /** * @brief m_size the Size in Unit::Px */ - QSizeF m_size; + QSizeF m_size{}; // margins /** * @brief m_margins the margins in Unit::Px */ - QMarginsF m_margins; + QMarginsF m_margins{}; // control - FollowGrainline m_followGrainLine; + FollowGrainline m_followGrainLine{FollowGrainline::No}; /** * @brief m_piecesGap the pieces gap in Unit::Px */ - qreal m_piecesGap; - bool m_warningSuperpositionOfPieces; - bool m_warningPiecesOutOfBound; - bool m_stickyEdges; + qreal m_piecesGap{0}; + bool m_warningSuperpositionOfPieces{false}; + bool m_warningPiecesOutOfBound{false}; + bool m_stickyEdges{false}; };