Skip to content

Commit 4160097

Browse files
committed
Pass configuration to relation widget
1 parent 8246d96 commit 4160097

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/gui/qgsattributeform.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,8 @@ void QgsAttributeForm::init()
528528
Q_FOREACH ( const QgsRelation& rel, QgsProject::instance()->relationManager()->referencedRelations( mLayer ) )
529529
{
530530
QgsRelationWidgetWrapper* rww = new QgsRelationWidgetWrapper( mLayer, rel, 0, this );
531+
QgsEditorWidgetConfig cfg = mLayer->editFormConfig()->widgetConfig( rel.id() );
532+
rww->setConfig( cfg );
531533
rww->setContext( mContext );
532534
gridLayout->addWidget( rww->widget(), row++, 0, 1, 2 );
533535
mWidgets.append( rww );
@@ -717,6 +719,8 @@ QWidget* QgsAttributeForm::createWidgetFromDef( const QgsAttributeEditorElement
717719
const QgsAttributeEditorRelation* relDef = dynamic_cast<const QgsAttributeEditorRelation*>( widgetDef );
718720

719721
QgsRelationWidgetWrapper* rww = new QgsRelationWidgetWrapper( mLayer, relDef->relation(), 0, this );
722+
QgsEditorWidgetConfig cfg = mLayer->editFormConfig()->widgetConfig( relDef->relation().id() );
723+
rww->setConfig( cfg );
720724
rww->setContext( context );
721725
newWidget = rww->widget();
722726
mWidgets.append( rww );
@@ -839,7 +843,7 @@ void QgsAttributeForm::createWrappers()
839843
if ( relation.isValid() )
840844
{
841845
QgsRelationWidgetWrapper* rww = new QgsRelationWidgetWrapper( mLayer, relation, myWidget, this );
842-
rww->setConfig( QgsEditorWidgetConfig() );
846+
rww->setConfig( mLayer->editFormConfig()->widgetConfig( relation.id() ) );
843847
rww->setContext( mContext );
844848
rww->widget(); // Will initialize the widget
845849
mWidgets.append( rww );

src/gui/qgsrelationeditorwidget.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ void QgsRelationEditorWidget::setQgisRelation( const QString& qgisRelationId )
187187
loadState();
188188
}
189189

190+
void QgsRelationEditorWidget::setQgisNmRelation( const QString& qgisRelationId )
191+
{
192+
mNmRelationId = qgisRelationId;
193+
194+
loadState();
195+
}
196+
190197
void QgsRelationEditorWidget::referencingLayerEditingToggled()
191198
{
192199
bool editable = false;

src/gui/qgsrelationeditorwidget.h

+12-1
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,21 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsCollapsibleGroupBox
4545

4646
//! Define the view mode for the dual view
4747
void setViewMode( QgsDualView::ViewMode mode );
48+
49+
//! Get the view mode for the dual view
4850
QgsDualView::ViewMode viewMode() {return mViewMode;}
4951

5052
//! Defines the relation ID (from project relations)
5153
//! @note use a widget's property to keep compatibility with using basic widget instead of QgsRelationEditorWidget
5254
void setQgisRelation( const QString& qgisRelationId );
53-
QString qgisRelation() { return mRelationId; } //property( "qgisRelation" ).toString()
55+
56+
//! Get the relation ID (from project relations)
57+
//! @note use a widget's property to keep compatibility with using basic widget instead of QgsRelationEditorWidget
58+
QString qgisRelation() const { return mRelationId; } //property( "qgisRelation" ).toString()
59+
60+
void setQgisNmRelation( const QString& qgisRelationId );
61+
62+
QString qgisNmRelation() const { return mNmRelationId; }
5463

5564
void setRelationFeature( const QgsRelation& relation, const QgsFeature& feature );
5665

@@ -75,6 +84,8 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsCollapsibleGroupBox
7584
QgsAttributeEditorContext mEditorContext;
7685
QgsRelation mRelation;
7786
QString mRelationId;
87+
QgsRelation mNmRelation;
88+
QString mNmRelationId;
7889
QgsFeature mFeature;
7990

8091
QToolButton* mToggleEditingButton;

0 commit comments

Comments
 (0)