Contents |
| Under Construction |
|---|
| This is a new page, currently under construction! |
The Code Generation plugin files are located into the KDE user data directory of KDevelop.
Each resource has its own folder :
As Code Generation plugin is very flexible, you do not need to create templates, contexts and generators for simple tasks.
You can edit a template to modify generated source code using the same contexts. If provided data are not enough, modify the context and use your new variables in your template or simply add existing contexts.
The first step is to create a new widget with Qt Designer.
| Information |
|---|
| Do not add usual dialog buttons ("Finish", "Cancel", etc.). Your widget will be inserted into a standard wizard. |
Then add a new dynamic property called contextName. Set up the value with the name of your context.
| Tip |
|---|
| Try to find an unique context name to avoid conflicts. |
It's time to define your data. Add many fields into your form. Use layouts, labels and others setup tools to make your own dialog. They will do not produce any data.
Take care of the fields names. They will be used to generate variables in the template.
Like previously mentionned, each kind of form field will produce a different data type:
All variables names wil be prefixed by the context name : MyCppClassContext.name, MyCppClassContext.baseClasses, etc.
Now, you can save your context in an UI file named <contextName>.ui:
Create a simple text file <templateName>.tpl:
Use data you have defined into your context :
#ifndef {{ MyCppClassContext.name }}#define {{ MyCppClassContext.name }} class {{ MyCppClassContext.name }} : {% for %}{% endfor %}{}#endif // {{ MyCppClassContext.name }}
The KDevelop4/Plugins:_Code_Generation page on Techbase.