Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix merge dialog using default clause instead of feature id
  • Loading branch information
domi4484 authored and nyalldawson committed Apr 22, 2023
1 parent bc56794 commit 6dda007
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -233,7 +233,13 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
{
int idx = mTableWidget->horizontalHeaderItem( j )->data( FieldIndex ).toInt();
bool setToManual = false;
if ( !mVectorLayer->dataProvider()->defaultValueClause( idx ).isEmpty() )

// For the Id use the target feature
if ( j == 0 )
{
mTableWidget->item( mTableWidget->rowCount() - 1, j )->setData( Qt::DisplayRole, mTargetFeatureId );
}
else if ( !mVectorLayer->dataProvider()->defaultValueClause( idx ).isEmpty() )
{
mTableWidget->item( mTableWidget->rowCount() - 1, j )->setData( Qt::DisplayRole, mVectorLayer->dataProvider()->defaultValueClause( idx ) );
setToManual = true;
Expand Down
2 changes: 2 additions & 0 deletions tests/src/app/testqgsmergeattributesdialog.cpp
Expand Up @@ -86,10 +86,12 @@ class TestQgsMergeattributesDialog : public QObject

// At beginnning the first feature of the list is the target
QCOMPARE( dialog.targetFeatureId(), f1.id() );
QCOMPARE( dialog.mergedAttributes().first(), f1.id() );

// Check after taking feature with largest geometry
QVERIFY( QMetaObject::invokeMethod( &dialog, "mFromLargestPushButton_clicked" ) );
QCOMPARE( dialog.targetFeatureId(), f2.id() );
QCOMPARE( dialog.mergedAttributes().first(), f2.id() );
}
};

Expand Down

0 comments on commit 6dda007

Please sign in to comment.