Commit 94e4d7b4 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some code to QStringView in qt6

parent 6d029470
Pipeline #123174 passed with stage
in 7 minutes and 38 seconds
......@@ -77,8 +77,11 @@ EwsAttachment::EwsAttachment(QXmlStreamReader &reader)
reader.skipCurrentElement();
return;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef readerName = reader.name();
#else
const QStringView readerName = reader.name();
#endif
if (readerName == QLatin1String("ItemAttachment")) {
d->mType = ItemAttachment;
} else if (readerName == QLatin1String("FileAttachment")) {
......
......@@ -52,8 +52,11 @@ EwsAttendee::EwsAttendee(QXmlStreamReader &reader)
qCWarningNC(EWSCLI_LOG) << QStringLiteral("Unexpected namespace in mailbox element:") << reader.namespaceUri();
return;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef readerName = reader.name();
#else
const QStringView readerName = reader.name();
#endif
if (readerName == QLatin1String("Mailbox")) {
d->mMailbox = EwsMailbox(reader);
if (!d->mMailbox.isValid()) {
......
......@@ -79,7 +79,11 @@ EwsEffectiveRights::EwsEffectiveRights(QXmlStreamReader &reader)
qCWarningNC(EWSCLI_LOG) << QStringLiteral("Unexpected namespace in mailbox element:") << reader.namespaceUri();
return;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef readerName = reader.name();
#else
const QStringView readerName = reader.name();
#endif
if (readerName == QLatin1String("CreateAssociated")) {
if (!d->readRight(reader, EwsEffectiveRightsPrivate::CreateAssociated)) {
return;
......
......@@ -181,8 +181,11 @@ EwsEventRequestBase::Event::Event(QXmlStreamReader &reader)
static const EventReader staticReader(items);
EventReader ewsreader(staticReader);
QStringRef elmName = reader.name();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef elmName = reader.name();
#else
const QStringView elmName = reader.name();
#endif
if (elmName == QLatin1String("CopiedEvent")) {
mType = EwsCopiedEvent;
} else if (elmName == QLatin1String("CreatedEvent")) {
......
......@@ -179,7 +179,11 @@ bool EwsFindFolderResponse::parseRootFolder(QXmlStreamReader &reader)
EwsFolder *EwsFindFolderResponse::readFolder(QXmlStreamReader &reader)
{
EwsFolder *folder = nullptr;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef readerName = reader.name();
#else
const QStringView readerName = reader.name();
#endif
if (readerName == QLatin1String("Folder") || readerName == QLatin1String("CalendarFolder") || readerName == QLatin1String("ContactsFolder")
|| readerName == QLatin1String("TasksFolder") || readerName == QLatin1String("SearchFolder")) {
folder = new EwsFolder(reader);
......
......@@ -244,7 +244,11 @@ bool EwsFindItemResponse::parseRootFolder(QXmlStreamReader &reader)
EwsItem *EwsFindItemResponse::readItem(QXmlStreamReader &reader)
{
EwsItem *item = nullptr;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef readerName = reader.name();
#else
const QStringView readerName = reader.name();
#endif
if (readerName == QLatin1String("Item") || readerName == QLatin1String("Message") || readerName == QLatin1String("CalendarItem")
|| readerName == QLatin1String("Contact") || readerName == QLatin1String("DistributionList") || readerName == QLatin1String("MeetingMessage")
|| readerName == QLatin1String("MeetingRequest") || readerName == QLatin1String("MeetingResponse") || readerName == QLatin1String("MeetingCancellation")
......
......@@ -59,8 +59,14 @@ EwsId::EwsId(QXmlStreamReader &reader)
// such as "FolderId" or "ParentFolderId".
const QXmlStreamAttributes &attrs = reader.attributes();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QStringRef idRef = attrs.value(QStringLiteral("Id"));
QStringRef changeKeyRef = attrs.value(QStringLiteral("ChangeKey"));
#else
QStringView idRef = attrs.value(QStringLiteral("Id"));
QStringView changeKeyRef = attrs.value(QStringLiteral("ChangeKey"));
#endif
if (idRef.isNull()) {
return;
}
......
......@@ -42,7 +42,11 @@ EwsMailbox::EwsMailbox(QXmlStreamReader &reader)
qCWarningNC(EWSCLI_LOG) << QStringLiteral("Unexpected namespace in mailbox element:") << reader.namespaceUri();
return;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef readerName = reader.name();
#else
const QStringView readerName = reader.name();
#endif
if (readerName == QLatin1String("Name")) {
d->mName = reader.readElementText();
if (reader.error() != QXmlStreamReader::NoError) {
......
......@@ -176,7 +176,11 @@ bool EwsPoxAutodiscoverRequest::readAccount(QXmlStreamReader &reader)
if (reader.namespaceUri() != poxAdOuRespNsUri) {
return setErrorMsg(QStringLiteral("Failed to read POX response - invalid namespace"));
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef readerName = reader.name();
#else
const QStringView readerName = reader.name();
#endif
if (readerName == QLatin1String("Action")) {
QString action = reader.readElementText();
if (action == QLatin1String("settings")) {
......@@ -213,8 +217,11 @@ bool EwsPoxAutodiscoverRequest::readProtocol(QXmlStreamReader &reader)
if (reader.namespaceUri() != poxAdOuRespNsUri) {
return setErrorMsg(QStringLiteral("Failed to read POX response - invalid namespace"));
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef readerName = reader.name();
#else
const QStringView readerName = reader.name();
#endif
if (readerName == QLatin1String("Type")) {
QString type = reader.readElementText();
if (type == QLatin1String("EXCH")) {
......
......@@ -247,7 +247,11 @@ bool ewsXmlResponseTypeReader(QXmlStreamReader &reader, QVariant &val)
template<> QString readXmlElementValue(QXmlStreamReader &reader, bool &ok, const QString &parentElement)
{
ok = true;
QStringRef elmName = reader.name();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef elmName = reader.name();
#else
const QStringView elmName = reader.name();
#endif
QString val = reader.readElementText();
if (reader.error() != QXmlStreamReader::NoError) {
qCWarningNC(EWSCLI_LOG) << QStringLiteral("Failed to read %1 element - invalid %2 element.").arg(parentElement, elmName.toString());
......@@ -261,7 +265,11 @@ template<> QString readXmlElementValue(QXmlStreamReader &reader, bool &ok, const
template<> int readXmlElementValue(QXmlStreamReader &reader, bool &ok, const QString &parentElement)
{
QStringRef elmName = reader.name();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef elmName = reader.name();
#else
const QStringView elmName = reader.name();
#endif
QString valStr = readXmlElementValue<QString>(reader, ok, parentElement);
int val = 0;
if (ok) {
......@@ -276,7 +284,11 @@ template<> int readXmlElementValue(QXmlStreamReader &reader, bool &ok, const QSt
template<> long readXmlElementValue(QXmlStreamReader &reader, bool &ok, const QString &parentElement)
{
QStringRef elmName = reader.name();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef elmName = reader.name();
#else
const QStringView elmName = reader.name();
#endif
QString valStr = readXmlElementValue<QString>(reader, ok, parentElement);
long val = 0;
if (ok) {
......@@ -291,7 +303,11 @@ template<> long readXmlElementValue(QXmlStreamReader &reader, bool &ok, const QS
template<> QDateTime readXmlElementValue(QXmlStreamReader &reader, bool &ok, const QString &parentElement)
{
QStringRef elmName = reader.name();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef elmName = reader.name();
#else
const QStringView elmName = reader.name();
#endif
QString valStr = readXmlElementValue<QString>(reader, ok, parentElement);
QDateTime val;
if (ok) {
......@@ -307,7 +323,11 @@ template<> QDateTime readXmlElementValue(QXmlStreamReader &reader, bool &ok, con
template<> bool readXmlElementValue(QXmlStreamReader &reader, bool &ok, const QString &parentElement)
{
QStringRef elmName = reader.name();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QStringRef elmName = reader.name();
#else
const QStringView elmName = reader.name();
#endif
QString valStr = readXmlElementValue<QString>(reader, ok, parentElement);
bool val = false;
if (ok) {
......
Supports Markdown
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