aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickswipedelegate.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-05-03 11:23:56 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2018-05-04 12:53:00 +0000
commitaea55d29d2555c5649c13d3bc11bde4799c6bac5 (patch)
tree52434edff3041005f98b6899566fce119855efae /src/quicktemplates2/qquickswipedelegate.cpp
parenta5d2731b1ec56580a79784759307d3b3c21ab87f (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/qquickswipedelegate.cpp')
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp50
1 files changed, 16 insertions, 34 deletions
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index dcf93437..fab50116 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -127,7 +127,7 @@ protected:
void finished() override;
private:
- QQuickSwipe *m_swipe;
+ QQuickSwipe *m_swipe = nullptr;
};
class QQuickSwipePrivate : public QObjectPrivate
@@ -135,23 +135,7 @@ class QQuickSwipePrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QQuickSwipe)
public:
- QQuickSwipePrivate(QQuickSwipeDelegate *control)
- : control(control),
- positionBeforePress(0),
- position(0),
- wasComplete(false),
- complete(false),
- enabled(true),
- left(nullptr),
- behind(nullptr),
- right(nullptr),
- leftItem(nullptr),
- behindItem(nullptr),
- rightItem(nullptr),
- transition(nullptr),
- transitionManager(nullptr)
- {
- }
+ QQuickSwipePrivate(QQuickSwipeDelegate *control) : control(control) { }
static QQuickSwipePrivate *get(QQuickSwipe *swipe);
@@ -175,24 +159,24 @@ public:
void beginTransition(qreal position);
void finishTransition();
- QQuickSwipeDelegate *control;
+ QQuickSwipeDelegate *control = nullptr;
// Same range as position, but is set before press events so that we can
// keep track of which direction the user must swipe when using left and right delegates.
- qreal positionBeforePress;
- qreal position;
+ qreal positionBeforePress = 0;
+ qreal position = 0;
// A "less strict" version of complete that is true if complete was true
// before the last press event.
- bool wasComplete;
- bool complete;
- bool enabled;
+ bool wasComplete = false;
+ bool complete = false;
+ bool enabled = true;
QQuickVelocityCalculator velocityCalculator;
- QQmlComponent *left;
- QQmlComponent *behind;
- QQmlComponent *right;
- QQuickItem *leftItem;
- QQuickItem *behindItem;
- QQuickItem *rightItem;
- QQuickTransition *transition;
+ QQmlComponent *left = nullptr;
+ QQmlComponent *behind = nullptr;
+ QQmlComponent *right = nullptr;
+ QQuickItem *leftItem = nullptr;
+ QQuickItem *behindItem = nullptr;
+ QQuickItem *rightItem = nullptr;
+ QQuickTransition *transition = nullptr;
QScopedPointer<QQuickSwipeTransitionManager> transitionManager;
};
@@ -1245,10 +1229,8 @@ class QQuickSwipeDelegateAttachedPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QQuickSwipeDelegateAttached)
public:
- QQuickSwipeDelegateAttachedPrivate() : pressed(false) { }
-
// True when left/right/behind is non-interactive and is pressed.
- bool pressed;
+ bool pressed = false;
};
/*!