|
QGIS API Documentation 4.1.0-Master (376402f9aeb)
|
Represents a 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. | |
| QgsSettingsEntryBase (const QString &name, QgsSettingsTreeNode *parent, const QVariant &defaultValue=QVariant(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions()) | |
| Constructor for QgsSettingsEntryBase. | |
| virtual | ~QgsSettingsEntryBase () |
| virtual bool | checkValueVariant (const QVariant &value) const |
Returns true if the given value is valid towards the setting definition. | |
| bool | copyValueFromKey (const QString &key, bool removeSettingAtKey=false) const |
| Copies the value from a given key if it exists. | |
| bool | copyValueFromKey (const QString &key, const QStringList &dynamicKeyPartList, bool removeSettingAtKey=false) const |
| Copies the value from a given key if it exists. | |
| void | copyValueToKey (const QString &key, const QStringList &dynamicKeyPartList=QStringList()) const |
| Copies the settings to the given key. | |
| 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()). | |
| QVariant | defaultValueAsVariant () const |
| Returns settings default value. | |
| QString | definitionKey () const |
| Returns settings entry defining key. | |
| QString | description () const |
| Returns the settings entry description. | |
| bool | exists (const QString &dynamicKeyPart=QString()) const |
Returns true if the settings is contained in the underlying QSettings. | |
| bool | exists (const QStringList &dynamicKeyPartList) const |
Returns true if the settings is contained in the underlying QSettings. | |
| QVariant | formerValueAsVariant (const QString &dynamicKeyPart) const |
| Returns the former value of the settings if it has been enabled in the options. | |
| 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. | |
| bool | hasChanged () const |
Returns true if the setting was changed during the current QGIS session. | |
| bool | hasDynamicKey () const |
Returns true if a part of the settings key is built dynamically. | |
| QString | key (const QString &dynamicKeyPart=QString()) const |
| Returns settings entry key. | |
| QString | key (const QStringList &dynamicKeyPartList) const |
| Returns settings entry key. | |
| bool | keyIsValid (const QString &key) const |
Returns true if the provided key match the settings entry. | |
| QString | name () const |
| Returns the name of the settings. | |
| Qgis::SettingsOptions | options () const |
| Returns the settings options. | |
| Qgis::SettingsOrigin | origin (const QStringList &dynamicKeyPartList) const |
| Returns the origin of the setting if it exists. | |
| QgsSettingsTreeNode * | parent () const |
| Returns the parent tree element. | |
| void | remove (const QString &dynamicKeyPart=QString()) const |
| Removes the settings from the underlying QSettings. | |
| void | remove (const QStringList &dynamicKeyPartList) const |
| Removes the settings from the underlying QSettings. | |
| Q_DECL_DEPRECATED int | section () const |
| Returns settings section. | |
| virtual Qgis::SettingsType | settingsType () const |
| Returns the settings entry type. | |
| bool | setVariantValue (const QVariant &value, const QString &dynamicKeyPart=QString()) const |
| Set settings value. | |
| bool | setVariantValue (const QVariant &value, const QStringList &dynamicKeyPartList) const |
| Set settings value. | |
| virtual QString | typeId () const |
| Returns the id of the type of settings This can be re-implemented in a custom implementation of a setting. | |
| Q_DECL_DEPRECATED QVariant | valueAsVariant (const QString &dynamicKeyPart, bool useDefaultValueOverride, const QVariant &defaultValueOverride) const |
| Returns settings value with an optional default value override. | |
| QVariant | valueAsVariant (const QString &dynamicKeyPart=QString()) const |
| Returns settings value with. | |
| QVariant | valueAsVariant (const QStringList &dynamicKeyPartList) const |
| Returns settings value with. | |
| Q_DECL_DEPRECATED QVariant | valueAsVariant (const QStringList &dynamicKeyPartList, bool useDefaultValueOverride, const QVariant &defaultValueOverride) const |
| Returns settings value with an optional default value override. | |
| QVariant | valueAsVariantWithDefaultOverride (const QVariant &defaultValueOverride, const QString &dynamicKeyPart=QString()) const |
| Returns settings value with a defaultValueOverride. | |
| QVariant | valueAsVariantWithDefaultOverride (const QVariant &defaultValueOverride, const QStringList &dynamicKeyPartList) const |
| Returns settings value. | |
Static Public Member Functions | |
| static QStringList | dynamicKeyPartToList (const QString &dynamicKeyPart) |
| Transforms a dynamic key part string to list. | |
| static void | setupUserSettings (const QString &profilePath) |
| Configures QSettings to use IniFormat at the given profilePath so that each thread's QSettings instance is recreated on next access with the correct format and path. | |
| static QSettings & | userSettings () |
| Returns a reference to the thread-local QSettings instance used internally by all QgsSettingsEntry operations. | |
Represents a settings entry and provides methods for reading and writing settings values.
Different subclasses are provided for different settings types with metainformation to validate set values and provide more accurate settings description for the gui.
Definition at line 48 of file qgssettingsentry.h.
|
inline |
Constructor for QgsSettingsEntryBase.
| key | specifies the key of the settings. |
| section | specifies the section. |
| defaultValue | specifies the default value for the settings entry. |
| description | specifies a description for the settings entry. |
| options | specifies the options for the settings entry. |
Definition at line 122 of file qgssettingsentry.h.
| QgsSettingsEntryBase::QgsSettingsEntryBase | ( | const QString & | name, |
| QgsSettingsTreeNode * | parent, | ||
| const QVariant & | defaultValue = QVariant(), | ||
| const QString & | description = QString(), | ||
| Qgis::SettingsOptions | options = Qgis::SettingsOptions() ) |
Constructor for QgsSettingsEntryBase.
| name | specifies the name of the setting. |
| parent | specifies the parent in the tree of settings. |
| defaultValue | specifies the default value for the settings entry. |
| description | specifies a description for the settings entry. |
| options | specifies the options for the settings entry. |
| QgsSettingsException | if the number of given parent named items doesn't match the complete key definition |
Definition at line 69 of file qgssettingsentry.cpp.
|
virtual |
Definition at line 84 of file qgssettingsentry.cpp.
|
inlinevirtual |
Returns true if the given value is valid towards the setting definition.
Reimplemented in QgsSettingsEntryBaseTemplate< T >, QgsSettingsEntryBaseTemplate< bool >, QgsSettingsEntryBaseTemplate< ColorTextFormat >, QgsSettingsEntryBaseTemplate< double >, QgsSettingsEntryBaseTemplate< ENUM >, QgsSettingsEntryBaseTemplate< FLAGS >, QgsSettingsEntryBaseTemplate< IdentifyMode >, QgsSettingsEntryBaseTemplate< int >, QgsSettingsEntryBaseTemplate< QColor >, QgsSettingsEntryBaseTemplate< Qgis::CadMeasurementDisplayType >, QgsSettingsEntryBaseTemplate< Qgis::DpiMode >, QgsSettingsEntryBaseTemplate< Qgis::EmbeddedScriptMode >, QgsSettingsEntryBaseTemplate< Qgis::EndCapStyle >, QgsSettingsEntryBaseTemplate< Qgis::GpsConnectionType >, QgsSettingsEntryBaseTemplate< Qgis::GpsInformationComponent >, QgsSettingsEntryBaseTemplate< Qgis::HttpMethod >, QgsSettingsEntryBaseTemplate< Qgis::JoinStyle >, QgsSettingsEntryBaseTemplate< Qgis::LayerTreeInsertionMethod >, QgsSettingsEntryBaseTemplate< Qgis::LegendSyncMode >, QgsSettingsEntryBaseTemplate< Qgis::MapToolUnit >, QgsSettingsEntryBaseTemplate< Qgis::SnappingMode >, QgsSettingsEntryBaseTemplate< Qgis::SnappingType >, QgsSettingsEntryBaseTemplate< Qgis::TilePixelRatio >, QgsSettingsEntryBaseTemplate< Qgis::UnknownLayerCrsBehavior >, QgsSettingsEntryBaseTemplate< Qgis::VectorRenderingSimplificationFlags >, QgsSettingsEntryBaseTemplate< Qgis::VectorSimplificationAlgorithm >, QgsSettingsEntryBaseTemplate< QgsAbstractGeometry::SegmentationToleranceType >, QgsSettingsEntryBaseTemplate< qlonglong >, QgsSettingsEntryBaseTemplate< QString >, QgsSettingsEntryBaseTemplate< QStringList >, QgsSettingsEntryBaseTemplate< Qt::TimeSpec >, QgsSettingsEntryBaseTemplate< QVariant >, and QgsSettingsEntryBaseTemplate< QVariantMap >.
Definition at line 371 of file qgssettingsentry.h.
|
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 334 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 284 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 307 of file qgssettingsentry.cpp.
| void QgsSettingsEntryBase::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()).
| 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 313 of file qgssettingsentry.cpp.
| QVariant QgsSettingsEntryBase::defaultValueAsVariant | ( | ) | const |
Returns settings default value.
Definition at line 262 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 149 of file qgssettingsentry.cpp.
| QString QgsSettingsEntryBase::description | ( | ) | const |
Returns the settings entry description.
Definition at line 267 of file qgssettingsentry.cpp.
|
static |
Transforms a dynamic key part string to list.
Definition at line 219 of file qgssettingsentry.cpp.
| bool QgsSettingsEntryBase::exists | ( | const QString & | dynamicKeyPart = QString() | ) | const |
Returns true if the settings is contained in the underlying QSettings.
| dynamicKeyPart | specifies the dynamic part of the settings key. |
Definition at line 160 of file qgssettingsentry.cpp.
| bool QgsSettingsEntryBase::exists | ( | const QStringList & | dynamicKeyPartList | ) | const |
Returns true if the settings is contained in the underlying QSettings.
| dynamicKeyPartList | specifies the list of dynamic parts of the settings key. |
Definition at line 165 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 272 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 277 of file qgssettingsentry.cpp.
|
inline |
Returns true if the setting was changed during the current QGIS session.
Definition at line 382 of file qgssettingsentry.h.
| bool QgsSettingsEntryBase::hasDynamicKey | ( | ) | const |
Returns true if a part of the settings key is built dynamically.
Definition at line 154 of file qgssettingsentry.cpp.
| QString QgsSettingsEntryBase::key | ( | const QString & | dynamicKeyPart = QString() | ) | const |
Returns settings entry key.
| dynamicKeyPart | specifies the dynamic part of the settings key. |
Definition at line 96 of file qgssettingsentry.cpp.
| QString QgsSettingsEntryBase::key | ( | const QStringList & | dynamicKeyPartList | ) | const |
Returns settings entry key.
| dynamicKeyPartList | specifies the list of dynamic parts of the settings key. |
Definition at line 101 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"
| key | to check |
Definition at line 133 of file qgssettingsentry.cpp.
|
inline |
|
inline |
| Qgis::SettingsOrigin QgsSettingsEntryBase::origin | ( | const QStringList & | dynamicKeyPartList | ) | const |
Returns the origin of the setting if it exists.
Definition at line 170 of file qgssettingsentry.cpp.
|
inline |
| void QgsSettingsEntryBase::remove | ( | const QString & | dynamicKeyPart = QString() | ) | const |
Removes the settings from the underlying QSettings.
| dynamicKeyPart | specifies the dynamic part of the settings key. |
Definition at line 178 of file qgssettingsentry.cpp.
| void QgsSettingsEntryBase::remove | ( | const QStringList & | dynamicKeyPartList | ) | const |
Removes the settings from the underlying QSettings.
| dynamicKeyPartList | specifies the list of dynamic parts of the settings key. |
Definition at line 183 of file qgssettingsentry.cpp.
| int QgsSettingsEntryBase::section | ( | ) | const |
Returns settings section.
The settings section of the parent group is returned if available.
Definition at line 188 of file qgssettingsentry.cpp.
|
inlinevirtual |
Returns the settings entry type.
Reimplemented in QgsSettingsEntryBaseTemplate< T >, QgsSettingsEntryBaseTemplate< bool >, QgsSettingsEntryBaseTemplate< ColorTextFormat >, QgsSettingsEntryBaseTemplate< double >, QgsSettingsEntryBaseTemplate< ENUM >, QgsSettingsEntryBaseTemplate< FLAGS >, QgsSettingsEntryBaseTemplate< IdentifyMode >, QgsSettingsEntryBaseTemplate< int >, QgsSettingsEntryBaseTemplate< QColor >, QgsSettingsEntryBaseTemplate< Qgis::CadMeasurementDisplayType >, QgsSettingsEntryBaseTemplate< Qgis::DpiMode >, QgsSettingsEntryBaseTemplate< Qgis::EmbeddedScriptMode >, QgsSettingsEntryBaseTemplate< Qgis::EndCapStyle >, QgsSettingsEntryBaseTemplate< Qgis::GpsConnectionType >, QgsSettingsEntryBaseTemplate< Qgis::GpsInformationComponent >, QgsSettingsEntryBaseTemplate< Qgis::HttpMethod >, QgsSettingsEntryBaseTemplate< Qgis::JoinStyle >, QgsSettingsEntryBaseTemplate< Qgis::LayerTreeInsertionMethod >, QgsSettingsEntryBaseTemplate< Qgis::LegendSyncMode >, QgsSettingsEntryBaseTemplate< Qgis::MapToolUnit >, QgsSettingsEntryBaseTemplate< Qgis::SnappingMode >, QgsSettingsEntryBaseTemplate< Qgis::SnappingType >, QgsSettingsEntryBaseTemplate< Qgis::TilePixelRatio >, QgsSettingsEntryBaseTemplate< Qgis::UnknownLayerCrsBehavior >, QgsSettingsEntryBaseTemplate< Qgis::VectorRenderingSimplificationFlags >, QgsSettingsEntryBaseTemplate< Qgis::VectorSimplificationAlgorithm >, QgsSettingsEntryBaseTemplate< QgsAbstractGeometry::SegmentationToleranceType >, QgsSettingsEntryBaseTemplate< qlonglong >, QgsSettingsEntryBaseTemplate< QString >, QgsSettingsEntryBaseTemplate< QStringList >, QgsSettingsEntryBaseTemplate< Qt::TimeSpec >, QgsSettingsEntryBaseTemplate< QVariant >, QgsSettingsEntryBaseTemplate< QVariantMap >, QgsSettingsEntryBool, QgsSettingsEntryColor, QgsSettingsEntryDouble, QgsSettingsEntryEnumFlag< T >, QgsSettingsEntryEnumFlag< ColorTextFormat >, QgsSettingsEntryEnumFlag< ENUM >, QgsSettingsEntryEnumFlag< FLAGS >, QgsSettingsEntryEnumFlag< IdentifyMode >, QgsSettingsEntryEnumFlag< Qgis::CadMeasurementDisplayType >, QgsSettingsEntryEnumFlag< Qgis::DpiMode >, QgsSettingsEntryEnumFlag< Qgis::EmbeddedScriptMode >, QgsSettingsEntryEnumFlag< Qgis::EndCapStyle >, QgsSettingsEntryEnumFlag< Qgis::GpsConnectionType >, QgsSettingsEntryEnumFlag< Qgis::GpsInformationComponent >, QgsSettingsEntryEnumFlag< Qgis::HttpMethod >, QgsSettingsEntryEnumFlag< Qgis::JoinStyle >, QgsSettingsEntryEnumFlag< Qgis::LayerTreeInsertionMethod >, QgsSettingsEntryEnumFlag< Qgis::LegendSyncMode >, QgsSettingsEntryEnumFlag< Qgis::MapToolUnit >, QgsSettingsEntryEnumFlag< Qgis::SnappingMode >, QgsSettingsEntryEnumFlag< Qgis::SnappingType >, QgsSettingsEntryEnumFlag< Qgis::TilePixelRatio >, QgsSettingsEntryEnumFlag< Qgis::UnknownLayerCrsBehavior >, QgsSettingsEntryEnumFlag< Qgis::VectorRenderingSimplificationFlags >, QgsSettingsEntryEnumFlag< Qgis::VectorSimplificationAlgorithm >, QgsSettingsEntryEnumFlag< QgsAbstractGeometry::SegmentationToleranceType >, QgsSettingsEntryEnumFlag< Qt::TimeSpec >, QgsSettingsEntryInteger64, QgsSettingsEntryInteger, QgsSettingsEntryString, QgsSettingsEntryStringList, QgsSettingsEntryVariant, and QgsSettingsEntryVariantMap.
Definition at line 305 of file qgssettingsentry.h.
|
static |
Configures QSettings to use IniFormat at the given profilePath so that each thread's QSettings instance is recreated on next access with the correct format and path.
This is a convenience wrapper around QSettings::setDefaultFormat() and QSettings::setPath().
It should be called once at application startup, before QgsApplication initialization, and only from the main thread.
If called a second time, it will have no effect.
Definition at line 52 of file qgssettingsentry.cpp.
| bool QgsSettingsEntryBase::setVariantValue | ( | const QVariant & | value, |
| const QString & | dynamicKeyPart = QString() ) const |
Set settings value.
| value | specifies the value to set. |
| dynamicKeyPart | specifies the dynamic part of the settings key. |
Definition at line 193 of file qgssettingsentry.cpp.
| bool QgsSettingsEntryBase::setVariantValue | ( | const QVariant & | value, |
| const QStringList & | dynamicKeyPartList ) const |
Set settings value.
This should be called from any implementation as it takes care of actually calling QSettings
| value | specifies the value to set. |
| dynamicKeyPartList | specifies the list of dynamic parts of the settings key. |
Definition at line 198 of file qgssettingsentry.cpp.
|
virtual |
Returns the id of the type of settings This can be re-implemented in a custom implementation of a setting.
Reimplemented in QgsSettingsEntryEnumFlag< T >, QgsSettingsEntryEnumFlag< ColorTextFormat >, QgsSettingsEntryEnumFlag< ENUM >, QgsSettingsEntryEnumFlag< FLAGS >, QgsSettingsEntryEnumFlag< IdentifyMode >, QgsSettingsEntryEnumFlag< Qgis::CadMeasurementDisplayType >, QgsSettingsEntryEnumFlag< Qgis::DpiMode >, QgsSettingsEntryEnumFlag< Qgis::EmbeddedScriptMode >, QgsSettingsEntryEnumFlag< Qgis::EndCapStyle >, QgsSettingsEntryEnumFlag< Qgis::GpsConnectionType >, QgsSettingsEntryEnumFlag< Qgis::GpsInformationComponent >, QgsSettingsEntryEnumFlag< Qgis::HttpMethod >, QgsSettingsEntryEnumFlag< Qgis::JoinStyle >, QgsSettingsEntryEnumFlag< Qgis::LayerTreeInsertionMethod >, QgsSettingsEntryEnumFlag< Qgis::LegendSyncMode >, QgsSettingsEntryEnumFlag< Qgis::MapToolUnit >, QgsSettingsEntryEnumFlag< Qgis::SnappingMode >, QgsSettingsEntryEnumFlag< Qgis::SnappingType >, QgsSettingsEntryEnumFlag< Qgis::TilePixelRatio >, QgsSettingsEntryEnumFlag< Qgis::UnknownLayerCrsBehavior >, QgsSettingsEntryEnumFlag< Qgis::VectorRenderingSimplificationFlags >, QgsSettingsEntryEnumFlag< Qgis::VectorSimplificationAlgorithm >, QgsSettingsEntryEnumFlag< QgsAbstractGeometry::SegmentationToleranceType >, and QgsSettingsEntryEnumFlag< Qt::TimeSpec >.
Definition at line 90 of file qgssettingsentry.cpp.
|
static |
Returns a reference to the thread-local QSettings instance used internally by all QgsSettingsEntry operations.
Definition at line 64 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 237 of file qgssettingsentry.cpp.
| QVariant QgsSettingsEntryBase::valueAsVariant | ( | const QString & | dynamicKeyPart = QString() | ) | const |
Returns settings value with.
| dynamicKeyPart | specifying the dynamic part of the settings key. |
Definition at line 227 of file qgssettingsentry.cpp.
| QVariant QgsSettingsEntryBase::valueAsVariant | ( | const QStringList & | dynamicKeyPartList | ) | const |
Returns settings value with.
| dynamicKeyPartList | specifying the dynamic part of the settings key. |
Definition at line 232 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 244 of file qgssettingsentry.cpp.
| QVariant QgsSettingsEntryBase::valueAsVariantWithDefaultOverride | ( | const QVariant & | defaultValueOverride, |
| const QString & | dynamicKeyPart = QString() ) const |
Returns settings value with a defaultValueOverride.
Definition at line 252 of file qgssettingsentry.cpp.
| QVariant QgsSettingsEntryBase::valueAsVariantWithDefaultOverride | ( | const QVariant & | defaultValueOverride, |
| const QStringList & | dynamicKeyPartList ) const |
Returns settings value.
| dynamicKeyPartList | specifies the list of dynamic parts of the settings key. |
| defaultValueOverride | if valid is used instead of the normal default value. |
Definition at line 257 of file qgssettingsentry.cpp.