Skip to content

Commit

Permalink
Merge pull request #51295 from 3nids/settings-registry-migration-core…
Browse files Browse the repository at this point in the history
…-5-tree-element

Tree structures for settings
  • Loading branch information
3nids committed Jan 23, 2023
2 parents 59fa8cb + 8afd48e commit 42f4e1c
Show file tree
Hide file tree
Showing 192 changed files with 4,688 additions and 2,251 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/code_layout.yml
Expand Up @@ -117,14 +117,6 @@ jobs:
- name: Doxygen Layout Test
run: ./tests/code_layout/test_doxygen_layout.sh

settings_registry_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Settings Registries Test
run: ./tests/code_layout/test_settings_registry.sh

indentation_check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion cmake_templates/Doxyfile.in
Expand Up @@ -845,7 +845,7 @@ EXCLUDE_PATTERNS = moc_* \
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories use the pattern */test/*

EXCLUDE_SYMBOLS =
EXCLUDE_SYMBOLS = *::settings*

# The EXAMPLE_PATH tag can be used to specify one or more files or directories
# that contain example code fragments that are included (see the \include
Expand Down
10 changes: 8 additions & 2 deletions python/core/additions/qgssettingsentry.py
Expand Up @@ -34,11 +34,13 @@ def __init__(self, key, pluginName, defaultValue, description=str(), options=Qgi
Constructor for PyQgsSettingsEntryEnumFlag.
:param key: argument specifies the final part of the settings key.
:param pluginName: argument is inserted in the key after the section.
:param pluginName: argument is either the plugin name or the settings tree parent element
:param defaultValue: argument specifies the default value for the settings entry.
:param description: argument specifies a description for the settings entry.
"""

# TODO QGIS 4: rename pluginName arg to parent

self.options = options
defaultValueStr = str()
self.__metaEnum = metaEnumFromValue(defaultValue)
Expand All @@ -51,7 +53,11 @@ def __init__(self, key, pluginName, defaultValue, description=str(), options=Qgi
defaultValueStr = self.__metaEnum.valueToKey(defaultValue)
self.__enumFlagClass = defaultValue.__class__

super().__init__(key, 'plugins/{}'.format(pluginName), defaultValueStr, description, options)
if type(pluginName) == str:
parent = QgsSettings.createPluginTreeElement(pluginName)
else:
parent = pluginName
super().__init__(key, parent, defaultValueStr, description, options)

def value(self, dynamicKeyPart=None):
"""
Expand Down
12 changes: 11 additions & 1 deletion python/core/auto_additions/qgis.py
Expand Up @@ -149,6 +149,9 @@
Qgis.ScaleMethod.baseClass = Qgis
QgsSettingsEntryBase.SettingsType = Qgis.SettingsType
# monkey patching scoped based enum
QgsSettingsEntryBase.Custom = Qgis.SettingsType.Custom
QgsSettingsEntryBase.Custom.is_monkey_patched = True
QgsSettingsEntryBase.Custom.__doc__ = "Custom implementation"
QgsSettingsEntryBase.Variant = Qgis.SettingsType.Variant
QgsSettingsEntryBase.Variant.is_monkey_patched = True
QgsSettingsEntryBase.Variant.__doc__ = "Generic variant"
Expand Down Expand Up @@ -176,7 +179,7 @@
QgsSettingsEntryBase.Color = Qgis.SettingsType.Color
QgsSettingsEntryBase.Color.is_monkey_patched = True
QgsSettingsEntryBase.Color.__doc__ = "Color"
Qgis.SettingsType.__doc__ = 'Types of settings entries\n\n.. versionadded:: 3.26\n\n' + '* ``Variant``: ' + Qgis.SettingsType.Variant.__doc__ + '\n' + '* ``String``: ' + Qgis.SettingsType.String.__doc__ + '\n' + '* ``StringList``: ' + Qgis.SettingsType.StringList.__doc__ + '\n' + '* ``VariantMap``: ' + Qgis.SettingsType.VariantMap.__doc__ + '\n' + '* ``Bool``: ' + Qgis.SettingsType.Bool.__doc__ + '\n' + '* ``Integer``: ' + Qgis.SettingsType.Integer.__doc__ + '\n' + '* ``Double``: ' + Qgis.SettingsType.Double.__doc__ + '\n' + '* ``EnumFlag``: ' + Qgis.SettingsType.EnumFlag.__doc__ + '\n' + '* ``Color``: ' + Qgis.SettingsType.Color.__doc__
Qgis.SettingsType.__doc__ = 'Types of settings entries\n\n.. versionadded:: 3.26\n\n' + '* ``Custom``: ' + Qgis.SettingsType.Custom.__doc__ + '\n' + '* ``Variant``: ' + Qgis.SettingsType.Variant.__doc__ + '\n' + '* ``String``: ' + Qgis.SettingsType.String.__doc__ + '\n' + '* ``StringList``: ' + Qgis.SettingsType.StringList.__doc__ + '\n' + '* ``VariantMap``: ' + Qgis.SettingsType.VariantMap.__doc__ + '\n' + '* ``Bool``: ' + Qgis.SettingsType.Bool.__doc__ + '\n' + '* ``Integer``: ' + Qgis.SettingsType.Integer.__doc__ + '\n' + '* ``Double``: ' + Qgis.SettingsType.Double.__doc__ + '\n' + '* ``EnumFlag``: ' + Qgis.SettingsType.EnumFlag.__doc__ + '\n' + '* ``Color``: ' + Qgis.SettingsType.Color.__doc__
# --
Qgis.SettingsType.baseClass = Qgis
# monkey patching scoped based enum
Expand Down Expand Up @@ -2213,6 +2216,13 @@
# --
Qgis.CoordinateDisplayType.baseClass = Qgis
# monkey patching scoped based enum
Qgis.SettingsOrigin.Any.__doc__ = "From any origin"
Qgis.SettingsOrigin.Global.__doc__ = "Global settings are stored in `global_settings.ini`"
Qgis.SettingsOrigin.Local.__doc__ = "Local settings are stored in the user profile"
Qgis.SettingsOrigin.__doc__ = 'The setting origin describes where a setting is stored.\n\n.. versionadded:: 3.30\n\n' + '* ``Any``: ' + Qgis.SettingsOrigin.Any.__doc__ + '\n' + '* ``Global``: ' + Qgis.SettingsOrigin.Global.__doc__ + '\n' + '* ``Local``: ' + Qgis.SettingsOrigin.Local.__doc__
# --
Qgis.SettingsOrigin.baseClass = Qgis
# monkey patching scoped based enum
Qgis.ScriptLanguage.Css.__doc__ = "CSS"
Qgis.ScriptLanguage.QgisExpression.__doc__ = "QGIS expressions"
Qgis.ScriptLanguage.Html.__doc__ = "HTML"
Expand Down
15 changes: 15 additions & 0 deletions python/core/auto_additions/qgssettingstreenode.py
@@ -0,0 +1,15 @@
# The following has been generated automatically from src/core/settings/qgssettingstreenode.h
# monkey patching scoped based enum
QgsSettingsTreeNode.Type.Root.__doc__ = "Root Element"
QgsSettingsTreeNode.Type.Standard.__doc__ = "Normal Element"
QgsSettingsTreeNode.Type.NamedList.__doc__ = ""
QgsSettingsTreeNode.Type.__doc__ = 'Type of tree element\n\n' + '* ``Root``: ' + QgsSettingsTreeNode.Type.Root.__doc__ + '\n' + '* ``Standard``: ' + QgsSettingsTreeNode.Type.Standard.__doc__ + '\n' + '* ``NamedList``: ' + QgsSettingsTreeNode.Type.NamedList.__doc__
# --
QgsSettingsTreeNode.Type.baseClass = QgsSettingsTreeNode
# monkey patching scoped based enum
QgsSettingsTreeNode.Option.NamedListSelectedItemSetting.__doc__ = "Creates a setting to store which is the current item"
QgsSettingsTreeNode.Option.__doc__ = 'Options for named list elements\n\n' + '* ``NamedListSelectedItemSetting``: ' + QgsSettingsTreeNode.Option.NamedListSelectedItemSetting.__doc__
# --
QgsSettingsTreeNode.Option.baseClass = QgsSettingsTreeNode
QgsSettingsTreeNode.Options.baseClass = QgsSettingsTreeNode
Options = QgsSettingsTreeNode # dirty hack since SIP seems to introduce the flags in module
12 changes: 0 additions & 12 deletions python/core/auto_generated/gps/qgsgpsconnection.sip.in
Expand Up @@ -45,18 +45,6 @@ Abstract base class for connection to a GPS device
};














QgsGpsConnection( QIODevice *dev /Transfer/ );
%Docstring
Constructor
Expand Down
1 change: 0 additions & 1 deletion python/core/auto_generated/gps/qgsgpslogger.sip.in
Expand Up @@ -28,7 +28,6 @@ from incoming GPS location points.
public:



QgsGpsLogger( QgsGpsConnection *connection, QObject *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsGpsLogger with the specified ``parent`` object.
Expand Down
21 changes: 18 additions & 3 deletions python/core/auto_generated/network/qgshttpheaders.sip.in
Expand Up @@ -10,6 +10,8 @@





class QgsHttpHeaders
{
%Docstring(signature="appended")
Expand All @@ -24,7 +26,7 @@ This class implements simple http header management.
public:


QgsHttpHeaders( const QMap<QString, QVariant> &headers );
QgsHttpHeaders( const QVariantMap &headers );
%Docstring
Constructor from map

Expand All @@ -36,12 +38,15 @@ Constructor from map
default constructor
%End

QgsHttpHeaders( const QgsSettings &settings, const QString &key = QString() );
QgsHttpHeaders( const QgsSettings &settings, const QString &key = QString() ) /Deprecated/;
%Docstring
Constructor from :py:class:`QgsSettings` ``settings`` object and root ``key``

:param settings:
:param key:

.. deprecated:: QGIS 3.30
use a variant map settings and the default constructor instead
%End

QgsHttpHeaders( const QString &key );
Expand All @@ -60,7 +65,14 @@ Constructor from a QDomElement ``element``

virtual ~QgsHttpHeaders();

bool updateSettings( QgsSettings &settings, const QString &key = QString() ) const;
QVariantMap headers() const;
%Docstring
Returns the headers as a variant map

.. versionadded:: 3.30
%End

bool updateSettings( QgsSettings &settings, const QString &key = QString() ) const /Deprecated/;
%Docstring
Updates the ``settings`` by adding all the http headers in the path "key/PATH_PREFIX/"

Expand All @@ -70,6 +82,9 @@ KEY_REFERER value will be available at path "key/PATH_PREFIX/KEY_REFERER" and pa
:param key: sub group path

:return: ``True`` if the update succeed

.. deprecated:: QGIS 3.30
directly use a variant setting instead
%End

bool updateNetworkRequest( QNetworkRequest &request ) const;
Expand Down
8 changes: 8 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Expand Up @@ -150,6 +150,7 @@ The development version

enum class SettingsType
{
Custom,
Variant,
String,
StringList,
Expand Down Expand Up @@ -1465,6 +1466,13 @@ The development version
CustomCrs,
};

enum class SettingsOrigin
{
Any,
Global,
Local,
};

enum class ScriptLanguage
{
Css,
Expand Down
1 change: 1 addition & 0 deletions python/core/auto_generated/qgsapplication.sip.in
Expand Up @@ -1105,6 +1105,7 @@ Emits the signal to collect all the strings of .qgs to be included in ts file
%End



%If (ANDROID)
//dummy method to workaround sip generation issue
bool x11EventFilter( XEvent *event );
Expand Down
7 changes: 2 additions & 5 deletions python/core/auto_generated/qgsowsconnection.sip.in
Expand Up @@ -10,6 +10,8 @@





class QgsOwsConnection : QObject
{
%Docstring(signature="appended")
Expand All @@ -22,11 +24,6 @@ Connections management
public:




const QgsSettingsEntryGroup settingsServiceConnectionDetailsGroup;
const QgsSettingsEntryGroup settingsServiceConnectionCredentialsGroup;

QgsOwsConnection( const QString &service, const QString &connName );
%Docstring
Constructor
Expand Down
29 changes: 28 additions & 1 deletion python/core/auto_generated/settings/qgssettings.sip.in
Expand Up @@ -66,6 +66,21 @@ static bool setGlobalSettingsPath( QString path );
};


static QgsSettingsTreeNode *createPluginTreeElement( const QString &pluginName );
%Docstring
Creates a settings tree element for the given ``pluginName``

.. versionadded:: 3.30
%End


static void unregisterPluginTreeElement( const QString &pluginName );
%Docstring
Unregisters the tree element for the given plugin

.. versionadded:: 3.30
%End

explicit QgsSettings( const QString &organization,
const QString &application = QString(), QObject *parent = 0 );
%Docstring
Expand Down Expand Up @@ -174,7 +189,7 @@ Returns a list of all keys, including subkeys, that can be read using the QSetti
%Docstring
Returns a list of all top-level keys that can be read using the QSettings object.
%End
QStringList childGroups() const;
QStringList childGroups( Qgis::SettingsOrigin origin = Qgis::SettingsOrigin::Any ) const;
%Docstring
Returns a list of all key top-level groups that contain keys that can be read using the QSettings object.
%End
Expand Down Expand Up @@ -213,6 +228,17 @@ Closes the array that was started using :py:func:`~QgsSettings.beginReadArray` o
%Docstring
Sets the current array index to i. Calls to functions such as :py:func:`~QgsSettings.setValue`, :py:func:`~QgsSettings.value`,
:py:func:`~QgsSettings.remove`, and :py:func:`~QgsSettings.contains` will operate on the array entry at that index.
%End

Qgis::SettingsOrigin origin( const QString &key ) const;
%Docstring
Returns the origin of the setting if it exists at the given ``key``

.. note::

it will return Qgis.SettingsOrigin.Any if the key doesn't exist

.. versionadded:: 3.30
%End

void setValue( const QString &key, const QVariant &value, QgsSettings::Section section = QgsSettings::NoSection );
Expand Down Expand Up @@ -246,6 +272,7 @@ An optional Section argument can be used to get a value from a specific Section.
%End



bool contains( const QString &key, QgsSettings::Section section = QgsSettings::NoSection ) const;
%Docstring
Returns ``True`` if there exists a setting called key; returns ``False`` otherwise.
Expand Down

0 comments on commit 42f4e1c

Please sign in to comment.