Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 61b4be8

Browse files
domi4484github-actions[bot]
authored andcommittedApr 21, 2023
Fix merge dialog using default clause instead of feature id
1 parent ac95195 commit 61b4be8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎src/app/qgsmergeattributesdialog.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,13 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
233233
{
234234
int idx = mTableWidget->horizontalHeaderItem( j )->data( FieldIndex ).toInt();
235235
bool setToManual = false;
236-
if ( !mVectorLayer->dataProvider()->defaultValueClause( idx ).isEmpty() )
236+
237+
// For the Id use the target feature
238+
if ( j == 0 )
239+
{
240+
mTableWidget->item( mTableWidget->rowCount() - 1, j )->setData( Qt::DisplayRole, mTargetFeatureId );
241+
}
242+
else if ( !mVectorLayer->dataProvider()->defaultValueClause( idx ).isEmpty() )
237243
{
238244
mTableWidget->item( mTableWidget->rowCount() - 1, j )->setData( Qt::DisplayRole, mVectorLayer->dataProvider()->defaultValueClause( idx ) );
239245
setToManual = true;

‎tests/src/app/testqgsmergeattributesdialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ class TestQgsMergeattributesDialog : public QObject
8686

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

9091
// Check after taking feature with largest geometry
9192
QVERIFY( QMetaObject::invokeMethod( &dialog, "mFromLargestPushButton_clicked" ) );
9293
QCOMPARE( dialog.targetFeatureId(), f2.id() );
94+
QCOMPARE( dialog.mergedAttributes().first(), f2.id() );
9395
}
9496
};
9597

0 commit comments

Comments
 (0)
Please sign in to comment.