summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-10-19 07:02:43 +0200
committerMontel Laurent <[email protected]>2017-10-19 07:03:00 +0200
commitcbdb08b920a914f46da4cb816a57b554b8952d74 (patch)
treedb6051527b927b4243a9f27e5cc08b444d262193
parent492b94414ac9899ceba4eeb1d8b4fa9766b86582 (diff)
Minor optimization
-rw-r--r--resources/ews/ewsautodiscoveryjob.cpp2
-rw-r--r--resources/ews/ewsclient/ewsattachment.cpp11
-rw-r--r--resources/ews/ewsclient/ewsattendee.cpp11
-rw-r--r--resources/ews/ewsclient/ewscreatefolderrequest.cpp2
-rw-r--r--resources/ews/ewsclient/ewsdeletefolderrequest.cpp2
-rw-r--r--resources/ews/ewsclient/ewsdeleteitemrequest.cpp2
-rw-r--r--resources/ews/ewsclient/ewseffectiverights.cpp18
-rw-r--r--resources/ews/ewsclient/ewseventrequestbase.cpp2
-rw-r--r--resources/ews/ewsclient/ewsfindfolderrequest.cpp13
-rw-r--r--resources/ews/ewsclient/ewsfinditemrequest.cpp27
-rw-r--r--resources/ews/ewsclient/ewsitem.cpp8
-rw-r--r--resources/ews/ewsclient/ewspropertyfield.cpp8
-rw-r--r--resources/ews/ewsclient/ewsrecurrence.cpp2
-rw-r--r--resources/ews/ewsresource.cpp2
14 files changed, 57 insertions, 53 deletions
diff --git a/resources/ews/ewsautodiscoveryjob.cpp b/resources/ews/ewsautodiscoveryjob.cpp
index 3825002..847b3c2 100644
--- a/resources/ews/ewsautodiscoveryjob.cpp
+++ b/resources/ews/ewsautodiscoveryjob.cpp
@@ -46,7 +46,7 @@ void EwsAutodiscoveryJob::start()
void EwsAutodiscoveryJob::parseEmail()
{
- int atIndex = mEmail.indexOf(QChar::fromLatin1('@'));
+ int atIndex = mEmail.indexOf(QLatin1Char('@'));
if (atIndex < 0) {
setErrorMsg(i18n("Incorrect email address"));
emitResult();
diff --git a/resources/ews/ewsclient/ewsattachment.cpp b/resources/ews/ewsclient/ewsattachment.cpp
index 1eff39b..f218900 100644
--- a/resources/ews/ewsclient/ewsattachment.cpp
+++ b/resources/ews/ewsclient/ewsattachment.cpp
@@ -93,14 +93,15 @@ EwsAttachment::EwsAttachment(QXmlStreamReader &reader)
return;
}
- if (reader.name() == QStringLiteral("ItemAttachment")) {
+ const QStringRef readerName = reader.name();
+ if (readerName == QStringLiteral("ItemAttachment")) {
d->mType = ItemAttachment;
- } else if (reader.name() == QStringLiteral("FileAttachment")) {
+ } else if (readerName == QStringLiteral("FileAttachment")) {
d->mType = FileAttachment;
- } else if (reader.name() == QStringLiteral("ReferenceAttachment")) {
+ } else if (readerName == QStringLiteral("ReferenceAttachment")) {
d->mType = ReferenceAttachment;
} else {
- qCWarningNC(EWSCLI_LOG) << QStringLiteral("Unknown attachment type %1").arg(reader.name().toString());
+ qCWarningNC(EWSCLI_LOG) << QStringLiteral("Unknown attachment type %1").arg(readerName.toString());
ok = false;
}
@@ -121,7 +122,7 @@ EwsAttachment::EwsAttachment(QXmlStreamReader &reader)
break;
}
- QString elmName = reader.name().toString();
+ const QString elmName = reader.name().toString();
if (elmName == QStringLiteral("AttachmentId")) {
QXmlStreamAttributes attrs = reader.attributes();
if (!attrs.hasAttribute(QStringLiteral("Id"))) {
diff --git a/resources/ews/ewsclient/ewsattendee.cpp b/resources/ews/ewsclient/ewsattendee.cpp
index ea0c80c..a9eb424 100644
--- a/resources/ews/ewsclient/ewsattendee.cpp
+++ b/resources/ews/ewsclient/ewsattendee.cpp
@@ -69,23 +69,24 @@ EwsAttendee::EwsAttendee(QXmlStreamReader &reader)
return;
}
- if (reader.name() == QStringLiteral("Mailbox")) {
+ const QStringRef readerName = reader.name();
+ if (readerName == QStringLiteral("Mailbox")) {
d->mMailbox = EwsMailbox(reader);
if (!d->mMailbox.isValid()) {
qCWarning(EWSCLI_LOG) << QStringLiteral("Failed to read EWS request - invalid attendee %1 element.")
- .arg(reader.name().toString());
+ .arg(readerName.toString());
return;
}
- } else if (reader.name() == QStringLiteral("ResponseType")) {
+ } else if (readerName == QStringLiteral("ResponseType")) {
bool ok;
d->mResponse = decodeEnumString<EwsEventResponseType>(reader.readElementText(),
responseTypeNames, responseTypeNameCount, &ok);
if (reader.error() != QXmlStreamReader::NoError || !ok) {
qCWarning(EWSCLI_LOG) << QStringLiteral("Failed to read EWS request - invalid attendee %1 element.")
- .arg(reader.name().toString());
+ .arg(readerName.toString());
return;
}
- } else if (reader.name() == QStringLiteral("LastResponseTime")) {
+ } else if (readerName == QStringLiteral("LastResponseTime")) {
// Unsupported - ignore
//qCWarningNC(EWSCLIENT_LOG) << QStringLiteral("Unsupported mailbox element %1").arg(reader.name().toString());
reader.skipCurrentElement();
diff --git a/resources/ews/ewsclient/ewscreatefolderrequest.cpp b/resources/ews/ewsclient/ewscreatefolderrequest.cpp
index 0cd9462..61fe9d8 100644
--- a/resources/ews/ewsclient/ewscreatefolderrequest.cpp
+++ b/resources/ews/ewsclient/ewscreatefolderrequest.cpp
@@ -44,7 +44,7 @@ void EwsCreateFolderRequest::start()
writer.writeEndElement();
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("Folders"));
- Q_FOREACH (const EwsFolder &folder, mFolders) {
+ for (const EwsFolder &folder : qAsConst(mFolders)) {
folder.write(writer);
}
writer.writeEndElement();
diff --git a/resources/ews/ewsclient/ewsdeletefolderrequest.cpp b/resources/ews/ewsclient/ewsdeletefolderrequest.cpp
index 147c12e..836b923 100644
--- a/resources/ews/ewsclient/ewsdeletefolderrequest.cpp
+++ b/resources/ews/ewsclient/ewsdeletefolderrequest.cpp
@@ -47,7 +47,7 @@ void EwsDeleteFolderRequest::start()
writer.writeAttribute(QStringLiteral("DeleteType"), deleteTypes[mType]);
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("FolderIds"));
- Q_FOREACH (const EwsId &id, mIds) {
+ for (const EwsId &id : qAsConst(mIds)) {
id.writeFolderIds(writer);
}
writer.writeEndElement();
diff --git a/resources/ews/ewsclient/ewsdeleteitemrequest.cpp b/resources/ews/ewsclient/ewsdeleteitemrequest.cpp
index 0959c72..19ce7de 100644
--- a/resources/ews/ewsclient/ewsdeleteitemrequest.cpp
+++ b/resources/ews/ewsclient/ewsdeleteitemrequest.cpp
@@ -47,7 +47,7 @@ void EwsDeleteItemRequest::start()
writer.writeAttribute(QStringLiteral("DeleteType"), deleteTypes[mType]);
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("ItemIds"));
- Q_FOREACH (const EwsId &id, mIds) {
+ for (const EwsId &id : qAsConst(mIds)) {
id.writeItemIds(writer);
}
writer.writeEndElement();
diff --git a/resources/ews/ewsclient/ewseffectiverights.cpp b/resources/ews/ewsclient/ewseffectiverights.cpp
index 8760180..b3ea9bc 100644
--- a/resources/ews/ewsclient/ewseffectiverights.cpp
+++ b/resources/ews/ewsclient/ewseffectiverights.cpp
@@ -95,38 +95,38 @@ EwsEffectiveRights::EwsEffectiveRights(QXmlStreamReader &reader)
<< reader.namespaceUri();
return;
}
-
- if (reader.name() == QStringLiteral("CreateAssociated")) {
+ const QStringRef readerName = reader.name();
+ if (readerName == QStringLiteral("CreateAssociated")) {
if (!d->readRight(reader, EwsEffectiveRightsPrivate::CreateAssociated)) {
return;
}
- } else if (reader.name() == QStringLiteral("CreateContents")) {
+ } else if (readerName == QStringLiteral("CreateContents")) {
if (!d->readRight(reader, EwsEffectiveRightsPrivate::CreateContents)) {
return;
}
- } else if (reader.name() == QStringLiteral("CreateHierarchy")) {
+ } else if (readerName == QStringLiteral("CreateHierarchy")) {
if (!d->readRight(reader, EwsEffectiveRightsPrivate::CreateHierarchy)) {
return;
}
- } else if (reader.name() == QStringLiteral("Delete")) {
+ } else if (readerName == QStringLiteral("Delete")) {
if (!d->readRight(reader, EwsEffectiveRightsPrivate::Delete)) {
return;
}
- } else if (reader.name() == QStringLiteral("Modify")) {
+ } else if (readerName == QStringLiteral("Modify")) {
if (!d->readRight(reader, EwsEffectiveRightsPrivate::Modify)) {
return;
}
- } else if (reader.name() == QStringLiteral("Read")) {
+ } else if (readerName == QStringLiteral("Read")) {
if (!d->readRight(reader, EwsEffectiveRightsPrivate::Read)) {
return;
}
- } else if (reader.name() == QStringLiteral("ViewPrivateItems")) {
+ } else if (readerName == QStringLiteral("ViewPrivateItems")) {
if (!d->readRight(reader, EwsEffectiveRightsPrivate::ViewPrivateItems)) {
return;
}
} else {
qCWarning(EWSCLI_LOG) << QStringLiteral("Failed to read %1 element - unknown element: %2.")
- .arg(QStringLiteral("EffectiveRights"), reader.name().toString());
+ .arg(QStringLiteral("EffectiveRights"), readerName.toString());
return;
}
}
diff --git a/resources/ews/ewsclient/ewseventrequestbase.cpp b/resources/ews/ewsclient/ewseventrequestbase.cpp
index 759ed81..bac6c4c 100644
--- a/resources/ews/ewsclient/ewseventrequestbase.cpp
+++ b/resources/ews/ewsclient/ewseventrequestbase.cpp
@@ -163,7 +163,7 @@ EwsEventRequestBase::Notification::Notification(QXmlStreamReader &reader)
bool EwsEventRequestBase::Notification::eventsReader(QXmlStreamReader &reader, QVariant &val)
{
Event::List events = val.value<Event::List>();
- QString elmName(reader.name().toString());
+ const QString elmName(reader.name().toString());
Event event(reader);
if (!event.isValid()) {
diff --git a/resources/ews/ewsclient/ewsfindfolderrequest.cpp b/resources/ews/ewsclient/ewsfindfolderrequest.cpp
index d916e8c..c0b11c2 100644
--- a/resources/ews/ewsclient/ewsfindfolderrequest.cpp
+++ b/resources/ews/ewsclient/ewsfindfolderrequest.cpp
@@ -195,11 +195,12 @@ bool EwsFindFolderResponse::parseRootFolder(QXmlStreamReader &reader)
EwsFolder* EwsFindFolderResponse::readFolder(QXmlStreamReader &reader)
{
EwsFolder *folder = nullptr;
- if (reader.name() == QStringLiteral("Folder") ||
- reader.name() == QStringLiteral("CalendarFolder") ||
- reader.name() == QStringLiteral("ContactsFolder") ||
- reader.name() == QStringLiteral("TasksFolder") ||
- reader.name() == QStringLiteral("SearchFolder")) {
+ const QStringRef readerName = reader.name();
+ if (readerName == QStringLiteral("Folder") ||
+ readerName == QStringLiteral("CalendarFolder") ||
+ readerName == QStringLiteral("ContactsFolder") ||
+ readerName == QStringLiteral("TasksFolder") ||
+ readerName == QStringLiteral("SearchFolder")) {
folder = new EwsFolder(reader);
if (!folder->isValid()) {
setErrorMsg(QStringLiteral("Failed to read EWS request - invalid %1 element.")
@@ -212,7 +213,7 @@ EwsFolder* EwsFindFolderResponse::readFolder(QXmlStreamReader &reader)
EwsClient::folderHash[(*folder)[EwsFolderFieldFolderId].value<EwsId>().id()] = dn.toString();
}
} else {
- qCWarning(EWSCLI_LOG).noquote() << QStringLiteral("Unsupported folder type %1").arg(reader.name().toString());
+ qCWarning(EWSCLI_LOG).noquote() << QStringLiteral("Unsupported folder type %1").arg(readerName.toString());
reader.skipCurrentElement();
}
diff --git a/resources/ews/ewsclient/ewsfinditemrequest.cpp b/resources/ews/ewsclient/ewsfinditemrequest.cpp
index 50b2001..c386c71 100644
--- a/resources/ews/ewsclient/ewsfinditemrequest.cpp
+++ b/resources/ews/ewsclient/ewsfinditemrequest.cpp
@@ -252,26 +252,27 @@ bool EwsFindItemResponse::parseRootFolder(QXmlStreamReader &reader)
EwsItem* EwsFindItemResponse::readItem(QXmlStreamReader &reader)
{
EwsItem *item = nullptr;
- if (reader.name() == QStringLiteral("Item") ||
- reader.name() == QStringLiteral("Message") ||
- reader.name() == QStringLiteral("CalendarItem") ||
- reader.name() == QStringLiteral("Contact") ||
- reader.name() == QStringLiteral("DistributionList") ||
- reader.name() == QStringLiteral("MeetingMessage") ||
- reader.name() == QStringLiteral("MeetingRequest") ||
- reader.name() == QStringLiteral("MeetingResponse") ||
- reader.name() == QStringLiteral("MeetingCancellation") ||
- reader.name() == QStringLiteral("Task")) {
- qCDebug(EWSCLI_LOG).noquote() << QStringLiteral("Processing %1").arg(reader.name().toString());
+ const QStringRef readerName = reader.name();
+ if (readerName == QStringLiteral("Item") ||
+ readerName == QStringLiteral("Message") ||
+ readerName == QStringLiteral("CalendarItem") ||
+ readerName == QStringLiteral("Contact") ||
+ readerName == QStringLiteral("DistributionList") ||
+ readerName == QStringLiteral("MeetingMessage") ||
+ readerName == QStringLiteral("MeetingRequest") ||
+ readerName == QStringLiteral("MeetingResponse") ||
+ readerName == QStringLiteral("MeetingCancellation") ||
+ readerName == QStringLiteral("Task")) {
+ qCDebug(EWSCLI_LOG).noquote() << QStringLiteral("Processing %1").arg(readerName.toString());
item = new EwsItem(reader);
if (!item->isValid()) {
setErrorMsg(QStringLiteral("Failed to read EWS request - invalid %1 element.")
- .arg(reader.name().toString()));
+ .arg(readerName.toString()));
delete item;
return nullptr;
}
} else {
- qCWarning(EWSCLI_LOG).noquote() << QStringLiteral("Unsupported folder type %1").arg(reader.name().toString());
+ qCWarning(EWSCLI_LOG).noquote() << QStringLiteral("Unsupported folder type %1").arg(readerName.toString());
reader.skipCurrentElement();
}
diff --git a/resources/ews/ewsclient/ewsitem.cpp b/resources/ews/ewsclient/ewsitem.cpp
index 6fc7021..74d40ab 100644
--- a/resources/ews/ewsclient/ewsitem.cpp
+++ b/resources/ews/ewsclient/ewsitem.cpp
@@ -419,13 +419,13 @@ EwsItem::EwsItem(QXmlStreamReader &reader)
EwsItemPrivate *d = reinterpret_cast<EwsItemPrivate*>(this->d.data());
// Check what item type are we
- QStringRef elmName = reader.name();
+ const QStringRef elmName = reader.name();
if (elmName == QStringLiteral("Item")) {
d->mType = EwsItemTypeItem;
- QStringRef subtype = reader.attributes().value(QStringLiteral("xsi:type"));
+ const QStringRef subtype = reader.attributes().value(QStringLiteral("xsi:type"));
if (!subtype.isEmpty()) {
- auto tokens = subtype.split(QChar::fromLatin1(':'));
- QStringRef type = tokens.size() == 1 ? tokens[0] : tokens[1];
+ auto tokens = subtype.split(QLatin1Char(':'));
+ const QStringRef type = tokens.size() == 1 ? tokens[0] : tokens[1];
if (type == QStringLiteral("AbchPersonItemType")) {
d->mType = EwsItemTypeAbchPerson;
}
diff --git a/resources/ews/ewsclient/ewspropertyfield.cpp b/resources/ews/ewsclient/ewspropertyfield.cpp
index 3b8c49e..44586a7 100644
--- a/resources/ews/ewsclient/ewspropertyfield.cpp
+++ b/resources/ews/ewsclient/ewspropertyfield.cpp
@@ -319,7 +319,7 @@ void EwsPropertyField::write(QXmlStreamWriter &writer) const
case IndexedField: {
writer.writeStartElement(ewsTypeNsUri, QStringLiteral("IndexedFieldURI"));
writer.writeAttribute(QStringLiteral("FieldURI"), d->mUri);
- QStringList tokens = d->mUri.split(QChar::fromLatin1(':'));
+ QStringList tokens = d->mUri.split(QLatin1Char(':'));
writer.writeAttribute(QStringLiteral("FieldIndex"), tokens[1] + QString::number(d->mIndex));
writer.writeEndElement();
break;
@@ -382,7 +382,7 @@ bool EwsPropertyField::read(QXmlStreamReader &reader)
return false;
}
QString uri = attrs.value(QStringLiteral("FieldURI")).toString();
- QStringList tokens = uri.split(QChar::fromLatin1(':'));
+ QStringList tokens = uri.split(QLatin1Char(':'));
QString indexStr = attrs.value(QStringLiteral("FieldIndex")).toString();
if (!indexStr.startsWith(tokens[1])) {
qCWarningNC(EWSCLI_LOG) << QStringLiteral("Error reading property field - malformed %1 attribute.")
@@ -542,7 +542,7 @@ bool EwsPropertyField::writeWithValue(QXmlStreamWriter &writer, const QVariant &
{
switch (d->mPropType) {
case Field: {
- QStringList tokens = d->mUri.split(QChar::fromLatin1(':'));
+ QStringList tokens = d->mUri.split(QLatin1Char(':'));
if (tokens.size() != 2) {
qCWarningNC(EWSCLI_LOG) << QStringLiteral("Invalid field URI: %1").arg(d->mUri);
return false;
@@ -553,7 +553,7 @@ bool EwsPropertyField::writeWithValue(QXmlStreamWriter &writer, const QVariant &
break;
}
case IndexedField: {
- QStringList tokens = d->mUri.split(QChar::fromLatin1(':'));
+ QStringList tokens = d->mUri.split(QLatin1Char(':'));
if (tokens.size() != 2) {
qCWarningNC(EWSCLI_LOG) << QStringLiteral("Invalid field URI: %1").arg(d->mUri);
return false;
diff --git a/resources/ews/ewsclient/ewsrecurrence.cpp b/resources/ews/ewsclient/ewsrecurrence.cpp
index 22463dd..c988928 100644
--- a/resources/ews/ewsclient/ewsrecurrence.cpp
+++ b/resources/ews/ewsclient/ewsrecurrence.cpp
@@ -551,7 +551,7 @@ bool EwsRecurrence::readDow(QXmlStreamReader &reader, QBitArray &dow)
{
bool ok;
QString text = reader.readElementText();
- QStringList days = text.split(QChar::fromLatin1(' '));
+ QStringList days = text.split(QLatin1Char(' '));
Q_FOREACH (const QString &day, days) {
short dowIndex = decodeEnumString<short>(day, dayOfWeekNames, dayOfWeekNameCount, &ok);
if (reader.error() != QXmlStreamReader::NoError || !ok) {
diff --git a/resources/ews/ewsresource.cpp b/resources/ews/ewsresource.cpp
index 58528a2..8c5e21b 100644
--- a/resources/ews/ewsresource.cpp
+++ b/resources/ews/ewsresource.cpp
@@ -461,7 +461,7 @@ void EwsResource::passwordRequestFinished(const QString &password)
if (mSettings->domain().isEmpty()) {
mEwsClient.setCredentials(mSettings->username(), mPassword);
} else {
- mEwsClient.setCredentials(mSettings->domain() + QChar::fromLatin1('\\') + mSettings->username(), mPassword);
+ mEwsClient.setCredentials(mSettings->domain() + QLatin1Char('\\') + mSettings->username(), mPassword);
}
mSettings->save();
if (mSettings->baseUrl().isEmpty()) {