From 1274fa1f799db688b7acdfac216c54cd3dc277f3 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 30 Apr 2018 13:08:25 +0200 Subject: Document the default value of ComboBox's currentIndex property Change-Id: I60dbf84127c800a5f0590ae46c4be3ece7ca3141 Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickcombobox.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 4d5efece..c61ea9ed 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -900,6 +900,8 @@ int QQuickComboBox::highlightedIndex() const This property holds the index of the current item in the combo box. + The default value is \c -1 when \l count is \c 0, and \c 0 otherwise. + \sa activated(), currentText, highlightedIndex */ int QQuickComboBox::currentIndex() const -- cgit v1.2.3 From a5d2731b1ec56580a79784759307d3b3c21ab87f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 4 May 2018 13:29:45 +0200 Subject: Fix QQuickPopupPositioner This is a double-regression caused by commits bcd1bed and 03a8c88. Both of these changes caused dangling pointers being left on the list of item change listeners. First, bcd1bed made QQuickPopupPositioner use QQuickItem::isAncestorOf() without noticing the difference that the old self-made isAncestorOf() conveniently returned true for the item itself, whereas the new built-in QQuickItem::isAncestorOf() doesn't. This had a nasty side effect that when the popup's parent item was removed from its parent, QQuickPopupPositioner::itemChildRemoved() no longer removed the ancestor listeners. Then, 03a8c88 made things worse by changing the stack allocation of QQuickPopupPositioner to heap allocation without ever deleting the positioner object. Valgrind output for tst_tooltip: ==14391== Invalid read of size 8 ==14391== at 0x79EFB9A: QQuickItemPrivate::itemChange(QQuickItem::ItemChange, QQuickItem::ItemChangeData const&) (qquickitem.cpp:6206) ==14391== by 0x79F3D98: QQuickItem::setParentItem(QQuickItem*) (qquickitem.cpp:2791) ==14391== by 0x79F3E87: QQuickItem::~QQuickItem() (qquickitem.cpp:2385) ==14391== by 0x7A16073: ~QQmlElement (qqmlprivate.h:103) ==14391== by 0x7A16073: QQmlPrivate::QQmlElement::~QQmlElement() (qqmlprivate.h:103) ==14391== by 0x7A9CFEE: QQuickView::~QQuickView() (qquickview.cpp:218) ==14391== by 0x4038215: quick_test_main_with_setup(int, char**, char const*, char const*, QObject*) (quicktest.cpp:512) ==14391== by 0x4038CFF: quick_test_main(int, char**, char const*, char const*) (quicktest.cpp:330) ==14391== by 0x400BD7: main (tst_default.cpp:44) ==14391== Address 0x1f2d3f10 is 0 bytes inside a block of size 32 free'd ==14391== at 0x4C2F29C: operator delete(void*) (vg_replace_malloc.c:576) ==14391== by 0x29CA2641: QQuickPopupPositioner::~QQuickPopupPositioner() (qquickpopuppositioner.cpp:68) ==14391== by 0x29CA004C: QQuickPopup::~QQuickPopup() (qquickpopup.cpp:783) ==14391== by 0x2A1A4CEE: ~QQuickToolTip (qquicktooltip_p.h:59) ==14391== by 0x2A1A4CEE: ~QQmlElement (qqmlprivate.h:103) ==14391== by 0x2A1A4CEE: QQmlPrivate::QQmlElement::~QQmlElement() (qqmlprivate.h:103) ==14391== by 0x6397A65: QObjectPrivate::deleteChildren() (qobject.cpp:1997) ==14391== by 0x6398DDA: QObject::~QObject() (qobject.cpp:1025) ==14391== by 0x79F41FA: QQuickItem::~QQuickItem() (qquickitem.cpp:2378) ==14391== by 0x7A897D5: QQuickMouseArea::~QQuickMouseArea() (qquickmousearea.cpp:452) ==14391== by 0x7A1699D: ~QQmlElement (qqmlprivate.h:103) ==14391== by 0x7A1699D: QQmlPrivate::QQmlElement::~QQmlElement() (qqmlprivate.h:103) ==14391== by 0x639082D: qDeleteInEventHandler(QObject*) (qobject.cpp:4603) ==14391== by 0x6392478: QObject::event(QEvent*) (qobject.cpp:1242) ==14391== by 0x79F1D77: QQuickItem::event(QEvent*) (qquickitem.cpp:8006) ==14391== Block was alloc'd at ==14391== at 0x4C2E226: operator new(unsigned long) (vg_replace_malloc.c:334) ==14391== by 0x29C9F939: QQuickPopupPrivate::init() (qquickpopup.cpp:280) ==14391== by 0x29C9FD4E: QQuickPopup::QQuickPopup(QQuickPopupPrivate&, QObject*) (qquickpopup.cpp:771) ==14391== by 0x29CC6CBB: QQuickToolTip::QQuickToolTip(QQuickItem*) (qquicktooltip.cpp:171) ==14391== by 0x2A1A58DD: QQmlElement (qqmlprivate.h:98) ==14391== by 0x2A1A58DD: void QQmlPrivate::createInto(void*) (qqmlprivate.h:107) ==14391== by 0x5D0186D: QQmlType::create(QObject**, void**, unsigned long) const (qqmlmetatype.cpp:915) ==14391== by 0x5D81EFF: QQmlObjectCreator::createInstance(int, QObject*, bool) (qqmlobjectcreator.cpp:1163) ==14391== by 0x5D85AE2: QQmlObjectCreator::create(int, QObject*, QQmlInstantiationInterrupt*) (qqmlobjectcreator.cpp:203) ==14391== by 0x5D82230: QQmlObjectCreator::createInstance(int, QObject*, bool) (qqmlobjectcreator.cpp:1202) ==14391== by 0x5D82F65: QQmlObjectCreator::setPropertyBinding(QQmlPropertyData const*, QV4::CompiledData::Binding const*) (qqmlobjectcreator.cpp:825) ==14391== by 0x5D85105: QQmlObjectCreator::setupBindings(bool) (qqmlobjectcreator.cpp:777) ==14391== by 0x5D857C5: QQmlObjectCreator::populateInstance(int, QObject*, QObject*, QQmlPropertyData const*) (qqmlobjectcreator.cpp:1456) Change-Id: Id368e79146f4673708a84253a009fcdf24ab4a2c Reviewed-by: J-P Nurmi Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickpopup.cpp | 2 ++ src/quicktemplates2/qquickpopuppositioner.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index e3ab952d..a481805f 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -775,6 +775,8 @@ QQuickPopup::~QQuickPopup() d->popupItem->ungrabShortcut(); delete d->popupItem; d->popupItem = nullptr; + delete d->positioner; + d->positioner = nullptr; } /*! diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp index 2b67c85e..f2d02df1 100644 --- a/src/quicktemplates2/qquickpopuppositioner.cpp +++ b/src/quicktemplates2/qquickpopuppositioner.cpp @@ -248,7 +248,7 @@ void QQuickPopupPositioner::itemParentChanged(QQuickItem *, QQuickItem *parent) void QQuickPopupPositioner::itemChildRemoved(QQuickItem *item, QQuickItem *child) { - if (child->isAncestorOf(m_parentItem)) + if (child == m_parentItem || child->isAncestorOf(m_parentItem)) removeAncestorListeners(item); } -- cgit v1.2.3 From aea55d29d2555c5649c13d3bc11bde4799c6bac5 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 3 May 2018 11:23:56 +0200 Subject: 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 --- src/quicktemplates2/qquickabstractbutton.cpp | 31 -------- src/quicktemplates2/qquickabstractbutton_p_p.h | 46 +++++------ src/quicktemplates2/qquickaction.cpp | 13 +--- src/quicktemplates2/qquickaction_p_p.h | 18 ++--- src/quicktemplates2/qquickactiongroup.cpp | 15 +--- src/quicktemplates2/qquickapplicationwindow.cpp | 38 +++------ src/quicktemplates2/qquickbusyindicator.cpp | 4 +- src/quicktemplates2/qquickbutton.cpp | 6 -- src/quicktemplates2/qquickbutton_p_p.h | 6 +- src/quicktemplates2/qquickbuttongroup.cpp | 20 ++--- src/quicktemplates2/qquickcheckbox.cpp | 10 +-- src/quicktemplates2/qquickcheckdelegate.cpp | 10 +-- src/quicktemplates2/qquickcombobox.cpp | 65 +++++----------- src/quicktemplates2/qquickcontainer.cpp | 8 -- src/quicktemplates2/qquickcontainer_p_p.h | 10 +-- src/quicktemplates2/qquickcontrol.cpp | 25 ------ src/quicktemplates2/qquickcontrol_p_p.h | 37 +++++---- src/quicktemplates2/qquickdeferredpointer_p_p.h | 3 +- src/quicktemplates2/qquickdelaybutton.cpp | 17 +--- src/quicktemplates2/qquickdial.cpp | 35 +++------ src/quicktemplates2/qquickdialog_p_p.h | 8 +- src/quicktemplates2/qquickdialogbuttonbox.cpp | 8 -- src/quicktemplates2/qquickdialogbuttonbox_p_p.h | 23 ++---- src/quicktemplates2/qquickdrawer.cpp | 13 +--- src/quicktemplates2/qquickdrawer_p_p.h | 10 +-- src/quicktemplates2/qquickgroupbox.cpp | 2 - src/quicktemplates2/qquickicon.cpp | 16 +--- src/quicktemplates2/qquickitemdelegate.cpp | 5 -- src/quicktemplates2/qquickitemdelegate_p_p.h | 4 +- src/quicktemplates2/qquicklabel.cpp | 1 - src/quicktemplates2/qquickmenu.cpp | 8 +- src/quicktemplates2/qquickmenu_p_p.h | 12 +-- src/quicktemplates2/qquickmenubar.cpp | 14 +--- src/quicktemplates2/qquickmenubar_p_p.h | 16 ++-- src/quicktemplates2/qquickmenubaritem_p_p.h | 13 +--- src/quicktemplates2/qquickmenuitem.cpp | 8 -- src/quicktemplates2/qquickmenuitem_p_p.h | 8 +- src/quicktemplates2/qquickoverlay.cpp | 19 +---- src/quicktemplates2/qquickoverlay_p_p.h | 6 +- src/quicktemplates2/qquickpage.cpp | 12 +-- src/quicktemplates2/qquickpageindicator.cpp | 19 ++--- src/quicktemplates2/qquickpagelayout.cpp | 4 +- src/quicktemplates2/qquickpagelayout_p_p.h | 6 +- src/quicktemplates2/qquickpane.cpp | 6 -- src/quicktemplates2/qquickpane_p_p.h | 6 +- src/quicktemplates2/qquickpopup.cpp | 55 +------------ src/quicktemplates2/qquickpopup_p_p.h | 91 +++++++++++----------- src/quicktemplates2/qquickpopupitem.cpp | 10 +-- src/quicktemplates2/qquickpopuppositioner.cpp | 4 +- src/quicktemplates2/qquickpopuppositioner_p_p.h | 6 +- src/quicktemplates2/qquickpresshandler.cpp | 10 --- src/quicktemplates2/qquickpresshandler_p_p.h | 14 ++-- src/quicktemplates2/qquickprogressbar.cpp | 16 +--- src/quicktemplates2/qquickrangeslider.cpp | 53 ++++--------- src/quicktemplates2/qquickroundbutton.cpp | 14 +--- src/quicktemplates2/qquickscrollbar.cpp | 24 ------ src/quicktemplates2/qquickscrollbar_p_p.h | 40 +++++----- src/quicktemplates2/qquickscrollindicator.cpp | 36 +++------ src/quicktemplates2/qquickscrollview.cpp | 20 ++--- src/quicktemplates2/qquickslider.cpp | 32 +++----- src/quicktemplates2/qquickspinbox.cpp | 51 ++++-------- src/quicktemplates2/qquickstackelement.cpp | 13 +--- src/quicktemplates2/qquickstackelement_p_p.h | 22 +++--- src/quicktemplates2/qquickstacktransition.cpp | 8 -- src/quicktemplates2/qquickstacktransition_p_p.h | 10 +-- src/quicktemplates2/qquickstackview_p.cpp | 7 -- src/quicktemplates2/qquickstackview_p_p.h | 18 ++--- src/quicktemplates2/qquickswipedelegate.cpp | 50 ++++-------- src/quicktemplates2/qquickswipeview.cpp | 23 ++---- src/quicktemplates2/qquickswitch.cpp | 4 +- src/quicktemplates2/qquickswitchdelegate.cpp | 4 +- src/quicktemplates2/qquicktabbar.cpp | 36 +++------ src/quicktemplates2/qquicktextarea.cpp | 12 +-- src/quicktemplates2/qquicktextarea_p_p.h | 8 +- src/quicktemplates2/qquicktextfield.cpp | 7 -- src/quicktemplates2/qquicktextfield_p_p.h | 6 +- src/quicktemplates2/qquicktoolbar.cpp | 4 +- src/quicktemplates2/qquicktoolseparator.cpp | 4 +- src/quicktemplates2/qquicktooltip.cpp | 20 +---- src/quicktemplates2/qquicktumbler.cpp | 28 ------- src/quicktemplates2/qquicktumbler_p_p.h | 35 ++++----- src/quicktemplates2/qquickvelocitycalculator.cpp | 6 -- src/quicktemplates2/qquickvelocitycalculator_p_p.h | 6 +- 83 files changed, 406 insertions(+), 1065 deletions(-) diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 0a8b8ddf..47ed0fff 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -51,10 +51,6 @@ QT_BEGIN_NAMESPACE -// copied from qabstractbutton.cpp -static const int AUTO_REPEAT_DELAY = 300; -static const int AUTO_REPEAT_INTERVAL = 100; - /*! \qmltype AbstractButton \inherits Control @@ -117,33 +113,6 @@ static const int AUTO_REPEAT_INTERVAL = 100; This signal is emitted when the button is interactively double clicked by the user via touch or mouse. */ -QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() - : explicitText(false), - down(false), - explicitDown(false), - pressed(false), - keepPressed(false), - checked(false), - checkable(false), - autoExclusive(false), - autoRepeat(false), - wasHeld(false), - holdTimer(0), - delayTimer(0), - repeatTimer(0), - repeatDelay(AUTO_REPEAT_DELAY), - repeatInterval(AUTO_REPEAT_INTERVAL), -#if QT_CONFIG(shortcut) - shortcutId(0), -#endif - pressButtons(Qt::NoButton), - indicator(nullptr), - group(nullptr), - display(QQuickAbstractButton::TextBesideIcon), - action(nullptr) -{ -} - void QQuickAbstractButtonPrivate::setPressPoint(const QPointF &point) { pressPoint = point; diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h index bb74e143..1b3b59ba 100644 --- a/src/quicktemplates2/qquickabstractbutton_p_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p_p.h @@ -62,8 +62,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButtonPrivate : public QQui Q_DECLARE_PUBLIC(QQuickAbstractButton) public: - QQuickAbstractButtonPrivate(); - static QQuickAbstractButtonPrivate *get(QQuickAbstractButton *button) { return button->d_func(); @@ -105,34 +103,38 @@ public: void cancelIndicator(); void executeIndicator(bool complete = false); - QString text; - bool explicitText; - bool down; - bool explicitDown; - bool pressed; - bool keepPressed; - bool checked; - bool checkable; - bool autoExclusive; - bool autoRepeat; - bool wasHeld; - int holdTimer; - int delayTimer; - int repeatTimer; - int repeatDelay; - int repeatInterval; + // copied from qabstractbutton.cpp + static const int AUTO_REPEAT_DELAY = 300; + static const int AUTO_REPEAT_INTERVAL = 100; + + bool explicitText = false; + bool down = false; + bool explicitDown = false; + bool pressed = false; + bool keepPressed = false; + bool checked = false; + bool checkable = false; + bool autoExclusive = false; + bool autoRepeat = false; + bool wasHeld = false; + int holdTimer = 0; + int delayTimer = 0; + int repeatTimer = 0; + int repeatDelay = AUTO_REPEAT_DELAY; + int repeatInterval = AUTO_REPEAT_INTERVAL; #if QT_CONFIG(shortcut) - int shortcutId; + int shortcutId = 0; QKeySequence shortcut; #endif + QString text; QQuickIcon icon; QQuickIcon effectiveIcon; QPointF pressPoint; QPointF movePoint; - Qt::MouseButtons pressButtons; + Qt::MouseButtons pressButtons = Qt::NoButton; + QQuickAbstractButton::Display display = QQuickAbstractButton::TextBesideIcon; QQuickDeferredPointer indicator; - QQuickButtonGroup *group; - QQuickAbstractButton::Display display; + QQuickButtonGroup *group = nullptr; QPointer action; }; diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp index fd899d0b..6ff3a183 100644 --- a/src/quicktemplates2/qquickaction.cpp +++ b/src/quicktemplates2/qquickaction.cpp @@ -121,8 +121,7 @@ static QKeySequence variantToKeySequence(const QVariant &var) } QQuickActionPrivate::ShortcutEntry::ShortcutEntry(QObject *target) - : m_shortcutId(0), - m_target(target) + : m_target(target) { } @@ -170,16 +169,6 @@ void QQuickActionPrivate::ShortcutEntry::setEnabled(bool enabled) QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enabled, m_shortcutId, m_target); } -QQuickActionPrivate::QQuickActionPrivate() - : explicitEnabled(false), - enabled(true), - checked(false), - checkable(false), - defaultShortcutEntry(nullptr), - group(nullptr) -{ -} - QVariant QQuickActionPrivate::shortcut() const { return vshortcut; diff --git a/src/quicktemplates2/qquickaction_p_p.h b/src/quicktemplates2/qquickaction_p_p.h index 331bcb65..98b0973b 100644 --- a/src/quicktemplates2/qquickaction_p_p.h +++ b/src/quicktemplates2/qquickaction_p_p.h @@ -64,8 +64,6 @@ class QQuickActionPrivate : public QObjectPrivate, public QQuickItemChangeListen Q_DECLARE_PUBLIC(QQuickAction) public: - QQuickActionPrivate(); - static QQuickActionPrivate *get(QQuickAction *action) { return action->d_func(); @@ -104,24 +102,24 @@ public: void setEnabled(bool enabled); private: - int m_shortcutId; - QObject *m_target; + int m_shortcutId = 0; + QObject *m_target = nullptr; }; ShortcutEntry *findShortcutEntry(QObject *target) const; void updateDefaultShortcutEntry(); - bool explicitEnabled; - bool enabled; - bool checked; - bool checkable; + bool explicitEnabled = false; + bool enabled = true; + bool checked = false; + bool checkable = false; QString text; QQuickIcon icon; QVariant vshortcut; QKeySequence keySequence; - ShortcutEntry *defaultShortcutEntry; + ShortcutEntry *defaultShortcutEntry = nullptr; QVector shortcutEntries; - QQuickActionGroup *group; + QQuickActionGroup *group = nullptr; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickactiongroup.cpp b/src/quicktemplates2/qquickactiongroup.cpp index 64895689..f831660b 100644 --- a/src/quicktemplates2/qquickactiongroup.cpp +++ b/src/quicktemplates2/qquickactiongroup.cpp @@ -142,13 +142,6 @@ class QQuickActionGroupPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickActionGroup) public: - QQuickActionGroupPrivate() - : enabled(true), - exclusive(true), - checkedAction(nullptr) - { - } - void clear(); void actionTriggered(); void _q_updateCurrent(); @@ -160,8 +153,8 @@ public: static QQuickAction *actions_at(QQmlListProperty *prop, int index); static void actions_clear(QQmlListProperty *prop); - bool enabled; - bool exclusive; + bool enabled = true; + bool exclusive = true; QPointer checkedAction; QVector actions; }; @@ -423,9 +416,7 @@ void QQuickActionGroup::removeAction(QQuickAction *action) class QQuickActionGroupAttachedPrivate : public QObjectPrivate { public: - QQuickActionGroupAttachedPrivate() : group(nullptr) { } - - QQuickActionGroup *group; + QQuickActionGroup *group = nullptr; }; QQuickActionGroupAttached::QQuickActionGroupAttached(QObject *parent) diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index 77cf5465..be28cb2a 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -123,18 +123,6 @@ class QQuickApplicationWindowPrivate : public QQuickItemChangeListener Q_DECLARE_PUBLIC(QQuickApplicationWindow) public: - QQuickApplicationWindowPrivate() - : complete(true), - background(nullptr), - contentItem(nullptr), - menuBar(nullptr), - header(nullptr), - footer(nullptr), - overlay(nullptr), - activeFocusControl(nullptr) - { - } - static QQuickApplicationWindowPrivate *get(QQuickApplicationWindow *window) { return window->d_func(); @@ -171,18 +159,18 @@ public: void cancelBackground(); void executeBackground(bool complete = false); - bool complete; + bool complete = true; QQuickDeferredPointer background; - QQuickItem *contentItem; - QQuickItem *menuBar; - QQuickItem *header; - QQuickItem *footer; - QQuickOverlay *overlay; + QQuickItem *contentItem = nullptr; + QQuickItem *menuBar = nullptr; + QQuickItem *header = nullptr; + QQuickItem *footer = nullptr; + QQuickOverlay *overlay = nullptr; QFont font; QLocale locale; QPalette palette; - QQuickItem *activeFocusControl; - QQuickApplicationWindow *q_ptr; + QQuickItem *activeFocusControl = nullptr; + QQuickApplicationWindow *q_ptr = nullptr; }; static void layoutItem(QQuickItem *item, qreal y, qreal width) @@ -862,17 +850,11 @@ class QQuickApplicationWindowAttachedPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickApplicationWindowAttached) public: - QQuickApplicationWindowAttachedPrivate() - : window(nullptr), - activeFocusControl(nullptr) - { - } - void windowChange(QQuickWindow *wnd); void activeFocusChange(); - QQuickWindow *window; - QQuickItem *activeFocusControl; + QQuickWindow *window = nullptr; + QQuickItem *activeFocusControl = nullptr; }; void QQuickApplicationWindowAttachedPrivate::windowChange(QQuickWindow *wnd) diff --git a/src/quicktemplates2/qquickbusyindicator.cpp b/src/quicktemplates2/qquickbusyindicator.cpp index e4f20d83..eea8eadb 100644 --- a/src/quicktemplates2/qquickbusyindicator.cpp +++ b/src/quicktemplates2/qquickbusyindicator.cpp @@ -79,9 +79,7 @@ QT_BEGIN_NAMESPACE class QQuickBusyIndicatorPrivate : public QQuickControlPrivate { public: - QQuickBusyIndicatorPrivate() : running(true) { } - - bool running; + bool running = true; }; QQuickBusyIndicator::QQuickBusyIndicator(QQuickItem *parent) diff --git a/src/quicktemplates2/qquickbutton.cpp b/src/quicktemplates2/qquickbutton.cpp index a1bea792..74b78408 100644 --- a/src/quicktemplates2/qquickbutton.cpp +++ b/src/quicktemplates2/qquickbutton.cpp @@ -84,12 +84,6 @@ QT_BEGIN_NAMESPACE \sa {Customizing Button}, {Button Controls} */ -QQuickButtonPrivate::QQuickButtonPrivate() - : flat(false), - highlighted(false) -{ -} - QQuickButton::QQuickButton(QQuickItem *parent) : QQuickAbstractButton(*(new QQuickButtonPrivate), parent) { diff --git a/src/quicktemplates2/qquickbutton_p_p.h b/src/quicktemplates2/qquickbutton_p_p.h index 5aaf2788..1d02e2ea 100644 --- a/src/quicktemplates2/qquickbutton_p_p.h +++ b/src/quicktemplates2/qquickbutton_p_p.h @@ -57,10 +57,8 @@ class QQuickButtonPrivate : public QQuickAbstractButtonPrivate Q_DECLARE_PUBLIC(QQuickButton) public: - QQuickButtonPrivate(); - - bool flat; - bool highlighted; + bool flat = false; + bool highlighted = false; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickbuttongroup.cpp b/src/quicktemplates2/qquickbuttongroup.cpp index e2b1a557..cddfb199 100644 --- a/src/quicktemplates2/qquickbuttongroup.cpp +++ b/src/quicktemplates2/qquickbuttongroup.cpp @@ -154,14 +154,6 @@ class QQuickButtonGroupPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickButtonGroup) public: - QQuickButtonGroupPrivate() - : complete(true), - exclusive(true), - settingCheckState(false), - checkState(Qt::Unchecked) - { - } - void clear(); void buttonClicked(); void _q_updateCurrent(); @@ -173,10 +165,10 @@ public: static QQuickAbstractButton *buttons_at(QQmlListProperty *prop, int index); static void buttons_clear(QQmlListProperty *prop); - bool complete; - bool exclusive; - bool settingCheckState; - Qt::CheckState checkState; + bool complete = true; + bool exclusive = true; + bool settingCheckState = false; + Qt::CheckState checkState = Qt::Unchecked; QPointer checkedButton; QVector buttons; }; @@ -500,9 +492,7 @@ void QQuickButtonGroup::componentComplete() class QQuickButtonGroupAttachedPrivate : public QObjectPrivate { public: - QQuickButtonGroupAttachedPrivate() : group(nullptr) { } - - QQuickButtonGroup *group; + QQuickButtonGroup *group = nullptr; }; QQuickButtonGroupAttached::QQuickButtonGroupAttached(QObject *parent) diff --git a/src/quicktemplates2/qquickcheckbox.cpp b/src/quicktemplates2/qquickcheckbox.cpp index c6519338..1f66966c 100644 --- a/src/quicktemplates2/qquickcheckbox.cpp +++ b/src/quicktemplates2/qquickcheckbox.cpp @@ -102,16 +102,10 @@ class QQuickCheckBoxPrivate : public QQuickAbstractButtonPrivate Q_DECLARE_PUBLIC(QQuickCheckBox) public: - QQuickCheckBoxPrivate() - : tristate(false), - checkState(Qt::Unchecked) - { - } - void setNextCheckState(const QJSValue &callback); - bool tristate; - Qt::CheckState checkState; + bool tristate = false; + Qt::CheckState checkState = Qt::Unchecked; QJSValue nextCheckState; }; diff --git a/src/quicktemplates2/qquickcheckdelegate.cpp b/src/quicktemplates2/qquickcheckdelegate.cpp index b53877df..f02c0bfa 100644 --- a/src/quicktemplates2/qquickcheckdelegate.cpp +++ b/src/quicktemplates2/qquickcheckdelegate.cpp @@ -89,16 +89,10 @@ class QQuickCheckDelegatePrivate : public QQuickItemDelegatePrivate Q_DECLARE_PUBLIC(QQuickCheckDelegate) public: - QQuickCheckDelegatePrivate() - : tristate(false), - checkState(Qt::Unchecked) - { - } - void setNextCheckState(const QJSValue &callback); - bool tristate; - Qt::CheckState checkState; + bool tristate = false; + Qt::CheckState checkState = Qt::Unchecked; QJSValue nextCheckState; }; 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 indicator; QQuickDeferredPointer 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 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(); diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp index 048cfdfa..3dfefdc0 100644 --- a/src/quicktemplates2/qquickcontainer.cpp +++ b/src/quicktemplates2/qquickcontainer.cpp @@ -192,14 +192,6 @@ static QQuickItem *effectiveContentItem(QQuickItem *item) return item; } -QQuickContainerPrivate::QQuickContainerPrivate() - : contentModel(nullptr), - currentIndex(-1), - updatingCurrent(false), - changeTypes(Destroyed | Parent | SiblingOrder) -{ -} - void QQuickContainerPrivate::init() { Q_Q(QQuickContainer); diff --git a/src/quicktemplates2/qquickcontainer_p_p.h b/src/quicktemplates2/qquickcontainer_p_p.h index 7791b69c..4e53aa8f 100644 --- a/src/quicktemplates2/qquickcontainer_p_p.h +++ b/src/quicktemplates2/qquickcontainer_p_p.h @@ -60,8 +60,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickContainerPrivate : public QQuickCon Q_DECLARE_PUBLIC(QQuickContainer) public: - QQuickContainerPrivate(); - static QQuickContainerPrivate *get(QQuickContainer *container) { return container->d_func(); @@ -94,10 +92,10 @@ public: static void contentChildren_clear(QQmlListProperty *prop); QObjectList contentData; - QQmlObjectModel *contentModel; - int currentIndex; - bool updatingCurrent; - QQuickItemPrivate::ChangeTypes changeTypes; + QQmlObjectModel *contentModel = nullptr; + int currentIndex = -1; + bool updatingCurrent = false; + QQuickItemPrivate::ChangeTypes changeTypes = Destroyed | Parent | SiblingOrder; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 9f796a70..28e8c429 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -105,32 +105,7 @@ static bool isKeyFocusReason(Qt::FocusReason reason) return reason == Qt::TabFocusReason || reason == Qt::BacktabFocusReason || reason == Qt::ShortcutFocusReason; } -QQuickControlPrivate::ExtraData::ExtraData() -{ -} - QQuickControlPrivate::QQuickControlPrivate() - : hasTopPadding(false), - hasLeftPadding(false), - hasRightPadding(false), - hasBottomPadding(false), - hasLocale(false), - wheelEnabled(false), -#if QT_CONFIG(quicktemplates2_hover) - hovered(false), - explicitHoverEnabled(false), -#endif - touchId(-1), - padding(0), - topPadding(0), - leftPadding(0), - rightPadding(0), - bottomPadding(0), - spacing(0), - focusPolicy(Qt::NoFocus), - focusReason(Qt::OtherFocusReason), - background(nullptr), - contentItem(nullptr) { #if QT_CONFIG(accessibility) QAccessible::installActivationObserver(this); diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h index 7d040ded..f90bb094 100644 --- a/src/quicktemplates2/qquickcontrol_p_p.h +++ b/src/quicktemplates2/qquickcontrol_p_p.h @@ -72,7 +72,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickControlPrivate : public QQuickItemP public: QQuickControlPrivate(); - virtual ~QQuickControlPrivate(); + ~QQuickControlPrivate(); static QQuickControlPrivate *get(QQuickControl *control) { @@ -147,34 +147,33 @@ public: virtual void executeBackground(bool complete = false); struct ExtraData { - ExtraData(); QFont requestedFont; QPalette requestedPalette; }; QLazilyAllocated extra; - bool hasTopPadding; - bool hasLeftPadding; - bool hasRightPadding; - bool hasBottomPadding; - bool hasLocale; - bool wheelEnabled; + bool hasTopPadding = false; + bool hasLeftPadding = false; + bool hasRightPadding = false; + bool hasBottomPadding = false; + bool hasLocale = false; + bool wheelEnabled = false; #if QT_CONFIG(quicktemplates2_hover) - bool hovered; - bool explicitHoverEnabled; + bool hovered = false; + bool explicitHoverEnabled = false; #endif - int touchId; - qreal padding; - qreal topPadding; - qreal leftPadding; - qreal rightPadding; - qreal bottomPadding; - qreal spacing; + int touchId = -1; + qreal padding = 0; + qreal topPadding = 0; + qreal leftPadding = 0; + qreal rightPadding = 0; + qreal bottomPadding = 0; + qreal spacing = 0; QLocale locale; QFont resolvedFont; QPalette resolvedPalette; - Qt::FocusPolicy focusPolicy; - Qt::FocusReason focusReason; + Qt::FocusPolicy focusPolicy = Qt::NoFocus; + Qt::FocusReason focusReason = Qt::OtherFocusReason; QQuickDeferredPointer background; QQuickDeferredPointer contentItem; }; diff --git a/src/quicktemplates2/qquickdeferredpointer_p_p.h b/src/quicktemplates2/qquickdeferredpointer_p_p.h index c793964f..f70b5dc6 100644 --- a/src/quicktemplates2/qquickdeferredpointer_p_p.h +++ b/src/quicktemplates2/qquickdeferredpointer_p_p.h @@ -79,7 +79,7 @@ public: inline QQuickDeferredPointer &operator=(const QQuickDeferredPointer &o); private: - quintptr ptr_value; + quintptr ptr_value = 0; static const quintptr WasExecutedBit = 0x1; static const quintptr IsExecutingBit = 0x2; @@ -88,7 +88,6 @@ private: template QQuickDeferredPointer::QQuickDeferredPointer() -: ptr_value(0) { } diff --git a/src/quicktemplates2/qquickdelaybutton.cpp b/src/quicktemplates2/qquickdelaybutton.cpp index 128f0c78..5b32fc71 100644 --- a/src/quicktemplates2/qquickdelaybutton.cpp +++ b/src/quicktemplates2/qquickdelaybutton.cpp @@ -80,15 +80,13 @@ class QQuickDelayButtonPrivate : public QQuickAbstractButtonPrivate Q_DECLARE_PUBLIC(QQuickDelayButton) public: - QQuickDelayButtonPrivate(); - void beginTransition(qreal to); void finishTransition(); void cancelTransition(); - int delay; - qreal progress; - QQuickTransition *transition; + int delay = 300; + qreal progress = 0.0; + QQuickTransition *transition = nullptr; QScopedPointer transitionManager; }; @@ -103,7 +101,7 @@ protected: void finished() override; private: - QQuickDelayButton *m_button; + QQuickDelayButton *m_button = nullptr; }; void QQuickDelayTransitionManager::transition(QQuickTransition *transition, qreal progress) @@ -129,13 +127,6 @@ void QQuickDelayTransitionManager::finished() emit m_button->activated(); } -QQuickDelayButtonPrivate::QQuickDelayButtonPrivate() - : delay(3000), - progress(0.0), - transition(nullptr) -{ -} - void QQuickDelayButtonPrivate::beginTransition(qreal to) { Q_Q(QQuickDelayButton); diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 03aee27e..a4124678 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -96,21 +96,6 @@ class QQuickDialPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickDial) public: - QQuickDialPrivate() - : from(0), - to(1), - value(0), - position(0), - angle(startAngle), - stepSize(0), - pressed(false), - snapMode(QQuickDial::NoSnap), - wrap(false), - live(true), - handle(nullptr) - { - } - qreal valueAt(qreal position) const; qreal snapPosition(qreal position) const; qreal positionAt(const QPointF &point) const; @@ -126,17 +111,17 @@ public: void cancelHandle(); void executeHandle(bool complete = false); - qreal from; - qreal to; - qreal value; - qreal position; - qreal angle; - qreal stepSize; - bool pressed; + qreal from = 0; + qreal to = 1; + qreal value = 0; + qreal position = 0; + qreal angle = startAngle; + qreal stepSize = 0; + bool pressed = false; QPointF pressPoint; - QQuickDial::SnapMode snapMode; - bool wrap; - bool live; + QQuickDial::SnapMode snapMode = QQuickDial::NoSnap; + bool wrap = false; + bool live = true; QQuickDeferredPointer handle; }; diff --git a/src/quicktemplates2/qquickdialog_p_p.h b/src/quicktemplates2/qquickdialog_p_p.h index e26182ac..e8008cec 100644 --- a/src/quicktemplates2/qquickdialog_p_p.h +++ b/src/quicktemplates2/qquickdialog_p_p.h @@ -63,8 +63,6 @@ class QQuickDialogPrivate : public QQuickPopupPrivate Q_DECLARE_PUBLIC(QQuickDialog) public: - QQuickDialogPrivate() : result(0), buttonBox(nullptr) { } - static QQuickDialogPrivate *get(QQuickDialog *dialog) { return dialog->d_func(); @@ -74,11 +72,11 @@ public: void handleClick(QQuickAbstractButton *button); - int result; + int result = 0; QString title; - QQuickDialogButtonBox *buttonBox; + QQuickDialogButtonBox *buttonBox = nullptr; QScopedPointer layout; - QPlatformDialogHelper::StandardButtons standardButtons; + QPlatformDialogHelper::StandardButtons standardButtons = QPlatformDialogHelper::NoButton; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index 52171f5b..e53313b1 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -192,14 +192,6 @@ QT_BEGIN_NAMESPACE \sa accepted(), rejected(), helpRequested() */ -QQuickDialogButtonBoxPrivate::QQuickDialogButtonBoxPrivate() - : alignment(0), - position(QQuickDialogButtonBox::Footer), - standardButtons(QPlatformDialogHelper::NoButton), - delegate(nullptr) -{ -} - void QQuickDialogButtonBoxPrivate::itemImplicitWidthChanged(QQuickItem *item) { Q_UNUSED(item); diff --git a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h index 7247d591..a98a299b 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h +++ b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h @@ -58,8 +58,6 @@ class QQuickDialogButtonBoxPrivate : public QQuickContainerPrivate Q_DECLARE_PUBLIC(QQuickDialogButtonBox) public: - QQuickDialogButtonBoxPrivate(); - static QQuickDialogButtonBoxPrivate *get(QQuickDialogButtonBox *box) { return box->d_func(); @@ -75,10 +73,10 @@ public: QQuickAbstractButton *createStandardButton(QPlatformDialogHelper::StandardButton button); void removeStandardButtons(); - Qt::Alignment alignment; - QQuickDialogButtonBox::Position position; - QPlatformDialogHelper::StandardButtons standardButtons; - QQmlComponent *delegate; + Qt::Alignment alignment = 0; + QQuickDialogButtonBox::Position position = QQuickDialogButtonBox::Footer; + QPlatformDialogHelper::StandardButtons standardButtons = QPlatformDialogHelper::NoButton; + QQmlComponent *delegate = nullptr; }; class QQuickDialogButtonBoxAttachedPrivate : public QObjectPrivate @@ -86,13 +84,6 @@ class QQuickDialogButtonBoxAttachedPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickDialogButtonBoxAttached) public: - QQuickDialogButtonBoxAttachedPrivate() - : buttonBox(nullptr), - buttonRole(QPlatformDialogHelper::InvalidRole), - standardButton(QPlatformDialogHelper::NoButton) - { - } - static QQuickDialogButtonBoxAttachedPrivate *get(QQuickDialogButtonBoxAttached *q) { return q->d_func(); @@ -100,9 +91,9 @@ public: void setButtonBox(QQuickDialogButtonBox *box); - QQuickDialogButtonBox *buttonBox; - QPlatformDialogHelper::ButtonRole buttonRole; - QPlatformDialogHelper::StandardButton standardButton; + QQuickDialogButtonBox *buttonBox = nullptr; + QPlatformDialogHelper::ButtonRole buttonRole = QPlatformDialogHelper::InvalidRole; + QPlatformDialogHelper::StandardButton standardButton = QPlatformDialogHelper::NoButton; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index 2d60e649..e06d9bba 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -171,15 +171,6 @@ QT_BEGIN_NAMESPACE \sa SwipeView, {Customizing Drawer}, {Navigation Controls}, {Popup Controls} */ -QQuickDrawerPrivate::QQuickDrawerPrivate() - : edge(Qt::LeftEdge), - offset(0), - position(0), - dragMargin(QGuiApplication::styleHints()->startDragDistance()) -{ - setEdge(Qt::LeftEdge); -} - qreal QQuickDrawerPrivate::offsetAt(const QPointF &point) const { qreal offset = positionAt(point) - position; @@ -608,6 +599,10 @@ bool QQuickDrawerPrivate::setEdge(Qt::Edge e) QQuickDrawer::QQuickDrawer(QObject *parent) : QQuickPopup(*(new QQuickDrawerPrivate), parent) { + Q_D(QQuickDrawer); + d->dragMargin = QGuiApplication::styleHints()->startDragDistance(); + d->setEdge(Qt::LeftEdge); + setFocus(true); setModal(true); setFiltersChildMouseEvents(true); diff --git a/src/quicktemplates2/qquickdrawer_p_p.h b/src/quicktemplates2/qquickdrawer_p_p.h index 0ceaf2e7..00055cee 100644 --- a/src/quicktemplates2/qquickdrawer_p_p.h +++ b/src/quicktemplates2/qquickdrawer_p_p.h @@ -59,8 +59,6 @@ class QQuickDrawerPrivate : public QQuickPopupPrivate Q_DECLARE_PUBLIC(QQuickDrawer) public: - QQuickDrawerPrivate(); - static QQuickDrawerPrivate *get(QQuickDrawer *drawer) { return drawer->d_func(); @@ -91,10 +89,10 @@ public: bool setEdge(Qt::Edge edge); - Qt::Edge edge; - qreal offset; - qreal position; - qreal dragMargin; + Qt::Edge edge = Qt::LeftEdge; + qreal offset = 0; + qreal position = 0; + qreal dragMargin = 0; QQuickVelocityCalculator velocityCalculator; }; diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp index 4f4c5eed..8cc91f11 100644 --- a/src/quicktemplates2/qquickgroupbox.cpp +++ b/src/quicktemplates2/qquickgroupbox.cpp @@ -89,8 +89,6 @@ class QQuickGroupBoxPrivate : public QQuickFramePrivate Q_DECLARE_PUBLIC(QQuickGroupBox) public: - QQuickGroupBoxPrivate() : label(nullptr) { } - void cancelLabel(); void executeLabel(bool complete = false); diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp index 79af62b1..1b8f4797 100644 --- a/src/quicktemplates2/qquickicon.cpp +++ b/src/quicktemplates2/qquickicon.cpp @@ -41,19 +41,11 @@ QT_BEGIN_NAMESPACE class QQuickIconPrivate : public QSharedData { public: - QQuickIconPrivate() - : width(0), - height(0), - color(Qt::transparent), - resolveMask(0) - { - } - QString name; QUrl source; - int width; - int height; - QColor color; + int width = 0; + int height = 0; + QColor color = Qt::transparent; enum ResolveProperties { NameResolved = 0x0001, @@ -65,7 +57,7 @@ public: }; // This is based on QFont's resolve_mask. - int resolveMask; + int resolveMask = 0; }; QQuickIcon::QQuickIcon() diff --git a/src/quicktemplates2/qquickitemdelegate.cpp b/src/quicktemplates2/qquickitemdelegate.cpp index 044141f2..c13cd7ed 100644 --- a/src/quicktemplates2/qquickitemdelegate.cpp +++ b/src/quicktemplates2/qquickitemdelegate.cpp @@ -64,11 +64,6 @@ QT_BEGIN_NAMESPACE \sa {Customizing ItemDelegate}, {Delegate Controls} */ -QQuickItemDelegatePrivate::QQuickItemDelegatePrivate() - : highlighted(false) -{ -} - QQuickItemDelegate::QQuickItemDelegate(QQuickItem *parent) : QQuickAbstractButton(*(new QQuickItemDelegatePrivate), parent) { diff --git a/src/quicktemplates2/qquickitemdelegate_p_p.h b/src/quicktemplates2/qquickitemdelegate_p_p.h index 9896da0c..4995f050 100644 --- a/src/quicktemplates2/qquickitemdelegate_p_p.h +++ b/src/quicktemplates2/qquickitemdelegate_p_p.h @@ -57,9 +57,7 @@ class QQuickItemDelegatePrivate : public QQuickAbstractButtonPrivate Q_DECLARE_PUBLIC(QQuickItemDelegate) public: - QQuickItemDelegatePrivate(); - - bool highlighted; + bool highlighted = false; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index d39006cd..2b23616a 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -80,7 +80,6 @@ QT_BEGIN_NAMESPACE */ QQuickLabelPrivate::QQuickLabelPrivate() - : background(nullptr) { #if QT_CONFIG(accessibility) QAccessible::installActivationObserver(this); diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index 5dbfe3d9..ecdd2825 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -184,15 +184,9 @@ static bool shouldCascade() } QQuickMenuPrivate::QQuickMenuPrivate() - : cascade(shouldCascade()), - hoverTimer(0), - currentIndex(-1), - overlap(0), - contentItem(nullptr), - contentModel(nullptr), - delegate(nullptr) { Q_Q(QQuickMenu); + cascade = shouldCascade(); contentModel = new QQmlObjectModel(q); } diff --git a/src/quicktemplates2/qquickmenu_p_p.h b/src/quicktemplates2/qquickmenu_p_p.h index 0c8ffb4d..83fe3e36 100644 --- a/src/quicktemplates2/qquickmenu_p_p.h +++ b/src/quicktemplates2/qquickmenu_p_p.h @@ -120,16 +120,16 @@ public: static QObject *contentData_at(QQmlListProperty *prop, int index); static void contentData_clear(QQmlListProperty *prop); - bool cascade; - int hoverTimer; - int currentIndex; - qreal overlap; + bool cascade = false; + int hoverTimer = 0; + int currentIndex = -1; + qreal overlap = 0; QPointer parentMenu; QPointer currentItem; - QQuickItem *contentItem; // TODO: cleanup + QQuickItem *contentItem = nullptr; // TODO: cleanup QVector contentData; QQmlObjectModel *contentModel; - QQmlComponent *delegate; + QQmlComponent *delegate = nullptr; QString title; }; diff --git a/src/quicktemplates2/qquickmenubar.cpp b/src/quicktemplates2/qquickmenubar.cpp index 8398633c..efb83a17 100644 --- a/src/quicktemplates2/qquickmenubar.cpp +++ b/src/quicktemplates2/qquickmenubar.cpp @@ -76,18 +76,6 @@ QT_BEGIN_NAMESPACE {Focus Management in Qt Quick Controls 2} */ -QQuickMenuBarPrivate::QQuickMenuBarPrivate() - : popupMode(false), - triggering(false), - hasContentWidth(false), - hasContentHeight(false), - contentWidth(0), - contentHeight(0), - delegate(nullptr) -{ - changeTypes |= Geometry; -} - QQuickItem *QQuickMenuBarPrivate::beginCreateItem() { Q_Q(QQuickMenuBar); @@ -303,6 +291,8 @@ void QQuickMenuBarPrivate::menus_clear(QQmlListProperty *prop) QQuickMenuBar::QQuickMenuBar(QQuickItem *parent) : QQuickContainer(*(new QQuickMenuBarPrivate), parent) { + Q_D(QQuickMenuBar); + d->changeTypes |= QQuickItemPrivate::Geometry; setFlag(ItemIsFocusScope); setFocusPolicy(Qt::ClickFocus); } diff --git a/src/quicktemplates2/qquickmenubar_p_p.h b/src/quicktemplates2/qquickmenubar_p_p.h index 161806fb..b6fdc9eb 100644 --- a/src/quicktemplates2/qquickmenubar_p_p.h +++ b/src/quicktemplates2/qquickmenubar_p_p.h @@ -61,8 +61,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickMenuBarPrivate : public QQuickConta Q_DECLARE_PUBLIC(QQuickMenuBar) public: - QQuickMenuBarPrivate(); - static QQuickMenuBarPrivate *get(QQuickMenuBar *menuBar) { return menuBar->d_func(); @@ -92,13 +90,13 @@ public: static QQuickMenu *menus_at(QQmlListProperty *prop, int index); static void menus_clear(QQmlListProperty *prop); - bool popupMode; - bool triggering; - bool hasContentWidth; - bool hasContentHeight; - qreal contentWidth; - qreal contentHeight; - QQmlComponent *delegate; + bool popupMode = false; + bool triggering = false; + bool hasContentWidth = false; + bool hasContentHeight = false; + qreal contentWidth = 0; + qreal contentHeight = 0; + QQmlComponent *delegate = nullptr; QPointer currentItem; }; diff --git a/src/quicktemplates2/qquickmenubaritem_p_p.h b/src/quicktemplates2/qquickmenubaritem_p_p.h index bd4c3a43..a36e8949 100644 --- a/src/quicktemplates2/qquickmenubaritem_p_p.h +++ b/src/quicktemplates2/qquickmenubaritem_p_p.h @@ -61,13 +61,6 @@ class QQuickMenuBarItemPrivate : public QQuickAbstractButtonPrivate Q_DECLARE_PUBLIC(QQuickMenuBarItem) public: - QQuickMenuBarItemPrivate() - : highlighted(false), - menu(nullptr), - menuBar(nullptr) - { - } - static QQuickMenuBarItemPrivate *get(QQuickMenuBarItem *item) { return item->d_func(); @@ -75,9 +68,9 @@ public: void setMenuBar(QQuickMenuBar *menuBar); - bool highlighted; - QQuickMenu *menu; - QQuickMenuBar *menuBar; + bool highlighted = false; + QQuickMenu *menu = nullptr; + QQuickMenuBar *menuBar = nullptr; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp index 6693d4f8..7a7b9b0b 100644 --- a/src/quicktemplates2/qquickmenuitem.cpp +++ b/src/quicktemplates2/qquickmenuitem.cpp @@ -89,14 +89,6 @@ QT_BEGIN_NAMESPACE \sa {Customizing Menu}, Menu, {Menu Controls} */ -QQuickMenuItemPrivate::QQuickMenuItemPrivate() - : highlighted(false), - arrow(nullptr), - menu(nullptr), - subMenu(nullptr) -{ -} - void QQuickMenuItemPrivate::setMenu(QQuickMenu *newMenu) { Q_Q(QQuickMenuItem); diff --git a/src/quicktemplates2/qquickmenuitem_p_p.h b/src/quicktemplates2/qquickmenuitem_p_p.h index 5deea6e3..034a199a 100644 --- a/src/quicktemplates2/qquickmenuitem_p_p.h +++ b/src/quicktemplates2/qquickmenuitem_p_p.h @@ -60,8 +60,6 @@ class QQuickMenuItemPrivate : public QQuickAbstractButtonPrivate Q_DECLARE_PUBLIC(QQuickMenuItem) public: - QQuickMenuItemPrivate(); - static QQuickMenuItemPrivate *get(QQuickMenuItem *item) { return item->d_func(); @@ -75,10 +73,10 @@ public: void cancelArrow(); void executeArrow(bool complete = false); - bool highlighted; + bool highlighted = false; QQuickDeferredPointer arrow; - QQuickMenu *menu; - QQuickMenu *subMenu; + QQuickMenu *menu = nullptr; + QQuickMenu *subMenu = nullptr; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index fe61dae2..eba31fe2 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -97,12 +97,6 @@ void QQuickOverlayPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChang updateGeometry(); } -QQuickOverlayPrivate::QQuickOverlayPrivate() - : modal(nullptr), - modeless(nullptr) -{ -} - bool QQuickOverlayPrivate::startDrag(QEvent *event, const QPointF &pos) { Q_Q(QQuickOverlay); @@ -563,18 +557,11 @@ class QQuickOverlayAttachedPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickOverlayAttached) public: - QQuickOverlayAttachedPrivate() - : window(nullptr), - modal(nullptr), - modeless(nullptr) - { - } - void setWindow(QQuickWindow *newWindow); - QQuickWindow *window; - QQmlComponent *modal; - QQmlComponent *modeless; + QQuickWindow *window = nullptr; + QQmlComponent *modal = nullptr; + QQmlComponent *modeless = nullptr; }; void QQuickOverlayAttachedPrivate::setWindow(QQuickWindow *newWindow) diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h index a290ecc2..b445f87a 100644 --- a/src/quicktemplates2/qquickoverlay_p_p.h +++ b/src/quicktemplates2/qquickoverlay_p_p.h @@ -63,8 +63,6 @@ class QQuickOverlayPrivate : public QQuickItemPrivate, public QQuickItemChangeLi Q_DECLARE_PUBLIC(QQuickOverlay) public: - QQuickOverlayPrivate(); - static QQuickOverlayPrivate *get(QQuickOverlay *overlay) { return overlay->d_func(); @@ -91,8 +89,8 @@ public: void updateGeometry(); - QQmlComponent *modal; - QQmlComponent *modeless; + QQmlComponent *modal = nullptr; + QQmlComponent *modeless = nullptr; QVector allPopups; QVector allDrawers; QPointer mouseGrabberPopup; diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp index 8f34dca9..25dce5e6 100644 --- a/src/quicktemplates2/qquickpage.cpp +++ b/src/quicktemplates2/qquickpage.cpp @@ -89,22 +89,14 @@ class QQuickPagePrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickPage) public: - QQuickPagePrivate(); - QQuickItem *getContentItem() override; - qreal contentWidth; - qreal contentHeight; + qreal contentWidth = 0; + qreal contentHeight = 0; QString title; QScopedPointer layout; }; -QQuickPagePrivate::QQuickPagePrivate() - : contentWidth(0), - contentHeight(0) -{ -} - QQuickItem *QQuickPagePrivate::getContentItem() { Q_Q(QQuickPage); diff --git a/src/quicktemplates2/qquickpageindicator.cpp b/src/quicktemplates2/qquickpageindicator.cpp index df720c91..dd90402e 100644 --- a/src/quicktemplates2/qquickpageindicator.cpp +++ b/src/quicktemplates2/qquickpageindicator.cpp @@ -89,15 +89,6 @@ class QQuickPageIndicatorPrivate : public QQuickControlPrivate, public QQuickIte Q_DECLARE_PUBLIC(QQuickPageIndicator) public: - QQuickPageIndicatorPrivate() - : count(0), - currentIndex(0), - interactive(false), - delegate(nullptr), - pressedItem(nullptr) - { - } - void handlePress(const QPointF &point) override; void handleMove(const QPointF &point) override; void handleRelease(const QPointF &point) override; @@ -109,11 +100,11 @@ public: void itemChildAdded(QQuickItem *, QQuickItem *child) override; - int count; - int currentIndex; - bool interactive; - QQmlComponent *delegate; - QQuickItem *pressedItem; + int count = 0; + int currentIndex = 0; + bool interactive = false; + QQmlComponent *delegate = nullptr; + QQuickItem *pressedItem = nullptr; }; void QQuickPageIndicatorPrivate::handlePress(const QPointF &point) diff --git a/src/quicktemplates2/qquickpagelayout.cpp b/src/quicktemplates2/qquickpagelayout.cpp index 595db560..6312cc97 100644 --- a/src/quicktemplates2/qquickpagelayout.cpp +++ b/src/quicktemplates2/qquickpagelayout.cpp @@ -75,9 +75,7 @@ static void setPosition(QQuickItem *item, Position position) } QQuickPageLayout::QQuickPageLayout(QQuickControl *control) - : m_header(nullptr), - m_footer(nullptr), - m_control(control) + : m_control(control) { } diff --git a/src/quicktemplates2/qquickpagelayout_p_p.h b/src/quicktemplates2/qquickpagelayout_p_p.h index aac52ca3..a3807b62 100644 --- a/src/quicktemplates2/qquickpagelayout_p_p.h +++ b/src/quicktemplates2/qquickpagelayout_p_p.h @@ -76,9 +76,9 @@ protected: void itemDestroyed(QQuickItem *item) override; private: - QQuickItem *m_header; - QQuickItem *m_footer; - QQuickControl *m_control; + QQuickItem *m_header = nullptr; + QQuickItem *m_footer = nullptr; + QQuickControl *m_control = nullptr; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp index 8038f1b1..7d3754de 100644 --- a/src/quicktemplates2/qquickpane.cpp +++ b/src/quicktemplates2/qquickpane.cpp @@ -106,12 +106,6 @@ QT_BEGIN_NAMESPACE {Focus Management in Qt Quick Controls 2} */ -QQuickPanePrivate::QQuickPanePrivate() - : contentWidth(0), - contentHeight(0) -{ -} - QQuickItem *QQuickPanePrivate::getContentItem() { Q_Q(QQuickPane); diff --git a/src/quicktemplates2/qquickpane_p_p.h b/src/quicktemplates2/qquickpane_p_p.h index 16a07f08..c811c487 100644 --- a/src/quicktemplates2/qquickpane_p_p.h +++ b/src/quicktemplates2/qquickpane_p_p.h @@ -59,12 +59,10 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPanePrivate : public QQuickControlP Q_DECLARE_PUBLIC(QQuickPane) public: - QQuickPanePrivate(); - QQuickItem *getContentItem() override; - qreal contentWidth; - qreal contentHeight; + qreal contentWidth = 0; + qreal contentHeight = 0; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index a481805f..b69dab64 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -213,57 +213,10 @@ QT_BEGIN_NAMESPACE \sa closed() */ -static const QQuickPopup::ClosePolicy DefaultClosePolicy = QQuickPopup::CloseOnEscape | QQuickPopup::CloseOnPressOutside; +const QQuickPopup::ClosePolicy QQuickPopupPrivate::DefaultClosePolicy = QQuickPopup::CloseOnEscape | QQuickPopup::CloseOnPressOutside; QQuickPopupPrivate::QQuickPopupPrivate() - : focus(false), - modal(false), - dim(false), - hasDim(false), - visible(false), - complete(true), - positioning(false), - hasWidth(false), - hasHeight(false), - hasTopMargin(false), - hasLeftMargin(false), - hasRightMargin(false), - hasBottomMargin(false), - allowVerticalFlip(false), - allowHorizontalFlip(false), - allowVerticalMove(true), - allowHorizontalMove(true), - allowVerticalResize(true), - allowHorizontalResize(true), - hadActiveFocusBeforeExitTransition(false), - interactive(true), - hasClosePolicy(false), - touchId(-1), - x(0), - y(0), - effectiveX(0), - effectiveY(0), - margins(-1), - topMargin(0), - leftMargin(0), - rightMargin(0), - bottomMargin(0), - contentWidth(0), - contentHeight(0), - transitionState(QQuickPopupPrivate::NoTransition), - closePolicy(DefaultClosePolicy), - parentItem(nullptr), - dimmer(nullptr), - window(nullptr), - enter(nullptr), - exit(nullptr), - popupItem(nullptr), - positioner(nullptr), - transitionManager(this) -{ -} - -QQuickPopupPrivate::~QQuickPopupPrivate() + : transitionManager(this) { } @@ -717,7 +670,7 @@ void QQuickPopupPrivate::resizeOverlay() } QQuickPopupTransitionManager::QQuickPopupTransitionManager(QQuickPopupPrivate *popup) - : QQuickTransitionManager(), popup(popup) + : popup(popup) { } @@ -1995,7 +1948,7 @@ void QQuickPopup::setClosePolicy(ClosePolicy policy) void QQuickPopup::resetClosePolicy() { Q_D(QQuickPopup); - setClosePolicy(DefaultClosePolicy); + setClosePolicy(QQuickPopupPrivate::DefaultClosePolicy); d->hasClosePolicy = false; } diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h index 6890fdac..318ae598 100644 --- a/src/quicktemplates2/qquickpopup_p_p.h +++ b/src/quicktemplates2/qquickpopup_p_p.h @@ -77,7 +77,7 @@ protected: void finished() override; private: - QQuickPopupPrivate *popup; + QQuickPopupPrivate *popup = nullptr; }; class Q_AUTOTEST_EXPORT QQuickPopupPrivate : public QObjectPrivate, public QQuickItemChangeListener @@ -86,7 +86,6 @@ class Q_AUTOTEST_EXPORT QQuickPopupPrivate : public QObjectPrivate, public QQuic public: QQuickPopupPrivate(); - ~QQuickPopupPrivate(); static QQuickPopupPrivate *get(QQuickPopup *popup) { @@ -142,50 +141,52 @@ public: NoTransition, EnterTransition, ExitTransition }; - bool focus; - bool modal; - bool dim; - bool hasDim; - bool visible; - bool complete; - bool positioning; - bool hasWidth; - bool hasHeight; - bool hasTopMargin; - bool hasLeftMargin; - bool hasRightMargin; - bool hasBottomMargin; - bool allowVerticalFlip; - bool allowHorizontalFlip; - bool allowVerticalMove; - bool allowHorizontalMove; - bool allowVerticalResize; - bool allowHorizontalResize; - bool hadActiveFocusBeforeExitTransition; - bool interactive; - bool hasClosePolicy; - int touchId; - qreal x; - qreal y; - qreal effectiveX; - qreal effectiveY; - qreal margins; - qreal topMargin; - qreal leftMargin; - qreal rightMargin; - qreal bottomMargin; - qreal contentWidth; - qreal contentHeight; + static const QQuickPopup::ClosePolicy DefaultClosePolicy; + + bool focus = false; + bool modal = false; + bool dim = false; + bool hasDim = false; + bool visible = false; + bool complete = true; + bool positioning = false; + bool hasWidth = false; + bool hasHeight = false; + bool hasTopMargin = false; + bool hasLeftMargin = false; + bool hasRightMargin = false; + bool hasBottomMargin = false; + bool allowVerticalFlip = false; + bool allowHorizontalFlip = false; + bool allowVerticalMove = true; + bool allowHorizontalMove = true; + bool allowVerticalResize = true; + bool allowHorizontalResize = true; + bool hadActiveFocusBeforeExitTransition = false; + bool interactive = true; + bool hasClosePolicy = false; + int touchId = -1; + qreal x = 0; + qreal y = 0; + qreal effectiveX = 0; + qreal effectiveY = 0; + qreal margins = -1; + qreal topMargin = 0; + qreal leftMargin = 0; + qreal rightMargin = 0; + qreal bottomMargin = 0; + qreal contentWidth = 0; + qreal contentHeight = 0; QPointF pressPoint; - TransitionState transitionState; - QQuickPopup::ClosePolicy closePolicy; - QQuickItem *parentItem; - QQuickItem *dimmer; - QQuickWindow *window; - QQuickTransition *enter; - QQuickTransition *exit; - QQuickPopupItem *popupItem; - QQuickPopupPositioner *positioner; + TransitionState transitionState = NoTransition; + QQuickPopup::ClosePolicy closePolicy = DefaultClosePolicy; + QQuickItem *parentItem = nullptr; + QQuickItem *dimmer = nullptr; + QQuickWindow *window = nullptr; + QQuickTransition *enter = nullptr; + QQuickTransition *exit = nullptr; + QQuickPopupItem *popupItem = nullptr; + QQuickPopupPositioner *positioner = nullptr; QList enterActions; QList exitActions; QQuickPopupTransitionManager transitionManager; diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp index 566a5245..f835aef4 100644 --- a/src/quicktemplates2/qquickpopupitem.cpp +++ b/src/quicktemplates2/qquickpopupitem.cpp @@ -67,15 +67,13 @@ public: void cancelBackground() override; void executeBackground(bool complete = false) override; - int backId; - int escapeId; - QQuickPopup *popup; + int backId = 0; + int escapeId = 0; + QQuickPopup *popup = nullptr; }; QQuickPopupItemPrivate::QQuickPopupItemPrivate(QQuickPopup *popup) - : backId(0), - escapeId(0), - popup(popup) + : popup(popup) { isTabFence = true; } diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp index f2d02df1..841eac9c 100644 --- a/src/quicktemplates2/qquickpopuppositioner.cpp +++ b/src/quicktemplates2/qquickpopuppositioner.cpp @@ -50,9 +50,7 @@ static const QQuickItemPrivate::ChangeTypes ItemChangeTypes = QQuickItemPrivate: | QQuickItemPrivate::Parent; QQuickPopupPositioner::QQuickPopupPositioner(QQuickPopup *popup) - : m_positioning(false), - m_parentItem(nullptr), - m_popup(popup) + : m_popup(popup) { } diff --git a/src/quicktemplates2/qquickpopuppositioner_p_p.h b/src/quicktemplates2/qquickpopuppositioner_p_p.h index 45b33538..db1f9b17 100644 --- a/src/quicktemplates2/qquickpopuppositioner_p_p.h +++ b/src/quicktemplates2/qquickpopuppositioner_p_p.h @@ -75,9 +75,9 @@ private: void removeAncestorListeners(QQuickItem *item); void addAncestorListeners(QQuickItem *item); - bool m_positioning; - QQuickItem *m_parentItem; - QQuickPopup *m_popup; + bool m_positioning = false; + QQuickItem *m_parentItem = nullptr; + QQuickPopup *m_popup = nullptr; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickpresshandler.cpp b/src/quicktemplates2/qquickpresshandler.cpp index 8f8167cd..8df25a82 100644 --- a/src/quicktemplates2/qquickpresshandler.cpp +++ b/src/quicktemplates2/qquickpresshandler.cpp @@ -44,16 +44,6 @@ QT_BEGIN_NAMESPACE -QQuickPressHandler::QQuickPressHandler() - : control(nullptr), - longPress(false), - pressAndHoldSignalIndex(-1), - pressedSignalIndex(-1), - releasedSignalIndex(-1), - delayedMousePressEvent(nullptr) -{ -} - void QQuickPressHandler::mousePressEvent(QMouseEvent *event) { longPress = false; diff --git a/src/quicktemplates2/qquickpresshandler_p_p.h b/src/quicktemplates2/qquickpresshandler_p_p.h index 7b2c88f3..99ef94bd 100644 --- a/src/quicktemplates2/qquickpresshandler_p_p.h +++ b/src/quicktemplates2/qquickpresshandler_p_p.h @@ -59,8 +59,6 @@ class QTimerEvent; struct QQuickPressHandler { - QQuickPressHandler(); - void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); @@ -69,14 +67,14 @@ struct QQuickPressHandler void clearDelayedMouseEvent(); bool isActive(); - QQuickItem *control; + QQuickItem *control = nullptr; QBasicTimer timer; QPointF pressPos; - bool longPress; - int pressAndHoldSignalIndex; - int pressedSignalIndex; - int releasedSignalIndex; - QMouseEvent *delayedMousePressEvent; + bool longPress = false; + int pressAndHoldSignalIndex = -1; + int pressedSignalIndex = -1; + int releasedSignalIndex = -1; + QMouseEvent *delayedMousePressEvent = nullptr; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickprogressbar.cpp b/src/quicktemplates2/qquickprogressbar.cpp index c5a24f6c..041d4d88 100644 --- a/src/quicktemplates2/qquickprogressbar.cpp +++ b/src/quicktemplates2/qquickprogressbar.cpp @@ -89,18 +89,10 @@ QT_BEGIN_NAMESPACE class QQuickProgressBarPrivate : public QQuickControlPrivate { public: - QQuickProgressBarPrivate() - : from(0), - to(1.0), - value(0), - indeterminate(false) - { - } - - qreal from; - qreal to; - qreal value; - bool indeterminate; + qreal from = 0; + qreal to = 1; + qreal value = 0; + bool indeterminate = false; }; QQuickProgressBar::QQuickProgressBar(QQuickItem *parent) 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 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) diff --git a/src/quicktemplates2/qquickroundbutton.cpp b/src/quicktemplates2/qquickroundbutton.cpp index 0784de81..d930edbe 100644 --- a/src/quicktemplates2/qquickroundbutton.cpp +++ b/src/quicktemplates2/qquickroundbutton.cpp @@ -65,19 +65,11 @@ class QQuickRoundButtonPrivate : public QQuickButtonPrivate Q_DECLARE_PUBLIC(QQuickRoundButton) public: - QQuickRoundButtonPrivate(); - - qreal radius; - bool explicitRadius; - void setRadius(qreal newRadius = -1.0); -}; -QQuickRoundButtonPrivate::QQuickRoundButtonPrivate() - : radius(0), - explicitRadius(false) -{ -} + qreal radius = 0; + bool explicitRadius = false; +}; void QQuickRoundButtonPrivate::setRadius(qreal newRadius) { diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index 67195ba8..9e6fe684 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -155,23 +155,6 @@ static const QQuickItemPrivate::ChangeTypes changeTypes = QQuickItemPrivate::Geo static const QQuickItemPrivate::ChangeTypes horizontalChangeTypes = changeTypes | QQuickItemPrivate::ImplicitHeight; static const QQuickItemPrivate::ChangeTypes verticalChangeTypes = changeTypes | QQuickItemPrivate::ImplicitWidth; -QQuickScrollBarPrivate::QQuickScrollBarPrivate() - : size(0), - position(0), - stepSize(0), - offset(0), - minimumSize(0), - active(false), - pressed(false), - moving(false), - interactive(true), - explicitInteractive(false), - orientation(Qt::Vertical), - snapMode(QQuickScrollBar::NoSnap), - policy(QQuickScrollBar::AsNeeded) -{ -} - QQuickScrollBarPrivate::VisualArea QQuickScrollBarPrivate::visualArea() const { qreal visualPos = position; @@ -751,13 +734,6 @@ QAccessible::Role QQuickScrollBar::accessibleRole() const } #endif -QQuickScrollBarAttachedPrivate::QQuickScrollBarAttachedPrivate() - : flickable(nullptr), - horizontal(nullptr), - vertical(nullptr) -{ -} - void QQuickScrollBarAttachedPrivate::setFlickable(QQuickFlickable *item) { if (flickable) { diff --git a/src/quicktemplates2/qquickscrollbar_p_p.h b/src/quicktemplates2/qquickscrollbar_p_p.h index 384348b4..5c7628b9 100644 --- a/src/quicktemplates2/qquickscrollbar_p_p.h +++ b/src/quicktemplates2/qquickscrollbar_p_p.h @@ -61,8 +61,6 @@ class QQuickScrollBarPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickScrollBar) public: - QQuickScrollBarPrivate(); - static QQuickScrollBarPrivate *get(QQuickScrollBar *bar) { return bar->d_func(); @@ -72,8 +70,8 @@ public: { VisualArea(qreal pos, qreal sz) : position(pos), size(sz) { } - qreal position; - qreal size; + qreal position = 0; + qreal size = 0; }; VisualArea visualArea() const; @@ -92,26 +90,24 @@ public: void visualAreaChange(const VisualArea &newVisualArea, const VisualArea &oldVisualArea); - qreal size; - qreal position; - qreal stepSize; - qreal offset; - qreal minimumSize; - bool active; - bool pressed; - bool moving; - bool interactive; - bool explicitInteractive; - Qt::Orientation orientation; - QQuickScrollBar::SnapMode snapMode; - QQuickScrollBar::Policy policy; + qreal size = 0; + qreal position = 0; + qreal stepSize = 0; + qreal offset = 0; + qreal minimumSize = 0; + bool active = false; + bool pressed = false; + bool moving = false; + bool interactive = true; + bool explicitInteractive = false; + Qt::Orientation orientation = Qt::Vertical; + QQuickScrollBar::SnapMode snapMode = QQuickScrollBar::NoSnap; + QQuickScrollBar::Policy policy = QQuickScrollBar::AsNeeded; }; class QQuickScrollBarAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener { public: - QQuickScrollBarAttachedPrivate(); - static QQuickScrollBarAttachedPrivate *get(QQuickScrollBarAttached *attached) { return attached->d_func(); @@ -137,9 +133,9 @@ public: void itemImplicitHeightChanged(QQuickItem *item) override; void itemDestroyed(QQuickItem *item) override; - QQuickFlickable *flickable; - QQuickScrollBar *horizontal; - QQuickScrollBar *vertical; + QQuickFlickable *flickable = nullptr; + QQuickScrollBar *horizontal = nullptr; + QQuickScrollBar *vertical = nullptr; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp index 511a8311..1e411bce 100644 --- a/src/quicktemplates2/qquickscrollindicator.cpp +++ b/src/quicktemplates2/qquickscrollindicator.cpp @@ -135,32 +135,23 @@ class QQuickScrollIndicatorPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickScrollIndicator) public: - QQuickScrollIndicatorPrivate() - : size(0), - minimumSize(0), - position(0), - active(false), - orientation(Qt::Vertical) - { - } - struct VisualArea { VisualArea(qreal pos, qreal sz) : position(pos), size(sz) { } - qreal position; - qreal size; + qreal position = 0; + qreal size = 0; }; VisualArea visualArea() const; void visualAreaChange(const VisualArea &newVisualArea, const VisualArea &oldVisualArea); void resizeContent() override; - qreal size; - qreal minimumSize; - qreal position; - bool active; - Qt::Orientation orientation; + qreal size = 0; + qreal minimumSize = 0; + qreal position = 0; + bool active = false; + Qt::Orientation orientation = Qt::Vertical; }; QQuickScrollIndicatorPrivate::VisualArea QQuickScrollIndicatorPrivate::visualArea() const @@ -427,13 +418,6 @@ qreal QQuickScrollIndicator::visualPosition() const class QQuickScrollIndicatorAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener { public: - QQuickScrollIndicatorAttachedPrivate() - : flickable(nullptr), - horizontal(nullptr), - vertical(nullptr) - { - } - void activateHorizontal(); void activateVertical(); @@ -445,9 +429,9 @@ public: void itemImplicitHeightChanged(QQuickItem *item) override; void itemDestroyed(QQuickItem *item) override; - QQuickFlickable *flickable; - QQuickScrollIndicator *horizontal; - QQuickScrollIndicator *vertical; + QQuickFlickable *flickable = nullptr; + QQuickScrollIndicator *horizontal = nullptr; + QQuickScrollIndicator *vertical = nullptr; }; void QQuickScrollIndicatorAttachedPrivate::activateHorizontal() diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp index 30750aa8..dba0d95c 100644 --- a/src/quicktemplates2/qquickscrollview.cpp +++ b/src/quicktemplates2/qquickscrollview.cpp @@ -106,8 +106,6 @@ class QQuickScrollViewPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickScrollView) public: - QQuickScrollViewPrivate(); - QQuickItem *getContentItem() override; QQuickFlickable *ensureFlickable(bool content); @@ -131,21 +129,12 @@ public: static QQuickItem *contentChildren_at(QQmlListProperty *prop, int index); static void contentChildren_clear(QQmlListProperty *prop); - bool wasTouched; - qreal contentWidth; - qreal contentHeight; - QQuickFlickable *flickable; + bool wasTouched = false; + qreal contentWidth = -1; + qreal contentHeight = -1; + QQuickFlickable *flickable = nullptr; }; -QQuickScrollViewPrivate::QQuickScrollViewPrivate() - : wasTouched(false), - contentWidth(-1), - contentHeight(-1), - flickable(nullptr) -{ - wheelEnabled = true; -} - QQuickItem *QQuickScrollViewPrivate::getContentItem() { if (!contentItem) @@ -359,6 +348,7 @@ QQuickScrollView::QQuickScrollView(QQuickItem *parent) setFlag(ItemIsFocusScope); setActiveFocusOnTab(true); setFiltersChildMouseEvents(true); + setWheelEnabled(true); } /*! diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index e9717368..5806aad5 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -92,20 +92,6 @@ class QQuickSliderPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickSlider) public: - QQuickSliderPrivate() - : from(0), - to(1), - value(0), - position(0), - stepSize(0), - live(true), - pressed(false), - orientation(Qt::Horizontal), - snapMode(QQuickSlider::NoSnap), - handle(nullptr) - { - } - qreal snapPosition(qreal position) const; qreal positionAt(const QPointF &point) const; void setPosition(qreal position); @@ -119,16 +105,16 @@ public: void cancelHandle(); void executeHandle(bool complete = false); - qreal from; - qreal to; - qreal value; - qreal position; - qreal stepSize; - bool live; - bool pressed; + qreal from = 0; + qreal to = 1; + qreal value = 0; + qreal position = 0; + qreal stepSize = 0; + bool live = true; + bool pressed = false; QPointF pressPoint; - Qt::Orientation orientation; - QQuickSlider::SnapMode snapMode; + Qt::Orientation orientation = Qt::Horizontal; + QQuickSlider::SnapMode snapMode = QQuickSlider::NoSnap; QQuickDeferredPointer handle; }; 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 indicator; }; diff --git a/src/quicktemplates2/qquickstackelement.cpp b/src/quicktemplates2/qquickstackelement.cpp index 887d43af..7ae5c495 100644 --- a/src/quicktemplates2/qquickstackelement.cpp +++ b/src/quicktemplates2/qquickstackelement.cpp @@ -72,18 +72,7 @@ private: }; QQuickStackElement::QQuickStackElement() - : QQuickItemViewTransitionableItem(nullptr), - index(-1), - init(false), - removal(false), - ownItem(false), - ownComponent(false), - widthValid(false), - heightValid(false), - context(nullptr), - component(nullptr), - view(nullptr), - status(QQuickStackView::Inactive) + : QQuickItemViewTransitionableItem(nullptr) { } diff --git a/src/quicktemplates2/qquickstackelement_p_p.h b/src/quicktemplates2/qquickstackelement_p_p.h index 2308f47d..65e73244 100644 --- a/src/quicktemplates2/qquickstackelement_p_p.h +++ b/src/quicktemplates2/qquickstackelement_p_p.h @@ -85,18 +85,18 @@ public: void itemDestroyed(QQuickItem *item) override; - int index; - bool init; - bool removal; - bool ownItem; - bool ownComponent; - bool widthValid; - bool heightValid; - QQmlContext *context; - QQmlComponent *component; - QQuickStackView *view; + int index = -1; + bool init = false; + bool removal = false; + bool ownItem = false; + bool ownComponent = false; + bool widthValid = false; + bool heightValid = false; + QQmlContext *context = nullptr; + QQmlComponent *component = nullptr; + QQuickStackView *view = nullptr; QPointer originalParent; - QQuickStackView::Status status; + QQuickStackView::Status status = QQuickStackView::Inactive; QV4::PersistentValue properties; QV4::PersistentValue qmlCallingContext; }; diff --git a/src/quicktemplates2/qquickstacktransition.cpp b/src/quicktemplates2/qquickstacktransition.cpp index 058359c3..a0192d1b 100644 --- a/src/quicktemplates2/qquickstacktransition.cpp +++ b/src/quicktemplates2/qquickstacktransition.cpp @@ -44,23 +44,18 @@ static QQuickStackTransition exitTransition(QQuickStackView::Operation operation { QQuickStackTransition st; st.status = QQuickStackView::Deactivating; - st.transition = nullptr; st.element = element; const QQuickItemViewTransitioner *transitioner = QQuickStackViewPrivate::get(view)->transitioner; switch (operation) { case QQuickStackView::PushTransition: - st.target = false; st.type = QQuickItemViewTransitioner::AddTransition; - st.viewBounds = QRectF(); if (transitioner) st.transition = transitioner->addDisplacedTransition; break; case QQuickStackView::ReplaceTransition: - st.target = false; st.type = QQuickItemViewTransitioner::MoveTransition; - st.viewBounds = QRectF(); if (transitioner) st.transition = transitioner->moveDisplacedTransition; break; @@ -83,7 +78,6 @@ static QQuickStackTransition enterTransition(QQuickStackView::Operation operatio { QQuickStackTransition st; st.status = QQuickStackView::Activating; - st.transition = nullptr; st.element = element; const QQuickItemViewTransitioner *transitioner = QQuickStackViewPrivate::get(view)->transitioner; @@ -104,9 +98,7 @@ static QQuickStackTransition enterTransition(QQuickStackView::Operation operatio st.transition = transitioner->moveTransition; break; case QQuickStackView::PopTransition: - st.target = false; st.type = QQuickItemViewTransitioner::RemoveTransition; - st.viewBounds = QRectF(); if (transitioner) st.transition = transitioner->removeDisplacedTransition; break; diff --git a/src/quicktemplates2/qquickstacktransition_p_p.h b/src/quicktemplates2/qquickstacktransition_p_p.h index 7101420c..3a08fb4a 100644 --- a/src/quicktemplates2/qquickstacktransition_p_p.h +++ b/src/quicktemplates2/qquickstacktransition_p_p.h @@ -66,12 +66,12 @@ struct QQuickStackTransition static QQuickStackTransition replaceExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view); static QQuickStackTransition replaceEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view); - bool target; - QQuickStackView::Status status; - QQuickItemViewTransitioner::TransitionType type; + bool target = false; + QQuickStackView::Status status = QQuickStackView::Inactive; + QQuickItemViewTransitioner::TransitionType type = QQuickItemViewTransitioner::NoTransition; QRectF viewBounds; - QQuickStackElement *element; - QQuickTransition *transition; + QQuickStackElement *element = nullptr; + QQuickTransition *transition = nullptr; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp index 606d259a..e0e1d9ef 100644 --- a/src/quicktemplates2/qquickstackview_p.cpp +++ b/src/quicktemplates2/qquickstackview_p.cpp @@ -47,13 +47,6 @@ QT_BEGIN_NAMESPACE -QQuickStackViewPrivate::QQuickStackViewPrivate() - : busy(false), - currentItem(nullptr), - transitioner(nullptr) -{ -} - void QQuickStackViewPrivate::warn(const QString &error) { Q_Q(QQuickStackView); diff --git a/src/quicktemplates2/qquickstackview_p_p.h b/src/quicktemplates2/qquickstackview_p_p.h index 7f1b77b1..74ea3e7a 100644 --- a/src/quicktemplates2/qquickstackview_p_p.h +++ b/src/quicktemplates2/qquickstackview_p_p.h @@ -66,8 +66,6 @@ class QQuickStackViewPrivate : public QQuickControlPrivate, public QQuickItemVie Q_DECLARE_PUBLIC(QQuickStackView) public: - QQuickStackViewPrivate(); - static QQuickStackViewPrivate *get(QQuickStackView *view) { return view->d_func(); @@ -94,14 +92,14 @@ public: void setBusy(bool busy); void depthChange(int newDepth, int oldDepth); - bool busy; + bool busy = false; QString operation; QJSValue initialItem; - QQuickItem *currentItem; + QQuickItem *currentItem = nullptr; QSet removing; QList removed; QStack elements; - QQuickItemViewTransitioner *transitioner; + QQuickItemViewTransitioner *transitioner = nullptr; }; class QQuickStackViewAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener @@ -109,12 +107,6 @@ class QQuickStackViewAttachedPrivate : public QObjectPrivate, public QQuickItemC Q_DECLARE_PUBLIC(QQuickStackViewAttached) public: - QQuickStackViewAttachedPrivate() - : explicitVisible(false), - element(nullptr) - { - } - static QQuickStackViewAttachedPrivate *get(QQuickStackViewAttached *attached) { return attached->d_func(); @@ -122,8 +114,8 @@ public: void itemParentChanged(QQuickItem *item, QQuickItem *parent); - bool explicitVisible; - QQuickStackElement *element; + bool explicitVisible = false; + QQuickStackElement *element = nullptr; }; QT_END_NAMESPACE 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 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; }; /*! diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp index 60bc9477..d3026597 100644 --- a/src/quicktemplates2/qquickswipeview.cpp +++ b/src/quicktemplates2/qquickswipeview.cpp @@ -108,19 +108,13 @@ class QQuickSwipeViewPrivate : public QQuickContainerPrivate Q_DECLARE_PUBLIC(QQuickSwipeView) public: - QQuickSwipeViewPrivate() - : interactive(true), - orientation(Qt::Horizontal) - { - } - void resizeItem(QQuickItem *item); void resizeItems(); static QQuickSwipeViewPrivate *get(QQuickSwipeView *view); - bool interactive; - Qt::Orientation orientation; + bool interactive = true; + Qt::Orientation orientation = Qt::Horizontal; }; class QQuickSwipeViewAttachedPrivate : public QObjectPrivate @@ -128,13 +122,6 @@ class QQuickSwipeViewAttachedPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickSwipeViewAttached) public: - QQuickSwipeViewAttachedPrivate() - : swipeView(nullptr), - index(-1), - currentIndex(-1) - { - } - static QQuickSwipeViewAttachedPrivate *get(QQuickSwipeViewAttached *attached) { return attached->d_func(); @@ -144,9 +131,9 @@ public: void updateCurrentIndex(); void setCurrentIndex(int i); - QQuickSwipeView *swipeView; - int index; - int currentIndex; + QQuickSwipeView *swipeView = nullptr; + int index = -1; + int currentIndex = -1; }; void QQuickSwipeViewPrivate::resizeItems() diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp index da1f0408..3c84bbc7 100644 --- a/src/quicktemplates2/qquickswitch.cpp +++ b/src/quicktemplates2/qquickswitch.cpp @@ -82,15 +82,13 @@ class QQuickSwitchPrivate : public QQuickAbstractButtonPrivate Q_DECLARE_PUBLIC(QQuickSwitch) public: - QQuickSwitchPrivate() : position(0) { } - qreal positionAt(const QPointF &point) const; bool canDrag(const QPointF &movePoint) const; void handleMove(const QPointF &point) override; void handleRelease(const QPointF &point) override; - qreal position; + qreal position = 0; }; qreal QQuickSwitchPrivate::positionAt(const QPointF &point) const diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp index d8ce8096..9257a5fd 100644 --- a/src/quicktemplates2/qquickswitchdelegate.cpp +++ b/src/quicktemplates2/qquickswitchdelegate.cpp @@ -79,15 +79,13 @@ class QQuickSwitchDelegatePrivate : public QQuickItemDelegatePrivate Q_DECLARE_PUBLIC(QQuickSwitchDelegate) public: - QQuickSwitchDelegatePrivate() : position(0) { } - qreal positionAt(const QPointF &point) const; bool canDrag(const QPointF &movePoint) const; void handleMove(const QPointF &point) override; void handleRelease(const QPointF &point) override; - qreal position; + qreal position = 0; }; qreal QQuickSwitchDelegatePrivate::positionAt(const QPointF &point) const 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(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); } diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index aca13d5e..db6d9283 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -132,14 +132,6 @@ QT_BEGIN_NAMESPACE */ QQuickTextAreaPrivate::QQuickTextAreaPrivate() - : QQuickTextEditPrivate(), -#if QT_CONFIG(quicktemplates2_hover) - hovered(false), - explicitHoverEnabled(false), -#endif - background(nullptr), - focusReason(Qt::OtherFocusReason), - flickable(nullptr) { #if QT_CONFIG(accessibility) QAccessible::installActivationObserver(this); @@ -892,9 +884,7 @@ void QQuickTextArea::timerEvent(QTimerEvent *event) class QQuickTextAreaAttachedPrivate : public QObjectPrivate { public: - QQuickTextAreaAttachedPrivate() : control(nullptr) { } - - QQuickTextArea *control; + QQuickTextArea *control = nullptr; }; QQuickTextAreaAttached::QQuickTextAreaAttached(QObject *parent) diff --git a/src/quicktemplates2/qquicktextarea_p_p.h b/src/quicktemplates2/qquicktextarea_p_p.h index 8621c61c..9120c61c 100644 --- a/src/quicktemplates2/qquicktextarea_p_p.h +++ b/src/quicktemplates2/qquicktextarea_p_p.h @@ -129,8 +129,8 @@ public: void executeBackground(bool complete = false); #if QT_CONFIG(quicktemplates2_hover) - bool hovered; - bool explicitHoverEnabled; + bool hovered = false; + bool explicitHoverEnabled = false; #endif struct ExtraData { @@ -142,9 +142,9 @@ public: QPalette resolvedPalette; QQuickDeferredPointer background; QString placeholder; - Qt::FocusReason focusReason; + Qt::FocusReason focusReason = Qt::OtherFocusReason; QQuickPressHandler pressHandler; - QQuickFlickable *flickable; + QQuickFlickable *flickable = nullptr; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp index 876ceca6..e7c66f84 100644 --- a/src/quicktemplates2/qquicktextfield.cpp +++ b/src/quicktemplates2/qquicktextfield.cpp @@ -113,13 +113,6 @@ QT_BEGIN_NAMESPACE */ QQuickTextFieldPrivate::QQuickTextFieldPrivate() - : QQuickTextInputPrivate(), -#if QT_CONFIG(quicktemplates2_hover) - hovered(false), - explicitHoverEnabled(false), -#endif - background(nullptr), - focusReason(Qt::OtherFocusReason) { #if QT_CONFIG(accessibility) QAccessible::installActivationObserver(this); diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h index 41843370..e863a92d 100644 --- a/src/quicktemplates2/qquicktextfield_p_p.h +++ b/src/quicktemplates2/qquicktextfield_p_p.h @@ -117,8 +117,8 @@ public: void executeBackground(bool complete = false); #if QT_CONFIG(quicktemplates2_hover) - bool hovered; - bool explicitHoverEnabled; + bool hovered = false; + bool explicitHoverEnabled = false; #endif struct ExtraData { @@ -130,7 +130,7 @@ public: QPalette resolvedPalette; QQuickDeferredPointer background; QString placeholder; - Qt::FocusReason focusReason; + Qt::FocusReason focusReason = Qt::OtherFocusReason; QQuickPressHandler pressHandler; }; diff --git a/src/quicktemplates2/qquicktoolbar.cpp b/src/quicktemplates2/qquicktoolbar.cpp index 99775c6a..a2f129fa 100644 --- a/src/quicktemplates2/qquicktoolbar.cpp +++ b/src/quicktemplates2/qquicktoolbar.cpp @@ -99,9 +99,7 @@ QT_BEGIN_NAMESPACE class QQuickToolBarPrivate : public QQuickPanePrivate { public: - QQuickToolBarPrivate() : position(QQuickToolBar::Header) { } - - QQuickToolBar::Position position; + QQuickToolBar::Position position = QQuickToolBar::Header; }; QQuickToolBar::QQuickToolBar(QQuickItem *parent) diff --git a/src/quicktemplates2/qquicktoolseparator.cpp b/src/quicktemplates2/qquicktoolseparator.cpp index 2ec7799f..a6fdfc5b 100644 --- a/src/quicktemplates2/qquicktoolseparator.cpp +++ b/src/quicktemplates2/qquicktoolseparator.cpp @@ -66,9 +66,7 @@ class QQuickToolSeparatorPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickToolSeparator) public: - QQuickToolSeparatorPrivate() : orientation(Qt::Vertical) { } - - Qt::Orientation orientation; + Qt::Orientation orientation = Qt::Vertical; }; QQuickToolSeparator::QQuickToolSeparator(QQuickItem *parent) diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp index 1bf6ca55..282b093d 100644 --- a/src/quicktemplates2/qquicktooltip.cpp +++ b/src/quicktemplates2/qquicktooltip.cpp @@ -124,20 +124,14 @@ class QQuickToolTipPrivate : public QQuickPopupPrivate Q_DECLARE_PUBLIC(QQuickToolTip) public: - QQuickToolTipPrivate() - : delay(0), - timeout(-1) - { - } - void startDelay(); void stopDelay(); void startTimeout(); void stopTimeout(); - int delay; - int timeout; + int delay = 0; + int timeout = -1; QString text; QBasicTimer delayTimer; QBasicTimer timeoutTimer; @@ -335,16 +329,10 @@ class QQuickToolTipAttachedPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickToolTipAttached) public: - QQuickToolTipAttachedPrivate() - : delay(0), - timeout(-1) - { - } - QQuickToolTip *instance(bool create) const; - int delay; - int timeout; + int delay = 0; + int timeout = -1; QString text; }; diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp index efa61dad..cc32a4e3 100644 --- a/src/quicktemplates2/qquicktumbler.cpp +++ b/src/quicktemplates2/qquicktumbler.cpp @@ -86,27 +86,6 @@ QT_BEGIN_NAMESPACE \sa {Customizing Tumbler}, {Input Controls} */ -QQuickTumblerPrivate::QQuickTumblerPrivate() - : delegate(nullptr), - visibleItemCount(5), - wrap(true), - explicitWrap(false), - ignoreWrapChanges(false), - view(nullptr), - viewContentItem(nullptr), - viewContentItemType(UnsupportedContentItemType), - currentIndex(-1), - pendingCurrentIndex(-1), - ignoreCurrentIndexChanges(false), - count(0), - ignoreSignals(false) -{ -} - -QQuickTumblerPrivate::~QQuickTumblerPrivate() -{ -} - namespace { static inline qreal delegateHeight(const QQuickTumbler *tumbler) { @@ -792,13 +771,6 @@ QPalette QQuickTumbler::defaultPalette() const return QQuickControlPrivate::themePalette(QPlatformTheme::ItemViewPalette); } -QQuickTumblerAttachedPrivate::QQuickTumblerAttachedPrivate() - : tumbler(nullptr), - index(-1), - displacement(0) -{ -} - void QQuickTumblerAttachedPrivate::init(QQuickItem *delegateItem) { if (!delegateItem->parentItem()) { diff --git a/src/quicktemplates2/qquicktumbler_p_p.h b/src/quicktemplates2/qquicktumbler_p_p.h index 75b1a396..7f824482 100644 --- a/src/quicktemplates2/qquicktumbler_p_p.h +++ b/src/quicktemplates2/qquicktumbler_p_p.h @@ -59,9 +59,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumblerPrivate : public QQuickContr Q_DECLARE_PUBLIC(QQuickTumbler) public: - QQuickTumblerPrivate(); - ~QQuickTumblerPrivate(); - enum ContentItemType { NoContentItem, UnsupportedContentItemType, @@ -76,23 +73,23 @@ public: static QQuickTumblerPrivate *get(QQuickTumbler *tumbler); QVariant model; - QQmlComponent *delegate; - int visibleItemCount; - bool wrap; - bool explicitWrap; - bool ignoreWrapChanges; - QQuickItem *view; - QQuickItem *viewContentItem; - ContentItemType viewContentItemType; + QQmlComponent *delegate = nullptr; + int visibleItemCount = 5; + bool wrap = true; + bool explicitWrap = false; + bool ignoreWrapChanges = false; + QQuickItem *view = nullptr; + QQuickItem *viewContentItem = nullptr; + ContentItemType viewContentItemType = UnsupportedContentItemType; union { qreal viewOffset; // PathView qreal viewContentY; // ListView }; - int currentIndex; - int pendingCurrentIndex; - bool ignoreCurrentIndexChanges; - int count; - bool ignoreSignals; + int currentIndex = -1; + int pendingCurrentIndex = -1; + bool ignoreCurrentIndexChanges = false; + int count = 0; + bool ignoreSignals = false; void _q_updateItemHeights(); void _q_updateItemWidths(); @@ -123,8 +120,6 @@ class QQuickTumblerAttachedPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickTumblerAttached) public: - QQuickTumblerAttachedPrivate(); - static QQuickTumblerAttachedPrivate *get(QQuickTumblerAttached *attached) { return attached->d_func(); @@ -138,9 +133,9 @@ public: // The Tumbler that contains the delegate. Required to calculated the displacement. QPointer tumbler; // The index of the delegate. Used to calculate the displacement. - int index; + int index = -1; // The displacement for our delegate. - qreal displacement; + qreal displacement = 0; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickvelocitycalculator.cpp b/src/quicktemplates2/qquickvelocitycalculator.cpp index b98eeff9..a0c5ec0d 100644 --- a/src/quicktemplates2/qquickvelocitycalculator.cpp +++ b/src/quicktemplates2/qquickvelocitycalculator.cpp @@ -58,12 +58,6 @@ QT_BEGIN_NAMESPACE doSomethingElse(); */ -QQuickVelocityCalculator::QQuickVelocityCalculator() - : m_point1Timestamp(0), - m_point2Timestamp(0) -{ -} - void QQuickVelocityCalculator::startMeasuring(const QPointF &point1, qint64 timestamp) { m_point1 = point1; diff --git a/src/quicktemplates2/qquickvelocitycalculator_p_p.h b/src/quicktemplates2/qquickvelocitycalculator_p_p.h index 144fe429..2b13ff07 100644 --- a/src/quicktemplates2/qquickvelocitycalculator_p_p.h +++ b/src/quicktemplates2/qquickvelocitycalculator_p_p.h @@ -56,8 +56,6 @@ QT_BEGIN_NAMESPACE class QQuickVelocityCalculator { public: - QQuickVelocityCalculator(); - void startMeasuring(const QPointF &point1, qint64 timestamp = 0); void stopMeasuring(const QPointF &m_point2, qint64 timestamp = 0); void reset(); @@ -66,8 +64,8 @@ public: private: QPointF m_point1; QPointF m_point2; - qint64 m_point1Timestamp; - qint64 m_point2Timestamp; + qint64 m_point1Timestamp = 0; + qint64 m_point2Timestamp = 0; // When a timestamp isn't available, we must use a timer. // When stopMeasuring() has been called, we store the elapsed time in point2timestamp. QElapsedTimer m_timer; -- cgit v1.2.3 From 2338fdc30b200c516356742802267b8c62bc7788 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 3 May 2018 13:00:13 +0200 Subject: Controls: use C++11 default member initialization Change-Id: Ief81868a8d314f7e7722fc0cb6670ae0dc4da50f Reviewed-by: Mitch Curtis --- src/quickcontrols2/qquickanimatednode.cpp | 7 +------ src/quickcontrols2/qquickanimatednode_p.h | 12 ++++++------ src/quickcontrols2/qquickclippedtext.cpp | 8 +------- src/quickcontrols2/qquickclippedtext_p.h | 12 ++++++------ src/quickcontrols2/qquickcolorimage.cpp | 2 +- src/quickcontrols2/qquickcolorimage_p.h | 4 ++-- src/quickcontrols2/qquickiconimage.cpp | 8 -------- src/quickcontrols2/qquickiconimage_p_p.h | 10 ++++------ src/quickcontrols2/qquickiconlabel.cpp | 14 -------------- src/quickcontrols2/qquickiconlabel_p_p.h | 22 ++++++++++------------ src/quickcontrols2/qquickmnemoniclabel.cpp | 3 +-- src/quickcontrols2/qquickmnemoniclabel_p.h | 2 +- src/quickcontrols2/qquickpaddedrectangle.cpp | 4 +--- src/quickcontrols2/qquickpaddedrectangle_p.h | 18 +++++++++--------- src/quickcontrols2/qquickproxytheme_p.h | 2 +- src/quickcontrols2/qquicktumblerview.cpp | 7 +------ src/quickcontrols2/qquicktumblerview_p.h | 10 +++++----- 17 files changed, 50 insertions(+), 95 deletions(-) diff --git a/src/quickcontrols2/qquickanimatednode.cpp b/src/quickcontrols2/qquickanimatednode.cpp index 3a18c757..b4e665de 100644 --- a/src/quickcontrols2/qquickanimatednode.cpp +++ b/src/quickcontrols2/qquickanimatednode.cpp @@ -44,12 +44,7 @@ QT_BEGIN_NAMESPACE QQuickAnimatedNode::QQuickAnimatedNode(QQuickItem *target) - : m_running(false), - m_duration(0), - m_loopCount(1), - m_currentTime(0), - m_currentLoop(0), - m_window(target->window()) + : m_window(target->window()) { } diff --git a/src/quickcontrols2/qquickanimatednode_p.h b/src/quickcontrols2/qquickanimatednode_p.h index 2e355e9a..d42d9319 100644 --- a/src/quickcontrols2/qquickanimatednode_p.h +++ b/src/quickcontrols2/qquickanimatednode_p.h @@ -98,13 +98,13 @@ private Q_SLOTS: void update(); private: - bool m_running; - int m_duration; - int m_loopCount; - int m_currentTime; - int m_currentLoop; + bool m_running = false; + int m_duration = 0; + int m_loopCount = 1; + int m_currentTime = 0; + int m_currentLoop = 0; QElapsedTimer m_timer; - QQuickWindow *m_window; + QQuickWindow *m_window = nullptr; }; QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickclippedtext.cpp b/src/quickcontrols2/qquickclippedtext.cpp index 7f113592..862197f3 100644 --- a/src/quickcontrols2/qquickclippedtext.cpp +++ b/src/quickcontrols2/qquickclippedtext.cpp @@ -41,13 +41,7 @@ QT_BEGIN_NAMESPACE QQuickClippedText::QQuickClippedText(QQuickItem *parent) - : QQuickText(parent), - m_hasClipWidth(false), - m_hasClipHeight(false), - m_clipX(0), - m_clipY(0), - m_clipWidth(0), - m_clipHeight(0) + : QQuickText(parent) { } diff --git a/src/quickcontrols2/qquickclippedtext_p.h b/src/quickcontrols2/qquickclippedtext_p.h index 7521525f..486ac7c4 100644 --- a/src/quickcontrols2/qquickclippedtext_p.h +++ b/src/quickcontrols2/qquickclippedtext_p.h @@ -81,12 +81,12 @@ public: private: void markClipDirty(); - bool m_hasClipWidth; - bool m_hasClipHeight; - qreal m_clipX; - qreal m_clipY; - qreal m_clipWidth; - qreal m_clipHeight; + bool m_hasClipWidth = false; + bool m_hasClipHeight = false; + qreal m_clipX = 0; + qreal m_clipY = 0; + qreal m_clipWidth = 0; + qreal m_clipHeight = 0; }; QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickcolorimage.cpp b/src/quickcontrols2/qquickcolorimage.cpp index 9d24a156..3afcef7e 100644 --- a/src/quickcontrols2/qquickcolorimage.cpp +++ b/src/quickcontrols2/qquickcolorimage.cpp @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE QQuickColorImage::QQuickColorImage(QQuickItem *parent) - : QQuickImage(parent), m_color(Qt::transparent), m_defaultColor(Qt::transparent) + : QQuickImage(parent) { } diff --git a/src/quickcontrols2/qquickcolorimage_p.h b/src/quickcontrols2/qquickcolorimage_p.h index 873bc2db..8227d068 100644 --- a/src/quickcontrols2/qquickcolorimage_p.h +++ b/src/quickcontrols2/qquickcolorimage_p.h @@ -79,8 +79,8 @@ protected: void pixmapChange() override; private: - QColor m_color; - QColor m_defaultColor; + QColor m_color = Qt::transparent; + QColor m_defaultColor = Qt::transparent; }; QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickiconimage.cpp b/src/quickcontrols2/qquickiconimage.cpp index 885bc7f9..c8357647 100644 --- a/src/quickcontrols2/qquickiconimage.cpp +++ b/src/quickcontrols2/qquickiconimage.cpp @@ -42,14 +42,6 @@ QT_BEGIN_NAMESPACE -QQuickIconImagePrivate::QQuickIconImagePrivate() - : color(Qt::transparent), - updatingIcon(false), - isThemeIcon(false), - updatingFillMode(false) -{ -} - bool QQuickIconImagePrivate::updateDevicePixelRatio(qreal targetDevicePixelRatio) { if (isThemeIcon) { diff --git a/src/quickcontrols2/qquickiconimage_p_p.h b/src/quickcontrols2/qquickiconimage_p_p.h index 8e8012bf..0c755ff6 100644 --- a/src/quickcontrols2/qquickiconimage_p_p.h +++ b/src/quickcontrols2/qquickiconimage_p_p.h @@ -59,19 +59,17 @@ class Q_QUICKCONTROLS2_PRIVATE_EXPORT QQuickIconImagePrivate : public QQuickImag Q_DECLARE_PUBLIC(QQuickIconImage) public: - QQuickIconImagePrivate(); - void updateIcon(); void updateFillMode(); qreal calculateDevicePixelRatio() const; bool updateDevicePixelRatio(qreal targetDevicePixelRatio) override; QUrl source; - QColor color; + QColor color = Qt::transparent; QThemeIconInfo icon; - bool updatingIcon; - bool isThemeIcon; - bool updatingFillMode; + bool updatingIcon = false; + bool isThemeIcon = false; + bool updatingFillMode = false; }; QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickiconlabel.cpp b/src/quickcontrols2/qquickiconlabel.cpp index 960d9905..6232b48c 100644 --- a/src/quickcontrols2/qquickiconlabel.cpp +++ b/src/quickcontrols2/qquickiconlabel.cpp @@ -57,20 +57,6 @@ static void completeComponent(QQuickItem *item) parserStatus->componentComplete(); } -QQuickIconLabelPrivate::QQuickIconLabelPrivate() - : mirrored(false), - display(QQuickIconLabel::TextBesideIcon), - alignment(Qt::AlignCenter), - spacing(0), - topPadding(0), - leftPadding(0), - rightPadding(0), - bottomPadding(0), - image(nullptr), - label(nullptr) -{ -} - bool QQuickIconLabelPrivate::hasIcon() const { return display != QQuickIconLabel::TextOnly && !icon.isEmpty(); diff --git a/src/quickcontrols2/qquickiconlabel_p_p.h b/src/quickcontrols2/qquickiconlabel_p_p.h index f0f4df4c..6a2a0f58 100644 --- a/src/quickcontrols2/qquickiconlabel_p_p.h +++ b/src/quickcontrols2/qquickiconlabel_p_p.h @@ -62,8 +62,6 @@ class QQuickIconLabelPrivate : public QQuickItemPrivate, public QQuickItemChange Q_DECLARE_PUBLIC(QQuickIconLabel) public: - explicit QQuickIconLabelPrivate(); - bool hasIcon() const; bool hasText() const; @@ -92,20 +90,20 @@ public: void itemImplicitHeightChanged(QQuickItem *) override; void itemDestroyed(QQuickItem *item) override; - bool mirrored; - QQuickIconLabel::Display display; - Qt::Alignment alignment; - qreal spacing; - qreal topPadding; - qreal leftPadding; - qreal rightPadding; - qreal bottomPadding; + bool mirrored = false; + QQuickIconLabel::Display display = QQuickIconLabel::TextBesideIcon; + Qt::Alignment alignment = Qt::AlignCenter; + qreal spacing = 0; + qreal topPadding = 0; + qreal leftPadding = 0; + qreal rightPadding = 0; + qreal bottomPadding = 0; QFont font; QColor color; QString text; QQuickIcon icon; - QQuickIconImage *image; - QQuickMnemonicLabel *label; + QQuickIconImage *image = nullptr; + QQuickMnemonicLabel *label = nullptr; }; QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickmnemoniclabel.cpp b/src/quickcontrols2/qquickmnemoniclabel.cpp index 9c8e9ab1..a006f076 100644 --- a/src/quickcontrols2/qquickmnemoniclabel.cpp +++ b/src/quickcontrols2/qquickmnemoniclabel.cpp @@ -41,8 +41,7 @@ QT_BEGIN_NAMESPACE QQuickMnemonicLabel::QQuickMnemonicLabel(QQuickItem *parent) - : QQuickText(parent), - m_mnemonicVisible(true) + : QQuickText(parent) { } diff --git a/src/quickcontrols2/qquickmnemoniclabel_p.h b/src/quickcontrols2/qquickmnemoniclabel_p.h index 33bc1e08..da5a83db 100644 --- a/src/quickcontrols2/qquickmnemoniclabel_p.h +++ b/src/quickcontrols2/qquickmnemoniclabel_p.h @@ -71,7 +71,7 @@ public: private: void updateMnemonic(); - bool m_mnemonicVisible; + bool m_mnemonicVisible = true; QString m_fullText; }; diff --git a/src/quickcontrols2/qquickpaddedrectangle.cpp b/src/quickcontrols2/qquickpaddedrectangle.cpp index f7088d54..fd9e9d90 100644 --- a/src/quickcontrols2/qquickpaddedrectangle.cpp +++ b/src/quickcontrols2/qquickpaddedrectangle.cpp @@ -41,9 +41,7 @@ QT_BEGIN_NAMESPACE QQuickPaddedRectangle::QQuickPaddedRectangle(QQuickItem *parent) : - QQuickRectangle(parent), m_padding(0), - m_topPadding(0), m_leftPadding(0), m_rightPadding(0), m_bottomPadding(0), - m_hasTopPadding(false), m_hasLeftPadding(false), m_hasRightPadding(false), m_hasBottomPadding(false) + QQuickRectangle(parent) { } diff --git a/src/quickcontrols2/qquickpaddedrectangle_p.h b/src/quickcontrols2/qquickpaddedrectangle_p.h index 261691ee..c2e0ddef 100644 --- a/src/quickcontrols2/qquickpaddedrectangle_p.h +++ b/src/quickcontrols2/qquickpaddedrectangle_p.h @@ -101,15 +101,15 @@ private: void setRightPadding(qreal padding, bool has); void setBottomPadding(qreal padding, bool has); - qreal m_padding; - qreal m_topPadding; - qreal m_leftPadding; - qreal m_rightPadding; - qreal m_bottomPadding; - bool m_hasTopPadding; - bool m_hasLeftPadding; - bool m_hasRightPadding; - bool m_hasBottomPadding; + qreal m_padding = 0; + qreal m_topPadding = 0; + qreal m_leftPadding = 0; + qreal m_rightPadding = 0; + qreal m_bottomPadding = 0; + bool m_hasTopPadding = false; + bool m_hasLeftPadding = false; + bool m_hasRightPadding = false; + bool m_hasBottomPadding = false; }; QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickproxytheme_p.h b/src/quickcontrols2/qquickproxytheme_p.h index 2d271e8c..879f03db 100644 --- a/src/quickcontrols2/qquickproxytheme_p.h +++ b/src/quickcontrols2/qquickproxytheme_p.h @@ -91,7 +91,7 @@ public: QString standardButtonText(int button) const override; private: - QPlatformTheme *m_theme; + QPlatformTheme *m_theme = nullptr; }; QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp index 4469810c..59d05211 100644 --- a/src/quickcontrols2/qquicktumblerview.cpp +++ b/src/quickcontrols2/qquicktumblerview.cpp @@ -46,12 +46,7 @@ QT_BEGIN_NAMESPACE QQuickTumblerView::QQuickTumblerView(QQuickItem *parent) : - QQuickItem(parent), - m_tumbler(nullptr), - m_delegate(nullptr), - m_pathView(nullptr), - m_listView(nullptr), - m_path(nullptr) + QQuickItem(parent) { // We don't call createView() here because we don't know what the wrap flag is set to // yet, and we don't want to create a view that might never get used. diff --git a/src/quickcontrols2/qquicktumblerview_p.h b/src/quickcontrols2/qquicktumblerview_p.h index 0ab0c3a9..138af1b4 100644 --- a/src/quickcontrols2/qquicktumblerview_p.h +++ b/src/quickcontrols2/qquicktumblerview_p.h @@ -96,12 +96,12 @@ private: void wrapChange(); - QQuickTumbler *m_tumbler; + QQuickTumbler *m_tumbler = nullptr; QVariant m_model; - QQmlComponent *m_delegate; - QQuickPathView *m_pathView; - QQuickListView *m_listView; - QQuickPath *m_path; + QQmlComponent *m_delegate = nullptr; + QQuickPathView *m_pathView = nullptr; + QQuickListView *m_listView = nullptr; + QQuickPath *m_path = nullptr; }; QT_END_NAMESPACE -- cgit v1.2.3 From bf39c3ce5524d151532d89efef40ff1a8e25f4c0 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 3 May 2018 13:13:55 +0200 Subject: Styles: use C++11 default member initialization Change-Id: Ifd7521b8a7bfd7da91808dd00ebdcb59f2ba46dc Reviewed-by: Mitch Curtis --- src/imports/controls/fusion/qquickfusiondial.cpp | 3 +- src/imports/controls/fusion/qquickfusiondial_p.h | 2 +- .../controls/imagine/qquickimageselector.cpp | 4 +-- .../controls/imagine/qquickimageselector_p.h | 6 ++-- .../controls/imagine/qquickimaginestyle.cpp | 1 - .../controls/imagine/qquickimaginestyle_p.h | 2 +- .../material/qquickmaterialbusyindicator.cpp | 19 +++++------- .../material/qquickmaterialbusyindicator_p.h | 4 +-- .../material/qquickmaterialprogressbar.cpp | 10 +++---- .../material/qquickmaterialprogressbar_p.h | 6 ++-- .../controls/material/qquickmaterialripple.cpp | 28 +++++------------- .../controls/material/qquickmaterialripple_p.h | 14 ++++----- .../controls/material/qquickmaterialstyle.cpp | 8 +---- .../controls/material/qquickmaterialstyle_p.h | 34 +++++++++++----------- .../controls/qquickdefaultbusyindicator.cpp | 2 +- .../controls/qquickdefaultbusyindicator_p.h | 2 +- src/imports/controls/qquickdefaultdial.cpp | 4 +-- src/imports/controls/qquickdefaultdial_p.h | 4 +-- src/imports/controls/qquickdefaultprogressbar.cpp | 9 ++---- src/imports/controls/qquickdefaultprogressbar_p.h | 4 +-- .../universal/qquickuniversalbusyindicator.cpp | 12 ++++---- .../universal/qquickuniversalbusyindicator_p.h | 6 ++-- .../universal/qquickuniversalprogressbar.cpp | 15 +++++----- .../universal/qquickuniversalprogressbar_p.h | 6 ++-- .../controls/universal/qquickuniversalstyle.cpp | 1 - .../controls/universal/qquickuniversalstyle_p.h | 20 ++++++------- 26 files changed, 95 insertions(+), 131 deletions(-) diff --git a/src/imports/controls/fusion/qquickfusiondial.cpp b/src/imports/controls/fusion/qquickfusiondial.cpp index 014078e6..182f5c0f 100644 --- a/src/imports/controls/fusion/qquickfusiondial.cpp +++ b/src/imports/controls/fusion/qquickfusiondial.cpp @@ -42,8 +42,7 @@ QT_BEGIN_NAMESPACE QQuickFusionDial::QQuickFusionDial(QQuickItem *parent) - : QQuickPaintedItem(parent), - m_highlight(false) + : QQuickPaintedItem(parent) { } diff --git a/src/imports/controls/fusion/qquickfusiondial_p.h b/src/imports/controls/fusion/qquickfusiondial_p.h index d3216521..740545d8 100644 --- a/src/imports/controls/fusion/qquickfusiondial_p.h +++ b/src/imports/controls/fusion/qquickfusiondial_p.h @@ -71,7 +71,7 @@ public: void paint(QPainter *painter) override; private: - bool m_highlight; + bool m_highlight = false; QPalette m_palette; }; diff --git a/src/imports/controls/imagine/qquickimageselector.cpp b/src/imports/controls/imagine/qquickimageselector.cpp index 1b3e80a9..67d3a24b 100644 --- a/src/imports/controls/imagine/qquickimageselector.cpp +++ b/src/imports/controls/imagine/qquickimageselector.cpp @@ -106,9 +106,7 @@ static QString findFile(const QDir &dir, const QString &baseName, const QStringL QQuickImageSelector::QQuickImageSelector(QObject *parent) : QObject(parent), - m_cache(cacheSize() > 0), - m_complete(false), - m_separator(QLatin1String("-")) + m_cache(cacheSize() > 0) { } diff --git a/src/imports/controls/imagine/qquickimageselector_p.h b/src/imports/controls/imagine/qquickimageselector_p.h index 2bb4e526..d050707d 100644 --- a/src/imports/controls/imagine/qquickimageselector_p.h +++ b/src/imports/controls/imagine/qquickimageselector_p.h @@ -110,12 +110,12 @@ protected: int calculateScore(const QStringList &states) const; private: - bool m_cache; - bool m_complete; + bool m_cache = false; + bool m_complete = false; QUrl m_source; QString m_path; QString m_name; - QString m_separator; + QString m_separator = QLatin1String("-"); QVariantList m_allStates; QStringList m_activeStates; QQmlProperty m_property; diff --git a/src/imports/controls/imagine/qquickimaginestyle.cpp b/src/imports/controls/imagine/qquickimaginestyle.cpp index 7617fbf5..9e1431de 100644 --- a/src/imports/controls/imagine/qquickimaginestyle.cpp +++ b/src/imports/controls/imagine/qquickimaginestyle.cpp @@ -51,7 +51,6 @@ static const QString ensureSlash(const QString &path) QQuickImagineStyle::QQuickImagineStyle(QObject *parent) : QQuickAttachedObject(parent), - m_explicitPath(false), m_path(*GlobalPath()) { init(); diff --git a/src/imports/controls/imagine/qquickimaginestyle_p.h b/src/imports/controls/imagine/qquickimaginestyle_p.h index 88b92c00..20a4baf0 100644 --- a/src/imports/controls/imagine/qquickimaginestyle_p.h +++ b/src/imports/controls/imagine/qquickimaginestyle_p.h @@ -82,7 +82,7 @@ protected: private: void init(); - bool m_explicitPath; + bool m_explicitPath = false; QString m_path; }; diff --git a/src/imports/controls/material/qquickmaterialbusyindicator.cpp b/src/imports/controls/material/qquickmaterialbusyindicator.cpp index 0a4191be..c18a4005 100644 --- a/src/imports/controls/material/qquickmaterialbusyindicator.cpp +++ b/src/imports/controls/material/qquickmaterialbusyindicator.cpp @@ -77,21 +77,16 @@ protected: void updateCurrentTime(int time) override; private: - int m_lastStartAngle; - int m_lastEndAngle; - qreal m_width; - qreal m_height; - qreal m_devicePixelRatio; + int m_lastStartAngle = 0; + int m_lastEndAngle = 0; + qreal m_width = 0; + qreal m_height = 0; + qreal m_devicePixelRatio = 1; QColor m_color; }; QQuickMaterialBusyIndicatorNode::QQuickMaterialBusyIndicatorNode(QQuickMaterialBusyIndicator *item) - : QQuickAnimatedNode(item), - m_lastStartAngle(0), - m_lastEndAngle(0), - m_width(0), - m_height(0), - m_devicePixelRatio(1) + : QQuickAnimatedNode(item) { setLoopCount(Infinite); setCurrentTime(item->elapsed()); @@ -179,7 +174,7 @@ void QQuickMaterialBusyIndicatorNode::sync(QQuickItem *item) } QQuickMaterialBusyIndicator::QQuickMaterialBusyIndicator(QQuickItem *parent) : - QQuickItem(parent), m_elapsed(0), m_color(Qt::black) + QQuickItem(parent) { setFlag(ItemHasContents); } diff --git a/src/imports/controls/material/qquickmaterialbusyindicator_p.h b/src/imports/controls/material/qquickmaterialbusyindicator_p.h index 6c6d2445..d29427c1 100644 --- a/src/imports/controls/material/qquickmaterialbusyindicator_p.h +++ b/src/imports/controls/material/qquickmaterialbusyindicator_p.h @@ -75,8 +75,8 @@ protected: QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; private: - int m_elapsed; - QColor m_color; + int m_elapsed = 0; + QColor m_color = Qt::black; }; QT_END_NAMESPACE diff --git a/src/imports/controls/material/qquickmaterialprogressbar.cpp b/src/imports/controls/material/qquickmaterialprogressbar.cpp index c1d36d3b..4635c57b 100644 --- a/src/imports/controls/material/qquickmaterialprogressbar.cpp +++ b/src/imports/controls/material/qquickmaterialprogressbar.cpp @@ -62,14 +62,12 @@ public: private: void moveNode(QSGTransformNode *node, const QRectF &geometry, qreal progress); - bool m_indeterminate; - QEasingCurve m_easing; + bool m_indeterminate = false; + QEasingCurve m_easing = QEasingCurve::OutCubic; }; QQuickMaterialProgressBarNode::QQuickMaterialProgressBarNode(QQuickMaterialProgressBar *item) - : QQuickAnimatedNode(item), - m_indeterminate(false), - m_easing(QEasingCurve::OutCubic) + : QQuickAnimatedNode(item) { setLoopCount(Infinite); setDuration(TotalDuration); @@ -176,7 +174,7 @@ void QQuickMaterialProgressBarNode::moveNode(QSGTransformNode *transformNode, co } QQuickMaterialProgressBar::QQuickMaterialProgressBar(QQuickItem *parent) - : QQuickItem(parent), m_color(Qt::black), m_progress(0.0), m_indeterminate(false) + : QQuickItem(parent) { setFlag(ItemHasContents); } diff --git a/src/imports/controls/material/qquickmaterialprogressbar_p.h b/src/imports/controls/material/qquickmaterialprogressbar_p.h index 981d9bfb..680f36a4 100644 --- a/src/imports/controls/material/qquickmaterialprogressbar_p.h +++ b/src/imports/controls/material/qquickmaterialprogressbar_p.h @@ -77,9 +77,9 @@ protected: QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; private: - QColor m_color; - qreal m_progress; - bool m_indeterminate; + QColor m_color = Qt::black; + qreal m_progress = 0.0; + bool m_indeterminate = false; }; QT_END_NAMESPACE diff --git a/src/imports/controls/material/qquickmaterialripple.cpp b/src/imports/controls/material/qquickmaterialripple.cpp index 1c3b3f12..e6287ff9 100644 --- a/src/imports/controls/material/qquickmaterialripple.cpp +++ b/src/imports/controls/material/qquickmaterialripple.cpp @@ -64,20 +64,16 @@ public: void sync(QQuickItem *item) override; private: - qreal m_from; - qreal m_to; - qreal m_value; - WavePhase m_phase; + qreal m_from = 0; + qreal m_to = 0; + qreal m_value = 0; + WavePhase m_phase = WaveEnter; QPointF m_anchor; QRectF m_bounds; }; QQuickMaterialRippleWaveNode::QQuickMaterialRippleWaveNode(QQuickMaterialRipple *ripple) - : QQuickAnimatedNode(ripple), - m_from(0), - m_to(0), - m_value(0), - m_phase(WaveEnter) + : QQuickAnimatedNode(ripple) { start(qRound(1000.0 * qSqrt(ripple->diameter() / 2.0 / WAVE_TOUCH_DOWN_ACCELERATION))); @@ -156,12 +152,11 @@ public: void sync(QQuickItem *item) override; private: - bool m_active; + bool m_active = false; }; QQuickMaterialRippleBackgroundNode::QQuickMaterialRippleBackgroundNode(QQuickMaterialRipple *ripple) - : QQuickAnimatedNode(ripple), - m_active(false) + : QQuickAnimatedNode(ripple) { setDuration(OPACITY_ENTER_DURATION_FAST); @@ -221,14 +216,7 @@ void QQuickMaterialRippleBackgroundNode::sync(QQuickItem *item) } QQuickMaterialRipple::QQuickMaterialRipple(QQuickItem *parent) - : QQuickItem(parent), - m_active(false), - m_pressed(false), - m_waves(0), - m_enterDelay(0), - m_trigger(Press), - m_clipRadius(0.0), - m_anchor(nullptr) + : QQuickItem(parent) { setFlag(ItemHasContents); } diff --git a/src/imports/controls/material/qquickmaterialripple_p.h b/src/imports/controls/material/qquickmaterialripple_p.h index 712697da..8a80113b 100644 --- a/src/imports/controls/material/qquickmaterialripple_p.h +++ b/src/imports/controls/material/qquickmaterialripple_p.h @@ -101,14 +101,14 @@ protected: void exitWave(); private: - bool m_active; - bool m_pressed; - int m_waves; - int m_enterDelay; - Trigger m_trigger; - qreal m_clipRadius; + bool m_active = false; + bool m_pressed = false; + int m_waves = 0; + int m_enterDelay = 0; + Trigger m_trigger = Press; + qreal m_clipRadius = 0.0; QColor m_color; - QQuickItem *m_anchor; + QQuickItem *m_anchor = nullptr; }; QT_END_NAMESPACE diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp index 08d88ec7..4dd4e128 100644 --- a/src/imports/controls/material/qquickmaterialstyle.cpp +++ b/src/imports/controls/material/qquickmaterialstyle.cpp @@ -427,11 +427,6 @@ static QQuickMaterialStyle::Theme effectiveTheme(QQuickMaterialStyle::Theme them } QQuickMaterialStyle::QQuickMaterialStyle(QObject *parent) : QQuickAttachedObject(parent), - m_explicitTheme(false), - m_explicitPrimary(false), - m_explicitAccent(false), - m_explicitForeground(false), - m_explicitBackground(false), m_customPrimary(globalPrimaryCustom), m_customAccent(globalAccentCustom), m_customForeground(globalForegroundCustom), @@ -442,8 +437,7 @@ QQuickMaterialStyle::QQuickMaterialStyle(QObject *parent) : QQuickAttachedObject m_primary(globalPrimary), m_accent(globalAccent), m_foreground(globalForeground), - m_background(globalBackground), - m_elevation(0) + m_background(globalBackground) { init(); } diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h index 2374eefb..6008b1e0 100644 --- a/src/imports/controls/material/qquickmaterialstyle_p.h +++ b/src/imports/controls/material/qquickmaterialstyle_p.h @@ -249,31 +249,31 @@ private: // These reflect whether a color value was explicitly set on the specific // item that this attached style object represents. - bool m_explicitTheme; - bool m_explicitPrimary; - bool m_explicitAccent; - bool m_explicitForeground; - bool m_explicitBackground; + bool m_explicitTheme = false; + bool m_explicitPrimary = false; + bool m_explicitAccent = false; + bool m_explicitForeground = false; + bool m_explicitBackground = false; // These reflect whether the color value that was either inherited or // explicitly set is in the form that QColor expects, rather than one of // our pre-defined color enum values. - bool m_customPrimary; - bool m_customAccent; - bool m_customForeground; - bool m_customBackground; + bool m_customPrimary = false; + bool m_customAccent = false; + bool m_customForeground = false; + bool m_customBackground = false; // These will be true when this item has an explicit or inherited foreground/background // color, or these colors were declared globally via settings (e.g. conf or env vars). // Some color properties of the style will return different values depending on whether // or not these are set. - bool m_hasForeground; - bool m_hasBackground; + bool m_hasForeground = false; + bool m_hasBackground = false; // The actual values for this item, whether explicit, inherited or globally set. - Theme m_theme; - uint m_primary; - uint m_accent; - uint m_foreground; - uint m_background; - int m_elevation; + Theme m_theme = Light; + uint m_primary = 0; + uint m_accent = 0; + uint m_foreground = 0; + uint m_background = 0; + int m_elevation = 0; }; QT_END_NAMESPACE diff --git a/src/imports/controls/qquickdefaultbusyindicator.cpp b/src/imports/controls/qquickdefaultbusyindicator.cpp index c02d8128..98a3cae3 100644 --- a/src/imports/controls/qquickdefaultbusyindicator.cpp +++ b/src/imports/controls/qquickdefaultbusyindicator.cpp @@ -138,7 +138,7 @@ void QQuickDefaultBusyIndicatorNode::sync(QQuickItem *item) } QQuickDefaultBusyIndicator::QQuickDefaultBusyIndicator(QQuickItem *parent) : - QQuickItem(parent), m_elapsed(0) + QQuickItem(parent) { setFlag(ItemHasContents); } diff --git a/src/imports/controls/qquickdefaultbusyindicator_p.h b/src/imports/controls/qquickdefaultbusyindicator_p.h index 1beeb0c9..eedaf09a 100644 --- a/src/imports/controls/qquickdefaultbusyindicator_p.h +++ b/src/imports/controls/qquickdefaultbusyindicator_p.h @@ -79,7 +79,7 @@ protected: QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; private: - int m_elapsed; + int m_elapsed = 0; QColor m_pen; QColor m_fill; }; diff --git a/src/imports/controls/qquickdefaultdial.cpp b/src/imports/controls/qquickdefaultdial.cpp index 845e634d..1653def7 100644 --- a/src/imports/controls/qquickdefaultdial.cpp +++ b/src/imports/controls/qquickdefaultdial.cpp @@ -43,9 +43,7 @@ QT_BEGIN_NAMESPACE QQuickDefaultDial::QQuickDefaultDial(QQuickItem *parent) : - QQuickPaintedItem(parent), - m_progress(0), - m_color(Qt::black) + QQuickPaintedItem(parent) { } diff --git a/src/imports/controls/qquickdefaultdial_p.h b/src/imports/controls/qquickdefaultdial_p.h index 10490610..73e14321 100644 --- a/src/imports/controls/qquickdefaultdial_p.h +++ b/src/imports/controls/qquickdefaultdial_p.h @@ -71,8 +71,8 @@ public: void paint(QPainter *painter) override; private: - qreal m_progress; - QColor m_color; + qreal m_progress = 0; + QColor m_color = Qt::black; }; QT_END_NAMESPACE diff --git a/src/imports/controls/qquickdefaultprogressbar.cpp b/src/imports/controls/qquickdefaultprogressbar.cpp index f5bd1db8..e8657255 100644 --- a/src/imports/controls/qquickdefaultprogressbar.cpp +++ b/src/imports/controls/qquickdefaultprogressbar.cpp @@ -77,13 +77,12 @@ public: void sync(QQuickItem *item) override; private: - bool m_indeterminate; - qreal m_pixelsPerSecond; + bool m_indeterminate = false; + qreal m_pixelsPerSecond = 0; }; QQuickDefaultProgressBarNode::QQuickDefaultProgressBarNode(QQuickDefaultProgressBar *item) : QQuickAnimatedNode(item), - m_indeterminate(false), m_pixelsPerSecond(item->width()) { setLoopCount(Infinite); @@ -209,9 +208,7 @@ void QQuickDefaultProgressBarNode::sync(QQuickItem *item) } QQuickDefaultProgressBar::QQuickDefaultProgressBar(QQuickItem *parent) : - QQuickItem(parent), - m_progress(0), - m_indeterminate(false) + QQuickItem(parent) { setFlag(ItemHasContents); } diff --git a/src/imports/controls/qquickdefaultprogressbar_p.h b/src/imports/controls/qquickdefaultprogressbar_p.h index 91f8056b..241d0b3b 100644 --- a/src/imports/controls/qquickdefaultprogressbar_p.h +++ b/src/imports/controls/qquickdefaultprogressbar_p.h @@ -77,8 +77,8 @@ protected: QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; private: - qreal m_progress; - bool m_indeterminate; + qreal m_progress = 0; + bool m_indeterminate = false; QColor m_color; }; diff --git a/src/imports/controls/universal/qquickuniversalbusyindicator.cpp b/src/imports/controls/universal/qquickuniversalbusyindicator.cpp index a3d09094..70170296 100644 --- a/src/imports/controls/universal/qquickuniversalbusyindicator.cpp +++ b/src/imports/controls/universal/qquickuniversalbusyindicator.cpp @@ -58,12 +58,12 @@ public: private: struct Phase { - Phase() : duration(0), from(0), to(0), curve(QEasingCurve::Linear) { } + Phase() = default; Phase(int d, qreal f, qreal t, QEasingCurve::Type c) : duration(d), from(f), to(t), curve(c) { } - int duration; - qreal from; - qreal to; - QEasingCurve curve; + int duration = 0; + qreal from = 0; + qreal to = 0; + QEasingCurve curve = QEasingCurve::Linear; }; Phase m_phases[PhaseCount]; @@ -186,7 +186,7 @@ void QQuickUniversalBusyIndicatorNode::sync(QQuickItem *item) } QQuickUniversalBusyIndicator::QQuickUniversalBusyIndicator(QQuickItem *parent) - : QQuickItem(parent), m_count(5), m_elapsed(0), m_color(Qt::black) + : QQuickItem(parent) { setFlag(ItemHasContents); } diff --git a/src/imports/controls/universal/qquickuniversalbusyindicator_p.h b/src/imports/controls/universal/qquickuniversalbusyindicator_p.h index 6b888463..119091b5 100644 --- a/src/imports/controls/universal/qquickuniversalbusyindicator_p.h +++ b/src/imports/controls/universal/qquickuniversalbusyindicator_p.h @@ -75,9 +75,9 @@ protected: QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; private: - int m_count; - int m_elapsed; - QColor m_color; + int m_count = 5; + int m_elapsed = 0; + QColor m_color = Qt::black; }; QT_END_NAMESPACE diff --git a/src/imports/controls/universal/qquickuniversalprogressbar.cpp b/src/imports/controls/universal/qquickuniversalprogressbar.cpp index 25dfda6f..7d4642c5 100644 --- a/src/imports/controls/universal/qquickuniversalprogressbar.cpp +++ b/src/imports/controls/universal/qquickuniversalprogressbar.cpp @@ -67,21 +67,20 @@ public: private: struct Phase { - Phase() : duration(0), from(0), to(0) { } + Phase() = default; Phase(int d, qreal f, qreal t) : duration(d), from(f), to(t) { } - int duration; - qreal from; - qreal to; + int duration = 0; + qreal from = 0; + qreal to = 0; }; - bool m_indeterminate; + bool m_indeterminate = false; Phase m_borderPhases[PhaseCount]; Phase m_ellipsePhases[PhaseCount]; }; QQuickUniversalProgressBarNode::QQuickUniversalProgressBarNode(QQuickUniversalProgressBar *item) - : QQuickAnimatedNode(item), - m_indeterminate(false) + : QQuickAnimatedNode(item) { setLoopCount(Infinite); setDuration(TotalDuration); @@ -267,7 +266,7 @@ void QQuickUniversalProgressBarNode::sync(QQuickItem *item) } QQuickUniversalProgressBar::QQuickUniversalProgressBar(QQuickItem *parent) - : QQuickItem(parent), m_color(Qt::black), m_progress(0.0), m_indeterminate(false) + : QQuickItem(parent) { setFlag(ItemHasContents); } diff --git a/src/imports/controls/universal/qquickuniversalprogressbar_p.h b/src/imports/controls/universal/qquickuniversalprogressbar_p.h index ef34289c..449f7965 100644 --- a/src/imports/controls/universal/qquickuniversalprogressbar_p.h +++ b/src/imports/controls/universal/qquickuniversalprogressbar_p.h @@ -77,9 +77,9 @@ protected: QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; private: - QColor m_color; - qreal m_progress; - bool m_indeterminate; + QColor m_color = Qt::black; + qreal m_progress = 0.0; + bool m_indeterminate = false; }; QT_END_NAMESPACE diff --git a/src/imports/controls/universal/qquickuniversalstyle.cpp b/src/imports/controls/universal/qquickuniversalstyle.cpp index dbc409fd..d46752f3 100644 --- a/src/imports/controls/universal/qquickuniversalstyle.cpp +++ b/src/imports/controls/universal/qquickuniversalstyle.cpp @@ -152,7 +152,6 @@ static bool HasGlobalForeground = false; static bool HasGlobalBackground = false; QQuickUniversalStyle::QQuickUniversalStyle(QObject *parent) : QQuickAttachedObject(parent), - m_explicitTheme(false), m_explicitAccent(false), m_explicitForeground(false), m_explicitBackground(false), m_hasForeground(HasGlobalForeground), m_hasBackground(HasGlobalBackground), m_theme(GlobalTheme), m_accent(GlobalAccent), m_foreground(GlobalForeground), m_background(GlobalBackground) { diff --git a/src/imports/controls/universal/qquickuniversalstyle_p.h b/src/imports/controls/universal/qquickuniversalstyle_p.h index eb9f6d83..429621d7 100644 --- a/src/imports/controls/universal/qquickuniversalstyle_p.h +++ b/src/imports/controls/universal/qquickuniversalstyle_p.h @@ -217,21 +217,21 @@ private: // These reflect whether a color value was explicitly set on the specific // item that this attached style object represents. - bool m_explicitTheme; - bool m_explicitAccent; - bool m_explicitForeground; - bool m_explicitBackground; + bool m_explicitTheme = false; + bool m_explicitAccent = false; + bool m_explicitForeground = false; + bool m_explicitBackground = false; // These will be true when this item has an explicit or inherited foreground/background // color, or these colors were declared globally via settings (e.g. conf or env vars). // Some color properties of the style will return different values depending on whether // or not these are set. - bool m_hasForeground; - bool m_hasBackground; + bool m_hasForeground = false; + bool m_hasBackground = false; // The actual values for this item, whether explicit, inherited or globally set. - QQuickUniversalStyle::Theme m_theme; - QRgb m_accent; - QRgb m_foreground; - QRgb m_background; + Theme m_theme = Light; + QRgb m_accent = Qt::blue; + QRgb m_foreground = Qt::black; + QRgb m_background = Qt::white; }; QT_END_NAMESPACE -- cgit v1.2.3