QGIS API Documentation  3.24.2-Tisler (13c1a02865)
Public Types | Public 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 Types

enum class  SettingsType : int {
  Variant , String , StringList , Bool ,
  Integer , Double , EnumFlag , Color
}
 Types of settings entries. More...
 

Public Member Functions

 QgsSettingsEntryBase (const QString &key, const QString &pluginName, const QVariant &defaultValue=QVariant(), const QString &description=QString())
 Constructor for QgsSettingsEntryBase. More...
 
 QgsSettingsEntryBase (const QString &key, QgsSettings::Section section, const QVariant &defaultValue=QVariant(), const QString &description=QString())
 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...
 
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...
 
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...
 
QgsSettings::Section section () const
 Returns settings section. More...
 
virtual SettingsType settingsType () const =0
 Returns the settings entry type. More...
 
virtual bool setVariantValue (const QVariant &value, const QString &dynamicKeyPart=QString()) const
 Set settings value. More...
 
virtual bool setVariantValue (const QVariant &value, const QStringList &dynamicKeyPartList) const
 Set settings value. More...
 
QVariant valueAsVariant (const QString &dynamicKeyPart=QString(), bool useDefaultValueOverride=false, const QVariant &defaultValueOverride=QVariant()) const
 Returns settings value. More...
 
QVariant valueAsVariant (const QStringList &dynamicKeyPartList, bool useDefaultValueOverride=false, const QVariant &defaultValueOverride=QVariant()) const
 Returns settings 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 37 of file qgssettingsentry.h.

Member Enumeration Documentation

◆ SettingsType

Types of settings entries.

Enumerator
Variant 

Generic variant.

String 

String.

StringList 

List of strings.

Bool 

Boolean.

Integer 

Integer.

Double 

Double precision numer.

EnumFlag 

Enum or Flag.

Color 

Color.

Definition at line 64 of file qgssettingsentry.h.

Constructor & Destructor Documentation

◆ QgsSettingsEntryBase() [1/2]

QgsSettingsEntryBase::QgsSettingsEntryBase ( const QString &  key,
QgsSettings::Section  section,
const QVariant &  defaultValue = QVariant(),
const QString &  description = QString() 
)

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.

Definition at line 22 of file qgssettingsentry.cpp.

◆ QgsSettingsEntryBase() [2/2]

QgsSettingsEntryBase::QgsSettingsEntryBase ( const QString &  key,
const QString &  pluginName,
const QVariant &  defaultValue = QVariant(),
const QString &  description = QString() 
)

Constructor for QgsSettingsEntryBase.

This constructor is intended to be used from plugins.

The key argument specifies the key of the settings. The pluginName argument is inserted in the key after the section. The defaultValue argument specifies the default value for the settings entry. The description argument specifies a description for the settings entry.

Definition at line 31 of file qgssettingsentry.cpp.

◆ ~QgsSettingsEntryBase()

QgsSettingsEntryBase::~QgsSettingsEntryBase ( )
virtual

Destructor for QgsSettingsEntryBase.

Definition at line 40 of file qgssettingsentry.cpp.

Member Function Documentation

◆ defaultValueAsVariant()

QVariant QgsSettingsEntryBase::defaultValueAsVariant ( ) const

Returns settings default value.

Definition at line 213 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 131 of file qgssettingsentry.cpp.

◆ description()

QString QgsSettingsEntryBase::description ( ) const

Returns the settings entry description.

Definition at line 218 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 150 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 155 of file qgssettingsentry.cpp.

◆ hasDynamicKey()

bool QgsSettingsEntryBase::hasDynamicKey ( ) const

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

Definition at line 144 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 44 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 53 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 86 of file qgssettingsentry.cpp.

◆ 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 160 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 165 of file qgssettingsentry.cpp.

◆ section()

QgsSettings::Section QgsSettingsEntryBase::section ( ) const

Returns settings section.

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

Definition at line 170 of file qgssettingsentry.cpp.

◆ settingsType()

virtual 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.

Definition at line 175 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.

Definition at line 184 of file qgssettingsentry.cpp.

◆ valueAsVariant() [1/2]

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

Returns settings value.

The dynamicKeyPart argument specifies the dynamic part of the settings key. The useDefaultValueOverride argument specifies if defaultValueOverride should be used. The defaultValueOverride argument if valid is used instead of the normal default value.

Definition at line 192 of file qgssettingsentry.cpp.

◆ valueAsVariant() [2/2]

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

Returns settings value.

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

Definition at line 201 of file qgssettingsentry.cpp.


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