WDraggableSpinBox: Make use of in-class initializers where applicable

This commit is contained in:
Lioncash 2020-06-28 06:54:38 -04:00
parent 37ada5110d
commit 012faba4cc
2 changed files with 18 additions and 23 deletions

View File

@ -7,10 +7,6 @@
WDraggableSpinBox::WDraggableSpinBox(QWidget *parent) WDraggableSpinBox::WDraggableSpinBox(QWidget *parent)
: QDoubleSpinBox(parent) : QDoubleSpinBox(parent)
, mBeingDragged(false)
, mDefaultValue(0)
, mMinDecimals(1)
, mTrimTrailingZeroes(true)
{ {
setMinimum(-1000000.0); setMinimum(-1000000.0);
setMaximum(1000000.0); setMaximum(1000000.0);
@ -18,9 +14,7 @@ WDraggableSpinBox::WDraggableSpinBox(QWidget *parent)
lineEdit()->installEventFilter(this); lineEdit()->installEventFilter(this);
} }
WDraggableSpinBox::~WDraggableSpinBox() WDraggableSpinBox::~WDraggableSpinBox() = default;
{
}
void WDraggableSpinBox::mousePressEvent(QMouseEvent *pEvent) void WDraggableSpinBox::mousePressEvent(QMouseEvent *pEvent)
{ {
@ -145,7 +139,7 @@ QString WDraggableSpinBox::textFromValue(double Val) const
return Str; return Str;
} }
bool WDraggableSpinBox::IsBeingDragged() bool WDraggableSpinBox::IsBeingDragged() const
{ {
return mBeingDragged; return mBeingDragged;
} }

View File

@ -6,23 +6,24 @@
class WDraggableSpinBox : public QDoubleSpinBox class WDraggableSpinBox : public QDoubleSpinBox
{ {
Q_OBJECT Q_OBJECT
bool mBeingDragged; bool mBeingDragged = false;
bool mBeenDragged; bool mBeenDragged = false;
double mDefaultValue; double mDefaultValue = 0.0;
int mLastY; int mLastY = 0;
int mMinDecimals; int mMinDecimals = 1;
bool mTrimTrailingZeroes; bool mTrimTrailingZeroes = true;
public: public:
explicit WDraggableSpinBox(QWidget *pParent = 0); explicit WDraggableSpinBox(QWidget *pParent = nullptr);
~WDraggableSpinBox(); ~WDraggableSpinBox() override;
void mousePressEvent(QMouseEvent *pEvent);
void mouseReleaseEvent(QMouseEvent *pEvent); void mousePressEvent(QMouseEvent* pEvent) override;
void mouseMoveEvent(QMouseEvent *pEvent); void mouseReleaseEvent(QMouseEvent* pEvent) override;
void wheelEvent(QWheelEvent *pEvent); void mouseMoveEvent(QMouseEvent* pEvent) override;
bool eventFilter(QObject *pObj, QEvent *pEvent); void wheelEvent(QWheelEvent* pEvent) override;
QString textFromValue(double Val) const; bool eventFilter(QObject* pObj, QEvent* pEvent) override;
bool IsBeingDragged(); QString textFromValue(double Val) const override;
bool IsBeingDragged() const;
void SetDefaultValue(double Value); void SetDefaultValue(double Value);
void SetMinDecimals(int Dec); void SetMinDecimals(int Dec);
void TrimTrailingZeroes(bool Trim); void TrimTrailingZeroes(bool Trim);