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 <QMouseEvent>
#include <QApplication> #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() void SliderPrivate::init()
{ {
Q_Q(Slider); Q_Q(Slider);
thumb = new SliderThumb(q);
track = new SliderTrack(q);
machine = new SliderStateMachine(q, thumb, track); machine = new SliderStateMachine(q, thumb, track);
oldValue = q->value(); oldValue = q->value();

View File

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