Preffer Q_FOREACH to foreach

This commit is contained in:
Albert Vaca 2016-06-21 14:50:17 +02:00
parent 6deef8b605
commit e880e14ed5
11 changed files with 28 additions and 28 deletions

View file

@ -85,7 +85,7 @@ int main(int argc, char** argv)
reply.waitForFinished();
const QStringList devices = reply.value();
foreach (const QString& id, devices) {
Q_FOREACH (const QString& id, devices) {
if (parser.isSet("id-only")) {
QTextStream(stdout) << id << endl;
} else {

View file

@ -293,7 +293,7 @@ void LanLinkProvider::sslErrors(const QList<QSslError>& errors)
disconnect(socket, SIGNAL(encrypted()), this, SLOT(encrypted()));
disconnect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>)));
foreach(const QSslError &error, errors) {
Q_FOREACH (const QSslError &error, errors) {
qCDebug(KDECONNECT_CORE) << "SSL Error :" << error.errorString();
switch (error.error()) {
case QSslError::CertificateSignatureFailed:
@ -322,7 +322,7 @@ void LanLinkProvider::sslErrors(const QList<QSslError>& errors)
void LanLinkProvider::sslErrorsLogButIgnore(const QList<QSslError>& errors)
{
foreach(const QSslError &error, errors) {
Q_FOREACH (const QSslError &error, errors) {
qCDebug(KDECONNECT_CORE) << "SSL Error (ignoring):" << error.errorString();
}
}

View file

@ -69,7 +69,7 @@ Daemon::Daemon(QObject *parent, bool testMode)
//Read remebered paired devices
const QStringList& list = KdeConnectConfig::instance()->trustedDevices();
Q_FOREACH(const QString& id, list) {
Q_FOREACH (const QString& id, list) {
Device* device = new Device(this, id);
connect(device, SIGNAL(reachableStatusChanged()), this, SLOT(onDeviceStatusChanged()));
connect(device, SIGNAL(trustedChanged(bool)), this, SLOT(onDeviceStatusChanged()));
@ -122,7 +122,7 @@ void Daemon::removeDevice(Device* device)
void Daemon::cleanDevices()
{
Q_FOREACH(Device* device, d->mDevices) {
Q_FOREACH (Device* device, d->mDevices) {
if (device->isTrusted()) {
continue;
}
@ -145,7 +145,7 @@ void Daemon::forceOnNetworkChange()
// I hate this, but not able to find an alternative now
Device *Daemon::getDevice(QString deviceId) {
Q_FOREACH(Device* device, d->mDevices) {
Q_FOREACH (Device* device, d->mDevices) {
if (device->id() == deviceId) {
return device;
}
@ -156,7 +156,7 @@ Device *Daemon::getDevice(QString deviceId) {
QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const
{
QStringList ret;
Q_FOREACH(Device* device, d->mDevices) {
Q_FOREACH (Device* device, d->mDevices) {
if (onlyReachable && !device->isReachable()) continue;
if (onlyTrusted && !device->isTrusted()) continue;
ret.append(device->id());
@ -243,7 +243,7 @@ bool Daemon::isDiscoveringDevices() const
QString Daemon::deviceIdByName(const QString &name) const
{
foreach(Device* d, d->mDevices) {
Q_FOREACH (Device* d, d->mDevices) {
if (d->name() == name && d->isTrusted())
return d->id();
}

View file

@ -113,7 +113,7 @@ void Device::reloadPlugins()
PluginLoader* loader = PluginLoader::instance();
const bool capabilitiesSupported = (m_protocolVersion >= 6);
foreach (const QString& pluginName, loader->getPluginList()) {
Q_FOREACH (const QString& pluginName, loader->getPluginList()) {
const KPluginMetaData service = loader->getPluginInfo(pluginName);
const QSet<QString> incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType").toSet();
const QSet<QString> outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType").toSet();
@ -149,10 +149,10 @@ void Device::reloadPlugins()
plugin = loader->instantiatePluginForDevice(pluginName, this);
}
foreach(const QString& interface, incomingInterfaces) {
Q_FOREACH (const QString& interface, incomingInterfaces) {
newPluginsByIncomingInterface.insert(interface, plugin);
}
foreach(const QString& interface, outgoingInterfaces) {
Q_FOREACH (const QString& interface, outgoingInterfaces) {
newPluginsByOutgoingInterface.insert(interface, plugin);
}
@ -334,7 +334,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
if (plugins.isEmpty()) {
qWarning() << "discarding unsupported package" << np.type() << "for" << name();
}
foreach(KdeConnectPlugin* plugin, plugins) {
Q_FOREACH (KdeConnectPlugin* plugin, plugins) {
plugin->receivePackage(np);
}
} else {

View file

@ -38,7 +38,7 @@ PluginLoader* PluginLoader::instance()
PluginLoader::PluginLoader()
{
QVector<KPluginMetaData> data = KPluginLoader::findPlugins("kdeconnect/");
foreach (const KPluginMetaData& metadata, data) {
Q_FOREACH (const KPluginMetaData& metadata, data) {
plugins[metadata.pluginId()] = metadata;
}
}
@ -87,7 +87,7 @@ KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(const QString& plugin
QStringList PluginLoader::incomingInterfaces() const
{
QSet<QString> ret;
foreach(const KPluginMetaData& service, plugins) {
Q_FOREACH (const KPluginMetaData& service, plugins) {
ret += KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType").toSet();
}
return ret.toList();
@ -96,7 +96,7 @@ QStringList PluginLoader::incomingInterfaces() const
QStringList PluginLoader::outgoingInterfaces() const
{
QSet<QString> ret;
foreach(const KPluginMetaData& service, plugins) {
Q_FOREACH (const KPluginMetaData& service, plugins) {
ret += KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType").toSet();
}
return ret.toList();

View file

@ -55,7 +55,7 @@ QList<QAction*> SendFileItemAction::actions(const KFileItemListProperties& fileI
QDBusPendingReply<QStringList> reply = iface.devices(true, true);
reply.waitForFinished();
const QStringList devices = reply.value();
foreach (const QString& id, devices) {
Q_FOREACH (const QString& id, devices) {
DeviceDbusInterface deviceIface(id);
if (!deviceIface.isValid()) {
continue;
@ -89,7 +89,7 @@ void SendFileItemAction::sendFile()
{
QList<QUrl> urls = sender()->property("urls").value<QList<QUrl>>();
QString id = sender()->property("id").toString();
foreach(const QUrl& url, urls) {
Q_FOREACH (const QUrl& url, urls) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+id+"/share", "org.kde.kdeconnect.device.share", "shareUrl");
msg.setArguments(QVariantList() << url.toString());
QDBusConnection::sessionBus().call(msg);

View file

@ -69,7 +69,7 @@ void NotificationsDbusInterface::processPackage(const NetworkPackage& np)
id = id.mid(id.indexOf("::") + 2);
removeNotification(id);
} else if (np.get<bool>("isRequest")) {
foreach (const auto& n, mNotifications) {
Q_FOREACH (const auto& n, mNotifications) {
NetworkPackage np(PACKAGE_TYPE_NOTIFICATION_REQUEST);
np.set("id", n->internalId());
np.set("appName", n->appName());

View file

@ -70,7 +70,7 @@ void RunCommandConfig::load()
QJsonDocument jsonDocument = QJsonDocument::fromJson(config()->get<QByteArray>("commands", "{}"));
QJsonObject jsonConfig = jsonDocument.object();
foreach(const QString &key, jsonConfig.keys()) {
Q_FOREACH (const QString &key, jsonConfig.keys()) {
const QJsonObject entry = jsonConfig[key].toObject();
const QString name = entry["name"].toString();
const QString command = entry["command"].toString();

View file

@ -96,7 +96,7 @@ void NotificationsListener::loadApplications()
{
applications.clear();
QVariantList list = mPlugin->config()->getList("applications");
foreach (const auto& a, list) {
Q_FOREACH (const auto& a, list) {
NotifyingApplication app = a.value<NotifyingApplication>();
if (!applications.contains(app.name))
applications.insert(app.name, app);
@ -129,7 +129,7 @@ uint NotificationsListener::Notify(const QString &appName, uint replacesId,
applications.insert(app.name, app);
// update config:
QVariantList list;
foreach (const auto& a, applications)
Q_FOREACH (const auto& a, applications)
list << QVariant::fromValue<NotifyingApplication>(a);
mPlugin->config()->setList("applications", list);
//qCDebug(KDECONNECT_PLUGIN_SENDNOTIFICATION) << "Added new application to config:" << app;

View file

@ -127,7 +127,7 @@ QStringList ConnectConnection::inspectHandles(uint handleType, const Tp::UIntLis
QStringList result;
foreach (uint handle, handles) {
Q_FOREACH (uint handle, handles) {
if (!m_handles.contains(handle)) {
return QStringList();
}
@ -172,7 +172,7 @@ Tp::UIntList ConnectConnection::requestHandles(uint handleType, const QStringLis
return result;
}
foreach(const QString &identify, identifiers) {
Q_FOREACH (const QString &identify, identifiers) {
uint handle = m_handles.key(identify, 0);
if (handle) {
result.append(handle);
@ -188,7 +188,7 @@ Tp::ContactAttributesMap ConnectConnection::getContactListAttributes(const QStri
{
Tp::ContactAttributesMap contactAttributes;
foreach (const uint handle, m_handles.keys()) {
Q_FOREACH (const uint handle, m_handles.keys()) {
if (handle == selfHandle()) {
continue;
}
@ -209,7 +209,7 @@ Tp::ContactAttributesMap ConnectConnection::getContactAttributes(const Tp::UIntL
Tp::ContactAttributesMap contactAttributes;
foreach (const uint handle, handles) {
Q_FOREACH (const uint handle, handles) {
if (m_handles.contains(handle)){
QVariantMap attributes;
attributes["org.freedesktop.Telepathy.Connection/contact-id"] = m_handles.value(handle);
@ -253,7 +253,7 @@ uint ConnectConnection::addContacts(const QStringList &identifiers)
}
QList<uint> newHandles;
foreach(const QString &identifier, identifiers) {
Q_FOREACH (const QString &identifier, identifiers) {
++handle;
m_handles.insert(handle, identifier);
newHandles << handle;
@ -334,7 +334,7 @@ void ConnectConnection::setContactList(const QStringList &identifiers)
uint ConnectConnection::getHandle(const QString &identifier) const
{
foreach (uint key, m_handles.keys()) {
Q_FOREACH (uint key, m_handles.keys()) {
if (m_handles.value(key) == identifier) {
return key;
}

View file

@ -328,7 +328,7 @@ void TestNotificationListener::testNotify()
// icon synchronization:
int count = 0;
foreach (const auto& iconName, KIconLoader::global()->queryIcons(-KIconLoader::SizeEnormous, KIconLoader::Application)) {
Q_FOREACH (const auto& iconName, KIconLoader::global()->queryIcons(-KIconLoader::SizeEnormous, KIconLoader::Application)) {
if (!iconName.endsWith(".png"))
continue;
if (count++ > 3) // max 3 iterations