Code Conventions
From PsiWiki
These are some conventions that should be taken into account when writing patches. Note that because of historical reasons, you might find code in Psi that does not comply to these standards.
- Use tabs (not spaces)
- Use foreach
- For emitting signals, use emit foo() and not foo()
- Use #include <QClass> (instead of #include <qclass.h>)
- Separate classes into separate files
- Document every method and class in the .cpp using DoxyGen. Look at growlnotifier.cpp for an example on how to do this. (a cheat sheet of the usable syntax is available on http://www.digilife.be/quickreferences/quickrefs.htm
For other conventions see Coding Tips and look at the source
- The opening braces of scopes should not live on their own line. e.g. int getInt() { and not int getInt()\n{
- The closing braces of scopes should live on their own line, left aligned with the line opening the block, except when followed by 'else' or in a do {\n} while
- For drop down boxes, and similar UI elements where code matches the selection by a translatable string, the string should be either in the .ui file or in the class that uses the .ui file but not in both. If they are in both, the ui file and the class MUST have the same name. (This is needed to be robust when translated)