From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- akregator/HACKING | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 akregator/HACKING (limited to 'akregator/HACKING') diff --git a/akregator/HACKING b/akregator/HACKING new file mode 100644 index 000000000..6e5c1b97d --- /dev/null +++ b/akregator/HACKING @@ -0,0 +1,251 @@ +================================================================================ +Indentation +================================================================================ + +We use 4 spaces instead of tabs everywhere. + +static void foo() +{ + if(bar()) // <-- 4 spaces + baz() // <-- 8 spaces +} + +================================================================================ +Braces +================================================================================ + +Opening braces should always be on their own line. + +class Foo +{ + // stuff +}; + +if (foo == bar) +{ + // stuff +} + +while (foo == bar && + baz == quux && + flop == pop) +{ + // stuff +} + +static void foo() +{ + // stuff +} + +Exceptions include inline functions that are just returning or setting a +value. However multiple statements should not ever be combined onto one line: + +class Foo +{ + public: + String value() const { return m_value; } +}; + +Also conditionals / loops that only contain one line in their body (but where +the conditional statement fits onto one line) should omit braces: + +if (foo == bar) + baz(); + +But: + +if (baz == quux && + ralf == spot) +{ + bar(); +} + +================================================================================ +Spaces +================================================================================ + +Spaces should be used between the conditional / loop type and the +conditional statement. They should not be used after parenthesis. However +the should be to mark of mathematical or comparative operators. + +if ( foo == bar ) + ^ ^ + +The marked spaces should be ommitted to produce: + +if (foo == bar) + +================================================================================ +Header Organization +================================================================================ + +Member variables should always be private or protected and prefixed with "m_". +Accessors may be inline in the headers. The organization of the members in a +class should be roughly as follows: + +public typedefs: +public ctors: +public methods: +public slots: +signals: +protected methods: +protected slots: +protected fields: +private methods: +private slots: +private fields: +private ctors: // if you define ctors/dtor as private, put them at end + +If there are no private slots there is no need for two private sections, however +private functions and private variables should be clearly separated. + +The implementations files -- .cpp files -- should follow (when possible) the +same order of function declarations as the header files. + +Virtual functions should always be marked as such even in derived classes where +it is not strictly necessary. + +================================================================================ +Whitespace +================================================================================ + +Whitespace should be used liberally. When blocks of code are logically distinct +I tend to put a blank line between them. This is difficult to explain +systematically but after looking a bit at the current code organization this +ideally will be somewhat clear. + +Also I tend to separate comments by blank lines on both sides. + +================================================================================ +Pointer and Reference Operators +================================================================================ + +This one is pretty simple. Use "Foo *f" and "Foo &f" in function signatures +and declarations. And also in signal/slot names. + +================================================================================ +Pointer and Reference Operators +================================================================================ + +An example object here: + +test.h: +#ifndef AKREGATOR_TEST_H +#define AKREGATOR_TEST_H + +#include "localinclude.h" +#include "anotherlocalinclude.h" +#include +#include +#include +#include + +class QSomething; + +namespace Akregator { + +class Test : public QObject +{ + Q_OBJECT + + public: + typedef QValueList list; + + Test(); + Test(QString someString); + explicit Test(int i = 0); + + virtual ~Test(); + + void someFunc(); + void someFunc2(QSomething *foo); + + static Test *instance() { return m_instance; } + + public slots: + void receive(QSomething &); + + signals: + void send(QSomething &); + + protected: + void someProtectedFunc(); + + static void someProtectedStaticFunc(); + + protected slots: + void protectedSlot(); + + protected: + int m_protectedVar; + + private: + int privateMethod(); + + static int staticPrivateMethod(); + + private slots: + void privateSlotIndeed(int youWonder); + + private: + int m_privateVar; + QSomething *m_tastyThing; + + static Test *m_instance; +}; + +} // no ; after namespace (borks on gcc 3.4+) + +#endif + +test.cpp: +#include "test.h" +#include "localinclude.h" +#include "anotherlocalinclude.h" +#include +#include +#include +#include +#include + +namespace Akregator { + +Test::Test() + : QObject() + , m_protectedVar(0) + , m_privateVar(0) + , m_tastyThing(0) + , m_instance(0) +{ +} + +Test::Test(QString someString) + : QObject() + , m_protectedVar(0) + , m_privateVar(0) + , m_tastyThing(someString) + , m_instance(0) +{ +} + +Test::Test(int i); + : QObject() + , m_protectedVar(0) + , m_privateVar(0) + , m_tastyThing(i) + , m_instance(0) +{ + if(i == 0) + kdDebug() << "Zero initializer" << endl; +} + +} // no ; after namespace (borks on gcc 3.4+) + +================================================================================ + +Original document by +Scott Wheeler + +Amendments for Akregator needs by +Stanislav Karchebny -- cgit v1.2.1