Skip to content
Permalink
Browse files

[dualview] Remove attrs from feature dialog when deleted (Fix #8504)

  • Loading branch information
m-kuhn committed Aug 23, 2013
1 parent a85d362 commit 6f574b41aedd9f7d00a9854bdbbd9b5209ef4e40
@@ -214,6 +214,8 @@ void QgsDualView::initLayerCache( QgsVectorLayer* layer )

mLayerCache->setFullCache( true );
}

connect( layer, SIGNAL( attributeDeleted( int ) ), this, SLOT( attributeDeleted( int ) ) );
}

void QgsDualView::initModels( QgsMapCanvas* mapCanvas )
@@ -380,6 +382,28 @@ void QgsDualView::previewExpressionChanged( const QString expression )
mLayerCache->layer()->setDisplayExpression( expression );
}

void QgsDualView::attributeDeleted( int attribute )
{
if ( mAttributeDialog && mAttributeDialog->dialog() )
{
// Let the dialog write the edited widget values to it's feature
mAttributeDialog->accept();
// Get the edited feature
QgsFeature* feat = mAttributeDialog->feature();
feat->deleteAttribute( attribute );

// Backup old dialog and delete only after creating the new dialog, so we can "hot-swap" the contained QgsFeature
QgsAttributeDialog* oldDialog = mAttributeDialog;

mAttributeEditorLayout->removeWidget( mAttributeDialog->dialog() );

mAttributeDialog = new QgsAttributeDialog( mLayerCache->layer(), new QgsFeature( *feat ), true, mDistanceArea, this, false );
mAttributeEditorLayout->addWidget( mAttributeDialog->dialog() );

delete oldDialog;
}
}

void QgsDualView::setFilteredFeatures( QgsFeatureIds filteredFeatures )
{
mFilterModel->setFilteredFeatures( filteredFeatures );
@@ -183,6 +183,14 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas

void previewExpressionChanged( const QString expression );

/**
* If an attribute on this layer is deleted, close any open editors
* (as long as the attribute dialog is not able to handle this problem)
*
* @param attribute The attribute being deleted
*/
void attributeDeleted( int attribute );

/**
* Will be called periodically, when loading layers from slow data providers.
*
@@ -53,7 +53,7 @@ class GUI_EXPORT QgsFeatureListView : public QListView
/**
* Destructor
*/
virtual ~QgsFeatureListView() {};
virtual ~QgsFeatureListView() {}

/**
* Returns the layer cache

0 comments on commit 6f574b4

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