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

Method load

plugins/filetemplates/templateoptionspage.cpp:54–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54void TemplateOptionsPage::load(const SourceFileTemplate& fileTemplate, TemplateRenderer* renderer)
55{
56 // TODO: keep any old changed values, as it comes by surprise to have them lost
57 // when going back and forward
58
59 // clear anything as there is on reentering the page
60 d->entries.clear();
61 d->controls.clear();
62 // clear any old option group boxes & the base layout
63 d->firstEditWidget = nullptr;
64 qDeleteAll(d->groupBoxes);
65 d->groupBoxes.clear();
66 delete layout();
67
68 auto* layout = new QVBoxLayout();
69 layout->setContentsMargins(0, 0, 0, 0);
70
71 const auto customOptions = fileTemplate.customOptions(renderer);
72 d->groupBoxes.reserve(customOptions.size());
73 d->entries.reserve(customOptions.size());
74 for (const auto& optionGroup : customOptions) {
75 auto* box = new QGroupBox(this);
76 d->groupBoxes.append(box);
77
78 box->setTitle(optionGroup.name);
79
80 auto* formLayout = new QFormLayout;
81
82 d->entries << optionGroup.options;
83 for (const auto& entry : optionGroup.options) {
84 QWidget* control = nullptr;
85 const QString type = entry.type;
86 if (type == QLatin1String("String"))
87 {
88 control = new QLineEdit(entry.value.toString(), box);
89 }
90 else if (type == QLatin1String("Enum"))
91 {
92 auto input = new QComboBox(box);
93 input->addItems(entry.values);
94 input->setCurrentText(entry.value.toString());
95 control = input;
96 }
97 else if (type == QLatin1String("Int"))
98 {
99 auto input = new QSpinBox(box);
100 input->setValue(entry.value.toInt());
101 if (!entry.minValue.isEmpty())
102 {
103 input->setMinimum(entry.minValue.toInt());
104 }
105 if (!entry.maxValue.isEmpty())
106 {
107 input->setMaximum(entry.maxValue.toInt());
108 }
109 control = input;
110 }
111 else if (type == QLatin1String("Bool"))

Callers 1

nextMethod · 0.45

Calls 14

toIntMethod · 0.80
setToolTipMethod · 0.80
clearMethod · 0.45
customOptionsMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45
setTitleMethod · 0.45
toStringMethod · 0.45
addItemsMethod · 0.45
setValueMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected