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),
ui(new Ui::PuzzleMainWindow),
pieceCarrousel(new VPieceCarrousel),
m_layout (nullptr),
m_selectedPiece (nullptr),
m_cmd(cmd)
{
ui->setupUi(this);

View File

@ -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();

View File

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

View File

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

View File

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

View File

@ -173,31 +173,31 @@ public:
private:
Q_DISABLE_COPY(VPuzzleLayout)
VPuzzleLayer *m_unplacedPiecesLayer;
QList<VPuzzleLayer *> m_layers;
QList<VPuzzleLayer *> 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};
};