Changeset View
Changeset View
Standalone View
Standalone View
doc/kdevelop/index.docbook
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | |||||
115 | <para>Alternatively, if the project you want to work with already exists on your hard drive (for example, because you have downloaded it as a tar file from an FTP server, because you already checked out a version of the project from a version control system, or because it is your own project that exists <emphasis>only</emphasis> on your own hard drive), then use <menuchoice><guimenu>Projects</guimenu><guimenuitem>Open/Import project</guimenuitem></menuchoice> and in the dialog box choose the directory in which your project resides.</para> | 115 | <para>Alternatively, if the project you want to work with already exists on your hard drive (for example, because you have downloaded it as a tar file from an FTP server, because you already checked out a version of the project from a version control system, or because it is your own project that exists <emphasis>only</emphasis> on your own hard drive), then use <menuchoice><guimenu>Projects</guimenu><guimenuitem>Open/Import project</guimenuitem></menuchoice> and in the dialog box choose the directory in which your project resides.</para> | ||
116 | </sect2> | 116 | </sect2> | ||
117 | </sect1> | 117 | </sect1> | ||
118 | <sect1 id="setting-up-an-application-as-a-second-project"><title>Setting up an application as a second project</title> | 118 | <sect1 id="setting-up-an-application-as-a-second-project"><title>Setting up an application as a second project</title> | ||
119 | <para>The next thing you want to do is set up other projects in the same session. In the example above, you would want to add the device driver as the second project, which you can do using exactly the same steps.</para> | 119 | <para>The next thing you want to do is set up other projects in the same session. In the example above, you would want to add the device driver as the second project, which you can do using exactly the same steps.</para> | ||
120 | <para>If you have multiple applications or libraries, simply repeat the steps to add more and more projects to your session.</para> | 120 | <para>If you have multiple applications or libraries, simply repeat the steps to add more and more projects to your session.</para> | ||
121 | </sect1> | 121 | </sect1> | ||
122 | <sect1 id="creating-projects-from-scratch"><title>Creating projects from scratch</title> | 122 | <sect1 id="creating-projects-from-scratch"><title>Creating projects from scratch</title> | ||
123 | <para>There is of course also the possibility that you want to start a new project from scratch. This can be done using the <menuchoice><guimenu>Projects</guimenu><guimenuitem>New from Template</guimenuitem></menuchoice> menu item, which presents you with a template selection dialog. Some project templates are provided with &kdevelop;, but even more are available by installing the <application>KAppTemplate</application> application. Choose the project type and programming language from the dialog, enter a name and location for you project, and click <guilabel>Next</guilabel>. | 123 | <para>There is of course also the possibility that you want to start a new project from scratch. This can be done using the <menuchoice><guimenu>Projects</guimenu><guimenuitem>New from Template...</guimenuitem></menuchoice> menu item, which presents you with a template selection dialog. Some project templates are provided with &kdevelop;, but even more are available by installing the <application>KAppTemplate</application> application. Choose the project type and programming language from the dialog, enter a name and location for you project, and click <guilabel>Next</guilabel>. | ||
124 | </para> | 124 | </para> | ||
125 | <para> | 125 | <para> | ||
126 | <screenshot> | 126 | <screenshot> | ||
127 | <screeninfo></screeninfo> | 127 | <screeninfo></screeninfo> | ||
128 | <mediaobject> | 128 | <mediaobject> | ||
129 | <imageobject> | 129 | <imageobject> | ||
130 | <imagedata fileref="kdevelop-project-dialog.png" format="PNG"/> | 130 | <imagedata fileref="kdevelop-project-dialog.png" format="PNG"/> | ||
131 | </imageobject> | 131 | </imageobject> | ||
▲ Show 20 Lines • Show All 882 Lines • ▼ Show 20 Line(s) | |||||
1014 | </informaltable> | 1014 | </informaltable> | ||
1015 | </para> | 1015 | </para> | ||
1016 | </sect1> | 1016 | </sect1> | ||
1017 | </chapter> | 1017 | </chapter> | ||
1018 | <chapter id="code-generation-with-templates"><title>Code generation with templates</title> | 1018 | <chapter id="code-generation-with-templates"><title>Code generation with templates</title> | ||
1019 | <para>&kdevelop; uses templates for generating source code files and to avoid writing repeatable code. | 1019 | <para>&kdevelop; uses templates for generating source code files and to avoid writing repeatable code. | ||
1020 | </para> | 1020 | </para> | ||
1021 | <sect1 id="creating-a-new-class"><title>Creating a new class</title> | 1021 | <sect1 id="creating-a-new-class"><title>Creating a new class</title> | ||
1022 | <para>The most common use for code generation is probably writing new classes. To create a new class in an existing project, right click on a project folder and choose <guilabel>Create from Template</guilabel>. The same dialog can be started from the menu by clicking <menuchoice><guimenu>File</guimenu><guimenuitem>New from Template</guimenuitem></menuchoice>, but using a project folder has the benefit of setting a base URL for the output files. Choose <filename>Class</filename> in the category selection view, and the desired language and template in the other two views. After you have selected a class template, you will have to specify the details of the new class. | 1022 | <para>The most common use for code generation is probably writing new classes. To create a new class in an existing project, right click on a project folder and choose <guilabel>Create from Template...</guilabel>. The same dialog can be started from the menu by clicking <menuchoice><guimenu>File</guimenu><guimenuitem>New from Template...</guimenuitem></menuchoice>, but using a project folder has the benefit of setting a base URL for the output files. Choose <filename>Class</filename> in the category selection view, and the desired language and template in the other two views. After you have selected a class template, you will have to specify the details of the new class. | ||
1023 | </para> | 1023 | </para> | ||
1024 | <para> | 1024 | <para> | ||
1025 | <screenshot> | 1025 | <screenshot> | ||
1026 | <screeninfo></screeninfo> | 1026 | <screeninfo></screeninfo> | ||
1027 | <mediaobject> | 1027 | <mediaobject> | ||
1028 | <imageobject> | 1028 | <imageobject> | ||
1029 | <imagedata fileref="kdevelop-template-selection.png" format="PNG"/> | 1029 | <imagedata fileref="kdevelop-template-selection.png" format="PNG"/> | ||
1030 | </imageobject> | 1030 | </imageobject> | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 1078 | <mediaobject> | |||
1084 | </textobject> | 1084 | </textobject> | ||
1085 | </mediaobject> | 1085 | </mediaobject> | ||
1086 | </screenshot> | 1086 | </screenshot> | ||
1087 | </para> | 1087 | </para> | ||
1088 | <para>You can see that data members are converted into Qt properties, with accessor functions and the Q_PROPERTY macros. Arguments to setter functions are even passed by const-reference, where appropriate. Additionally, a private class is declared, and a private pointer created with Q_DECLARE_PRIVATE. All this is done by the template, choosing a different template in the first step could completely change the output. | 1088 | <para>You can see that data members are converted into Qt properties, with accessor functions and the Q_PROPERTY macros. Arguments to setter functions are even passed by const-reference, where appropriate. Additionally, a private class is declared, and a private pointer created with Q_DECLARE_PRIVATE. All this is done by the template, choosing a different template in the first step could completely change the output. | ||
1089 | </para> | 1089 | </para> | ||
1090 | </sect1> | 1090 | </sect1> | ||
1091 | <sect1 id="creating-a-new-unit-test"><title>Creating a new unit test</title> | 1091 | <sect1 id="creating-a-new-unit-test"><title>Creating a new unit test</title> | ||
1092 | <para>Even though most testing frameworks require each test to also be a class, &kdevelop; includes a method to simplify the creation of unit tests. To create a new test, right click on a project folder and choose <guilabel>Create from Template</guilabel>. In the template selection page, choose <filename>Test</filename> as the category, then choose your programming language and template and click <guilabel>Next</guilabel>. | 1092 | <para>Even though most testing frameworks require each test to also be a class, &kdevelop; includes a method to simplify the creation of unit tests. To create a new test, right click on a project folder and choose <guilabel>Create from Template...</guilabel>. In the template selection page, choose <filename>Test</filename> as the category, then choose your programming language and template and click <guilabel>Next</guilabel>. | ||
1093 | </para> | 1093 | </para> | ||
1094 | <para>You will be prompted for the test name and a list of test cases. For the test cases, you only have to specify a list of names. Some unit testing frameworks, such as PyUnit and PHPUnit, require that test cases start with a special prefix. In &kdevelop;, the template is responsible for adding the prefix, so you do not have to prefix the test cases here. After clicking <guilabel>Next</guilabel>, specify the license and output locations for the generated files, and the test will be created. | 1094 | <para>You will be prompted for the test name and a list of test cases. For the test cases, you only have to specify a list of names. Some unit testing frameworks, such as PyUnit and PHPUnit, require that test cases start with a special prefix. In &kdevelop;, the template is responsible for adding the prefix, so you do not have to prefix the test cases here. After clicking <guilabel>Next</guilabel>, specify the license and output locations for the generated files, and the test will be created. | ||
1095 | </para> | 1095 | </para> | ||
1096 | <para>Unit tests created this way will not be added to any target automatically. If you are using CTest or some other testing framework, make sure to add the new files to a target. | 1096 | <para>Unit tests created this way will not be added to any target automatically. If you are using CTest or some other testing framework, make sure to add the new files to a target. | ||
1097 | </para> | 1097 | </para> | ||
1098 | </sect1> | 1098 | </sect1> | ||
1099 | <sect1 id="other-files"><title>Other files</title> | 1099 | <sect1 id="other-files"><title>Other files</title> | ||
1100 | <para>While classes and unit tests receive special attention when generating code from templates, the same method can be used for any kind of source code files. For example, one could use a template for a CMake Find module or a .desktop file. This can be done by choosing <guilabel>Create from Template</guilabel>, and selecting the wanted category and template. If the selected category is neither <filename>Class</filename> nor <filename>Test</filename>, you will only have the option of choosing the license, any custom options specified by the template, and the output file locations. As with classes and tests, finishing the assistant will generate the files and open them in the editor. | 1100 | <para>While classes and unit tests receive special attention when generating code from templates, the same method can be used for any kind of source code files. For example, one could use a template for a CMake Find module or a .desktop file. This can be done by choosing <guilabel>Create from Template...</guilabel>, and selecting the wanted category and template. If the selected category is neither <filename>Class</filename> nor <filename>Test</filename>, you will only have the option of choosing the license, any custom options specified by the template, and the output file locations. As with classes and tests, finishing the assistant will generate the files and open them in the editor. | ||
1101 | </para> | 1101 | </para> | ||
1102 | </sect1> | 1102 | </sect1> | ||
1103 | <sect1 id="managing-templates"><title>Managing templates</title> | 1103 | <sect1 id="managing-templates"><title>Managing templates</title> | ||
1104 | <para>From the <menuchoice><guimenu>File</guimenu><guimenuitem>New from Template</guimenuitem></menuchoice> assistant, you can also download additional file templates by clicking the <guilabel>Get more Templates...</guilabel> button. This opens a Get Hot New Stuff dialog, where you can install additional templates, as well as update or remove them. There is also a configuration module for templates, which can be reached by clicking <menuchoice><guimenu>Settings</guimenu><guisubmenu>Configure &kdevelop;</guisubmenu><guimenuitem>Templates</guimenuitem></menuchoice>. From there, you can manage both file templates (explained above) and project templates (used for creating new projects). | 1104 | <para>From the <menuchoice><guimenu>File</guimenu><guimenuitem>New from Template...</guimenuitem></menuchoice> assistant, you can also download additional file templates by clicking the <guilabel>Get more Templates...</guilabel> button. This opens a Get Hot New Stuff dialog, where you can install additional templates, as well as update or remove them. There is also a configuration module for templates, which can be reached by clicking <menuchoice><guimenu>Settings</guimenu><guisubmenu>Configure &kdevelop;</guisubmenu><guimenuitem>Templates</guimenuitem></menuchoice>. From there, you can manage both file templates (explained above) and project templates (used for creating new projects). | ||
1105 | </para> | 1105 | </para> | ||
1106 | <para> | 1106 | <para> | ||
1107 | <screenshot> | 1107 | <screenshot> | ||
1108 | <screeninfo></screeninfo> | 1108 | <screeninfo></screeninfo> | ||
1109 | <mediaobject> | 1109 | <mediaobject> | ||
1110 | <imageobject> | 1110 | <imageobject> | ||
1111 | <imagedata fileref="kdevelop-template-manager.png" format="PNG"/> | 1111 | <imagedata fileref="kdevelop-template-manager.png" format="PNG"/> | ||
1112 | </imageobject> | 1112 | </imageobject> | ||
▲ Show 20 Lines • Show All 407 Lines • Show Last 20 Lines |