From 00213a3a0906f0e1b5fa97a9e8de235a1e3cdcbf Mon Sep 17 00:00:00 2001 From: Cyril Rossi Date: Mon, 3 Feb 2020 13:50:17 +0100 Subject: kconfig_compiler : generate kconfig settings with subgroup Summary: Following D27059, add `parentGroupName` attribute to `group` element to generate kconfig settings with subgroups Reviewers: ervin, dfaure, #frameworks, meven Reviewed By: ervin, meven Subscribers: apol, meven, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27133 --- src/kconfig_compiler/KConfigSourceGenerator.cpp | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/kconfig_compiler/KConfigSourceGenerator.cpp') diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 0da8d4df..bb2694b2 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -333,6 +333,10 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr } } + if (!entry->parentGroup.isEmpty()) { + stream() << " " << itemVarStr << "->setGroup(cg" << QString(entry->group).remove(QRegExp(QStringLiteral("\\W"))) << ");\n"; + } + stream() << " addItem( " << itemVarStr; QString quotedName = entry->name; addQuotes(quotedName); @@ -342,6 +346,11 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr stream() << " );\n"; } +// TODO : Some compiler option won't work or generate bogus settings file. +// * Does not manage properly Notifiers=true kcfgc option for parameterized entries : +// ** KConfigCompilerSignallingItem generated with wrong userData parameter (4th one). +// ** setWriteFlags() is missing. +// * Q_PROPERTY signal won't work void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QString &key) { for (int i = 0; i <= entry->paramMax; i++) { @@ -410,8 +419,25 @@ void KConfigSourceGenerator::handleCurrentGroupChange(const CfgEntry *entry) } mCurrentGroup = entry->group; - stream() << " setCurrentGroup( " << paramString(mCurrentGroup, parseResult.parameters) << " );"; - stream() << "\n\n"; + + if (!entry->parentGroup.isEmpty()) { + QString parentGroup = QString(entry->parentGroup).remove(QRegExp(QStringLiteral("\\W"))); + if (!mConfigGroupList.contains(parentGroup)) { + stream() << " KConfigGroup cg" << parentGroup + << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n"; + mConfigGroupList << parentGroup; + } + QString currentGroup = QString(mCurrentGroup).remove(QRegExp(QStringLiteral("\\W"))); + if (!mConfigGroupList.contains(currentGroup)) { + stream() << " KConfigGroup cg" << currentGroup + << " = cg" << QString(entry->parentGroup).remove(QRegExp(QStringLiteral("\\W"))) + << ".group(" << paramString(mCurrentGroup, parseResult.parameters) << ");\n"; + mConfigGroupList << currentGroup; + } + } else { + stream() << " setCurrentGroup( " << paramString(mCurrentGroup, parseResult.parameters) << " );"; + stream() << "\n\n"; + } } void KConfigSourceGenerator::doConstructor() -- cgit v1.2.1