move object construction to initialization list

This commit is contained in:
laserpants 2016-06-21 15:23:10 +03:00
parent 427dd30f03
commit f92c66cc0e
2 changed files with 33 additions and 29 deletions

View File

@ -6,12 +6,27 @@
#include <QMouseEvent>
#include <QApplication>
SliderPrivate::SliderPrivate(Slider *q)
: q_ptr(q),
thumb(new SliderThumb(q)),
track(new SliderTrack(q)),
machine(0),
hoverTrack(false),
hoverThumb(false),
hover(false),
step(false),
pageStepMode(true),
stepTo(0),
oldValue(0),
trackWidth(2),
useThemeColors(true)
{
}
void SliderPrivate::init()
{
Q_Q(Slider);
thumb = new SliderThumb(q);
track = new SliderTrack(q);
machine = new SliderStateMachine(q, thumb, track);
oldValue = q->value();

View File

@ -13,18 +13,7 @@ class SliderPrivate
Q_DECLARE_PUBLIC(Slider)
public:
SliderPrivate(Slider *q)
: q_ptr(q),
hoverTrack(false),
hoverThumb(false),
hover(false),
step(false),
pageStepMode(true),
stepTo(0),
oldValue(0),
trackWidth(2),
useThemeColors(true)
{}
SliderPrivate(Slider *q);
void init();
@ -35,22 +24,22 @@ public:
void setHovered(bool status);
Slider *const q_ptr;
SliderThumb *thumb;
SliderTrack *track;
Slider *const q_ptr;
SliderThumb *const thumb;
SliderTrack *const track;
SliderStateMachine *machine;
bool hoverTrack;
bool hoverThumb;
bool hover;
bool step;
bool pageStepMode;
int stepTo;
int oldValue;
int trackWidth;
QColor thumbColor;
QColor trackColor;
QColor disabledColor;
bool useThemeColors;
bool hoverTrack;
bool hoverThumb;
bool hover;
bool step;
bool pageStepMode;
int stepTo;
int oldValue;
int trackWidth;
QColor thumbColor;
QColor trackColor;
QColor disabledColor;
bool useThemeColors;
};
#endif // SLIDER_P_H