Skip to content

Commit

Permalink
Merge branch 'master' of github.com:qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
pcav committed Aug 23, 2013
2 parents c9cf745 + 8aa7795 commit 5d49afb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/gui/attributetable/qgsdualview.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 );
Expand Down
9 changes: 9 additions & 0 deletions src/gui/attributetable/qgsdualview.h
Expand Up @@ -183,6 +183,15 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas

void previewExpressionChanged( const QString expression );

/**
* If an attribute on this layer is deleted, remove the field also for open
* attribute dialogs.
* (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.
*
Expand Down
2 changes: 1 addition & 1 deletion src/gui/attributetable/qgsfeaturelistview.h
Expand Up @@ -53,7 +53,7 @@ class GUI_EXPORT QgsFeatureListView : public QListView
/**
* Destructor
*/
virtual ~QgsFeatureListView() {};
virtual ~QgsFeatureListView() {}

/**
* Returns the layer cache
Expand Down

0 comments on commit 5d49afb

Please sign in to comment.