Commit 9f7c7041 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make it compile against qt6

parent a21d9bad
Pipeline #121566 passed with stage
in 2 minutes and 14 seconds
include(ECMAddTests)
find_package(Qt5Test CONFIG REQUIRED)
find_package(Qt${QT_MAJOR_VERSION}Test CONFIG REQUIRED)
set(kgapitest_SRCS
fakeaccountstorage.cpp
......
......@@ -78,7 +78,7 @@ private Q_SLOTS:
TestableAccountManager accountManager;
const auto promise = accountManager.getAccount(ApiKey1, SecretKey1, Account1, { Account::contactsScopeUrl() });
QCOMPARE(promise->account(), {});
QCOMPARE(promise->account(), AccountPtr{});
QSignalSpy spy(promise, &AccountPromise::finished);
QVERIFY(spy.wait());
QCOMPARE(spy.count(), 1);
......@@ -104,7 +104,7 @@ private Q_SLOTS:
QVERIFY(insertedAccount);
const auto promise = accountManager.getAccount(ApiKey1, SecretKey1, Account1, { Account::contactsScopeUrl() });
QCOMPARE(promise->account(), {});
QCOMPARE(promise->account(), AccountPtr{});
QSignalSpy spy(promise, &AccountPromise::finished);
QVERIFY(spy.wait());
QCOMPARE(spy.count(), 1);
......@@ -132,7 +132,7 @@ private Q_SLOTS:
Account::accountInfoEmailScopeUrl() });
const auto promise = accountManager.getAccount(ApiKey1, SecretKey1, Account1, { Account::calendarScopeUrl() });
QCOMPARE(promise->account(), {});
QCOMPARE(promise->account(), AccountPtr{});
QSignalSpy spy(promise, &AccountPromise::finished);
QVERIFY(spy.wait());
QCOMPARE(spy.count(), 1);
......@@ -186,7 +186,7 @@ private Q_SLOTS:
TestableAccountManager accountManager;
const auto promise = accountManager.findAccount(ApiKey1, Account1);
QCOMPARE(promise->account(), {});
QCOMPARE(promise->account(), AccountPtr{});
QSignalSpy spy(promise, &AccountPromise::finished);
QVERIFY(spy.wait());
QCOMPARE(spy.count(), 1);
......@@ -200,7 +200,7 @@ private Q_SLOTS:
const auto insertedAccount = accountManager.fakeStore()->generateAccount(ApiKey1, Account1, { Account::calendarScopeUrl() });
const auto promise = accountManager.findAccount(ApiKey1, Account1);
QCOMPARE(promise->account(), {});
QCOMPARE(promise->account(), AccountPtr{});
QSignalSpy spy(promise, &AccountPromise::finished);
QVERIFY(spy.wait());
QCOMPARE(spy.count(), 1);
......@@ -223,7 +223,7 @@ private Q_SLOTS:
insertedAccount->setRefreshToken(QStringLiteral("FakeRefreshToken"));
const auto promise = accountManager.refreshTokens(ApiKey1, SecretKey1, Account1);
QCOMPARE(promise->account(), {});
QCOMPARE(promise->account(), AccountPtr{});
QSignalSpy spy(promise, &AccountPromise::finished);
QVERIFY(spy.wait());
QCOMPARE(spy.count(), 1);
......
......@@ -826,10 +826,15 @@ ObjectsList parseEventJSONFeed(const QByteArray& jsonFeed, FeedData& feedData)
KCalendarCore::DateList Private::parseRDate(const QString& rule)
{
KCalendarCore::DateList list;
QStringRef value;
QTimeZone tz;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QStringRef value;
const auto left = rule.leftRef(rule.indexOf(QLatin1Char(':')));
#else
QStringView value;
const auto left = QStringView(rule).left(rule.indexOf(QLatin1Char(':')));
#endif
const auto params = left.split(QLatin1Char(';'));
for (const auto &param : params) {
if (param.startsWith(QLatin1String("VALUE"))) {
......@@ -839,8 +844,11 @@ KCalendarCore::DateList Private::parseRDate(const QString& rule)
tz = QTimeZone(_name.toUtf8());
}
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const auto datesStr = rule.midRef(rule.lastIndexOf(QLatin1Char(':')) + 1);
#else
const auto datesStr = QStringView(rule).mid(rule.lastIndexOf(QLatin1Char(':')) + 1);
#endif
const auto dates = datesStr.split(QLatin1Char(','));
for (const auto &date : dates) {
QDate dt;
......
......@@ -9,7 +9,6 @@
#include "contactsgroup.h"
#include "utils.h"
#include "debug.h"
#include <kcontacts_version.h>
#include <QDomDocument>
#include <QDomElement>
......@@ -451,16 +450,10 @@ ObjectPtr Private::JSONToContact(const QVariantMap& data)
for (const QVariant & em : emails) {
const QVariantMap email = em.toMap();
const auto emailType = Contact::emailSchemeToProtocolName(email.value(QStringLiteral("rel")).toString());
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
const QMap<QString, QStringList> params({ { QStringLiteral("type"), { emailType } } });
contact->insertEmail(email.value(QStringLiteral("address")).toString(),
email.value(QStringLiteral("primary")).toBool(), params);
#else
KContacts::Email emailAddress(email.value(QStringLiteral("address")).toString());
emailAddress.setType(Contact::emailSchemeToProtocolType(emailType));
emailAddress.setPreferred(email.value(QStringLiteral("primary")).toBool());
contact->addEmail(emailAddress);
#endif
}
/* IMs */
......@@ -1068,19 +1061,10 @@ ContactPtr XMLToContact(const QByteArray& xmlData)
if (e.tagName() == QLatin1String("gd:email")) {
const auto emailType = Contact::emailSchemeToProtocolName(e.attribute(QStringLiteral("rel"), {}));
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
const QMap<QString, QStringList> params({ { QStringLiteral("type"), { emailType } } });
contact->insertEmail(e.attribute(QStringLiteral("address")),
(e.attribute(QStringLiteral("primary")).toLower() == QLatin1String("true")), params);
#else
KContacts::Email emailAddress(e.attribute(QStringLiteral("address")));
emailAddress.setType(Contact::emailSchemeToProtocolType(emailType));
emailAddress.setPreferred(e.attribute(QStringLiteral("primary")).toLower() == QLatin1String("true"));
contact->addEmail(emailAddress);
#endif
continue;
}
......
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