Skip to content
Permalink
Browse files

check for layers instead of relations

  • Loading branch information
signedav committed Sep 17, 2018
1 parent f7f36cd commit bfe2fbc552d8ef4f62d361ea3a89c8e4c83c8615
Showing with 13 additions and 8 deletions.
  1. +13 −8 src/gui/editorwidgets/qgsrelationwidgetwrapper.cpp
@@ -19,7 +19,8 @@
#include "qgsattributeeditorcontext.h"
#include "qgsproject.h"
#include "qgsrelationmanager.h"

#undef QGISDEBUG
#include "qgslogger.h"
#include <QWidget>

QgsRelationWidgetWrapper::QgsRelationWidgetWrapper( QgsVectorLayer *vl, const QgsRelation &relation, QWidget *editor, QWidget *parent )
@@ -48,22 +49,27 @@ void QgsRelationWidgetWrapper::setVisible( bool visible )

void QgsRelationWidgetWrapper::aboutToSave()
{
// If this widget is already embedded by the same relation return
if ( !mRelation.isValid() || !widget() || !widget()->isVisible() || mRelation.referencingLayer()->name() == mRelation.referencedLayer()->name() )
return;


QgsDebugMsg( QString( "2. Rel Name: %1, ParentLayer: %2 ChildLayer: %3" ).arg( mRelation.name(), mRelation.referencedLayer()->name(), mRelation.referencingLayer()->name() ) );

// If this widget is already embedded by the same relation, reduce functionality
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().isValid() && ( ctx->relation().referencedLayer()->name() == mRelation.referencingLayer()->name()
|| ctx->relation().referencedLayer()->name() == mNmRelation.referencedLayer()->name() )
)
{
QgsDebugMsg( QString( "- Layer %1 allready occured in the relation %2 as referenced layer" ).arg( mRelation.referencingLayer()->name(), ctx->relation().name() ) );
return;
}
ctx = ctx->parentContext();
}
while ( ctx );

if ( !mRelation.isValid() || !widget() || !widget()->isVisible() )
return;

// Calling isModified() will emit a beforeModifiedCheck()
// signal that will make the embedded form to send any
// outstanding widget changes to the edit buffer
@@ -139,7 +145,6 @@ void QgsRelationWidgetWrapper::initWidget( QWidget *editor )
}
while ( ctx );


w->setRelations( mRelation, mNmRelation );

mWidget = w;

0 comments on commit bfe2fbc

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