diff --git a/python/core/additions/qgssettingsentry.py b/python/core/additions/qgssettingsentry.py index eb09bb72c5c..6bd23ccb898 100644 --- a/python/core/additions/qgssettingsentry.py +++ b/python/core/additions/qgssettingsentry.py @@ -54,7 +54,7 @@ class PyQgsSettingsEntryEnumFlag(QgsSettingsEntryBase): self.__enumFlagClass = defaultValue.__class__ if type(pluginName) == str: - parent = QgsSettings.createPluginTreeElement(pluginName) + parent = QgsSettings.createPluginTreeNode(pluginName) else: parent = pluginName super().__init__(key, parent, defaultValueStr, description, options) diff --git a/python/core/auto_additions/qgssettingstreenode.py b/python/core/auto_additions/qgssettingstreenode.py index be035d92426..90475cfc0b3 100644 --- a/python/core/auto_additions/qgssettingstreenode.py +++ b/python/core/auto_additions/qgssettingstreenode.py @@ -1,14 +1,14 @@ # The following has been generated automatically from src/core/settings/qgssettingstreenode.h # monkey patching scoped based enum -QgsSettingsTreeNode.Type.Root.__doc__ = "Root Element" -QgsSettingsTreeNode.Type.Standard.__doc__ = "Normal Element" +QgsSettingsTreeNode.Type.Root.__doc__ = "Root Node" +QgsSettingsTreeNode.Type.Standard.__doc__ = "Normal Node" QgsSettingsTreeNode.Type.NamedList.__doc__ = "" -QgsSettingsTreeNode.Type.__doc__ = 'Type of tree element\n\n' + '* ``Root``: ' + QgsSettingsTreeNode.Type.Root.__doc__ + '\n' + '* ``Standard``: ' + QgsSettingsTreeNode.Type.Standard.__doc__ + '\n' + '* ``NamedList``: ' + QgsSettingsTreeNode.Type.NamedList.__doc__ +QgsSettingsTreeNode.Type.__doc__ = 'Type of tree node\n\n' + '* ``Root``: ' + QgsSettingsTreeNode.Type.Root.__doc__ + '\n' + '* ``Standard``: ' + QgsSettingsTreeNode.Type.Standard.__doc__ + '\n' + '* ``NamedList``: ' + QgsSettingsTreeNode.Type.NamedList.__doc__ # -- QgsSettingsTreeNode.Type.baseClass = QgsSettingsTreeNode # monkey patching scoped based enum QgsSettingsTreeNode.Option.NamedListSelectedItemSetting.__doc__ = "Creates a setting to store which is the current item" -QgsSettingsTreeNode.Option.__doc__ = 'Options for named list elements\n\n' + '* ``NamedListSelectedItemSetting``: ' + QgsSettingsTreeNode.Option.NamedListSelectedItemSetting.__doc__ +QgsSettingsTreeNode.Option.__doc__ = 'Options for named list nodes\n\n' + '* ``NamedListSelectedItemSetting``: ' + QgsSettingsTreeNode.Option.NamedListSelectedItemSetting.__doc__ # -- QgsSettingsTreeNode.Option.baseClass = QgsSettingsTreeNode QgsSettingsTreeNode.Options.baseClass = QgsSettingsTreeNode diff --git a/python/core/auto_generated/settings/qgssettings.sip.in b/python/core/auto_generated/settings/qgssettings.sip.in index 600a04cf593..c159551f855 100644 --- a/python/core/auto_generated/settings/qgssettings.sip.in +++ b/python/core/auto_generated/settings/qgssettings.sip.in @@ -66,17 +66,17 @@ static bool setGlobalSettingsPath( QString path ); }; - static QgsSettingsTreeNode *createPluginTreeElement( const QString &pluginName ); + static QgsSettingsTreeNode *createPluginTreeNode( const QString &pluginName ); %Docstring -Creates a settings tree element for the given ``pluginName`` +Creates a settings tree node for the given ``pluginName`` .. versionadded:: 3.30 %End - static void unregisterPluginTreeElement( const QString &pluginName ); + static void unregisterPluginTreeNode( const QString &pluginName ); %Docstring -Unregisters the tree element for the given plugin +Unregisters the tree node for the given plugin .. versionadded:: 3.30 %End diff --git a/python/core/auto_generated/settings/qgssettingsentryimpl.sip.in b/python/core/auto_generated/settings/qgssettingsentryimpl.sip.in index ee25d64f7d2..f64b23fb8ef 100644 --- a/python/core/auto_generated/settings/qgssettingsentryimpl.sip.in +++ b/python/core/auto_generated/settings/qgssettingsentryimpl.sip.in @@ -81,7 +81,7 @@ This constructor is intended to be used from plugins. :param options: specifies the options for the settings entry. %End %MethodCode - sipCpp = new sipQgsSettingsEntryVariant( QgsSettingsEntryVariant( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4 ) ); + sipCpp = new sipQgsSettingsEntryVariant( QgsSettingsEntryVariant( *a0, QgsSettings::createPluginTreeNode( *a1 ), *a2, *a3, *a4 ) ); %End @@ -188,7 +188,7 @@ This constructor is intended to be used from plugins. :param options: specifies the options for the settings entry. %End %MethodCode - sipCpp = new sipQgsSettingsEntryString( QgsSettingsEntryString( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4 ) ); + sipCpp = new sipQgsSettingsEntryString( QgsSettingsEntryString( *a0, QgsSettings::createPluginTreeNode( *a1 ), *a2, *a3, *a4 ) ); %End virtual Qgis::SettingsType settingsType() const; @@ -279,7 +279,7 @@ This constructor is intended to be used from plugins. :param options: specifies the options for the settings entry. %End %MethodCode - sipCpp = new sipQgsSettingsEntryStringList( QgsSettingsEntryStringList( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4 ) ); + sipCpp = new sipQgsSettingsEntryStringList( QgsSettingsEntryStringList( *a0, QgsSettings::createPluginTreeNode( *a1 ), *a2, *a3, *a4 ) ); %End virtual Qgis::SettingsType settingsType() const; @@ -357,7 +357,7 @@ This constructor is intended to be used from plugins. :param options: specifies the options for the settings entry. %End %MethodCode - sipCpp = new sipQgsSettingsEntryBool( QgsSettingsEntryBool( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4 ) ); + sipCpp = new sipQgsSettingsEntryBool( QgsSettingsEntryBool( *a0, QgsSettings::createPluginTreeNode( *a1 ), a2, *a3, *a4 ) ); %End @@ -448,7 +448,7 @@ This constructor is intended to be used from plugins. :param maxValue: specifies the maximal value. %End %MethodCode - sipCpp = new sipQgsSettingsEntryInteger( QgsSettingsEntryInteger( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4, a5, a6 ) ); + sipCpp = new sipQgsSettingsEntryInteger( QgsSettingsEntryInteger( *a0, QgsSettings::createPluginTreeNode( *a1 ), a2, *a3, *a4, a5, a6 ) ); %End virtual Qgis::SettingsType settingsType() const; @@ -558,7 +558,7 @@ This constructor is intended to be used from plugins. :param displayDecimals: specifies a hint for the gui about how much decimals to show %End %MethodCode - sipCpp = new sipQgsSettingsEntryDouble( QgsSettingsEntryDouble( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4, a5, a6, a7 ) ); + sipCpp = new sipQgsSettingsEntryDouble( QgsSettingsEntryDouble( *a0, QgsSettings::createPluginTreeNode( *a1 ), a2, *a3, *a4, a5, a6, a7 ) ); %End @@ -667,7 +667,7 @@ This constructor is intended to be used from plugins. :param options: specifies the options for the settings entry. %End %MethodCode - sipCpp = new sipQgsSettingsEntryColor( QgsSettingsEntryColor( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4, a5 ) ); + sipCpp = new sipQgsSettingsEntryColor( QgsSettingsEntryColor( *a0, QgsSettings::createPluginTreeNode( *a1 ), *a2, *a3, *a4, a5 ) ); %End virtual Qgis::SettingsType settingsType() const; @@ -757,7 +757,7 @@ This constructor is intended to be used from plugins. :param options: specifies the options for the settings entry. %End %MethodCode - sipCpp = new sipQgsSettingsEntryVariantMap( QgsSettingsEntryVariantMap( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4 ) ); + sipCpp = new sipQgsSettingsEntryVariantMap( QgsSettingsEntryVariantMap( *a0, QgsSettings::createPluginTreeNode( *a1 ), *a2, *a3, *a4 ) ); %End virtual Qgis::SettingsType settingsType() const; diff --git a/python/core/auto_generated/settings/qgssettingstreeelement.sip.in b/python/core/auto_generated/settings/qgssettingstreeelement.sip.in index bbf667ae48b..720d1e504ba 100644 --- a/python/core/auto_generated/settings/qgssettingstreeelement.sip.in +++ b/python/core/auto_generated/settings/qgssettingstreeelement.sip.in @@ -61,7 +61,7 @@ to automatically register a settings entry on its creation when a parent is prov virtual ~QgsSettingsTreeNode(); - QgsSettingsTreeNode *createChildElement( const QString &key ) throw( QgsSettingsException ) /KeepReference/; + QgsSettingsTreeNode *createChildNode( const QString &key ) throw( QgsSettingsException ) /KeepReference/; %Docstring Creates a normal tree element It will return the existing child element if it exists at the given key @@ -69,7 +69,7 @@ It will return the existing child element if it exists at the given key :raises QgsSettingsException: if a setting exists with the same key %End - QgsSettingsTreeNamedListNode *createNamedListElement( const QString &key, const QgsSettingsTreeNode::Options &options = QgsSettingsTreeNode::Options() ) throw( QgsSettingsException ) /KeepReference/; + QgsSettingsTreeNamedListNode *createNamedListNode( const QString &key, const QgsSettingsTreeNode::Options &options = QgsSettingsTreeNode::Options() ) throw( QgsSettingsException ) /KeepReference/; %Docstring Creates a named list tree element. This is useful to register groups of settings for several named items (for instance credentials for several named services) @@ -177,7 +177,7 @@ Registers a child elements This is not available in Python bindings. Use method createElement on an existing tree element. -.. seealso:: :py:func:`QgsSettings.createPluginTreeElement` +.. seealso:: :py:func:`QgsSettings.createPluginTreeNode` %End QgsSettingsTreeNode( const QgsSettingsTreeNode &other ); }; @@ -272,9 +272,9 @@ Init the elements with the specific ``options`` .. note:: - This is not available in Python bindings. Use method createNamedListElement on an existing tree element. + This is not available in Python bindings. Use method createNamedListNode on an existing tree element. -.. seealso:: :py:func:`QgsSettings.createPluginTreeElement` +.. seealso:: :py:func:`QgsSettings.createPluginTreeNode` %End QgsSettingsTreeNamedListNode( const QgsSettingsTreeNamedListNode &other ); }; diff --git a/python/core/auto_generated/settings/qgssettingstreenode.sip.in b/python/core/auto_generated/settings/qgssettingstreenode.sip.in index 5a3110e2d7b..a4e80e6fda3 100644 --- a/python/core/auto_generated/settings/qgssettingstreenode.sip.in +++ b/python/core/auto_generated/settings/qgssettingstreenode.sip.in @@ -14,11 +14,11 @@ class QgsSettingsTreeNode { %Docstring(signature="appended") -:py:class:`QgsSettingsTreeNode` is a tree element for the settings registry +:py:class:`QgsSettingsTreeNode` is a tree node for the settings registry to help organizing and introspecting the registry. -It is either a root element, a normal element or +It is either a root node, a normal node or a named list (to store a group of settings under a dynamic named key). -The root element holds a pointer to a registry (might be null) +The root node holds a pointer to a registry (might be null) to automatically register a settings entry on its creation when a parent is provided. .. seealso:: :py:class:`QgsSettingsEntryBase` @@ -61,24 +61,24 @@ to automatically register a settings entry on its creation when a parent is prov virtual ~QgsSettingsTreeNode(); - QgsSettingsTreeNode *createChildElement( const QString &key ) throw( QgsSettingsException ) /KeepReference/; + QgsSettingsTreeNode *createChildNode( const QString &key ) throw( QgsSettingsException ) /KeepReference/; %Docstring -Creates a normal tree element -It will return the existing child element if it exists at the given key +Creates a normal tree node +It will return the existing child node if it exists at the given key :raises QgsSettingsException: if a setting exists with the same key %End - QgsSettingsTreeNamedListNode *createNamedListElement( const QString &key, const QgsSettingsTreeNode::Options &options = QgsSettingsTreeNode::Options() ) throw( QgsSettingsException ) /KeepReference/; + QgsSettingsTreeNamedListNode *createNamedListNode( const QString &key, const QgsSettingsTreeNode::Options &options = QgsSettingsTreeNode::Options() ) throw( QgsSettingsException ) /KeepReference/; %Docstring -Creates a named list tree element. +Creates a named list tree node. This is useful to register groups of settings for several named items (for instance credentials for several named services) %End Type type() const; %Docstring -Returns the type of element +Returns the type of node %End void registerChildSetting( const QgsSettingsEntryBase *setting, const QString &key ) throw( QgsSettingsException ); @@ -108,19 +108,19 @@ Unregisters the child setting :param parentsNamedItems: the list of named items in the parent named list (if any) %End - void unregisterChildElement( QgsSettingsTreeNode *element ); + void unregisterChildNode( QgsSettingsTreeNode *node ); %Docstring -Unregisters the child tree ``element`` +Unregisters the child tree ``node`` %End - QList childrenElements() const; + QList childrenNodes() const; %Docstring -Returns the children elements +Returns the children nodes %End - QgsSettingsTreeNode *childElement( const QString &key ); + QgsSettingsTreeNode *childNode( const QString &key ); %Docstring -Returns the existing child element if it exists at the given ``key`` +Returns the existing child node if it exists at the given ``key`` %End QList childrenSettings() const; @@ -135,22 +135,22 @@ Returns the existing child settings if it exists at the given ``key`` QgsSettingsTreeNode *parent() const; %Docstring -Returns the parent of the element or None if it does not exists +Returns the parent of the node or None if it does not exists %End QString key() const; %Docstring -Returns the key of the element (without its parents) +Returns the key of the node (without its parents) %End QString completeKey() const; %Docstring -Returns the complete key of the element (including its parents) +Returns the complete key of the node (including its parents) %End - int namedElementsCount() const; + int namedNodesCount() const; %Docstring -Returns the number of named elements in the complete key +Returns the number of named nodes in the complete key %End SIP_PYOBJECT __repr__(); @@ -162,9 +162,9 @@ Returns the number of named elements in the complete key %End protected: - void registerChildElement( QgsSettingsTreeNode *element ); + void registerChildNode( QgsSettingsTreeNode *node ); %Docstring -Registers a child elements +Registers a child nodes %End @@ -175,9 +175,9 @@ Registers a child elements .. note:: - This is not available in Python bindings. Use method createElement on an existing tree element. + This is not available in Python bindings. Use method createNode on an existing tree node. -.. seealso:: :py:func:`QgsSettings.createPluginTreeElement` +.. seealso:: :py:func:`QgsSettings.createPluginTreeNode` %End QgsSettingsTreeNode( const QgsSettingsTreeNode &other ); }; @@ -187,9 +187,9 @@ Registers a child elements class QgsSettingsTreeNamedListNode : QgsSettingsTreeNode { %Docstring(signature="appended") -:py:class:`QgsSettingsTreeNamedListNode` is a named list tree element for the settings registry +:py:class:`QgsSettingsTreeNamedListNode` is a named list tree node for the settings registry to help organizing and introspecting the registry. -the named list element is used to store a group of settings under a dynamically named key. +the named list node is used to store a group of settings under a dynamically named key. .. seealso:: :py:class:`QgsSettingsTreeNode` @@ -228,7 +228,7 @@ Returns the list of items void setSelectedItem( const QString &item, const QStringList &parentsNamedItems = QStringList() ) throw( QgsSettingsException ); %Docstring -Sets the selected named item from the named list element +Sets the selected named item from the named list node :param item: the item to set as selected :param parentsNamedItems: the list of named items in the parent named list (if any) @@ -238,7 +238,7 @@ Sets the selected named item from the named list element QString selectedItem( const QStringList &parentsNamedItems = QStringList() ) throw( QgsSettingsException ); %Docstring -Returns the selected named item from the named list element +Returns the selected named item from the named list node :param parentsNamedItems: the list of named items in the parent named list (if any) @@ -247,7 +247,7 @@ Returns the selected named item from the named list element void deleteItem( const QString &item, const QStringList &parentsNamedItems = QStringList() ) throw( QgsSettingsException ); %Docstring -Deletes a named item from the named list element +Deletes a named item from the named list node :param item: the item to delete :param parentsNamedItems: the list of named items in the parent named list (if any) @@ -263,7 +263,7 @@ Returns the setting used to store the selected item protected: void initNamedList( const QgsSettingsTreeNode::Options &options ); %Docstring -Init the elements with the specific ``options`` +Init the nodes with the specific ``options`` %End private: @@ -272,9 +272,9 @@ Init the elements with the specific ``options`` .. note:: - This is not available in Python bindings. Use method createNamedListElement on an existing tree element. + This is not available in Python bindings. Use method createNamedListNode on an existing tree node. -.. seealso:: :py:func:`QgsSettings.createPluginTreeElement` +.. seealso:: :py:func:`QgsSettings.createPluginTreeNode` %End QgsSettingsTreeNamedListNode( const QgsSettingsTreeNamedListNode &other ); }; diff --git a/python/pyplugin_installer/installer.py b/python/pyplugin_installer/installer.py index fad63b74a34..97ee2d8a989 100644 --- a/python/pyplugin_installer/installer.py +++ b/python/pyplugin_installer/installer.py @@ -578,7 +578,7 @@ class QgsPluginInstaller(QObject): if not os.path.isfile(filePath): return - QgsSettings.createPluginTreeElement("_plugin_manager").childSetting("last-zip-directory").setValue(QFileInfo(filePath).absoluteDir().absolutePath()) + QgsSettings.createPluginTreeNode("_plugin_manager").childSetting("last-zip-directory").setValue(QFileInfo(filePath).absoluteDir().absolutePath()) pluginName = None with zipfile.ZipFile(filePath, 'r') as zf: diff --git a/python/pyplugin_installer/installer_data.py b/python/pyplugin_installer/installer_data.py index addbc971f2b..c85e61eda36 100644 --- a/python/pyplugin_installer/installer_data.py +++ b/python/pyplugin_installer/installer_data.py @@ -229,22 +229,22 @@ class Repositories(QObject): def checkingOnStart(self) -> bool: """ return true if checking for news and updates is enabled """ - return QgsSettings.createPluginTreeElement("_plugin_manager").childSetting('automatically-check-for-updates').value() + return QgsSettings.createPluginTreeNode("_plugin_manager").childSetting('automatically-check-for-updates').value() def setCheckingOnStart(self, state: bool): """ set state of checking for news and updates """ - QgsSettings.createPluginTreeElement("_plugin_manager").childSetting('automatically-check-for-updates').setValue(state) + QgsSettings.createPluginTreeNode("_plugin_manager").childSetting('automatically-check-for-updates').setValue(state) def saveCheckingOnStartLastDate(self): """ set today's date as the day of last checking """ - QgsSettings.createPluginTreeElement("_plugin_manager").childSetting('check-on-start-last-date').setValue(QDate.currentDate()) + QgsSettings.createPluginTreeNode("_plugin_manager").childSetting('check-on-start-last-date').setValue(QDate.currentDate()) def timeForChecking(self) -> bool: """ determine whether it's the time for checking for news and updates now """ settings = QgsSettings() try: # QgsSettings may contain ivalid value... - interval = QgsSettings.createPluginTreeElement("_plugin_manager").childSetting('check-on-start-last-date').valueAs(type=QDate).daysTo(QDate.currentDate()) + interval = QgsSettings.createPluginTreeNode("_plugin_manager").childSetting('check-on-start-last-date').valueAs(type=QDate).daysTo(QDate.currentDate()) except: interval = 0 if interval >= Repositories.CHECK_ON_START_INTERVAL: @@ -711,8 +711,8 @@ class Plugins(QObject): self.mPlugins = {} for i in list(self.localCache.keys()): self.mPlugins[i] = self.localCache[i].copy() - allowExperimental = QgsSettings.createPluginTreeElement("_plugin_manager").childSetting("allow-experimental").value() - allowDeprecated = QgsSettings.createPluginTreeElement("_plugin_manager").childSetting("allow-deprecated").value() + allowExperimental = QgsSettings.createPluginTreeNode("_plugin_manager").childSetting("allow-experimental").value() + allowDeprecated = QgsSettings.createPluginTreeNode("_plugin_manager").childSetting("allow-deprecated").value() for i in list(self.repoCache.values()): for j in i: plugin = j.copy() # do not update repoCache elements! @@ -808,7 +808,7 @@ class Plugins(QObject): # ----------------------------------------- # def markNews(self): """ mark all new plugins as new """ - seenPlugins = QgsSettings.createPluginTreeElement("_plugin_manager").childSetting("seen-plugins").valueWithDefaultOverride(list(self.mPlugins.keys())) + seenPlugins = QgsSettings.createPluginTreeNode("_plugin_manager").childSetting("seen-plugins").valueWithDefaultOverride(list(self.mPlugins.keys())) if len(seenPlugins) > 0: for plugin in list(self.mPlugins.keys()): if seenPlugins.count(plugin) == 0 and self.mPlugins[plugin]["status"] == "not installed": @@ -817,7 +817,7 @@ class Plugins(QObject): # ----------------------------------------- # def updateSeenPluginsList(self): """ update the list of all seen plugins """ - setting = QgsSettings.createPluginTreeElement("_plugin_manager").childSetting("seen-plugins") + setting = QgsSettings.createPluginTreeNode("_plugin_manager").childSetting("seen-plugins") seenPlugins = setting.valueWithDefaultOverride(list(self.mPlugins.keys())) for plugin in list(self.mPlugins.keys()): if seenPlugins.count(plugin) == 0: diff --git a/src/app/georeferencer/qgsgeorefmainwindow.h b/src/app/georeferencer/qgsgeorefmainwindow.h index 6aded5b06ba..f94083ad86f 100644 --- a/src/app/georeferencer/qgsgeorefmainwindow.h +++ b/src/app/georeferencer/qgsgeorefmainwindow.h @@ -62,7 +62,7 @@ class QgsGeoreferencerMainWindow : public QMainWindow, private Ui::QgsGeorefPlug Q_OBJECT public: - static inline QgsSettingsTreeNode *sTreeGeoreferencer = QgsSettings::sTreeApp->createChildElement( QStringLiteral( "georeferencer" ) ); + static inline QgsSettingsTreeNode *sTreeGeoreferencer = QgsSettings::sTreeApp->createChildNode( QStringLiteral( "georeferencer" ) ); static const QgsSettingsEntryEnumFlag *settingResamplingMethod; static const QgsSettingsEntryString *settingCompressionMethod; diff --git a/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.h b/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.h index af9fe556144..c4e120c68c5 100644 --- a/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.h +++ b/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.h @@ -54,7 +54,7 @@ class APP_EXPORT QgsMapToolsDigitizingTechniqueManager : public QObject public: static const QgsSettingsEntryEnumFlag *settingsDigitizingTechnique; - static inline QgsSettingsTreeNode *sTreeShapeMapTools = QgsSettings::sTreeDigitizing->createChildElement( QStringLiteral( "shape-map-tools" ) ); + static inline QgsSettingsTreeNode *sTreeShapeMapTools = QgsSettings::sTreeDigitizing->createChildNode( QStringLiteral( "shape-map-tools" ) ); static const QgsSettingsEntryString *settingMapToolShapeDefaultForShape; static const QgsSettingsEntryString *settingMapToolShapeCurrent; diff --git a/src/app/pluginmanager/qgspluginmanager.h b/src/app/pluginmanager/qgspluginmanager.h index acac5b77b56..693bd837b87 100644 --- a/src/app/pluginmanager/qgspluginmanager.h +++ b/src/app/pluginmanager/qgspluginmanager.h @@ -52,7 +52,7 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag Q_OBJECT public: - static inline QgsSettingsTreeNode *sTreePluginManager = QgsSettings::sTreePlugins->createChildElement( QStringLiteral( "_plugin_manager" ) ); + static inline QgsSettingsTreeNode *sTreePluginManager = QgsSettings::sTreePlugins->createChildNode( QStringLiteral( "_plugin_manager" ) ); static const QgsSettingsEntryBool *settingsAutomaticallyCheckForPluginUpdates; static const QgsSettingsEntryBool *settingsAllowExperimental; @@ -60,7 +60,7 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag static const QgsSettingsEntryVariant *settingsCheckOnStartLastDate; static const QgsSettingsEntryStringList *settingsSeenPlugins; - static inline QgsSettingsTreeNode *sTreeUi = sTreePluginManager->createChildElement( QStringLiteral( "UI" ) ); + static inline QgsSettingsTreeNode *sTreeUi = sTreePluginManager->createChildNode( QStringLiteral( "UI" ) ); static const QgsSettingsEntryString *settingsLastZipDirectory; static const QgsSettingsEntryBool *settingsShowInstallFromZipWarning; diff --git a/src/core/gps/qgsbabelformatregistry.h b/src/core/gps/qgsbabelformatregistry.h index 9fe86dc5259..f2d8dccf3d5 100644 --- a/src/core/gps/qgsbabelformatregistry.h +++ b/src/core/gps/qgsbabelformatregistry.h @@ -39,7 +39,7 @@ class CORE_EXPORT QgsBabelFormatRegistry #ifndef SIP_RUN - static inline QgsSettingsTreeNamedListNode *sTreeBabelDevices = QgsSettings::sTreeGps->createNamedListElement( QStringLiteral( "babel-devices" ) ); + static inline QgsSettingsTreeNamedListNode *sTreeBabelDevices = QgsSettings::sTreeGps->createNamedListNode( QStringLiteral( "babel-devices" ) ); static const QgsSettingsEntryString *settingsBabelWptDownload; static const QgsSettingsEntryString *settingsBabelWptUpload; diff --git a/src/core/locator/qgslocator.h b/src/core/locator/qgslocator.h index ba3b7b85e59..2d8bdaf6be5 100644 --- a/src/core/locator/qgslocator.h +++ b/src/core/locator/qgslocator.h @@ -154,7 +154,7 @@ class CORE_EXPORT QgsLocator : public QObject QStringList completionList() const {return mAutocompletionList;} #ifndef SIP_RUN - static inline QgsSettingsTreeNamedListNode *sTreeLocatorFilters = QgsSettings::treeRoot()->createNamedListElement( QStringLiteral( "locator-filters" ) ); + static inline QgsSettingsTreeNamedListNode *sTreeLocatorFilters = QgsSettings::treeRoot()->createNamedListNode( QStringLiteral( "locator-filters" ) ); //! Settings entry locator filter enabled static const QgsSettingsEntryBool *settingsLocatorFilterEnabled; diff --git a/src/core/processing/qgsprocessing.h b/src/core/processing/qgsprocessing.h index 33975bbd4d8..02bdfcc4579 100644 --- a/src/core/processing/qgsprocessing.h +++ b/src/core/processing/qgsprocessing.h @@ -109,7 +109,7 @@ class CORE_EXPORT QgsProcessing static const QString TEMPORARY_OUTPUT; #ifndef SIP_RUN - static inline QgsSettingsTreeNode *sTreeConfiguration = QgsSettings::sTreeQgis->createChildElement( QStringLiteral( "configuration" ) ); + static inline QgsSettingsTreeNode *sTreeConfiguration = QgsSettings::sTreeQgis->createChildNode( QStringLiteral( "configuration" ) ); //! Settings entry prefer filename as layer name static const QgsSettingsEntryBool *settingsPreferFilenameAsLayerName; diff --git a/src/core/qgsowsconnection.h b/src/core/qgsowsconnection.h index f43893050b5..149249e0f47 100644 --- a/src/core/qgsowsconnection.h +++ b/src/core/qgsowsconnection.h @@ -40,7 +40,7 @@ class CORE_EXPORT QgsXyzConnectionSettings SIP_SKIP { public: - static inline QgsSettingsTreeNamedListNode *sTreeXyzConnections = QgsSettings::sTreeConnections->createNamedListElement( QStringLiteral( "xyz" ), QgsSettingsTreeNode::Option::NamedListSelectedItemSetting ); + static inline QgsSettingsTreeNamedListNode *sTreeXyzConnections = QgsSettings::sTreeConnections->createNamedListNode( QStringLiteral( "xyz" ), QgsSettingsTreeNode::Option::NamedListSelectedItemSetting ); static const QgsSettingsEntryString *settingsUrl; static const QgsSettingsEntryVariantMap *settingsHeaders; @@ -64,7 +64,7 @@ class CORE_EXPORT QgsXyzConnectionSettings SIP_SKIP class CORE_EXPORT QgsArcGisConnectionSettings SIP_SKIP { public: - static inline QgsSettingsTreeNamedListNode *sTreeConnectionArcgis = QgsSettings::sTreeConnections->createNamedListElement( QStringLiteral( "arcgisfeatureserver" ), QgsSettingsTreeNamedListNode::Option::NamedListSelectedItemSetting ); + static inline QgsSettingsTreeNamedListNode *sTreeConnectionArcgis = QgsSettings::sTreeConnections->createNamedListNode( QStringLiteral( "arcgisfeatureserver" ), QgsSettingsTreeNamedListNode::Option::NamedListSelectedItemSetting ); static const QgsSettingsEntryString *settingsUrl; static const QgsSettingsEntryString *settingsAuthcfg; @@ -87,8 +87,8 @@ class CORE_EXPORT QgsOwsConnection : public QObject public: #ifndef SIP_RUN - static inline QgsSettingsTreeNamedListNode *sTtreeOwsServices = QgsSettings::sTreeConnections->createNamedListElement( QStringLiteral( "ows" ) ); - static inline QgsSettingsTreeNamedListNode *sTreeOwsConnections = sTtreeOwsServices->createNamedListElement( QStringLiteral( "connections" ) ); + static inline QgsSettingsTreeNamedListNode *sTtreeOwsServices = QgsSettings::sTreeConnections->createNamedListNode( QStringLiteral( "ows" ) ); + static inline QgsSettingsTreeNamedListNode *sTreeOwsConnections = sTtreeOwsServices->createNamedListNode( QStringLiteral( "connections" ) ); static const QgsSettingsEntryString *settingsUrl; static const QgsSettingsEntryVariantMap *settingsHeaders; diff --git a/src/core/settings/qgssettings.cpp b/src/core/settings/qgssettings.cpp index a387a431da7..248178b9ae5 100644 --- a/src/core/settings/qgssettings.cpp +++ b/src/core/settings/qgssettings.cpp @@ -50,24 +50,23 @@ void QgsSettings::init() QgsSettingsTreeNode *QgsSettings::treeRoot() { // this must be defined in cpp code so we are sure only one instance is around - static QgsSettingsTreeNode *sTreeRoot = QgsSettingsTreeNode::createRootElement(); + static QgsSettingsTreeNode *sTreeRoot = QgsSettingsTreeNode::createRootNode(); return sTreeRoot; } -QgsSettingsTreeNode *QgsSettings::createPluginTreeElement( const QString &pluginName ) +QgsSettingsTreeNode *QgsSettings::createPluginTreeNode( const QString &pluginName ) { - QgsSettingsTreeNode *te = sTreePlugins->childElement( pluginName ); + QgsSettingsTreeNode *te = sTreePlugins->childNode( pluginName ); if ( te ) return te; else - return sTreePlugins->createChildElement( pluginName ); + return sTreePlugins->createChildNode( pluginName ); } -void QgsSettings::unregisterPluginTreeElement( const QString &pluginName ) +void QgsSettings::unregisterPluginTreeNode( const QString &pluginName ) { - //QgsDebugMsg( "unregister plugin tree element" ); - QgsSettingsTreeNode *pluginTreeElement = sTreePlugins->childElement( pluginName ); - delete pluginTreeElement; + QgsSettingsTreeNode *pluginTreeNode = sTreePlugins->childNode( pluginName ); + delete pluginTreeNode; } QgsSettings::QgsSettings( const QString &organization, const QString &application, QObject *parent ) diff --git a/src/core/settings/qgssettings.h b/src/core/settings/qgssettings.h index c042b02675c..c2681622641 100644 --- a/src/core/settings/qgssettings.h +++ b/src/core/settings/qgssettings.h @@ -83,49 +83,49 @@ class CORE_EXPORT QgsSettings : public QObject #ifndef SIP_RUN /** - * Returns the tree root element for the settings + * Returns the tree root node for the settings * \since QGIS 3.30 */ static QgsSettingsTreeNode *treeRoot(); // only create first level here - static inline QgsSettingsTreeNode *sTreeApp = treeRoot()->createChildElement( QStringLiteral( "app" ) ); - static inline QgsSettingsTreeNode *sTreeConnections = treeRoot()->createChildElement( QStringLiteral( "connections" ) ); - static inline QgsSettingsTreeNode *sTreeCore = treeRoot()->createChildElement( QStringLiteral( "core" ) ); - static inline QgsSettingsTreeNode *sTreeElevationProfile = treeRoot()->createChildElement( QStringLiteral( "elevation-profile" ) ); - static inline QgsSettingsTreeNode *sTreeFonts = treeRoot()->createChildElement( QStringLiteral( "fonts" ) ); - static inline QgsSettingsTreeNode *sTreeGeometryValidation = treeRoot()->createChildElement( QStringLiteral( "geometry_validation" ) ); - static inline QgsSettingsTreeNode *sTreeGps = treeRoot()->createChildElement( QStringLiteral( "gps" ) ); - static inline QgsSettingsTreeNode *sTreeGui = treeRoot()->createChildElement( QStringLiteral( "gui" ) ); - static inline QgsSettingsTreeNode *sTreeLayerTree = treeRoot()->createChildElement( QStringLiteral( "layer-tree" ) ); - static inline QgsSettingsTreeNode *sTreeLayout = treeRoot()->createChildElement( QStringLiteral( "layout" ) ); - static inline QgsSettingsTreeNode *sTreeLocale = treeRoot()->createChildElement( QStringLiteral( "locale" ) ); - static inline QgsSettingsTreeNode *sTreeMap = treeRoot()->createChildElement( QStringLiteral( "map" ) ); - static inline QgsSettingsTreeNode *sTreeNetwork = treeRoot()->createChildElement( QStringLiteral( "network" ) ); - static inline QgsSettingsTreeNode *sTreeQgis = treeRoot()->createChildElement( QStringLiteral( "qgis" ) ); - static inline QgsSettingsTreeNode *sTreePlugins = treeRoot()->createChildElement( QStringLiteral( "plugins" ) ); - static inline QgsSettingsTreeNode *sTreeProcessing = treeRoot()->createChildElement( QStringLiteral( "processing" ) ); - static inline QgsSettingsTreeNode *sTreeRaster = treeRoot()->createChildElement( QStringLiteral( "raster" ) ); - static inline QgsSettingsTreeNode *sTreeSvg = treeRoot()->createChildElement( QStringLiteral( "svg" ) ); - static inline QgsSettingsTreeNode *sTreeWms = treeRoot()->createChildElement( QStringLiteral( "wms" ) ); + static inline QgsSettingsTreeNode *sTreeApp = treeRoot()->createChildNode( QStringLiteral( "app" ) ); + static inline QgsSettingsTreeNode *sTreeConnections = treeRoot()->createChildNode( QStringLiteral( "connections" ) ); + static inline QgsSettingsTreeNode *sTreeCore = treeRoot()->createChildNode( QStringLiteral( "core" ) ); + static inline QgsSettingsTreeNode *sTreeElevationProfile = treeRoot()->createChildNode( QStringLiteral( "elevation-profile" ) ); + static inline QgsSettingsTreeNode *sTreeFonts = treeRoot()->createChildNode( QStringLiteral( "fonts" ) ); + static inline QgsSettingsTreeNode *sTreeGeometryValidation = treeRoot()->createChildNode( QStringLiteral( "geometry_validation" ) ); + static inline QgsSettingsTreeNode *sTreeGps = treeRoot()->createChildNode( QStringLiteral( "gps" ) ); + static inline QgsSettingsTreeNode *sTreeGui = treeRoot()->createChildNode( QStringLiteral( "gui" ) ); + static inline QgsSettingsTreeNode *sTreeLayerTree = treeRoot()->createChildNode( QStringLiteral( "layer-tree" ) ); + static inline QgsSettingsTreeNode *sTreeLayout = treeRoot()->createChildNode( QStringLiteral( "layout" ) ); + static inline QgsSettingsTreeNode *sTreeLocale = treeRoot()->createChildNode( QStringLiteral( "locale" ) ); + static inline QgsSettingsTreeNode *sTreeMap = treeRoot()->createChildNode( QStringLiteral( "map" ) ); + static inline QgsSettingsTreeNode *sTreeNetwork = treeRoot()->createChildNode( QStringLiteral( "network" ) ); + static inline QgsSettingsTreeNode *sTreeQgis = treeRoot()->createChildNode( QStringLiteral( "qgis" ) ); + static inline QgsSettingsTreeNode *sTreePlugins = treeRoot()->createChildNode( QStringLiteral( "plugins" ) ); + static inline QgsSettingsTreeNode *sTreeProcessing = treeRoot()->createChildNode( QStringLiteral( "processing" ) ); + static inline QgsSettingsTreeNode *sTreeRaster = treeRoot()->createChildNode( QStringLiteral( "raster" ) ); + static inline QgsSettingsTreeNode *sTreeSvg = treeRoot()->createChildNode( QStringLiteral( "svg" ) ); + static inline QgsSettingsTreeNode *sTreeWms = treeRoot()->createChildNode( QStringLiteral( "wms" ) ); // sub levels - static inline QgsSettingsTreeNode *sTreeDigitizing = sTreeQgis->createChildElement( QStringLiteral( "digitizing" ) ); + static inline QgsSettingsTreeNode *sTreeDigitizing = sTreeQgis->createChildNode( QStringLiteral( "digitizing" ) ); #endif /** - * Creates a settings tree element for the given \a pluginName + * Creates a settings tree node for the given \a pluginName * \since QGIS 3.30 */ - static QgsSettingsTreeNode *createPluginTreeElement( const QString &pluginName ); + static QgsSettingsTreeNode *createPluginTreeNode( const QString &pluginName ); /** - * Unregisters the tree element for the given plugin + * Unregisters the tree node for the given plugin * \since QGIS 3.30 */ - static void unregisterPluginTreeElement( const QString &pluginName ); + static void unregisterPluginTreeNode( const QString &pluginName ); /** * Constructs a QgsSettings object for accessing settings of the application diff --git a/src/core/settings/qgssettingsentryimpl.h b/src/core/settings/qgssettingsentryimpl.h index f01490c77ea..3392a692f11 100644 --- a/src/core/settings/qgssettingsentryimpl.h +++ b/src/core/settings/qgssettingsentryimpl.h @@ -85,7 +85,7 @@ class CORE_EXPORT QgsSettingsEntryVariant : public QgsSettingsEntryByReference const QString &description = QString(), Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER; % MethodCode - sipCpp = new sipQgsSettingsEntryBool( QgsSettingsEntryBool( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4 ) ); + sipCpp = new sipQgsSettingsEntryBool( QgsSettingsEntryBool( *a0, QgsSettings::createPluginTreeNode( *a1 ), a2, *a3, *a4 ) ); % End #endif @@ -451,7 +451,7 @@ class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue int minValue = std::numeric_limits::min(), int maxValue = std::numeric_limits::max() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER; % MethodCode - sipCpp = new sipQgsSettingsEntryInteger( QgsSettingsEntryInteger( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4, a5, a6 ) ); + sipCpp = new sipQgsSettingsEntryInteger( QgsSettingsEntryInteger( *a0, QgsSettings::createPluginTreeNode( *a1 ), a2, *a3, *a4, a5, a6 ) ); % End #endif @@ -643,7 +643,7 @@ class CORE_EXPORT QgsSettingsEntryDouble : public QgsSettingsEntryByValue::max(), int displayDecimals = 1 ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER; % MethodCode - sipCpp = new sipQgsSettingsEntryDouble( QgsSettingsEntryDouble( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4, a5, a6, a7 ) ); + sipCpp = new sipQgsSettingsEntryDouble( QgsSettingsEntryDouble( *a0, QgsSettings::createPluginTreeNode( *a1 ), a2, *a3, *a4, a5, a6, a7 ) ); % End #endif @@ -754,7 +754,7 @@ class CORE_EXPORT QgsSettingsEntryColor : public QgsSettingsEntryByReferenceunregisterChildElement( this ); + mParent->unregisterChildNode( this ); - qDeleteAll( mChildrenElements ); + qDeleteAll( mChildrenNodes ); qDeleteAll( mChildrenSettings ); } -QgsSettingsTreeNode *QgsSettingsTreeNode::createRootElement() +QgsSettingsTreeNode *QgsSettingsTreeNode::createRootNode() { QgsSettingsTreeNode *te = new QgsSettingsTreeNode(); te->mType = Type::Root; @@ -38,47 +38,47 @@ QgsSettingsTreeNode *QgsSettingsTreeNode::createRootElement() return te; } -QgsSettingsTreeNode *QgsSettingsTreeNode::createChildElement( const QString &key ) +QgsSettingsTreeNode *QgsSettingsTreeNode::createChildNode( const QString &key ) { - QgsSettingsTreeNode *te = childElement( key ); + QgsSettingsTreeNode *te = childNode( key ); if ( te ) return te; if ( childSetting( key ) ) - throw QgsSettingsException( QObject::tr( "Settings tree element '%1' already holds a child setting with key '%2'." ).arg( this->key(), key ) ); + throw QgsSettingsException( QObject::tr( "Settings tree node '%1' already holds a child setting with key '%2'." ).arg( this->key(), key ) ); te = new QgsSettingsTreeNode(); te->mType = Type::Standard; te->init( this, key ); - registerChildElement( te ); + registerChildNode( te ); return te; } -QgsSettingsTreeNamedListNode *QgsSettingsTreeNode::createNamedListElement( const QString &key, const QgsSettingsTreeNode::Options &options ) +QgsSettingsTreeNamedListNode *QgsSettingsTreeNode::createNamedListNode( const QString &key, const QgsSettingsTreeNode::Options &options ) { - QgsSettingsTreeNode *nte = childElement( key ); + QgsSettingsTreeNode *nte = childNode( key ); if ( nte ) { if ( nte->type() == Type::NamedList ) return dynamic_cast( nte ); else - throw QgsSettingsException( QObject::tr( "Settings tree element '%1' already holds a child element with key '%2', but it is not a named list.." ).arg( this->key(), key ) ); + throw QgsSettingsException( QObject::tr( "Settings tree node '%1' already holds a child node with key '%2', but it is not a named list.." ).arg( this->key(), key ) ); } if ( childSetting( key ) ) - throw QgsSettingsException( QObject::tr( "Settings tree element '%1' already holds a child setting with key '%2'." ).arg( this->key(), key ) ); + throw QgsSettingsException( QObject::tr( "Settings tree node '%1' already holds a child setting with key '%2'." ).arg( this->key(), key ) ); QgsSettingsTreeNamedListNode *te = new QgsSettingsTreeNamedListNode(); te->mType = Type::NamedList; te->init( this, key ); te->initNamedList( options ); - registerChildElement( te ); + registerChildNode( te ); return te; } -QgsSettingsTreeNode *QgsSettingsTreeNode::childElement( const QString &key ) +QgsSettingsTreeNode *QgsSettingsTreeNode::childNode( const QString &key ) { - QList::const_iterator it = mChildrenElements.constBegin(); - for ( ; it != mChildrenElements.constEnd(); ++it ) + QList::const_iterator it = mChildrenNodes.constBegin(); + for ( ; it != mChildrenNodes.constEnd(); ++it ) { if ( ( *it )->key() == key ) return *it; @@ -100,18 +100,18 @@ const QgsSettingsEntryBase *QgsSettingsTreeNode::childSetting( const QString &ke void QgsSettingsTreeNode::registerChildSetting( const QgsSettingsEntryBase *setting, const QString &key ) { - if ( childElement( key ) ) - throw QgsSettingsException( QObject::tr( "Settings tree element '%1' already holds a child tree element with key '%2'." ).arg( this->key(), key ) ); + if ( childNode( key ) ) + throw QgsSettingsException( QObject::tr( "Settings tree node '%1' already holds a child tree node with key '%2'." ).arg( this->key(), key ) ); if ( childSetting( key ) ) - throw QgsSettingsException( QObject::tr( "Settings tree element '%1' already holds a child setting with key '%2'." ).arg( this->key(), key ) ); + throw QgsSettingsException( QObject::tr( "Settings tree node '%1' already holds a child setting with key '%2'." ).arg( this->key(), key ) ); mChildrenSettings.append( setting ); } -void QgsSettingsTreeNode::registerChildElement( QgsSettingsTreeNode *element ) +void QgsSettingsTreeNode::registerChildNode( QgsSettingsTreeNode *node ) { - mChildrenElements.append( element ); + mChildrenNodes.append( node ); } void QgsSettingsTreeNode::unregisterChildSetting( const QgsSettingsEntryBase *setting, bool deleteSettingValues, const QStringList &parentsNamedItems ) @@ -122,9 +122,9 @@ void QgsSettingsTreeNode::unregisterChildSetting( const QgsSettingsEntryBase *se mChildrenSettings.removeAll( setting ); } -void QgsSettingsTreeNode::unregisterChildElement( QgsSettingsTreeNode *element ) +void QgsSettingsTreeNode::unregisterChildNode( QgsSettingsTreeNode *node ) { - mChildrenElements.removeAll( element ); + mChildrenNodes.removeAll( node ); } void QgsSettingsTreeNode::init( QgsSettingsTreeNode *parent, const QString &key ) @@ -144,9 +144,9 @@ void QgsSettingsTreeNamedListNode::initNamedList( const QgsSettingsTreeNode::Opt mSelectedItemSetting = new QgsSettingsEntryString( QStringLiteral( "%1/selected" ).arg( mCompleteKey ), nullptr ); } - mNamedElementsCount = mParent->namedElementsCount() + 1; + mNamedNodesCount = mParent->namedNodesCount() + 1; mItemsCompleteKey = QStringLiteral( "%1items/" ).arg( mCompleteKey ); - mCompleteKey.append( QStringLiteral( "items/%%1/" ).arg( mNamedElementsCount ) ); + mCompleteKey.append( QStringLiteral( "items/%%1/" ).arg( mNamedNodesCount ) ); } QgsSettingsTreeNamedListNode::~QgsSettingsTreeNamedListNode() @@ -162,8 +162,8 @@ QStringList QgsSettingsTreeNamedListNode::items( const QStringList &parentsNamed QStringList QgsSettingsTreeNamedListNode::items( Qgis::SettingsOrigin origin, const QStringList &parentsNamedItems ) const { - if ( namedElementsCount() - 1 != parentsNamedItems.count() ) - throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) for the element '%2' doesn't match with the number of named items in the key (%3)." ).arg( QString::number( parentsNamedItems.count() ), mCompleteKey, QString::number( namedElementsCount() ) ) ); + if ( namedNodesCount() - 1 != parentsNamedItems.count() ) + throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) for the node '%2' doesn't match with the number of named items in the key (%3)." ).arg( QString::number( parentsNamedItems.count() ), mCompleteKey, QString::number( namedNodesCount() ) ) ); const QString completeKeyParam = completeKeyWithNamedItems( mItemsCompleteKey, parentsNamedItems ); @@ -174,30 +174,30 @@ QStringList QgsSettingsTreeNamedListNode::items( Qgis::SettingsOrigin origin, co void QgsSettingsTreeNamedListNode::setSelectedItem( const QString &item, const QStringList &parentsNamedItems ) { - if ( namedElementsCount() - 1 != parentsNamedItems.count() ) - throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) for the element '%2' doesn't match with the number of named items in the key (%3)." ).arg( QString::number( parentsNamedItems.count() ), mCompleteKey, QString::number( namedElementsCount() ) ) ); + if ( namedNodesCount() - 1 != parentsNamedItems.count() ) + throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) for the node '%2' doesn't match with the number of named items in the key (%3)." ).arg( QString::number( parentsNamedItems.count() ), mCompleteKey, QString::number( namedNodesCount() ) ) ); if ( !mOptions.testFlag( Option::NamedListSelectedItemSetting ) ) - throw QgsSettingsException( QObject::tr( "The named list element '%1' has no option to set the current selected entry." ).arg( mCompleteKey ) ); + throw QgsSettingsException( QObject::tr( "The named list node '%1' has no option to set the current selected entry." ).arg( mCompleteKey ) ); mSelectedItemSetting->setValue( item, parentsNamedItems ); } QString QgsSettingsTreeNamedListNode::selectedItem( const QStringList &parentsNamedItems ) { - if ( namedElementsCount() - 1 != parentsNamedItems.count() ) - throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) for the element '%2' doesn't match with the number of named items in the key (%3)." ).arg( QString::number( parentsNamedItems.count() ), mCompleteKey, QString::number( namedElementsCount() ) ) ); + if ( namedNodesCount() - 1 != parentsNamedItems.count() ) + throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) for the node '%2' doesn't match with the number of named items in the key (%3)." ).arg( QString::number( parentsNamedItems.count() ), mCompleteKey, QString::number( namedNodesCount() ) ) ); if ( !mOptions.testFlag( Option::NamedListSelectedItemSetting ) ) - throw QgsSettingsException( QObject::tr( "The named list element '%1' has no option to set the current selected entry." ).arg( mCompleteKey ) ); + throw QgsSettingsException( QObject::tr( "The named list node '%1' has no option to set the current selected entry." ).arg( mCompleteKey ) ); return mSelectedItemSetting->value( parentsNamedItems ); } void QgsSettingsTreeNamedListNode::deleteItem( const QString &item, const QStringList &parentsNamedItems ) { - if ( namedElementsCount() - 1 != parentsNamedItems.count() ) - throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) doesn't match with the number of named items in the key (%2)." ).arg( parentsNamedItems.count(), namedElementsCount() ) ); + if ( namedNodesCount() - 1 != parentsNamedItems.count() ) + throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) doesn't match with the number of named items in the key (%2)." ).arg( parentsNamedItems.count(), namedNodesCount() ) ); if ( !mOptions.testFlag( Option::NamedListSelectedItemSetting ) ) - throw QgsSettingsException( QObject::tr( "The named list element has no option to set the current selected entry." ) ); + throw QgsSettingsException( QObject::tr( "The named list node has no option to set the current selected entry." ) ); QStringList args = parentsNamedItems; args << item; diff --git a/src/core/settings/qgssettingstreenode.h b/src/core/settings/qgssettingstreenode.h index 175d0250434..a4a7a65127c 100644 --- a/src/core/settings/qgssettingstreenode.h +++ b/src/core/settings/qgssettingstreenode.h @@ -30,11 +30,11 @@ class QgsSettingsEntryString; /** * \ingroup core * \class QgsSettingsTreeNode - * \brief QgsSettingsTreeNode is a tree element for the settings registry + * \brief QgsSettingsTreeNode is a tree node for the settings registry * to help organizing and introspecting the registry. - * It is either a root element, a normal element or + * It is either a root node, a normal node or * a named list (to store a group of settings under a dynamic named key). - * The root element holds a pointer to a registry (might be null) + * The root node holds a pointer to a registry (might be null) * to automatically register a settings entry on its creation when a parent is provided. * * \see QgsSettingsEntryBase @@ -59,16 +59,16 @@ class CORE_EXPORT QgsSettingsTreeNode Q_GADGET public: - //! Type of tree element + //! Type of tree node enum class Type { - Root, //!< Root Element - Standard, //!< Normal Element - NamedList, //! Named List Element + Root, //!< Root Node + Standard, //!< Normal Node + NamedList, //! Named List Node }; Q_ENUM( Type ) - //! Options for named list elements + //! Options for named list nodes enum class Option { NamedListSelectedItemSetting, //!< Creates a setting to store which is the current item @@ -81,26 +81,26 @@ class CORE_EXPORT QgsSettingsTreeNode virtual ~QgsSettingsTreeNode(); /** - * Creates a tree root element - * \note This is not available in Python bindings. Use QgsSettings.createPluginTreeElement instead. + * Creates a tree root node + * \note This is not available in Python bindings. Use QgsSettings.createPluginTreeNode instead. */ - static QgsSettingsTreeNode *createRootElement() SIP_SKIP; + static QgsSettingsTreeNode *createRootNode() SIP_SKIP; /** - * Creates a normal tree element - * It will return the existing child element if it exists at the given key + * Creates a normal tree node + * It will return the existing child node if it exists at the given key * \throws QgsSettingsException if a setting exists with the same key */ - QgsSettingsTreeNode *createChildElement( const QString &key ) SIP_THROW( QgsSettingsException ) SIP_KEEPREFERENCE; + QgsSettingsTreeNode *createChildNode( const QString &key ) SIP_THROW( QgsSettingsException ) SIP_KEEPREFERENCE; /** - * Creates a named list tree element. + * Creates a named list tree node. * This is useful to register groups of settings for several named items (for instance credentials for several named services) */ - QgsSettingsTreeNamedListNode *createNamedListElement( const QString &key, const QgsSettingsTreeNode::Options &options = QgsSettingsTreeNode::Options() ) SIP_THROW( QgsSettingsException ) SIP_KEEPREFERENCE; + QgsSettingsTreeNamedListNode *createNamedListNode( const QString &key, const QgsSettingsTreeNode::Options &options = QgsSettingsTreeNode::Options() ) SIP_THROW( QgsSettingsException ) SIP_KEEPREFERENCE; - //! Returns the type of element + //! Returns the type of node Type type() const {return mType;} /** @@ -121,14 +121,14 @@ class CORE_EXPORT QgsSettingsTreeNode */ void unregisterChildSetting( const QgsSettingsEntryBase *setting, bool deleteSettingValues = false, const QStringList &parentsNamedItems = QStringList() ); - //! Unregisters the child tree \a element - void unregisterChildElement( QgsSettingsTreeNode *element ); + //! Unregisters the child tree \a node + void unregisterChildNode( QgsSettingsTreeNode *node ); - //! Returns the children elements - QList childrenElements() const {return mChildrenElements;} + //! Returns the children nodes + QList childrenNodes() const {return mChildrenNodes;} - //! Returns the existing child element if it exists at the given \a key - QgsSettingsTreeNode *childElement( const QString &key ); + //! Returns the existing child node if it exists at the given \a key + QgsSettingsTreeNode *childNode( const QString &key ); //! Returns the children settings QList childrenSettings() const {return mChildrenSettings;} @@ -136,17 +136,17 @@ class CORE_EXPORT QgsSettingsTreeNode //! Returns the existing child settings if it exists at the given \a key const QgsSettingsEntryBase *childSetting( const QString &key ); - //! Returns the parent of the element or nullptr if it does not exists + //! Returns the parent of the node or nullptr if it does not exists QgsSettingsTreeNode *parent() const {return mParent;} - //! Returns the key of the element (without its parents) + //! Returns the key of the node (without its parents) QString key() const {return mKey;} - //! Returns the complete key of the element (including its parents) + //! Returns the complete key of the node (including its parents) QString completeKey() const {return mCompleteKey;} - //! Returns the number of named elements in the complete key - int namedElementsCount() const {return mNamedElementsCount;} + //! Returns the number of named nodes in the complete key + int namedNodesCount() const {return mNamedNodesCount;} #ifdef SIP_RUN SIP_PYOBJECT __repr__(); @@ -159,8 +159,8 @@ class CORE_EXPORT QgsSettingsTreeNode #endif protected: - //! Registers a child elements - void registerChildElement( QgsSettingsTreeNode *element ); + //! Registers a child nodes + void registerChildNode( QgsSettingsTreeNode *node ); Type mType = Type::Root; @@ -168,27 +168,27 @@ class CORE_EXPORT QgsSettingsTreeNode private: /** - * \note This is not available in Python bindings. Use method createElement on an existing tree element. - * \see QgsSettings.createPluginTreeElement + * \note This is not available in Python bindings. Use method createNode on an existing tree node. + * \see QgsSettings.createPluginTreeNode */ QgsSettingsTreeNode() = default SIP_FORCE; QgsSettingsTreeNode( const QgsSettingsTreeNode &other ) = default SIP_FORCE; - //! itilaize the tree element + //! itilaize the tree node void init( QgsSettingsTreeNode *parent, const QString &key ); friend class QgsSettingsTreeNamedListNode; - QgsSettingsTreeNode *childElementAtKey( const QString &key ); + QgsSettingsTreeNode *childNodeAtKey( const QString &key ); - QList mChildrenElements; + QList mChildrenNodes; QList mChildrenSettings; QgsSettingsTreeNode *mParent = nullptr; QString mKey; QString mCompleteKey; - int mNamedElementsCount = 0; + int mNamedNodesCount = 0; }; @@ -196,9 +196,9 @@ class CORE_EXPORT QgsSettingsTreeNode /** * \ingroup core * \class QgsSettingsTreeNamedListNode - * \brief QgsSettingsTreeNamedListNode is a named list tree element for the settings registry + * \brief QgsSettingsTreeNamedListNode is a named list tree node for the settings registry * to help organizing and introspecting the registry. - * the named list element is used to store a group of settings under a dynamically named key. + * the named list node is used to store a group of settings under a dynamically named key. * * \see QgsSettingsTreeNode * \see QgsSettingsEntryBase @@ -228,7 +228,7 @@ class CORE_EXPORT QgsSettingsTreeNamedListNode : public QgsSettingsTreeNode /** - * Sets the selected named item from the named list element + * Sets the selected named item from the named list node * \param item the item to set as selected * \param parentsNamedItems the list of named items in the parent named list (if any) * \throws QgsSettingsException if the number of given parent named items doesn't match the complete key definition @@ -236,14 +236,14 @@ class CORE_EXPORT QgsSettingsTreeNamedListNode : public QgsSettingsTreeNode void setSelectedItem( const QString &item, const QStringList &parentsNamedItems = QStringList() ) SIP_THROW( QgsSettingsException ); /** - * Returns the selected named item from the named list element + * Returns the selected named item from the named list node * \param parentsNamedItems the list of named items in the parent named list (if any) * \throws QgsSettingsException if the number of given parent named items doesn't match the complete key definition */ QString selectedItem( const QStringList &parentsNamedItems = QStringList() ) SIP_THROW( QgsSettingsException ); /** - * Deletes a named item from the named list element + * Deletes a named item from the named list node * \param item the item to delete * \param parentsNamedItems the list of named items in the parent named list (if any) * \throws QgsSettingsException if the number of given parent named items doesn't match the complete key definition @@ -254,15 +254,15 @@ class CORE_EXPORT QgsSettingsTreeNamedListNode : public QgsSettingsTreeNode const QgsSettingsEntryString *selectedItemSetting() const {return mSelectedItemSetting;} protected: - //! Init the elements with the specific \a options + //! Init the nodes with the specific \a options void initNamedList( const QgsSettingsTreeNode::Options &options ); private: friend class QgsSettingsTreeNode; /** - * \note This is not available in Python bindings. Use method createNamedListElement on an existing tree element. - * \see QgsSettings.createPluginTreeElement + * \note This is not available in Python bindings. Use method createNamedListNode on an existing tree node. + * \see QgsSettings.createPluginTreeNode */ QgsSettingsTreeNamedListNode() = default SIP_FORCE; diff --git a/src/core/vectortile/qgsvectortileconnection.h b/src/core/vectortile/qgsvectortileconnection.h index ee2671fe978..defd461fb8d 100644 --- a/src/core/vectortile/qgsvectortileconnection.h +++ b/src/core/vectortile/qgsvectortileconnection.h @@ -34,7 +34,7 @@ class CORE_EXPORT QgsVectorTileProviderConnection : public QgsAbstractProviderCo #ifndef SIP_RUN - static inline QgsSettingsTreeNamedListNode *sTreeConnectionVectorTile = QgsSettings::sTreeConnections->createNamedListElement( QStringLiteral( "vector-tile" ), QgsSettingsTreeNamedListNode::Option::NamedListSelectedItemSetting ); + static inline QgsSettingsTreeNamedListNode *sTreeConnectionVectorTile = QgsSettings::sTreeConnections->createNamedListNode( QStringLiteral( "vector-tile" ), QgsSettingsTreeNamedListNode::Option::NamedListSelectedItemSetting ); static const QgsSettingsEntryString *settingsUrl; static const QgsSettingsEntryInteger *settingsZmin; diff --git a/src/gui/symbology/qgsstylemanagerdialog.h b/src/gui/symbology/qgsstylemanagerdialog.h index 8991dcd8063..2bb922e1177 100644 --- a/src/gui/symbology/qgsstylemanagerdialog.h +++ b/src/gui/symbology/qgsstylemanagerdialog.h @@ -74,7 +74,7 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan public: #ifndef SIP_RUN - static inline QgsSettingsTreeNode *sTtreeStyleManager = QgsSettings::sTreeApp->createChildElement( QStringLiteral( "style-manager" ) ); + static inline QgsSettingsTreeNode *sTtreeStyleManager = QgsSettings::sTreeApp->createChildNode( QStringLiteral( "style-manager" ) ); /** * Last used folder for generic style database actions. diff --git a/tests/src/python/test_qgssettingsentry.py b/tests/src/python/test_qgssettingsentry.py index df906fefaf1..000494fffb4 100644 --- a/tests/src/python/test_qgssettingsentry.py +++ b/tests/src/python/test_qgssettingsentry.py @@ -101,7 +101,7 @@ class TestQgsSettingsEntry(unittest.TestCase): self.assertEqual(settings_entry.key(), settings_key_complete) def test_with_parent_element(self): - root = QgsSettings.createPluginTreeElement(self.pluginName) + root = QgsSettings.createPluginTreeNode(self.pluginName) setting = QgsSettingsEntryInteger("my_setting", root) self.assertEqual(setting.key(), f"/plugins/{self.pluginName}/my_setting") diff --git a/tests/src/python/test_qgssettingstreenode.py b/tests/src/python/test_qgssettingstreenode.py index 43df5ce5c22..0b9d8b87e40 100644 --- a/tests/src/python/test_qgssettingstreenode.py +++ b/tests/src/python/test_qgssettingstreenode.py @@ -28,67 +28,67 @@ class TestQgsSettingsEntry(unittest.TestCase): self.pluginName = "UnitTest" def tearDown(self): - QgsSettings.unregisterPluginTreeElement(self.pluginName) + QgsSettings.unregisterPluginTreeNode(self.pluginName) def test_constructor(self): with self.assertRaises(TypeError): QgsSettingsTreeNode() - root = QgsSettings.createPluginTreeElement(self.pluginName) + root = QgsSettings.createPluginTreeNode(self.pluginName) self.assertEqual(root.type(), QgsSettingsTreeNode.Type.Standard) - pluginsElement = root.parent() - self.assertEqual(pluginsElement.type(), QgsSettingsTreeNode.Type.Standard) - self.assertEqual(pluginsElement.parent().type(), QgsSettingsTreeNode.Type.Root) - self.assertEqual(pluginsElement.parent().parent(), None) + pluginsNode = root.parent() + self.assertEqual(pluginsNode.type(), QgsSettingsTreeNode.Type.Standard) + self.assertEqual(pluginsNode.parent().type(), QgsSettingsTreeNode.Type.Root) + self.assertEqual(pluginsNode.parent().parent(), None) def test_parent(self): - root = QgsSettings.createPluginTreeElement(self.pluginName) + root = QgsSettings.createPluginTreeNode(self.pluginName) self.assertEqual(root.type(), QgsSettingsTreeNode.Type.Standard) - l1 = root.createChildElement("test-parent-level-1") + l1 = root.createChildNode("test-parent-level-1") self.assertEqual(l1.type(), QgsSettingsTreeNode.Type.Standard) self.assertEqual(l1.key(), "test-parent-level-1") self.assertEqual(l1.completeKey(), f"/plugins/{self.pluginName}/test-parent-level-1/") self.assertEqual(l1.parent(), root) - self.assertEqual(root.childrenElements(), [l1]) + self.assertEqual(root.childrenNodes(), [l1]) self.assertEqual(root.childrenSettings(), []) - l1a = l1.createChildElement("level-a") + l1a = l1.createChildNode("level-a") self.assertEqual(l1a.type(), QgsSettingsTreeNode.Type.Standard) self.assertEqual(l1a.key(), "level-a") self.assertEqual(l1a.completeKey(), f"/plugins/{self.pluginName}/test-parent-level-1/level-a/") self.assertEqual(l1a.parent(), l1) - self.assertEqual(l1.childrenElements(), [l1a]) - l1b = l1.createChildElement("level-b") - self.assertEqual(l1.childrenElements(), [l1a, l1b]) + self.assertEqual(l1.childrenNodes(), [l1a]) + l1b = l1.createChildNode("level-b") + self.assertEqual(l1.childrenNodes(), [l1a, l1b]) def test_setting(self): - root = QgsSettings.createPluginTreeElement(self.pluginName) + root = QgsSettings.createPluginTreeNode(self.pluginName) setting = QgsSettingsEntryString("mysetting", root) self.assertEqual(setting.parent(), root) self.assertEqual(setting.key(), f"/plugins/{self.pluginName}/mysetting") self.assertEqual(root.childrenSettings(), [setting]) - self.assertEqual(root.childrenElements(), []) + self.assertEqual(root.childrenNodes(), []) def test_named_list(self): - proot = QgsSettings.createPluginTreeElement(self.pluginName) - l1 = proot.createChildElement("level-1") - self.assertEqual(l1.namedElementsCount(), 0) - nl = l1.createNamedListElement("my_list") + proot = QgsSettings.createPluginTreeNode(self.pluginName) + l1 = proot.createChildNode("level-1") + self.assertEqual(l1.namedNodesCount(), 0) + nl = l1.createNamedListNode("my_list") self.assertEqual(nl.key(), "my_list") self.assertEqual(nl.completeKey(), f"/plugins/{self.pluginName}/level-1/my_list/items/%1/") - self.assertEqual(nl.namedElementsCount(), 1) - self.assertEqual(nl.childrenElements(), []) + self.assertEqual(nl.namedNodesCount(), 1) + self.assertEqual(nl.childrenNodes(), []) self.assertEqual(nl.childrenSettings(), []) # nesting lists - nl2 = nl.createNamedListElement("my_nested_list", QgsSettingsTreeNode.Option.NamedListSelectedItemSetting) + nl2 = nl.createNamedListNode("my_nested_list", QgsSettingsTreeNode.Option.NamedListSelectedItemSetting) self.assertEqual(nl2.key(), "my_nested_list") self.assertEqual(nl2.completeKey(), f"/plugins/{self.pluginName}/level-1/my_list/items/%1/my_nested_list/items/%2/") - self.assertEqual(nl2.namedElementsCount(), 2) - self.assertEqual(nl2.childrenElements(), []) + self.assertEqual(nl2.namedNodesCount(), 2) + self.assertEqual(nl2.childrenNodes(), []) self.assertEqual(len(nl2.childrenSettings()), 0) # the setting for the current selection self.assertEqual(nl2.selectedItemSetting().definitionKey(), f"/plugins/{self.pluginName}/level-1/my_list/items/%1/my_nested_list/selected") selected_key = f"/plugins/{self.pluginName}/level-1/my_list/items/item1/my_nested_list/selected" @@ -100,7 +100,7 @@ class TestQgsSettingsEntry(unittest.TestCase): setting = QgsSettingsEntryString("mysetting-inlist", nl2) self.assertEqual(setting.definitionKey(), f"/plugins/{self.pluginName}/level-1/my_list/items/%1/my_nested_list/items/%2/mysetting-inlist") self.assertEqual(setting.key(['item1', 'item2']), f"/plugins/{self.pluginName}/level-1/my_list/items/item1/my_nested_list/items/item2/mysetting-inlist") - self.assertEqual(nl2.childrenElements(), []) + self.assertEqual(nl2.childrenNodes(), []) self.assertEqual(len(nl2.childrenSettings()), 1) self.assertEqual(nl2.childrenSettings()[0], setting) setting.setValue("xxx", ["item1", "item2"]) @@ -111,32 +111,32 @@ class TestQgsSettingsEntry(unittest.TestCase): self.assertEqual(QgsSettings().value(setting.key(['item1', 'item2'])), None) def test_registration(self): - proot = QgsSettings.createPluginTreeElement(self.pluginName) - self.assertEqual(len(proot.childrenElements()), 0) - l1 = proot.createChildElement("level-1") - self.assertEqual(len(proot.childrenElements()), 1) - QgsSettings.unregisterPluginTreeElement(self.pluginName) + proot = QgsSettings.createPluginTreeNode(self.pluginName) + self.assertEqual(len(proot.childrenNodes()), 0) + l1 = proot.createChildNode("level-1") + self.assertEqual(len(proot.childrenNodes()), 1) + QgsSettings.unregisterPluginTreeNode(self.pluginName) # with several levels + settings - proot = QgsSettings.createPluginTreeElement(self.pluginName) - l1 = proot.createChildElement("level-1") + proot = QgsSettings.createPluginTreeNode(self.pluginName) + l1 = proot.createChildNode("level-1") s1 = QgsSettingsEntryString("my-setting-1", l1) - l2 = l1.createChildElement("level-2") + l2 = l1.createChildNode("level-2") self.assertEqual(len(l2.childrenSettings()), 0) s2 = QgsSettingsEntryString("my-setting-2", l2) self.assertEqual(len(l2.childrenSettings()), 1) l2.unregisterChildSetting(s2) self.assertEqual(len(l2.childrenSettings()), 0) - QgsSettings.unregisterPluginTreeElement(self.pluginName) + QgsSettings.unregisterPluginTreeNode(self.pluginName) def test_duplicated_key(self): - proot = QgsSettings.createPluginTreeElement(self.pluginName) - proot.createChildElement("duplicate-key") + proot = QgsSettings.createPluginTreeNode(self.pluginName) + proot.createChildNode("duplicate-key") with self.assertRaises(QgsSettingsException): QgsSettingsEntryString("duplicate-key", proot) def test_python_implementation(self): - proot = QgsSettings.createPluginTreeElement(self.pluginName) + proot = QgsSettings.createPluginTreeNode(self.pluginName) self.setting = QgsSettingsEntryEnumFlag("python-implemented-setting", proot, QgsUnitTypes.LayoutMeters) self.assertEqual(type(self.setting), QgsSettingsEntryEnumFlag) self.assertEqual(type(proot.childSetting("python-implemented-setting")), QgsSettingsEntryEnumFlag)