Skip to content
Permalink
Browse files

mZoomToFeatureButton visibility is set on several places. To keep it …

…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 2ce9e48aec4e6f6399dcb46cd9dd2646218e0212
Showing with 16 additions and 10 deletions.
  1. +14 −10 src/gui/qgsrelationeditorwidget.cpp
  2. +2 −0 src/gui/qgsrelationeditorwidget.h
@@ -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() );

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

mZoomToFeatureButton->setVisible(
mButtons.testFlag( QgsAttributeEditorRelation::Button::ZoomToChildFeature ) &&
mEditorContext.mapCanvas() && (
(
mNmRelation.isValid() &&
@@ -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
@@ -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;

0 comments on commit 2ce9e48

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