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
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ private:
|
|||
QNetworkReply *reply;
|
||||
private
|
||||
slots:
|
||||
void sslErrors(QList<QSslError> errorList);
|
||||
void sslErrors(const QList<QSslError> &errorList);
|
||||
};
|
||||
|
||||
#endif // CHECKCLOUDCONNECTION_H
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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++);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue