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/qquickrangeslider.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/qquickrangeslider.cpp')
-rw-r--r-- | src/quicktemplates2/qquickrangeslider.cpp | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 35797203..569d7645 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -98,14 +98,7 @@ class QQuickRangeSliderNodePrivate : public QObjectPrivate public: QQuickRangeSliderNodePrivate(qreal value, QQuickRangeSlider *slider) : value(value), - isPendingValue(false), - pendingValue(0), - position(0), - handle(nullptr), - slider(slider), - pressed(false), - hovered(false), - touchId(-1) + slider(slider) { } @@ -119,15 +112,15 @@ public: static QQuickRangeSliderNodePrivate *get(QQuickRangeSliderNode *node); - qreal value; - bool isPendingValue; - qreal pendingValue; - qreal position; + qreal value = 0; + bool isPendingValue = false; + qreal pendingValue = 0; + qreal position = 0; QQuickDeferredPointer<QQuickItem> handle; - QQuickRangeSlider *slider; - bool pressed; - bool hovered; - int touchId; + QQuickRangeSlider *slider = nullptr; + bool pressed = false; + bool hovered = false; + int touchId = -1; }; bool QQuickRangeSliderNodePrivate::isFirst() const @@ -355,18 +348,6 @@ class QQuickRangeSliderPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickRangeSlider) public: - QQuickRangeSliderPrivate() - : live(true), - from(defaultFrom), - to(defaultTo), - stepSize(0), - first(nullptr), - second(nullptr), - orientation(Qt::Horizontal), - snapMode(QQuickRangeSlider::NoSnap) - { - } - QQuickRangeSliderNode *pressedNode(int touchId = -1) const; #if QT_CONFIG(quicktemplates2_multitouch) @@ -379,15 +360,15 @@ public: void updateHover(const QPointF &pos); - bool live; - qreal from; - qreal to; - qreal stepSize; - QQuickRangeSliderNode *first; - QQuickRangeSliderNode *second; + bool live = true; + qreal from = defaultFrom; + qreal to = defaultTo; + qreal stepSize = 0; + QQuickRangeSliderNode *first = nullptr; + QQuickRangeSliderNode *second = nullptr; QPointF pressPoint; - Qt::Orientation orientation; - QQuickRangeSlider::SnapMode snapMode; + Qt::Orientation orientation = Qt::Horizontal; + QQuickRangeSlider::SnapMode snapMode = QQuickRangeSlider::NoSnap; }; static qreal valueAt(const QQuickRangeSlider *slider, qreal position) |