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 b120e563 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Adapt to KCalCore recurrenceId changes

This lead to a small change in behavior, but that's completely internalized
to the plugin, so also adjusted tests correspondingly.
parent 89bcdb3e
......@@ -17,7 +17,7 @@
"date": "2016-05-08",
"time": ""
},
"uid": "Akonadi-3-20160506T000000"
"uid": "Akonadi-3-20160506T000000CEST"
},
{
......@@ -34,7 +34,7 @@
"date": "2016-05-15",
"time": ""
},
"uid": "Akonadi-3-20160513T000000"
"uid": "Akonadi-3-20160513T000000CEST"
},
{
......@@ -51,7 +51,7 @@
"date": "2016-05-22",
"time": ""
},
"uid": "Akonadi-3-20160520T000000"
"uid": "Akonadi-3-20160520T000000CEST"
},
{
......@@ -68,7 +68,7 @@
"date": "2016-05-29",
"time": ""
},
"uid": "Akonadi-3-20160527T000000"
"uid": "Akonadi-3-20160527T000000CEST"
}
]
}
......@@ -17,7 +17,7 @@
"date": "2016-05-06",
"time": ""
},
"uid": "Akonadi-4-20160506T000000"
"uid": "Akonadi-4-20160506T000000CEST"
},
{
......@@ -34,7 +34,7 @@
"date": "2016-05-13",
"time": ""
},
"uid": "Akonadi-4-20160513T000000"
"uid": "Akonadi-4-20160513T000000CEST"
},
{
......@@ -51,7 +51,7 @@
"date": "2016-05-20",
"time": ""
},
"uid": "Akonadi-4-20160520T000000"
"uid": "Akonadi-4-20160520T000000CEST"
},
{
......@@ -68,7 +68,7 @@
"date": "2016-05-27",
"time": ""
},
"uid": "Akonadi-4-20160527T000000"
"uid": "Akonadi-4-20160527T000000CEST"
}
]
}
......@@ -42,7 +42,7 @@ public:
{
}
QString callGenerateUid(const KCalCore::Incidence::Ptr &incidence, const KDateTime &recurrenceId) const
QString callGenerateUid(const KCalCore::Incidence::Ptr &incidence, const QDateTime &recurrenceId) const
{
return Visitor::generateUid(incidence, recurrenceId);
}
......@@ -66,27 +66,27 @@ using DateTimeRange = QPair<QDateTime, QDateTime>;
void EventDataVisitorTest::testGenerateUID_data()
{
QTest::addColumn<KCalCore::Incidence::Ptr>("incidence");
QTest::addColumn<KDateTime>("recurrenceId");
QTest::addColumn<QDateTime>("recurrenceId");
QTest::addColumn<qint64>("itemId");
QTest::addColumn<QString>("expectedUID");
auto incidence = KCalCore::Event::Ptr::create().staticCast<KCalCore::Incidence>();
QTest::newRow("simple event") << incidence << KDateTime()
QTest::newRow("simple event") << incidence << QDateTime()
<< 1ll << QStringLiteral("Akonadi-1");
QTest::newRow("recurring event") << incidence << KDateTime(QDate(2016, 5, 29), QTime(15, 47, 0), KDateTime::UTC)
QTest::newRow("recurring event") << incidence << QDateTime(QDate(2016, 5, 29), QTime(15, 47, 0), Qt::UTC)
<< 1ll << QStringLiteral("Akonadi-1-20160529T154700UTC");
incidence = KCalCore::Todo::Ptr::create().staticCast<KCalCore::Incidence>();
QTest::newRow("simple todo") << incidence << KDateTime()
QTest::newRow("simple todo") << incidence << QDateTime()
<< 42ll << QStringLiteral("Akonadi-42");
QTest::newRow("recurring todo") << incidence << KDateTime(QDate(2016, 5, 29), QTime(15, 49, 5), KDateTime::UTC)
QTest::newRow("recurring todo") << incidence << QDateTime(QDate(2016, 5, 29), QTime(15, 49, 5), Qt::UTC)
<< 42ll << QStringLiteral("Akonadi-42-20160529T154905UTC");
}
void EventDataVisitorTest::testGenerateUID()
{
QFETCH(KCalCore::Incidence::Ptr, incidence);
QFETCH(KDateTime, recurrenceId);
QFETCH(QDateTime, recurrenceId);
QFETCH(qint64, itemId);
QFETCH(QString, expectedUID);
......
......@@ -80,9 +80,13 @@ KCalCore::Incidence::Ptr TestDataParser::incidence() const
QDateTime TestDataParser::parseDateTime(const QJsonObject &dateTime)
{
return QDateTime(QDate::fromString(dateTime[QStringLiteral("date")].toString(), Qt::ISODate),
QTime::fromString(dateTime[QStringLiteral("time")].toString(), Qt::ISODate),
QTimeZone(dateTime[QStringLiteral("tz")].toString().toLatin1())).toLocalTime();
const auto date = QDate::fromString(dateTime[QStringLiteral("date")].toString(), Qt::ISODate);
const auto time = QTime::fromString(dateTime[QStringLiteral("time")].toString(), Qt::ISODate);
if (dateTime.contains(QLatin1String("tz"))) {
return QDateTime(date, time, QTimeZone(dateTime[QStringLiteral("tz")].toString().toLatin1())).toLocalTime();
} else {
return QDateTime(date, time, Qt::LocalTime);
}
}
void TestDataParser::parse()
......
......@@ -72,7 +72,7 @@ bool BaseEventDataVisitor::isInRange(const QDate &start, const QDate &end) const
}
}
QString BaseEventDataVisitor::generateUid(const KCalCore::Incidence::Ptr &incidence, const KDateTime &recurrenceId) const
QString BaseEventDataVisitor::generateUid(const KCalCore::Incidence::Ptr &incidence, const QDateTime &recurrenceId) const
{
// Get a corresponding Akonadi Item: Akonadi ID is the only reliably unique
// and persistent identifier when dealing with incidences from multiple
......@@ -85,7 +85,7 @@ QString BaseEventDataVisitor::generateUid(const KCalCore::Incidence::Ptr &incide
if (recurrenceId.isValid()) {
return QStringLiteral("Akonadi-%1-%2").arg(itemId)
.arg(recurrenceId.toString(QStringLiteral("%Y%m%dT%H%M%S%Z")));
.arg(recurrenceId.toString(QStringLiteral("yyyyMMddThhmmsst")));
} else {
return QStringLiteral("Akonadi-%1").arg(itemId);
}
......@@ -110,7 +110,7 @@ QVector<CalendarEvents::EventData> BaseEventDataVisitor::explodeIncidenceOccuren
}
copy.setStartDateTime(dt);
copy.setEndDateTime(dt.addSecs(duration));
copy.setUid(generateUid(incidence, rec));
copy.setUid(generateUid(incidence, rec.dateTime()));
results.push_back(copy);
......
......@@ -37,7 +37,7 @@ public:
protected:
BaseEventDataVisitor(PimDataSource *dataSource, const QDate &start, const QDate &end);
QString generateUid(const KCalCore::Incidence::Ptr &incidence, const KDateTime &recurrenceId = KDateTime()) const;
QString generateUid(const KCalCore::Incidence::Ptr &incidence, const QDateTime &recurrenceId = {}) const;
bool isInRange(const QDate &start, const QDate &end) const;
QVector<CalendarEvents::EventData> explodeIncidenceOccurences(const CalendarEvents::EventData &ed, const KCalCore::Incidence::Ptr &incidence, bool &ok);
......
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