Make wxQtSpinBoxBase-derived valueChanged() methods inline

It seems better to have them in the class itself, near the connect()
call binding them.

This also resolves an inconsistency between wxQtSpinBox::valueChanged(),
which was defined elsewhere in the source file, and the same method of
wxQtDoubleSpinBox, which was defined directly after the class
declaration.

See https://github.com/wxWidgets/wxWidgets/pull/1168
This commit is contained in:
Vadim Zeitlin
2019-01-23 16:45:21 +01:00
parent adee46d155
commit 6b3a0cc460

View File

@@ -154,7 +154,16 @@ public:
this, &wxQtSpinBox::valueChanged); this, &wxQtSpinBox::valueChanged);
} }
private: private:
void valueChanged(int value); void valueChanged(int value)
{
wxControl *handler = GetHandler();
if ( handler )
{
wxSpinEvent event( wxEVT_SPINCTRL, handler->GetId() );
event.SetInt( value );
EmitEvent( event );
}
}
}; };
class wxQtDoubleSpinBox : public wxQtSpinBoxBase< QDoubleSpinBox > class wxQtDoubleSpinBox : public wxQtSpinBoxBase< QDoubleSpinBox >
@@ -167,19 +176,17 @@ public:
this, &wxQtDoubleSpinBox::valueChanged); this, &wxQtDoubleSpinBox::valueChanged);
} }
private: private:
void valueChanged(double value); void valueChanged(double value)
};
void wxQtDoubleSpinBox::valueChanged(double value)
{
wxControl *handler = GetHandler();
if ( handler )
{ {
wxSpinDoubleEvent event( wxEVT_SPINCTRLDOUBLE, handler->GetId() ); wxControl *handler = GetHandler();
event.SetValue(value); if ( handler )
EmitEvent( event ); {
wxSpinDoubleEvent event( wxEVT_SPINCTRLDOUBLE, handler->GetId() );
event.SetValue(value);
EmitEvent( event );
}
} }
} };
//############################################################################## //##############################################################################
@@ -236,17 +243,6 @@ void wxSpinCtrl::SetValue( const wxString &value )
qtSpinBox->setValue( qtSpinBox->valueFromText( wxQtConvertString( value ))); qtSpinBox->setValue( qtSpinBox->valueFromText( wxQtConvertString( value )));
} }
void wxQtSpinBox::valueChanged(int value)
{
wxControl *handler = GetHandler();
if ( handler )
{
wxSpinEvent event( wxEVT_SPINCTRL, handler->GetId() );
event.SetInt( value );
EmitEvent( event );
}
}
//############################################################################## //##############################################################################
template class wxSpinCtrlQt< double, QDoubleSpinBox >; template class wxSpinCtrlQt< double, QDoubleSpinBox >;