Skip to content

Commit

Permalink
Cleanup misleading QgsEditorWidgetWrapper::valueChanged signals
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 5, 2018
1 parent d5074df commit 46177aa
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 153 deletions.
54 changes: 1 addition & 53 deletions python/gui/editorwidgets/core/qgseditorwidgetwrapper.sip
Original file line number Diff line number Diff line change
Expand Up @@ -258,59 +258,7 @@ to reflect the new value.
:param value: The new value of the attribute
%End

void valueChanged( const QString &value );
%Docstring
If you emit to this slot in your implementation, an appropriate change notification
will be broadcasted. Helper for string type widgets.

:param value: The value
%End

void valueChanged( int value ) /PyName=valueChangedInt/;
%Docstring
If you emit to this slot in your implementation, an appropriate change notification
will be broadcasted. Helper for int type widgets.

:param value: The value

.. note::

Python name valueChangedInt
%End

void valueChanged( double value ) /PyName=valueChangedDouble/;
%Docstring
If you emit to this slot in your implementation, an appropriate change notification
will be broadcasted. Helper for double type widgets.

:param value: The value

.. note::

Python name valueChangedDouble
%End

void valueChanged( bool value ) /PyName=valueChangedBool/;
%Docstring
If you emit to this slot in your implementation, an appropriate change notification
will be broadcasted. Helper for bool type widgets.

:param value: The value

.. note::

Python name valueChangedBool
%End

void valueChanged( qlonglong value );
%Docstring
If you emit to this slot in your implementation, an appropriate change notification
will be broadcasted. Helper for longlong type widgets.

:param value: The value
%End

void valueChanged();
void emitValueChanged();
%Docstring
Will call the value() method to determine the emitted value
%End
Expand Down
27 changes: 1 addition & 26 deletions src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,7 @@ void QgsEditorWidgetWrapper::setFeature( const QgsFeature &feature )
setValue( feature.attribute( mFieldIdx ) );
}

void QgsEditorWidgetWrapper::valueChanged( const QString &value )
{
emit valueChanged( QVariant( value ) );
}

void QgsEditorWidgetWrapper::valueChanged( int value )
{
emit valueChanged( QVariant( value ) );
}

void QgsEditorWidgetWrapper::valueChanged( double value )
{
emit valueChanged( QVariant( value ) );
}

void QgsEditorWidgetWrapper::valueChanged( bool value )
{
emit valueChanged( QVariant( value ) );
}

void QgsEditorWidgetWrapper::valueChanged( qlonglong value )
{
emit valueChanged( QVariant( value ) );
}

void QgsEditorWidgetWrapper::valueChanged()
void QgsEditorWidgetWrapper::emitValueChanged()
{
emit valueChanged( value() );
}
Expand Down
57 changes: 1 addition & 56 deletions src/gui/editorwidgets/core/qgseditorwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,65 +256,10 @@ class GUI_EXPORT QgsEditorWidgetWrapper : public QgsWidgetWrapper
*/
virtual void setValue( const QVariant &value ) = 0;

/**
* If you emit to this slot in your implementation, an appropriate change notification
* will be broadcasted. Helper for string type widgets.
*
* \param value The value
*/
void valueChanged( const QString &value );

/**
* If you emit to this slot in your implementation, an appropriate change notification
* will be broadcasted. Helper for int type widgets.
*
* \param value The value
* \note Python name valueChangedInt
*/
#ifndef SIP_RUN
void valueChanged( int value );
#else
void valueChanged( int value ) SIP_PYNAME( valueChangedInt );
#endif

/**
* If you emit to this slot in your implementation, an appropriate change notification
* will be broadcasted. Helper for double type widgets.
*
* \param value The value
* \note Python name valueChangedDouble
*/
#ifndef SIP_RUN
void valueChanged( double value );
#else
void valueChanged( double value ) SIP_PYNAME( valueChangedDouble );
#endif

/**
* If you emit to this slot in your implementation, an appropriate change notification
* will be broadcasted. Helper for bool type widgets.
*
* \param value The value
* \note Python name valueChangedBool
*/
#ifndef SIP_RUN
void valueChanged( bool value );
#else
void valueChanged( bool value ) SIP_PYNAME( valueChangedBool );
#endif

/**
* If you emit to this slot in your implementation, an appropriate change notification
* will be broadcasted. Helper for longlong type widgets.
*
* \param value The value
*/
void valueChanged( qlonglong value );

/**
* Will call the value() method to determine the emitted value
*/
void valueChanged();
void emitValueChanged();

protected:

Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgscheckboxwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ void QgsCheckboxWidgetWrapper::initWidget( QWidget *editor )
mGroupBox = qobject_cast<QGroupBox *>( editor );

if ( mCheckBox )
connect( mCheckBox, &QAbstractButton::toggled, this, static_cast<void ( QgsEditorWidgetWrapper::* )( bool )>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mCheckBox, &QAbstractButton::toggled, this, [ = ]( bool state ) { emit valueChanged( state ); } );
if ( mGroupBox )
connect( mGroupBox, &QGroupBox::toggled, this, static_cast<void ( QgsEditorWidgetWrapper::* )( bool )>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mGroupBox, &QGroupBox::toggled, this, [ = ]( bool state ) { emit valueChanged( state ); } );
}

bool QgsCheckboxWidgetWrapper::valid() const
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsclassificationwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void QgsClassificationWidgetWrapper::initWidget( QWidget *editor )
}

connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgscolorwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void QgsColorWidgetWrapper::initWidget( QWidget *editor )
}

mColorButton->setShowNull( true );
connect( mColorButton, &QgsColorButton::colorChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mColorButton, &QgsColorButton::colorChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
}

bool QgsColorWidgetWrapper::valid() const
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsenumerationwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void QgsEnumerationWidgetWrapper::initWidget( QWidget *editor )
mComboBox->addItem( s, s );
}
connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void QgsExternalResourceWidgetWrapper::initWidget( QWidget *editor )
}

if ( mLineEdit )
connect( mLineEdit, &QLineEdit::textChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )( const QString & )>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & value ) { emit valueChanged( value ); } );

}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsrangewidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void QgsRangeWidgetWrapper::initWidget( QWidget *editor )
mDoubleSpinBox->setSuffix( config( QStringLiteral( "Suffix" ) ).toString() );

connect( mDoubleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ),
this, static_cast < void ( QgsEditorWidgetWrapper::* )( double ) > ( &QgsEditorWidgetWrapper::valueChanged ) );
this, [ = ]( double value ) { emit valueChanged( value ); } );
}
else if ( mIntSpinBox )
{
Expand Down
6 changes: 3 additions & 3 deletions src/gui/editorwidgets/qgstexteditwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ void QgsTextEditWrapper::initWidget( QWidget *editor )
mLineEdit = qobject_cast<QLineEdit *>( editor );

if ( mTextEdit )
connect( mTextEdit, &QTextEdit::textChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mTextEdit, &QTextEdit::textChanged, this, &QgsEditorWidgetWrapper::emitValueChanged );

if ( mPlainTextEdit )
connect( mPlainTextEdit, &QPlainTextEdit::textChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mPlainTextEdit, &QPlainTextEdit::textChanged, this, &QgsEditorWidgetWrapper::emitValueChanged );

if ( mLineEdit )
{
Expand All @@ -131,7 +131,7 @@ void QgsTextEditWrapper::initWidget( QWidget *editor )
fle->setNullValue( defVal.toString() );
}

connect( mLineEdit, &QLineEdit::textChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )( const QString & )>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & value ) { emit valueChanged( value ); } );
connect( mLineEdit, &QLineEdit::textChanged, this, &QgsTextEditWrapper::textChanged );

mWritablePalette = mLineEdit->palette();
Expand Down
5 changes: 2 additions & 3 deletions src/gui/editorwidgets/qgsuniquevaluewidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,13 @@ void QgsUniqueValuesWidgetWrapper::initWidget( QWidget *editor )
c->setCompletionMode( QCompleter::PopupCompletion );
mLineEdit->setCompleter( c );

connect( mLineEdit, &QLineEdit::textChanged, this,
static_cast<void ( QgsEditorWidgetWrapper::* )( const QString & )>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & value ) { emit valueChanged( value ); } );
}

if ( mComboBox )
{
connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsuuidwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void QgsUuidWidgetWrapper::setValue( const QVariant &value )
if ( mLabel )
mLabel->setText( QUuid::createUuid().toString() );

valueChanged();
emitValueChanged();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsvaluemapwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void QgsValueMapWidgetWrapper::initWidget( QWidget *editor )
++it;
}
connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void QgsValueRelationWidgetWrapper::initWidget( QWidget *editor )
}

connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
}
else if ( mListWidget )
{
Expand All @@ -122,7 +122,7 @@ void QgsValueRelationWidgetWrapper::initWidget( QWidget *editor )

mListWidget->addItem( item );
}
connect( mListWidget, &QListWidget::itemChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mListWidget, &QListWidget::itemChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
}
else if ( mLineEdit )
{
Expand All @@ -138,7 +138,7 @@ void QgsValueRelationWidgetWrapper::initWidget( QWidget *editor )
completer->setCaseSensitivity( Qt::CaseInsensitive );
mLineEdit->setCompleter( completer );

connect( mLineEdit, &QLineEdit::textChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::valueChanged ) );
connect( mLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & value ) { emit valueChanged( value ); } );
}
}

Expand Down

0 comments on commit 46177aa

Please sign in to comment.