aboutsummaryrefslogtreecommitdiff
path: root/src/kconfig_compiler/kconfig_compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kconfig_compiler/kconfig_compiler.cpp')
-rw-r--r--src/kconfig_compiler/kconfig_compiler.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp
index c7f2d9d9..c648d7d0 100644
--- a/src/kconfig_compiler/kconfig_compiler.cpp
+++ b/src/kconfig_compiler/kconfig_compiler.cpp
@@ -80,6 +80,7 @@ public:
if (!visibility.isEmpty()) {
visibility += ' ';
}
+ parentInConstructor = codegenConfig.value(QStringLiteral("ParentInConstructor"), false).toBool();
forceStringFilename = codegenConfig.value(QStringLiteral("ForceStringFilename"), false).toBool();
singleton = codegenConfig.value(QStringLiteral("Singleton"), false).toBool();
staticAccessors = singleton;
@@ -125,6 +126,7 @@ public:
QString className; // The class name to be generated
QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton)
QString visibility;
+ bool parentInConstructor; // The class has the optional parent parameter in its constructor
bool forceStringFilename;
bool singleton; // The class will be a singleton
bool staticAccessors; // provide or not static accessors
@@ -1895,6 +1897,12 @@ int main(int argc, char **argv)
}
h << " " << param((*it).type) << " " << (*it).name;
}
+ if (cfg.parentInConstructor) {
+ if (cfgFileNameArg || !parameters.isEmpty()) {
+ h << ",";
+ }
+ h << " QObject *parent = nullptr";
+ }
h << " );" << endl;
} else {
h << " static " << cfg.className << " *self();" << endl;
@@ -2125,6 +2133,12 @@ int main(int argc, char **argv)
if (cfgFileNameArg) {
h << "KSharedConfig::Ptr config";
}
+ if (cfg.parentInConstructor) {
+ if (cfgFileNameArg) {
+ h << ", ";
+ }
+ h << "QObject *parent = nullptr";
+ }
h << ");" << endl;
h << " friend class " << cfg.className << "Helper;" << endl << endl;
}
@@ -2357,14 +2371,14 @@ int main(int argc, char **argv)
}
// Constructor
- cpp << cfg.className << "::" << cfg.className << "( ";
+ cpp << cfg.className << "::" << cfg.className << "(";
if (cfgFileNameArg) {
if (! cfg.forceStringFilename) {
cpp << " KSharedConfig::Ptr config";
} else {
cpp << " const QString& config";
}
- cpp << (parameters.isEmpty() ? " " : ", ");
+ cpp << (parameters.isEmpty() ? "" : ",");
}
for (QList<Param>::ConstIterator it = parameters.constBegin();
@@ -2374,6 +2388,13 @@ int main(int argc, char **argv)
}
cpp << " " << param((*it).type) << " " << (*it).name;
}
+
+ if (cfg.parentInConstructor) {
+ if (cfgFileNameArg || !parameters.isEmpty()) {
+ cpp << ",";
+ }
+ cpp << " QObject *parent";
+ }
cpp << " )" << endl;
cpp << " : " << cfg.inherits << "(";
@@ -2400,6 +2421,10 @@ int main(int argc, char **argv)
cpp << "{" << endl;
+ if (cfg.parentInConstructor) {
+ cpp << " setParent(parent);" << endl;
+ }
+
if (cfg.dpointer) {
cpp << " d = new " + cfg.className + "Private;" << endl;
if (hasNonModifySignals) {