mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
Fields of non existent joined features are set to NULL
This commit is contained in:
parent
257f35c46f
commit
5253aa80e2
@ -1936,16 +1936,6 @@ void QgsAttributeForm::ContainerInformation::apply( QgsExpressionContext *expres
|
||||
}
|
||||
}
|
||||
|
||||
QgsFeature QgsAttributeForm::joinedFeature( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const
|
||||
{
|
||||
QgsFeature joinedFeature = mLayer->joinBuffer()->joinedFeatureOf( info, feature );
|
||||
|
||||
if ( !joinedFeature.isValid() )
|
||||
joinedFeature = QgsVectorLayerUtils::createFeature( info->joinLayer(), QgsGeometry(), QgsAttributeMap() );
|
||||
|
||||
return joinedFeature;
|
||||
}
|
||||
|
||||
void QgsAttributeForm::updateJoinedFields( const QgsEditorWidgetWrapper &eww )
|
||||
{
|
||||
QgsFeature formFeature;
|
||||
@ -1960,7 +1950,7 @@ void QgsAttributeForm::updateJoinedFields( const QgsEditorWidgetWrapper &eww )
|
||||
if ( !info->isDynamicFormEnabled() )
|
||||
continue;
|
||||
|
||||
QgsFeature joinFeature = joinedFeature( info, formFeature );
|
||||
QgsFeature joinFeature = mLayer->joinBuffer()->joinedFeatureOf( info, formFeature );
|
||||
|
||||
QStringList *subsetFields = info->joinFieldNamesSubset();
|
||||
if ( subsetFields )
|
||||
@ -1968,7 +1958,12 @@ void QgsAttributeForm::updateJoinedFields( const QgsEditorWidgetWrapper &eww )
|
||||
Q_FOREACH ( const QString &field, *subsetFields )
|
||||
{
|
||||
QString prefixedName = info->prefixedFieldName( field );
|
||||
changeAttribute( prefixedName, joinFeature.attribute( field ) );
|
||||
QVariant val;
|
||||
|
||||
if ( joinFeature.isValid() )
|
||||
val = joinFeature.attribute( field );
|
||||
|
||||
changeAttribute( prefixedName, val );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1976,7 +1971,12 @@ void QgsAttributeForm::updateJoinedFields( const QgsEditorWidgetWrapper &eww )
|
||||
Q_FOREACH ( const QgsField &field, joinFeature.fields() )
|
||||
{
|
||||
QString prefixedName = info->prefixedFieldName( field );
|
||||
changeAttribute( prefixedName, joinFeature.attribute( field.name() ) );
|
||||
QVariant val;
|
||||
|
||||
if ( joinFeature.isValid() )
|
||||
val = joinFeature.attribute( field.name() );
|
||||
|
||||
changeAttribute( prefixedName, val );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,8 +273,6 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
|
||||
|
||||
void initPython();
|
||||
|
||||
QgsFeature joinedFeature( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;
|
||||
|
||||
void updateJoinedFields( const QgsEditorWidgetWrapper &eww );
|
||||
|
||||
struct WidgetInfo
|
||||
|
Loading…
x
Reference in New Issue
Block a user