16#ifndef QGSSETTINGSENTRYENUMFLAG_H
17#define QGSSETTINGSENTRYENUMFLAG_H
56 mMetaEnum = QMetaEnum::fromType<T>();
57 Q_ASSERT( mMetaEnum.isValid() );
58 if ( !mMetaEnum.isValid() )
59 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '%1'" ).arg( this->
key() ) );
67 if ( !mMetaEnum.isValid() )
69 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '%1'" ).arg( this->
key() ) );
75 if ( !mMetaEnum.isFlag() )
82 QgsDebugMsg( QStringLiteral(
"Invalid enum/flag key/s '%1' for settings key '%2'" ).arg(
value.toString(), this->key() ) );
97 if ( !mMetaEnum.isValid() )
99 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '%1'" ).arg( this->
key( dynamicKeyPartList ) ) );
103 QVariant variantValue;
108 variantValue =
static_cast<int>(
value );
112 if ( !mMetaEnum.isFlag() )
SettingsType
Types of settings entries.
Qgis::SettingsOptions options() const
Returns the settings options.
Q_DECL_DEPRECATED QgsSettings::Section section() const
Returns settings section.
QString description() const
Returns the settings entry description.
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.
Base abstract class for settings entry which are passed by value.
T defaultValue() const
Returns settings default value.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
A template class for enum and flag settings entry.
bool setValuePrivate(T value, const QStringList &dynamicKeyPartList) const override
Set settings value.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
QgsSettingsEntryEnumFlag(const QString &key, const QString §ion, T defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryEnumFlagBase.
T convertFromVariant(const QVariant &value) const override
Returns settings default value.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
QString qgsFlagValueToKeys(const T &value, bool *returnOk=nullptr)
Returns the value for the given keys of a flag.
T qgsFlagKeysToValue(const QString &keys, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given keys of a flag.