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/qquicktabbar.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/qquicktabbar.cpp')
-rw-r--r-- | src/quicktemplates2/qquicktabbar.cpp | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp index cd0c5c45..2d732152 100644 --- a/src/quicktemplates2/qquicktabbar.cpp +++ b/src/quicktemplates2/qquicktabbar.cpp @@ -100,8 +100,6 @@ class QQuickTabBarPrivate : public QQuickContainerPrivate Q_DECLARE_PUBLIC(QQuickTabBar) public: - QQuickTabBarPrivate(); - void updateCurrentItem(); void updateCurrentIndex(); void updateLayout(); @@ -110,12 +108,12 @@ public: void itemImplicitWidthChanged(QQuickItem *item) override; void itemImplicitHeightChanged(QQuickItem *item) override; - bool updatingLayout; - bool hasContentWidth; - bool hasContentHeight; - qreal contentWidth; - qreal contentHeight; - QQuickTabBar::Position position; + bool updatingLayout = false; + bool hasContentWidth = false; + bool hasContentHeight = false; + qreal contentWidth = 0; + qreal contentHeight = 0; + QQuickTabBar::Position position = QQuickTabBar::Header; }; class QQuickTabBarAttachedPrivate : public QObjectPrivate @@ -123,12 +121,6 @@ class QQuickTabBarAttachedPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickTabBarAttached) public: - QQuickTabBarAttachedPrivate() - : index(-1), - tabBar(nullptr) - { - } - static QQuickTabBarAttachedPrivate *get(QQuickTabBarAttached *attached) { return attached->d_func(); @@ -136,21 +128,10 @@ public: void update(QQuickTabBar *tabBar, int index); - int index; - QQuickTabBar *tabBar; + int index = -1; + QQuickTabBar *tabBar = nullptr; }; -QQuickTabBarPrivate::QQuickTabBarPrivate() - : updatingLayout(false), - hasContentWidth(false), - hasContentHeight(false), - contentWidth(0), - contentHeight(0), - position(QQuickTabBar::Header) -{ - changeTypes |= Geometry | ImplicitWidth | ImplicitHeight; -} - void QQuickTabBarPrivate::updateCurrentItem() { QQuickTabButton *button = qobject_cast<QQuickTabButton *>(contentModel->get(currentIndex)); @@ -258,6 +239,7 @@ QQuickTabBar::QQuickTabBar(QQuickItem *parent) : QQuickContainer(*(new QQuickTabBarPrivate), parent) { Q_D(QQuickTabBar); + d->changeTypes |= QQuickItemPrivate::Geometry | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight; setFlag(ItemIsFocusScope); QObjectPrivate::connect(this, &QQuickTabBar::currentIndexChanged, d, &QQuickTabBarPrivate::updateCurrentItem); } |