From 8381730f6b3c0160ab8322b0432bb36effad0de2 Mon Sep 17 00:00:00 2001 From: Daniel Knittl-Frank Date: Sun, 27 Oct 2019 13:18:00 +0100 Subject: [PATCH] Replace initializer list macros with delegating constructors --- include/LcdWidget.h | 2 +- src/gui/widgets/Knob.cpp | 29 +++++++++++------------------ src/gui/widgets/LcdWidget.cpp | 22 ++++++---------------- src/gui/widgets/LedCheckbox.cpp | 11 ++--------- 4 files changed, 20 insertions(+), 44 deletions(-) diff --git a/include/LcdWidget.h b/include/LcdWidget.h index 89bafd1d169..cf8a7f94654 100644 --- a/include/LcdWidget.h +++ b/include/LcdWidget.h @@ -100,7 +100,7 @@ public slots: int m_numDigits; int m_marginWidth; - void initUi( const QString& name, const QString &style = QString("19green") ); //!< to be called by ctors + void initUi( const QString& name, const QString &style ); //!< to be called by ctors } ; diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 72c6c7f8bac..7b603844951 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -53,35 +53,28 @@ TextFloat * Knob::s_textFloat = NULL; -//! @todo: in C++11, we can use delegating ctors -#define DEFAULT_KNOB_INITIALIZER_LIST \ - QWidget( _parent ), \ - FloatModelView( new FloatModel( 0, 0, 0, 1, NULL, _name, true ), this ), \ - m_label( "" ), \ - m_knobPixmap( NULL ), \ - m_volumeKnob( false ), \ - m_volumeRatio( 100.0, 0.0, 1000000.0 ), \ - m_buttonPressed( false ), \ - m_angle( -10 ), \ - m_lineWidth( 0 ), \ - m_textColor( 255, 255, 255 ) Knob::Knob( knobTypes _knob_num, QWidget * _parent, const QString & _name ) : - DEFAULT_KNOB_INITIALIZER_LIST, + QWidget( _parent ), + FloatModelView( new FloatModel( 0, 0, 0, 1, NULL, _name, true ), this ), + m_label( "" ), + m_knobPixmap( NULL ), + m_volumeKnob( false ), + m_volumeRatio( 100.0, 0.0, 1000000.0 ), + m_buttonPressed( false ), + m_angle( -10 ), + m_lineWidth( 0 ), + m_textColor( 255, 255, 255 ), m_knobNum( _knob_num ) { initUi( _name ); } Knob::Knob( QWidget * _parent, const QString & _name ) : - DEFAULT_KNOB_INITIALIZER_LIST, - m_knobNum( knobBright_26 ) + Knob( knobBright_26, _parent, _name ) { - initUi( _name ); } -#undef DEFAULT_KNOB_INITIALIZER_LIST - diff --git a/src/gui/widgets/LcdWidget.cpp b/src/gui/widgets/LcdWidget.cpp index 2b85a64ede8..e34e1eb47b3 100644 --- a/src/gui/widgets/LcdWidget.cpp +++ b/src/gui/widgets/LcdWidget.cpp @@ -39,42 +39,32 @@ -//! @todo: in C++11, we can use delegating ctors -#define DEFAULT_LCDWIDGET_INITIALIZER_LIST \ - QWidget( parent ), \ - m_label(), \ - m_textColor( 255, 255, 255 ), \ - m_textShadowColor( 64, 64, 64 ) - LcdWidget::LcdWidget( QWidget* parent, const QString& name ) : - DEFAULT_LCDWIDGET_INITIALIZER_LIST, - m_numDigits( 1 ) + LcdWidget( 1, parent, name ) { - initUi( name ); } LcdWidget::LcdWidget( int numDigits, QWidget* parent, const QString& name ) : - DEFAULT_LCDWIDGET_INITIALIZER_LIST, - m_numDigits( numDigits ) + LcdWidget( numDigits, QString("19green"), parent, name ) { - initUi( name ); } LcdWidget::LcdWidget( int numDigits, const QString& style, QWidget* parent, const QString& name ) : - DEFAULT_LCDWIDGET_INITIALIZER_LIST, + QWidget( parent ), + m_label(), + m_textColor( 255, 255, 255 ), + m_textShadowColor( 64, 64, 64 ), m_numDigits( numDigits ) { initUi( name, style ); } -#undef DEFAULT_LCDWIDGET_INITIALIZER_LIST - diff --git a/src/gui/widgets/LedCheckbox.cpp b/src/gui/widgets/LedCheckbox.cpp index f69ec6719fd..bdb537744f7 100644 --- a/src/gui/widgets/LedCheckbox.cpp +++ b/src/gui/widgets/LedCheckbox.cpp @@ -39,13 +39,9 @@ static const QString names[LedCheckBox::NumColors] = -//! @todo: in C++11, we can use delegating ctors -#define DEFAULT_LEDCHECKBOX_INITIALIZER_LIST \ - AutomatableButton( _parent, _name ) - LedCheckBox::LedCheckBox( const QString & _text, QWidget * _parent, const QString & _name, LedColors _color ) : - DEFAULT_LEDCHECKBOX_INITIALIZER_LIST, + AutomatableButton( _parent, _name ), m_text( _text ) { initUi( _color ); @@ -56,13 +52,10 @@ LedCheckBox::LedCheckBox( const QString & _text, QWidget * _parent, LedCheckBox::LedCheckBox( QWidget * _parent, const QString & _name, LedColors _color ) : - DEFAULT_LEDCHECKBOX_INITIALIZER_LIST + LedCheckBox( QString(), _parent, _name, _color ) { - initUi( _color ); } -#undef DEFAULT_LEDCHECKBOX_INITIALIZER_LIST - LedCheckBox::~LedCheckBox()