Skip to content

Commit

Permalink
avoid opening multiple attribute forms for a single feature in identify
Browse files Browse the repository at this point in the history
(fixes #13520)

On behalf of Faunalia, sponsored by ENEL
  • Loading branch information
jef-n committed Apr 20, 2017
1 parent 5eadc45 commit 7b8fb79
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/app/qgsfeatureaction.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );

Expand Down

0 comments on commit 7b8fb79

Please sign in to comment.