mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
2b9ca488fd
commit
c4c8094e32
21 changed files with 62 additions and 49 deletions
|
@ -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>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue