diff options
Diffstat (limited to 'src/HACKING')
-rw-r--r-- | src/HACKING | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/HACKING b/src/HACKING new file mode 100644 index 0000000..599dd3b --- /dev/null +++ b/src/HACKING @@ -0,0 +1,95 @@ +This file describes the coding conventions used in Gwenview. + + +Naming +------ + +Classes should be named like this: MyClass. The class MyClass should be defined +in the myclass.h file and implemented in myclass.cpp. + +Variables and functions should be named like this: myVariable. Static and +member variables are identified by a prefix (s or m), without underscore. + +int sStaticVariable. + +class MyClass { + int mMemberVariable; + + void doSomething() { + int localVariable; + } +}; + + +Enum items and consts are spelled like this: + +const int MY_CONST_VALUE=120; +enum AnEnum { ITEM1, ITEM2, ITEM3 }; + + +Namespace +--------- + +All code should be enclosed in the "Gwenview" namespace. Make sure the closing +curly bracket of the namespace looks like this : + +} // namespace + +This avoids wondering why the curly bracket is here. + + +Code layout +----------- + +Use tabs, not spaces. + +The opening brace follows the function/class/for/while. Insert a space after +commas and after for/while keywords. + +void myFunction() { + int v1; + int v2=12; + for (v1=0; v1<10; ++v1) { + doSomething(v1, v2); + } +} + +class MyClass { +}; + + +If the if content is only one line long, you can place it on the same line and +omit the curly braces, but DO NOT omit them if you place the content after the +if. + +// Ok +if (!data) { + return; +} + +// Ok too +if (!data) return; + +// Bad +if (!data) + return; + + +Include files +------------- + +Group include files in the Qt, KDE or local groups and sort them +alphabetically. When writing the implementation file of a class which is a +Q_OBJECT, make sure you include the .moc file, not the .h. + +// Qt +#include <qobject.h> +#include <qwidget.h> + +// KDE +#include <kiconview.h> +#include <klistview.h> + +// Local +#include "aclass.h" +#include "myclass.moc" |