Skip to content
Permalink
Browse files
Avoid endless sub-RelationEditorWidget creation fix #42952 (#43246)
* Avoid endless sub-RelationEditorWidget creation fix 42952

* Added missing docstring
  • Loading branch information
domi4484 committed May 17, 2021
1 parent 1107653 commit 40988a8901bc746b4b5dc5601a01d03df1aafd65
@@ -217,6 +217,11 @@ Duplicates features



void showEvent( QShowEvent * );
%Docstring
Refresh the UI when the widget becomes visible
%End

void updateTitle() /Deprecated/;
%Docstring
Updates the title contents to reflect the current state of the widget
@@ -181,8 +181,8 @@ void QgsRelationWidgetWrapper::initWidget( QWidget *editor )
const QgsAttributeEditorContext *ctx = &context();
do
{
if ( ( ctx->relation().name() == mRelation.name() && ctx->formMode() == QgsAttributeEditorContext::Embed )
|| ( mNmRelation.isValid() && ctx->relation().name() == mNmRelation.name() ) )
if ( ( ctx->relation().id() == mRelation.id() && ctx->formMode() == QgsAttributeEditorContext::Embed )
|| ( mNmRelation.isValid() && ctx->relation().id() == mNmRelation.id() ) )
{
w->setVisible( false );
break;
@@ -626,6 +626,11 @@ void QgsAbstractRelationEditorWidget::duplicateFeatures( const QgsFeatureIds &fi
}
}

void QgsAbstractRelationEditorWidget::showEvent( QShowEvent * )
{
updateUi();
}


///////////////////////////////////////////////////////////////////////////////

@@ -235,6 +235,11 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget

bool mForceSuppressFormPopup = false;

/**
* Refresh the UI when the widget becomes visible
*/
void showEvent( QShowEvent * );

/**
* Updates the title contents to reflect the current state of the widget
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
@@ -192,9 +192,14 @@ QgsRelationEditorWidget::QgsRelationEditorWidget( const QVariantMap &config, QWi
// add buttons layout
rootLayout->addLayout( buttonLayout );

mRelationLayout = new QGridLayout();
mRelationLayout->setContentsMargins( 0, 0, 0, 0 );
rootLayout->addLayout( mRelationLayout );
// add dual view
QGridLayout *relationLayout = new QGridLayout();
relationLayout->setContentsMargins( 0, 0, 0, 0 );
mDualView = new QgsDualView( this );
mDualView->setView( mViewMode );
connect( mDualView, &QgsDualView::showContextMenuExternally, this, &QgsRelationEditorWidget::showContextMenu );
relationLayout->addWidget( mDualView );
rootLayout->addLayout( relationLayout );

connect( mViewModeButtonGroup, static_cast<void ( QButtonGroup::* )( int )>( &QButtonGroup::buttonClicked ),
this, static_cast<void ( QgsRelationEditorWidget::* )( int )>( &QgsRelationEditorWidget::setViewMode ) );
@@ -214,14 +219,6 @@ QgsRelationEditorWidget::QgsRelationEditorWidget( const QVariantMap &config, QWi

void QgsRelationEditorWidget::initDualView( QgsVectorLayer *layer, const QgsFeatureRequest &request )
{
if ( !mDualView )
{
mDualView = new QgsDualView( this );
mDualView->setView( mViewMode );
connect( mDualView, &QgsDualView::showContextMenuExternally, this, &QgsRelationEditorWidget::showContextMenu );
mRelationLayout->addWidget( mDualView );
}

QgsAttributeEditorContext ctx { mEditorContext };
ctx.setParentFormFeature( mFeature );
mDualView->init( layer, mEditorContext.mapCanvas(), request, ctx );
@@ -365,6 +362,9 @@ void QgsRelationEditorWidget::updateUi()
if ( !mRelation.isValid() || !mFeature.isValid() )
return;

if ( !isVisible() )
return;

QgsFeatureRequest request = mRelation.getRelatedFeaturesRequest( mFeature );

if ( mNmRelation.isValid() )
@@ -225,7 +225,6 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsAbstractRelationEditorWidge
QToolButton *mFormViewButton = nullptr;
QToolButton *mTableViewButton = nullptr;
QToolButton *mAddFeatureGeometryButton = nullptr;
QGridLayout *mRelationLayout = nullptr;
QObjectUniquePtr<QgsMapToolDigitizeFeature> mMapToolDigitize;
QButtonGroup *mViewModeButtonGroup = nullptr;
QgsVectorLayerSelectionManager *mFeatureSelectionMgr = nullptr;

0 comments on commit 40988a8

Please sign in to comment.