Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pass configuration to relation widget
  • Loading branch information
m-kuhn committed Dec 8, 2015
1 parent 8246d96 commit 4160097
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/gui/qgsattributeform.cpp
Expand Up @@ -528,6 +528,8 @@ void QgsAttributeForm::init()
Q_FOREACH ( const QgsRelation& rel, QgsProject::instance()->relationManager()->referencedRelations( mLayer ) )
{
QgsRelationWidgetWrapper* rww = new QgsRelationWidgetWrapper( mLayer, rel, 0, this );
QgsEditorWidgetConfig cfg = mLayer->editFormConfig()->widgetConfig( rel.id() );
rww->setConfig( cfg );
rww->setContext( mContext );
gridLayout->addWidget( rww->widget(), row++, 0, 1, 2 );
mWidgets.append( rww );
Expand Down Expand Up @@ -717,6 +719,8 @@ QWidget* QgsAttributeForm::createWidgetFromDef( const QgsAttributeEditorElement
const QgsAttributeEditorRelation* relDef = dynamic_cast<const QgsAttributeEditorRelation*>( widgetDef );

QgsRelationWidgetWrapper* rww = new QgsRelationWidgetWrapper( mLayer, relDef->relation(), 0, this );
QgsEditorWidgetConfig cfg = mLayer->editFormConfig()->widgetConfig( relDef->relation().id() );
rww->setConfig( cfg );
rww->setContext( context );
newWidget = rww->widget();
mWidgets.append( rww );
Expand Down Expand Up @@ -839,7 +843,7 @@ void QgsAttributeForm::createWrappers()
if ( relation.isValid() )
{
QgsRelationWidgetWrapper* rww = new QgsRelationWidgetWrapper( mLayer, relation, myWidget, this );
rww->setConfig( QgsEditorWidgetConfig() );
rww->setConfig( mLayer->editFormConfig()->widgetConfig( relation.id() ) );
rww->setContext( mContext );
rww->widget(); // Will initialize the widget
mWidgets.append( rww );
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsrelationeditorwidget.cpp
Expand Up @@ -187,6 +187,13 @@ void QgsRelationEditorWidget::setQgisRelation( const QString& qgisRelationId )
loadState();
}

void QgsRelationEditorWidget::setQgisNmRelation( const QString& qgisRelationId )
{
mNmRelationId = qgisRelationId;

loadState();
}

void QgsRelationEditorWidget::referencingLayerEditingToggled()
{
bool editable = false;
Expand Down
13 changes: 12 additions & 1 deletion src/gui/qgsrelationeditorwidget.h
Expand Up @@ -45,12 +45,21 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsCollapsibleGroupBox

//! Define the view mode for the dual view
void setViewMode( QgsDualView::ViewMode mode );

//! Get the view mode for the dual view
QgsDualView::ViewMode viewMode() {return mViewMode;}

//! Defines the relation ID (from project relations)
//! @note use a widget's property to keep compatibility with using basic widget instead of QgsRelationEditorWidget
void setQgisRelation( const QString& qgisRelationId );
QString qgisRelation() { return mRelationId; } //property( "qgisRelation" ).toString()

//! Get the relation ID (from project relations)
//! @note use a widget's property to keep compatibility with using basic widget instead of QgsRelationEditorWidget
QString qgisRelation() const { return mRelationId; } //property( "qgisRelation" ).toString()

void setQgisNmRelation( const QString& qgisRelationId );

QString qgisNmRelation() const { return mNmRelationId; }

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

Expand All @@ -75,6 +84,8 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsCollapsibleGroupBox
QgsAttributeEditorContext mEditorContext;
QgsRelation mRelation;
QString mRelationId;
QgsRelation mNmRelation;
QString mNmRelationId;
QgsFeature mFeature;

QToolButton* mToggleEditingButton;
Expand Down

0 comments on commit 4160097

Please sign in to comment.