QGIS API Documentation  3.27.0-Master (11ef3e5184)
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsSettingsEntryBase Class Referenceabstract

Represent settings entry and provides methods for reading and writing settings values. More...

#include <qgssettingsentry.h>

Inheritance diagram for QgsSettingsEntryBase:
Inheritance graph
[legend]

Public Member Functions

 QgsSettingsEntryBase (const QString &key, const QString &section, const QVariant &defaultValue=QVariant(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
 Constructor for QgsSettingsEntryBase. More...
 
virtual ~QgsSettingsEntryBase ()
 Destructor for QgsSettingsEntryBase. 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 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...
 
Qgis::SettingsOptions options () const
 Returns the settings options. 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 QgsSettings::Section section () const
 Returns settings section. More...
 
virtual Qgis::SettingsType settingsType () const =0
 Returns the settings entry type. More...
 
virtual Q_DECL_DEPRECATED bool setVariantValue (const QVariant &value, const QString &dynamicKeyPart=QString()) const
 Set settings value. More...
 
virtual Q_DECL_DEPRECATED bool setVariantValue (const QVariant &value, const QStringList &dynamicKeyPartList) const
 Set settings value. 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 the dynamicKeyPart argument specifying the dynamic part of the settings key. More...
 
QVariant valueAsVariant (const QStringList &dynamicKeyPartList) const
 Returns settings value with the dynamicKeyPart argument specifying the dynamic part of the settings key. 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...
 

Static Public Member Functions

static QStringList dynamicKeyPartToList (const QString &dynamicKeyPart)
 Transforms a dynamic key part string to list. More...
 

Protected Member Functions

bool setVariantValuePrivate (const QVariant &value, const QStringList &dynamicKeyPartList=QStringList()) const
 Sets the settings value with a variant value. More...
 

Detailed Description

Represent settings entry and provides methods for reading and writing settings values.

Different subclasses are provided for different settings types with metainformations to validate set values and provide more accurate settings description for the gui.

Since
QGIS 3.20

Definition at line 102 of file qgssettingsentry.h.

Constructor & Destructor Documentation

◆ QgsSettingsEntryBase()

QgsSettingsEntryBase::QgsSettingsEntryBase ( const QString &  key,
const QString &  section,
const QVariant &  defaultValue = QVariant(),
const QString &  description = QString(),
Qgis::SettingsOptions  options = Qgis::SettingsOptions() 
)
inline

Constructor for QgsSettingsEntryBase.

The key argument specifies the key of the settings. The section argument specifies the section. The defaultValue argument specifies the default value for the settings entry. The description argument specifies a description for the settings entry. The options argument specifies the options for the settings entry.

Definition at line 144 of file qgssettingsentry.h.

◆ ~QgsSettingsEntryBase()

virtual QgsSettingsEntryBase::~QgsSettingsEntryBase ( )
inlinevirtual

Destructor for QgsSettingsEntryBase.

Definition at line 159 of file qgssettingsentry.h.

Member Function Documentation

◆ defaultValueAsVariant()

QVariant QgsSettingsEntryBase::defaultValueAsVariant ( ) const

Returns settings default value.

Definition at line 264 of file qgssettingsentry.cpp.

◆ definitionKey()

QString QgsSettingsEntryBase::definitionKey ( ) const

Returns settings entry defining key.

For dynamic settings it return the key with the placeholder for dynamic part included. For non-dynamic settings returns the same as key().

Definition at line 162 of file qgssettingsentry.cpp.

◆ description()

QString QgsSettingsEntryBase::description ( ) const

Returns the settings entry description.

Definition at line 269 of file qgssettingsentry.cpp.

◆ dynamicKeyPartToList()

QStringList QgsSettingsEntryBase::dynamicKeyPartToList ( const QString &  dynamicKeyPart)
static

Transforms a dynamic key part string to list.

Since
QGIS 3.26

Definition at line 220 of file qgssettingsentry.cpp.

◆ exists() [1/2]

bool QgsSettingsEntryBase::exists ( const QString &  dynamicKeyPart = QString()) const

Returns true if the settings is contained in the underlying QSettings.

The dynamicKeyPart argument specifies the dynamic part of the settings key.

Definition at line 173 of file qgssettingsentry.cpp.

◆ exists() [2/2]

bool QgsSettingsEntryBase::exists ( const QStringList &  dynamicKeyPartList) const

Returns true if the settings is contained in the underlying QSettings.

The dynamicKeyParts argument specifies the list of dynamic parts of the settings key.

Definition at line 178 of file qgssettingsentry.cpp.

◆ formerValueAsVariant() [1/2]

QVariant QgsSettingsEntryBase::formerValueAsVariant ( const QString &  dynamicKeyPart) 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.

Since
QGIS 3.26

Definition at line 274 of file qgssettingsentry.cpp.

◆ formerValueAsVariant() [2/2]

QVariant QgsSettingsEntryBase::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.

Since
QGIS 3.26

Definition at line 279 of file qgssettingsentry.cpp.

◆ hasDynamicKey()

bool QgsSettingsEntryBase::hasDynamicKey ( ) const

Returns true if a part of the settings key is built dynamically.

Definition at line 167 of file qgssettingsentry.cpp.

◆ key() [1/2]

QString QgsSettingsEntryBase::key ( const QString &  dynamicKeyPart = QString()) const

Returns settings entry key.

The dynamicKeyPart argument specifies the dynamic part of the settings key.

Definition at line 109 of file qgssettingsentry.cpp.

◆ key() [2/2]

QString QgsSettingsEntryBase::key ( const QStringList &  dynamicKeyPartList) const

Returns settings entry key.

The dynamicKeyParts argument specifies the list of dynamic parts of the settings key.

Definition at line 114 of file qgssettingsentry.cpp.

◆ keyIsValid()

bool QgsSettingsEntryBase::keyIsValid ( const QString &  key) const

Returns true if the provided key match the settings entry.

This is useful for settings with dynamic keys. For example this permits one to check that the settings key "NewsFeed/httpsfeedqgisorg/27/content" is valid for the settings entry defined with the key "NewsFeed/%1/%2/content"

The key to check

Definition at line 147 of file qgssettingsentry.cpp.

◆ options()

Qgis::SettingsOptions QgsSettingsEntryBase::options ( ) const
inline

Returns the settings options.

Since
QGIS 3.26

Definition at line 202 of file qgssettingsentry.h.

◆ remove() [1/2]

void QgsSettingsEntryBase::remove ( const QString &  dynamicKeyPart = QString()) const

Removes the settings from the underlying QSettings.

The dynamicKeyPart argument specifies the dynamic part of the settings key.

Definition at line 183 of file qgssettingsentry.cpp.

◆ remove() [2/2]

void QgsSettingsEntryBase::remove ( const QStringList &  dynamicKeyPartList) const

Removes the settings from the underlying QSettings.

The dynamicKeyParts argument specifies the list of dynamic parts of the settings key.

Definition at line 188 of file qgssettingsentry.cpp.

◆ section()

Q_DECL_DEPRECATED QgsSettings::Section QgsSettingsEntryBase::section ( ) const
inline

Returns settings section.

The settings section of the parent group is returned if available.

Deprecated:
since QGIS 3.26 the key is entirely self-defined

Definition at line 236 of file qgssettingsentry.h.

◆ settingsType()

virtual Qgis::SettingsType QgsSettingsEntryBase::settingsType ( ) const
pure virtual

◆ setVariantValue() [1/2]

bool QgsSettingsEntryBase::setVariantValue ( const QVariant &  value,
const QString &  dynamicKeyPart = QString() 
) const
virtual

Set settings value.

The value to set. The dynamicKeyPart argument specifies the dynamic part of the settings key.

Deprecated:
since QGIS 3.26 use setVariantValuePrivate or an implementation setValue instead

Definition at line 193 of file qgssettingsentry.cpp.

◆ setVariantValue() [2/2]

bool QgsSettingsEntryBase::setVariantValue ( const QVariant &  value,
const QStringList &  dynamicKeyPartList 
) const
virtual

Set settings value.

The value to set. The dynamicKeyParts argument specifies the list of dynamic parts of the settings key.

Deprecated:
since QGIS 3.26 use setVariantValuePrivate or an implementation setValue instead

Definition at line 198 of file qgssettingsentry.cpp.

◆ setVariantValuePrivate()

bool QgsSettingsEntryBase::setVariantValuePrivate ( const QVariant &  value,
const QStringList &  dynamicKeyPartList = QStringList() 
) const
protected

Sets the settings value with a variant value.

This should be called from any implementation as it takes care of actually calling QSettings

Since
QGIS 3.26

Definition at line 203 of file qgssettingsentry.cpp.

◆ valueAsVariant() [1/4]

QVariant QgsSettingsEntryBase::valueAsVariant ( const QString &  dynamicKeyPart,
bool  useDefaultValueOverride,
const QVariant &  defaultValueOverride 
) const

Returns settings value with an optional default value override.

Deprecated:
since QGIS 3.26 use valueAsVariantWithDefaultOverride instead

Definition at line 238 of file qgssettingsentry.cpp.

◆ valueAsVariant() [2/4]

QVariant QgsSettingsEntryBase::valueAsVariant ( const QString &  dynamicKeyPart = QString()) const

Returns settings value with the dynamicKeyPart argument specifying the dynamic part of the settings key.

Definition at line 228 of file qgssettingsentry.cpp.

◆ valueAsVariant() [3/4]

QVariant QgsSettingsEntryBase::valueAsVariant ( const QStringList &  dynamicKeyPartList) const

Returns settings value with the dynamicKeyPart argument specifying the dynamic part of the settings key.

Definition at line 233 of file qgssettingsentry.cpp.

◆ valueAsVariant() [4/4]

QVariant QgsSettingsEntryBase::valueAsVariant ( const QStringList &  dynamicKeyPartList,
bool  useDefaultValueOverride,
const QVariant &  defaultValueOverride 
) const

Returns settings value with an optional default value override.

Deprecated:
since QGIS 3.26 use valueAsVariantWithDefaultOverride instead

Definition at line 245 of file qgssettingsentry.cpp.

◆ valueAsVariantWithDefaultOverride() [1/2]

QVariant QgsSettingsEntryBase::valueAsVariantWithDefaultOverride ( const QVariant &  defaultValueOverride,
const QString &  dynamicKeyPart = QString() 
) const

Returns settings value with a defaultValueOverride.

Since
QGIS 3.26

Definition at line 253 of file qgssettingsentry.cpp.

◆ valueAsVariantWithDefaultOverride() [2/2]

QVariant QgsSettingsEntryBase::valueAsVariantWithDefaultOverride ( const QVariant &  defaultValueOverride,
const QStringList &  dynamicKeyPartList 
) const

Returns settings value.

The dynamicKeyPartList argument specifies the list of dynamic parts of the settings key. The defaultValueOverride argument if valid is used instead of the normal default value.

Since
QGIS 3.26

Definition at line 258 of file qgssettingsentry.cpp.


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