Skip to content

Commit

Permalink
mZoomToFeatureButton visibility is set on several places. To keep it …
Browse files Browse the repository at this point in the history
…stable and not beeing dependant on the order or the setting it stores mChildIsSpacial and mButtons (the configuration).

On setVisibleButtons it does only set mZoomToFeatureButton visible, if the referenced layer of relation / the referencing layer of the nmRelation is spacial and the flag is set.
On setRelation it does only set mZoomToFeatureButton visible, if the referenced layer of relation / the referencing layer of the nmRelation is spacial and the flag of the config is set.
On updateButtons it does only set mZoomToFeatureButton visible, if the referenced layer of relation / the referencing layer of the nmRelation is spacial and the flag is set and the mapCanvas of the context is existing.

fixes #37718
  • Loading branch information
signedav committed Sep 10, 2020
1 parent 509c5e1 commit 2ce9e48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/gui/qgsrelationeditorwidget.cpp
Expand Up @@ -358,9 +358,11 @@ void QgsRelationEditorWidget::setRelations( const QgsRelation &relation, const Q
}

if ( mNmRelation.isValid() )
mZoomToFeatureButton->setVisible( mNmRelation.referencedLayer()->isSpatial() );
mChildIsSpatial = mNmRelation.referencedLayer()->isSpatial();
else
mZoomToFeatureButton->setVisible( mRelation.referencingLayer()->isSpatial() );
mChildIsSpatial = mRelation.referencingLayer()->isSpatial();

mZoomToFeatureButton->setVisible( mButtons.testFlag( QgsAttributeEditorRelation::Button::ZoomToChildFeature ) && mChildIsSpatial );

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

Expand Down Expand Up @@ -429,6 +431,7 @@ void QgsRelationEditorWidget::updateButtons()
mUnlinkFeatureButton->setEnabled( linkable && selectionNotEmpty );

mZoomToFeatureButton->setVisible(
mButtons.testFlag( QgsAttributeEditorRelation::Button::ZoomToChildFeature ) &&
mEditorContext.mapCanvas() && (
(
mNmRelation.isValid() &&
Expand Down Expand Up @@ -959,14 +962,15 @@ bool QgsRelationEditorWidget::showSaveChildEditsButton() const

void QgsRelationEditorWidget::setVisibleButtons( const QgsAttributeEditorRelation::Buttons &buttons )
{
mLinkFeatureButton->setVisible( buttons.testFlag( QgsAttributeEditorRelation::Button::Link ) );
mUnlinkFeatureButton->setVisible( buttons.testFlag( QgsAttributeEditorRelation::Button::Unlink ) );
mSaveEditsButton->setVisible( buttons.testFlag( QgsAttributeEditorRelation::Button::SaveChildEdits ) );
mAddFeatureButton->setVisible( buttons.testFlag( QgsAttributeEditorRelation::Button::AddChildFeature ) );
mAddFeatureGeometryButton->setVisible( buttons.testFlag( QgsAttributeEditorRelation::Button::AddChildFeature ) );
mDuplicateFeatureButton->setVisible( buttons.testFlag( QgsAttributeEditorRelation::Button::DuplicateChildFeature ) );
mDeleteFeatureButton->setVisible( buttons.testFlag( QgsAttributeEditorRelation::Button::DeleteChildFeature ) );
mZoomToFeatureButton->setVisible( buttons.testFlag( QgsAttributeEditorRelation::Button::ZoomToChildFeature ) );
mButtons = buttons;
mLinkFeatureButton->setVisible( mButtons.testFlag( QgsAttributeEditorRelation::Button::Link ) );
mUnlinkFeatureButton->setVisible( mButtons.testFlag( QgsAttributeEditorRelation::Button::Unlink ) );
mSaveEditsButton->setVisible( mButtons.testFlag( QgsAttributeEditorRelation::Button::SaveChildEdits ) );
mAddFeatureButton->setVisible( mButtons.testFlag( QgsAttributeEditorRelation::Button::AddChildFeature ) );
mAddFeatureGeometryButton->setVisible( mButtons.testFlag( QgsAttributeEditorRelation::Button::AddChildFeature ) );
mDuplicateFeatureButton->setVisible( mButtons.testFlag( QgsAttributeEditorRelation::Button::DuplicateChildFeature ) );
mDeleteFeatureButton->setVisible( mButtons.testFlag( QgsAttributeEditorRelation::Button::DeleteChildFeature ) );
mZoomToFeatureButton->setVisible( mButtons.testFlag( QgsAttributeEditorRelation::Button::ZoomToChildFeature ) && mChildIsSpatial );
}

QgsAttributeEditorRelation::Buttons QgsRelationEditorWidget::visibleButtons() const
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsrelationeditorwidget.h
Expand Up @@ -329,8 +329,10 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsCollapsibleGroupBox
QObjectUniquePtr<QgsMapToolDigitizeFeature> mMapToolDigitize;
QButtonGroup *mViewModeButtonGroup = nullptr;

QgsAttributeEditorRelation::Buttons mButtons;
bool mShowLabel = true;
bool mVisible = false;
bool mChildIsSpatial = false;

bool mForceSuppressFormPopup = false;
QVariant mNmRelationId;
Expand Down

0 comments on commit 2ce9e48

Please sign in to comment.