QGIS API Documentation 3.29.0-Master (19d7edcfed)
|
Represent settings entry and provides methods for reading and writing settings values. More...
#include <qgssettingsentry.h>
Public Member Functions | |
QgsSettingsEntryBase (const QString &key, const QString §ion, const QVariant &defaultValue=QVariant(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions()) | |
Constructor for QgsSettingsEntryBase. More... | |
QgsSettingsEntryBase (const QString &key, QgsSettingsTreeNode *parentTreeElement, const QVariant &defaultValue=QVariant(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions()) SIP_THROW(QgsSettingsException) | |
Constructor for QgsSettingsEntryBase. More... | |
virtual | ~QgsSettingsEntryBase () |
Destructor for QgsSettingsEntryBase. 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... | |
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... | |
Qgis::SettingsOrigin | origin (const QStringList &dynamicKeyPartList) const |
Returns the origin of the setting if it exists. More... | |
QgsSettingsTreeNode * | parent () 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 QgsSettings::Section | section () const |
Returns settings section. More... | |
virtual Qgis::SettingsType | settingsType () const |
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. 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... | |
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... | |
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.
Definition at line 41 of file qgssettingsentry.h.
|
inline |
Constructor for QgsSettingsEntryBase.
Definition at line 86 of file qgssettingsentry.h.
QgsSettingsEntryBase::QgsSettingsEntryBase | ( | const QString & | key, |
QgsSettingsTreeNode * | parentTreeElement, | ||
const QVariant & | defaultValue = QVariant() , |
||
const QString & | description = QString() , |
||
Qgis::SettingsOptions | options = Qgis::SettingsOptions() |
||
) |
Constructor for QgsSettingsEntryBase.
QgsSettingsException | if the number of given parent named items doesn't match the complete key definition |
Definition at line 23 of file qgssettingsentry.cpp.
|
virtual |
Destructor for QgsSettingsEntryBase.
Definition at line 37 of file qgssettingsentry.cpp.
|
inline |
Copies the value from a given key if it exists.
key | the key to copy the setting value from. |
removeSettingAtKey | if true , the setting at the old key will be removed. |
true
if the key exists and the setting value could be copied. Definition at line 291 of file qgssettingsentry.h.
bool QgsSettingsEntryBase::copyValueFromKey | ( | const QString & | key, |
const QStringList & | dynamicKeyPartList, | ||
bool | removeSettingAtKey = false |
||
) | const |
Copies the value from a given key if it exists.
key | the key to copy the setting value from. |
dynamicKeyPartList | is the optional dynamic key part to determine the key. It must be the same for origin and destination keys. |
removeSettingAtKey | if true , the setting at the old key will be removed. |
true
if the key exists and the setting value could be copied. Definition at line 226 of file qgssettingsentry.cpp.
void QgsSettingsEntryBase::copyValueToKey | ( | const QString & | key, |
const QStringList & | dynamicKeyPartList = QStringList() |
||
) | const |
Copies the settings to the given key.
key | the key to copy the setting value to. |
dynamicKeyPartList | is the optional dynamic key part to determine the key. It must be the same for origin and destination keys. |
Definition at line 246 of file qgssettingsentry.cpp.
QVariant QgsSettingsEntryBase::defaultValueAsVariant | ( | ) | const |
Returns settings default value.
Definition at line 203 of file qgssettingsentry.cpp.
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 96 of file qgssettingsentry.cpp.
QString QgsSettingsEntryBase::description | ( | ) | const |
Returns the settings entry description.
Definition at line 208 of file qgssettingsentry.cpp.
|
static |
Transforms a dynamic key part string to list.
Definition at line 159 of file qgssettingsentry.cpp.
bool QgsSettingsEntryBase::exists | ( | const QString & | dynamicKeyPart = QString() | ) | const |
Returns true
if the settings is contained in the underlying QSettings.
Definition at line 107 of file qgssettingsentry.cpp.
bool QgsSettingsEntryBase::exists | ( | const QStringList & | dynamicKeyPartList | ) | const |
Returns true
if the settings is contained in the underlying QSettings.
Definition at line 112 of file qgssettingsentry.cpp.
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.
Definition at line 213 of file qgssettingsentry.cpp.
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.
Definition at line 218 of file qgssettingsentry.cpp.
bool QgsSettingsEntryBase::hasDynamicKey | ( | ) | const |
Returns true
if a part of the settings key is built dynamically.
Definition at line 101 of file qgssettingsentry.cpp.
QString QgsSettingsEntryBase::key | ( | const QString & | dynamicKeyPart = QString() | ) | const |
Returns settings entry key.
Definition at line 44 of file qgssettingsentry.cpp.
QString QgsSettingsEntryBase::key | ( | const QStringList & | dynamicKeyPartList | ) | const |
Returns settings entry key.
Definition at line 49 of file qgssettingsentry.cpp.
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"
Definition at line 81 of file qgssettingsentry.cpp.
|
inline |
Qgis::SettingsOrigin QgsSettingsEntryBase::origin | ( | const QStringList & | dynamicKeyPartList | ) | const |
Returns the origin of the setting if it exists.
Definition at line 117 of file qgssettingsentry.cpp.
|
inline |
void QgsSettingsEntryBase::remove | ( | const QString & | dynamicKeyPart = QString() | ) | const |
Removes the settings from the underlying QSettings.
Definition at line 122 of file qgssettingsentry.cpp.
void QgsSettingsEntryBase::remove | ( | const QStringList & | dynamicKeyPartList | ) | const |
Removes the settings from the underlying QSettings.
Definition at line 127 of file qgssettingsentry.cpp.
|
inline |
Returns settings section.
The settings section of the parent group is returned if available.
Definition at line 200 of file qgssettingsentry.h.
|
inlinevirtual |
Returns the settings entry type.
Reimplemented in QgsSettingsEntryEnumFlag< T >, QgsSettingsEntryEnumFlag< Qgis::GpsConnectionType >, QgsSettingsEntryEnumFlag< Qt::TimeSpec >, QgsSettingsEntryEnumFlag< Qgis::GpsInformationComponent >, QgsSettingsEntryEnumFlag< Qgis::DpiMode >, QgsSettingsEntryEnumFlag< Qgis::TilePixelRatio >, QgsSettingsEntryEnumFlag< Qgis::SnappingMode >, QgsSettingsEntryEnumFlag< Qgis::SnappingType >, QgsSettingsEntryEnumFlag< QgsTolerance::UnitType >, QgsSettingsEntryEnumFlag< Qgis::JoinStyle >, QgsSettingsEntryEnumFlag< Qgis::EndCapStyle >, QgsSettingsEntryVariant, QgsSettingsEntryString, QgsSettingsEntryStringList, QgsSettingsEntryBool, QgsSettingsEntryInteger, QgsSettingsEntryInteger64, QgsSettingsEntryDouble, QgsSettingsEntryColor, QgsSettingsEntryVariantMap, QgsSettingsEntryByReference< T >, QgsSettingsEntryByReference< QColor >, QgsSettingsEntryByReference< QString >, QgsSettingsEntryByReference< QStringList >, QgsSettingsEntryByReference< QVariant >, QgsSettingsEntryByReference< QVariantMap >, QgsSettingsEntryByValue< T >, QgsSettingsEntryByValue< bool >, QgsSettingsEntryByValue< double >, QgsSettingsEntryByValue< int >, QgsSettingsEntryByValue< qlonglong >, QgsSettingsEntryByValue< Qgis::GpsConnectionType >, QgsSettingsEntryByValue< Qt::TimeSpec >, QgsSettingsEntryByValue< Qgis::GpsInformationComponent >, QgsSettingsEntryByValue< Qgis::DpiMode >, QgsSettingsEntryByValue< Qgis::TilePixelRatio >, QgsSettingsEntryByValue< Qgis::SnappingMode >, QgsSettingsEntryByValue< Qgis::SnappingType >, QgsSettingsEntryByValue< QgsTolerance::UnitType >, QgsSettingsEntryByValue< Qgis::JoinStyle >, and QgsSettingsEntryByValue< Qgis::EndCapStyle >.
Definition at line 262 of file qgssettingsentry.h.
|
virtual |
Set settings value.
The value to set.
Definition at line 132 of file qgssettingsentry.cpp.
|
virtual |
Set settings value.
The value to set.
Definition at line 137 of file qgssettingsentry.cpp.
|
protected |
Sets the settings value with a variant value.
This should be called from any implementation as it takes care of actually calling QSettings
Definition at line 142 of file qgssettingsentry.cpp.
QVariant QgsSettingsEntryBase::valueAsVariant | ( | const QString & | dynamicKeyPart, |
bool | useDefaultValueOverride, | ||
const QVariant & | defaultValueOverride | ||
) | const |
Returns settings value with an optional default value override.
Definition at line 177 of file qgssettingsentry.cpp.
QVariant QgsSettingsEntryBase::valueAsVariant | ( | const QString & | dynamicKeyPart = QString() | ) | const |
Returns settings value with.
Definition at line 167 of file qgssettingsentry.cpp.
QVariant QgsSettingsEntryBase::valueAsVariant | ( | const QStringList & | dynamicKeyPartList | ) | const |
Returns settings value with.
Definition at line 172 of file qgssettingsentry.cpp.
QVariant QgsSettingsEntryBase::valueAsVariant | ( | const QStringList & | dynamicKeyPartList, |
bool | useDefaultValueOverride, | ||
const QVariant & | defaultValueOverride | ||
) | const |
Returns settings value with an optional default value override.
Definition at line 184 of file qgssettingsentry.cpp.
QVariant QgsSettingsEntryBase::valueAsVariantWithDefaultOverride | ( | const QVariant & | defaultValueOverride, |
const QString & | dynamicKeyPart = QString() |
||
) | const |
Returns settings value with a defaultValueOverride.
Definition at line 192 of file qgssettingsentry.cpp.
QVariant QgsSettingsEntryBase::valueAsVariantWithDefaultOverride | ( | const QVariant & | defaultValueOverride, |
const QStringList & | dynamicKeyPartList | ||
) | const |
Returns settings value.
Definition at line 197 of file qgssettingsentry.cpp.