Skip to content
Permalink
Browse files

Merge pull request #5691 from elpaso/bugfix-17507-gpkg-filtered-edit

[app][bugfix] Update layer editable state when filter is changed
  • Loading branch information
elpaso committed Nov 22, 2017
2 parents 059c997 + d775a0d commit db3c93c3a65126fc8ed8daf71dc38db6aa6d8bd0
@@ -8928,27 +8928,20 @@ void QgisApp::layerSubsetString()
}

// launch the query builder
QgsQueryBuilder *qb = new QgsQueryBuilder( vlayer, this );
std::unique_ptr<QgsQueryBuilder> qb( new QgsQueryBuilder( vlayer, this ) );
QString subsetBefore = vlayer->subsetString();

// 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
delete qb;
}

void QgisApp::saveLastMousePosition( const QgsPointXY &p )
@@ -11097,14 +11090,13 @@ void QgisApp::layersWereAdded( const QList<QgsMapLayer *> &layers )
connect( vlayer, &QgsVectorLayer::labelingFontNotFound, this, &QgisApp::labelingFontNotFound );

QgsVectorDataProvider *vProvider = vlayer->dataProvider();
if ( vProvider && vProvider->capabilities() & QgsVectorDataProvider::EditingCapabilities )
{
connect( vlayer, &QgsVectorLayer::layerModified, this, &QgisApp::updateLayerModifiedActions );
connect( vlayer, &QgsVectorLayer::editingStarted, this, &QgisApp::layerEditStateChanged );
connect( vlayer, &QgsVectorLayer::editingStopped, this, &QgisApp::layerEditStateChanged );
connect( vlayer, &QgsVectorLayer::readOnlyChanged, this, &QgisApp::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, &QgsVectorLayer::layerModified, this, &QgisApp::updateLayerModifiedActions );
connect( vlayer, &QgsVectorLayer::editingStarted, this, &QgisApp::layerEditStateChanged );
connect( vlayer, &QgsVectorLayer::editingStopped, this, &QgisApp::layerEditStateChanged );
connect( vlayer, &QgsVectorLayer::readOnlyChanged, this, &QgisApp::layerEditStateChanged );
connect( vlayer, &QgsVectorLayer::raiseError, this, &QgisApp::onLayerError );

provider = vProvider;
@@ -689,7 +689,13 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! mark project dirty
void markDirty();

void layersWereAdded( const QList<QgsMapLayer *> & );
/**
* \brief layersWereAdded is triggered when layers were added
* This method loops through the list of \a layers and connect all
* application signals that need to listen to layer events.
* \param layers list of map layers that have been added
*/
void layersWereAdded( const QList<QgsMapLayer *> &layers );

/* layer will be removed - changed from removingLayer to removingLayers
in 1.8.
@@ -226,6 +226,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
{
menu->addAction( toggleEditingAction );
toggleEditingAction->setChecked( vlayer->isEditable() );
toggleEditingAction->setEnabled( true );
}
if ( saveLayerEditsAction && vlayer->isModified() )
{
@@ -346,10 +346,10 @@ class GUI_EXPORT QgsEditorWidgetWrapper : public QgsWidgetWrapper
QString mConstraintFailureReason;

//! The current constraint result
ConstraintResult mConstraintResult;
ConstraintResult mConstraintResult = ConstraintResultPass;

//! The current constraint result
bool mConstraintResultVisible;
bool mConstraintResultVisible = false;

int mFieldIdx;
QgsFeature mFeature;
@@ -89,7 +89,7 @@ class GUI_EXPORT QgsAggregateToolButton : public QToolButton
private:
void updateAvailableAggregates();
QMenu *mMenu = nullptr;
QVariant::Type mType;
QVariant::Type mType = QVariant::Invalid;
bool mActive = false;
QString mAggregate;
QList<QgsAggregateCalculator::AggregateInfo> mAvailableAggregates;
@@ -573,12 +573,15 @@ bool QgsOgrProvider::setSubsetString( const QString &theSQL, bool updateFeatureC
}

// check the validity of the layer
QgsDebugMsg( "checking validity" );
QgsDebugMsgLevel( "checking validity", 4 );
loadFields();
QgsDebugMsg( "Done checking validity" );
QgsDebugMsgLevel( "Done checking validity", 4 );

invalidateCachedExtent( false );

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

emit dataChanged();

return true;

0 comments on commit db3c93c

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