MCPcopy Create free account
hub / github.com/KDE/kdevelop / readEntry

Method readEntry

kdevplatform/language/codegen/sourcefiletemplate.cpp:37–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35};
36
37ConfigOption SourceFileTemplatePrivate::readEntry(const QDomElement& element,
38 TemplateRenderer* renderer) const
39{
40 ConfigOption entry;
41
42 entry.name = element.attribute(QStringLiteral("name"));
43 entry.type = element.attribute(QStringLiteral("type"), QStringLiteral("String"));
44
45 bool isDefaultValueSet = false;
46 for (QDomElement e = element.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
47 QString tag = e.tagName();
48
49 if (tag == QLatin1String("label")) {
50 entry.label = e.text();
51 } else if (tag == QLatin1String("tooltip")) {
52 if (entry.label.isEmpty()) {
53 entry.label = e.text();
54 }
55 entry.context = e.text();
56 } else if (tag == QLatin1String("whatsthis")) {
57 if (entry.label.isEmpty()) {
58 entry.label = e.text();
59 }
60 if (entry.context.isEmpty()) {
61 entry.context = e.text();
62 }
63 } else if (tag == QLatin1String("min")) {
64 entry.minValue = e.text();
65 } else if (tag == QLatin1String("max")) {
66 entry.maxValue = e.text();
67 } else if (tag == QLatin1String("default")) {
68 entry.value = renderer->render(e.text(), entry.name);
69 isDefaultValueSet = true;
70 } else if (tag == QLatin1String("choices")) {
71 QStringList values;
72 QDomNodeList choices = element.elementsByTagName(QStringLiteral("choice"));
73 values.reserve(choices.size());
74 for (int j = 0; j < choices.size(); ++j) {
75 QDomElement choiceElement = choices.at(j).toElement();
76 values << choiceElement.attribute(QStringLiteral("name"));
77 }
78
79 Q_ASSERT(!values.isEmpty());
80 if (values.isEmpty()) {
81 qCWarning(LANGUAGE) << "Entry " << entry.name << "has an enum without any choices";
82 }
83 entry.values = values;
84 }
85 }
86
87 qCDebug(LANGUAGE) << "Read entry" << entry.name << "with default value" << entry.value;
88
89 // preset value for enum if needed
90 if (!entry.values.isEmpty()) {
91 if (isDefaultValueSet) {
92 const bool isSaneDefaultValue = entry.values.contains(entry.value.toString());
93 Q_ASSERT(isSaneDefaultValue);
94 if (!isSaneDefaultValue) {

Callers 15

loadMethod · 0.80
BreakpointMethod · 0.80
VariableWidgetMethod · 0.80
rebaseMatchingUrlFunction · 0.80
loadFromConfigurationMethod · 0.80
loadSettingsMethod · 0.80
projectOverridesSessionFunction · 0.80
populateStyleFromConfigFunction · 0.80
addModelineMethod · 0.80
ProjectSourcePageMethod · 0.80

Calls 10

attributeMethod · 0.80
isNullMethod · 0.80
renderMethod · 0.80
textMethod · 0.45
isEmptyMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
containsMethod · 0.45
toStringMethod · 0.45

Tested by 11

verifySessionDirFunction · 0.64
cloneSessionMethod · 0.64
readFromConfigMethod · 0.64
loadPluginMethod · 0.64
PluginMethod · 0.64
runClangTidyMethod · 0.64
PluginMethod · 0.64
runClangTidyMethod · 0.64
createTestJobFunction · 0.64