Skip to content
Permalink
Browse files

Don't double add features

Fix #10969
  • Loading branch information
m-kuhn committed Jul 30, 2014
1 parent 4506b81 commit 3e53c392613e932478f2446325f412b6e618c1b9
Showing with 15 additions and 1 deletion.
  1. +1 −0 src/gui/qgsattributedialog.cpp
  2. +8 −1 src/gui/qgsattributeform.cpp
  3. +6 −0 src/gui/qgsattributeform.h
@@ -102,6 +102,7 @@ void QgsAttributeDialog::init( QgsVectorLayer* layer, QgsFeature* feature, QgsAt
setLayout( new QGridLayout() );
layout()->setMargin( 0 );
mAttributeForm = new QgsAttributeForm( layer, *feature, context, parent );
mAttributeForm->disconnectButtonBox();
layout()->addWidget( mAttributeForm );
QDialogButtonBox* buttonBox = mAttributeForm->findChild<QDialogButtonBox*>();
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
@@ -65,7 +65,8 @@ void QgsAttributeForm::hideButtonBox()
mButtonBox->hide();

// Make sure that changes are taken into account if somebody tries to figure out if there have been some
connect( mLayer, SIGNAL( beforeModifiedCheck() ), this, SLOT( save() ) );
if ( !mIsAddDialog )
connect( mLayer, SIGNAL( beforeModifiedCheck() ), this, SLOT( save() ) );
}

void QgsAttributeForm::showButtonBox()
@@ -75,6 +76,12 @@ void QgsAttributeForm::showButtonBox()
disconnect( mLayer, SIGNAL( beforeModifiedCheck() ), this, SLOT( save() ) );
}

void QgsAttributeForm::disconnectButtonBox()
{
disconnect( mButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
disconnect( mButtonBox, SIGNAL( rejected() ), this, SLOT( resetValues() ) );
}

void QgsAttributeForm::addInterface( QgsAttributeFormInterface* iface )
{
mInterfaces.append( iface );
@@ -46,6 +46,12 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
*/
void showButtonBox();

/**
* Disconnects the button box (Ok/Cancel) from the accept/resetValues slots
* If this method is called, you have to create these connections from outside
*/
void disconnectButtonBox();

/**
* Takes ownership
* @param iface

0 comments on commit 3e53c39

Please sign in to comment.
You can’t perform that action at this time.