OpieCodeStyle

This document describes code style guidelines and change policies for Opie.

A lot of existing code in Opie doesn't conform to these guidelines, but going through all of the source files and changing them would be time consuming, potentially risky, and in the case of naming, possibly even undesirable (affecting source/binary compatiblity). Generally, outside of libraries it should be OK to fix up the code style in a file before you work on it (as well as associated files within the same directory/application if you wish). Code style fixes should be kept as separate commits to actual substantive (i.e. functional) changes to the code - fix up the whole file/group of files, commit, then make your functional changes and commit those.

Layout
void SomeClass::someMethod {   // Code here }
 * Standard indenting should be four spaces. There is no rule on indenting for line continuation other than it should be at least one indent (four spaces), ideally more.
 * Functions should be laid out as follows:

...   if( somevariable == 1 ) { // Do some stuff }   else { // Do some other stuff } ...
 * Code blocks within a method should keep the opening brace next to the statement, and  blocks should appear on the next line e.g.

if( somevariable == 1 ) doSomething; else doSomethingElse;
 * With, it is fine to omit the braces if there is only one statement to be executed, but the statement should appear indented on the next line and there should be no blank lines or comments inbetween. e.g.


 * For readability, bracketing in statements and function calls should leave a space between the brackets and around operators as in the above examples.

Naming

 * Object field variables should use the prefix  (and should always be protected or private)
 * Class names should use camel case with the first letter capitalised eg.
 * Object functions should use camel case with the first letter left as lower case (Qt-style) eg.
 * Ideally get/set functions should use the Qt naming style, e.g. for retrieving a "size" value you would have  and for setting it you would have

Other

 * Code in library/ (i.e. libqpe) cannot use anything from libopie2. Use qDebug instead of odebug if you want to output debug messages.
 * Code in library/ should not be changed in any way that would break binary compatibility unless it is unavoidable. (OK, we've already broken binary compat in the past, but it's supposed to be a stable interface).
 * All strings displayed to the user (excluding debug messages) should be in English but enclosed in translate markers, e.g. . Sometimes it may be necessary to prefix   as  . (Refer to the Qt documentation.)

Important: when submitting patches, please don't change the indenting or code style unless you submit the style changes as a separate pre-patch.