Skip to content
Permalink
Browse files

Use id in gui if name is empty and crop layerid-part in the generated id

The name can be empty, so use the id instead in the combo box. To avoid so long ids, the part taken from the layerid in the relation id is cropped to 10 signs. They are unique anyway because there is used a suffix counting up.
  • Loading branch information
signedav authored and m-kuhn committed Nov 14, 2017
1 parent ea5ed67 commit d4b2895b82d6fd1ba648944ee9b101f67da1ba5d
Showing with 7 additions and 3 deletions.
  1. +2 −2 src/app/qgsrelationmanagerdialog.cpp
  2. +5 −1 src/gui/editorwidgets/qgsrelationreferenceconfigdlg.cpp
@@ -92,9 +92,9 @@ void QgsRelationManagerDialog::on_mBtnAddRelation_clicked()
QString relationId = addDlg.relationId();
if ( addDlg.relationId() == "" )
relationId = QString( "%1_%2_%3_%4" )
.arg( addDlg.referencingLayerId(),
.arg( addDlg.referencingLayerId().left( 10 ),
addDlg.references().at( 0 ).first,
addDlg.referencedLayerId(),
addDlg.referencedLayerId().left( 10 ),
addDlg.references().at( 0 ).second );

QStringList existingNames;
@@ -47,7 +47,11 @@ QgsRelationReferenceConfigDlg::QgsRelationReferenceConfigDlg( QgsVectorLayer* vl

Q_FOREACH ( const QgsRelation& relation, vl->referencingRelations( fieldIdx ) )
{
mComboRelation->addItem( QString( "%1 (%2)" ).arg( relation.name(), relation.referencedLayerId() ), relation.id() );
if ( relation.name().isEmpty() )
mComboRelation->addItem( QString( "%1 (%2)" ).arg( relation.id(), relation.referencedLayerId() ), relation.id() );
else
mComboRelation->addItem( QString( "%1 (%2)" ).arg( relation.name(), relation.referencedLayerId() ), relation.id() );

if ( relation.referencedLayer() )
{
mExpressionWidget->setField( relation.referencedLayer()->displayExpression() );

0 comments on commit d4b2895

Please sign in to comment.
You can’t perform that action at this time.