Commit 7145faa8 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Refactor BaseEventDataVisitor::generateUid() to make it testable

parent a9278353
......@@ -79,20 +79,25 @@ QString BaseEventDataVisitor::generateUid(const KCalCore::Incidence::Ptr &incide
// Get a corresponding Akonadi Item: Akonadi ID is the only reliably unique
// and persistent identifier when dealing with incidences from multiple
// calendars
const Akonadi::Item item = mCalendar->item(incidence);
if (!item.isValid()) {
const qint64 itemId = itemIdForIncidence(incidence);
if (itemId <= 0) {
// Can this happen? What do we do now?!
return QString();
if (recurrenceId.isValid()) {
return QStringLiteral("Akonadi-%1-%2").arg(
return QStringLiteral("Akonadi-%1-%2").arg(itemId)
} else {
return QStringLiteral("Akonadi-%1").arg(;
return QStringLiteral("Akonadi-%1").arg(itemId);
qint64 BaseEventDataVisitor::itemIdForIncidence(const KCalCore::Incidence::Ptr &incidence) const
return mCalendar->item(incidence).id();
QVector<CalendarEvents::EventData> BaseEventDataVisitor::explodeIncidenceOccurences(const CalendarEvents::EventData &ed,
const KCalCore::Incidence::Ptr &incidence,
bool &ok)
......@@ -47,6 +47,9 @@ protected:
QVector<CalendarEvents::EventData> explodeIncidenceOccurences(const CalendarEvents::EventData &ed,
const KCalCore::Incidence::Ptr &incidence,
bool &ok);
// can be overridden by unit-tests
virtual qint64 itemIdForIncidence(const KCalCore::Incidence::Ptr &incidence) const;
Akonadi::ETMCalendar *mCalendar;
QDate mStart;
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