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

View File

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