Skip to content
Permalink
Browse files

[bugfix] Update layer editable state when filter is changed

Fixes #17507 Unable to edit filtered GeoPackage layer

Backported from master #5691
  • Loading branch information
elpaso committed Nov 27, 2017
1 parent f206a75 commit 0577b2e64129b259fcff358e4094f0299f717775
Showing with 16 additions and 17 deletions.
  1. +12 −17 src/app/qgisapp.cpp
  2. +1 −0 src/app/qgsapplayertreeviewmenuprovider.cpp
  3. +3 −0 src/providers/ogr/qgsogrprovider.cpp
@@ -8273,17 +8273,13 @@ void QgisApp::layerSubsetString()
// Set the sql in the query builder to the same in the prop dialog
// (in case the user has already changed it)
qb->setSql( vlayer->subsetString() );
// Open the query builder
if ( qb->exec() )
// Open the query builder and refresh symbology if sql has changed
// Note: repaintRequested is emitted directly from QgsQueryBuilder
// when the sql is set in the layer.
if ( qb->exec() && ( subsetBefore != qb->sql() ) && mLayerTreeView )
{
if ( subsetBefore != qb->sql() )
{
vlayer->triggerRepaint();
if ( mLayerTreeView )
{
mLayerTreeView->refreshLayerSymbology( vlayer->id() );
}
}
mLayerTreeView->refreshLayerSymbology( vlayer->id() );
activateDeactivateLayerRelatedActions( vlayer );
}

// delete the query builder object
@@ -10257,13 +10253,12 @@ void QgisApp::layersWereAdded( const QList<QgsMapLayer *>& theLayers )
connect( vlayer, SIGNAL( labelingFontNotFound( QgsVectorLayer*, QString ) ), this, SLOT( labelingFontNotFound( QgsVectorLayer*, QString ) ) );

QgsVectorDataProvider* vProvider = vlayer->dataProvider();
if ( vProvider && vProvider->capabilities() & QgsVectorDataProvider::EditingCapabilities )
{
connect( vlayer, SIGNAL( layerModified() ), this, SLOT( updateLayerModifiedActions() ) );
connect( vlayer, SIGNAL( editingStarted() ), this, SLOT( layerEditStateChanged() ) );
connect( vlayer, SIGNAL( editingStopped() ), this, SLOT( layerEditStateChanged() ) );
}

// Do not check for layer editing capabilities because they may change
// (for example when subsetString is added/removed) and signals need to
// be in place in order to update the GUI
connect( vlayer, SIGNAL( layerModified() ), this, SLOT( updateLayerModifiedActions() ) );
connect( vlayer, SIGNAL( editingStarted() ), this, SLOT( layerEditStateChanged() ) );
connect( vlayer, SIGNAL( editingStopped() ), this, SLOT( layerEditStateChanged() ) );
connect( vlayer, SIGNAL( raiseError( QString ) ), this, SLOT( onLayerError( QString ) ) );

provider = vProvider;
@@ -216,6 +216,7 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
{
menu->addAction( toggleEditingAction );
toggleEditingAction->setChecked( vlayer->isEditable() );
toggleEditingAction->setEnabled( true );
}
if ( saveLayerEditsAction && vlayer->isModified() )
{
@@ -580,6 +580,9 @@ bool QgsOgrProvider::setSubsetString( const QString& theSQL, bool updateFeatureC

invalidateCachedExtent( false );

// Changing the filter may change capabilities
computeCapabilities();

emit dataChanged();

return true;

0 comments on commit 0577b2e

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