From c864267f04a3b9bf5794bd1352d1c6baf653fa2d Mon Sep 17 00:00:00 2001 From: Jean Vincent Date: Thu, 20 Jul 2017 16:14:07 +0200 Subject: [PATCH] Replace Q_FOREACH with C++11 range-for Summary: The use of Q_FOREACH is advised against (https://doc.qt.io/qt-5/qtglobal.html#Q_FOREACH) since Qt 5.7 and will eventually be removed from Qt. I replaced all occurrences with the range-for loop introduced in C++11 (except for the one in daemon.cpp in deviceIdByName which might have a bug / typo in it). I added const to the container or casted it with qAsConst when appropriate to avoid unnecessary copies. (This is my first submission. I did all the unit tests, and they all passed but I don't know how to show it here.) Reviewers: #kde_connect, nicolasfella, apol Reviewed By: #kde_connect, nicolasfella, apol Subscribers: albertvaka, apol, nicolasfella Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D6724 --- cli/kdeconnect-cli.cpp | 2 +- .../bluetooth/bluetoothlinkprovider.cpp | 4 ++-- core/daemon.cpp | 18 +++++++++--------- core/device.cpp | 18 +++++++++--------- core/pluginloader.cpp | 10 +++++----- fileitemactionplugin/sendfileitemaction.cpp | 6 +++--- interfaces/devicesmodel.cpp | 2 +- interfaces/notificationsmodel.cpp | 6 +++--- kio/kiokdeconnect.cpp | 4 ++-- plasmoid/declarativeplugin/responsewaiter.cpp | 2 +- plugins/mpriscontrol/mpriscontrolplugin.cpp | 4 ++-- .../notificationsdbusinterface.cpp | 2 +- plugins/pausemusic/pausemusicplugin.cpp | 6 +++--- plugins/runcommand/runcommand_config.cpp | 3 ++- .../notificationslistener.cpp | 6 +++--- tests/pluginloadtest.cpp | 3 ++- tests/sendfiletest.cpp | 3 ++- tests/testnotificationlistener.cpp | 3 ++- tests/testsocketlinereader.cpp | 2 +- tests/testsslsocketlinereader.cpp | 4 ++-- 20 files changed, 56 insertions(+), 52 deletions(-) diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp index bd1ebd94b..0552d525f 100644 --- a/cli/kdeconnect-cli.cpp +++ b/cli/kdeconnect-cli.cpp @@ -90,7 +90,7 @@ int main(int argc, char** argv) } const QStringList devices = blockOnReply(iface.devices(paired, reachable)); - Q_FOREACH (const QString& id, devices) { + for (const QString& id : devices) { if (parser.isSet(QStringLiteral("id-only"))) { QTextStream(stdout) << id << endl; } else { diff --git a/core/backends/bluetooth/bluetoothlinkprovider.cpp b/core/backends/bluetooth/bluetoothlinkprovider.cpp index 6a8855f6d..7cc9eaf08 100644 --- a/core/backends/bluetooth/bluetoothlinkprovider.cpp +++ b/core/backends/bluetooth/bluetoothlinkprovider.cpp @@ -114,9 +114,9 @@ void BluetoothLinkProvider::addLink(BluetoothDeviceLink* deviceLink, const QStri //I'm the new device and I found an existing device void BluetoothLinkProvider::serviceDiscoveryFinished() { - QList services = mServiceDiscoveryAgent->discoveredServices(); + const QList services = mServiceDiscoveryAgent->discoveredServices(); - Q_FOREACH (QBluetoothServiceInfo info, services) { + for (QBluetoothServiceInfo info : services) { if (mSockets.contains(info.device().address())) { continue; } diff --git a/core/daemon.cpp b/core/daemon.cpp index 6fd4cb57e..01aba12b3 100644 --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -78,12 +78,12 @@ Daemon::Daemon(QObject *parent, bool testMode) //Read remebered paired devices const QStringList& list = KdeConnectConfig::instance()->trustedDevices(); - Q_FOREACH (const QString& id, list) { + for (const QString& id : list) { addDevice(new Device(this, id)); } //Listen to new devices - Q_FOREACH (LinkProvider* a, d->mLinkProviders) { + for (LinkProvider* a : qAsConst(d->mLinkProviders)) { connect(a, &LinkProvider::onConnectionReceived, this, &Daemon::onNewDeviceLink); a->onStart(); @@ -127,7 +127,7 @@ void Daemon::removeDevice(Device* device) void Daemon::cleanDevices() { - Q_FOREACH (Device* device, d->mDevices) { + for (Device* device : qAsConst(d->mDevices)) { if (device->isTrusted()) { continue; } @@ -142,14 +142,14 @@ void Daemon::cleanDevices() void Daemon::forceOnNetworkChange() { qCDebug(KDECONNECT_CORE) << "Sending onNetworkChange to " << d->mLinkProviders.size() << " LinkProviders"; - Q_FOREACH (LinkProvider* a, d->mLinkProviders) { + for (LinkProvider* a : qAsConst(d->mLinkProviders)) { a->onNetworkChange(); } } Device*Daemon::getDevice(const QString& deviceId) { - Q_FOREACH (Device* device, d->mDevices) { + for (Device* device : qAsConst(d->mDevices)) { if (device->id() == deviceId) { return device; } @@ -160,7 +160,7 @@ Device*Daemon::getDevice(const QString& deviceId) QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const { QStringList ret; - Q_FOREACH (Device* device, d->mDevices) { + for (Device* device : qAsConst(d->mDevices)) { if (onlyReachable && !device->isReachable()) continue; if (onlyTrusted && !device->isTrusted()) continue; ret.append(device->id()); @@ -244,9 +244,9 @@ bool Daemon::isDiscoveringDevices() const QString Daemon::deviceIdByName(const QString &name) const { - Q_FOREACH (Device* d, d->mDevices) { - if (d->name() == name && d->isTrusted()) - return d->id(); + for (Device* device : qAsConst(d->mDevices)) { + if (device->name() == name && device->isTrusted()) + return device->id(); } return {}; } diff --git a/core/device.cpp b/core/device.cpp index 413d89587..d0f8565f0 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -102,7 +102,7 @@ void Device::reloadPlugins() PluginLoader* loader = PluginLoader::instance(); - Q_FOREACH (const QString& pluginName, m_supportedPlugins) { + for (const QString& pluginName : qAsConst(m_supportedPlugins)) { const KPluginMetaData service = loader->getPluginInfo(pluginName); const bool pluginEnabled = isPluginEnabled(pluginName); @@ -116,7 +116,7 @@ void Device::reloadPlugins() } Q_ASSERT(plugin); - Q_FOREACH (const QString& interface, incomingCapabilities) { + for (const QString& interface : incomingCapabilities) { newPluginsByIncomingCapability.insert(interface, plugin); } @@ -134,7 +134,7 @@ void Device::reloadPlugins() m_pluginsByIncomingCapability = newPluginsByIncomingCapability; QDBusConnection bus = QDBusConnection::sessionBus(); - Q_FOREACH(KdeConnectPlugin* plugin, m_plugins) { + for (KdeConnectPlugin* plugin : qAsConst(m_plugins)) { //TODO: see how it works in Android (only done once, when created) plugin->connected(); @@ -165,14 +165,14 @@ void Device::requestPair() return; } - Q_FOREACH(DeviceLink* dl, m_deviceLinks) { + for (DeviceLink* dl : qAsConst(m_deviceLinks)) { dl->userRequestsPair(); } } void Device::unpair() { - Q_FOREACH(DeviceLink* dl, m_deviceLinks) { + for (DeviceLink* dl : qAsConst(m_deviceLinks)) { dl->userRequestsUnpair(); } KdeConnectConfig::instance()->removeTrustedDevice(id()); @@ -184,7 +184,7 @@ void Device::pairStatusChanged(DeviceLink::PairStatus status) if (status == DeviceLink::NotPaired) { KdeConnectConfig::instance()->removeTrustedDevice(id()); - Q_FOREACH(DeviceLink* dl, m_deviceLinks) { + for (DeviceLink* dl : qAsConst(m_deviceLinks)) { if (dl != sender()) { dl->setPairStatus(DeviceLink::NotPaired); } @@ -325,7 +325,7 @@ bool Device::sendPackage(NetworkPackage& np) Q_ASSERT(isTrusted()); //Maybe we could block here any package that is not an identity or a pairing package to prevent sending non encrypted data - Q_FOREACH(DeviceLink* dl, m_deviceLinks) { + for (DeviceLink* dl : qAsConst(m_deviceLinks)) { if (dl->sendPackage(np)) return true; } @@ -340,7 +340,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np) if (plugins.isEmpty()) { qWarning() << "discarding unsupported package" << np.type() << "for" << name(); } - Q_FOREACH (KdeConnectPlugin* plugin, plugins) { + for (KdeConnectPlugin* plugin : plugins) { plugin->receivePackage(np); } } else { @@ -359,7 +359,7 @@ QStringList Device::availableLinks() const { QStringList sl; sl.reserve(m_deviceLinks.size()); - Q_FOREACH(DeviceLink* dl, m_deviceLinks) { + for (DeviceLink* dl : qAsConst(m_deviceLinks)) { sl.append(dl->provider()->name()); } return sl; diff --git a/core/pluginloader.cpp b/core/pluginloader.cpp index 05739c649..681e0c8ad 100644 --- a/core/pluginloader.cpp +++ b/core/pluginloader.cpp @@ -36,8 +36,8 @@ PluginLoader* PluginLoader::instance() PluginLoader::PluginLoader() { - QVector data = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/")); - Q_FOREACH (const KPluginMetaData& metadata, data) { + const QVector data = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/")); + for (const KPluginMetaData& metadata : data) { plugins[metadata.pluginId()] = metadata; } } @@ -86,7 +86,7 @@ KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(const QString& plugin QStringList PluginLoader::incomingCapabilities() const { QSet ret; - Q_FOREACH (const KPluginMetaData& service, plugins) { + for (const KPluginMetaData& service : qAsConst(plugins)) { ret += KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPackageType")).toSet(); } return ret.toList(); @@ -95,7 +95,7 @@ QStringList PluginLoader::incomingCapabilities() const QStringList PluginLoader::outgoingCapabilities() const { QSet ret; - Q_FOREACH (const KPluginMetaData& service, plugins) { + for (const KPluginMetaData& service : qAsConst(plugins)) { ret += KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPackageType")).toSet(); } return ret.toList(); @@ -105,7 +105,7 @@ QSet PluginLoader::pluginsForCapabilities(const QSet& incoming { QSet ret; - Q_FOREACH (const KPluginMetaData& service, plugins) { + for (const KPluginMetaData& service : qAsConst(plugins)) { const QSet pluginIncomingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPackageType")).toSet(); const QSet pluginOutgoingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPackageType")).toSet(); diff --git a/fileitemactionplugin/sendfileitemaction.cpp b/fileitemactionplugin/sendfileitemaction.cpp index 1a35771c2..3a9993616 100644 --- a/fileitemactionplugin/sendfileitemaction.cpp +++ b/fileitemactionplugin/sendfileitemaction.cpp @@ -55,7 +55,7 @@ QList SendFileItemAction::actions(const KFileItemListProperties& fileI QDBusPendingReply reply = iface.devices(true, true); reply.waitForFinished(); const QStringList devices = reply.value(); - Q_FOREACH (const QString& id, devices) { + for (const QString& id : devices) { DeviceDbusInterface deviceIface(id); if (!deviceIface.isValid()) { continue; @@ -87,9 +87,9 @@ QList SendFileItemAction::actions(const KFileItemListProperties& fileI void SendFileItemAction::sendFile() { - QList urls = sender()->property("urls").value>(); + const QList urls = sender()->property("urls").value>(); QString id = sender()->property("id").toString(); - Q_FOREACH (const QUrl& url, urls) { + for (const QUrl& url : urls) { QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+id+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl")); msg.setArguments(QVariantList() << url.toString()); QDBusConnection::sessionBus().call(msg); diff --git a/interfaces/devicesmodel.cpp b/interfaces/devicesmodel.cpp index a72d8da7f..cb0da81ae 100644 --- a/interfaces/devicesmodel.cpp +++ b/interfaces/devicesmodel.cpp @@ -203,7 +203,7 @@ void DevicesModel::receivedDeviceList(QDBusPendingCallWatcher* watcher) return; beginInsertRows(QModelIndex(), 0, deviceIds.count()-1); - Q_FOREACH(const QString& id, deviceIds) { + for (const QString& id : deviceIds) { appendDevice(new DeviceDbusInterface(id, this)); } endInsertRows(); diff --git a/interfaces/notificationsmodel.cpp b/interfaces/notificationsmodel.cpp index b22a4c4e3..80df27923 100644 --- a/interfaces/notificationsmodel.cpp +++ b/interfaces/notificationsmodel.cpp @@ -155,7 +155,7 @@ void NotificationsModel::receivedNotifications(QDBusPendingCallWatcher* watcher) } beginInsertRows(QModelIndex(), 0, notificationIds.size() - 1); - Q_FOREACH (const QString& notificationId, notificationIds) { + for (const QString& notificationId : notificationIds) { NotificationDbusInterface* dbusInterface = new NotificationDbusInterface(m_deviceId, notificationId, this); m_notificationList.append(dbusInterface); } @@ -229,7 +229,7 @@ int NotificationsModel::rowCount(const QModelIndex& parent) const bool NotificationsModel::isAnyDimissable() const { - Q_FOREACH (NotificationDbusInterface* notification, m_notificationList) { + for (NotificationDbusInterface* notification : qAsConst(m_notificationList)) { if (notification->dismissable()) { return true; } @@ -239,7 +239,7 @@ bool NotificationsModel::isAnyDimissable() const void NotificationsModel::dismissAll() { - Q_FOREACH (NotificationDbusInterface* notification, m_notificationList) { + for (NotificationDbusInterface* notification : qAsConst(m_notificationList)) { if (notification->dismissable()) { notification->dismiss(); } diff --git a/kio/kiokdeconnect.cpp b/kio/kiokdeconnect.cpp index 0bbb13fa6..05cda9fee 100644 --- a/kio/kiokdeconnect.cpp +++ b/kio/kiokdeconnect.cpp @@ -84,9 +84,9 @@ void KioKdeconnect::listAllDevices() infoMessage(i18n("Listing devices...")); //TODO: Change to all devices and show different icons for connected and disconnected? - QStringList devices = m_dbusInterface->devices(true, true); + const QStringList devices = m_dbusInterface->devices(true, true); - Q_FOREACH(const QString& deviceId, devices) { + for (const QString& deviceId : devices) { DeviceDbusInterface interface(deviceId); diff --git a/plasmoid/declarativeplugin/responsewaiter.cpp b/plasmoid/declarativeplugin/responsewaiter.cpp index ed974e9bd..6288e782d 100644 --- a/plasmoid/declarativeplugin/responsewaiter.cpp +++ b/plasmoid/declarativeplugin/responsewaiter.cpp @@ -117,7 +117,7 @@ void DBusAsyncResponse::onTimeout() const QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const { - Q_FOREACH(int type, m_registered) + for (int type : qAsConst(m_registered)) { if (variant.canConvert(QVariant::Type(type))) { diff --git a/plugins/mpriscontrol/mpriscontrolplugin.cpp b/plugins/mpriscontrol/mpriscontrolplugin.cpp index 6266b4a03..3a85a2876 100644 --- a/plugins/mpriscontrol/mpriscontrolplugin.cpp +++ b/plugins/mpriscontrol/mpriscontrolplugin.cpp @@ -48,8 +48,8 @@ MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args connect(QDBusConnection::sessionBus().interface(), &QDBusConnectionInterface::serviceOwnerChanged, this, &MprisControlPlugin::serviceOwnerChanged); //Add existing interfaces - QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); - Q_FOREACH (const QString& service, services) { + const QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); + for (const QString& service : services) { // The string doesn't matter, it just needs to be empty/non-empty serviceOwnerChanged(service, QLatin1String(""), QStringLiteral("1")); } diff --git a/plugins/notifications/notificationsdbusinterface.cpp b/plugins/notifications/notificationsdbusinterface.cpp index 3654551c6..d6cb3cfc5 100644 --- a/plugins/notifications/notificationsdbusinterface.cpp +++ b/plugins/notifications/notificationsdbusinterface.cpp @@ -65,7 +65,7 @@ void NotificationsDbusInterface::processPackage(const NetworkPackage& np) id = id.mid(id.indexOf(QLatin1String("::")) + 2); removeNotification(id); } else if (np.get(QStringLiteral("isRequest"))) { - Q_FOREACH (const auto& n, mNotifications) { + for (const auto& n : qAsConst(mNotifications)) { NetworkPackage np(PACKAGE_TYPE_NOTIFICATION_REQUEST, { {"id", n->internalId()}, {"appName", n->appName()}, diff --git a/plugins/pausemusic/pausemusicplugin.cpp b/plugins/pausemusic/pausemusicplugin.cpp index 4f1b90647..5b5bcd090 100644 --- a/plugins/pausemusic/pausemusicplugin.cpp +++ b/plugins/pausemusic/pausemusicplugin.cpp @@ -90,8 +90,8 @@ bool PauseMusicPlugin::receivePackage(const NetworkPackage& np) if (pause) { //Search for interfaces currently playing - QStringList interfaces = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); - Q_FOREACH (const QString& iface, interfaces) { + const QStringList interfaces = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); + for (const QString& iface : interfaces) { if (iface.startsWith(QLatin1String("org.mpris.MediaPlayer2"))) { QDBusInterface mprisInterface(iface, QStringLiteral("/org/mpris/MediaPlayer2"), QStringLiteral("org.mpris.MediaPlayer2.Player")); QString status = mprisInterface.property("PlaybackStatus").toString(); @@ -120,7 +120,7 @@ bool PauseMusicPlugin::receivePackage(const NetworkPackage& np) } if (pause && !pausedSources.empty()) { - Q_FOREACH (const QString& iface, pausedSources) { + for (const QString& iface : qAsConst(pausedSources)) { QDBusInterface mprisInterface(iface, QStringLiteral("/org/mpris/MediaPlayer2"), QStringLiteral("org.mpris.MediaPlayer2.Player")); mprisInterface.asyncCall(QStringLiteral("PlayPause")); } diff --git a/plugins/runcommand/runcommand_config.cpp b/plugins/runcommand/runcommand_config.cpp index 6686d241c..cfb3bb2c5 100644 --- a/plugins/runcommand/runcommand_config.cpp +++ b/plugins/runcommand/runcommand_config.cpp @@ -70,7 +70,8 @@ void RunCommandConfig::load() QJsonDocument jsonDocument = QJsonDocument::fromJson(config()->get(QStringLiteral("commands"), "{}")); QJsonObject jsonConfig = jsonDocument.object(); - Q_FOREACH (const QString &key, jsonConfig.keys()) { + const QStringList keys = jsonConfig.keys(); + for (const QString& key : keys) { const QJsonObject entry = jsonConfig[key].toObject(); const QString name = entry[QStringLiteral("name")].toString(); const QString command = entry[QStringLiteral("command")].toString(); diff --git a/plugins/sendnotifications/notificationslistener.cpp b/plugins/sendnotifications/notificationslistener.cpp index d047ca2e5..816d78e12 100644 --- a/plugins/sendnotifications/notificationslistener.cpp +++ b/plugins/sendnotifications/notificationslistener.cpp @@ -97,8 +97,8 @@ void NotificationsListener::setTranslatedAppName() void NotificationsListener::loadApplications() { applications.clear(); - QVariantList list = mPlugin->config()->getList(QStringLiteral("applications")); - Q_FOREACH (const auto& a, list) { + const QVariantList list = mPlugin->config()->getList(QStringLiteral("applications")); + for (const auto& a : list) { NotifyingApplication app = a.value(); if (!applications.contains(app.name)) applications.insert(app.name, app); @@ -204,7 +204,7 @@ uint NotificationsListener::Notify(const QString &appName, uint replacesId, applications.insert(app.name, app); // update config: QVariantList list; - Q_FOREACH (const auto& a, applications) + for (const auto& a : qAsConst(applications)) list << QVariant::fromValue(a); mPlugin->config()->setList(QStringLiteral("applications"), list); //qCDebug(KDECONNECT_PLUGIN_SENDNOTIFICATION) << "Added new application to config:" << app; diff --git a/tests/pluginloadtest.cpp b/tests/pluginloadtest.cpp index b649f4b97..7e30bcffb 100644 --- a/tests/pluginloadtest.cpp +++ b/tests/pluginloadtest.cpp @@ -48,7 +48,8 @@ class PluginLoadTest : public QObject void testPlugins() { Device* d = nullptr; mDaemon->acquireDiscoveryMode(QStringLiteral("plugintest")); - Q_FOREACH(Device* id, mDaemon->devicesList()) { + const QList devicesList = mDaemon->devicesList(); + for (Device* id : devicesList) { if (id->isReachable()) { if (!id->isTrusted()) id->requestPair(); diff --git a/tests/sendfiletest.cpp b/tests/sendfiletest.cpp index c2c29a424..4d5063e77 100644 --- a/tests/sendfiletest.cpp +++ b/tests/sendfiletest.cpp @@ -52,7 +52,8 @@ class TestSendFile : public QObject void testSend() { mDaemon->acquireDiscoveryMode(QStringLiteral("test")); Device* d = nullptr; - Q_FOREACH(Device* id, mDaemon->devicesList()) { + const QList devicesList = mDaemon->devicesList(); + for (Device* id : devicesList) { if (id->isReachable()) { if (!id->isTrusted()) id->requestPair(); diff --git a/tests/testnotificationlistener.cpp b/tests/testnotificationlistener.cpp index e82bc4dda..8fa6e547c 100644 --- a/tests/testnotificationlistener.cpp +++ b/tests/testnotificationlistener.cpp @@ -354,7 +354,8 @@ void TestNotificationListener::testNotify() QStringList iconPaths; // appIcon int count = 0; - Q_FOREACH (const auto& iconName, KIconLoader::global()->queryIcons(-KIconLoader::SizeEnormous, KIconLoader::Application)) { + const QStringList icons = KIconLoader::global()->queryIcons(-KIconLoader::SizeEnormous, KIconLoader::Application); + for (const auto& iconName : icons) { if (!iconName.endsWith(QLatin1String(".png"))) continue; if (count++ > 3) // max 3 iterations diff --git a/tests/testsocketlinereader.cpp b/tests/testsocketlinereader.cpp index 02612a81e..828e56916 100644 --- a/tests/testsocketlinereader.cpp +++ b/tests/testsocketlinereader.cpp @@ -67,7 +67,7 @@ void TestSocketLineReader::socketLineReader() { QList dataToSend; dataToSend << "foobar\n" << "barfoo\n" << "foobar?\n" << "\n" << "barfoo!\n" << "panda\n"; - Q_FOREACH(const QByteArray &line, dataToSend) { + for (const QByteArray& line : dataToSend) { mConn->write(line); } mConn->flush(); diff --git a/tests/testsslsocketlinereader.cpp b/tests/testsslsocketlinereader.cpp index 09a53e1fe..24a912cba 100644 --- a/tests/testsslsocketlinereader.cpp +++ b/tests/testsslsocketlinereader.cpp @@ -138,7 +138,7 @@ void TestSslSocketLineReader::testTrustedDevice() QList dataToSend; dataToSend << "foobar\n" << "barfoo\n" << "foobar?\n" << "\n" << "barfoo!\n" << "panda\n"; - Q_FOREACH(const QByteArray &line, dataToSend) { + for (const QByteArray &line : dataToSend) { mClientSocket->write(line); } mClientSocket->flush(); @@ -197,7 +197,7 @@ void TestSslSocketLineReader::testUntrustedDevice() QList dataToSend; dataToSend << "foobar\n" << "barfoo\n" << "foobar?\n" << "\n" << "barfoo!\n" << "panda\n"; - Q_FOREACH(const QByteArray &line, dataToSend) { + for (const QByteArray &line : dataToSend) { mClientSocket->write(line); } mClientSocket->flush();