From 4172b33b1222a586d95dbc7e69dad7a19a307ea1 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Tue, 14 May 2019 17:15:11 +0200 Subject: Replace Q_FOREACH (foreach) by C++11 ranged for-loops Q_FOREACH is bad and will be deprecated in the future: https://www.kdab.com/goodbye-q_foreach/ This also disables Q_FOREACH by defining QT_NO_FOREACH. --- src/base/QXmppElement.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/base/QXmppElement.cpp') diff --git a/src/base/QXmppElement.cpp b/src/base/QXmppElement.cpp index 7d0e33fa..9b07f851 100644 --- a/src/base/QXmppElement.cpp +++ b/src/base/QXmppElement.cpp @@ -88,7 +88,7 @@ QXmppElementPrivate::QXmppElementPrivate(const QDomElement &element) QXmppElementPrivate::~QXmppElementPrivate() { - foreach (QXmppElementPrivate *child, children) + for (auto *child : children) if (!child->counter.deref()) delete child; } @@ -178,7 +178,7 @@ void QXmppElement::appendChild(const QXmppElement &child) QXmppElement QXmppElement::firstChildElement(const QString &name) const { - foreach (QXmppElementPrivate *child_d, d->children) + for (auto *child_d : d->children) if (name.isEmpty() || child_d->name == name) return QXmppElement(child_d); return QXmppElement(); @@ -238,12 +238,12 @@ void QXmppElement::toXml(QXmlStreamWriter *writer) const writer->writeStartElement(d->name); if (d->attributes.contains("xmlns")) writer->writeAttribute("xmlns", d->attributes.value("xmlns")); - foreach (const QString &attr, d->attributes.keys()) + for (const auto &attr : d->attributes.keys()) if (attr != "xmlns") helperToXmlAddAttribute(writer, attr, d->attributes.value(attr)); if (!d->value.isEmpty()) writer->writeCharacters(d->value); - foreach (const QXmppElement &child, d->children) - child.toXml(writer); + for (auto *childPrivate : d->children) + QXmppElement(childPrivate).toXml(writer); writer->writeEndElement(); } -- cgit v1.2.3