Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
simplify code
  • Loading branch information
3nids committed May 22, 2023
1 parent ef50800 commit 73df7e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
26 changes: 7 additions & 19 deletions src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -176,7 +176,7 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
mTableWidget->setColumnCount( col + 1 );
mFieldToColumnMap[ mFields.at( idx ).name() ] = col;

QComboBox *cb = createMergeComboBox( mFields.at( idx ).type() );
QComboBox *cb = createMergeComboBox( mFields.at( idx ).type(), col );
if ( ! mVectorLayer->dataProvider()->pkAttributeIndexes().contains( mFields.fieldOriginIndex( idx ) ) &&
mFields.at( idx ).constraints().constraints() & QgsFieldConstraints::ConstraintUnique )
{
Expand Down Expand Up @@ -266,7 +266,7 @@ void QgsMergeAttributesDialog::createTableWidgetContents()

}

QComboBox *QgsMergeAttributesDialog::createMergeComboBox( QVariant::Type columnType ) const
QComboBox *QgsMergeAttributesDialog::createMergeComboBox( QVariant::Type columnType, int column )
{
QComboBox *newComboBox = new QComboBox();
//add items for feature
Expand Down Expand Up @@ -300,8 +300,11 @@ QComboBox *QgsMergeAttributesDialog::createMergeComboBox( QVariant::Type columnT
newComboBox->addItem( tr( "Skip Attribute" ), QStringLiteral( "skip" ) );
newComboBox->addItem( tr( "Manual Value" ), QStringLiteral( "manual" ) );

connect( newComboBox, &QComboBox::currentTextChanged,
this, &QgsMergeAttributesDialog::comboValueChanged );
connect( newComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]( int index )
{
refreshMergedValue( column );
} );

return newComboBox;
}

Expand All @@ -317,21 +320,6 @@ int QgsMergeAttributesDialog::findComboColumn( QComboBox *c ) const
return -1;
}

void QgsMergeAttributesDialog::comboValueChanged( const QString &text )
{
Q_UNUSED( text )
QComboBox *senderComboBox = qobject_cast<QComboBox *>( sender() );
if ( !senderComboBox )
{
return;
}
int column = findComboColumn( senderComboBox );
if ( column < 0 )
return;

refreshMergedValue( column );
}

void QgsMergeAttributesDialog::selectedRowChanged()
{
//find out selected row
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgsmergeattributesdialog.h
Expand Up @@ -75,7 +75,6 @@ class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeA
void setAllToSkip();

private slots:
void comboValueChanged( const QString &text );
void selectedRowChanged();
void mFromSelectedPushButton_clicked();
void mFromLargestPushButton_clicked();
Expand All @@ -88,7 +87,7 @@ class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeA
void setAttributeTableConfig( const QgsAttributeTableConfig &config );

//! Create new combo box with the options for featureXX / mean / min / max
QComboBox *createMergeComboBox( QVariant::Type columnType ) const;
QComboBox *createMergeComboBox( QVariant::Type columnType, int column );

/**
* Returns the table widget column index of a combo box
Expand Down

0 comments on commit 73df7e5

Please sign in to comment.