Skip to content

Commit

Permalink
sipify them all
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jan 16, 2023
1 parent 0eceb91 commit 44039d1
Show file tree
Hide file tree
Showing 15 changed files with 549 additions and 38 deletions.
8 changes: 5 additions & 3 deletions python/core/additions/qgssettingsentry.py
Expand Up @@ -29,12 +29,12 @@ class PyQgsSettingsEntryEnumFlag
since QGIS 3.20
"""

def __init__(self, key, pluginName, defaultValue, description=str(), options=Qgis.SettingsOptions()):
def __init__(self, key, parent, defaultValue, description=str(), options=Qgis.SettingsOptions()):
"""
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 parent: 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.
"""
Expand All @@ -51,7 +51,9 @@ 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(parent) == str:
parent = QgsSettings.createPluginTreeElement(parent)
super().__init__(key, parent, defaultValueStr, description, options)

def value(self, dynamicKeyPart=None):
"""
Expand Down
13 changes: 12 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 Type"
QgsSettingsEntryBase.Variant = Qgis.SettingsType.Variant
QgsSettingsEntryBase.Variant.is_monkey_patched = True
QgsSettingsEntryBase.Variant.__doc__ = "Generic variant"
Expand Down Expand Up @@ -176,10 +179,18 @@
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
Qgis.SettingsAccessMode.PreferLocal.__doc__ = "Look in local settings first, then in global if the setting is not found"
Qgis.SettingsAccessMode.PreferGlobal.__doc__ = "Look in global settings first, then in local if the setting is not found"
Qgis.SettingsAccessMode.LocalOnly.__doc__ = "Lool only in local settings"
Qgis.SettingsAccessMode.GlobalOnly.__doc__ = "Look only in global settings"
Qgis.SettingsAccessMode.__doc__ = 'SettingsAccessMode\n\n.. versionadded:: 3.30\n\n' + '* ``PreferLocal``: ' + Qgis.SettingsAccessMode.PreferLocal.__doc__ + '\n' + '* ``PreferGlobal``: ' + Qgis.SettingsAccessMode.PreferGlobal.__doc__ + '\n' + '* ``LocalOnly``: ' + Qgis.SettingsAccessMode.LocalOnly.__doc__ + '\n' + '* ``GlobalOnly``: ' + Qgis.SettingsAccessMode.GlobalOnly.__doc__
# --
Qgis.SettingsAccessMode.baseClass = Qgis
# monkey patching scoped based enum
Qgis.SldExportOption.NoOptions.__doc__ = "Default SLD export"
Qgis.SldExportOption.Svg.__doc__ = "Export complex styles to separate SVG files for better compatibility with OGC servers"
Qgis.SldExportOption.__doc__ = 'SLD export options\n\n.. versionadded:: 3.30\n\n' + '* ``NoOptions``: ' + Qgis.SldExportOption.NoOptions.__doc__ + '\n' + '* ``Svg``: ' + Qgis.SldExportOption.Svg.__doc__
Expand Down
15 changes: 15 additions & 0 deletions python/core/auto_additions/qgssettingstreeelement.py
@@ -0,0 +1,15 @@
# 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.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.baseClass = QgsSettingsTreeElement
# monkey patching scoped based enum
QgsSettingsTreeElement.Option.NamedListSelectedItemSetting.__doc__ = ""
QgsSettingsTreeElement.Option.__doc__ = 'Options for named list elements\n\n' + '* ``NamedListSelectedItemSetting``: ' + QgsSettingsTreeElement.Option.NamedListSelectedItemSetting.__doc__
# --
QgsSettingsTreeElement.Option.baseClass = QgsSettingsTreeElement
QgsSettingsTreeElement.Options.baseClass = QgsSettingsTreeElement
Options = QgsSettingsTreeElement # dirty hack since SIP seems to introduce the flags in module
19 changes: 16 additions & 3 deletions python/core/auto_generated/network/qgshttpheaders.sip.in
Expand Up @@ -24,7 +24,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 +36,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 +63,14 @@ Constructor from a QDomElement ``element``

virtual ~QgsHttpHeaders();

bool updateSettings( QgsSettings &settings, const QString &key = QString() ) const;
QVariantMap headers() const;
%Docstring
reeturn 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 +80,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
1 change: 1 addition & 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
2 changes: 2 additions & 0 deletions python/core/auto_generated/qgsapplication.sip.in
Expand Up @@ -9,6 +9,7 @@




class QgsApplication : QApplication
{
%Docstring(signature="appended")
Expand Down Expand Up @@ -1090,6 +1091,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
6 changes: 1 addition & 5 deletions python/core/auto_generated/qgsowsconnection.sip.in
Expand Up @@ -10,6 +10,7 @@




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




const QgsSettingsEntryGroup settingsServiceConnectionDetailsGroup;
const QgsSettingsEntryGroup settingsServiceConnectionCredentialsGroup;

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


static QgsSettingsTreeElement *createPluginTreeElement( const QString &pluginName ) throw( QgsSettingsException );
%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
69 changes: 60 additions & 9 deletions python/core/auto_generated/settings/qgssettingsentry.sip.in
Expand Up @@ -23,7 +23,7 @@ Creates a group of setting which have a common definition of base key
#include "qgssettingsentry.h"
%End
public:
QgsSettingsEntryGroup( const QList<const QgsSettingsEntryBase *> settings );
QgsSettingsEntryGroup( QList<const QgsSettingsEntryBase *> settings );
%Docstring
Constructor
%End
Expand Down Expand Up @@ -101,6 +101,8 @@ to validate set values and provide more accurate settings description for the gu
sipType = sipType_QgsSettingsEntryDouble;
else if ( dynamic_cast< QgsSettingsEntryColor * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryColor;
else if ( dynamic_cast< QgsSettingsEntryBase * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryBase;
else
sipType = NULL;
%End
Expand All @@ -113,7 +115,6 @@ Transforms a dynamic key part string to list
.. versionadded:: 3.26
%End


QgsSettingsEntryBase( const QString &key,
const QString &section,
const QVariant &defaultValue = QVariant(),
Expand All @@ -127,6 +128,21 @@ The ``section`` argument specifies the section.
The ``defaultValue`` argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
The ``options`` argument specifies the options for the settings entry.
%End

QgsSettingsEntryBase( const QString &key,
QgsSettingsTreeElement *parentTreeElement,
const QVariant &defaultValue = QVariant(),
const QString &description = QString(),
Qgis::SettingsOptions options = Qgis::SettingsOptions() );
%Docstring
Constructor for QgsSettingsEntryBase.

The ``key`` argument specifies the key of the settings.
The ``parent`` argument specifies the parent in the tree of settings.
The ``defaultValue`` argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
The ``options`` argument specifies the options for the settings entry.
%End

virtual ~QgsSettingsEntryBase();
Expand Down Expand Up @@ -282,7 +298,7 @@ Returns settings value with an optional default value override
Returns settings default value.
%End

virtual Qgis::SettingsType settingsType() const = 0;
virtual Qgis::SettingsType settingsType() const;
%Docstring
Returns the settings entry type.
%End
Expand All @@ -308,20 +324,28 @@ Returns the current value (or default) if there is no former value.
.. versionadded:: 3.26
%End

bool migrateFromKey( const QString &oldKey, const QString &oldSection = QString(), const QString &dynamicKeyPart = QString() ) const;
bool copyValueFromKey( const QString &key, const QStringList &dynamicKeyPartList = QStringList(), bool deleteOldKey = false ) const;
%Docstring
Check if the settings does not exist and try to set it from a given ``oldKey`` and ``oldSection``
Checks if the settings does not exist and try to set it from a given ``oldKey``.
\arg dynamicKeyPartList is the optional dynamic key part to determine the key. It must be the same for origin and destination keys.
If ``deleteOldKey``, the setting with the old key will be removed

:return: ``True`` if the key exists and the setting value could be copied

.. versionadded:: 3.30
%End

bool migrateFromKey( const QString &oldKey, const QString &oldSection, const QStringList &dynamicKeyPartList ) const;
void copyValueToKey( const QString &key, const QStringList &dynamicKeyPartList = QStringList() ) const;
%Docstring
Check if the settings does not exist and try to set it from a given ``oldKey``
Copies the settings to the given ``key``
\arg dynamicKeyPartList is the optional dynamic key part to determine the key. It must be the same for origin and destination keys.

.. note::
.. versionadded:: 3.30
%End

The old key must contain its section (the section from the current setting will not be prepended)
QgsSettingsTreeElement *parent() const;
%Docstring
Returns the parent tree element

.. versionadded:: 3.30
%End
Expand Down Expand Up @@ -358,6 +382,21 @@ Base abstract class for settings entry which are passed by reference
%End
public:

QgsSettingsEntryByReference( const QString &key,
QgsSettingsTreeElement *parent,
const T &defaultValue,
const QString &description = QString(),
Qgis::SettingsOptions options = Qgis::SettingsOptions() );
%Docstring
Constructor for QgsSettingsEntryByReference.

The ``key`` argument specifies the key of the settings.
The ``parent`` argument specifies the parent in the tree of settings.
The ``defaultValue`` argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
The ``options`` arguments specifies the options for the settings entry.
%End

QgsSettingsEntryByReference( const QString &key,
const QString &section,
const T &defaultValue,
Expand All @@ -367,6 +406,7 @@ Base abstract class for settings entry which are passed by reference
Constructor for QgsSettingsEntryByReference.

The ``key`` argument specifies the key of the settings.
The ``section`` argument specifies the section.
The ``defaultValue`` argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
The ``options`` arguments specifies the options for the settings entry.
Expand Down Expand Up @@ -492,6 +532,17 @@ Base abstract class for settings entry which are passed by value
%End
public:

QgsSettingsEntryByValue( const QString &key, QgsSettingsTreeElement *parent, QVariant defaultValue, const QString &description = QString(), Qgis::SettingsOptions options = Qgis::SettingsOptions() );
%Docstring
Constructor for QgsSettingsEntryByValue.

The ``key`` argument specifies the key of the settings.
The ``parent`` argument specifies the parent in the tree of settings.
The ``section`` argument specifies the section.
The ``defaultValue`` argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
The ``options`` arguments specifies the options for the settings entry.
%End

QgsSettingsEntryByValue( const QString &key, const QString &section, QVariant defaultValue, const QString &description = QString(), Qgis::SettingsOptions options = Qgis::SettingsOptions() );
%Docstring
Expand Down

0 comments on commit 44039d1

Please sign in to comment.