Skip to content

Commit

Permalink
Enum flag sip
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Apr 26, 2021
1 parent 95dfe0f commit 4fb0ab2
Show file tree
Hide file tree
Showing 8 changed files with 537 additions and 88 deletions.
6 changes: 3 additions & 3 deletions python/core/auto_additions/qgssettingsentry.py
Expand Up @@ -6,7 +6,7 @@
QgsSettingsEntryBase.SettingsType.Bool.__doc__ = ""
QgsSettingsEntryBase.SettingsType.Integer.__doc__ = ""
QgsSettingsEntryBase.SettingsType.Double.__doc__ = ""
QgsSettingsEntryBase.SettingsType.Enum.__doc__ = ""
QgsSettingsEntryBase.SettingsType.Flag.__doc__ = ""
QgsSettingsEntryBase.SettingsType.__doc__ = '\n\n' + '* ``Variant``: ' + QgsSettingsEntryBase.SettingsType.Variant.__doc__ + '\n' + '* ``String``: ' + QgsSettingsEntryBase.SettingsType.String.__doc__ + '\n' + '* ``StringList``: ' + QgsSettingsEntryBase.SettingsType.StringList.__doc__ + '\n' + '* ``Bool``: ' + QgsSettingsEntryBase.SettingsType.Bool.__doc__ + '\n' + '* ``Integer``: ' + QgsSettingsEntryBase.SettingsType.Integer.__doc__ + '\n' + '* ``Double``: ' + QgsSettingsEntryBase.SettingsType.Double.__doc__ + '\n' + '* ``Enum``: ' + QgsSettingsEntryBase.SettingsType.Enum.__doc__ + '\n' + '* ``Flag``: ' + QgsSettingsEntryBase.SettingsType.Flag.__doc__
QgsSettingsEntryBase.SettingsType.EnumFlag.__doc__ = ""
QgsSettingsEntryBase.SettingsType.Color.__doc__ = ""
QgsSettingsEntryBase.SettingsType.__doc__ = '\n\n' + '* ``Variant``: ' + QgsSettingsEntryBase.SettingsType.Variant.__doc__ + '\n' + '* ``String``: ' + QgsSettingsEntryBase.SettingsType.String.__doc__ + '\n' + '* ``StringList``: ' + QgsSettingsEntryBase.SettingsType.StringList.__doc__ + '\n' + '* ``Bool``: ' + QgsSettingsEntryBase.SettingsType.Bool.__doc__ + '\n' + '* ``Integer``: ' + QgsSettingsEntryBase.SettingsType.Integer.__doc__ + '\n' + '* ``Double``: ' + QgsSettingsEntryBase.SettingsType.Double.__doc__ + '\n' + '* ``EnumFlag``: ' + QgsSettingsEntryBase.SettingsType.EnumFlag.__doc__ + '\n' + '* ``Color``: ' + QgsSettingsEntryBase.SettingsType.Color.__doc__
# --
163 changes: 161 additions & 2 deletions python/core/auto_generated/settings/qgssettingsentry.sip.in
Expand Up @@ -36,6 +36,8 @@ to validate set values and provide more accurate settings description for the gu
sipType = sipType_QgsSettingsEntryInteger;
else if ( dynamic_cast< QgsSettingsEntryDouble * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryDouble;
else if ( dynamic_cast< QgsSettingsEntryColor * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryColor;
else
sipType = NULL;
%End
Expand All @@ -49,8 +51,8 @@ to validate set values and provide more accurate settings description for the gu
Bool,
Integer,
Double,
Enum,
Flag
EnumFlag,
Color
};


Expand Down Expand Up @@ -757,10 +759,167 @@ Returns how much decimals should be shown in the Gui.



template <T>
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 QgsSettingsEntryEnumFlag.

The ``key`` argument specifies the final part of the settings key.
The ``section`` argument specifies the section.
The ``default`` value 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
Get 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
Get 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

T defaultValue() const;
%Docstring
Get settings default value.
%End

bool setValue( const T &value, const QString &dynamicKeyPart = QString() ) const;
%Docstring
\copydoc :py:class:`QgsSettingsEntryBase`.setValue
%End

bool setValue( const T &value, const QStringList &dynamicKeyPartList ) const;
%Docstring
\copydoc :py:class:`QgsSettingsEntryBase`.setValue
%End

virtual QgsSettingsEntryBase::SettingsType settingsType() const;
%Docstring
\copydoc :py:class:`QgsSettingsEntryBase`.settingsType
%End

};












class QgsSettingsEntryColor : QgsSettingsEntryBase
{
%Docstring(signature="appended")
A color settings entry.

.. versionadded:: 3.20
%End

%TypeHeaderCode
#include "qgssettingsentry.h"
%End
public:


QgsSettingsEntryColor( const QString &key,
const QString &pluginName,
const QColor &defaultValue = QColor(),
const QString &description = QString() );
%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 ``default`` value argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
%End

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

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

QColor value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const QString &defaultValueOverride = QString() ) const;
%Docstring
Get 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;
%Docstring
Get 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

QColor defaultValue() const;
%Docstring
Get settings default value.
%End

virtual SettingsType settingsType() const;
%Docstring
\copydoc :py:class:`QgsSettingsEntryBase`.settingsType
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
84 changes: 84 additions & 0 deletions python/core/auto_generated/settings/qgssettingsregistrycore.sip.in
Expand Up @@ -33,6 +33,7 @@ Constructor for QgsSettingsRegistryCore.

virtual ~QgsSettingsRegistryCore();

<<<<<<< HEAD
const QgsSettingsEntryBase *getSettingsEntry( const QString &key );
%Docstring
Returns the :py:class:`QgsSettingsEntry` with the given ``key`` or None if not found.
Expand All @@ -42,6 +43,89 @@ Returns the :py:class:`QgsSettingsEntry` with the given ``key`` or None if not f
%Docstring
Add ``settingsEntry`` to the register.
%End
=======
const QgsSettingsEntryInteger settingsDigitizingStreamTolerance;

const QgsSettingsEntryInteger settingsDigitizingLineWidth;

const QgsSettingsEntryInteger settingsDigitizingLineColorRed;

const QgsSettingsEntryInteger settingsDigitizingLineColorGreen;

const QgsSettingsEntryInteger settingsDigitizingLineColorBlue;

const QgsSettingsEntryInteger settingsDigitizingLineColorAlpha;

const QgsSettingsEntryDouble settingsDigitizingLineColorAlphaScale;

const QgsSettingsEntryInteger settingsDigitizingFillColorRed;

const QgsSettingsEntryInteger settingsDigitizingFillColorGreen;

const QgsSettingsEntryInteger settingsDigitizingFillColorBlue;

const QgsSettingsEntryInteger settingsDigitizingFillColorAlpha;

const QgsSettingsEntryBool settingsDigitizingLineGhost;

const QgsSettingsEntryDouble settingsDigitizingDefaultZValue;

const QgsSettingsEntryBool settingsDigitizingDefaultSnapEnabled;

class QgsSettingsEntryEnumFlag_settingsDigitizingDefaultSnapType
{
%TypeHeaderCode
#include "qgssettingsregistrycore.h"
#include "qgssettingsentry.h"
typedef QgsSettingsEntryEnumFlag<QgsSnappingConfig::SnappingTypes> QgsSettingsEntryEnumFlag_settingsDigitizingDefaultSnapType;
%End
public:
QgsSettingsEntryEnumFlag_settingsDigitizingDefaultSnapType( const QString &key, QgsSettings::Section section, const QgsSnappingConfig::SnappingTypes &defaultValue, const QString &description = QString() );
QString key( const QString &dynamicKeyPart = QString() ) const;
QgsSnappingConfig::SnappingTypes value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const QgsSnappingConfig::SnappingTypes &defaultValueOverride = QgsSnappingConfig::SnappingTypes() ) const;
};
const QgsSettingsEntryEnumFlag_settingsDigitizingDefaultSnapType settingsDigitizingDefaultSnapType;

const QgsSettingsEntryDouble settingsDigitizingDefaultSnappingTolerance;


const QgsSettingsEntryDouble settingsDigitizingSearchRadiusVertexEdit;


const QgsSettingsEntryColor settingsDigitizingSnapColor;

const QgsSettingsEntryBool settingsDigitizingSnapTooltip;

const QgsSettingsEntryBool settingsDigitizingSnapInvisibleFeature;

const QgsSettingsEntryBool settingsDigitizingMarkerOnlyForSelected;

const QgsSettingsEntryString settingsDigitizingMarkerStyle;

const QgsSettingsEntryDouble settingsDigitizingMarkerSizeMm;

const QgsSettingsEntryBool settingsDigitizingReuseLastValues;

const QgsSettingsEntryBool settingsDigitizingDisableEnterAttributeValuesDialog;

const QgsSettingsEntryInteger settingsDigitizingValidateGeometries;


const QgsSettingsEntryInteger settingsDigitizingOffsetQuadSeg;

const QgsSettingsEntryDouble settingsDigitizingOffsetMiterLimit;

const QgsSettingsEntryBool settingsDigitizingConvertToCurve;

const QgsSettingsEntryDouble settingsDigitizingConvertToCurveAngleTolerance;

const QgsSettingsEntryDouble settingsDigitizingConvertToCurveDistanceTolerance;


const QgsSettingsEntryBool settingsDigitizingOffsetShowAdvanced;

const QgsSettingsEntryInteger settingsDigitizingTracingMaxFeatureCount;
>>>>>>> 27bb50bc4d (Enum flag sip)

};

Expand Down
49 changes: 49 additions & 0 deletions src/core/settings/qgssettingsentry.cpp
Expand Up @@ -642,4 +642,53 @@ int QgsSettingsEntryDouble::displayHintDecimals() const
return mDisplayHintDecimals;
}

QgsSettingsEntryColor::QgsSettingsEntryColor( const QString &key, QgsSettings::Section section, const QColor &defaultValue, const QString &description )
: QgsSettingsEntryBase( key,
section,
defaultValue,
description )
{
}

QgsSettingsEntryColor::QgsSettingsEntryColor( const QString &key, const QString &pluginName, const QColor &defaultValue, const QString &description )
: QgsSettingsEntryBase( key,
pluginName,
defaultValue,
description )
{
}

bool QgsSettingsEntryColor::setValue( const QColor &value, const QString &dynamicKeyPart ) const
{
QStringList dynamicKeyPartList;
if ( !dynamicKeyPart.isNull() )
dynamicKeyPartList.append( dynamicKeyPart );

return setValue( value, dynamicKeyPartList );
}

bool QgsSettingsEntryColor::setValue( const QColor &value, const QStringList &dynamicKeyPartList ) const
{
return QgsSettingsEntryBase::setVariantValue( value, dynamicKeyPartList );
}

QColor QgsSettingsEntryColor::value( const QString &dynamicKeyPart, bool useDefaultValueOverride, const QString &defaultValueOverride ) const
{
return valueAsVariant( dynamicKeyPart, useDefaultValueOverride, defaultValueOverride ).value<QColor>();
}

QColor QgsSettingsEntryColor::value( const QStringList &dynamicKeyPartList, bool useDefaultValueOverride, const QString &defaultValueOverride ) const
{
return valueAsVariant( dynamicKeyPartList, useDefaultValueOverride, defaultValueOverride ).value<QColor>();
}

QColor QgsSettingsEntryColor::defaultValue() const
{
return defaultValueAsVariant().value<QColor>();
}

QgsSettingsEntryBase::SettingsType QgsSettingsEntryColor::settingsType() const
{
return QgsSettingsEntryBase::SettingsType::Color;
}

0 comments on commit 4fb0ab2

Please sign in to comment.