Adhere to this style guide strictly while adding new code to digiKam or 
working on existing code. 

========================================================================
Formatting:
========================================================================

-------------------------------------------------------------------------
* Indentation length
-------------------------------------------------------------------------

Indent with 4 spaces exactly.

for eg:

void function()
{
....int a;                    // 4 spaces from beginning
....for (int i=0; i<10; i++)  // 4 spaces from beginning
....{                         // 4 spaces from beginning
........a = i;                // 4 spaces from previous indent block

Emacs by default will indent to 4 spaces
vim users add this to you .vimrc
 set tabstop=4        


-------------------------------------------------------------------------
* Tabs vs Spaces
-------------------------------------------------------------------------

Absolutely no tabs. Use a sensible editor which will convert tabs to spaces. 
This will reduce unnecessary changes in your cvs commits.

Emacs by default will convert tab to spaces.
For vim users, add this to your .vimrc
  set expandtab

-------------------------------------------------------------------------
* Line length
-------------------------------------------------------------------------

Line length should never exceed 80 chars (unless really necessary - these 
cases are rare). Having long lines greatly reduces readability of code

-------------------------------------------------------------------------
* Bracketing
-------------------------------------------------------------------------

In almost all cases, {} brackets should start on a newline and should be 
aligned with previous line (follow the indentation spaces). for eg.

class A 
{ //new line
...

for (int i=0; i<10; i++)
{ //new line

if (a == foobar)
{ //new line
... 
}
else
{ // new line
..
} 

-------------------------------------------------------------------------
* Positioning of Access modifiers
-------------------------------------------------------------------------

public, private, protected, public slots, ... should be aligned to the 
beginning of the line with no margin

class A
{
public: // aligned to left 
...
private slots: // aligned to left 


Follow a consistent order in defining these attributes. The recommended
order is public, protected (functions), private (functions), 
signals, public slots, protected slots, private slots, private (variables)


========================================================================
Class, file and Variable names:
========================================================================

-------------------------------------------------------------------------
* Class and filenames
-------------------------------------------------------------------------

- filenames should always be in lower-case 
- class names should match the filenames. Capitalize the first letter and
  other letters logically to improve readability

-------------------------------------------------------------------------
* Member variables
-------------------------------------------------------------------------

- member variable names should always be of the form m_varName. 
- Captilize logically so that it becomes easy to read it. Do not capitalize
  the first letter after _ (Use m_varName not m_VarName)
- variable names should be indicative of their functionality and also of 
  the type they belong too if they are instances of qt widgets.
  for eg, QCheckBox* m_autoRotateCheckBox;

-------------------------------------------------------------------------
* Non-Member variables
-------------------------------------------------------------------------
- non-member variables should follow the same naming convention as the member 
  variables, except for the leading m_

========================================================================
Comments and Whitespace
========================================================================

Use whitespaces liberally to improve readability. Add blank lines between logical
sections of the code.

Comment as much as possible. Position comments at the beginning of the
section/line you want to comment, NEVER at the end of the line

// put your comments here
a = (b == foobar) ? 1 : -1; 

a = (b == foobar) ? 1 : -1; // you are asking for trouble by putting comments here


========================================================================
Header files
========================================================================


- Add copyright to top of every file
- Double inclusion protection defines are all upper case letters and are 
  composed of the classname and a H suffix separated by underscore

#ifndef ANOTHERNICECLASS_H
#define ANOTHERNICECLASS_H

class AnotherNiceClass
{
}

#endif

- Use forward declarations as much as possible.

class QFileInfo;

class A
{
....QFileInfo* m_fileInfo;

========================================================================
General recommendations
========================================================================

Use a decent editor which does auto-indentation/syntax-highlighting for you. 
I personally use Emacs. There are excellent initializer scripts in the kdesdk
package for xemacs and vim which can substantially increase your productivity.

Just to give a taste of what i can do with emacs (and kdesdk):

* automatically insert copyright (and ifdefs) in new files.
* insertion of class function definitions for declared class 
  functions in header with one keystroke
* switch between header and declaration files with one keystroke
* go to corresponding definition/declaration with one keystroke
* tab completion of variable/function names already declared.

