@@ -88,6 +88,45 @@ void QgsEditFormConfig::onRelationsLoaded()
88
88
}
89
89
}
90
90
91
+ bool QgsEditFormConfig::updateRelationWidgetInTabs ( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config )
92
+ {
93
+ QList<QgsAttributeEditorElement *> children = container->children ();
94
+ for ( QgsAttributeEditorElement *child : children )
95
+ {
96
+ qDebug () << QString ( " it's item named %1 and type %2" ).arg ( child->name () ).arg ( child->type () );
97
+
98
+ if ( child->type () == QgsAttributeEditorElement::AeTypeContainer )
99
+ {
100
+ QgsAttributeEditorContainer *container = dynamic_cast <QgsAttributeEditorContainer *>( child );
101
+ if ( updateRelationWidgetInTabs ( container, widgetName, config ) )
102
+ {
103
+ // return when a relation has been set in a child or child child...
104
+ return true ;
105
+ }
106
+ }
107
+ else if ( child->type () == QgsAttributeEditorElement::AeTypeRelation )
108
+ {
109
+ QgsAttributeEditorRelation *relation = dynamic_cast < QgsAttributeEditorRelation * >( child );
110
+ if ( relation )
111
+ {
112
+ if ( relation->relation ().id () == widgetName )
113
+ {
114
+ if ( config.contains ( QStringLiteral ( " nm-rel" ) ) )
115
+ {
116
+ relation->setNmRelationId ( config[QStringLiteral ( " nm-rel" )] );
117
+ }
118
+ if ( config.contains ( QStringLiteral ( " force-suppress-popup" ) ) )
119
+ {
120
+ relation->setForceSuppressFormPopup ( config[QStringLiteral ( " force-suppress-popup" )].toBool () );
121
+ }
122
+ return true ;
123
+ }
124
+ }
125
+ }
126
+ }
127
+ return false ;
128
+ }
129
+
91
130
bool QgsEditFormConfig::setWidgetConfig ( const QString &widgetName, const QVariantMap &config )
92
131
{
93
132
if ( d->mFields .indexOf ( widgetName ) != -1 )
@@ -96,6 +135,12 @@ bool QgsEditFormConfig::setWidgetConfig( const QString &widgetName, const QVaria
96
135
return false ;
97
136
}
98
137
138
+ if ( config.contains ( QStringLiteral ( " force-suppress-popup" ) ) || config.contains ( QStringLiteral ( " nm-rel" ) ) )
139
+ {
140
+ // set it in the tab for the first relation editor widget
141
+ updateRelationWidgetInTabs ( d->mInvisibleRootContainer , widgetName, config );
142
+ }
143
+
99
144
d.detach ();
100
145
d->mWidgetConfigs [widgetName] = config;
101
146
return true ;
0 commit comments