aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickcombobox.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/qquickcombobox.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/qquickcombobox.cpp')
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp65
1 files changed, 19 insertions, 46 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index c61ea9ed..f7b5f157 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -187,7 +187,7 @@ public:
QString stringValue(int index, const QString &role) override;
private:
- QQuickComboBox *combo;
+ QQuickComboBox *combo = nullptr;
};
QQuickComboBoxDelegateModel::QQuickComboBoxDelegateModel(QQuickComboBox *combo)
@@ -220,8 +220,6 @@ class QQuickComboBoxPrivate : public QQuickControlPrivate
Q_DECLARE_PUBLIC(QQuickComboBox)
public:
- QQuickComboBoxPrivate();
-
bool isPopupVisible() const;
void showPopup();
void hidePopup(bool accept);
@@ -263,62 +261,37 @@ public:
void cancelPopup();
void executePopup(bool complete = false);
- bool flat;
- bool down;
- bool hasDown;
- bool pressed;
- bool ownModel;
- bool keyNavigating;
- bool hasDisplayText;
- bool hasCurrentIndex;
- int highlightedIndex;
- int currentIndex;
+ bool flat = false;
+ bool down = false;
+ bool hasDown = false;
+ bool pressed = false;
+ bool ownModel = false;
+ bool keyNavigating = false;
+ bool hasDisplayText = false;
+ bool hasCurrentIndex = false;
+ int highlightedIndex = -1;
+ int currentIndex = -1;
QVariant model;
QString textRole;
QString currentText;
QString displayText;
- QQuickItem *pressedItem;
- QQmlInstanceModel *delegateModel;
- QQmlComponent *delegate;
+ QQuickItem *pressedItem = nullptr;
+ QQmlInstanceModel *delegateModel = nullptr;
+ QQmlComponent *delegate = nullptr;
QQuickDeferredPointer<QQuickItem> indicator;
QQuickDeferredPointer<QQuickPopup> popup;
struct ExtraData {
- ExtraData()
- : editable(false),
- accepting(false),
- allowComplete(false),
- inputMethodHints(Qt::ImhNone),
- validator(nullptr) { }
-
- bool editable;
- bool accepting;
- bool allowComplete;
- Qt::InputMethodHints inputMethodHints;
+ bool editable = false;
+ bool accepting = false;
+ bool allowComplete = false;
+ Qt::InputMethodHints inputMethodHints = Qt::ImhNone;
QString editText;
- QValidator *validator;
+ QValidator *validator = nullptr;
};
QLazilyAllocated<ExtraData> extra;
};
-QQuickComboBoxPrivate::QQuickComboBoxPrivate()
- : flat(false),
- down(false),
- hasDown(false),
- pressed(false),
- ownModel(false),
- keyNavigating(false),
- hasDisplayText(false),
- hasCurrentIndex(false),
- highlightedIndex(-1),
- currentIndex(-1),
- delegateModel(nullptr),
- delegate(nullptr),
- indicator(nullptr),
- popup(nullptr)
-{
-}
-
bool QQuickComboBoxPrivate::isPopupVisible() const
{
return popup && popup->isVisible();