Skip to content

Commit

Permalink
Fix merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Dec 9, 2021
1 parent 80f822b commit 4cd945d
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 105 deletions.
Expand Up @@ -156,13 +156,6 @@ Returns the widget configuration
virtual void setConfig( const QVariantMap &config ) = 0;
%Docstring
Defines the widget configuration
%End

bool multiEditModeActive() const;
%Docstring
Returns true if editing multiple features at a time

.. versionadded:: 3.24
%End

signals:
Expand Down
2 changes: 0 additions & 2 deletions src/gui/qgsabstractrelationeditorwidget.cpp
Expand Up @@ -250,8 +250,6 @@ void QgsAbstractRelationEditorWidget::addFeature( const QgsGeometry &geometry )
updateUi();

emit relatedFeaturesChanged();

return addedFeatureIds;
}

void QgsAbstractRelationEditorWidget::deleteFeature( const QgsFeatureId fid )
Expand Down
6 changes: 0 additions & 6 deletions src/gui/qgsabstractrelationeditorwidget.h
Expand Up @@ -170,12 +170,6 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
*/
virtual void setConfig( const QVariantMap &config ) = 0;

/**
* Returns true if editing multiple features at a time
* \since QGIS 3.24
*/
bool multiEditModeActive() const;

signals:

/**
Expand Down
92 changes: 2 additions & 90 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -482,83 +482,6 @@ bool QgsAttributeForm::saveEdits( QString *error )
return success;
}

void QgsAttributeForm::updateValuesDependencies( const int originIdx )
{
updateFieldDependencies();

updateValuesDependenciesDefaultValues( originIdx );
updateValuesDependenciesVirtualFields( originIdx );
}

void QgsAttributeForm::updateValuesDependenciesDefaultValues( const int originIdx )
{
if ( !mDefaultValueDependencies.contains( originIdx ) )
return;

// create updated Feature
QgsFeature updatedFeature = QgsFeature( mFeature );
if ( mFeature.isValid() || mMode == QgsAttributeEditorContext::AddFeatureMode )
{
QgsAttributes dst = mFeature.attributes();
for ( QgsWidgetWrapper *ww : std::as_const( mWidgets ) )
{
QgsEditorWidgetWrapper *eww = qobject_cast<QgsEditorWidgetWrapper *>( ww );
if ( eww )
{
QVariantList dstVars = QVariantList() << dst.at( eww->fieldIdx() );
QVariantList srcVars = QVariantList() << eww->value();
QList<int> fieldIndexes = QList<int>() << eww->fieldIdx();

// append additional fields
const QStringList additionalFields = eww->additionalFields();
for ( const QString &fieldName : additionalFields )
{
int idx = eww->layer()->fields().lookupField( fieldName );
fieldIndexes << idx;
dstVars << dst.at( idx );
}
srcVars.append( eww->additionalFieldValues() );

Q_ASSERT( dstVars.count() == srcVars.count() );

for ( int i = 0; i < dstVars.count(); i++ )
{

if ( !qgsVariantEqual( dstVars[i], srcVars[i] ) && srcVars[i].isValid() && fieldIsEditable( fieldIndexes[i] ) )
{
dst[fieldIndexes[i]] = srcVars[i];
}
}
}
}
updatedFeature.setAttributes( dst );

// go through depending fields and update the fields with defaultexpression
QList<QgsWidgetWrapper *> relevantWidgets = mDefaultValueDependencies.values( originIdx );
for ( QgsWidgetWrapper *ww : std::as_const( relevantWidgets ) )
{
QgsEditorWidgetWrapper *eww = qobject_cast<QgsEditorWidgetWrapper *>( ww );
if ( eww )
{
//do not update when when mMode is not AddFeatureMode and it's not applyOnUpdate
if ( mMode != QgsAttributeEditorContext::AddFeatureMode && !eww->field().defaultValueDefinition().applyOnUpdate() )
{
continue;
}

//do not update when this widget is already updating (avoid recursions)
if ( mAlreadyUpdatedFields.contains( eww->fieldIdx() ) )
continue;

QgsExpressionContext context = createExpressionContext( updatedFeature );
const QVariant value = mLayer->defaultValue( eww->fieldIdx(), updatedFeature, &context );
eww->setValue( value );
mCurrentFormFeature.setAttribute( eww->field().name(), value );
}
}
}
}

QgsFeature QgsAttributeForm::getUpdatedFeature() const
{
// create updated Feature
Expand Down Expand Up @@ -636,8 +559,9 @@ void QgsAttributeForm::updateValuesDependenciesDefaultValues( const int originId
continue;

QgsExpressionContext context = createExpressionContext( updatedFeature );
QString value = mLayer->defaultValue( eww->fieldIdx(), updatedFeature, &context ).toString();
const QVariant value = mLayer->defaultValue( eww->fieldIdx(), updatedFeature, &context );
eww->setValue( value );
mCurrentFormFeature.setAttribute( eww->field().name(), value );
}
}
}
Expand Down Expand Up @@ -2894,18 +2818,6 @@ void QgsAttributeForm::updateRelatedLayerFieldsDependencies( QgsEditorWidgetWrap
}
}

void QgsAttributeForm::setMultiEditFeatureIdsRelations( const QgsFeatureIds &fids )
{
for ( QgsAttributeFormWidget *formWidget : mFormWidgets )
{
QgsAttributeFormRelationEditorWidget *relationEditorWidget = dynamic_cast<QgsAttributeFormRelationEditorWidget *>( formWidget );
if ( !relationEditorWidget )
continue;

relationEditorWidget->setMultiEditFeatureIds( fids );
}
}

void QgsAttributeForm::updateIcon( QgsEditorWidgetWrapper *eww )
{
if ( !eww->widget() || !mIconMap[eww->widget()] )
Expand Down

0 comments on commit 4cd945d

Please sign in to comment.