16#ifndef QGSSETTINGSENTRY_H
17#define QGSSETTINGSENTRY_H
47 sipType = sipType_QgsSettingsEntryVariant;
49 sipType = sipType_QgsSettingsEntryString;
51 sipType = sipType_QgsSettingsEntryStringList;
53 sipType = sipType_QgsSettingsEntryVariantMap;
55 sipType = sipType_QgsSettingsEntryBool;
57 sipType = sipType_QgsSettingsEntryInteger;
59 sipType = sipType_QgsSettingsEntryDouble;
61 sipType = sipType_QgsSettingsEntryColor;
63 sipType = sipType_QgsSettingsEntryBase;
75 static QStringList dynamicKeyPartToList(
const QString &dynamicKeyPart );
87 const QString §ion,
88 const QVariant &defaultValue = QVariant(),
89 const QString &description = QString(),
90 Qgis::SettingsOptions options = Qgis::SettingsOptions() )
92 , mKey( QStringLiteral(
"%1/%2" ).arg( section, key ) )
93 , mDefaultValue( defaultValue )
94 , mDescription( description )
112 const QVariant &defaultValue = QVariant(),
113 const QString &description = QString(),
125 QString name()
const {
return mName;}
132 QString key(
const QString &dynamicKeyPart = QString() )
const;
139 QString key(
const QStringList &dynamicKeyPartList )
const;
150 bool keyIsValid(
const QString &key )
const;
157 QString definitionKey()
const;
162 bool hasDynamicKey()
const;
168 Qgis::SettingsOptions
options()
const {
return mOptions;}
175 bool exists(
const QString &dynamicKeyPart = QString() )
const;
182 bool exists(
const QStringList &dynamicKeyPartList )
const;
196 void remove(
const QString &dynamicKeyPart = QString() )
const;
203 void remove(
const QStringList &dynamicKeyPartList )
const;
209 Q_DECL_DEPRECATED
int section()
const;
218 Q_DECL_DEPRECATED
virtual bool setVariantValue(
const QVariant &value,
const QString &dynamicKeyPart = QString() ) const
SIP_DEPRECATED;
227 Q_DECL_DEPRECATED virtual
bool setVariantValue( const QVariant &value, const QStringList &dynamicKeyPartList ) const
SIP_DEPRECATED;
230 QVariant valueAsVariant( const QString &dynamicKeyPart = QString() ) const;
233 QVariant valueAsVariant( const QStringList &dynamicKeyPartList ) const;
239 QVariant valueAsVariantWithDefaultOverride( const QVariant &defaultValueOverride, const QString &dynamicKeyPart = QString() ) const;
248 QVariant valueAsVariantWithDefaultOverride( const QVariant &defaultValueOverride, const QStringList &dynamicKeyPartList ) const;
254 Q_DECL_DEPRECATED QVariant valueAsVariant( const QString &dynamicKeyPart,
bool useDefaultValueOverride, const QVariant &defaultValueOverride ) const
SIP_DEPRECATED;
260 Q_DECL_DEPRECATED QVariant valueAsVariant( const QStringList &dynamicKeyPartList,
bool useDefaultValueOverride, const QVariant &defaultValueOverride ) const
SIP_DEPRECATED;
266 QVariant defaultValueAsVariant() const;
277 QString description()
const;
284 QVariant formerValueAsVariant(
const QString &dynamicKeyPart )
const;
291 QVariant formerValueAsVariant(
const QStringList &dynamicKeyPartList )
const;
310 bool copyValueFromKey(
const QString &key,
const QStringList &dynamicKeyPartList,
bool removeSettingAtKey =
false )
const;
318 void copyValueToKey(
const QString &key,
const QStringList &dynamicKeyPartList = QStringList() )
const;
333 bool setVariantValuePrivate(
const QVariant &value,
const QStringList &dynamicKeyPartList = QStringList() )
const;
336 QString formerValuekey(
const QStringList &dynamicKeyPartList )
const;
338 QString completeKeyPrivate(
const QString &key,
const QStringList &dynamicKeyPartList )
const;
343 QVariant mDefaultValue;
344 QString mDescription;
345 Qgis::SettingsOptions mOptions;
380 Qgis::SettingsOptions
options = Qgis::SettingsOptions() )
397 Qgis::SettingsOptions
options = Qgis::SettingsOptions() )
435 Q_DECL_DEPRECATED T
value(
const QString &dynamicKeyPart,
bool useDefaultValueOverride,
const T &defaultValueOverride )
const SIP_DEPRECATED
437 if ( useDefaultValueOverride )
447 Q_DECL_DEPRECATED T
value(
const QStringList &dynamicKeyPartList,
bool useDefaultValueOverride,
const T &defaultValueOverride )
const SIP_DEPRECATED
449 if ( useDefaultValueOverride )
461 bool setValue(
const T &
value,
const QString &dynamicKeyPart = QString() )
const
472 bool setValue(
const T &
value,
const QStringList &dynamicKeyPartList )
const
508 return QVariant::fromValue(
value );
594 Q_DECL_DEPRECATED T
value(
const QString &dynamicKeyPart,
bool useDefaultValueOverride, T defaultValueOverride )
const SIP_DEPRECATED
596 if ( useDefaultValueOverride )
606 Q_DECL_DEPRECATED T
value(
const QStringList &dynamicKeyPartList,
bool useDefaultValueOverride, T defaultValueOverride )
const SIP_DEPRECATED
608 if ( useDefaultValueOverride )
667 return QVariant::fromValue(
value );
The Qgis class provides global constants for use throughout the application.
SettingsType
Types of settings entries.
@ Custom
Custom implementation.
SettingsOrigin
The setting origin describes where a setting is stored.
Represent settings entry and provides methods for reading and writing settings values.
bool copyValueFromKey(const QString &key, bool removeSettingAtKey=false) const
Copies the value from a given key if it exists.
Qgis::SettingsOptions options() const
Returns the settings options.
QVariant defaultValueAsVariant() const
Returns settings default value.
QString description() const
Returns the settings entry description.
QgsSettingsTreeNode * parent() const
Returns the parent tree element.
Q_DECL_DEPRECATED int section() const
Returns settings section.
QString name() const
Returns the name of the settings.
QVariant formerValueAsVariant(const QString &dynamicKeyPart) const
Returns the former value of the settings if it has been enabled in the options.
QVariant valueAsVariant(const QString &dynamicKeyPart=QString()) const
Returns settings value with.
bool setVariantValuePrivate(const QVariant &value, const QStringList &dynamicKeyPartList=QStringList()) const
Sets the settings value with a variant value.
QString key(const QString &dynamicKeyPart=QString()) const
Returns settings entry key.
static QStringList dynamicKeyPartToList(const QString &dynamicKeyPart)
Transforms a dynamic key part string to list.
QVariant valueAsVariantWithDefaultOverride(const QVariant &defaultValueOverride, const QString &dynamicKeyPart=QString()) const
Returns settings value with a defaultValueOverride.
QgsSettingsEntryBase(const QString &key, const QString §ion, const QVariant &defaultValue=QVariant(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryBase.
A boolean settings entry.
Base abstract class for settings entry which are passed by reference.
Q_DECL_DEPRECATED T value(const QStringList &dynamicKeyPartList, bool useDefaultValueOverride, const T &defaultValueOverride) const
Returns the settings value for the dynamicKeyPartList and with a defaultValueOverride.
virtual QVariant convertToVariant(const T &value) const
Converts the value to a variant.
T formerValue(const QString &dynamicKeyPart=QString()) const
Returns the former value.
T valueWithDefaultOverride(const T &defaultValueOverride, const QString &dynamicKeyPart=QString()) const
Returns the settings value with a defaultValueOverride and with an optional dynamicKeyPart.
QgsSettingsEntryByReference(const QString &name, QgsSettingsTreeNode *parent, const T &defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryByReference.
virtual Qgis::SettingsType settingsType() const override=0
Returns the settings entry type.
T formerValue(const QStringList &dynamicKeyPartList) const
Returns the former value Returns the current value (or default) if there is no former value.
QgsSettingsEntryByReference(const QString &key, const QString §ion, const T &defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryByReference.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
Q_DECL_DEPRECATED T value(const QString &dynamicKeyPart, bool useDefaultValueOverride, const T &defaultValueOverride) const
Returns the settings value for the dynamicKeyPart and with a defaultValueOverride.
T defaultValue() const
Returns settings default value.
T value(const QStringList &dynamicKeyPartList) const
Returns settings value.
bool setValue(const T &value, const QStringList &dynamicKeyPartList) const
Set settings value.
virtual T convertFromVariant(const QVariant &value) const =0
Converts the variant value to the value type of the setting.
virtual bool checkValue(const T &value) const
Check if the value is valid.
bool setValuePrivate(const T &value, const QStringList &dynamicKeyPartList) const
Sets the settings value with an optional list of dynamic parts.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
T valueWithDefaultOverride(const T &defaultValueOverride, const QStringList &dynamicKeyPartList) const
Returns the settings value with a defaultValueOverride for the dynamicKeyPartList.
Base abstract class for settings entry which are passed by value.
T formerValue(const QString &dynamicKeyPart=QString()) const
Returns the former value Returns the current value (or default) if there is no former value.
virtual QVariant convertToVariant(T value) const
Converts the value to a variant.
QgsSettingsEntryByValue(const QString &key, QgsSettingsTreeNode *parent, QVariant defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryByValue.
virtual T convertFromVariant(const QVariant &value) const =0
Converts the variant value to the value type of the setting.
virtual bool setValuePrivate(T value, const QStringList &dynamicKeyPartList) const
Sets the settings value with an optional list of dynamic parts.
T valueWithDefaultOverride(T defaultValueOverride, const QString &dynamicKeyPart=QString()) const
Returns the settings value with a defaultValueOverride and with an optional dynamicKeyPart.
QgsSettingsEntryByValue(const QString &key, const QString §ion, QVariant defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryByValue.
T value(const QStringList &dynamicKeyPartList) const
Returns settings value.
T defaultValue() const
Returns settings default value.
T valueWithDefaultOverride(T defaultValueOverride, const QStringList &dynamicKeyPartList) const
Returns the settings value with a defaultValueOverride for the dynamicKeyPartList.
virtual bool checkValue(T value) const
Check if the value is valid.
bool setValue(T value, const QStringList &dynamicKeyPartList) const
Set settings value.
bool setValue(T value, const QString &dynamicKeyPart=QString()) const
Set settings value.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
T formerValue(const QStringList &dynamicKeyPartList) const
Returns the former value Returns the current value (or default) if there is no former value.
virtual Qgis::SettingsType settingsType() const override=0
Returns the settings entry type.
Q_DECL_DEPRECATED T value(const QStringList &dynamicKeyPartList, bool useDefaultValueOverride, T defaultValueOverride) const
Returns the settings value for the dynamicKeyPartList and with a defaultValueOverride.
Q_DECL_DEPRECATED T value(const QString &dynamicKeyPart, bool useDefaultValueOverride, T defaultValueOverride) const
Returns the settings value for the dynamicKeyPart and with a defaultValueOverride.
An integer settings entry.
A string list settings entry.
A string list settings entry.
A variant settings entry.
Custom exception class for settings related exceptions.
QgsSettingsTreeNode is a tree node for the settings tree to help organizing and introspecting the tre...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_THROW(name,...)