Skip to content
Permalink
Browse files
avoid opening multiple attribute forms for a single feature in identify
(fixes #13520)

On behalf of Faunalia, sponsored by ENEL
  • Loading branch information
jef-n committed Apr 20, 2017
1 parent 5eadc45 commit 7b8fb793cf63483477b8af1670541aca033e8ab9
Showing with 24 additions and 4 deletions.
  1. +24 −4 src/app/qgsfeatureaction.cpp
@@ -63,6 +63,7 @@ QgsAttributeDialog *QgsFeatureAction::newDialog( bool cloneFeature )

QgsAttributeDialog *dialog = new QgsAttributeDialog( mLayer, f, cloneFeature, parentWidget(), true, context );
dialog->setWindowFlags( dialog->windowFlags() | Qt::Tool );
dialog->setObjectName( QString( "featureactiondlg:%1:%2" ).arg( mLayer->id(), f->id() ) );

if ( mLayer->actions()->size() > 0 )
{
@@ -95,10 +96,19 @@ QgsAttributeDialog *QgsFeatureAction::newDialog( bool cloneFeature )

bool QgsFeatureAction::viewFeatureForm( QgsHighlight *h )
{
if ( !mLayer )
if ( !mLayer || !mFeature )
return false;

QgsAttributeDialog *dialog = newDialog( true );
QString name( QString( "featureactiondlg:%1:%2" ).arg( mLayer->id(), mFeature->id() ) );

QgsAttributeDialog *dialog = QgisApp::instance()->findChild<QgsAttributeDialog *>( name );
if ( dialog )
{
dialog->raise();
return true;
}

dialog = newDialog( true );
dialog->setHighlight( h );
// delete the dialog when it is closed
dialog->setAttribute( Qt::WA_DeleteOnClose );
@@ -125,7 +135,16 @@ bool QgsFeatureAction::editFeature( bool showModal )
}
else
{
QgsAttributeDialog* dialog = newDialog( false );
QString name( QString( "featureactiondlg:%1:%2" ).arg( mLayer->id(), mFeature->id() ) );

QgsAttributeDialog *dialog = QgisApp::instance()->findChild<QgsAttributeDialog *>( name );
if ( dialog )
{
dialog->raise();
return true;
}

dialog = newDialog( false );

if ( !mFeature->isValid() )
dialog->setMode( QgsAttributeForm::AddFeatureMode );
@@ -151,7 +170,8 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes, boo
QgsDebugMsg( QString( "reuseLastValues: %1" ).arg( reuseLastValues ) );

QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
context
<< QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mLayer );

0 comments on commit 7b8fb79

Please sign in to comment.