16#ifndef QGSSETTINGSENTRYENUMFLAG_H
17#define QGSSETTINGSENTRYENUMFLAG_H
59 mMetaEnum = QMetaEnum::fromType<T>();
60 Q_ASSERT( mMetaEnum.isValid() );
61 if ( !mMetaEnum.isValid() )
62 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '%1'" ).arg( this->
key() ) );
84 mMetaEnum = QMetaEnum::fromType<T>();
85 Q_ASSERT( mMetaEnum.isValid() );
86 if ( !mMetaEnum.isValid() )
87 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '%1'" ).arg( this->
key() ) );
92 if ( mMetaEnum.isFlag() )
104 if ( !mMetaEnum.isValid() )
106 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '%1'" ).arg( this->
key() ) );
112 if ( !mMetaEnum.isFlag() )
119 QgsDebugMsg( QStringLiteral(
"Invalid enum/flag key/s '%1' for settings key '%2'" ).arg(
value.toString(), this->key() ) );
123 return enumFlagValue;
134 if ( !mMetaEnum.isValid() )
136 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '%1'" ).arg( this->
key( dynamicKeyPartList ) ) );
140 QVariant variantValue;
145 variantValue =
static_cast<int>(
value );
149 if ( !mMetaEnum.isFlag() )
SettingsType
Types of settings entries.
Qgis::SettingsOptions options() const
Returns the settings options.
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.
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.
QVariant convertToVariant(T value) const override
Converts the value to a variant.
QgsSettingsEntryEnumFlag(const QString &name, QgsSettingsTreeNode *parent, T defaultValue, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryEnumFlagBase.
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.
QgsSettingsTreeNode is a tree node for the settings tree to help organizing and introspecting the tre...
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.