Changeset View
Changeset View
Standalone View
Standalone View
src/kconfig_compiler/KConfigSourceGenerator.cpp
Show First 20 Lines • Show All 307 Lines • ▼ Show 20 Line(s) | 288 | for (const auto &choice : qAsConst(entry->choices.choices)) { | |||
---|---|---|---|---|---|
308 | } | 308 | } | ||
309 | stream() << " values" << entry->name << ".append( choice );\n"; | 309 | stream() << " values" << entry->name << ".append( choice );\n"; | ||
310 | stream() << " }\n"; | 310 | stream() << " }\n"; | ||
311 | } | 311 | } | ||
312 | } | 312 | } | ||
313 | 313 | | |||
314 | void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QString &key) | 314 | void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QString &key) | ||
315 | { | 315 | { | ||
316 | stream() << " " << itemPath(entry, cfg()) << " = " | 316 | const QString itemVarStr = itemPath(entry, cfg()); | ||
317 | stream() << " " << itemVarStr << " = " | ||||
317 | << newItem(entry, key, entry->defaultValue, cfg()) << '\n'; | 318 | << newItem(entry, key, entry->defaultValue, cfg()) << '\n'; | ||
318 | 319 | | |||
319 | if (!entry->min.isEmpty()) { | 320 | if (!entry->min.isEmpty()) { | ||
320 | stream() << " " << itemPath(entry, cfg()) << "->setMinValue(" << entry->min << ");\n"; | 321 | stream() << " " << itemVarStr << "->setMinValue(" << entry->min << ");\n"; | ||
321 | } | 322 | } | ||
322 | if (!entry->max.isEmpty()) { | 323 | if (!entry->max.isEmpty()) { | ||
323 | stream() << " " << itemPath(entry, cfg()) << "->setMaxValue(" << entry->max << ");\n"; | 324 | stream() << " " << itemVarStr << "->setMaxValue(" << entry->max << ");\n"; | ||
324 | } | 325 | } | ||
325 | 326 | | |||
326 | if (cfg().setUserTexts) { | 327 | if (cfg().setUserTexts) { | ||
327 | stream() << userTextsFunctions(entry, cfg()); | 328 | stream() << userTextsFunctions(entry, cfg()); | ||
328 | } | 329 | } | ||
329 | 330 | | |||
330 | if (cfg().allNotifiers || cfg().notifiers.contains(entry->name)) { | 331 | if (cfg().allNotifiers || cfg().notifiers.contains(entry->name)) { | ||
331 | stream() << " " << itemPath(entry, cfg()) << "->setWriteFlags(KConfigBase::Notify);\n"; | 332 | stream() << " " << itemVarStr << "->setWriteFlags(KConfigBase::Notify);\n"; | ||
333 | } | ||||
334 | | ||||
335 | for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) { | ||||
336 | if (!choice.val.isEmpty()) { | ||||
337 | stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; | ||||
338 | } | ||||
332 | } | 339 | } | ||
333 | 340 | | |||
334 | stream() << " addItem( " << itemPath(entry, cfg()); | 341 | stream() << " addItem( " << itemVarStr; | ||
335 | QString quotedName = entry->name; | 342 | QString quotedName = entry->name; | ||
336 | addQuotes(quotedName); | 343 | addQuotes(quotedName); | ||
337 | if (quotedName != key) { | 344 | if (quotedName != key) { | ||
338 | stream() << ", QStringLiteral( \"" << entry->name << "\" )"; | 345 | stream() << ", QStringLiteral( \"" << entry->name << "\" )"; | ||
339 | } | 346 | } | ||
340 | stream() << " );\n"; | 347 | stream() << " );\n"; | ||
341 | } | 348 | } | ||
342 | 349 | | |||
343 | void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QString &key) | 350 | void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QString &key) | ||
344 | { | 351 | { | ||
345 | for (int i = 0; i <= entry->paramMax; i++) { | 352 | for (int i = 0; i <= entry->paramMax; i++) { | ||
346 | QString itemVarStr(itemPath(entry, cfg()) + QStringLiteral("[%1]").arg(i)); | 353 | QString itemVarStr(itemPath(entry, cfg()) + QStringLiteral("[%1]").arg(i)); | ||
347 | 354 | | |||
348 | QString defaultStr = !entry->paramDefaultValues[i].isEmpty() ? entry->paramDefaultValues[i] | 355 | QString defaultStr = !entry->paramDefaultValues[i].isEmpty() ? entry->paramDefaultValues[i] | ||
349 | : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i) | 356 | : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i) | ||
350 | : defaultValue(entry->type); | 357 | : defaultValue(entry->type); | ||
351 | 358 | | |||
352 | stream() << " " << itemVarStr << " = " | 359 | stream() << " " << itemVarStr << " = " | ||
353 | << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), QStringLiteral("[%1]").arg(i)) << '\n'; | 360 | << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), QStringLiteral("[%1]").arg(i)) << '\n'; | ||
354 | 361 | | |||
362 | for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) { | ||||
363 | if (!choice.val.isEmpty()) { | ||||
364 | stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; | ||||
365 | } | ||||
366 | } | ||||
367 | | ||||
355 | if (cfg().setUserTexts) { | 368 | if (cfg().setUserTexts) { | ||
356 | stream() << userTextsFunctions(entry, cfg(), itemVarStr, entry->paramName); | 369 | stream() << userTextsFunctions(entry, cfg(), itemVarStr, entry->paramName); | ||
357 | } | 370 | } | ||
358 | 371 | | |||
359 | // Make mutators for enum parameters work by adding them with $(..) replaced by the | 372 | // Make mutators for enum parameters work by adding them with $(..) replaced by the | ||
360 | // param name. The check for isImmutable in the set* functions doesn't have the param | 373 | // param name. The check for isImmutable in the set* functions doesn't have the param | ||
361 | // name available, just the corresponding enum value (int), so we need to store the | 374 | // name available, just the corresponding enum value (int), so we need to store the | ||
362 | // param names in a separate static list!. | 375 | // param names in a separate static list!. | ||
▲ Show 20 Lines • Show All 310 Lines • Show Last 20 Lines |