Skip to content

Commit 5d49afb

Browse files
committedAug 23, 2013
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents c9cf745 + 8aa7795 commit 5d49afb

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed
 

‎src/gui/attributetable/qgsdualview.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ void QgsDualView::initLayerCache( QgsVectorLayer* layer )
214214

215215
mLayerCache->setFullCache( true );
216216
}
217+
218+
connect( layer, SIGNAL( attributeDeleted( int ) ), this, SLOT( attributeDeleted( int ) ) );
217219
}
218220

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

385+
void QgsDualView::attributeDeleted( int attribute )
386+
{
387+
if ( mAttributeDialog && mAttributeDialog->dialog() )
388+
{
389+
// Let the dialog write the edited widget values to it's feature
390+
mAttributeDialog->accept();
391+
// Get the edited feature
392+
QgsFeature* feat = mAttributeDialog->feature();
393+
feat->deleteAttribute( attribute );
394+
395+
// Backup old dialog and delete only after creating the new dialog, so we can "hot-swap" the contained QgsFeature
396+
QgsAttributeDialog* oldDialog = mAttributeDialog;
397+
398+
mAttributeEditorLayout->removeWidget( mAttributeDialog->dialog() );
399+
400+
mAttributeDialog = new QgsAttributeDialog( mLayerCache->layer(), new QgsFeature( *feat ), true, mDistanceArea, this, false );
401+
mAttributeEditorLayout->addWidget( mAttributeDialog->dialog() );
402+
403+
delete oldDialog;
404+
}
405+
}
406+
383407
void QgsDualView::setFilteredFeatures( QgsFeatureIds filteredFeatures )
384408
{
385409
mFilterModel->setFilteredFeatures( filteredFeatures );

‎src/gui/attributetable/qgsdualview.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
183183

184184
void previewExpressionChanged( const QString expression );
185185

186+
/**
187+
* If an attribute on this layer is deleted, remove the field also for open
188+
* attribute dialogs.
189+
* (as long as the attribute dialog is not able to handle this problem)
190+
*
191+
* @param attribute The attribute being deleted
192+
*/
193+
void attributeDeleted( int attribute );
194+
186195
/**
187196
* Will be called periodically, when loading layers from slow data providers.
188197
*

‎src/gui/attributetable/qgsfeaturelistview.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class GUI_EXPORT QgsFeatureListView : public QListView
5353
/**
5454
* Destructor
5555
*/
56-
virtual ~QgsFeatureListView() {};
56+
virtual ~QgsFeatureListView() {}
5757

5858
/**
5959
* Returns the layer cache

0 commit comments

Comments
 (0)
Please sign in to comment.