Skip to content
Permalink
Browse files
Fix slider and dial widgets never emit their valueChanged(QVariant)
signals. Fixes use of dial/slider with multiedit form mode.
  • Loading branch information
nyalldawson committed Apr 29, 2016
1 parent 6c9bc93 commit 25c0624
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
@@ -169,7 +169,7 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
mQgsDial->setSingleStep( step );
}

connect( editor, SIGNAL( valueChanged( QVariant ) ), this, SLOT( valueChanged( QVariant ) ) );
connect( editor, SIGNAL( valueChanged( QVariant ) ), this, SLOT( valueChangedVariant( QVariant ) ) );
}
else if ( mDial )
{
@@ -198,7 +198,7 @@ bool QgsRangeWidgetWrapper::valid() const
return mSlider || mDial || mQgsDial || mQgsSlider || mIntSpinBox || mDoubleSpinBox;
}

void QgsRangeWidgetWrapper::valueChanged( const QVariant& v )
void QgsRangeWidgetWrapper::valueChangedVariant( const QVariant& v )
{
if ( v.type() == QVariant::Int )
valueChanged( v.toInt() );
@@ -55,8 +55,11 @@ class GUI_EXPORT QgsRangeWidgetWrapper : public QgsEditorWidgetWrapper
public slots:
virtual void setValue( const QVariant& value ) override;

public slots:
void valueChanged( const QVariant& );
private slots:

// NOTE - cannot be named "valueChanged", otherwise implicit conversion to QVariant results in
// infinite recursion
void valueChangedVariant( const QVariant& );

private:
QSpinBox* mIntSpinBox;
@@ -113,24 +113,20 @@ void QgsDial::valueChanged( int value )
if ( mMin.isNull() || mMax.isNull() || mStep.isNull() )
{
mValue = QVariant();
return;
}

if ( mMin.type() == QVariant::Int &&
mMax.type() == QVariant::Int &&
mStep.type() == QVariant::Int &&
mValue.type() == QVariant::Int )
else if ( mMin.type() == QVariant::Int &&
mMax.type() == QVariant::Int &&
mStep.type() == QVariant::Int &&
mValue.type() == QVariant::Int )
{
mValue = value;
return;
}

if ( mMin.type() == QVariant::Double &&
mMax.type() == QVariant::Double &&
mStep.type() == QVariant::Double &&
mValue.type() == QVariant::Double )
else if ( mMin.type() == QVariant::Double &&
mMax.type() == QVariant::Double &&
mStep.type() == QVariant::Double &&
mValue.type() == QVariant::Double )
{
mValue = QVariant( mMin.toDouble() + value * mStep.toDouble() );
return;
}
emit valueChanged( mValue );
}
@@ -118,24 +118,21 @@ void QgsSlider::valueChanged( int value )
if ( mMin.isNull() || mMax.isNull() || mStep.isNull() )
{
mValue = QVariant();
return;
}

if ( mMin.type() == QVariant::Int &&
mMax.type() == QVariant::Int &&
mStep.type() == QVariant::Int &&
mValue.type() == QVariant::Int )
else if ( mMin.type() == QVariant::Int &&
mMax.type() == QVariant::Int &&
mStep.type() == QVariant::Int &&
mValue.type() == QVariant::Int )
{
mValue = value;
return;
}

if ( mMin.type() == QVariant::Double &&
mMax.type() == QVariant::Double &&
mStep.type() == QVariant::Double &&
mValue.type() == QVariant::Double )
else if ( mMin.type() == QVariant::Double &&
mMax.type() == QVariant::Double &&
mStep.type() == QVariant::Double &&
mValue.type() == QVariant::Double )
{
mValue = QVariant( mMin.toDouble() + value * mStep.toDouble() );
return;
}

emit valueChanged( mValue );
}

0 comments on commit 25c0624

Please sign in to comment.