Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b10653ea authored by Laurent Montel's avatar Laurent Montel 😁

Minor optimization

parent bf6c2230
......@@ -67,7 +67,7 @@ void EwsCreateItemRequest::start()
}
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("Items"));
Q_FOREACH (const EwsItem &item, mItems) {
for (const EwsItem &item : qAsConst(mItems)) {
item.write(writer);
}
writer.writeEndElement();
......
......@@ -61,13 +61,13 @@ EwsEffectiveRightsPrivate::~EwsEffectiveRightsPrivate()
bool EwsEffectiveRightsPrivate::readRight(QXmlStreamReader &reader, Right right)
{
QString elm = reader.name().toString();
QString text = reader.readElementText();
if (reader.error() != QXmlStreamReader::NoError) {
qCWarning(EWSCLI_LOG) << QStringLiteral("Failed to read %1 element - invalid %2 element.")
.arg(QStringLiteral("EffectiveRights"), elm);
return false;
}
const QString text = reader.readElementText();
if (text == QStringLiteral("true")) {
mRights.setBit(right);
} else if (text == QStringLiteral("false")) {
......
......@@ -54,7 +54,7 @@ void EwsGetFolderRequest::start()
mShape.write(writer);
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("FolderIds"));
Q_FOREACH (const EwsId &id, mIds) {
for (const EwsId &id : qAsConst(mIds)) {
id.writeFolderIds(writer);
}
writer.writeEndElement();
......
......@@ -51,7 +51,7 @@ void EwsGetItemRequest::start()
mShape.write(writer);
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("ItemIds"));
Q_FOREACH (const EwsId &id, mIds) {
for (const EwsId &id : qAsConst(mIds)) {
id.writeItemIds(writer);
}
writer.writeEndElement();
......
......@@ -353,9 +353,9 @@ bool EwsItemPrivate::categoriesReader(QXmlStreamReader &reader, QVariant &val)
bool EwsItemPrivate::categoriesWriter(QXmlStreamWriter &writer, const QVariant &val)
{
QStringList categories = val.toStringList();
const QStringList categories = val.toStringList();
Q_FOREACH (const QString &cat, categories) {
for (const QString &cat : categories) {
writer.writeTextElement(ewsTypeNsUri, QStringLiteral("String"), cat);
}
......
......@@ -56,22 +56,22 @@ EwsMailbox::EwsMailbox(QXmlStreamReader &reader)
<< reader.namespaceUri();
return;
}
if (reader.name() == QStringLiteral("Name")) {
const QStringRef readerName = reader.name();
if (readerName == QStringLiteral("Name")) {
d->mName = reader.readElementText();
if (reader.error() != QXmlStreamReader::NoError) {
qCWarning(EWSCLI_LOG) << QStringLiteral("Failed to read EWS request - invalid mailbox Name element.");
return;
}
} else if (reader.name() == QStringLiteral("EmailAddress")) {
} else if (readerName == QStringLiteral("EmailAddress")) {
d->mEmail = reader.readElementText();
if (reader.error() != QXmlStreamReader::NoError) {
qCWarning(EWSCLI_LOG) << QStringLiteral("Failed to read EWS request - invalid mailbox EmailAddress element.");
return;
}
} else if (reader.name() == QStringLiteral("RoutingType") ||
reader.name() == QStringLiteral("MailboxType") ||
reader.name() == QStringLiteral("ItemId")) {
} else if (readerName == QStringLiteral("RoutingType") ||
readerName == QStringLiteral("MailboxType") ||
readerName == QStringLiteral("ItemId")) {
// Unsupported - ignore
//qCWarningNC(EWSCLIENT_LOG) << QStringLiteral("Unsupported mailbox element %1").arg(reader.name().toString());
reader.skipCurrentElement();
......
......@@ -43,7 +43,7 @@ void EwsMoveFolderRequest::start()
writer.writeEndElement();
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("FolderIds"));
Q_FOREACH (const EwsId &id, mIds) {
for (const EwsId &id : qAsConst(mIds)) {
id.writeFolderIds(writer);
}
writer.writeEndElement();
......
......@@ -43,7 +43,7 @@ void EwsMoveItemRequest::start()
writer.writeEndElement();
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("ItemIds"));
Q_FOREACH (const EwsId &id, mIds) {
for (const EwsId &id : qAsConst(mIds)) {
id.writeItemIds(writer);
}
writer.writeEndElement();
......
......@@ -187,8 +187,8 @@ bool EwsPoxAutodiscoverRequest::readAccount(QXmlStreamReader &reader)
if (reader.namespaceUri() != poxAdOuRespNsUri) {
return setErrorMsg(QStringLiteral("Failed to read POX response - invalid namespace"));
}
if (reader.name() == QStringLiteral("Action")) {
const QStringRef readerName = reader.name();
if (readerName == QStringLiteral("Action")) {
QString action = reader.readElementText();
if (action == QStringLiteral("settings")) {
mAction = Settings;
......@@ -200,13 +200,13 @@ bool EwsPoxAutodiscoverRequest::readAccount(QXmlStreamReader &reader)
return setErrorMsg(QStringLiteral("Failed to read POX response - unknown action '%1'")
.arg(action));
}
} else if (reader.name() == QStringLiteral("RedirectUrl")) {
} else if (readerName == QStringLiteral("RedirectUrl")) {
mRedirectUrl = reader.readElementText();
} else if (reader.name() == QStringLiteral("RedirectAddr")) {
} else if (readerName == QStringLiteral("RedirectAddr")) {
mRedirectAddr = reader.readElementText();
} else if (reader.name() == QStringLiteral("RedirectAddr")) {
} else if (readerName == QStringLiteral("RedirectAddr")) {
mRedirectAddr = reader.readElementText();
} else if (reader.name() == QStringLiteral("Protocol")) {
} else if (readerName == QStringLiteral("Protocol")) {
if (!readProtocol(reader)) {
return false;
}
......@@ -226,7 +226,8 @@ bool EwsPoxAutodiscoverRequest::readProtocol(QXmlStreamReader &reader)
return setErrorMsg(QStringLiteral("Failed to read POX response - invalid namespace"));
}
if (reader.name() == QStringLiteral("Type")) {
const QStringRef readerName = reader.name();
if (readerName == QStringLiteral("Type")) {
QString type = reader.readElementText();
if (type == QStringLiteral("EXCH")) {
proto.mType = ExchangeProto;
......@@ -238,9 +239,9 @@ bool EwsPoxAutodiscoverRequest::readProtocol(QXmlStreamReader &reader)
return setErrorMsg(QStringLiteral("Failed to read POX response - unknown protocol '%1'")
.arg(type));
}
} else if (reader.name() == QStringLiteral("EwsUrl")) {
} else if (readerName == QStringLiteral("EwsUrl")) {
proto.mEwsUrl = reader.readElementText();
} else if (reader.name() == QStringLiteral("OabUrl")) {
} else if (readerName == QStringLiteral("OabUrl")) {
proto.mOabUrl = reader.readElementText();
} else {
reader.skipCurrentElement();
......
......@@ -583,8 +583,8 @@ void EwsPropertyField::writeValue(QXmlStreamWriter &writer, const QVariant &valu
{
switch (value.type()) {
case QVariant::StringList: {
QStringList list = value.toStringList();
Q_FOREACH (const QString &str, list) {
const QStringList list = value.toStringList();
for (const QString &str : list) {
writer.writeTextElement(ewsTypeNsUri, QStringLiteral("String"), str);
}
break;
......@@ -602,9 +602,9 @@ void EwsPropertyField::writeExtendedValue(QXmlStreamWriter &writer, const QVaria
{
switch (value.type()) {
case QVariant::StringList: {
QStringList list = value.toStringList();
const QStringList list = value.toStringList();
writer.writeStartElement(ewsTypeNsUri, QStringLiteral("Values"));
Q_FOREACH (const QString &str, list) {
for (const QString &str : list) {
writer.writeTextElement(ewsTypeNsUri, QStringLiteral("Value"), str);
}
writer.writeEndElement();
......
......@@ -210,7 +210,7 @@ bool ewsXmlItemReader(QXmlStreamReader &reader, QVariant &val)
bool ewsXmlFolderReader(QXmlStreamReader &reader, QVariant &val)
{
QString elmName = reader.name().toString();
const QString elmName = reader.name().toString();
EwsFolder folder = EwsFolder(reader);
if (!folder.isValid()) {
qCWarningNC(EWSCLI_LOG) << QStringLiteral("Failed to read %1 element - invalid content.")
......@@ -224,7 +224,7 @@ bool ewsXmlFolderReader(QXmlStreamReader &reader, QVariant &val)
bool ewsXmlEnumReader(QXmlStreamReader &reader, QVariant &val, const QVector<QString> &items)
{
QString elmName = reader.name().toString();
const QString elmName = reader.name().toString();
QString text = reader.readElementText();
if (reader.error() != QXmlStreamReader::NoError) {
qCWarningNC(EWSCLI_LOG) << QStringLiteral("Failed to read %1 element - invalid content.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment