mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Merge pull request #31863 from m-kuhn/gapCheckIgnoreMissingLayer
Gap check ignore missing layer
This commit is contained in:
commit
ff4f32db0d
@ -1398,6 +1398,14 @@ Sets the coordinate transform context to ``transformContext``
|
||||
|
||||
signals:
|
||||
|
||||
void beforeResolveReferences( QgsProject *project );
|
||||
%Docstring
|
||||
Emitted when all layers are loaded and references can be resolved,
|
||||
just before the references of this layer are resolved.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
void statusChanged( const QString &status );
|
||||
%Docstring
|
||||
Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
|
||||
|
@ -37,10 +37,13 @@ void QgsGeometryGapCheck::prepare( const QgsGeometryCheckContext *context, const
|
||||
if ( configuration.value( QStringLiteral( "allowedGapsEnabled" ) ).toBool() )
|
||||
{
|
||||
QgsVectorLayer *layer = context->project()->mapLayer<QgsVectorLayer *>( configuration.value( "allowedGapsLayer" ).toString() );
|
||||
mAllowedGapsLayer = layer;
|
||||
mAllowedGapsSource = qgis::make_unique<QgsVectorLayerFeatureSource>( layer );
|
||||
if ( layer )
|
||||
{
|
||||
mAllowedGapsLayer = layer;
|
||||
mAllowedGapsSource = qgis::make_unique<QgsVectorLayerFeatureSource>( layer );
|
||||
|
||||
mAllowedGapsBuffer = configuration.value( QStringLiteral( "allowedGapsBuffer" ) ).toDouble();
|
||||
mAllowedGapsBuffer = configuration.value( QStringLiteral( "allowedGapsBuffer" ) ).toDouble();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -27,6 +27,7 @@ email : matthias@opengis.ch
|
||||
#include "qgsreadwritelocker.h"
|
||||
#include "qgsmessagebar.h"
|
||||
#include "qgsmessagebaritem.h"
|
||||
#include "qgsmessagelog.h"
|
||||
|
||||
#include <QtConcurrent>
|
||||
#include <QFutureWatcher>
|
||||
@ -99,7 +100,10 @@ void QgsGeometryValidationService::onLayersAdded( const QList<QgsMapLayer *> &la
|
||||
mLayerChecks.remove( vectorLayer );
|
||||
} );
|
||||
|
||||
enableLayerChecks( vectorLayer );
|
||||
connect( vectorLayer, &QgsMapLayer::beforeResolveReferences, this, [this, vectorLayer]()
|
||||
{
|
||||
enableLayerChecks( vectorLayer );
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -273,9 +277,16 @@ void QgsGeometryValidationService::enableLayerChecks( QgsVectorLayer *layer )
|
||||
if ( checkConfiguration.value( QStringLiteral( "allowedGapsEnabled" ) ).toBool() )
|
||||
{
|
||||
QgsVectorLayer *gapsLayer = QgsProject::instance()->mapLayer<QgsVectorLayer *>( checkConfiguration.value( "allowedGapsLayer" ).toString() );
|
||||
connect( layer, &QgsVectorLayer::editingStarted, gapsLayer, [gapsLayer] { gapsLayer->startEditing(); } );
|
||||
connect( layer, &QgsVectorLayer::beforeRollBack, gapsLayer, [gapsLayer] { gapsLayer->rollBack(); } );
|
||||
connect( layer, &QgsVectorLayer::editingStopped, gapsLayer, [gapsLayer] { gapsLayer->commitChanges(); } );
|
||||
if ( gapsLayer )
|
||||
{
|
||||
connect( layer, &QgsVectorLayer::editingStarted, gapsLayer, [gapsLayer] { gapsLayer->startEditing(); } );
|
||||
connect( layer, &QgsVectorLayer::beforeRollBack, gapsLayer, [gapsLayer] { gapsLayer->rollBack(); } );
|
||||
connect( layer, &QgsVectorLayer::editingStopped, gapsLayer, [gapsLayer] { gapsLayer->commitChanges(); } );
|
||||
}
|
||||
else
|
||||
{
|
||||
QgsMessageLog::logMessage( tr( "Allowed gaps layer %1 configured but not loaded. Allowed gaps not working." ).arg( checkConfiguration.value( "allowedGapsLayer" ).toString() ), tr( "Geometry validation" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -612,6 +612,7 @@ QString QgsMapLayer::decodedSource( const QString &source, const QString &dataPr
|
||||
|
||||
void QgsMapLayer::resolveReferences( QgsProject *project )
|
||||
{
|
||||
emit beforeResolveReferences( project );
|
||||
if ( m3DRenderer )
|
||||
m3DRenderer->resolveReferences( *project );
|
||||
}
|
||||
|
@ -1254,6 +1254,14 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
* Emitted when all layers are loaded and references can be resolved,
|
||||
* just before the references of this layer are resolved.
|
||||
*
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
void beforeResolveReferences( QgsProject *project );
|
||||
|
||||
//! Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
|
||||
void statusChanged( const QString &status );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user