diff --git a/coding-style.md b/coding-style.md new file mode 100644 index 00000000..16f2ffb7 --- /dev/null +++ b/coding-style.md @@ -0,0 +1,43 @@ +## C++ Coding Style + +Mainly borrowed from [google c++ style coding style](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml) + +### Naming Conventions + +#### Member Vairables + +Lower case words seprated by underscores, and ends with an underscore, e.g. `repos_list_`, `context_menu_` + +#### Variables in Qt Ui Files + +Camel case starts with a "m", e.g. `mUserNameText`, `mServerAddr` + +#### Functions + +Camel case, e.g. `showRepos` + +#### Setter and Getter + +- setter: `setRepoName()` +- getter: `repoName()` + +#### Constants + +Camel case starts with "k", e.g. : + + const int kRepoRefreshInterval = 1000; + const char *kDefaultName = "seafile"; + +Use constants variables instead of macros to define constants. + +### Invoking functions + +- constant function parameter must be passed by object reference +- No `this->` when invoking member functions. + +### Others + +- no source file scope static variable/function, use anonymous namespace +- use forward declaration when possible, instead of including unnecessary header files +- Never use exceptions + diff --git a/dev-guide.md b/dev-guide.md index 795f72b0..24987949 100644 --- a/dev-guide.md +++ b/dev-guide.md @@ -1,20 +1,20 @@ ## C++ Coding Style -TO DO +Refer to `coding-style.md` ## I18N ### update the .ts files make update-ts - - + + ### Add a new language 1. add the language to the LANGUAGES variable in `CMakeLists.txt` SET(LANGUAGES zh_CN xx_YY) - + 2. make update-ts 3. add a line to `seafile-client.qrc` @@ -26,8 +26,8 @@ TO DO 1. add the language to the LANGUAGES variable in `CMakeLists.txt` SET(LANGUAGES zh_CN xx_YY) - + 2. add a line to `seafile-client.qrc` i18n/seafile_xx_YY.qm - +