From 012faba4cc802d4a981fa3aa8ef258a1b44dcef9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 28 Jun 2020 06:54:38 -0400 Subject: [PATCH] WDraggableSpinBox: Make use of in-class initializers where applicable --- src/Editor/Widgets/WDraggableSpinBox.cpp | 10 ++------ src/Editor/Widgets/WDraggableSpinBox.h | 31 ++++++++++++------------ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/Editor/Widgets/WDraggableSpinBox.cpp b/src/Editor/Widgets/WDraggableSpinBox.cpp index fb380837..608fbee2 100644 --- a/src/Editor/Widgets/WDraggableSpinBox.cpp +++ b/src/Editor/Widgets/WDraggableSpinBox.cpp @@ -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; } diff --git a/src/Editor/Widgets/WDraggableSpinBox.h b/src/Editor/Widgets/WDraggableSpinBox.h index 2aeb1622..cfcf8027 100644 --- a/src/Editor/Widgets/WDraggableSpinBox.h +++ b/src/Editor/Widgets/WDraggableSpinBox.h @@ -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);