diff options
author | Méven Car <meven29@gmail.com> | 2020-03-05 10:02:46 +0100 |
---|---|---|
committer | Méven Car <meven.car@enioka.com> | 2020-03-08 19:02:19 +0100 |
commit | ec207330d5bd61799a47092bf555a523ab000f93 (patch) | |
tree | 1d81fd6d70ff14dcad535cc79c8d40c641a1c676 /src/kconfig_compiler/KConfigSourceGenerator.cpp | |
parent | a38f3d91d9dc6717010f01893ae26c8015b6bb05 (diff) | |
download | kconfig-ec207330d5bd61799a47092bf555a523ab000f93.tar.gz kconfig-ec207330d5bd61799a47092bf555a523ab000f93.tar.bz2 |
KconfigXT: Add a value attribute to Enum field choices
Summary:
Allow to write choices such as :
```
<choices>
<choice name="enum_name" value="I can't containt (anything)"></choice>
<choice name="normal_choice"></choice>
</choices>
```
Test Plan: ctest
Reviewers: ervin, bport, crossi, #frameworks
Reviewed By: ervin
Subscribers: ngraham, davidre, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D27463
Diffstat (limited to 'src/kconfig_compiler/KConfigSourceGenerator.cpp')
-rw-r--r-- | src/kconfig_compiler/KConfigSourceGenerator.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 33e0ed69..3e8a8156 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -313,13 +313,14 @@ void KConfigSourceGenerator::createEnums(const CfgEntry *entry) void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QString &key) { + const QString itemVarStr = itemPath(entry, cfg()); const QString innerItemVarStr = innerItemVar(entry, cfg()); if (!entry->signalList.isEmpty()) { stream() << " " << innerItemVarStr << " = " << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n'; } - stream() << " " << itemPath(entry, cfg()) << " = " + stream() << " " << itemVarStr << " = " << newItem(entry, key, entry->defaultValue, cfg()) << '\n'; if (!entry->min.isEmpty()) { @@ -335,10 +336,16 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr } if (cfg().allNotifiers || cfg().notifiers.contains(entry->name)) { - stream() << " " << itemPath(entry, cfg()) << "->setWriteFlags(KConfigBase::Notify);\n"; + stream() << " " << itemVarStr << "->setWriteFlags(KConfigBase::Notify);\n"; } - stream() << " addItem( " << itemPath(entry, cfg()); + for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) { + if (!choice.val.isEmpty()) { + stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; + } + } + + stream() << " addItem( " << itemVarStr; QString quotedName = entry->name; addQuotes(quotedName); if (quotedName != key) { @@ -374,6 +381,12 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt stream() << " " << innerItemVarStr << "->setMaxValue(" << entry->max << ");\n"; } + for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) { + if (!choice.val.isEmpty()) { + stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; + } + } + if (cfg().setUserTexts) { stream() << userTextsFunctions(entry, cfg(), itemVarStr, entry->paramName); } |