16#ifndef QGSSETTINGSENTRY_H
17#define QGSSETTINGSENTRY_H
31static const inline QMetaEnum sSettingsTypeMetaEnum = QMetaEnum::fromType<Qgis::SettingsType>()
SIP_SKIP;
50 sipType = sipType_QgsSettingsEntryVariant;
52 sipType = sipType_QgsSettingsEntryString;
54 sipType = sipType_QgsSettingsEntryStringList;
56 sipType = sipType_QgsSettingsEntryVariantMap;
58 sipType = sipType_QgsSettingsEntryBool;
60 sipType = sipType_QgsSettingsEntryInteger;
62 sipType = sipType_QgsSettingsEntryDouble;
64 sipType = sipType_QgsSettingsEntryColor;
66 sipType = sipType_QgsSettingsEntryBase;
78 static QStringList dynamicKeyPartToList(
const QString &dynamicKeyPart );
90 const QString §ion,
91 const QVariant &defaultValue = QVariant(),
92 const QString &description = QString(),
95 , mKey( QStringLiteral(
"%1/%2" ).arg( section,
key ) )
96 , mDefaultValue( defaultValue )
97 , mDescription( description )
115 const QVariant &defaultValue = QVariant(),
116 const QString &description = QString(),
126 virtual QString typeId() const;
132 QString name()
const {
return mName;}
139 QString
key(
const QString &dynamicKeyPart = QString() )
const;
146 QString
key(
const QStringList &dynamicKeyPartList )
const;
157 bool keyIsValid(
const QString &
key )
const;
164 QString definitionKey()
const;
169 bool hasDynamicKey()
const;
182 bool exists(
const QString &dynamicKeyPart = QString() )
const;
189 bool exists(
const QStringList &dynamicKeyPartList )
const;
203 void remove(
const QString &dynamicKeyPart = QString() )
const;
210 void remove(
const QStringList &dynamicKeyPartList )
const;
216 Q_DECL_DEPRECATED
int section()
const;
224 bool setVariantValue(
const QVariant &value,
const QString &dynamicKeyPart = QString() )
const;
232 bool setVariantValue(
const QVariant &value,
const QStringList &dynamicKeyPartList )
const;
235 QVariant valueAsVariant(
const QString &dynamicKeyPart = QString() )
const;
238 QVariant valueAsVariant(
const QStringList &dynamicKeyPartList )
const;
244 QVariant valueAsVariantWithDefaultOverride(
const QVariant &defaultValueOverride,
const QString &dynamicKeyPart = QString() )
const;
253 QVariant valueAsVariantWithDefaultOverride(
const QVariant &defaultValueOverride,
const QStringList &dynamicKeyPartList )
const;
259 Q_DECL_DEPRECATED QVariant valueAsVariant(
const QString &dynamicKeyPart,
bool useDefaultValueOverride,
const QVariant &defaultValueOverride )
const SIP_DEPRECATED;
265 Q_DECL_DEPRECATED QVariant valueAsVariant(
const QStringList &dynamicKeyPartList,
bool useDefaultValueOverride,
const QVariant &defaultValueOverride )
const SIP_DEPRECATED;
271 QVariant defaultValueAsVariant()
const;
282 QString description()
const;
289 QVariant formerValueAsVariant(
const QString &dynamicKeyPart )
const;
296 QVariant formerValueAsVariant(
const QStringList &dynamicKeyPartList )
const;
315 bool copyValueFromKey(
const QString &
key,
const QStringList &dynamicKeyPartList,
bool removeSettingAtKey =
false )
const;
323 void copyValueToKey(
const QString &
key,
const QStringList &dynamicKeyPartList = QStringList() )
const;
333 void copyValueToKeyIfChanged(
const QString &
key,
const QStringList &dynamicKeyPartList = QStringList() )
const;
356 QString formerValuekey(
const QStringList &dynamicKeyPartList )
const;
358 QString completeKeyPrivate(
const QString &
key,
const QStringList &dynamicKeyPartList )
const;
363 QVariant mDefaultValue;
364 QString mDescription;
366 mutable bool mHasChanged =
false;
456 bool setValue(
const T &
value,
const QString &dynamicKeyPart = QString() )
const
467 bool setValue(
const T &
value,
const QStringList &dynamicKeyPartList )
const
508 return QVariant::fromValue(
value );
SettingsType
Types of settings entries.
@ Custom
Custom implementation.
QFlags< SettingsOption > SettingsOptions
SettingsOrigin
The setting origin describes where a setting is stored.
Base abstract class for settings entries with typed get and set methods.
QgsSettingsEntryBaseTemplate(const QString &name, QgsSettingsTreeNode *parent, const QVariant &defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryByReference.
virtual bool setValuePrivate(const T &value, const QStringList &dynamicKeyPartList) const
Sets the settings value with an optional list of dynamic parts.
T valueWithDefaultOverride(const T &defaultValueOverride, const QString &dynamicKeyPart=QString()) const
Returns the settings value with a defaultValueOverride and with an optional dynamicKeyPart.
T defaultValue() const
Returns settings default value.
virtual T convertFromVariant(const QVariant &value) const =0
Converts the variant value to the value type of the setting.
virtual Qgis::SettingsType settingsType() const override=0
Returns the settings entry type.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
QgsSettingsEntryBaseTemplate(const QString &key, const QString §ion, const QVariant &defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryByReference.
virtual QVariant convertToVariant(const T &value) const
Converts the value to a variant.
bool checkValueVariant(const QVariant &value) const override
Returns true if the given value is valid towards the setting definition.
T value(const QStringList &dynamicKeyPartList) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
bool setValue(const T &value, const QStringList &dynamicKeyPartList) const
Set settings value.
virtual bool checkValuePrivate(const T &value) const
Check if the value is valid.
T formerValue(const QString &dynamicKeyPart=QString()) const
Returns the former value.
T valueWithDefaultOverride(const T &defaultValueOverride, const QStringList &dynamicKeyPartList) const
Returns the settings value with a defaultValueOverride for the dynamicKeyPartList.
T formerValue(const QStringList &dynamicKeyPartList) const
Returns the former value Returns the current value (or default) if there is no former value.
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.
bool hasChanged() const
Returns true if the setting was changed during the current QGIS session.
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.
virtual bool checkValueVariant(const QVariant &value) const
Returns true if the given value is valid towards the setting definition.
bool setVariantValue(const QVariant &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
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.
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.
virtual Qgis::SettingsType settingsType() const
Returns the settings entry type.
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.
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...
QString key() const
Returns the key of the node (without its parents)
QgsSettingsTreeNode * parent() const
Returns the parent of the node or nullptr if it does not exists.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_THROW(name,...)