QGIS/src/gui/qgsattributeformrelationeditorwidget.cpp
Matthias Kuhn e969584ad9 Avoid freezing attribute form with recursion
The search widget wrappers for relations have two issues

* They recursively load whatever relations are defined. With self-referencing this leads to 💀
  This is addressed by only loading one level of relations in search widgets.

* They would load even when hidden, leading to long load times on attribute table opening.
  We now only actually load the form on the show event
2018-03-06 09:46:44 -05:00

44 lines
1.8 KiB
C++

/***************************************************************************
qgsattributeformrelationeditorwidget.cpp
--------------------------------------
Date : Nov 2017
Copyright : (C) 2017 Matthias Kuhn
Email : matthias@opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsattributeformrelationeditorwidget.h"
#include "qgsrelationaggregatesearchwidgetwrapper.h"
#include "qgsattributeform.h"
#include "qgsrelationwidgetwrapper.h"
QgsAttributeFormRelationEditorWidget::QgsAttributeFormRelationEditorWidget( QgsRelationWidgetWrapper *wrapper, QgsAttributeForm *form )
: QgsAttributeFormWidget( wrapper, form )
, mWrapper( wrapper )
{
setSearchWidgetToolButtonVisible( false );
}
void QgsAttributeFormRelationEditorWidget::createSearchWidgetWrappers( const QgsAttributeEditorContext &context )
{
if ( context.parentContext() )
{
mSearchWidget = new QgsRelationAggregateSearchWidgetWrapper( layer(), mWrapper, form() );
mSearchWidget->setContext( context );
setSearchWidgetWrapper( mSearchWidget );
}
}
QString QgsAttributeFormRelationEditorWidget::currentFilterExpression() const
{
return mSearchWidget->expression();
}