From c4c8094e32ad78dee558a80584470172f48c45b1 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 1 Apr 2019 22:15:19 +0200 Subject: 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 --- CodingStyle.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'CodingStyle.md') 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(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 -- cgit v1.2.3-70-g09d2