summaryrefslogtreecommitdiffstats
path: root/core
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 /core
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 'core')
-rw-r--r--core/btdiscovery.cpp4
-rw-r--r--core/checkcloudconnection.cpp4
-rw-r--r--core/checkcloudconnection.h2
-rw-r--r--core/cloudstorage.cpp4
-rw-r--r--core/cloudstorage.h2
-rw-r--r--core/qt-ble.cpp8
-rw-r--r--core/qt-ble.h2
-rw-r--r--core/qthelper.cpp6
8 files changed, 16 insertions, 16 deletions
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp
index 3ef0273fe..7e75994da 100644
--- a/core/btdiscovery.cpp
+++ b/core/btdiscovery.cpp
@@ -198,8 +198,8 @@ void BTDiscovery::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
this_d.name = device.name();
btPairedDevices.append(this_d);
- QList<QBluetoothUuid> serviceUuids = device.serviceUuids();
- foreach (QBluetoothUuid id, serviceUuids) {
+ const auto serviceUuids = device.serviceUuids();
+ for (QBluetoothUuid id: serviceUuids) {
addBtUuid(id);
qDebug() << id.toByteArray();
}
diff --git a/core/checkcloudconnection.cpp b/core/checkcloudconnection.cpp
index ffe2094f6..b912160c1 100644
--- a/core/checkcloudconnection.cpp
+++ b/core/checkcloudconnection.cpp
@@ -76,11 +76,11 @@ bool CheckCloudConnection::checkServer()
return false;
}
-void CheckCloudConnection::sslErrors(QList<QSslError> errorList)
+void CheckCloudConnection::sslErrors(const QList<QSslError> &errorList)
{
if (verbose) {
qDebug() << "Received error response trying to set up https connection with cloud storage backend:";
- Q_FOREACH (QSslError err, errorList) {
+ for (QSslError err: errorList) {
qDebug() << err.errorString();
}
}
diff --git a/core/checkcloudconnection.h b/core/checkcloudconnection.h
index 69f8a2964..312a1e78c 100644
--- a/core/checkcloudconnection.h
+++ b/core/checkcloudconnection.h
@@ -15,7 +15,7 @@ private:
QNetworkReply *reply;
private
slots:
- void sslErrors(QList<QSslError> errorList);
+ void sslErrors(const QList<QSslError> &errorList);
};
#endif // CHECKCLOUDCONNECTION_H
diff --git a/core/cloudstorage.cpp b/core/cloudstorage.cpp
index 39d9a4d66..77d9153e9 100644
--- a/core/cloudstorage.cpp
+++ b/core/cloudstorage.cpp
@@ -81,11 +81,11 @@ void CloudStorageAuthenticate::uploadError(QNetworkReply::NetworkError)
qDebug() << "Received error response from cloud storage backend:" << reply->errorString();
}
-void CloudStorageAuthenticate::sslErrors(QList<QSslError> errorList)
+void CloudStorageAuthenticate::sslErrors(const QList<QSslError> &errorList)
{
if (verbose) {
qDebug() << "Received error response trying to set up https connection with cloud storage backend:";
- Q_FOREACH (QSslError err, errorList) {
+ for (QSslError err: errorList) {
qDebug() << err.errorString();
}
}
diff --git a/core/cloudstorage.h b/core/cloudstorage.h
index 681b2b290..b19b3292c 100644
--- a/core/cloudstorage.h
+++ b/core/cloudstorage.h
@@ -16,7 +16,7 @@ signals:
private
slots:
void uploadError(QNetworkReply::NetworkError error);
- void sslErrors(QList<QSslError> errorList);
+ void sslErrors(const QList<QSslError> &errorList);
void uploadFinished();
private:
QNetworkReply *reply;
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp
index 9626042b5..9ee5def51 100644
--- a/core/qt-ble.cpp
+++ b/core/qt-ble.cpp
@@ -341,7 +341,7 @@ dc_status_t BLEObject::setHwCredit(unsigned int c)
return DC_STATUS_SUCCESS;
}
-dc_status_t BLEObject::setupHwTerminalIo(QList<QLowEnergyCharacteristic> allC)
+dc_status_t BLEObject::setupHwTerminalIo(const QList<QLowEnergyCharacteristic> &allC)
{ /* This initalizes the Terminal I/O client as described in
* http://www.telit.com/fileadmin/user_upload/products/Downloads/sr-rf/BlueMod/TIO_Implementation_Guide_r04.pdf
* Referenced section numbers below are from that document.
@@ -479,16 +479,16 @@ dc_status_t qt_ble_open(void **io, dc_context_t *, const char *devaddr, dc_user_
return r;
}
} else {
- foreach (const QLowEnergyCharacteristic &c, list) {
+ for (const QLowEnergyCharacteristic &c: list) {
if (!is_read_characteristic(c))
continue;
qDebug() << "Using read characteristic" << c.uuid();
- QList<QLowEnergyDescriptor> l = c.descriptors();
+ const QList<QLowEnergyDescriptor> l = c.descriptors();
QLowEnergyDescriptor d = l.first();
- foreach (const QLowEnergyDescriptor &tmp, l) {
+ for (const QLowEnergyDescriptor &tmp: l) {
if (tmp.type() == QBluetoothUuid::ClientCharacteristicConfiguration) {
d = tmp;
break;
diff --git a/core/qt-ble.h b/core/qt-ble.h
index 65e23964a..2b011163f 100644
--- a/core/qt-ble.h
+++ b/core/qt-ble.h
@@ -35,7 +35,7 @@ public slots:
void characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value);
void characteristicWritten(const QLowEnergyCharacteristic &c, const QByteArray &value);
void writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &value);
- dc_status_t setupHwTerminalIo(QList<QLowEnergyCharacteristic>);
+ dc_status_t setupHwTerminalIo(const QList<QLowEnergyCharacteristic> &allC);
dc_status_t setHwCredit(unsigned int c);
private:
QVector<QLowEnergyService *> services;
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 1a85d35a7..3738e56f2 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -1144,7 +1144,7 @@ QStringList imageExtensionFilters()
QStringList videoExtensionFilters()
{
QStringList filters;
- foreach (const QString &format, videoExtensionsList)
+ for (const QString &format: videoExtensionsList)
filters.append("*" + format);
return filters;
}
@@ -1506,9 +1506,9 @@ int parse_seabear_header(const char *filename, char **params, int pnr)
parseLine = f.readLine().trimmed();
- QStringList currColumns = parseLine.split(';');
+ const QStringList currColumns = parseLine.split(';');
unsigned short index = 0;
- Q_FOREACH (QString columnText, currColumns) {
+ for (const QString &columnText: currColumns) {
if (columnText == "Time") {
params[pnr++] = strdup("timeField");
params[pnr++] = intdup(index++);