Changeset View
Changeset View
Standalone View
Standalone View
plugins/filetemplates/templateoptionspage.cpp
Show All 35 Lines | |||||
36 | using namespace KDevelop; | 36 | using namespace KDevelop; | ||
37 | 37 | | |||
38 | class KDevelop::TemplateOptionsPagePrivate | 38 | class KDevelop::TemplateOptionsPagePrivate | ||
39 | { | 39 | { | ||
40 | public: | 40 | public: | ||
41 | QList<SourceFileTemplate::ConfigOption> entries; | 41 | QList<SourceFileTemplate::ConfigOption> entries; | ||
42 | QHash<QString, QWidget*> controls; | 42 | QHash<QString, QWidget*> controls; | ||
43 | QHash<QString, QByteArray> typeProperties; | 43 | QHash<QString, QByteArray> typeProperties; | ||
44 | QList<QWidget*> groupBoxes; | ||||
44 | }; | 45 | }; | ||
45 | 46 | | |||
46 | TemplateOptionsPage::TemplateOptionsPage(QWidget* parent, Qt::WindowFlags f) | 47 | TemplateOptionsPage::TemplateOptionsPage(QWidget* parent, Qt::WindowFlags f) | ||
47 | : QWidget(parent, f) | 48 | : QWidget(parent, f) | ||
48 | , d(new TemplateOptionsPagePrivate) | 49 | , d(new TemplateOptionsPagePrivate) | ||
49 | { | 50 | { | ||
50 | d->typeProperties.insert(QStringLiteral("String"), "text"); | 51 | d->typeProperties.insert(QStringLiteral("String"), "text"); | ||
51 | d->typeProperties.insert(QStringLiteral("Int"), "value"); | 52 | d->typeProperties.insert(QStringLiteral("Int"), "value"); | ||
52 | d->typeProperties.insert(QStringLiteral("Bool"), "checked"); | 53 | d->typeProperties.insert(QStringLiteral("Bool"), "checked"); | ||
53 | } | 54 | } | ||
54 | 55 | | |||
55 | TemplateOptionsPage::~TemplateOptionsPage() | 56 | TemplateOptionsPage::~TemplateOptionsPage() | ||
56 | { | 57 | { | ||
57 | delete d; | 58 | delete d; | ||
58 | } | 59 | } | ||
59 | 60 | | |||
60 | void TemplateOptionsPage::load(const SourceFileTemplate& fileTemplate, TemplateRenderer* renderer) | 61 | void TemplateOptionsPage::load(const SourceFileTemplate& fileTemplate, TemplateRenderer* renderer) | ||
61 | { | 62 | { | ||
63 | // TODO: keep any old changed values, as it comes by surprise to have them lost | ||||
64 | // when going back and forward | ||||
65 | | ||||
66 | // clear anything as there is on reentering the page | ||||
62 | d->entries.clear(); | 67 | d->entries.clear(); | ||
68 | d->controls.clear(); | ||||
69 | // clear any old option group boxes & the base layout | ||||
70 | qDeleteAll(d->groupBoxes); | ||||
71 | d->groupBoxes.clear(); | ||||
72 | delete layout(); | ||||
63 | 73 | | |||
64 | QVBoxLayout* layout = new QVBoxLayout(); | 74 | QVBoxLayout* layout = new QVBoxLayout(); | ||
65 | QHash<QString, QList<SourceFileTemplate::ConfigOption> > options = fileTemplate.customOptions(renderer); | 75 | QHash<QString, QList<SourceFileTemplate::ConfigOption> > options = fileTemplate.customOptions(renderer); | ||
66 | QHash<QString, QList<SourceFileTemplate::ConfigOption> >::const_iterator it; | 76 | QHash<QString, QList<SourceFileTemplate::ConfigOption> >::const_iterator it; | ||
67 | 77 | | |||
68 | for (it = options.constBegin(); it != options.constEnd(); ++it) | 78 | for (it = options.constBegin(); it != options.constEnd(); ++it) | ||
69 | { | 79 | { | ||
70 | QGroupBox* box = new QGroupBox(this); | 80 | QGroupBox* box = new QGroupBox(this); | ||
81 | d->groupBoxes.append(box); | ||||
82 | | ||||
71 | box->setTitle(it.key()); | 83 | box->setTitle(it.key()); | ||
72 | 84 | | |||
73 | QFormLayout* formLayout = new QFormLayout; | 85 | QFormLayout* formLayout = new QFormLayout; | ||
74 | 86 | | |||
75 | d->entries << it.value(); | 87 | d->entries << it.value(); | ||
76 | foreach (const SourceFileTemplate::ConfigOption& entry, it.value()) | 88 | foreach (const SourceFileTemplate::ConfigOption& entry, it.value()) | ||
77 | { | 89 | { | ||
78 | QWidget* control = nullptr; | 90 | QWidget* control = nullptr; | ||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |