From 08ada3aadf7a5dfd30d6c82d6dd43decd0318a0c Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Thu, 24 Feb 2022 13:41:34 +0100 Subject: [PATCH] sipify + move sipify config file to ./python --- .../settings/qgssettingsentry.sip.in | 761 +++++------------- .../settings/qgssettingsentryimpl.sip.in | 512 ++++++++++++ python/core/core_auto.sip | 1 + {scripts => python}/sipify.yaml | 3 + scripts/sipify.pl | 2 +- 5 files changed, 702 insertions(+), 577 deletions(-) create mode 100644 python/core/auto_generated/settings/qgssettingsentryimpl.sip.in rename {scripts => python}/sipify.yaml (57%) diff --git a/python/core/auto_generated/settings/qgssettingsentry.sip.in b/python/core/auto_generated/settings/qgssettingsentry.sip.in index 9639223d6f4..3213481cb72 100644 --- a/python/core/auto_generated/settings/qgssettingsentry.sip.in +++ b/python/core/auto_generated/settings/qgssettingsentry.sip.in @@ -43,23 +43,12 @@ to validate set values and provide more accurate settings description for the gu %End public: - enum class SettingsType - { - Variant, - String, - StringList, - Bool, - Integer, - Double, - EnumFlag, - Color - }; - QgsSettingsEntryBase( const QString &key, const QString &pluginName, const QVariant &defaultValue = QVariant(), - const QString &description = QString() ); + const QString &description = QString(), + Qgis::SettingsOptions options = Qgis::SettingsOptions() ); %Docstring Constructor for QgsSettingsEntryBase. This constructor is intended to be used from plugins. @@ -68,6 +57,7 @@ The ``key`` argument specifies the key of the settings. The ``pluginName`` argument is inserted in the key after 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 virtual ~QgsSettingsEntryBase(); @@ -158,30 +148,66 @@ The ``value`` to set. The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. %End - QVariant valueAsVariant( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const QVariant &defaultValueOverride = QVariant() ) const; + QVariant valueAsVariant( const QString &dynamicKeyPart = QString() ) const; +%Docstring +Returns settings value with the ``dynamicKeyPart`` argument specifying the dynamic part of the settings key. +%End + + QVariant valueAsVariant( const QStringList &dynamicKeyPartList ) const; +%Docstring +Returns settings value with the ``dynamicKeyPart`` argument specifying the dynamic part of the settings key. +%End + + QVariant valueAsVariantWithDefaultOverride( const QVariant &defaultValueOverride ) const; +%Docstring +Returns settings value with a ``defaultValueOverride`` + +.. versionadded:: 3.26 +%End + + QVariant valueAsVariantWithDefaultOverride( const QString &dynamicKeyPart, const QVariant &defaultValueOverride ) const; %Docstring Returns settings value. The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. The ``defaultValueOverride`` argument if valid is used instead of the normal default value. + +.. versionadded:: 3.26 %End - QVariant valueAsVariant( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride = false, const QVariant &defaultValueOverride = QVariant() ) const; + QVariant valueAsVariantWithDefaultOverride( const QStringList &dynamicKeyPartList, const QVariant &defaultValueOverride ) const; %Docstring Returns settings value. -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. +The ``dynamicKeyPartList`` argument specifies the list of dynamic parts of the settings key. The ``defaultValueOverride`` argument if valid is used instead of the normal default value. + +.. versionadded:: 3.26 %End + QVariant valueAsVariant( const QString &dynamicKeyPart, bool useDefaultValueOverride, const QVariant &defaultValueOverride ) const /Deprecated/; +%Docstring +Returns settings value with an optional default value override + +.. deprecated:: QGIS 3.26 + use valueAsVariantWithDefaultOverride instead +%End + + QVariant valueAsVariant( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride, const QVariant &defaultValueOverride ) const /Deprecated/; +%Docstring +Returns settings value with an optional default value override + +.. deprecated:: QGIS 3.26 + use valueAsVariantWithDefaultOverride instead +%End + + QVariant defaultValueAsVariant() const; %Docstring Returns settings default value. %End - virtual SettingsType settingsType() const = 0; + virtual Qgis::SettingsType settingsType() const = 0; %Docstring Returns the settings entry type. %End @@ -189,18 +215,39 @@ Returns the settings entry type. QString description() const; %Docstring Returns the settings entry description. +%End + + QVariant formerValueAsVariant( const QString &dynamicKeyPart ) const; +%Docstring +Returns the former value of the settings if it has been enabled in the options +Returns the current value (or default) if there is no former value. + +.. versionadded:: 3.26 +%End + + QVariant formerValueAsVariant( const QStringList &dynamicKeyPartList ) const; +%Docstring +Returns the former value of the settings if it has been enabled in the options +Returns the current value (or default) if there is no former value. + +.. versionadded:: 3.26 %End }; -class QgsSettingsEntryVariant : QgsSettingsEntryBase +template +class QgsSettingsEntryByReference : QgsSettingsEntryBase { %Docstring(signature="appended") -A variant settings entry. +Base abstract class for settings entry which are passed by reference -.. versionadded:: 3.20 +.. seealso:: :py:class:`QgsSettingsEntryBase` + +.. seealso:: :py:class:`QgsSettingsEntryByValue` + +.. versionadded:: 3.26 %End %TypeHeaderCode @@ -209,21 +256,53 @@ A variant settings entry. public: - QgsSettingsEntryVariant( const QString &key, - const QString &pluginName, - const QVariant &defaultValue = QVariant(), - const QString &description = QString() ); + QgsSettingsEntryByReference( const QString &key, + const QString &pluginName, + const T &defaultValue, + const QString &description = QString(), + Qgis::SettingsOptions options = Qgis::SettingsOptions() ); %Docstring -Constructor for QgsSettingsEntryVariant. +Constructor for QgsSettingsEntryByReference. This constructor is intended to be used from plugins. The ``key`` argument specifies the key of the settings. The ``pluginName`` argument is inserted in the key after 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 - bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() ) const; + T valueWithDefaultOverride( const T &defaultValueOverride ) const; +%Docstring +Returns the settings value with a ``defaultValueOverride`` +%End + T valueWithDefaultOverride( const QString &dynamicKeyPart, const T &defaultValueOverride ) const; +%Docstring +Returns the settings value for the ``dynamicKeyPart`` and with a ``defaultValueOverride`` +%End + T valueWithDefaultOverride( const QStringList &dynamicKeyPartList, const T &defaultValueOverride ) const; +%Docstring +Returns the settings value for the ``dynamicKeyPartList`` and with a ``defaultValueOverride`` +%End + + T value( const QString &dynamicKeyPart, bool useDefaultValueOverride, const T &defaultValueOverride ) const /Deprecated/; +%Docstring +Returns the settings value for the ``dynamicKeyPart`` and with a ``defaultValueOverride`` + +.. deprecated:: QGIS 3.26 + use valueAsVariantWithDefaultOverride instead +%End + + T value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride, const T &defaultValueOverride ) const /Deprecated/; +%Docstring +Returns the settings value for the ``dynamicKeyPartList`` and with a ``defaultValueOverride`` + +.. deprecated:: QGIS 3.26 + use valueAsVariantWithDefaultOverride instead +%End + + + virtual bool setValue( const T &value, const QString &dynamicKeyPart = QString() ) const = 0; %Docstring Set settings value. @@ -231,7 +310,7 @@ The ``value`` to set. The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. %End - bool setValue( const QVariant &value, const QStringList &dynamicKeyPartList ) const; + virtual bool setValue( const T &value, const QStringList &dynamicKeyPartList ) const = 0; %Docstring Set settings value. @@ -239,534 +318,20 @@ The ``value`` to set. The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. %End - QVariant value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const QVariant &defaultValueOverride = QVariant() ) const; + T value( const QString &dynamicKeyPart = QString() ) const; %Docstring Returns settings value. The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. The ``defaultValueOverride`` argument if valid is used instead of the normal default value. %End - QVariant value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride = false, const QVariant &defaultValueOverride = QVariant() ) const; + + T value( const QStringList &dynamicKeyPartList ) const; %Docstring Returns settings value. -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - QVariant defaultValue() const; -%Docstring -Returns settings default value. -%End - - virtual SettingsType settingsType() const; -}; - - -class QgsSettingsEntryString : QgsSettingsEntryBase -{ -%Docstring(signature="appended") - -A string settings entry. - -.. versionadded:: 3.20 -%End - -%TypeHeaderCode -#include "qgssettingsentry.h" -%End - public: - - - QgsSettingsEntryString( const QString &key, - const QString &pluginName, - const QString &defaultValue = QString(), - const QString &description = QString() ); -%Docstring -Constructor for QgsSettingsEntryString. -This constructor is intended to be used from plugins. - -The ``key`` argument specifies the key of the settings. -The ``pluginName`` argument is inserted in the key after the section. -The ``defaultValue`` argument specifies the default value for the settings entry. -The ``description`` argument specifies a description for the settings entry. -%End - - bool setValue( const QString &value, const QString &dynamicKeyPart = QString() ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -%End - - bool setValue( const QString &value, const QStringList &dynamicKeyPartList ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -%End - - QString value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const QString &defaultValueOverride = QString() ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - QString value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride = false, const QString &defaultValueOverride = QString() ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - QString defaultValue() const; -%Docstring -Returns settings default value. -%End - - virtual SettingsType settingsType() const; - - void setMinLength( int minLength ); -%Docstring -Set the string minimum length. - -minLength The string minimum length. -%End - - int minLength(); -%Docstring -Returns the string minimum length. -%End - - void setMaxLength( int maxLength ); -%Docstring -Set the string maximum length. - -maxLength The string maximum length. -%End - - int maxLength(); -%Docstring -Returns the string maximum length. By -1 there is no limitation. -%End - -}; - - -class QgsSettingsEntryStringList : QgsSettingsEntryBase -{ -%Docstring(signature="appended") - -A string list settings entry. - -.. versionadded:: 3.20 -%End - -%TypeHeaderCode -#include "qgssettingsentry.h" -%End - public: - - - QgsSettingsEntryStringList( const QString &key, - const QString &pluginName, - const QStringList &defaultValue = QStringList(), - const QString &description = QString() ); -%Docstring -Constructor for QgsSettingsEntryStringList. -This constructor is intended to be used from plugins. - -The ``key`` argument specifies the key of the settings. -The ``pluginName`` argument is inserted in the key after the section. -The ``defaultValue`` argument specifies the default value for the settings entry. -The ``description`` argument specifies a description for the settings entry. -%End - - bool setValue( const QStringList &value, const QString &dynamicKeyPart = QString() ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -%End - - bool setValue( const QStringList &value, const QStringList &dynamicKeyPartList ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -%End - - QStringList value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const QStringList &defaultValueOverride = QStringList() ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - QStringList value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride = false, const QStringList &defaultValueOverride = QStringList() ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - QStringList defaultValue() const; -%Docstring -Returns settings default value. -%End - - virtual SettingsType settingsType() const; - -}; - - -class QgsSettingsEntryBool : QgsSettingsEntryBase -{ -%Docstring(signature="appended") - -A boolean settings entry. - -.. versionadded:: 3.20 -%End - -%TypeHeaderCode -#include "qgssettingsentry.h" -%End - public: - - - QgsSettingsEntryBool( const QString &key, - const QString &pluginName, - bool defaultValue = false, - const QString &description = QString() ); -%Docstring -Constructor for QgsSettingsEntryBool. -This constructor is intended to be used from plugins. - -The ``key`` argument specifies the key of the settings. -The ``pluginName`` argument is inserted in the key after the section. -The ``defaultValue`` argument specifies the default value for the settings entry. -The ``description`` argument specifies a description for the settings entry. -%End - - bool setValue( bool value, const QString &dynamicKeyPart = QString() ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -%End - - bool setValue( bool value, const QStringList &dynamicKeyPartList ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -%End - - bool value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, bool defaultValueOverride = false ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - bool value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride = false, bool defaultValueOverride = false ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - bool defaultValue() const; -%Docstring -Returns settings default value. -%End - - virtual SettingsType settingsType() const; -}; - - -class QgsSettingsEntryInteger : QgsSettingsEntryBase -{ -%Docstring(signature="appended") - -An integer settings entry. - -.. versionadded:: 3.20 -%End - -%TypeHeaderCode -#include "qgssettingsentry.h" -%End - public: - - - - QgsSettingsEntryInteger( const QString &key, - const QString &pluginName, - qlonglong defaultValue = 0, - const QString &description = QString() ); -%Docstring -Constructor for QgsSettingsEntryInteger. -This constructor is intended to be used from plugins. - -The ``key`` argument specifies the key of the settings. -The ``pluginName`` argument is inserted in the key after the section. -The ``defaultValue`` argument specifies the default value for the settings entry. -The ``description`` argument specifies a description for the settings entry. -%End - - bool setValue( qlonglong value, const QString &dynamicKeyPart = QString() ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -%End - - bool setValue( qlonglong value, const QStringList &dynamicKeyPartList ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -%End - - qlonglong value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, qlonglong defaultValueOverride = 0 ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - qlonglong value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride = false, qlonglong defaultValueOverride = 0 ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - qlonglong defaultValue() const; -%Docstring -Returns settings default value. -%End - - virtual SettingsType settingsType() const; - - void setMinValue( qlonglong minValue ); -%Docstring -Set the minimum value. - -minValue The minimum value. -%End - - qlonglong minValue(); -%Docstring -Returns the minimum value. -%End - - void setMaxValue( qlonglong maxValue ); -%Docstring -Set the maximum value. - -maxValue The maximum value. -%End - - qlonglong maxValue(); -%Docstring -Returns the maximum value. -%End - -}; - - -class QgsSettingsEntryDouble : QgsSettingsEntryBase -{ -%Docstring(signature="appended") - -A double settings entry. - -.. versionadded:: 3.20 -%End - -%TypeHeaderCode -#include "qgssettingsentry.h" -%End - public: - - - QgsSettingsEntryDouble( const QString &key, - const QString &pluginName, - double defaultValue, - const QString &description = QString() ); -%Docstring -Constructor for QgsSettingsEntryDouble. -This constructor is intended to be used from plugins. - -The ``key`` argument specifies the key of the settings. -The ``pluginName`` argument is inserted in the key after the section. -The ``defaultValueargument`` specifies the default value for the settings entry. -The ``description`` argument specifies a description for the settings entry. -%End - - bool setValue( double value, const QString &dynamicKeyPart = QString() ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -%End - - bool setValue( double value, const QStringList &dynamicKeyPartList ) const; -%Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -%End - - double value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, double defaultValueOverride = 0.0 ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - double value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride = false, double defaultValueOverride = 0.0 ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - double defaultValue() const; -%Docstring -Returns settings default value. -%End - - virtual SettingsType settingsType() const; - - void setMinValue( double minValue ); -%Docstring -Set the minimum value. - -minValue The minimum value. -%End - - double minValue() const; -%Docstring -Returns the minimum value. -%End - - void setMaxValue( double maxValue ); -%Docstring -Set the maximum value. - -maxValue The maximum value. -%End - - double maxValue() const; -%Docstring -Returns the maximum value. -%End - - void setDisplayHintDecimals( int displayHintDecimals ); -%Docstring -Set the display hint decimals. - -displayHintDecimals The number of decimals that should be shown in the Gui. -%End - - int displayHintDecimals() const; -%Docstring -Returns how much decimals should be shown in the Gui. -%End - -}; - - -template -class QgsSettingsEntryEnumFlag : QgsSettingsEntryBase -{ -%Docstring(signature="appended") - -A template class for enum and flag settings entry. - -.. note:: - - This template class has a dedicated handling in sipify.pl - -.. versionadded:: 3.20 -%End - -%TypeHeaderCode -#include "qgssettingsentry.h" -%End - public: - - QgsSettingsEntryEnumFlag( const QString &key, QgsSettings::Section section, const T &defaultValue, const QString &description = QString() ); -%Docstring -Constructor for :py:class:`QgsSettingsEntryEnumFlagBase`. - -The ``key`` argument specifies the final part of the settings key. -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. - -.. note:: - - The enum needs to be declared with Q_ENUM, and flags with Q_FLAG (not Q_FLAGS). - -.. note:: - - for Python bindings, a custom implementation is achieved in Python directly -%End - - T value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const T &defaultValueOverride = T() ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. -The ``defaultValueOverride`` argument if valid is used instead of the normal default value. -%End - - T value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride = false, const T &defaultValueOverride = T() ) const; -%Docstring -Returns settings value. - -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. +The ``dynamicKeyPartList`` argument specifies the list of dynamic parts of the settings key. The ``defaultValueOverride`` argument if valid is used instead of the normal default value. %End @@ -775,34 +340,35 @@ The ``defaultValueOverride`` argument if valid is used instead of the normal def Returns settings default value. %End - bool setValue( const T &value, const QString &dynamicKeyPart = QString() ) const; + T formerValue( const QString &dynamicKeyPart = QString() ) const; %Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. +Returns the former value +Returns the current value (or default) if there is no former value. %End - bool setValue( const T &value, const QStringList &dynamicKeyPartList ) const; + T formerValue( const QStringList &dynamicKeyPartList ) const; %Docstring -Set settings value. - -The ``value`` to set. -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. +Returns the former value +Returns the current value (or default) if there is no former value. %End - virtual QgsSettingsEntryBase::SettingsType settingsType() const; - + protected: + virtual T convertFromVariant( const QVariant &value ) const = 0; }; -class QgsSettingsEntryColor : QgsSettingsEntryBase +template +class QgsSettingsEntryByValue : QgsSettingsEntryBase { %Docstring(signature="appended") -A color settings entry. +Base abstract class for settings entry which are passed by value -.. versionadded:: 3.20 +.. seealso:: :py:class:`QgsSettingsEntryBase` + +.. seealso:: :py:class:`QgsSettingsEntryByReference` + +.. versionadded:: 3.26 %End %TypeHeaderCode @@ -811,21 +377,52 @@ A color settings entry. public: - QgsSettingsEntryColor( const QString &key, - const QString &pluginName, - const QColor &defaultValue = QColor(), - const QString &description = QString() ); + QgsSettingsEntryByValue( const QString &key, + const QString &pluginName, + T defaultValue, + const QString &description = QString(), + Qgis::SettingsOptions options = Qgis::SettingsOptions() ); %Docstring -Constructor for QgsSettingsEntryColor. +Constructor for QgsSettingsEntryByValue. This constructor is intended to be used from plugins. The ``key`` argument specifies the key of the settings. The ``pluginName`` argument is inserted in the key after 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 - bool setValue( const QColor &value, const QString &dynamicKeyPart = QString() ) const; + T valueWithDefaultOverride( T defaultValueOverride ) const; +%Docstring +Returns the settings value with a ``defaultValueOverride`` +%End + T valueWithDefaultOverride( const QString &dynamicKeyPart, T defaultValueOverride ) const; +%Docstring +Returns the settings value for the ``dynamicKeyPart`` and with a ``defaultValueOverride`` +%End + T valueWithDefaultOverride( const QStringList &dynamicKeyPartList, T defaultValueOverride ) const; +%Docstring +Returns the settings value for the ``dynamicKeyPartList`` and with a ``defaultValueOverride`` +%End + + T value( const QString &dynamicKeyPart, bool useDefaultValueOverride, T defaultValueOverride ) const /Deprecated/; +%Docstring +Returns the settings value for the ``dynamicKeyPart`` and with a ``defaultValueOverride`` + +.. deprecated:: QGIS 3.26 + use valueWithDefaultOverride instead +%End + + T value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride, T defaultValueOverride ) const /Deprecated/; +%Docstring +Returns the settings value for the ``dynamicKeyPartList`` and with a ``defaultValueOverride`` + +.. deprecated:: QGIS 3.26 + use valueWithDefaultOverride instead +%End + + virtual bool setValue( T value, const QString &dynamicKeyPart = QString() ) const = 0; %Docstring Set settings value. @@ -833,7 +430,7 @@ The ``value`` to set. The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. %End - bool setValue( const QColor &value, const QStringList &dynamicKeyPartList ) const; + virtual bool setValue( T value, const QStringList &dynamicKeyPartList ) const = 0; %Docstring Set settings value. @@ -841,33 +438,45 @@ The ``value`` to set. The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. %End - QColor value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const QString &defaultValueOverride = QString() ) const; + T value( const QString &dynamicKeyPart = QString() ) const; %Docstring Returns settings value. The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. The ``defaultValueOverride`` argument if valid is used instead of the normal default value. %End - QColor value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride = false, const QString &defaultValueOverride = QString() ) const; + + T value( const QStringList &dynamicKeyPartList ) const; %Docstring Returns settings value. -The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. -The ``useDefaultValueOverride`` argument specifies if defaultValueOverride should be used. +The ``dynamicKeyPartList`` argument specifies the list of dynamic parts of the settings key. The ``defaultValueOverride`` argument if valid is used instead of the normal default value. %End - QColor defaultValue() const; + T defaultValue() const; %Docstring Returns settings default value. %End - virtual SettingsType settingsType() const; + T formerValue( const QString &dynamicKeyPart = QString() ) const; +%Docstring +Returns the former value +Returns the current value (or default) if there is no former value. +%End + T formerValue( const QStringList &dynamicKeyPartList ) const; +%Docstring +Returns the former value +Returns the current value (or default) if there is no former value. +%End + + protected: + virtual T convertFromVariant( const QVariant &value ) const = 0; }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/auto_generated/settings/qgssettingsentryimpl.sip.in b/python/core/auto_generated/settings/qgssettingsentryimpl.sip.in new file mode 100644 index 00000000000..c7e922deb23 --- /dev/null +++ b/python/core/auto_generated/settings/qgssettingsentryimpl.sip.in @@ -0,0 +1,512 @@ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/settings/qgssettingsentryimpl.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + + + +typedef QgsSettingsEntryByReference QgsSettingsEntryByReferenceQVariantBase; + +class QgsSettingsEntryVariant : QgsSettingsEntryByReferenceQVariantBase +{ +%Docstring(signature="appended") + +A variant settings entry. + +.. versionadded:: 3.20 +%End + +%TypeHeaderCode +#include "qgssettingsentryimpl.h" +#include "qgssettingsentry.h" +typedef QgsSettingsEntryByReference QgsSettingsEntryByReferenceQVariantBase; +%End + public: + + + QgsSettingsEntryVariant( const QString &key, + const QString &pluginName, + const QVariant &defaultValue = QVariant(), + const QString &description = QString(), + Qgis::SettingsOptions options = Qgis::SettingsOptions() ); +%Docstring +Constructor for QgsSettingsEntryVariant. +This constructor is intended to be used from plugins. + +The ``key`` argument specifies the key of the settings. +The ``pluginName`` argument is inserted in the key after 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 + + virtual bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. +%End + + virtual bool setValue( const QVariant &value, const QStringList &dynamicKeyPartList ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. +%End + + virtual Qgis::SettingsType settingsType() const; + +}; + + + +typedef QgsSettingsEntryByReference QgsSettingsEntryByReferenceQStringBase; + +class QgsSettingsEntryString : QgsSettingsEntryByReferenceQStringBase +{ +%Docstring(signature="appended") + +A string settings entry. + +.. versionadded:: 3.20 +%End + +%TypeHeaderCode +#include "qgssettingsentryimpl.h" +#include "qgssettingsentry.h" +typedef QgsSettingsEntryByReference QgsSettingsEntryByReferenceQStringBase; +%End + public: + + + QgsSettingsEntryString( const QString &key, + const QString &pluginName, + const QString &defaultValue = QString(), + const QString &description = QString(), + Qgis::SettingsOptions options = Qgis::SettingsOptions() ); +%Docstring +Constructor for QgsSettingsEntryString. +This constructor is intended to be used from plugins. + +The ``key`` argument specifies the key of the settings. +The ``pluginName`` argument is inserted in the key after 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 + + virtual bool setValue( const QString &value, const QString &dynamicKeyPart = QString() ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. +%End + + virtual bool setValue( const QString &value, const QStringList &dynamicKeyPartList ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. +%End + + virtual Qgis::SettingsType settingsType() const; + + void setMinLength( int minLength ); +%Docstring +Set the string minimum length. + +minLength The string minimum length. +%End + + int minLength(); +%Docstring +Returns the string minimum length. +%End + + void setMaxLength( int maxLength ); +%Docstring +Set the string maximum length. + +maxLength The string maximum length. +%End + + int maxLength(); +%Docstring +Returns the string maximum length. By -1 there is no limitation. +%End + +}; + + + +typedef QgsSettingsEntryByReference QgsSettingsEntryByReferenceQStringListBase; + +class QgsSettingsEntryStringList : QgsSettingsEntryByReferenceQStringListBase +{ +%Docstring(signature="appended") + +A string list settings entry. + +.. versionadded:: 3.20 +%End + +%TypeHeaderCode +#include "qgssettingsentryimpl.h" +#include "qgssettingsentry.h" +typedef QgsSettingsEntryByReference QgsSettingsEntryByReferenceQStringListBase; +%End + public: + + + QgsSettingsEntryStringList( const QString &key, + const QString &pluginName, + const QStringList &defaultValue = QStringList(), + const QString &description = QString(), + Qgis::SettingsOptions options = Qgis::SettingsOptions() ); +%Docstring +Constructor for QgsSettingsEntryStringList. +This constructor is intended to be used from plugins. + +The ``key`` argument specifies the key of the settings. +The ``pluginName`` argument is inserted in the key after 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 + + virtual bool setValue( const QStringList &value, const QString &dynamicKeyPart = QString() ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. +%End + + virtual bool setValue( const QStringList &value, const QStringList &dynamicKeyPartList ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. +%End + + virtual Qgis::SettingsType settingsType() const; + +}; + + + +typedef QgsSettingsEntryByValue QgsSettingsEntryByValueboolBase; + +class QgsSettingsEntryBool : QgsSettingsEntryByValueboolBase +{ +%Docstring(signature="appended") + +A boolean settings entry. + +.. versionadded:: 3.20 +%End + +%TypeHeaderCode +#include "qgssettingsentryimpl.h" +#include "qgssettingsentry.h" +typedef QgsSettingsEntryByValue QgsSettingsEntryByValueboolBase; +%End + public: + + + QgsSettingsEntryBool( const QString &key, const QString &pluginName, bool defaultValue = false, const QString &description = QString(), Qgis::SettingsOptions options = Qgis::SettingsOptions() ); +%Docstring +Constructor for QgsSettingsEntryBool. +This constructor is intended to be used from plugins. + +The ``key`` argument specifies the key of the settings. +The ``pluginName`` argument is inserted in the key after 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 + + virtual bool setValue( bool value, const QString &dynamicKeyPart = QString() ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. +%End + + virtual bool setValue( bool value, const QStringList &dynamicKeyPartList ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. +%End + + virtual Qgis::SettingsType settingsType() const; + +}; + + + +typedef QgsSettingsEntryByValue QgsSettingsEntryByValueqlonglongBase; + +class QgsSettingsEntryInteger : QgsSettingsEntryByValueqlonglongBase +{ +%Docstring(signature="appended") + +An integer settings entry. + +.. versionadded:: 3.20 +%End + +%TypeHeaderCode +#include "qgssettingsentryimpl.h" +#include "qgssettingsentry.h" +typedef QgsSettingsEntryByValue QgsSettingsEntryByValueqlonglongBase; +%End + public: + + + + QgsSettingsEntryInteger( const QString &key, + const QString &pluginName, + qlonglong defaultValue = 0, + const QString &description = QString(), + Qgis::SettingsOptions options = Qgis::SettingsOptions() ); +%Docstring +Constructor for QgsSettingsEntryInteger. +This constructor is intended to be used from plugins. + +The ``key`` argument specifies the key of the settings. +The ``pluginName`` argument is inserted in the key after 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 + + virtual bool setValue( qlonglong value, const QString &dynamicKeyPart = QString() ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. +%End + + virtual bool setValue( qlonglong value, const QStringList &dynamicKeyPartList ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. +%End + + virtual Qgis::SettingsType settingsType() const; + + void setMinValue( qlonglong minValue ); +%Docstring +Set the minimum value. + +minValue The minimum value. +%End + + qlonglong minValue(); +%Docstring +Returns the minimum value. +%End + + void setMaxValue( qlonglong maxValue ); +%Docstring +Set the maximum value. + +maxValue The maximum value. +%End + + qlonglong maxValue(); +%Docstring +Returns the maximum value. +%End + +}; + + + +typedef QgsSettingsEntryByValue QgsSettingsEntryByValuedoubleBase; + +class QgsSettingsEntryDouble : QgsSettingsEntryByValuedoubleBase +{ +%Docstring(signature="appended") + +A double settings entry. + +.. versionadded:: 3.20 +%End + +%TypeHeaderCode +#include "qgssettingsentryimpl.h" +#include "qgssettingsentry.h" +typedef QgsSettingsEntryByValue QgsSettingsEntryByValuedoubleBase; +%End + public: + + + QgsSettingsEntryDouble( const QString &key, + const QString &pluginName, + double defaultValue, + const QString &description = QString(), + Qgis::SettingsOptions options = Qgis::SettingsOptions() ); +%Docstring +Constructor for QgsSettingsEntryDouble. +This constructor is intended to be used from plugins. + +The ``key`` argument specifies the key of the settings. +The ``pluginName`` argument is inserted in the key after the section. +The ``defaultValue`` argument specifies the default value for the settings entry. +The ``options`` arguments specifies the options for the settings entry. +The ``description`` argument specifies a description for the settings entry. +%End + + virtual bool setValue( double value, const QString &dynamicKeyPart = QString() ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. +%End + + virtual bool setValue( double value, const QStringList &dynamicKeyPartList ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. +%End + + virtual Qgis::SettingsType settingsType() const; + + void setMinValue( double minValue ); +%Docstring +Set the minimum value. + +minValue The minimum value. +%End + + double minValue() const; +%Docstring +Returns the minimum value. +%End + + void setMaxValue( double maxValue ); +%Docstring +Set the maximum value. + +maxValue The maximum value. +%End + + double maxValue() const; +%Docstring +Returns the maximum value. +%End + + void setDisplayHintDecimals( int displayHintDecimals ); +%Docstring +Set the display hint decimals. + +displayHintDecimals The number of decimals that should be shown in the Gui. +%End + + int displayHintDecimals() const; +%Docstring +Returns how much decimals should be shown in the Gui. +%End + +}; + + + + +typedef QgsSettingsEntryByReference QgsSettingsEntryByReferenceQColorBase; + +class QgsSettingsEntryColor : QgsSettingsEntryByReferenceQColorBase +{ +%Docstring(signature="appended") + +A color settings entry. + +.. versionadded:: 3.20 +%End + +%TypeHeaderCode +#include "qgssettingsentryimpl.h" +#include "qgssettingsentry.h" +typedef QgsSettingsEntryByReference QgsSettingsEntryByReferenceQColorBase; +%End + public: + + + QgsSettingsEntryColor( const QString &key, + const QString &pluginName, + const QColor &defaultValue = QColor(), + const QString &description = QString(), + Qgis::SettingsOptions options = Qgis::SettingsOptions() ); +%Docstring +Constructor for QgsSettingsEntryColor. +This constructor is intended to be used from plugins. + +The ``key`` argument specifies the key of the settings. +The ``pluginName`` argument is inserted in the key after 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 + + virtual bool setValue( const QColor &value, const QString &dynamicKeyPart = QString() ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key. +%End + + virtual bool setValue( const QColor &value, const QStringList &dynamicKeyPartList ) const; + +%Docstring +Set settings value. + +The ``value`` to set. +The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key. +%End + + virtual Qgis::SettingsType settingsType() const; + +}; + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/settings/qgssettingsentryimpl.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/python/core/core_auto.sip b/python/core/core_auto.sip index 24fef3f2c28..c8888f8a0d8 100644 --- a/python/core/core_auto.sip +++ b/python/core/core_auto.sip @@ -659,6 +659,7 @@ %Include auto_generated/textrenderer/qgstextshadowsettings.sip %Include auto_generated/settings/qgssettings.sip %Include auto_generated/settings/qgssettingsentry.sip +%Include auto_generated/settings/qgssettingsentryimpl.sip %Include auto_generated/settings/qgssettingsregistry.sip %Include auto_generated/settings/qgssettingsregistrycore.sip %Include auto_generated/validity/qgsabstractvaliditycheck.sip diff --git a/scripts/sipify.yaml b/python/sipify.yaml similarity index 57% rename from scripts/sipify.yaml rename to python/sipify.yaml index 50dc885408b..c17228c4e9d 100644 --- a/scripts/sipify.yaml +++ b/python/sipify.yaml @@ -2,6 +2,9 @@ class_headerfile: QgsAbstractFeatureIteratorFromSource: qgsfeatureiterator.h + QgsSettingsEntryByReference: qgssettingsentry.h + QgsSettingsEntryByValue: qgssettingsentry.h + no_export_macro: - QgsRange diff --git a/scripts/sipify.pl b/scripts/sipify.pl index 02adb3a0fa2..0227c538147 100755 --- a/scripts/sipify.pl +++ b/scripts/sipify.pl @@ -37,7 +37,7 @@ chomp(my @INPUT_LINES = <$handle>); close $handle; # config -my $cfg_file = File::Spec->catfile( dirname(__FILE__), 'sipify.yaml' ); +my $cfg_file = File::Spec->catfile( dirname(__FILE__), '../python/sipify.yaml' ); my $yaml = YAML::Tiny->read( $cfg_file ); my $SIP_CONFIG = $yaml->[0];