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(),
93 Qgis::SettingsOptions options = Qgis::SettingsOptions() )
95 , mKey( QStringLiteral(
"%1/%2" ).arg( section,
key ) )
96 , mDefaultValue( defaultValue )
97 , mDescription( description )
115 const QVariant &defaultValue = QVariant(),
116 const QString &description = QString(),
129 virtual QString typeId() const;
135 QString name()
const {
return mName;}
142 QString
key(
const QString &dynamicKeyPart = QString() )
const;
149 QString
key(
const QStringList &dynamicKeyPartList )
const;
160 bool keyIsValid(
const QString &
key )
const;
167 QString definitionKey()
const;
172 bool hasDynamicKey()
const;
178 Qgis::SettingsOptions
options()
const {
return mOptions;}
185 bool exists(
const QString &dynamicKeyPart = QString() )
const;
192 bool exists(
const QStringList &dynamicKeyPartList )
const;
206 void remove(
const QString &dynamicKeyPart = QString() )
const;
213 void remove(
const QStringList &dynamicKeyPartList )
const;
219 Q_DECL_DEPRECATED
int section()
const;
227 bool setVariantValue(
const QVariant &value,
const QString &dynamicKeyPart = QString() )
const;
235 bool setVariantValue(
const QVariant &value,
const QStringList &dynamicKeyPartList )
const;
238 QVariant valueAsVariant(
const QString &dynamicKeyPart = QString() )
const;
241 QVariant valueAsVariant(
const QStringList &dynamicKeyPartList )
const;
247 QVariant valueAsVariantWithDefaultOverride(
const QVariant &defaultValueOverride,
const QString &dynamicKeyPart = QString() )
const;
256 QVariant valueAsVariantWithDefaultOverride(
const QVariant &defaultValueOverride,
const QStringList &dynamicKeyPartList )
const;
262 Q_DECL_DEPRECATED QVariant valueAsVariant(
const QString &dynamicKeyPart,
bool useDefaultValueOverride,
const QVariant &defaultValueOverride )
const SIP_DEPRECATED;
268 Q_DECL_DEPRECATED QVariant valueAsVariant(
const QStringList &dynamicKeyPartList,
bool useDefaultValueOverride,
const QVariant &defaultValueOverride )
const SIP_DEPRECATED;
274 QVariant defaultValueAsVariant()
const;
285 QString description()
const;
292 QVariant formerValueAsVariant(
const QString &dynamicKeyPart )
const;
299 QVariant formerValueAsVariant(
const QStringList &dynamicKeyPartList )
const;
318 bool copyValueFromKey(
const QString &
key,
const QStringList &dynamicKeyPartList,
bool removeSettingAtKey =
false )
const;
326 void copyValueToKey(
const QString &
key,
const QStringList &dynamicKeyPartList = QStringList() )
const;
342 QString formerValuekey(
const QStringList &dynamicKeyPartList )
const;
344 QString completeKeyPrivate(
const QString &
key,
const QStringList &dynamicKeyPartList )
const;
349 QVariant mDefaultValue;
350 QString mDescription;
351 Qgis::SettingsOptions mOptions;
384 Qgis::SettingsOptions
options = Qgis::SettingsOptions() )
401 Qgis::SettingsOptions
options = Qgis::SettingsOptions() )
441 bool setValue(
const T &
value,
const QString &dynamicKeyPart = QString() )
const
452 bool setValue(
const T &
value,
const QStringList &dynamicKeyPartList )
const
493 return QVariant::fromValue(
value );
SettingsType
Types of settings entries.
@ Custom
Custom implementation.
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.
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,...)