blob: 79604a162c5597f6a134900a63ba92f3a62a8d8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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 TQt, KDE or local groups and sort them
alphabetically. When writing the implementation file of a class which is a
TQ_OBJECT, make sure you include the .moc file, not the .h.
// TQt
#include <qobject.h>
#include <qwidget.h>
// KDE
#include <kiconview.h>
#include <tdelistview.h>
// Local
#include "aclass.h"
#include "myclass.moc"
|