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 committed Nov 14, 2017
1 parent a49ed09 commit b02133f89c549d01597a07fb48f2c3eb507761a8
Showing with 6 additions and 3 deletions.
  1. +2 −2 src/app/qgsrelationmanagerdialog.cpp
  2. +4 −1 src/gui/editorwidgets/qgsrelationreferenceconfigdlg.cpp
@@ -106,9 +106,9 @@ void QgsRelationManagerDialog::mBtnAddRelation_clicked()
QString relationId = addDlg.relationId();
if ( addDlg.relationId().isEmpty() )
relationId = QStringLiteral( "%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;
@@ -36,7 +36,10 @@ QgsRelationReferenceConfigDlg::QgsRelationReferenceConfigDlg( QgsVectorLayer *vl

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

0 comments on commit b02133f

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