Skip to content

Commit a9a0c89

Browse files
author
timlinux
committedOct 10, 2008

File tree

2 files changed

+114
-27
lines changed

2 files changed

+114
-27
lines changed
 

‎CODING

Lines changed: 90 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
%!encoding: iso-8859-1
1+
Quantum GIS (QGIS)
2+
Developers guide for QGIS
23

34

45
------------------------------------------------------------------------
@@ -17,17 +18,19 @@
1718
1.3.2. Standard Header and License
1819
1.3.3. CVS Keyword
1920
1.4. Variable Names
20-
1.5. Editing
21-
1.5.1. Tabs
22-
1.5.2. Indentation
23-
1.5.3. Braces
24-
1.6. Coding Style
25-
1.6.1. Where-ever Possible Generalize Code
26-
1.6.2. Prefer Having Constants First in Predicates
27-
1.6.3. Whitespace Can Be Your Friend
28-
1.6.4. Add Trailing Identifying Comments
29-
1.6.5. Use Braces Even for Single Line Statements
30-
1.6.6. Book recommendations
21+
1.5. Enumerated Types
22+
1.6. Global Constants
23+
1.7. Editing
24+
1.7.1. Tabs
25+
1.7.2. Indentation
26+
1.7.3. Braces
27+
1.8. Coding Style
28+
1.8.1. Where-ever Possible Generalize Code
29+
1.8.2. Prefer Having Constants First in Predicates
30+
1.8.3. Whitespace Can Be Your Friend
31+
1.8.4. Add Trailing Identifying Comments
32+
1.8.5. Use Braces Even for Single Line Statements
33+
1.8.6. Book recommendations
3134
2. SVN Access
3235
2.1. Accessing the Repository
3336
2.2. Anonymous Access
@@ -52,7 +55,8 @@
5255
3.3. Adding your unit test to CMakeLists.txt
5356
3.4. Building your unit test
5457
3.5. Run your tests
55-
4. Authors
58+
4. HIG (Human Interface Guidelines)
59+
5. Authors
5660

5761

5862
------------------------------------------------------------------------
@@ -204,26 +208,54 @@ Variable names begin with a lower case letter and are formed using mixed case.
204208
currentExtent
205209

206210

211+
1.5. Enumerated Types
212+
=====================
213+
214+
Enumerated types should be named in CamelCase with a leading capital e.g.:
215+
216+
217+
enum UnitType
218+
{
219+
Meters,
220+
Feet,
221+
Degrees,
222+
UnknownUnit
223+
} ;
207224

208-
1.5. Editing
225+
226+
Do not use generic type names that will conflict with other types. e.g. use "UnkownUnit" rather
227+
than "Unknown"
228+
229+
230+
1.6. Global Constants
231+
=====================
232+
233+
Global constants should be written in upper case underscore separated e.g.:
234+
235+
236+
const long GEOCRS_ID = 3344;
237+
238+
239+
240+
1.7. Editing
209241
============
210242

211243
Any text editor/IDE can be used to edit QGIS code, providing the following requirements are met.
212244

213245

214-
1.5.1. Tabs
246+
1.7.1. Tabs
215247
===========
216248

217249
Set your editor to emulate tabs with spaces. Tab spacing should be set to 2 spaces.
218250

219251

220-
1.5.2. Indentation
252+
1.7.2. Indentation
221253
==================
222254

223255
Source code should be indented to improve readability. There is a .indent.pro file in the QGIS src directory that contains the switches to be used when indenting code using the GNU indent program. If you don't use GNU indent, you should emulate these settings.
224256

225257

226-
1.5.3. Braces
258+
1.7.3. Braces
227259
=============
228260

229261
Braces should start on the line following the expression:
@@ -241,13 +273,13 @@ Braces should start on the line following the expression:
241273

242274

243275

244-
1.6. Coding Style
276+
1.8. Coding Style
245277
=================
246278

247279
Here are described some programming hints and tips that will hopefully reduce errors, development time, and maintenance.
248280

249281

250-
1.6.1. Where-ever Possible Generalize Code
282+
1.8.1. Where-ever Possible Generalize Code
251283
==========================================
252284

253285

@@ -262,7 +294,7 @@ This will:
262294
maintain for others
263295

264296

265-
1.6.2. Prefer Having Constants First in Predicates
297+
1.8.2. Prefer Having Constants First in Predicates
266298
==================================================
267299

268300
Prefer to put constants first in predicates.
@@ -276,7 +308,7 @@ logic bugs. The compiler will generate an error if you accidentally use "=" ins
276308
inherently cannot be assigned values.
277309

278310

279-
1.6.3. Whitespace Can Be Your Friend
311+
1.8.3. Whitespace Can Be Your Friend
280312
====================================
281313

282314
Adding spaces between operators, statements, and functions makes it easier for humans to parse code.
@@ -294,7 +326,7 @@ or this:
294326

295327

296328

297-
1.6.4. Add Trailing Identifying Comments
329+
1.8.4. Add Trailing Identifying Comments
298330
========================================
299331

300332
Adding comments at the end of function, struct and class implementations makes it easier to find them later.
@@ -314,7 +346,7 @@ E.g.,
314346

315347

316348

317-
1.6.5. Use Braces Even for Single Line Statements
349+
1.8.5. Use Braces Even for Single Line Statements
318350
=================================================
319351

320352
Using braces for code in if/then blocks or similar code structures even for single line statements means that adding another
@@ -346,14 +378,17 @@ So, prefer this:
346378

347379

348380

349-
1.6.6. Book recommendations
381+
1.8.6. Book recommendations
350382
===========================
351383

352384
* Effective C++ (http://www.awprofessional.com/title/0321334876), Scott Meyers
353385
* More Effective C++ (http://www.awprofessional.com/bookstore/product.asp?isbn=020163371X&rl=1), Scott Meyers
354386
* Effective STL (http://www.awprofessional.com/title/0201749629), Scott Meyers
355387
* Design Patterns (http://www.awprofessional.com/title/0201634988), GoF
356388

389+
You should also really read this article from Qt Quarterly on
390+
http://doc.trolltech.com/qq/qq13-apis.html designing Qt style (APIs)
391+
357392

358393
2. SVN Access
359394
=============
@@ -520,10 +555,10 @@ deal with the patches that are sent to use easily.
520555
========================
521556

522557
If the patch is a fix for a specific bug, please name the file with the bug number in it e.g.
523-
bug777fix.diff, and attach it to the original bug report in trac (https://svn.qgis.org/trac).
558+
bug777fix.diff, and attach it to the original bug report in trac (https://trac.osgeo.org/qgis/).
524559

525560
If the bug is an enhancement or new feature, its usually a good idea to create a ticket in
526-
trac (https://svn.qgis.org/trac) first and then attach you
561+
trac (https://trac.osgeo.org/qgis/) first and then attach you
527562

528563

529564
2.6.2. Create your patch in the top level QGIS source dir
@@ -1190,7 +1225,35 @@ CMakeLists.txt parts) are still being worked on so that the testing framework
11901225
works in a truly platform way. I will update this document as things progress.
11911226

11921227

1193-
4. Authors
1228+
4. HIG (Human Interface Guidelines)
1229+
===================================
1230+
1231+
In order for all graphical user interface elements to appear consistant and
1232+
to all the user to instinctively use dialogs, it is important that the following
1233+
guidelines are followed in layout and design of GUIs.
1234+
1235+
1. Group related elements using group boxes:
1236+
Try to identify elements that can be grouped together and then use
1237+
group boxes with a label identify the topic of that group.
1238+
Avoid using group boxes with only a single widget / item inside.
1239+
2. Capitalise first letter only in group box labels:
1240+
Group box labels should be written as a phrase with leading capital letter,
1241+
and all remaing words written with lower case first letters
1242+
3. Do not end labels for widgets or group boxes with a colon:
1243+
Adding a colon causes visual noise and does not impart additional meaning,
1244+
so dont use them. An exception to this rule is when you have two labels
1245+
next to each other e.g.: Label1 Plugin (Path:) Label2 [/path/to/plugins]
1246+
4. Keep harmful actions away from harmless ones:
1247+
If you have actions for 'delete', 'remove' etc, try to impose adequate
1248+
space between the harmful action and innocuous actions so that the users
1249+
is less likely to inadvertantly click on the harmful action.
1250+
5. Always use a QButtonBox for 'OK', 'Cancel' etc buttons:
1251+
Using a button box will ensure that the order of 'OK' and 'Cancel' etc,
1252+
buttons is consistent with the operating system / locale / desktop
1253+
environment that the user is using.
1254+
1255+
1256+
5. Authors
11941257
==========
11951258

11961259
* Tim Sutton (author and editor)

‎doc/CODING.t2t

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,30 @@ Examples:
147147
mapCanvas
148148
currentExtent
149149
```
150+
== Enumerated Types ==
151+
152+
Enumerated types should be named in CamelCase with a leading capital e.g.:
153+
154+
```
155+
enum UnitType
156+
{
157+
Meters,
158+
Feet,
159+
Degrees,
160+
UnknownUnit
161+
} ;
162+
```
163+
164+
Do not use generic type names that will conflict with other types. e.g. use "UnkownUnit" rather
165+
than "Unknown"
166+
167+
== Global Constants ==
168+
169+
Global constants should be written in upper case underscore separated e.g.:
170+
171+
```
172+
const long GEOCRS_ID = 3344;
173+
```
150174

151175
== Editing ==
152176
Any text editor/IDE can be used to edit QGIS code, providing the following requirements are met.

0 commit comments

Comments
 (0)
Please sign in to comment.