16#ifndef QGSSETTINGSENTRY_H
17#define QGSSETTINGSENTRY_H
48 sipIsErr = sipCpp->isValid() ? 0 : 1;
50 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Settings do not share the same base definition key for this group. This will lead to unpredictable results." ).toUtf8().constData() );
61 QString baseKey(
const QStringList &dynamicKeyPartList = QStringList() )
const;
64 const QList<const QgsSettingsEntryBase *>
settings()
const {
return mSettings;}
70 void removeAllSettingsAtBaseKey(
const QStringList &dynamicKeyPartList = QStringList() )
const;
76 void removeAllChildrenSettings(
const QString &dynamicKeyPart = QString() )
const;
82 void removeAllChildrenSettings(
const QStringList &dynamicKeyPartList )
const;
85 bool hasDynamicKey()
const;
87 QList<const QgsSettingsEntryBase *> mSettings;
88 QString mDefinitionBaseKey;
108 sipType = sipType_QgsSettingsEntryVariant;
110 sipType = sipType_QgsSettingsEntryString;
112 sipType = sipType_QgsSettingsEntryStringList;
114 sipType = sipType_QgsSettingsEntryBool;
116 sipType = sipType_QgsSettingsEntryInteger;
118 sipType = sipType_QgsSettingsEntryDouble;
120 sipType = sipType_QgsSettingsEntryColor;
132 static QStringList dynamicKeyPartToList(
const QString &dynamicKeyPart );
145 const QString §ion,
146 const QVariant &defaultValue = QVariant(),
147 const QString &description = QString(),
148 Qgis::SettingsOptions options = Qgis::SettingsOptions() )
149 : mKey( QStringLiteral(
"%1/%2" ).arg( section, key ) )
150 , mDefaultValue( defaultValue )
151 , mDescription( description )
153 , mOptions( options )
166 QString key(
const QString &dynamicKeyPart = QString() )
const;
173 QString key(
const QStringList &dynamicKeyPartList )
const;
184 bool keyIsValid(
const QString &key )
const;
191 QString definitionKey()
const;
196 bool hasDynamicKey()
const;
202 Qgis::SettingsOptions
options()
const {
return mOptions;}
209 bool exists(
const QString &dynamicKeyPart = QString() )
const;
216 bool exists(
const QStringList &dynamicKeyPartList )
const;
223 void remove(
const QString &dynamicKeyPart = QString() )
const;
230 void remove(
const QStringList &dynamicKeyPartList )
const;
245 Q_DECL_DEPRECATED
virtual bool setVariantValue(
const QVariant &value,
const QString &dynamicKeyPart = QString() ) const
SIP_DEPRECATED;
254 Q_DECL_DEPRECATED virtual
bool setVariantValue( const QVariant &value, const QStringList &dynamicKeyPartList ) const
SIP_DEPRECATED;
257 QVariant valueAsVariant( const QString &dynamicKeyPart = QString() ) const;
260 QVariant valueAsVariant( const QStringList &dynamicKeyPartList ) const;
266 QVariant valueAsVariantWithDefaultOverride( const QVariant &defaultValueOverride, const QString &dynamicKeyPart = QString() ) const;
275 QVariant valueAsVariantWithDefaultOverride( const QVariant &defaultValueOverride, const QStringList &dynamicKeyPartList ) const;
281 Q_DECL_DEPRECATED QVariant valueAsVariant( const QString &dynamicKeyPart,
bool useDefaultValueOverride, const QVariant &defaultValueOverride ) const
SIP_DEPRECATED;
287 Q_DECL_DEPRECATED QVariant valueAsVariant( const QStringList &dynamicKeyPartList,
bool useDefaultValueOverride, const QVariant &defaultValueOverride ) const
SIP_DEPRECATED;
293 QVariant defaultValueAsVariant() const;
298 virtual
Qgis::SettingsType settingsType() const = 0;
303 QString description() const;
310 QVariant formerValueAsVariant( const QString &dynamicKeyPart ) const;
317 QVariant formerValueAsVariant( const QStringList &dynamicKeyPartList ) const;
326 bool setVariantValuePrivate( const QVariant &value, const QStringList &dynamicKeyPartList = QStringList() ) const;
329 QString formerValuekey( const QStringList &dynamicKeyPartList ) const;
332 QVariant mDefaultValue;
333 QString mDescription;
335 Qgis::SettingsOptions mOptions;
363 const QString §ion,
364 const T &defaultValue,
365 const QString &description = QString(),
366 Qgis::SettingsOptions options = Qgis::SettingsOptions() )
379 T
value(
const QString &dynamicKeyPart = QString() )
const {
return this->convertFromVariant( valueAsVariant( dynamicKeyPart ) );}
387 T
value(
const QStringList &dynamicKeyPartList )
const {
return this->convertFromVariant( valueAsVariant( dynamicKeyPartList ) );}
390 T
valueWithDefaultOverride(
const T &defaultValueOverride,
const QString &dynamicKeyPart = QString() )
const {
return this->convertFromVariant( valueAsVariantWithDefaultOverride( defaultValueOverride, dynamicKeyPart ) );}
392 T
valueWithDefaultOverride(
const T &defaultValueOverride,
const QStringList &dynamicKeyPartList )
const {
return this->convertFromVariant( valueAsVariantWithDefaultOverride( defaultValueOverride, dynamicKeyPartList ) );}
398 Q_DECL_DEPRECATED T
value(
const QString &dynamicKeyPart,
bool useDefaultValueOverride,
const T &defaultValueOverride )
const SIP_DEPRECATED
400 if ( useDefaultValueOverride )
401 return this->convertFromVariant( valueAsVariantWithDefaultOverride( defaultValueOverride, dynamicKeyPart ) );
403 return this->convertFromVariant( valueAsVariant( dynamicKeyPart ) );
410 Q_DECL_DEPRECATED T
value(
const QStringList &dynamicKeyPartList,
bool useDefaultValueOverride,
const T &defaultValueOverride )
const SIP_DEPRECATED
412 if ( useDefaultValueOverride )
413 return this->convertFromVariant( valueAsVariantWithDefaultOverride( defaultValueOverride, dynamicKeyPartList ) );
415 return this->convertFromVariant( valueAsVariant( dynamicKeyPartList ) );
424 bool setValue(
const T &value,
const QString &dynamicKeyPart = QString() )
const
426 return setValuePrivate( value, dynamicKeyPartToList( dynamicKeyPart ) );
435 bool setValue(
const T &value,
const QStringList &dynamicKeyPartList )
const
437 return setValuePrivate( value, dynamicKeyPartList );
441 T
defaultValue()
const {
return convertFromVariant( defaultValueAsVariant() );}
447 T
formerValue(
const QString &dynamicKeyPart = QString() )
const {
return convertFromVariant( formerValueAsVariant( dynamicKeyPart ) );}
453 T
formerValue(
const QStringList &dynamicKeyPartList )
const {
return convertFromVariant( formerValueAsVariant( dynamicKeyPartList ) );}
459 if ( checkValue( value ) )
471 return QVariant::fromValue( value );
508 QgsSettingsEntryByValue(
const QString &key,
const QString §ion, QVariant defaultValue,
const QString &description = QString(), Qgis::SettingsOptions options = Qgis::SettingsOptions() )
520 T
value(
const QString &dynamicKeyPart = QString() )
const {
return this->convertFromVariant( valueAsVariant( dynamicKeyPart ) );}
528 T
value(
const QStringList &dynamicKeyPartList )
const {
return this->convertFromVariant( valueAsVariant( dynamicKeyPartList ) );}
531 T
valueWithDefaultOverride( T defaultValueOverride,
const QString &dynamicKeyPart = QString() )
const {
return this->convertFromVariant( valueAsVariantWithDefaultOverride( defaultValueOverride, dynamicKeyPart ) );}
533 T
valueWithDefaultOverride( T defaultValueOverride,
const QStringList &dynamicKeyPartList )
const {
return this->convertFromVariant( valueAsVariantWithDefaultOverride( defaultValueOverride, dynamicKeyPartList ) );}
539 Q_DECL_DEPRECATED T
value(
const QString &dynamicKeyPart,
bool useDefaultValueOverride, T defaultValueOverride )
const SIP_DEPRECATED
541 if ( useDefaultValueOverride )
542 return this->convertFromVariant( valueAsVariantWithDefaultOverride( defaultValueOverride, dynamicKeyPart ) );
544 return this->convertFromVariant( valueAsVariant( dynamicKeyPart ) );
551 Q_DECL_DEPRECATED T
value(
const QStringList &dynamicKeyPartList,
bool useDefaultValueOverride, T defaultValueOverride )
const SIP_DEPRECATED
553 if ( useDefaultValueOverride )
554 return this->convertFromVariant( valueAsVariantWithDefaultOverride( defaultValueOverride, dynamicKeyPartList ) );
556 return this->convertFromVariant( valueAsVariant( dynamicKeyPartList ) );
565 bool setValue( T value,
const QString &dynamicKeyPart = QString() )
const
567 return setValuePrivate( value, dynamicKeyPartToList( dynamicKeyPart ) );
576 bool setValue( T value,
const QStringList &dynamicKeyPartList )
const
578 return setValuePrivate( value, dynamicKeyPartList );
582 T
defaultValue()
const {
return convertFromVariant( defaultValueAsVariant() );}
588 T
formerValue(
const QString &dynamicKeyPart = QString() )
const {
return convertFromVariant( formerValueAsVariant( dynamicKeyPart ) );}
594 T
formerValue(
const QStringList &dynamicKeyPartList )
const {
return convertFromVariant( formerValueAsVariant( dynamicKeyPartList ) );}
600 if ( checkValue( value ) )
612 return QVariant::fromValue( value );
The Qgis class provides global constants for use throughout the application.
SettingsType
Types of settings entries.
Represent settings entry and provides methods for reading and writing settings values.
virtual ~QgsSettingsEntryBase()
Destructor for QgsSettingsEntryBase.
Qgis::SettingsOptions options() const
Returns the settings options.
Q_DECL_DEPRECATED QgsSettings::Section section() const
Returns settings section.
bool setVariantValuePrivate(const QVariant &value, const QStringList &dynamicKeyPartList=QStringList()) const
Sets the settings value with a variant value.
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.
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.
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.
Creates a group of setting which have a common definition of base key.
bool isValid() const
Returns if the group is valid (if settings share the same base key)
const QList< const QgsSettingsEntryBase * > settings() const
Returns all the settings.
QgsSettingsEntryGroup(const QList< const QgsSettingsEntryBase * > settings)
Constructor.
An integer settings entry.
A string list settings entry.
A variant settings entry.
Section
Sections for namespaced settings.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)