Skip to content
Permalink
Browse files

Pass configuration to relation widget

  • Loading branch information
m-kuhn committed Dec 8, 2015
1 parent 8246d96 commit 4160097c2bba19dced27765b20dc1e18ee04d439
Showing with 24 additions and 2 deletions.
  1. +5 −1 src/gui/qgsattributeform.cpp
  2. +7 −0 src/gui/qgsrelationeditorwidget.cpp
  3. +12 −1 src/gui/qgsrelationeditorwidget.h
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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;
@@ -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 );

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

QToolButton* mToggleEditingButton;

0 comments on commit 4160097

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