Skip to content
Permalink
Browse files

Merge pull request #42296 from domi4484/fixNmRelationMissing

Fix QgsAbstractRelationEditorWidget inconsistency NmRelation / NmRelationId
  • Loading branch information
m-kuhn authored and github-actions committed Mar 29, 2021
1 parent 0d261d2 commit 14a3843433b84509b07b501aa52d505839ccb0fe
@@ -61,6 +61,13 @@ inserting and deleting entries on the intermediate table as required.
%Docstring
Returns the relation

.. versionadded:: 3.18
%End

QgsRelation nmRelation() const;
%Docstring
Returns the nm relation

.. versionadded:: 3.18
%End

@@ -268,8 +268,6 @@ void QgsRelationWidgetWrapper::setNmRelationId( const QVariant &nmRelationId )
{
if ( mWidget )
{
mWidget->setNmRelationId( nmRelationId );

mNmRelation = QgsProject::instance()->relationManager()->relation( nmRelationId.toString() );

// If this widget is already embedded by the same relation, reduce functionality
@@ -22,6 +22,7 @@
#include "qgsfeature.h"
#include "qgsfeatureselectiondlg.h"
#include "qgsrelation.h"
#include "qgsrelationmanager.h"
#include "qgspolymorphicrelation.h"
#include "qgsvectorlayertools.h"
#include "qgsproject.h"
@@ -116,12 +117,16 @@ void QgsAbstractRelationEditorWidget::setFeature( const QgsFeature &feature, boo

void QgsAbstractRelationEditorWidget::setNmRelationId( const QVariant &nmRelationId )
{
mNmRelationId = nmRelationId;
QgsRelation nmrelation = QgsProject::instance()->relationManager()->relation( nmRelationId.toString() );
beforeSetRelations( mRelation, nmrelation );
mNmRelation = nmrelation;
afterSetRelations();
updateUi();
}

QVariant QgsAbstractRelationEditorWidget::nmRelationId() const
{
return mNmRelationId;
return mNmRelation.id();
}

QString QgsAbstractRelationEditorWidget::label() const
@@ -86,6 +86,12 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
*/
QgsRelation relation() const {return mRelation;}

/**
* Returns the nm relation
* \since QGIS 3.18
*/
QgsRelation nmRelation() const {return mNmRelation;}

/**
* Sets the \a feature being edited and updates the UI unless \a update is set to FALSE
*/
@@ -226,7 +232,6 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
bool mLayerInSameTransactionGroup = false;

bool mForceSuppressFormPopup = false;
QVariant mNmRelationId;
QString mLabel;

/**

0 comments on commit 14a3843

Please sign in to comment.