mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-30 00:29:39 -05:00
Add methods to clear recent crs or remove one crs
This commit is contained in:
parent
8282b6631e
commit
08bf81dbeb
@ -1123,6 +1123,20 @@ Pushes a recently used CRS to the top of the recent CRS list.
|
||||
.. versionadded:: 3.10.3
|
||||
%End
|
||||
|
||||
static void removeRecentCoordinateReferenceSystem( const QgsCoordinateReferenceSystem &crs );
|
||||
%Docstring
|
||||
Removes a CRS from the list of recently used CRS.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
static void clearRecentCoordinateReferenceSystems();
|
||||
%Docstring
|
||||
Cleans the list of recently used CRS.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
|
||||
static void invalidateCache();
|
||||
%Docstring
|
||||
|
||||
@ -2942,6 +2942,40 @@ void QgsCoordinateReferenceSystem::pushRecentCoordinateReferenceSystem( const Qg
|
||||
settings.setValue( QStringLiteral( "UI/recentProjectionsProj4" ), proj );
|
||||
}
|
||||
|
||||
|
||||
void QgsCoordinateReferenceSystem::removeRecentCoordinateReferenceSystem( const QgsCoordinateReferenceSystem &crs )
|
||||
{
|
||||
if ( crs.srsid() == 0 || !crs.isValid() )
|
||||
return;
|
||||
|
||||
QList<QgsCoordinateReferenceSystem> recent = recentCoordinateReferenceSystems();
|
||||
recent.removeAll( crs );
|
||||
QStringList authids;
|
||||
authids.reserve( recent.size() );
|
||||
QStringList proj;
|
||||
proj.reserve( recent.size() );
|
||||
QStringList wkt;
|
||||
wkt.reserve( recent.size() );
|
||||
for ( const QgsCoordinateReferenceSystem &c : std::as_const( recent ) )
|
||||
{
|
||||
authids << c.authid();
|
||||
proj << c.toProj();
|
||||
wkt << c.toWkt( WKT_PREFERRED );
|
||||
}
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "UI/recentProjectionsAuthId" ), authids );
|
||||
settings.setValue( QStringLiteral( "UI/recentProjectionsWkt" ), wkt );
|
||||
settings.setValue( QStringLiteral( "UI/recentProjectionsProj4" ), proj );
|
||||
}
|
||||
|
||||
void QgsCoordinateReferenceSystem::clearRecentCoordinateReferenceSystems()
|
||||
{
|
||||
QgsSettings settings;
|
||||
settings.remove( QStringLiteral( "UI/recentProjectionsAuthId" ) );
|
||||
settings.remove( QStringLiteral( "UI/recentProjectionsWkt" ) );
|
||||
settings.remove( QStringLiteral( "UI/recentProjectionsProj4" ) );
|
||||
}
|
||||
|
||||
void QgsCoordinateReferenceSystem::invalidateCache( bool disableCache )
|
||||
{
|
||||
sSrIdCacheLock()->lockForWrite();
|
||||
|
||||
@ -1063,6 +1063,18 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
|
||||
*/
|
||||
static void pushRecentCoordinateReferenceSystem( const QgsCoordinateReferenceSystem &crs );
|
||||
|
||||
/**
|
||||
* Removes a CRS from the list of recently used CRS.
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
static void removeRecentCoordinateReferenceSystem( const QgsCoordinateReferenceSystem &crs );
|
||||
|
||||
/**
|
||||
* Cleans the list of recently used CRS.
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
static void clearRecentCoordinateReferenceSystems();
|
||||
|
||||
#ifndef SIP_RUN
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user