diff options
-rw-r--r-- | autotests/kconfig_compiler/test1.cpp.ref | 2 | ||||
-rw-r--r-- | src/kconfig_compiler/kconfig_compiler.cpp | 19 |
2 files changed, 16 insertions, 5 deletions
diff --git a/autotests/kconfig_compiler/test1.cpp.ref b/autotests/kconfig_compiler/test1.cpp.ref index c0d94eef..16b1833b 100644 --- a/autotests/kconfig_compiler/test1.cpp.ref +++ b/autotests/kconfig_compiler/test1.cpp.ref @@ -63,7 +63,7 @@ Test1::Test1( const QString & transport, const QString & folder, QObject *parent itemMyStringListHidden = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "MyStringListHidden" ), mMyStringListHidden, defaultMyStringListHidden ); addItem( itemMyStringListHidden, QStringLiteral( "MyStringListHidden" ) ); KConfigSkeleton::ItemInt *itemMyNumber; - itemMyNumber = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "List-%1-%2" ).arg( mParamtransport ).arg( mParamfolder ), mMyNumber, 1 ); + itemMyNumber = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "List-%1-%2" ).arg( mParamtransport, mParamfolder ), mMyNumber, 1 ); addItem( itemMyNumber, QStringLiteral( "MyNumber" ) ); } diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 50c54f8f..d278414e 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -490,19 +490,30 @@ QString paramString(const QString &group, const QList<Param> ¶meters) QString paramString = group; QString arguments; int i = 1; + bool firstArg = true; for (const auto ¶m : parameters) { const QString paramName = param.name; const QString str = QLatin1String{"$("} + paramName + QLatin1Char{')'}; if (paramString.contains(str)) { const QString tmp = QStringLiteral("%%1").arg(i++); paramString.replace(str, tmp); - // TODO: change the code here to get C++ code generated by KConfig to use - // QString::arg(QString, QString, QString) instead of QString().arg().arg() - arguments += QLatin1String{".arg( mParam"} + paramName + QLatin1String{" )"}; + + if (firstArg) { + arguments += QLatin1String{".arg( "}; + firstArg = false; + } + + arguments += QLatin1String{"mParam"} + paramName + QLatin1String{", "}; } } - if (arguments.isEmpty()) { + if (!arguments.isEmpty()) { + // Remove the last ", " + arguments.chop(2); + + // Close the ".arg( " + arguments += QLatin1String{" )"}; + } else { return QLatin1String{"QStringLiteral( \""} + group + QLatin1String{"\" )"}; } |