Skip to content

Commit

Permalink
Fix N:M Relations
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 15, 2017
1 parent 5bd164b commit a081905
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/app/qgsfieldsproperties.cpp
Expand Up @@ -397,9 +397,9 @@ void QgsFieldsProperties::loadRelations()
if ( nmrel.fieldPairs().at( 0 ).referencingField() != relation.fieldPairs().at( 0 ).referencingField() )
nmCombo->addItem( QStringLiteral( "%1 (%2)" ).arg( nmrel.referencedLayer()->name(), nmrel.fieldPairs().at( 0 ).referencedField() ), nmrel.id() );

const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( mLayer, relation.id() );
const QgsEditFormConfig editFormConfig = mLayer->editFormConfig();

const QVariant nmrelcfg = setup.config().value( QStringLiteral( "nm-rel" ) );
const QVariant nmrelcfg = editFormConfig.widgetConfig( relation.id() ).value( QStringLiteral( "nm-rel" ) );

int idx = nmCombo->findData( nmrelcfg.toString() );

Expand Down
6 changes: 2 additions & 4 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -1594,8 +1594,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
const QgsAttributeEditorRelation *relDef = static_cast<const QgsAttributeEditorRelation *>( widgetDef );

QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper( mLayer, relDef->relation(), nullptr, this );
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, relDef->relation().id() );
rww->setConfig( widgetSetup.config() );
rww->setConfig( mLayer->editFormConfig().widgetConfig( relDef->relation().id() ) );
rww->setContext( context );
newWidgetInfo.widget = rww->widget();
rww->setShowLabel( relDef->showLabel() );
Expand Down Expand Up @@ -1757,8 +1756,7 @@ void QgsAttributeForm::createWrappers()
if ( relation.isValid() )
{
QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper( mLayer, relation, myWidget, this );
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, relation.id() );
rww->setConfig( widgetSetup.config() );
rww->setConfig( mLayer->editFormConfig().widgetConfig( relation.id() ) );
rww->setContext( mContext );
rww->widget(); // Will initialize the widget
mWidgets.append( rww );
Expand Down

0 comments on commit a081905

Please sign in to comment.