Skip to content

Commit

Permalink
Fixed editing poly relations
Browse files Browse the repository at this point in the history
  • Loading branch information
suricactus committed Jan 18, 2021
1 parent 6dc92b5 commit 439e290
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/app/qgsrelationmanagerdialog.cpp
Expand Up @@ -280,7 +280,8 @@ void QgsRelationManagerDialog::mActionEditPolymorphicRelation_triggered()
if ( rows.size() != 1 )
return;

addDlg.setPolymorphicRelation( mRelationsTree->topLevelItem( rows[0].row() )->data( 0, Qt::UserRole ).value<QgsPolymorphicRelation>() );
const QgsPolymorphicRelation polyRel = mRelationsTree->topLevelItem( rows[0].row() )->data( 0, Qt::UserRole ).value<QgsPolymorphicRelation>();
addDlg.setPolymorphicRelation( polyRel );

if ( addDlg.exec() )
{
Expand All @@ -302,6 +303,19 @@ void QgsRelationManagerDialog::mActionEditPolymorphicRelation_triggered()
else
relation.setId( relationId );

for ( int i = 0, l = mRelationsTree->topLevelItemCount(); i < l; i++ )
{
mRelationsTree->topLevelItem( i )->data( 0, Qt::UserRole );
QgsPolymorphicRelation currentPolyRel = mRelationsTree->topLevelItem( i )->data( 0, Qt::UserRole ).value<QgsPolymorphicRelation>();

if ( currentPolyRel.id() == polyRel.id() )
{
// we safely assume that polymorphic relations are always a top level item
mRelationsTree->takeTopLevelItem( i );
break;
}
}

addPolymorphicRelation( relation );
}
}
Expand Down

0 comments on commit 439e290

Please sign in to comment.