Use brace initialization to define default value for class members.

Requires less code.
This commit is contained in:
Roman Telezhynskyi 2020-04-23 15:14:56 +03:00
parent d769e9d3e2
commit 7a46b98f5b
6 changed files with 16 additions and 30 deletions

View File

@ -52,8 +52,6 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::PuzzleMainWindow), ui(new Ui::PuzzleMainWindow),
pieceCarrousel(new VPieceCarrousel), pieceCarrousel(new VPieceCarrousel),
m_layout (nullptr),
m_selectedPiece (nullptr),
m_cmd(cmd) m_cmd(cmd)
{ {
ui->setupUi(this); ui->setupUi(this);

View File

@ -80,9 +80,9 @@ private:
VPieceCarrousel *pieceCarrousel; VPieceCarrousel *pieceCarrousel;
VPuzzleCommandLinePtr m_cmd; VPuzzleCommandLinePtr m_cmd;
VPuzzleLayout *m_layout; VPuzzleLayout *m_layout{nullptr};
VPuzzlePiece *m_selectedPiece; VPuzzlePiece *m_selectedPiece{nullptr};
void InitMenuBar(); void InitMenuBar();

View File

@ -28,10 +28,7 @@
#include "vpuzzlelayer.h" #include "vpuzzlelayer.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer::VPuzzleLayer() : VPuzzleLayer::VPuzzleLayer()
m_name(QString("")),
m_pieces(QList<VPuzzlePiece*>()),
m_isVisible(true)
{ {
} }

View File

@ -51,11 +51,11 @@ public:
bool GetIsVisible() const; bool GetIsVisible() const;
private: private:
QString m_name; QString m_name{};
QList<VPuzzlePiece *> m_pieces; QList<VPuzzlePiece *> m_pieces{};
// control // control
bool m_isVisible; bool m_isVisible{true};
}; };

View File

@ -30,16 +30,7 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayout::VPuzzleLayout() : VPuzzleLayout::VPuzzleLayout() :
m_unplacedPiecesLayer(new VPuzzleLayer()), m_unplacedPiecesLayer(new VPuzzleLayer())
m_layers(QList<VPuzzleLayer *>()),
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)
{ {
} }

View File

@ -173,31 +173,31 @@ public:
private: private:
Q_DISABLE_COPY(VPuzzleLayout) Q_DISABLE_COPY(VPuzzleLayout)
VPuzzleLayer *m_unplacedPiecesLayer; VPuzzleLayer *m_unplacedPiecesLayer;
QList<VPuzzleLayer *> m_layers; QList<VPuzzleLayer *> m_layers{};
// format // format
Unit m_unit; Unit m_unit{Unit::Cm};
/** /**
* @brief m_size the Size in Unit::Px * @brief m_size the Size in Unit::Px
*/ */
QSizeF m_size; QSizeF m_size{};
// margins // margins
/** /**
* @brief m_margins the margins in Unit::Px * @brief m_margins the margins in Unit::Px
*/ */
QMarginsF m_margins; QMarginsF m_margins{};
// control // control
FollowGrainline m_followGrainLine; FollowGrainline m_followGrainLine{FollowGrainline::No};
/** /**
* @brief m_piecesGap the pieces gap in Unit::Px * @brief m_piecesGap the pieces gap in Unit::Px
*/ */
qreal m_piecesGap; qreal m_piecesGap{0};
bool m_warningSuperpositionOfPieces; bool m_warningSuperpositionOfPieces{false};
bool m_warningPiecesOutOfBound; bool m_warningPiecesOutOfBound{false};
bool m_stickyEdges; bool m_stickyEdges{false};
}; };