Fix option "show label" on relation editor

If the option was disabled, the label was still shown.
This commit is contained in:
Matthias Kuhn 2020-06-12 17:35:17 +02:00 committed by Nyall Dawson
parent 8e09f4e9c1
commit d8b3adab94
3 changed files with 13 additions and 9 deletions

View File

@ -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 );
@ -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 );

View File

@ -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();
@ -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();
@ -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 )
@ -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;

View File

@ -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;