diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-04-27 10:44:50 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-05-02 12:42:15 +0000 |
commit | b4fca58fbe488e034b762fbcf04bc7334efa2c86 (patch) | |
tree | b48b3298930acb32861efa2233470d59966d4f59 | |
parent | 804261e2808878baf657efacb0fb42408853629e (diff) | |
download | qttools-b4fca58fbe488e034b762fbcf04bc7334efa2c86.tar.gz |
Qt Designer and shared classes: Use member initialization for structs.
Use member initialization and remove unneeded constructors.
Change-Id: I289797dc0e6999b802c35c48f001e9f74a402272
Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
21 files changed, 71 insertions, 155 deletions
diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp index 45589e313..2f3861cbe 100644 --- a/src/designer/src/components/formeditor/formwindowsettings.cpp +++ b/src/designer/src/components/formeditor/formwindowsettings.cpp @@ -48,18 +48,16 @@ namespace qdesigner_internal { // Data structure containing form dialog data providing comparison struct FormWindowData { - FormWindowData(); - bool equals(const FormWindowData&) const; void fromFormWindow(FormWindowBase* fw); void applyToFormWindow(FormWindowBase* fw) const; - bool layoutDefaultEnabled; - int defaultMargin; - int defaultSpacing; + bool layoutDefaultEnabled{false}; + int defaultMargin{0}; + int defaultSpacing{0}; - bool layoutFunctionsEnabled; + bool layoutFunctionsEnabled{false}; QString marginFunction; QString spacingFunction; @@ -69,7 +67,7 @@ struct FormWindowData { QStringList includeHints; - bool hasFormGrid; + bool hasFormGrid{false}; Grid grid; }; @@ -86,15 +84,6 @@ QDebug operator<<(QDebug str, const FormWindowData &d) return str; } -FormWindowData::FormWindowData() : - layoutDefaultEnabled(false), - defaultMargin(0), - defaultSpacing(0), - layoutFunctionsEnabled(false), - hasFormGrid(false) -{ -} - bool FormWindowData::equals(const FormWindowData &rhs) const { return layoutDefaultEnabled == rhs.layoutDefaultEnabled && diff --git a/src/designer/src/components/formeditor/itemview_propertysheet.cpp b/src/designer/src/components/formeditor/itemview_propertysheet.cpp index ab0554014..e9164b915 100644 --- a/src/designer/src/components/formeditor/itemview_propertysheet.cpp +++ b/src/designer/src/components/formeditor/itemview_propertysheet.cpp @@ -44,12 +44,12 @@ QT_BEGIN_NAMESPACE namespace qdesigner_internal { struct Property { - Property() : m_sheet(0),m_id(-1) {} + Property() = default; Property(QDesignerPropertySheetExtension *sheet, int id) : m_sheet(sheet), m_id(id) {} - QDesignerPropertySheetExtension *m_sheet; - int m_id; + QDesignerPropertySheetExtension *m_sheet{nullptr}; + int m_id{-1}; }; typedef QMap<int, Property> FakePropertyMap; diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.h b/src/designer/src/components/propertyeditor/designerpropertymanager.h index 8c46505e3..ec19b2ffa 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.h +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.h @@ -177,8 +177,7 @@ private: int bitCount(int mask) const; struct FlagData { - FlagData() : val(0) {} - uint val; + uint val{0}; DesignerFlagList flags; QList<uint> values; }; diff --git a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp index 1d586cd97..018f1e2b1 100644 --- a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp +++ b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp @@ -79,7 +79,7 @@ namespace qdesigner_internal { // Entry of the model list struct WidgetBoxCategoryEntry { - WidgetBoxCategoryEntry(); + WidgetBoxCategoryEntry() = default; explicit WidgetBoxCategoryEntry(const QDesignerWidgetBoxInterface::Widget &widget, const QString &filter, const QIcon &icon, @@ -90,15 +90,9 @@ struct WidgetBoxCategoryEntry { QString whatsThis; QString filter; QIcon icon; - bool editable; + bool editable{false}; }; - -WidgetBoxCategoryEntry::WidgetBoxCategoryEntry() : - editable(false) -{ -} - WidgetBoxCategoryEntry::WidgetBoxCategoryEntry(const QDesignerWidgetBoxInterface::Widget &w, const QString &filterIn, const QIcon &i, bool e) : diff --git a/src/designer/src/designer/qdesigner.cpp b/src/designer/src/designer/qdesigner.cpp index 23f35f2d7..244c1defb 100644 --- a/src/designer/src/designer/qdesigner.cpp +++ b/src/designer/src/designer/qdesigner.cpp @@ -167,15 +167,11 @@ static void showHelp(QCommandLineParser &parser, const QString &errorMessage = Q struct Options { - Options() - : resourceDir(QLibraryInfo::location(QLibraryInfo::TranslationsPath)) - , server(false), clientPort(0), enableInternalDynamicProperties(false) {} - QStringList files; - QString resourceDir; - bool server; - quint16 clientPort; - bool enableInternalDynamicProperties; + QString resourceDir{QLibraryInfo::location(QLibraryInfo::TranslationsPath)}; + bool server{false}; + quint16 clientPort{0}; + bool enableInternalDynamicProperties{false}; }; static inline QDesigner::ParseArgumentsResult diff --git a/src/designer/src/designer/qdesigner_appearanceoptions.cpp b/src/designer/src/designer/qdesigner_appearanceoptions.cpp index 633503f60..a715478ed 100644 --- a/src/designer/src/designer/qdesigner_appearanceoptions.cpp +++ b/src/designer/src/designer/qdesigner_appearanceoptions.cpp @@ -44,11 +44,6 @@ QT_BEGIN_NAMESPACE // ---------------- AppearanceOptions -AppearanceOptions::AppearanceOptions() : - uiMode(DockedMode) -{ -} - bool AppearanceOptions::equals(const AppearanceOptions &rhs) const { return uiMode == rhs.uiMode && toolWindowFontSettings == rhs.toolWindowFontSettings; diff --git a/src/designer/src/designer/qdesigner_appearanceoptions.h b/src/designer/src/designer/qdesigner_appearanceoptions.h index 62476b5e4..f48b16976 100644 --- a/src/designer/src/designer/qdesigner_appearanceoptions.h +++ b/src/designer/src/designer/qdesigner_appearanceoptions.h @@ -54,12 +54,11 @@ namespace Ui { /* AppearanceOptions data */ struct AppearanceOptions { - AppearanceOptions(); bool equals(const AppearanceOptions&) const; void toSettings(QDesignerSettings &) const; void fromSettings(const QDesignerSettings &); - UIMode uiMode; + UIMode uiMode{DockedMode}; ToolWindowFontSettings toolWindowFontSettings; }; diff --git a/src/designer/src/designer/qdesigner_toolwindow.cpp b/src/designer/src/designer/qdesigner_toolwindow.cpp index 917ef57b0..28b0d417a 100644 --- a/src/designer/src/designer/qdesigner_toolwindow.cpp +++ b/src/designer/src/designer/qdesigner_toolwindow.cpp @@ -53,12 +53,6 @@ enum { debugToolWindow = 0 }; QT_BEGIN_NAMESPACE // ---------------- QDesignerToolWindowFontSettings -ToolWindowFontSettings::ToolWindowFontSettings() : - m_writingSystem(QFontDatabase::Any), - m_useFont(false) -{ -} - bool ToolWindowFontSettings::equals(const ToolWindowFontSettings &rhs) const { return m_useFont == rhs.m_useFont && diff --git a/src/designer/src/designer/qdesigner_toolwindow.h b/src/designer/src/designer/qdesigner_toolwindow.h index 319b6fa74..351a5e289 100644 --- a/src/designer/src/designer/qdesigner_toolwindow.h +++ b/src/designer/src/designer/qdesigner_toolwindow.h @@ -43,12 +43,11 @@ QT_BEGIN_NAMESPACE struct ToolWindowFontSettings { - ToolWindowFontSettings(); bool equals(const ToolWindowFontSettings &) const; QFont m_font; - QFontDatabase::WritingSystem m_writingSystem; - bool m_useFont; + QFontDatabase::WritingSystem m_writingSystem{QFontDatabase::Any}; + bool m_useFont{false}; }; inline bool operator==(const ToolWindowFontSettings &tw1, const ToolWindowFontSettings &tw2) diff --git a/src/designer/src/lib/shared/formlayoutmenu.cpp b/src/designer/src/lib/shared/formlayoutmenu.cpp index e859ff6e7..acb572a3e 100644 --- a/src/designer/src/lib/shared/formlayoutmenu.cpp +++ b/src/designer/src/lib/shared/formlayoutmenu.cpp @@ -73,13 +73,11 @@ namespace qdesigner_internal { // Struct that describes a row of controls (descriptive label and control) to // be added to a form layout. struct FormLayoutRow { - FormLayoutRow() : buddy(false) {} - QString labelName; QString labelText; QString fieldClassName; QString fieldName; - bool buddy; + bool buddy{false}; }; // A Dialog to edit a FormLayoutRow. Lets the user input a label text, label diff --git a/src/designer/src/lib/shared/newactiondialog.cpp b/src/designer/src/lib/shared/newactiondialog.cpp index 0d1fab4c3..48c2b7922 100644 --- a/src/designer/src/lib/shared/newactiondialog.cpp +++ b/src/designer/src/lib/shared/newactiondialog.cpp @@ -48,13 +48,6 @@ QT_BEGIN_NAMESPACE namespace qdesigner_internal { -// -------------------- ActionData - -ActionData::ActionData() : - checkable(false) -{ -} - // Returns a combination of ChangeMask flags unsigned ActionData::compare(const ActionData &rhs) const { diff --git a/src/designer/src/lib/shared/newactiondialog_p.h b/src/designer/src/lib/shared/newactiondialog_p.h index 52817951b..183084e33 100644 --- a/src/designer/src/lib/shared/newactiondialog_p.h +++ b/src/designer/src/lib/shared/newactiondialog_p.h @@ -67,7 +67,6 @@ struct ActionData { IconChanged = 0x8, CheckableChanged = 0x10, KeysequenceChanged = 0x20 }; - ActionData(); // Returns a combination of ChangeMask flags unsigned compare(const ActionData &rhs) const; @@ -75,7 +74,7 @@ struct ActionData { QString name; QString toolTip; PropertySheetIconValue icon; - bool checkable; + bool checkable{false}; PropertySheetKeySequenceValue keysequence; }; diff --git a/src/designer/src/lib/shared/qdesigner_membersheet.cpp b/src/designer/src/lib/shared/qdesigner_membersheet.cpp index f202a588f..4d7c82c4c 100644 --- a/src/designer/src/lib/shared/qdesigner_membersheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_membersheet.cpp @@ -74,10 +74,8 @@ public: class Info { public: - inline Info() : visible(true) {} - QString group; - bool visible; + bool visible{true}; }; typedef QHash<int, Info> InfoHash; diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp index a6bd9e37f..7878736bb 100644 --- a/src/designer/src/lib/shared/qdesigner_utils.cpp +++ b/src/designer/src/lib/shared/qdesigner_utils.cpp @@ -252,10 +252,8 @@ namespace qdesigner_internal metaEnum(me) { } - PropertySheetEnumValue::PropertySheetEnumValue() : - value(0) - { - } + + PropertySheetEnumValue::PropertySheetEnumValue() = default; // ---------------- PropertySheetFlagValue PropertySheetFlagValue::PropertySheetFlagValue(int v, const DesignerMetaFlags &mf) : @@ -264,10 +262,7 @@ namespace qdesigner_internal { } - PropertySheetFlagValue::PropertySheetFlagValue() : - value(0) - { - } + PropertySheetFlagValue::PropertySheetFlagValue() = default; // ---------------- PropertySheetPixmapValue PropertySheetPixmapValue::PropertySheetPixmapValue(const QString &path) : m_path(path) diff --git a/src/designer/src/lib/shared/qdesigner_utils_p.h b/src/designer/src/lib/shared/qdesigner_utils_p.h index 5b45a03c0..8d116479a 100644 --- a/src/designer/src/lib/shared/qdesigner_utils_p.h +++ b/src/designer/src/lib/shared/qdesigner_utils_p.h @@ -204,7 +204,7 @@ struct QDESIGNER_SHARED_EXPORT PropertySheetEnumValue PropertySheetEnumValue(int v, const DesignerMetaEnum &me); PropertySheetEnumValue(); - int value; + int value{0}; DesignerMetaEnum metaEnum; }; @@ -215,7 +215,7 @@ struct QDESIGNER_SHARED_EXPORT PropertySheetFlagValue PropertySheetFlagValue(int v, const DesignerMetaFlags &mf); PropertySheetFlagValue(); - int value; + int value{0}; DesignerMetaFlags metaFlags; }; diff --git a/src/shared/deviceskin/deviceskin.cpp b/src/shared/deviceskin/deviceskin.cpp index faac28958..380e16360 100644 --- a/src/shared/deviceskin/deviceskin.cpp +++ b/src/shared/deviceskin/deviceskin.cpp @@ -72,12 +72,6 @@ static QString msgImageNotLoaded(const QString &f) { } // ------------ DeviceSkinButtonArea -DeviceSkinButtonArea::DeviceSkinButtonArea() : - keyCode(0), - activeWhenClosed(0) -{ -} - QDebug &operator<<(QDebug &str, const DeviceSkinButtonArea &a) { diff --git a/src/shared/deviceskin/deviceskin.h b/src/shared/deviceskin/deviceskin.h index d0e50bac2..060c306a8 100644 --- a/src/shared/deviceskin/deviceskin.h +++ b/src/shared/deviceskin/deviceskin.h @@ -50,14 +50,13 @@ class QTextStream; // ------- Button Area struct DeviceSkinButtonArea { - DeviceSkinButtonArea(); QString name; - int keyCode; + int keyCode{0}; QPolygon area; QString text; - bool activeWhenClosed; - bool toggleArea; - bool toggleActiveArea; + bool activeWhenClosed{false}; + bool toggleArea{false}; + bool toggleActiveArea{false}; }; // -------- Parameters diff --git a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp index a6b84048d..ccd995a62 100644 --- a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp +++ b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp @@ -62,17 +62,15 @@ public: struct WidgetItem { - WidgetItem() : widget(0), label(0), widgetLabel(0), - button(0), container(0), layout(0), /*line(0), */parent(0), expanded(false) { } - QWidget *widget; // can be null - QLabel *label; // main label with property name - QLabel *widgetLabel; // label substitute showing the current value if there is no widget - QToolButton *button; // expandable button for items with children - QWidget *container; // container which is expanded when the button is clicked - QGridLayout *layout; // layout in container - WidgetItem *parent; + QWidget *widget{nullptr}; // can be null + QLabel *label{nullptr}; // main label with property name + QLabel *widgetLabel{nullptr}; // label substitute showing the current value if there is no widget + QToolButton *button{nullptr}; // expandable button for items with children + QWidget *container{nullptr}; // container which is expanded when the button is clicked + QGridLayout *layout{nullptr}; // layout in container + WidgetItem *parent{nullptr}; QList<WidgetItem *> children; - bool expanded; + bool expanded{false}; }; private: void updateLater(); diff --git a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp index ec0a61712..19bc1ce98 100644 --- a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp +++ b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp @@ -60,15 +60,13 @@ public: struct WidgetItem { - WidgetItem() : widget(0), label(0), widgetLabel(0), - groupBox(0), layout(0), line(0), parent(0) { } - QWidget *widget; // can be null - QLabel *label; - QLabel *widgetLabel; - QGroupBox *groupBox; - QGridLayout *layout; - QFrame *line; - WidgetItem *parent; + QWidget *widget{nullptr}; // can be null + QLabel *label{nullptr}; + QLabel *widgetLabel{nullptr}; + QGroupBox *groupBox{nullptr}; + QGridLayout *layout{nullptr}; + QFrame *line{nullptr}; + WidgetItem *parent{nullptr}; QList<WidgetItem *> children; }; private: diff --git a/src/shared/qtpropertybrowser/qtpropertymanager.cpp b/src/shared/qtpropertybrowser/qtpropertymanager.cpp index 4f435f4df..6f1ce2059 100644 --- a/src/shared/qtpropertybrowser/qtpropertymanager.cpp +++ b/src/shared/qtpropertybrowser/qtpropertymanager.cpp @@ -583,11 +583,10 @@ public: struct Data { - Data() : val(0), minVal(-INT_MAX), maxVal(INT_MAX), singleStep(1) {} - int val; - int minVal; - int maxVal; - int singleStep; + int val{0}; + int minVal{-INT_MAX}; + int maxVal{INT_MAX}; + int singleStep{1}; int minimumValue() const { return minVal; } int maximumValue() const { return maxVal; } void setMinimumValue(int newMinVal) { setSimpleMinimumData(this, newMinVal); } @@ -860,12 +859,11 @@ public: struct Data { - Data() : val(0), minVal(-DBL_MAX), maxVal(DBL_MAX), singleStep(1), decimals(2) {} - double val; - double minVal; - double maxVal; - double singleStep; - int decimals; + double val{0}; + double minVal{-DBL_MAX}; + double maxVal{DBL_MAX}; + double singleStep{1}; + int decimals{2}; double minimumValue() const { return minVal; } double maximumValue() const { return maxVal; } void setMinimumValue(double newMinVal) { setSimpleMinimumData(this, newMinVal); } @@ -1543,11 +1541,9 @@ public: struct Data { - Data() : val(QDate::currentDate()), minVal(QDate(1752, 9, 14)), - maxVal(QDate(7999, 12, 31)) {} - QDate val; - QDate minVal; - QDate maxVal; + QDate val{QDate::currentDate()}; + QDate minVal{QDate(1752, 9, 14)}; + QDate maxVal{QDate(7999, 12, 31)}; QDate minimumValue() const { return minVal; } QDate maximumValue() const { return maxVal; } void setMinimumValue(const QDate &newMinVal) { setSimpleMinimumData(this, newMinVal); } @@ -2706,9 +2702,8 @@ public: struct Data { - Data() : decimals(2) {} QPointF val; - int decimals; + int decimals{2}; }; void slotDoubleChanged(QtProperty *property, double value); @@ -2989,10 +2984,9 @@ public: struct Data { - Data() : val(QSize(0, 0)), minVal(QSize(0, 0)), maxVal(QSize(INT_MAX, INT_MAX)) {} - QSize val; - QSize minVal; - QSize maxVal; + QSize val{0, 0}; + QSize minVal{0, 0}; + QSize maxVal{INT_MAX, INT_MAX}; QSize minimumValue() const { return minVal; } QSize maximumValue() const { return maxVal; } void setMinimumValue(const QSize &newMinVal) { setSizeMinimumData(this, newMinVal); } @@ -3334,11 +3328,10 @@ public: struct Data { - Data() : val(QSizeF(0, 0)), minVal(QSizeF(0, 0)), maxVal(QSizeF(INT_MAX, INT_MAX)), decimals(2) {} - QSizeF val; - QSizeF minVal; - QSizeF maxVal; - int decimals; + QSizeF val{0, 0}; + QSizeF minVal{0, 0}; + QSizeF maxVal{INT_MAX, INT_MAX}; + int decimals{2}; QSizeF minimumValue() const { return minVal; } QSizeF maximumValue() const { return maxVal; } void setMinimumValue(const QSizeF &newMinVal) { setSizeMinimumData(this, newMinVal); } @@ -3733,8 +3726,7 @@ public: struct Data { - Data() : val(0, 0, 0, 0) {} - QRect val; + QRect val{0, 0, 0, 0}; QRect constraint; }; @@ -4142,10 +4134,9 @@ public: struct Data { - Data() : val(0, 0, 0, 0), decimals(2) {} - QRectF val; + QRectF val{0, 0, 0, 0}; QRectF constraint; - int decimals; + int decimals{2}; }; typedef QMap<const QtProperty *, Data> PropertyValueMap; @@ -4609,8 +4600,7 @@ public: struct Data { - Data() : val(-1) {} - int val; + int val{-1}; QStringList enumNames; QMap<int, QIcon> enumIcons; }; @@ -4882,8 +4872,7 @@ public: struct Data { - Data() : val(-1) {} - int val; + int val{-1}; QStringList flagNames; }; diff --git a/src/shared/qttoolbardialog/qttoolbardialog.cpp b/src/shared/qttoolbardialog/qttoolbardialog.cpp index 9b3a07cf6..b86743ec6 100644 --- a/src/shared/qttoolbardialog/qttoolbardialog.cpp +++ b/src/shared/qttoolbardialog/qttoolbardialog.cpp @@ -139,8 +139,6 @@ public: QToolBar *toolBarByName(const QString &toolBarName) const; - QtFullToolBarManagerPrivate(); - QMap<QString, QList<QAction *> > categoryToActions; QMap<QAction *, QString> actionToCategory; @@ -154,17 +152,9 @@ public: QMap<QToolBar *, QList<QAction *> > defaultToolBars; QList<QToolBar *> customToolBars; - QMainWindow *theMainWindow; + QMainWindow *theMainWindow{nullptr}; }; - - - -QtFullToolBarManagerPrivate::QtFullToolBarManagerPrivate() - : theMainWindow(0) -{ -} - QToolBar *QtFullToolBarManagerPrivate::toolBarWidgetAction(QAction *action) const { if (widgetActions.contains(action)) |