|
@@ -84,6 +84,39 @@ |
|
|
// canonical project instance |
|
|
QgsProject *QgsProject::sProject = nullptr; |
|
|
|
|
|
///@cond PRIVATE |
|
|
class ScopedIntIncrementor |
|
|
{ |
|
|
public: |
|
|
|
|
|
ScopedIntIncrementor( int *variable ) |
|
|
: mVariable( variable ) |
|
|
{ |
|
|
( *mVariable )++; |
|
|
} |
|
|
|
|
|
ScopedIntIncrementor( const ScopedIntIncrementor &other ) = delete; |
|
|
ScopedIntIncrementor &operator=( const ScopedIntIncrementor &other ) = delete; |
|
|
|
|
|
void release() |
|
|
{ |
|
|
if ( mVariable ) |
|
|
( *mVariable )--; |
|
|
|
|
|
mVariable = nullptr; |
|
|
} |
|
|
|
|
|
~ScopedIntIncrementor() |
|
|
{ |
|
|
release(); |
|
|
} |
|
|
|
|
|
private: |
|
|
int *mVariable = nullptr; |
|
|
}; |
|
|
///@endcond |
|
|
|
|
|
|
|
|
/** |
|
|
Take the given scope and key and convert them to a string list of key |
|
|
tokens that will be used to navigate through a Property hierarchy |
|
@@ -779,6 +812,8 @@ void QgsProject::setTransformContext( const QgsCoordinateTransformContext &conte |
|
|
|
|
|
void QgsProject::clear() |
|
|
{ |
|
|
ScopedIntIncrementor snapSingleBlocker( &mBlockSnappingUpdates ); |
|
|
|
|
|
QgsSettings settings; |
|
|
|
|
|
mProjectScope.reset(); |
|
@@ -816,7 +851,6 @@ void QgsProject::clear() |
|
|
mTimeSettings->reset(); |
|
|
mDisplaySettings->reset(); |
|
|
mSnappingConfig.reset(); |
|
|
emit snappingConfigChanged( mSnappingConfig ); |
|
|
emit avoidIntersectionsModeChanged(); |
|
|
emit topologicalEditingChanged(); |
|
|
|
|
@@ -857,11 +891,18 @@ void QgsProject::clear() |
|
|
int alpha = settings.value( QStringLiteral( "qgis/default_selection_color_alpha" ), 255 ).toInt(); |
|
|
setSelectionColor( QColor( red, green, blue, alpha ) ); |
|
|
|
|
|
mSnappingConfig.clearIndividualLayerSettings(); |
|
|
|
|
|
removeAllMapLayers(); |
|
|
mRootGroup->clear(); |
|
|
if ( mMainAnnotationLayer ) |
|
|
mMainAnnotationLayer->reset(); |
|
|
|
|
|
snapSingleBlocker.release(); |
|
|
|
|
|
if ( !mBlockSnappingUpdates ) |
|
|
emit snappingConfigChanged( mSnappingConfig ); |
|
|
|
|
|
setDirty( false ); |
|
|
emit homePathChanged(); |
|
|
emit cleared(); |
|
@@ -1280,6 +1321,9 @@ bool QgsProject::read( QgsProject::ReadFlags flags ) |
|
|
|
|
|
bool QgsProject::readProjectFile( const QString &filename, QgsProject::ReadFlags flags ) |
|
|
{ |
|
|
// avoid multiple emission of snapping updated signals |
|
|
ScopedIntIncrementor snapSignalBlock( &mBlockSnappingUpdates ); |
|
|
|
|
|
QFile projectFile( filename ); |
|
|
clearError(); |
|
|
|
|
@@ -1702,7 +1746,11 @@ bool QgsProject::readProjectFile( const QString &filename, QgsProject::ReadFlags |
|
|
emit readProjectWithContext( *doc, context ); |
|
|
|
|
|
profile.switchTask( tr( "Updating interface" ) ); |
|
|
emit snappingConfigChanged( mSnappingConfig ); |
|
|
|
|
|
snapSignalBlock.release(); |
|
|
if ( !mBlockSnappingUpdates ) |
|
|
emit snappingConfigChanged( mSnappingConfig ); |
|
|
|
|
|
emit avoidIntersectionsModeChanged(); |
|
|
emit topologicalEditingChanged(); |
|
|
emit projectColorsChanged(); |
|
@@ -2008,13 +2056,13 @@ void QgsProject::onMapLayersAdded( const QList<QgsMapLayer *> &layers ) |
|
|
} |
|
|
} |
|
|
|
|
|
if ( mSnappingConfig.addLayers( layers ) ) |
|
|
if ( !mBlockSnappingUpdates && mSnappingConfig.addLayers( layers ) ) |
|
|
emit snappingConfigChanged( mSnappingConfig ); |
|
|
} |
|
|
|
|
|
void QgsProject::onMapLayersRemoved( const QList<QgsMapLayer *> &layers ) |
|
|
{ |
|
|
if ( mSnappingConfig.removeLayers( layers ) ) |
|
|
if ( !mBlockSnappingUpdates && mSnappingConfig.removeLayers( layers ) ) |
|
|
emit snappingConfigChanged( mSnappingConfig ); |
|
|
} |
|
|
|
|
@@ -3422,8 +3470,17 @@ QgsAnnotationLayer *QgsProject::mainAnnotationLayer() |
|
|
|
|
|
void QgsProject::removeAllMapLayers() |
|
|
{ |
|
|
if ( mLayerStore->count() == 0 ) |
|
|
return; |
|
|
|
|
|
ScopedIntIncrementor snapSingleBlocker( &mBlockSnappingUpdates ); |
|
|
mProjectScope.reset(); |
|
|
mLayerStore->removeAllMapLayers(); |
|
|
|
|
|
snapSingleBlocker.release(); |
|
|
mSnappingConfig.clearIndividualLayerSettings(); |
|
|
if ( !mBlockSnappingUpdates ) |
|
|
emit snappingConfigChanged( mSnappingConfig ); |
|
|
} |
|
|
|
|
|
void QgsProject::reloadAllLayers() |
|
|