diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-05-03 11:23:56 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2018-05-04 12:53:00 +0000 |
commit | aea55d29d2555c5649c13d3bc11bde4799c6bac5 (patch) | |
tree | 52434edff3041005f98b6899566fce119855efae /src/quicktemplates2/qquickspinbox.cpp | |
parent | a5d2731b1ec56580a79784759307d3b3c21ab87f (diff) |
Templates: use C++11 default member initialization
The code is more readable and less error-prone (this patch caught a few
uninitialized members) when the members are initialized in the same
place where they are declared. In many cases, empty default destructors
can be entirely removed, and we get faster implicitly declared inline
default constructors defined by the compiler.
Change-Id: I14c5448afc901f9b2ac5965f28c1c26c0b646c08
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickspinbox.cpp')
-rw-r--r-- | src/quicktemplates2/qquickspinbox.cpp | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 7412936c..08c59cca 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -108,22 +108,6 @@ class QQuickSpinBoxPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickSpinBox) public: - QQuickSpinBoxPrivate() - : editable(false), - wrap(false), - from(0), - to(99), - value(0), - stepSize(1), - delayTimer(0), - repeatTimer(0), - up(nullptr), - down(nullptr), - validator(nullptr), - inputMethodHints(Qt::ImhDigitsOnly) - { - } - int boundValue(int value, bool wrap) const; void updateValue(); bool setValue(int value, bool wrap, bool modified); @@ -151,21 +135,21 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; - bool editable; - bool wrap; - int from; - int to; - int value; - int stepSize; - int delayTimer; - int repeatTimer; + bool editable = false; + bool wrap = false; + int from = 0; + int to = 99; + int value = 0; + int stepSize = 1; + int delayTimer = 0; + int repeatTimer = 0; QString displayText; - QQuickSpinButton *up; - QQuickSpinButton *down; - QValidator *validator; + QQuickSpinButton *up = nullptr; + QQuickSpinButton *down = nullptr; + QValidator *validator = nullptr; mutable QJSValue textFromValue; mutable QJSValue valueFromText; - Qt::InputMethodHints inputMethodHints; + Qt::InputMethodHints inputMethodHints = Qt::ImhDigitsOnly; }; class QQuickSpinButtonPrivate : public QObjectPrivate @@ -173,13 +157,6 @@ class QQuickSpinButtonPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickSpinButton) public: - QQuickSpinButtonPrivate() - : pressed(false), - hovered(false), - indicator(nullptr) - { - } - static QQuickSpinButtonPrivate *get(QQuickSpinButton *button) { return button->d_func(); @@ -188,8 +165,8 @@ public: void cancelIndicator(); void executeIndicator(bool complete = false); - bool pressed; - bool hovered; + bool pressed = false; + bool hovered = false; QQuickDeferredPointer<QQuickItem> indicator; }; |