Skip to content
Permalink
Browse files

When the "edit attributes of selected features" button is clicked

and only a SINGLE feature is selected, then show the attribute
edit form in single edit mode instead of multi-edit mode

The multi-edit buttons and logic has no meaning when users
are editing only a single feature.
  • Loading branch information
nyalldawson committed Feb 8, 2021
1 parent 8e57368 commit bad13f2560c02d1cbc41816da7a014180238f781
Showing with 17 additions and 5 deletions.
  1. +17 −5 src/app/qgisapp.cpp
@@ -10114,17 +10114,29 @@ void QgisApp::modifyAttributesOfSelectedFeatures()
return;
}

//dummy feature
QgsFeature f( vl->fields() );
QgsAttributeEditorContext context( createAttributeEditorContext() );
context.setAllowCustomUi( false );
context.setVectorLayerTools( mVectorLayerTools );
context.setCadDockWidget( mAdvancedDigitizingDockWidget );
context.setMapCanvas( mMapCanvas );
context.setAttributeFormMode( QgsAttributeEditorContext::Mode::MultiEditMode );

QgsAttributeDialog *dialog = new QgsAttributeDialog( vl, &f, false, this, true, context );
dialog->setMode( QgsAttributeEditorContext::MultiEditMode );
QgsAttributeDialog *dialog = nullptr;
if ( vl->selectedFeatureCount() == 1 )
{
context.setAttributeFormMode( QgsAttributeEditorContext::Mode::SingleEditMode );
QgsFeature f = vl->selectedFeatures().at( 0 );
dialog = new QgsAttributeDialog( vl, &f, false, this, true, context );
dialog->setMode( QgsAttributeEditorContext::SingleEditMode );
}
else
{
context.setAttributeFormMode( QgsAttributeEditorContext::Mode::MultiEditMode );

//dummy feature
QgsFeature f( vl->fields() );
dialog = new QgsAttributeDialog( vl, &f, false, this, true, context );
dialog->setMode( QgsAttributeEditorContext::MultiEditMode );
}
dialog->setAttribute( Qt::WA_DeleteOnClose );
dialog->show();
}

0 comments on commit bad13f2

Please sign in to comment.