Skip to content
Permalink
Browse files
Merge pull request #42954 from domi4484/settingsRegistryQep124PartThree
Settings registry (QEP 124) part three
  • Loading branch information
3nids committed Apr 30, 2021
2 parents 8d0d677 + 810af98 commit 4e9932c37f19bcc7284a852302fb96a36071f35a
Showing with 995 additions and 637 deletions.
  1. +2 −3 python/core/__init__.py.in
  2. +32 −87 python/core/additions/qgssettingsentry.py
  3. +3 −3 python/core/auto_additions/qgssettingsentry.py
  4. +0 −1 python/core/auto_generated/layout/qgslayout.sip.in
  5. +0 −3 python/core/auto_generated/locator/qgslocator.sip.in
  6. +2 −0 python/core/auto_generated/network/qgsnetworkaccessmanager.sip.in
  7. +1 −0 python/core/auto_generated/network/qgsnewsfeedparser.sip.in
  8. +1 −0 python/core/auto_generated/processing/qgsprocessing.sip.in
  9. +1 −0 python/core/auto_generated/qgsapplication.sip.in
  10. +1 −0 python/core/auto_generated/qgsgeometryoptions.sip.in
  11. +1 −0 python/core/auto_generated/qgslocalizeddatapathregistry.sip.in
  12. +1 −0 python/core/auto_generated/qgsmaprendererjob.sip.in
  13. +150 −2 python/core/auto_generated/settings/qgssettingsentry.sip.in
  14. +4 −4 python/core/auto_generated/settings/qgssettingsregistry.sip.in
  15. +2 −0 python/core/auto_generated/settings/qgssettingsregistrycore.sip.in
  16. +2 −2 src/analysis/vector/geometry_checker/qgsgeometryisvalidcheck.cpp
  17. +5 −6 src/app/labeling/qgsmaptoollabel.cpp
  18. +6 −8 src/app/main.cpp
  19. +3 −6 src/app/maptools/qgsappmaptools.cpp
  20. +90 −93 src/app/options/qgsoptions.cpp
  21. +4 −5 src/app/qgisapp.cpp
  22. +1 −1 src/app/qgsdisplayangle.cpp
  23. +3 −4 src/app/qgsfeatureaction.cpp
  24. +2 −2 src/app/qgsmaptooladdellipse.h
  25. +15 −17 src/app/qgsmaptooloffsetcurve.cpp
  26. +1 −1 src/app/qgsmeasuredialog.cpp
  27. +1 −1 src/app/qgsprojectproperties.cpp
  28. +21 −16 src/app/qgssettingstree.cpp
  29. +1 −0 src/app/qgssettingstree.h
  30. +2 −3 src/app/qgssnappingwidget.cpp
  31. +3 −4 src/app/vertextool/qgslockedfeature.cpp
  32. +3 −5 src/app/vertextool/qgsvertextool.cpp
  33. +2 −0 src/core/layout/qgslayout.h
  34. +2 −0 src/core/locator/qgslocator.h
  35. +2 −2 src/core/network/qgsnetworkaccessmanager.cpp
  36. +7 −0 src/core/network/qgsnetworkaccessmanager.h
  37. +8 −9 src/core/network/qgsnewsfeedparser.cpp
  38. +12 −0 src/core/network/qgsnewsfeedparser.h
  39. +12 −0 src/core/processing/qgsprocessing.h
  40. +1 −1 src/core/processing/qgsprocessingcontext.cpp
  41. +0 −2 src/core/processing/qgsprocessingprovider.cpp
  42. +3 −5 src/core/processing/qgsprocessingutils.cpp
  43. +1 −1 src/core/project/qgsproject.cpp
  44. +4 −7 src/core/qgsapplication.cpp
  45. +14 −0 src/core/qgsapplication.h
  46. +1 −1 src/core/qgsgeometryoptions.cpp
  47. +6 −0 src/core/qgsgeometryoptions.h
  48. +2 −2 src/core/qgslocalizeddatapathregistry.cpp
  49. +6 −0 src/core/qgslocalizeddatapathregistry.h
  50. +1 −2 src/core/qgsmaprendererjob.cpp
  51. +6 −0 src/core/qgsmaprendererjob.h
  52. +9 −9 src/core/qgssnappingconfig.cpp
  53. +7 −10 src/core/qgstolerance.cpp
  54. +2 −2 src/core/qgstracer.cpp
  55. +55 −0 src/core/settings/qgssettingsentry.cpp
  56. +80 −82 src/core/settings/qgssettingsentry.h
  57. +5 −5 src/core/settings/qgssettingsregistry.cpp
  58. +4 −4 src/core/settings/qgssettingsregistry.h
  59. +69 −0 src/core/settings/qgssettingsregistrycore.cpp
  60. +118 −0 src/core/settings/qgssettingsregistrycore.h
  61. +4 −5 src/core/vector/qgsvectorlayerrenderer.cpp
  62. +4 −4 src/gui/qgsconfigureshortcutsdialog.cpp
  63. +1 −2 src/gui/qgsgui.cpp
  64. +2 −2 src/gui/qgsmapcanvas.cpp
  65. +4 −4 src/gui/qgsmapcanvassnappingutils.cpp
  66. +2 −2 src/gui/qgsmapcanvastracer.cpp
  67. +8 −12 src/gui/qgsmaptoolcapture.cpp
  68. +17 −27 src/gui/qgsmaptooledit.cpp
  69. +3 −5 src/gui/qgssnapindicator.cpp
  70. +2 −3 src/gui/vector/qgsattributesformproperties.cpp
  71. +9 −11 tests/src/analysis/testqgsprocessing.cpp
  72. +2 −1 tests/src/app/testqgsgpsinformationwidget.cpp
  73. +14 −15 tests/src/app/testqgsmaptooladdfeatureline.cpp
  74. +3 −3 tests/src/app/testqgsmaptooladdfeaturepoint.cpp
  75. +13 −13 tests/src/app/testqgsmaptoolcircle.cpp
  76. +11 −11 tests/src/app/testqgsmaptoolcircularstring.cpp
  77. +17 −17 tests/src/app/testqgsmaptoolellipse.cpp
  78. +17 −17 tests/src/app/testqgsmaptoolrectangle.cpp
  79. +13 −13 tests/src/app/testqgsmaptoolregularpolygon.cpp
  80. +3 −3 tests/src/app/testqgsmaptoolreshape.cpp
  81. +2 −2 tests/src/app/testqgsvertextool.cpp
  82. +1 −2 tests/src/core/testqgscompositionconverter.cpp
  83. +1 −1 tests/src/core/testqgsnetworkaccessmanager.cpp
  84. +5 −5 tests/src/core/testqgsnewsfeedparser.cpp
  85. +4 −4 tests/src/core/testqgssettingsentry.cpp
  86. +14 −14 tests/src/core/testqgssettingsregistry.cpp
  87. +4 −5 tests/src/core/testqgstranslateproject.cpp
  88. +3 −4 tests/src/gui/testqgsmaptooledit.cpp
  89. +5 −5 tests/src/python/test_qgssettingsentry.py
  90. +4 −4 tests/src/python/test_qgssettingsregistry.py
@@ -34,7 +34,7 @@ from .additions.qgsfeature import mapping_feature
from .additions.qgsfunction import register_function, qgsfunction
from .additions.qgsgeometry import _geometryNonZero, mapping_geometry
from .additions.qgssettings import _qgssettings_enum_value, _qgssettings_set_enum_value, _qgssettings_flag_value
from .additions.qgssettingsentry import PyQgsSettingsEntryEnum, PyQgsSettingsEntryFlag
from .additions.qgssettingsentry import PyQgsSettingsEntryEnumFlag
from .additions.qgstaskwrapper import QgsTaskWrapper
from .additions.readwritecontextentercategory import ReadWriteContextEnterCategory
from .additions.runtimeprofiler import ScopedRuntimeProfileContextManager
@@ -59,8 +59,7 @@ QgsDateTimeRange.__repr__ = datetime_range_repr
QgsDateRange.__repr__ = date_range_repr

# Classes patched
QgsSettingsEntryEnum = PyQgsSettingsEntryEnum
QgsSettingsEntryFlag = PyQgsSettingsEntryFlag
QgsSettingsEntryEnumFlag = PyQgsSettingsEntryEnumFlag

# Classes patched using a derived class
QgsProviderMetadata = PyProviderMetadata
@@ -22,76 +22,73 @@
import qgis # required to get base class of enums


class _PyQgsSettingsEntryEnumFlag(QgsSettingsEntryBase):
""" class QgsSettingsEntryEnum
ingroup core
An enum settings entry.
since QGIS 3.20
class PyQgsSettingsEntryEnumFlag(QgsSettingsEntryBase):
""" class PyQgsSettingsEntryEnumFlag
ingroup core
An enum settings entry.
since QGIS 3.20
"""

def __init__(self, key, pluginName, defaultValue, description=str()):
""" Constructor for _PyQgsSettingsEntryEnumFlag.
""" Constructor for PyQgsSettingsEntryEnumFlag.
:param self: the QgsSettingsEntryEnum object
:param key: argument specifies the final part of the settings key.
:param pluginName: argument is inserted in the key after the section.
:param defaultValue: argument specifies the default value for the settings entry.
:param description: argument specifies a description for the settings entry.
.. note:: This constructor should not be used. Use PyQgsSettingsEntryEnum
or PyQgsSettingsEntryFlag instead.
:param self: the PyQgsSettingsEntryEnumFlag object
:param key: argument specifies the final part of the settings key.
:param pluginName: argument is inserted in the key after the section.
:param defaultValue: argument specifies the default value for the settings entry.
:param description: argument specifies a description for the settings entry.
"""

defaultValueStr = str()
self.__metaEnum = metaEnumFromValue(defaultValue)
if self.__metaEnum is None or not self.__metaEnum.isValid():
QgsLogger.debug("Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '{0}'".format(self.key()))
else:
if self.settingsType() is self.SettingsType.Enum:
defaultValueStr = self.__metaEnum.valueToKey(defaultValue)
else:
if self.__metaEnum.isFlag():
defaultValueStr = self.__metaEnum.valueToKeys(defaultValue)
else:
defaultValueStr = self.__metaEnum.valueToKey(defaultValue)
self.__enumFlagClass = defaultValue.__class__

super().__init__(key, pluginName, defaultValueStr, description)

def value(self, dynamicKeyPart=None, useDefaultValueOverride=False, defaultValueOverride=None):
""" Get settings value.
:param self: the _PyQgsSettingsEntryEnumFlag object
:param dynamicKeyPart: argument specifies the dynamic part of the settings key.
:param useDefaultValueOverride: argument specifies if defaultValueOverride should be used.
:param defaultValueOverride: argument if valid is used instead of the normal default value.
:param self: the PyQgsSettingsEntryEnumFlag object
:param dynamicKeyPart: argument specifies the dynamic part of the settings key.
:param useDefaultValueOverride: argument specifies if defaultValueOverride should be used.
:param defaultValueOverride: argument if valid is used instead of the normal default value.
"""

defaultValue = self.defaultValue()
if useDefaultValueOverride:
defaultValue = defaultValueOverride

if self.settingsType() is self.SettingsType.Enum:
return QgsSettings().enumValue(self.key(dynamicKeyPart),
if self.__metaEnum.isFlag():
return QgsSettings().flagValue(self.key(dynamicKeyPart),
defaultValue,
self.section())
else:
return QgsSettings().flagValue(self.key(dynamicKeyPart),
return QgsSettings().enumValue(self.key(dynamicKeyPart),
defaultValue,
self.section())

def defaultValue(self):
""" Get settings default value.
:param self: the _PyQgsSettingsEntryEnumFlag object
:param self: the PyQgsSettingsEntryEnumFlag object
"""

if self.__metaEnum is None or not self.__metaEnum.isValid():
QgsLogger.debug("Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '{0}'".format(self.key()))
return -1

defaultValueString = self.defaultValueAsVariant()
if self.settingsType() is self.SettingsType.Enum:
(defaultValue, ok) = self.__metaEnum.keyToValue(defaultValueString)
else:
if self.__metaEnum.isFlag():
(defaultValue, ok) = self.__metaEnum.keysToValue(defaultValueString)
else:
(defaultValue, ok) = self.__metaEnum.keyToValue(defaultValueString)
if not ok:
QgsLogger.debug("Invalid enum/flag key/s '{0}'.".format(self.defaultValueAsVariant()))
return -1
@@ -103,81 +100,29 @@ def defaultValue(self):
def setValue(self, value, dynamicKeyPart=None):
""" Set settings value.
:param self: the _PyQgsSettingsEntryEnumFlag object
:param dynamicKeyPart: argument specifies the dynamic part of the settings key.
:param self: the PyQgsSettingsEntryEnumFlag object
:param dynamicKeyPart: argument specifies the dynamic part of the settings key.
"""

if self.__metaEnum is None or not self.__metaEnum.isValid():
QgsLogger.debug("Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '{0}'".format(self.key()))
return False

enumFlagKey = str()
if self.settingsType() is self.SettingsType.Enum:
enumFlagKey = self.__metaEnum.valueToKey(value)
else:
if self.__metaEnum.isFlag():
enumFlagKey = self.__metaEnum.valueToKeys(value)
else:
enumFlagKey = self.__metaEnum.valueToKey(value)
if not enumFlagKey:
QgsLogger.debug("Invalid enum/flag value '{0}'.".format(value))
return False

return super().setVariantValue(enumFlagKey, dynamicKeyPart)


class PyQgsSettingsEntryEnum(_PyQgsSettingsEntryEnumFlag):
""" class QgsSettingsEntryEnum
ingroup core
An enum settings entry.
since QGIS 3.20
"""

def __init__(self, key, pluginName, defaultValue, description=str()):
""" Constructor for QgsSettingsEntryEnum.
:param self: the QgsSettingsEntryEnum object
:param key: argument specifies the final part of the settings key.
:param pluginName: argument is inserted in the key after the section.
:param defaultValue: argument specifies the default value for the settings entry.
:param description: argument specifies a description for the settings entry.
.. note:: The enum needs to be declared with Q_ENUM.
"""

super().__init__(key, pluginName, defaultValue, description)

def settingsType(self):
""" Get the settings entry type.
:param self: the QgsSettingsEntryEnum object
"""

return self.SettingsType.Enum


class PyQgsSettingsEntryFlag(_PyQgsSettingsEntryEnumFlag):
""" class QgsSettingsEntryFlag
ingroup core
A flag settings entry.
since QGIS 3.20
"""

def __init__(self, key, pluginName, defaultValue, description=str()):
""" Constructor for QgsSettingsEntryFlag.
:param self: the QgsSettingsEntryFlag object
:param key: argument specifies the final part of the settings key.
:param pluginName: argument is inserted in the key after the section.
:param defaultValue: argument specifies the default value for the settings entry.
:param description: argument specifies a description for the settings entry.
.. note:: The flag needs to be declared with Q_FLAG (not Q_FLAGS).
"""

super().__init__(key, pluginName, defaultValue, description)

def settingsType(self):
""" Get the settings entry type.
:param self: the QgsSettingsEntryFlag object
:param self: the PyQgsSettingsEntryEnumFlag object
"""

return self.SettingsType.Flag
return self.SettingsType.EnumFlag
@@ -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__
# --
@@ -614,7 +614,6 @@ should be canceled.
.. versionadded:: 3.10
%End

const QgsSettingsEntryStringList settingsSearchPathForTemplates;

public slots:

@@ -141,9 +141,6 @@ This list is updated when preparing the search
.. versionadded:: 3.16
%End

const QgsSettingsEntryBool settingsLocatorFilterEnabled;
const QgsSettingsEntryBool settingsLocatorFilterDefault;
const QgsSettingsEntryString settingsLocatorFilterPrefix;

signals:

@@ -343,6 +343,8 @@ Forwards an external browser login closure request to the authentication handler
.. versionadded:: 3.20
%End



signals:

void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * ) /Deprecated/;
@@ -93,6 +93,7 @@ Returns the authentication configuration for the parser.
Returns the settings key used for a feed with the given ``baseUrl``.
%End


public slots:

void fetch();
@@ -52,6 +52,7 @@ Converts a source ``type`` to a string representation.
%End

static const QString TEMPORARY_OUTPUT;

};

/************************************************************************
@@ -1003,6 +1003,7 @@ Emits the signal to collect all the strings of .qgs to be included in ts file
.. versionadded:: 3.4
%End


%If (ANDROID)
//dummy method to workaround sip generation issue
bool x11EventFilter( XEvent *event );
@@ -118,6 +118,7 @@ Read the geometry options from ``node``.
.. versionadded:: 3.4
%End


signals:

void checkConfigurationChanged();
@@ -60,6 +60,7 @@ Since the paths are stored by order of preference, lower positions in the list t
Unregisters a localized path
%End


private:
QgsLocalizedDataPathRegistry( const QgsLocalizedDataPathRegistry &other );
};
@@ -157,6 +157,7 @@ Returns map settings with which this job was started.




signals:

void renderingLayersFinished();

0 comments on commit 4e9932c

Please sign in to comment.