Jump to: navigation, search

Information about the group Translation of the wiki page Policies/Kdelibs Coding Style.
Policies/Kdelibs Coding StyleCurrent message text
...ding Style/Page display title/csPolicies/Kdelibs Coding Style
...licies/Kdelibs Coding Style/1/csThis document describes the recommended coding style for kdelibs. Nobody is forced to use this style, but to have consistent formatting of the source code files it is recommended to make use of it.
...licies/Kdelibs Coding Style/2/cs'''In short: Kdelibs coding style follows the [ Qt 4 coding style], with one main difference: using curly braces even when the body of a conditional statement contains only one line.'''
...licies/Kdelibs Coding Style/3/cs== Odsazení ==
* Bez tabulátorů
* 4 mezery namísto jednoho tabulátoru
...licies/Kdelibs Coding Style/4/cs== Variable declaration ==
* Each variable declaration on a new line
* Each new word in a variable name starts with a capital letter (so-called camelCase)
* Avoid abbreviations
* Take useful names. No short names, except:
** Single character variable names can denote counters and temporary variables whose purpose is obvious
* Variables and functions start with a lowercase letter
...licies/Kdelibs Coding Style/5/csPříklad:
...licies/Kdelibs Coding Style/6/cs// špatně
...licies/Kdelibs Coding Style/7/cs// správně
...licies/Kdelibs Coding Style/8/cs== Whitespace ==
* Use blank lines to group statements
* Use only one empty line
* Use one space after each keyword
* For pointers or references, use a single space before '*' or '&', but not after
* No space after a cast
...licies/Kdelibs Coding Style/9/csPříklad:
...icies/Kdelibs Coding Style/10/cs// špatně
...icies/Kdelibs Coding Style/11/cs// správně
...icies/Kdelibs Coding Style/12/cs== Braces ==
As a base rule, the left curly brace goes on the same line as the start of the statement.
...icies/Kdelibs Coding Style/13/csPříklad:
...icies/Kdelibs Coding Style/14/cs// špatně
...icies/Kdelibs Coding Style/15/cs// správně
...icies/Kdelibs Coding Style/16/csException: Function implementations, class, struct and namespace declarations always have the opening brace on the start of a line.
...icies/Kdelibs Coding Style/17/csPříklad:
...icies/Kdelibs Coding Style/18/csUse curly braces even when the body of a conditional statement contains only one line.
...icies/Kdelibs Coding Style/19/csPříklad:
...icies/Kdelibs Coding Style/20/cs// špatně
...icies/Kdelibs Coding Style/21/cs// správně
...icies/Kdelibs Coding Style/22/cs== Switch statements ==
Case labels are on the same column as the switch
...icies/Kdelibs Coding Style/23/csExample:
...icies/Kdelibs Coding Style/24/cs== Line breaks ==
Try to keep lines shorter than 100 characters, inserting line breaks as necessary.
...icies/Kdelibs Coding Style/25/cs== Qt Includes ==
* If you add #includes for Qt classes, use both the module and class name.  This allows library code to be used by applications without excessive compiler include paths.
...icies/Kdelibs Coding Style/26/csPříklad:
...icies/Kdelibs Coding Style/27/cs// špatně
...icies/Kdelibs Coding Style/28/cs// správně
...icies/Kdelibs Coding Style/29/cs== Artistic Style (astyle) automatic code formatting ==
You can use [ astyle] (>=1.23) to format code or to test if you have followed this document. Run the following command:
...icies/Kdelibs Coding Style/30/csPři použití astyle (>=2.01) musíte spustit následující příkaz:
...icies/Kdelibs Coding Style/31/csYou can find a shell script to run this command in:
...icies/Kdelibs Coding Style/40/cs* [ kde-dev-scripts/astyle-kdelibs] (POSIX)
* [ kde-dev-scripts/astyle-kdelibs.bat] (Windows)
...icies/Kdelibs Coding Style/32/cs== Emacs and Vim scripts ==
The [ kde-dev-scripts] directory in the kdesdk module contains, among other useful things, some useful additions to the Emacs and Vim text editors that make it easier to edit KDE code with them.
=== Emacs ===
The [ kde-emacs] directory contains a set of key bindings, macros and general useful code. It is compatible with both GNU Emacs and XEmacs.
...icies/Kdelibs Coding Style/33/csTo start using kde-emacs, add the following to your .emacs:
...icies/Kdelibs Coding Style/34/csMany settings can be changed by editing the "kde-emacs" group via <tt>M-x customize-group</tt>.
...icies/Kdelibs Coding Style/35/csFor more information, including what the key bindings are and what additional settings you could add to your .emacs, please check <tt>kde-emacs.el</tt> itself.
...icies/Kdelibs Coding Style/36/cs=== Vim ===
You can find a vim script in [ kde-devel-vim.vim] that helps you to keep the coding style correct. In addition to defaulting to the kdelibs coding style it will automatically use the correct style for Solid and kdepim code. If you want to add rules for other projects feel free to add them in the SetCodingStyle function.
...icies/Kdelibs Coding Style/37/csTo use the script, include it in your {{path|~/.vimrc}} like this:
...icies/Kdelibs Coding Style/38/csDocument started by Urs Wolfer. Some parts of this document have been adopted from the Qt Coding Style document posted by Zack Rusin on kde-core-devel.
...icies/Kdelibs Coding Style/39/cs[[Category:Policies]] [[Category:C++]]
NavigationShowing 41 messages.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal