summaryrefslogtreecommitdiffstats
path: root/CodingStyle.md
diff options
context:
space:
mode:
authorGravatar Rolf Eike Beer <eike@sf-mail.de>2019-04-01 22:15:19 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 12:59:17 +0300
commitc4c8094e32ad78dee558a80584470172f48c45b1 (patch)
tree4fede2acf0f1a3cee2182d96b1b3efa33e4fd8ff /CodingStyle.md
parent2b9ca488fd18dc9d65d42dc5900e120a07e5b3f6 (diff)
downloadsubsurface-c4c8094e32ad78dee558a80584470172f48c45b1.tar.gz
get rid of some foreach and Q_FOREACH constructs
See https://www.kdab.com/goodbye-q_foreach/ This is reduced to the places where the container is const or can be made const without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7) and std::as_const (C++17) are not available in all supported setups. Also do some minor cleanups along the way. Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
Diffstat (limited to 'CodingStyle.md')
-rw-r--r--CodingStyle.md12
1 files changed, 11 insertions, 1 deletions
diff --git a/CodingStyle.md b/CodingStyle.md
index cb27c4b1d..9be434470 100644
--- a/CodingStyle.md
+++ b/CodingStyle.md
@@ -156,6 +156,16 @@ other editors that implement this coding style, please add them here.
```
QLowEnergyService *service = qobject_cast<QLowEnergyService*>(sender());
```
+ - If the variable is a container that is only assigned to a local variable to
+ be able to use it in a range-based for loop
+ ```
+ const auto l = device.serviceUuids();
+ for (QBluetoothUuid id: serviceUuids) {
+ ```
+ The variable has also to be const to avoid that Qt containers will do a
+ deep copy when the range bases for loop will call the begin() method
+ internally.
+
* text strings
The default language of subsurface is US English so please use US English
spelling and terminology.
@@ -173,7 +183,7 @@ other editors that implement this coding style, please add them here.
This works by default in classes (indirectly) derived from QObject. Each
string to be translated is associated with a context, which corresponds
to the class name. Classes that are not derived from QObject can generate
- the tr() functions by using the `Q_DECLARE_FUNCTIONS` macro:
+ the tr() functions by using the `Q_DECLARE_TR_FUNCTIONS` macro:
```
#include <QCoreApplication>