Skip to content

Commit

Permalink
When the "edit attributes of selected features" button is clicked
Browse files Browse the repository at this point in the history
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 bad13f2
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/app/qgisapp.cpp
Expand Up @@ -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();
}
Expand Down

0 comments on commit bad13f2

Please sign in to comment.