QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Public Member Functions | Protected Member Functions | List of all members
QgsSettingsEntryBaseTemplate< T > Class Template Referenceabstract

Base abstract class for settings entries with typed get and set methods. More...

#include <qgssettingsentry.h>

Inheritance diagram for QgsSettingsEntryBaseTemplate< T >:
Inheritance graph
[legend]

Public Member Functions

 QgsSettingsEntryBaseTemplate (const QString &key, const QString &section, const QVariant &defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
 Constructor for QgsSettingsEntryByReference. More...
 
 QgsSettingsEntryBaseTemplate (const QString &name, QgsSettingsTreeNode *parent, const QVariant &defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
 Constructor for QgsSettingsEntryByReference. More...
 
bool checkValueVariant (const QVariant &value) const override
 Returns true if the given value is valid towards the setting definition. More...
 
virtual T convertFromVariant (const QVariant &value) const =0
 Converts the variant value to the value type of the setting. More...
 
defaultValue () const
 Returns settings default value. More...
 
formerValue (const QString &dynamicKeyPart=QString()) const
 Returns the former value. More...
 
formerValue (const QStringList &dynamicKeyPartList) const
 Returns the former value Returns the current value (or default) if there is no former value. More...
 
virtual Qgis::SettingsType settingsType () const override=0
 Returns the settings entry type. More...
 
bool setValue (const T &value, const QString &dynamicKeyPart=QString()) const
 Set settings value. More...
 
bool setValue (const T &value, const QStringList &dynamicKeyPartList) const
 Set settings value. More...
 
value (const QString &dynamicKeyPart=QString()) const
 Returns settings value. More...
 
value (const QStringList &dynamicKeyPartList) const
 Returns settings value. More...
 
valueWithDefaultOverride (const T &defaultValueOverride, const QString &dynamicKeyPart=QString()) const
 Returns the settings value with a defaultValueOverride and with an optional dynamicKeyPart. More...
 
valueWithDefaultOverride (const T &defaultValueOverride, const QStringList &dynamicKeyPartList) const
 Returns the settings value with a defaultValueOverride for the dynamicKeyPartList. More...
 
- Public Member Functions inherited from QgsSettingsEntryBase
 QgsSettingsEntryBase (const QString &key, const QString &section, const QVariant &defaultValue=QVariant(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
 Constructor for QgsSettingsEntryBase. More...
 
 QgsSettingsEntryBase (const QString &name, QgsSettingsTreeNode *parent, const QVariant &defaultValue=QVariant(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
 Constructor for QgsSettingsEntryBase. More...
 
virtual ~QgsSettingsEntryBase ()
 Destructor for QgsSettingsEntryBase. More...
 
virtual bool checkValueVariant (const QVariant &value) const
 Returns true if the given value is valid towards the setting definition. More...
 
bool copyValueFromKey (const QString &key, bool removeSettingAtKey=false) const
 Copies the value from a given key if it exists. More...
 
bool copyValueFromKey (const QString &key, const QStringList &dynamicKeyPartList, bool removeSettingAtKey=false) const
 Copies the value from a given key if it exists. More...
 
void copyValueToKey (const QString &key, const QStringList &dynamicKeyPartList=QStringList()) const
 Copies the settings to the given key. More...
 
void copyValueToKeyIfChanged (const QString &key, const QStringList &dynamicKeyPartList=QStringList()) const
 Copies the settings to the given key, if it has changed during the current QGIS session (see hasChanged()). More...
 
QVariant defaultValueAsVariant () const
 Returns settings default value. More...
 
QString definitionKey () const
 Returns settings entry defining key. More...
 
QString description () const
 Returns the settings entry description. More...
 
bool exists (const QString &dynamicKeyPart=QString()) const
 Returns true if the settings is contained in the underlying QSettings. More...
 
bool exists (const QStringList &dynamicKeyPartList) const
 Returns true if the settings is contained in the underlying QSettings. More...
 
QVariant formerValueAsVariant (const QString &dynamicKeyPart) const
 Returns the former value of the settings if it has been enabled in the options. More...
 
QVariant formerValueAsVariant (const QStringList &dynamicKeyPartList) const
 Returns the former value of the settings if it has been enabled in the options Returns the current value (or default) if there is no former value. More...
 
bool hasChanged () const
 Returns true if the setting was changed during the current QGIS session. More...
 
bool hasDynamicKey () const
 Returns true if a part of the settings key is built dynamically. More...
 
QString key (const QString &dynamicKeyPart=QString()) const
 Returns settings entry key. More...
 
QString key (const QStringList &dynamicKeyPartList) const
 Returns settings entry key. More...
 
bool keyIsValid (const QString &key) const
 Returns true if the provided key match the settings entry. More...
 
QString name () const
 Returns the name of the settings. More...
 
Qgis::SettingsOptions options () const
 Returns the settings options. More...
 
Qgis::SettingsOrigin origin (const QStringList &dynamicKeyPartList) const
 Returns the origin of the setting if it exists. More...
 
QgsSettingsTreeNodeparent () const
 Returns the parent tree element. More...
 
void remove (const QString &dynamicKeyPart=QString()) const
 Removes the settings from the underlying QSettings. More...
 
void remove (const QStringList &dynamicKeyPartList) const
 Removes the settings from the underlying QSettings. More...
 
Q_DECL_DEPRECATED int section () const
 Returns settings section. More...
 
virtual Qgis::SettingsType settingsType () const
 Returns the settings entry type. More...
 
bool setVariantValue (const QVariant &value, const QString &dynamicKeyPart=QString()) const
 Set settings value. More...
 
bool setVariantValue (const QVariant &value, const QStringList &dynamicKeyPartList) const
 Set settings value. More...
 
virtual QString typeId () const
 Returns the id of the type of settings This can be re-implemented in a custom implementation of a setting. More...
 
Q_DECL_DEPRECATED QVariant valueAsVariant (const QString &dynamicKeyPart, bool useDefaultValueOverride, const QVariant &defaultValueOverride) const
 Returns settings value with an optional default value override. More...
 
QVariant valueAsVariant (const QString &dynamicKeyPart=QString()) const
 Returns settings value with. More...
 
QVariant valueAsVariant (const QStringList &dynamicKeyPartList) const
 Returns settings value with. More...
 
Q_DECL_DEPRECATED QVariant valueAsVariant (const QStringList &dynamicKeyPartList, bool useDefaultValueOverride, const QVariant &defaultValueOverride) const
 Returns settings value with an optional default value override. More...
 
QVariant valueAsVariantWithDefaultOverride (const QVariant &defaultValueOverride, const QString &dynamicKeyPart=QString()) const
 Returns settings value with a defaultValueOverride. More...
 
QVariant valueAsVariantWithDefaultOverride (const QVariant &defaultValueOverride, const QStringList &dynamicKeyPartList) const
 Returns settings value. More...
 

Protected Member Functions

virtual bool checkValuePrivate (const T &value) const
 Check if the value is valid. More...
 
virtual QVariant convertToVariant (const T &value) const
 Converts the value to a variant. More...
 
virtual bool setValuePrivate (const T &value, const QStringList &dynamicKeyPartList) const
 Sets the settings value with an optional list of dynamic parts. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from QgsSettingsEntryBase
static QStringList dynamicKeyPartToList (const QString &dynamicKeyPart)
 Transforms a dynamic key part string to list. More...
 

Detailed Description

template<class T>
class QgsSettingsEntryBaseTemplate< T >

Base abstract class for settings entries with typed get and set methods.

See also
QgsSettingsEntryBase
Since
QGIS 3.32

Definition at line 382 of file qgssettingsentry.h.

Constructor & Destructor Documentation

◆ QgsSettingsEntryBaseTemplate() [1/2]

template<class T >
QgsSettingsEntryBaseTemplate< T >::QgsSettingsEntryBaseTemplate ( const QString &  name,
QgsSettingsTreeNode parent,
const QVariant &  defaultValue,
const QString &  description = QString(),
Qgis::SettingsOptions  options = Qgis::SettingsOptions() 
)
inline

Constructor for QgsSettingsEntryByReference.

Parameters
namespecifies the key of the settings.
parentspecifies the parent in the tree of settings.
defaultValuespecifies the default value for the settings entry.
descriptionspecifies a description for the settings entry.
optionsspecifies the options for the settings entry.
Exceptions
QgsSettingsExceptionif the number of given parent named items doesn't match the complete key definition
Since
QGIS 3.30

Definition at line 398 of file qgssettingsentry.h.

◆ QgsSettingsEntryBaseTemplate() [2/2]

template<class T >
QgsSettingsEntryBaseTemplate< T >::QgsSettingsEntryBaseTemplate ( const QString &  key,
const QString &  section,
const QVariant &  defaultValue,
const QString &  description = QString(),
Qgis::SettingsOptions  options = Qgis::SettingsOptions() 
)
inline

Constructor for QgsSettingsEntryByReference.

Parameters
keyspecifies the key of the settings.
sectionspecifies the section.
defaultValuespecifies the default value for the settings entry.
descriptionspecifies a description for the settings entry.
optionsspecifies the options for the settings entry.

Definition at line 415 of file qgssettingsentry.h.

Member Function Documentation

◆ checkValuePrivate()

template<class T >
virtual bool QgsSettingsEntryBaseTemplate< T >::checkValuePrivate ( const T &  value) const
inlineprotectedvirtual

Check if the value is valid.

Definition at line 515 of file qgssettingsentry.h.

◆ checkValueVariant()

template<class T >
bool QgsSettingsEntryBaseTemplate< T >::checkValueVariant ( const QVariant &  value) const
inlineoverridevirtual

Returns true if the given value is valid towards the setting definition.

Reimplemented from QgsSettingsEntryBase.

Definition at line 490 of file qgssettingsentry.h.

◆ convertFromVariant()

template<class T >
virtual T QgsSettingsEntryBaseTemplate< T >::convertFromVariant ( const QVariant &  value) const
pure virtual

◆ convertToVariant()

template<class T >
virtual QVariant QgsSettingsEntryBaseTemplate< T >::convertToVariant ( const T &  value) const
inlineprotectedvirtual

◆ defaultValue()

template<class T >
T QgsSettingsEntryBaseTemplate< T >::defaultValue ( ) const
inline

Returns settings default value.

Definition at line 476 of file qgssettingsentry.h.

◆ formerValue() [1/2]

template<class T >
T QgsSettingsEntryBaseTemplate< T >::formerValue ( const QString &  dynamicKeyPart = QString()) const
inline

Returns the former value.

Returns the current value (or default) if there is no former value.

Definition at line 482 of file qgssettingsentry.h.

◆ formerValue() [2/2]

template<class T >
T QgsSettingsEntryBaseTemplate< T >::formerValue ( const QStringList &  dynamicKeyPartList) const
inline

Returns the former value Returns the current value (or default) if there is no former value.

Definition at line 488 of file qgssettingsentry.h.

◆ settingsType()

template<class T >
virtual Qgis::SettingsType QgsSettingsEntryBaseTemplate< T >::settingsType ( ) const
overridepure virtual

◆ setValue() [1/2]

template<class T >
bool QgsSettingsEntryBaseTemplate< T >::setValue ( const T &  value,
const QString &  dynamicKeyPart = QString() 
) const
inline

Set settings value.

Parameters
valuespecifies the value to set.
dynamicKeyPartspecifies the dynamic part of the settings key.

Definition at line 459 of file qgssettingsentry.h.

◆ setValue() [2/2]

template<class T >
bool QgsSettingsEntryBaseTemplate< T >::setValue ( const T &  value,
const QStringList &  dynamicKeyPartList 
) const
inline

Set settings value.

Parameters
valuespecifies the value to set.
dynamicKeyPartListspecifies the list of dynamic parts of the settings key.

Definition at line 470 of file qgssettingsentry.h.

◆ setValuePrivate()

template<class T >
virtual bool QgsSettingsEntryBaseTemplate< T >::setValuePrivate ( const T &  value,
const QStringList &  dynamicKeyPartList 
) const
inlineprotectedvirtual

◆ value() [1/2]

template<class T >
T QgsSettingsEntryBaseTemplate< T >::value ( const QString &  dynamicKeyPart = QString()) const
inline

Returns settings value.

Parameters
dynamicKeyPartspecifies the dynamic part of the settings key.

Definition at line 431 of file qgssettingsentry.h.

◆ value() [2/2]

template<class T >
T QgsSettingsEntryBaseTemplate< T >::value ( const QStringList &  dynamicKeyPartList) const
inline

Returns settings value.

Parameters
dynamicKeyPartListspecifies the list of dynamic parts of the settings key.

Definition at line 438 of file qgssettingsentry.h.

◆ valueWithDefaultOverride() [1/2]

template<class T >
T QgsSettingsEntryBaseTemplate< T >::valueWithDefaultOverride ( const T &  defaultValueOverride,
const QString &  dynamicKeyPart = QString() 
) const
inline

Returns the settings value with a defaultValueOverride and with an optional dynamicKeyPart.

Definition at line 442 of file qgssettingsentry.h.

◆ valueWithDefaultOverride() [2/2]

template<class T >
T QgsSettingsEntryBaseTemplate< T >::valueWithDefaultOverride ( const T &  defaultValueOverride,
const QStringList &  dynamicKeyPartList 
) const
inline

Returns the settings value with a defaultValueOverride for the dynamicKeyPartList.

Definition at line 448 of file qgssettingsentry.h.


The documentation for this class was generated from the following file: