Skip to content
Permalink
Browse files
Fix #43539, backport from #43579
  • Loading branch information
domi4484 authored and nyalldawson committed Jun 14, 2021
1 parent 1e3aae0 commit 4cb8343c674e53453d6534b50e69bd5c75ff9737
Showing with 10 additions and 25 deletions.
  1. +10 −25 src/gui/qgsrelationeditorwidget.cpp
@@ -233,18 +233,7 @@ void QgsRelationEditorWidget::setRelationFeature( const QgsRelation &relation, c

updateTitle();

QgsVectorLayer *lyr = relation.referencingLayer();

bool canChangeAttributes = lyr->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
if ( canChangeAttributes && !lyr->readOnly() )
{
mToggleEditingButton->setEnabled( true );
updateButtons();
}
else
{
mToggleEditingButton->setEnabled( false );
}
updateButtons();

setObjectName( QStringLiteral( "referenced/" ) + mRelation.name() );

@@ -345,18 +334,6 @@ void QgsRelationEditorWidget::setRelations( const QgsRelation &relation, const Q

updateTitle();

QgsVectorLayer *lyr = relation.referencingLayer();

bool canChangeAttributes = lyr->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
if ( canChangeAttributes && !lyr->readOnly() )
{
mToggleEditingButton->setEnabled( true );
}
else
{
mToggleEditingButton->setEnabled( false );
}

updateButtons();

setObjectName( QStringLiteral( "referenced/" ) + mRelation.name() );
@@ -405,24 +382,32 @@ void QgsRelationEditorWidget::setFeature( const QgsFeature &feature, bool update

void QgsRelationEditorWidget::updateButtons()
{
bool toggleEditingButtonEnabled = false;
bool editable = false;
bool linkable = false;
bool spatial = false;
bool selectionNotEmpty = mFeatureSelectionMgr ? mFeatureSelectionMgr->selectedFeatureCount() : false;

if ( mRelation.isValid() )
{
bool canSupportEditing = mRelation.referencingLayer()->dataProvider()->capabilities() & QgsVectorDataProvider::EditingCapabilities;
canSupportEditing &= !mRelation.referencingLayer()->readOnly();
toggleEditingButtonEnabled = canSupportEditing;
editable = mRelation.referencingLayer()->isEditable();
linkable = mRelation.referencingLayer()->isEditable();
spatial = mRelation.referencingLayer()->isSpatial();
}

if ( mNmRelation.isValid() )
{
bool canSupportEditing = mNmRelation.referencedLayer()->dataProvider()->capabilities() & QgsVectorDataProvider::EditingCapabilities;
canSupportEditing &= !mNmRelation.referencedLayer()->readOnly();
toggleEditingButtonEnabled |= canSupportEditing;
editable = mNmRelation.referencedLayer()->isEditable();
spatial = mNmRelation.referencedLayer()->isSpatial();
}

mToggleEditingButton->setEnabled( toggleEditingButtonEnabled );
mAddFeatureButton->setEnabled( editable );
mAddFeatureGeometryButton->setEnabled( editable );
mDuplicateFeatureButton->setEnabled( editable && selectionNotEmpty );
@@ -431,7 +416,7 @@ void QgsRelationEditorWidget::updateButtons()
mUnlinkFeatureButton->setEnabled( linkable && selectionNotEmpty );
mZoomToFeatureButton->setEnabled( selectionNotEmpty );
mToggleEditingButton->setChecked( editable );
mSaveEditsButton->setEnabled( editable );
mSaveEditsButton->setEnabled( editable || linkable );

mToggleEditingButton->setVisible( !mLayerInSameTransactionGroup );
mLinkFeatureButton->setVisible( mButtonsVisibility.testFlag( QgsAttributeEditorRelation::Button::Link ) );

0 comments on commit 4cb8343

Please sign in to comment.