Skip to content

Commit

Permalink
migrate XYZ settings + fix some migration + fix dox + fix QgsSettings…
Browse files Browse the repository at this point in the history
…TreeNamedList::items
  • Loading branch information
3nids committed Jan 16, 2023
1 parent 8444a9b commit 6a043ed
Show file tree
Hide file tree
Showing 31 changed files with 500 additions and 494 deletions.
6 changes: 3 additions & 3 deletions python/core/auto_additions/qgssettingstreeelement.py
@@ -1,9 +1,9 @@
# The following has been generated automatically from src/core/settings/qgssettingstreeelement.h
# monkey patching scoped based enum
QgsSettingsTreeElement.Type.Root.__doc__ = ""
QgsSettingsTreeElement.Type.Normal.__doc__ = ""
QgsSettingsTreeElement.Type.Root.__doc__ = "Root Element"
QgsSettingsTreeElement.Type.Standard.__doc__ = "Normal Element"
QgsSettingsTreeElement.Type.NamedList.__doc__ = ""
QgsSettingsTreeElement.Type.__doc__ = '\n\n' + '* ``Root``: ' + QgsSettingsTreeElement.Type.Root.__doc__ + '\n' + '* ``Normal``: ' + QgsSettingsTreeElement.Type.Normal.__doc__ + '\n' + '* ``NamedList``: ' + QgsSettingsTreeElement.Type.NamedList.__doc__
QgsSettingsTreeElement.Type.__doc__ = 'Type of tree element\n\n' + '* ``Root``: ' + QgsSettingsTreeElement.Type.Root.__doc__ + '\n' + '* ``Standard``: ' + QgsSettingsTreeElement.Type.Standard.__doc__ + '\n' + '* ``NamedList``: ' + QgsSettingsTreeElement.Type.NamedList.__doc__
# --
QgsSettingsTreeElement.Type.baseClass = QgsSettingsTreeElement
# monkey patching scoped based enum
Expand Down
1 change: 1 addition & 0 deletions python/core/auto_generated/qgsowsconnection.sip.in
Expand Up @@ -11,6 +11,7 @@




class QgsOwsConnection : QObject
{
%Docstring(signature="appended")
Expand Down
Expand Up @@ -32,11 +32,6 @@ Constructor for QgsSettingsRegistryCore.

virtual ~QgsSettingsRegistryCore();


void migrateOldSettings();

void backwardCompatibility();

};

/************************************************************************
Expand Down
Expand Up @@ -38,7 +38,7 @@ to automatically register a settings entry on its creation when a parent is prov
enum class Type
{
Root,
Normal,
Standard,
NamedList,
};

Expand Down Expand Up @@ -140,7 +140,6 @@ Returns the number of named elements in the complete key
Registers a child elements
%End

void init( QgsSettingsTreeElement *parent, const QString &key );


private:
Expand Down Expand Up @@ -213,6 +212,9 @@ Deletes a named entry from the named list element
%End

QgsSettingsEntryString *selectedItemSetting() const;
%Docstring
Returns the setting used to store the selected item
%End

protected:
void initNamedList( const QgsSettingsTreeElement::Options &options );
Expand Down
2 changes: 1 addition & 1 deletion python/gui/auto_generated/qgshttpheaderwidget.sip.in
Expand Up @@ -47,7 +47,7 @@ fill the inner header map from the settings defined at ``key``
:param key:
%End

void updateSettings( QgsSettings &settings, const QString &key ) const;
void updateSettings( QgsSettings &settings, const QString &key ) const /Deprecated/;
%Docstring
update the ``settings`` with the http headers present in the inner map.

Expand Down
13 changes: 5 additions & 8 deletions src/core/geocms/geonode/qgsgeonodeconnection.cpp
Expand Up @@ -24,18 +24,18 @@ const QString QgsGeoNodeConnectionUtils::sGeoNodeConnection = QStringLiteral( "G
QgsGeoNodeConnection::QgsGeoNodeConnection( const QString &name )
: mConnName( name )
{
mUri.setParam( QStringLiteral( "url" ), QgsOwsConnection::settingsConnectionUrl->value( {QgsGeoNodeConnectionUtils::sGeoNodeConnection.toLower(), mConnName} ) );
mUri.setParam( QStringLiteral( "url" ), QgsOwsConnection::settingsUrl->value( {QgsGeoNodeConnectionUtils::sGeoNodeConnection.toLower(), mConnName} ) );

// Check for credentials and prepend to the connection info
const QString username = QgsOwsConnection::settingsConnectionUsername->value( {QgsGeoNodeConnectionUtils::sGeoNodeConnection, mConnName} );
const QString password = QgsOwsConnection::settingsConnectionPassword->value( {QgsGeoNodeConnectionUtils::sGeoNodeConnection, mConnName} );
const QString username = QgsOwsConnection::settingsUsername->value( {QgsGeoNodeConnectionUtils::sGeoNodeConnection, mConnName} );
const QString password = QgsOwsConnection::settingsPassword->value( {QgsGeoNodeConnectionUtils::sGeoNodeConnection, mConnName} );
if ( !username.isEmpty() )
{
mUri.setUsername( username );
mUri.setPassword( password );
}

const QString authcfg = QgsOwsConnection::settingsConnectionAuthCfg->value( {QgsGeoNodeConnectionUtils::sGeoNodeConnection, mConnName} );
const QString authcfg = QgsOwsConnection::settingsAuthCfg->value( {QgsGeoNodeConnectionUtils::sGeoNodeConnection, mConnName} );
if ( !authcfg.isEmpty() )
{
mUri.setAuthConfigId( authcfg );
Expand Down Expand Up @@ -89,10 +89,7 @@ QgsDataSourceUri &QgsGeoNodeConnection::addWcsConnectionSettings( QgsDataSourceU

QStringList QgsGeoNodeConnectionUtils::connectionList()
{
QgsSettings settings;
// Add Section manually
settings.beginGroup( QStringLiteral( "qgis/connections-geonode" ) );
return settings.childGroups();
return QgsOwsConnection::sTreeOwsConnections->items( {QStringLiteral( "geonode" )} );
}

void QgsGeoNodeConnectionUtils::deleteConnection( const QString &name )
Expand Down
38 changes: 19 additions & 19 deletions src/core/qgsowsconnection.cpp
Expand Up @@ -38,28 +38,28 @@ QgsOwsConnection::QgsOwsConnection( const QString &service, const QString &connN
{
QgsDebugMsgLevel( "theConnName = " + connName, 4 );

const QString url = settingsConnectionUrl->value( {mService.toLower(), mConnName} );
const QString url = settingsUrl->value( {mService.toLower(), mConnName} );
mConnectionInfo = url;
mUri.setParam( QStringLiteral( "url" ), url );

// Check for credentials and prepend to the connection info
const QString username = settingsConnectionUsername->value( {mService, mConnName} );
const QString password = settingsConnectionPassword->value( {mService, mConnName} );
const QString username = settingsUsername->value( {mService, mConnName} );
const QString password = settingsPassword->value( {mService, mConnName} );
if ( !username.isEmpty() )
{
// check for a password, if none prompt to get it
mUri.setUsername( username );
mUri.setPassword( password );
}

const QString authcfg = settingsConnectionAuthCfg->value( {mService, mConnName} );
const QString authcfg = settingsAuthCfg->value( {mService, mConnName} );
if ( !authcfg.isEmpty() )
{
mUri.setAuthConfigId( authcfg );
}
mConnectionInfo.append( ",authcfg=" + authcfg );

QgsHttpHeaders httpHeaders( settingsConnectionHeaders->value( {mService.toLower(), mConnName} ) );
QgsHttpHeaders httpHeaders( settingsHeaders->value( {mService.toLower(), mConnName} ) );
mUri.setHttpHeaders( httpHeaders );
const QString referer = httpHeaders[QgsHttpHeaders::KEY_REFERER].toString();
if ( !referer.isEmpty() )
Expand Down Expand Up @@ -143,31 +143,31 @@ QgsDataSourceUri &QgsOwsConnection::addWmsWcsConnectionSettings( QgsDataSourceUr
{
addCommonConnectionSettings( uri, service, connName );

settingsConnectionHeaders->setValue( uri.httpHeaders().headers(), {service.toLower(), connName} );
settingsHeaders->setValue( uri.httpHeaders().headers(), {service.toLower(), connName} );

if ( settingsConnectionIgnoreGetMapURI->value( {service.toLower(), connName} ) )
if ( settingsIgnoreGetMapURI->value( {service.toLower(), connName} ) )
{
uri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), QStringLiteral( "1" ) );
}
if ( settingsConnectionIgnoreGetFeatureInfoURI->value( {service.toLower(), connName} ) )
if ( settingsIgnoreGetFeatureInfoURI->value( {service.toLower(), connName} ) )
{
uri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), QStringLiteral( "1" ) );
}
if ( settingsConnectionSmoothPixmapTransform->value( {service.toLower(), connName} ) )
if ( settingsSmoothPixmapTransform->value( {service.toLower(), connName} ) )
{
uri.setParam( QStringLiteral( "SmoothPixmapTransform" ), QStringLiteral( "1" ) );
}
if ( settingsConnectionReportedLayerExtents->value( {service.toLower(), connName} ) )
if ( settingsReportedLayerExtents->value( {service.toLower(), connName} ) )
{
uri.setParam( QStringLiteral( "IgnoreReportedLayerExtents" ), QStringLiteral( "1" ) );
}
if ( settingsConnectionDpiMode->exists( {service.toLower(), connName} ) )
if ( settingsDpiMode->exists( {service.toLower(), connName} ) )
{
uri.setParam( QStringLiteral( "dpiMode" ), QString::number( static_cast<int>( settingsConnectionDpiMode->value( {service.toLower(), connName} ) ) ) );
uri.setParam( QStringLiteral( "dpiMode" ), QString::number( static_cast<int>( settingsDpiMode->value( {service.toLower(), connName} ) ) ) );
}
if ( settingsConnectionTilePixelRatio->exists( {service.toLower(), connName} ) )
if ( settingsTilePixelRatio->exists( {service.toLower(), connName} ) )
{
uri.setParam( QStringLiteral( "tilePixelRatio" ), QString::number( static_cast<int>( settingsConnectionTilePixelRatio->value( {service.toLower(), connName} ) ) ) );
uri.setParam( QStringLiteral( "tilePixelRatio" ), QString::number( static_cast<int>( settingsTilePixelRatio->value( {service.toLower(), connName} ) ) ) );
}

return uri;
Expand Down Expand Up @@ -199,13 +199,13 @@ QgsDataSourceUri &QgsOwsConnection::addWfsConnectionSettings( QgsDataSourceUri &
{
addCommonConnectionSettings( uri, service, connName );

const QString version = settingsConnectionVersion->value( {service.toLower(), connName} );
const QString version = settingsVersion->value( {service.toLower(), connName} );
if ( !version.isEmpty() )
{
uri.setParam( QStringLiteral( "version" ), version );
}

const QString maxnumFeatures = settingsConnectionMaxNumFeatures->value( {service.toLower(), connName} );
const QString maxnumFeatures = settingsMaxNumFeatures->value( {service.toLower(), connName} );
if ( !maxnumFeatures.isEmpty() )
{
uri.setParam( QStringLiteral( "maxNumFeatures" ), maxnumFeatures );
Expand Down Expand Up @@ -250,17 +250,17 @@ void QgsOwsConnection::addCommonConnectionSettings( QgsDataSourceUri &uri, const
void QgsOwsConnection::addCommonConnectionSettings( QgsDataSourceUri &uri, const QString &service, const QString &connectionName )
{

if ( settingsConnectionIgnoreAxisOrientation->value( {service.toLower(), connectionName} ) )
if ( settingsIgnoreAxisOrientation->value( {service.toLower(), connectionName} ) )
{
uri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), QStringLiteral( "1" ) );
}
if ( settingsConnectionInvertAxisOrientation->value( {service.toLower(), connectionName} ) )
if ( settingsInvertAxisOrientation->value( {service.toLower(), connectionName} ) )
{
uri.setParam( QStringLiteral( "InvertAxisOrientation" ), QStringLiteral( "1" ) );
}
}

void QgsOwsConnection::deleteConnection( const QString &service, const QString &name )
{
sTreeConnectionServices->deleteItem( service.toLower(), {name} );
sTreeOwsConnections->deleteItem( service.toLower(), {name} );
}
65 changes: 43 additions & 22 deletions src/core/qgsowsconnection.h
Expand Up @@ -30,6 +30,28 @@
#include <QStringList>
#include <QPushButton>

/**
* \ingroup core
* \brief Connections settingss for XYZ
*/
class CORE_EXPORT QgsXyzConnectionSettings SIP_SKIP
{
public:
static inline QgsSettingsTreeNamedListElement *sTreeXyzConnections = QgsSettings::sTtreeConnections->createNamedListElement( QStringLiteral( "xyz" ), QgsSettingsTreeElement::Option::NamedListSelectedItemSetting );

static inline QgsSettingsEntryString *settingsUrl = new QgsSettingsEntryString( QStringLiteral( "url" ), sTreeXyzConnections, QString() ) ;
static inline QgsSettingsEntryVariantMap *settingsHeaders = new QgsSettingsEntryVariantMap( QStringLiteral( "http-header" ), sTreeXyzConnections ) ;
static inline QgsSettingsEntryInteger *settingsZmin = new QgsSettingsEntryInteger( QStringLiteral( "zmin" ), sTreeXyzConnections, -1 );
static inline QgsSettingsEntryInteger *settingsZmax = new QgsSettingsEntryInteger( QStringLiteral( "zmax" ), sTreeXyzConnections, -1 );
static inline QgsSettingsEntryDouble *settingsTilePixelRatio = new QgsSettingsEntryDouble( QStringLiteral( "tilePixelRatio" ), sTreeXyzConnections, 0, QStringLiteral( "0 = unknown (not scaled), 1.0 = 256x256, 2.0 = 512x512" ) ) ;
static inline QgsSettingsEntryBool *settingsHidden = new QgsSettingsEntryBool( QStringLiteral( "hidden" ), sTreeXyzConnections, false ) ;
static inline QgsSettingsEntryString *settingsInterpretation = new QgsSettingsEntryString( QStringLiteral( "interpretation" ), sTreeXyzConnections, QString() ) ;

static inline QgsSettingsEntryString *settingsUsername = new QgsSettingsEntryString( QStringLiteral( "username" ), sTreeXyzConnections ) ;
static inline QgsSettingsEntryString *settingsPassword = new QgsSettingsEntryString( QStringLiteral( "password" ), sTreeXyzConnections ) ;
static inline QgsSettingsEntryString *settingsAuthcfg = new QgsSettingsEntryString( QStringLiteral( "authcfg" ), sTreeXyzConnections ) ;
};


/**
* \ingroup core
Expand All @@ -42,28 +64,27 @@ class CORE_EXPORT QgsOwsConnection : public QObject
public:

#ifndef SIP_RUN
static inline QgsSettingsTreeNamedListElement *sTtreeOwsConnections = QgsSettings::sTtreeConnections->createNamedListElement( QStringLiteral( "ows" ) );
static inline QgsSettingsTreeNamedListElement *sTreeConnectionServices = sTtreeOwsConnections->createNamedListElement( QStringLiteral( "services" ) );

static inline QgsSettingsEntryString *settingsConnectionUrl = new QgsSettingsEntryString( QStringLiteral( "url" ), sTreeConnectionServices, QString() ) ;
static inline QgsSettingsEntryVariantMap *settingsConnectionHeaders = new QgsSettingsEntryVariantMap( QStringLiteral( "http-header" ), sTreeConnectionServices ) ;
static inline QgsSettingsEntryString *settingsConnectionVersion = new QgsSettingsEntryString( QStringLiteral( "version" ), sTreeConnectionServices, QString() ) ;
static inline QgsSettingsEntryBool *settingsConnectionIgnoreGetMapURI = new QgsSettingsEntryBool( QStringLiteral( "ignoreGetMapURI" ), sTreeConnectionServices, false ) ;
static inline QgsSettingsEntryBool *settingsConnectionIgnoreGetFeatureInfoURI = new QgsSettingsEntryBool( QStringLiteral( "ignoreGetFeatureInfoURI" ), sTreeConnectionServices, false ) ;
static inline QgsSettingsEntryBool *settingsConnectionSmoothPixmapTransform = new QgsSettingsEntryBool( QStringLiteral( "smoothPixmapTransform" ), sTreeConnectionServices, false ) ;
static inline QgsSettingsEntryBool *settingsConnectionReportedLayerExtents = new QgsSettingsEntryBool( QStringLiteral( "reportedLayerExtents" ), sTreeConnectionServices, false ) ;
static inline QgsSettingsEntryEnumFlag<Qgis::DpiMode> *settingsConnectionDpiMode = new QgsSettingsEntryEnumFlag<Qgis::DpiMode>( QStringLiteral( "dpiMode" ), sTreeConnectionServices, Qgis::DpiMode::All, QString(), Qgis::SettingsOption::SaveEnumFlagAsInt ) ;
static inline QgsSettingsEntryEnumFlag<Qgis::TilePixelRatio> *settingsConnectionTilePixelRatio = new QgsSettingsEntryEnumFlag<Qgis::TilePixelRatio>( QStringLiteral( "tilePixelRatio" ), sTreeConnectionServices, Qgis::TilePixelRatio::Undefined, QString(), Qgis::SettingsOption::SaveEnumFlagAsInt ) ;
static inline QgsSettingsEntryString *settingsConnectionMaxNumFeatures = new QgsSettingsEntryString( QStringLiteral( "maxnumfeatures" ), sTreeConnectionServices ) ;
static inline QgsSettingsEntryString *settingsConnectionPagesize = new QgsSettingsEntryString( QStringLiteral( "pagesize" ), sTreeConnectionServices ) ;
static inline QgsSettingsEntryBool *settingsConnectionPagingEnabled = new QgsSettingsEntryBool( QStringLiteral( "pagingenabled" ), sTreeConnectionServices, true ) ;
static inline QgsSettingsEntryBool *settingsConnectionPreferCoordinatesForWfsT11 = new QgsSettingsEntryBool( QStringLiteral( "preferCoordinatesForWfsT11" ), sTreeConnectionServices, false ) ;
static inline QgsSettingsEntryBool *settingsConnectionIgnoreAxisOrientation = new QgsSettingsEntryBool( QStringLiteral( "ignoreAxisOrientation" ), sTreeConnectionServices, false ) ;
static inline QgsSettingsEntryBool *settingsConnectionInvertAxisOrientation = new QgsSettingsEntryBool( QStringLiteral( "invertAxisOrientation" ), sTreeConnectionServices, false ) ;

static inline QgsSettingsEntryString *settingsConnectionUsername = new QgsSettingsEntryString( QStringLiteral( "username" ), sTreeConnectionServices ) ;
static inline QgsSettingsEntryString *settingsConnectionPassword = new QgsSettingsEntryString( QStringLiteral( "password" ), sTreeConnectionServices ) ;
static inline QgsSettingsEntryString *settingsConnectionAuthCfg = new QgsSettingsEntryString( QStringLiteral( "authcfg" ), sTreeConnectionServices ) ;
static inline QgsSettingsTreeNamedListElement *sTtreeOwsServices = QgsSettings::sTtreeConnections->createNamedListElement( QStringLiteral( "ows" ) );
static inline QgsSettingsTreeNamedListElement *sTreeOwsConnections = sTtreeOwsServices->createNamedListElement( QStringLiteral( "connections" ) );

static inline QgsSettingsEntryString *settingsUrl = new QgsSettingsEntryString( QStringLiteral( "url" ), sTreeOwsConnections, QString() ) ;
static inline QgsSettingsEntryVariantMap *settingsHeaders = new QgsSettingsEntryVariantMap( QStringLiteral( "http-header" ), sTreeOwsConnections ) ;
static inline QgsSettingsEntryString *settingsVersion = new QgsSettingsEntryString( QStringLiteral( "version" ), sTreeOwsConnections, QString() ) ;
static inline QgsSettingsEntryBool *settingsIgnoreGetMapURI = new QgsSettingsEntryBool( QStringLiteral( "ignoreGetMapURI" ), sTreeOwsConnections, false ) ;
static inline QgsSettingsEntryBool *settingsIgnoreGetFeatureInfoURI = new QgsSettingsEntryBool( QStringLiteral( "ignoreGetFeatureInfoURI" ), sTreeOwsConnections, false ) ;
static inline QgsSettingsEntryBool *settingsSmoothPixmapTransform = new QgsSettingsEntryBool( QStringLiteral( "smoothPixmapTransform" ), sTreeOwsConnections, false ) ;
static inline QgsSettingsEntryBool *settingsReportedLayerExtents = new QgsSettingsEntryBool( QStringLiteral( "reportedLayerExtents" ), sTreeOwsConnections, false ) ;
static inline QgsSettingsEntryEnumFlag<Qgis::DpiMode> *settingsDpiMode = new QgsSettingsEntryEnumFlag<Qgis::DpiMode>( QStringLiteral( "dpiMode" ), sTreeOwsConnections, Qgis::DpiMode::All, QString(), Qgis::SettingsOption::SaveEnumFlagAsInt ) ;
static inline QgsSettingsEntryEnumFlag<Qgis::TilePixelRatio> *settingsTilePixelRatio = new QgsSettingsEntryEnumFlag<Qgis::TilePixelRatio>( QStringLiteral( "tilePixelRatio" ), sTreeOwsConnections, Qgis::TilePixelRatio::Undefined, QString(), Qgis::SettingsOption::SaveEnumFlagAsInt ) ;
static inline QgsSettingsEntryString *settingsMaxNumFeatures = new QgsSettingsEntryString( QStringLiteral( "maxnumfeatures" ), sTreeOwsConnections ) ;
static inline QgsSettingsEntryString *settingsPagesize = new QgsSettingsEntryString( QStringLiteral( "pagesize" ), sTreeOwsConnections ) ;
static inline QgsSettingsEntryBool *settingsPagingEnabled = new QgsSettingsEntryBool( QStringLiteral( "pagingenabled" ), sTreeOwsConnections, true ) ;
static inline QgsSettingsEntryBool *settingsPreferCoordinatesForWfsT11 = new QgsSettingsEntryBool( QStringLiteral( "preferCoordinatesForWfsT11" ), sTreeOwsConnections, false ) ;
static inline QgsSettingsEntryBool *settingsIgnoreAxisOrientation = new QgsSettingsEntryBool( QStringLiteral( "ignoreAxisOrientation" ), sTreeOwsConnections, false ) ;
static inline QgsSettingsEntryBool *settingsInvertAxisOrientation = new QgsSettingsEntryBool( QStringLiteral( "invertAxisOrientation" ), sTreeOwsConnections, false ) ;
static inline QgsSettingsEntryString *settingsUsername = new QgsSettingsEntryString( QStringLiteral( "username" ), sTreeOwsConnections ) ;
static inline QgsSettingsEntryString *settingsPassword = new QgsSettingsEntryString( QStringLiteral( "password" ), sTreeOwsConnections ) ;
static inline QgsSettingsEntryString *settingsAuthCfg = new QgsSettingsEntryString( QStringLiteral( "authcfg" ), sTreeOwsConnections ) ;

#endif

Expand Down
6 changes: 6 additions & 0 deletions src/core/settings/qgssettings.h
Expand Up @@ -81,7 +81,13 @@ class CORE_EXPORT QgsSettings : public QObject
};

#ifndef SIP_RUN

/**
* Returns the tree root element for the settings
* \since QGIS 3.30
*/
static QgsSettingsTreeElement *treeRoot();

static inline QgsSettingsTreeElement *sTtreeConnections = treeRoot()->createChildElement( QStringLiteral( "connections" ) );
static inline QgsSettingsTreeElement *sTreeLocale = treeRoot()->createChildElement( QStringLiteral( "locale" ) );
static inline QgsSettingsTreeElement *sTreeGps = treeRoot()->createChildElement( QStringLiteral( "gps" ) );
Expand Down

0 comments on commit 6a043ed

Please sign in to comment.