16#ifndef QGSSETTINGSENTRYENUMFLAG_H
17#define QGSSETTINGSENTRYENUMFLAG_H
59 mMetaEnum = QMetaEnum::fromType<T>();
60 Q_ASSERT( mMetaEnum.isValid() );
61 if ( !mMetaEnum.isValid() )
62 QgsDebugError( 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 QgsDebugError( 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 QgsDebugError( QStringLiteral(
"Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '%1'" ).arg( this->
key() ) );
112 if ( !mMetaEnum.isFlag() )
119 QgsDebugError( QStringLiteral(
"Invalid enum/flag key/s '%1' for settings key '%2'" ).arg(
value.toString(), this->key() ) );
123 return enumFlagValue;
134 if ( !mMetaEnum.isValid() )
136 QgsDebugError( 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.
Base abstract class for settings entries with typed get and set methods.
T defaultValue() const
Returns settings default value.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
virtual QString typeId() const
Returns the id of the type of settings This can be re-implemented in a custom implementation of a set...
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.
bool setVariantValue(const QVariant &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
QString name() const
Returns the name of the settings.
QString key(const QString &dynamicKeyPart=QString()) const
Returns settings entry key.
A template class for enum and flag settings entry.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
virtual QString typeId() const override
Returns the id of the type of settings This can be re-implemented in a custom implementation of a set...
QVariant convertToVariant(const T &value) const override
Converts the value to a variant.
bool setValuePrivate(const T &value, const QStringList &dynamicKeyPartList) const override
Set settings value.
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.
#define QgsDebugError(str)