Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix option "show label" on relation editor
If the option was disabled, the label was still shown.
  • Loading branch information
m-kuhn authored and nyalldawson committed Jun 15, 2020
1 parent 8e09f4e commit d8b3ada
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -1927,8 +1927,6 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt

QgsRelationWidgetWrapper *rww = setupRelationWidgetWrapper( relDef->relation(), context );

rww->setShowLabel( relDef->showLabel() );

QgsAttributeFormRelationEditorWidget *formWidget = new QgsAttributeFormRelationEditorWidget( rww, this );
formWidget->createSearchWidgetWrappers( mContext );

Expand All @@ -1938,6 +1936,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
rww->setShowLinkButton( relDef->showLinkButton() );
rww->setShowUnlinkButton( relDef->showUnlinkButton() );
rww->setShowSaveChildEditsButton( relDef->showSaveChildEditsButton() );
rww->setShowLabel( relDef->showLabel() );

mWidgets.append( rww );
mFormWidgets.append( formWidget );
Expand Down
18 changes: 11 additions & 7 deletions src/gui/qgsrelationeditorwidget.cpp
Expand Up @@ -228,8 +228,7 @@ void QgsRelationEditorWidget::setRelationFeature( const QgsRelation &relation, c
connect( mRelation.referencingLayer(), &QgsVectorLayer::editingStarted, this, &QgsRelationEditorWidget::updateButtons );
connect( mRelation.referencingLayer(), &QgsVectorLayer::editingStopped, this, &QgsRelationEditorWidget::updateButtons );

if ( mShowLabel )
setTitle( relation.name() );
updateTitle();

QgsVectorLayer *lyr = relation.referencingLayer();

Expand Down Expand Up @@ -340,7 +339,7 @@ void QgsRelationEditorWidget::setRelations( const QgsRelation &relation, const Q
connect( mNmRelation.referencedLayer(), &QgsVectorLayer::editingStopped, this, &QgsRelationEditorWidget::updateButtons );
}

setTitle( relation.name() );
updateTitle();

QgsVectorLayer *lyr = relation.referencingLayer();

Expand Down Expand Up @@ -972,10 +971,7 @@ void QgsRelationEditorWidget::setShowLabel( bool showLabel )
{
mShowLabel = showLabel;

if ( mShowLabel && mRelation.isValid() )
setTitle( mRelation.name() );
else
setTitle( QString() );
updateTitle();
}

void QgsRelationEditorWidget::showContextMenu( QgsActionMenu *menu, const QgsFeatureId fid )
Expand Down Expand Up @@ -1014,6 +1010,14 @@ void QgsRelationEditorWidget::unsetMapTool()
disconnect( mMapToolDigitize, &QgsMapToolDigitizeFeature::digitizingCompleted, this, &QgsRelationEditorWidget::onDigitizingCompleted );
}

void QgsRelationEditorWidget::updateTitle()
{
if ( mShowLabel && mRelation.isValid() )
setTitle( mRelation.name() );
else
setTitle( QString() );
}

QgsFeature QgsRelationEditorWidget::feature() const
{
return mFeature;
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsrelationeditorwidget.h
Expand Up @@ -250,6 +250,7 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsCollapsibleGroupBox
void initDualView( QgsVectorLayer *layer, const QgsFeatureRequest &request );
void setMapTool( QgsMapTool *mapTool );
void unsetMapTool();
void updateTitle();

QgsDualView *mDualView = nullptr;
QPointer<QgsMessageBarItem> mMessageBarItem;
Expand Down

0 comments on commit d8b3ada

Please sign in to comment.