Commit 3d6c3bb4 authored by Volker Krause's avatar Volker Krause
Browse files

Use calendar item access utility methods from akonadi-calendar

Depends on akonadi-calendar!18.
parent 6eacac2d
Pipeline #169081 passed with stage
in 3 minutes and 24 seconds
......@@ -37,7 +37,7 @@ set(EVENTVIEW_LIB_VERSION ${PIM_VERSION})
set(CALENDARUTILS_LIB_VERSION "5.20.40")
set(AKONADI_LIB_VERSION "5.20.40")
set(QT_REQUIRED_VERSION "5.15.2")
set(AKONADICALENDAR_LIB_VERSION "5.20.40")
set(AKONADICALENDAR_LIB_VERSION "5.20.42")
set(KMIME_LIB_VERSION "5.20.40")
set(LIBKDEPIM_LIB_VERSION "5.20.40")
set(CALENDARSUPPORT_LIB_VERSION "5.20.40")
......
......@@ -14,6 +14,7 @@
#include "agendaview.h"
#include "prefs.h"
#include <Akonadi/CalendarUtils>
#include <Akonadi/ETMCalendar>
#include <Akonadi/IncidenceChanger>
#include <CalendarSupport/Utils>
......@@ -2233,7 +2234,7 @@ void Agenda::selectIncidenceByUid(const QString &uid)
void Agenda::selectItem(const Akonadi::Item &item)
{
selectIncidenceByUid(CalendarSupport::incidence(item)->uid());
selectIncidenceByUid(Akonadi::CalendarUtils::incidence(item)->uid());
}
// This function seems never be called.
......
......@@ -20,6 +20,7 @@
#include "calendarview_debug.h"
#include <Akonadi/CalendarUtils>
#include <Akonadi/ETMCalendar>
#include <Akonadi/IncidenceChanger>
#include <CalendarSupport/CollectionSelection>
......@@ -1804,7 +1805,7 @@ void AgendaView::updateEventDates(AgendaItem *item, bool addIncidence, Akonadi::
Akonadi::Collection collection = calendar()->collection(collectionId);
result = changer()->createIncidence(incidence, collection, this) != -1;
} else {
KCalendarCore::Incidence::Ptr oldIncidence(CalendarSupport::incidence(aitem));
KCalendarCore::Incidence::Ptr oldIncidence(Akonadi::CalendarUtils::incidence(aitem));
aitem.setPayload<KCalendarCore::Incidence::Ptr>(incidence);
result = changer()->modifyIncidence(aitem, oldIncidence, this) != -1;
}
......@@ -1883,7 +1884,7 @@ void AgendaView::showIncidences(const Akonadi::Item::List &incidences, const QDa
bool wehaveall = true;
if (filter) {
for (const Akonadi::Item &aitem : incidences) {
if (!(wehaveall = filter->filterIncidence(CalendarSupport::incidence(aitem)))) {
if (!(wehaveall = filter->filterIncidence(Akonadi::CalendarUtils::incidence(aitem)))) {
break;
}
}
......@@ -1893,15 +1894,15 @@ void AgendaView::showIncidences(const Akonadi::Item::List &incidences, const QDa
calendar()->setFilter(nullptr);
}
QDateTime start = CalendarSupport::incidence(incidences.first())->dtStart().toLocalTime();
QDateTime end = CalendarSupport::incidence(incidences.first())->dateTime(KCalendarCore::Incidence::RoleEnd).toLocalTime();
QDateTime start = Akonadi::CalendarUtils::incidence(incidences.first())->dtStart().toLocalTime();
QDateTime end = Akonadi::CalendarUtils::incidence(incidences.first())->dateTime(KCalendarCore::Incidence::RoleEnd).toLocalTime();
Akonadi::Item first = incidences.first();
for (const Akonadi::Item &aitem : incidences) {
if (CalendarSupport::incidence(aitem)->dtStart().toLocalTime() < start) {
if (Akonadi::CalendarUtils::incidence(aitem)->dtStart().toLocalTime() < start) {
first = aitem;
}
start = qMin(start, CalendarSupport::incidence(aitem)->dtStart().toLocalTime());
end = qMax(start, CalendarSupport::incidence(aitem)->dateTime(KCalendarCore::Incidence::RoleEnd).toLocalTime());
start = qMin(start, Akonadi::CalendarUtils::incidence(aitem)->dtStart().toLocalTime());
end = qMax(start, Akonadi::CalendarUtils::incidence(aitem)->dateTime(KCalendarCore::Incidence::RoleEnd).toLocalTime());
}
end.toTimeZone(start.timeZone()); // allow direct comparison of dates
......@@ -2148,11 +2149,11 @@ void AgendaView::slotIncidencesDropped(const QList<QUrl> &items, const QPoint &g
KDateTime newTime(day, time, preferences()->timeSpec());
newTime.setDateOnly(allDay);
Todo::Ptr todo = CalendarSupport::todo(todoItem);
Todo::Ptr todo = Akonadi::CalendarUtils4::todo(todoItem);
if (todo && dynamic_cast<Akonadi::ETMCalendar *>(calendar())) {
const Akonadi::Item existingTodoItem = calendar()->itemForIncidence(calendar()->todo(todo->uid()));
if (Todo::Ptr existingTodo = CalendarSupport::todo(existingTodoItem)) {
if (Todo::Ptr existingTodo = Akonadi::CalendarUtils::todo(existingTodoItem)) {
qCDebug(CALENDARVIEW_LOG) << "Drop existing Todo";
Todo::Ptr oldTodo(existingTodo->clone());
if (changer()) {
......
......@@ -11,14 +11,14 @@
#include "eventview_p.h"
#include "prefs.h"
#include <Akonadi/EntityTreeModel>
#include <CalendarSupport/CollectionSelection>
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
#include <Akonadi/CalendarUtils>
#include <Akonadi/ETMViewStateSaver>
#include <Akonadi/EntityDisplayAttribute>
#include <Akonadi/EntityTreeModel>
#include <KCalendarCore/CalFilter>
......@@ -73,7 +73,7 @@ EventView::~EventView() = default;
void EventView::defaultAction(const Akonadi::Item &aitem)
{
qCDebug(CALENDARVIEW_LOG);
const Incidence::Ptr incidence = CalendarSupport::incidence(aitem);
const Incidence::Ptr incidence = Akonadi::CalendarUtils::incidence(aitem);
if (!incidence) {
return;
}
......
......@@ -12,6 +12,7 @@
#include "journalframe.h"
#include <Akonadi/CalendarUtils>
#include <CalendarSupport/Utils>
#include <KCalendarCore/Journal>
......@@ -262,19 +263,19 @@ void JournalFrame::setDirty()
void JournalFrame::printJournal()
{
Q_EMIT printJournal(CalendarSupport::journal(mJournal), false);
Q_EMIT printJournal(Akonadi::CalendarUtils::journal(mJournal), false);
}
void JournalFrame::printPreviewJournal()
{
Q_EMIT printJournal(CalendarSupport::journal(mJournal), true);
Q_EMIT printJournal(Akonadi::CalendarUtils::journal(mJournal), true);
}
void JournalFrame::readJournal(const Akonadi::Item &j)
{
int baseFontSize = QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize();
mJournal = j;
const KCalendarCore::Journal::Ptr journal = CalendarSupport::journal(j);
const KCalendarCore::Journal::Ptr journal = Akonadi::CalendarUtils::journal(j);
mBrowser->clear();
QTextCursor cursor = QTextCursor(mBrowser->textCursor());
cursor.movePosition(QTextCursor::Start);
......
......@@ -12,6 +12,7 @@
#include "journalview.h"
#include "journalframe.h"
#include <Akonadi/CalendarUtils>
#include <CalendarSupport/Utils>
#include "calendarview_debug.h"
......@@ -141,7 +142,7 @@ void JournalView::showIncidences(const Akonadi::Item::List &incidences, const QD
Q_UNUSED(date)
clearEntries();
for (const Akonadi::Item &i : incidences) {
if (const KCalendarCore::Journal::Ptr j = CalendarSupport::journal(i)) {
if (const KCalendarCore::Journal::Ptr j = Akonadi::CalendarUtils::journal(i)) {
appendJournal(i, j->dtStart().date());
}
}
......@@ -149,7 +150,7 @@ void JournalView::showIncidences(const Akonadi::Item::List &incidences, const QD
void JournalView::changeIncidenceDisplay(const Akonadi::Item &incidence, Akonadi::IncidenceChanger::ChangeType changeType)
{
if (KCalendarCore::Journal::Ptr journal = CalendarSupport::journal(incidence)) {
if (KCalendarCore::Journal::Ptr journal = Akonadi::CalendarUtils::journal(incidence)) {
switch (changeType) {
case Akonadi::IncidenceChanger::ChangeTypeCreate:
appendJournal(incidence, journal->dtStart().date());
......
......@@ -15,6 +15,7 @@
#include <CalendarSupport/Utils>
#include <Akonadi/CalendarUtils>
#include <Akonadi/ETMCalendar>
#include <Akonadi/IncidenceChanger>
......@@ -437,14 +438,14 @@ void ListView::showIncidences(const Akonadi::Item::List &itemList, const QDate &
void ListView::changeIncidenceDisplay(const Akonadi::Item &aitem, int action)
{
const Incidence::Ptr incidence = CalendarSupport::incidence(aitem);
const Incidence::Ptr incidence = Akonadi::CalendarUtils::incidence(aitem);
ListViewItem *item = nullptr;
const QDate f = d->mSelectedDates.constFirst();
const QDate l = d->mSelectedDates.constLast();
QDate date;
if (CalendarSupport::hasTodo(aitem)) {
date = CalendarSupport::todo(aitem)->dtDue().toLocalTime().date();
date = Akonadi::CalendarUtils::todo(aitem)->dtDue().toLocalTime().date();
} else {
date = incidence->dtStart().toLocalTime().date();
}
......@@ -521,7 +522,7 @@ void ListView::popupMenu(const QPoint &point)
// FIXME: For recurring incidences we don't know the date of this
// occurrence, there's no reference to it at all!
Q_EMIT showIncidencePopupSignal(aitem, CalendarSupport::incidence(aitem)->dtStart().date());
Q_EMIT showIncidencePopupSignal(aitem, Akonadi::CalendarUtils::incidence(aitem)->dtStart().date());
} else {
Q_EMIT showNewEventPopupSignal();
}
......
......@@ -12,6 +12,7 @@
#include "prefs.h"
#include "prefs_base.h" // Ugly, but needed for the Enums
#include <Akonadi/CalendarUtils>
#include <Akonadi/IncidenceChanger>
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
......@@ -575,7 +576,7 @@ QColor IncidenceMonthItem::bgColor() const
const auto &prefs = monthScene()->monthView()->preferences();
if (!prefs->todosUseCategoryColors() && mIsTodo) {
Todo::Ptr todo = CalendarSupport::todo(akonadiItem());
Todo::Ptr todo = Akonadi::CalendarUtils::todo(akonadiItem());
Q_ASSERT(todo);
if (todo) {
// this is dtDue if there's no dtRecurrence
......
......@@ -8,6 +8,8 @@
#include "timelineitem.h"
#include <Akonadi/CalendarUtils>
#include <KGantt/KGanttGlobal>
#include <CalendarSupport/Utils>
......@@ -32,7 +34,7 @@ TimelineItem::TimelineItem(const Akonadi::ETMCalendar::Ptr &calendar, uint index
void TimelineItem::insertIncidence(const Akonadi::Item &aitem, const QDateTime &_start, const QDateTime &_end)
{
const Incidence::Ptr incidence = CalendarSupport::incidence(aitem);
const Incidence::Ptr incidence = Akonadi::CalendarUtils::incidence(aitem);
QDateTime start(_start);
QDateTime end(_end);
if (!start.isValid()) {
......@@ -102,7 +104,7 @@ TimelineSubItem::TimelineSubItem(const Akonadi::ETMCalendar::Ptr &calendar, cons
, mToolTipNeedsUpdate(true)
{
setData(KGantt::TypeTask, KGantt::ItemTypeRole);
if (!CalendarSupport::incidence(incidence)->isReadOnly()) {
if (!Akonadi::CalendarUtils::incidence(incidence)->isReadOnly()) {
setFlags(Qt::ItemIsSelectable);
}
}
......@@ -138,7 +140,7 @@ void TimelineSubItem::updateToolTip()
mToolTipNeedsUpdate = false;
setData(IncidenceFormatter::toolTipStr(CalendarSupport::displayName(mCalendar.data(), mIncidence.parentCollection()),
CalendarSupport::incidence(mIncidence),
Akonadi::CalendarUtils::incidence(mIncidence),
originalStart().date(),
true),
Qt::ToolTipRole);
......
......@@ -11,10 +11,10 @@
#include <KGantt/KGanttGraphicsView>
#include <Akonadi/CalendarUtils>
#include <Akonadi/ETMCalendar>
#include <Akonadi/IncidenceChanger>
#include <CalendarSupport/CollectionSelection>
#include <CalendarSupport/Utils>
#include <KCalendarCore/OccurrenceIterator>
#include "calendarview_debug.h"
......@@ -56,7 +56,7 @@ void TimelineViewPrivate::contextMenuRequested(QPoint point)
Q_EMIT q->showNewEventPopupSignal();
mSelectedItemList = Akonadi::Item::List();
} else {
Q_EMIT q->showIncidencePopupSignal(tlitem->incidence(), CalendarSupport::incidence(tlitem->incidence())->dtStart().date());
Q_EMIT q->showIncidencePopupSignal(tlitem->incidence(), Akonadi::CalendarUtils::incidence(tlitem->incidence())->dtStart().date());
mSelectedItemList << tlitem->incidence();
}
......@@ -83,7 +83,7 @@ TimelineItem *TimelineViewPrivate::calendarItemForIncidence(const Akonadi::Item
void TimelineViewPrivate::insertIncidence(const Akonadi::Item &aitem, QDate day)
{
const Incidence::Ptr incidence = CalendarSupport::incidence(aitem);
const Incidence::Ptr incidence = Akonadi::CalendarUtils::incidence(aitem);
// qCDebug(CALENDARVIEW_LOG) << "Item " << aitem.id() << " parentcollection: " << aitem.parentCollection().id();
TimelineItem *item = calendarItemForIncidence(aitem);
if (!item) {
......@@ -109,7 +109,7 @@ void TimelineViewPrivate::insertIncidence(const Akonadi::Item &aitem, QDate day)
void TimelineViewPrivate::insertIncidence(const Akonadi::Item &incidence)
{
const Event::Ptr event = CalendarSupport::event(incidence);
const Event::Ptr event = Akonadi::CalendarUtils::event(incidence);
if (!event) {
return;
}
......@@ -163,7 +163,7 @@ void TimelineViewPrivate::itemChanged(QStandardItem *item)
}
const Akonadi::Item i = tlit->incidence();
const Incidence::Ptr inc = CalendarSupport::incidence(i);
const Incidence::Ptr inc = Akonadi::CalendarUtils::incidence(i);
QDateTime newStart(tlit->startTime());
if (inc->allDay()) {
......
......@@ -15,6 +15,7 @@
#include <KEmailAddress>
#include <KLocalizedString>
#include <Akonadi/CalendarUtils>
#include <Akonadi/IncidenceTreeModel>
#include <KCalUtils/DndFactory>
......@@ -102,7 +103,7 @@ QVariant TodoModel::data(const QModelIndex &index, int role) const
// Q_ASSERT( false );
return {};
}
const KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(item);
const KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(item);
if (!todo) {
qCCritical(CALENDARVIEW_LOG) << "item.hasPayload()" << item.hasPayload();
if (item.hasPayload<KCalendarCore::Incidence::Ptr>()) {
......@@ -327,7 +328,7 @@ bool TodoModel::setData(const QModelIndex &index, const QVariant &value, int rol
}
const auto item = data(index, Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
const KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(item);
const KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(item);
if (!item.isValid() || !todo) {
qCWarning(CALENDARVIEW_LOG) << "TodoModel::setData() called, bug item is invalid or doesn't have payload";
......@@ -529,12 +530,12 @@ bool TodoModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
// we don't want to change the created todo, but the one which is already
// stored in our calendar / tree
const Akonadi::Item item = d->findItemByUid(t->uid(), QModelIndex());
KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(item);
KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(item);
KCalendarCore::Todo::Ptr destTodo;
if (parent.isValid()) {
const auto parentItem = this->data(parent, Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
if (parentItem.isValid()) {
destTodo = CalendarSupport::todo(parentItem);
destTodo = Akonadi::CalendarUtils::todo(parentItem);
}
}
......@@ -545,7 +546,7 @@ bool TodoModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
return false;
}
const QString parentUid = tmp->relatedTo();
tmp = CalendarSupport::incidence(d->m_calendar->item(parentUid));
tmp = Akonadi::CalendarUtils::incidence(d->m_calendar->item(parentUid));
}
if (!destTodo || !destTodo->hasRecurrenceId()) {
......@@ -570,7 +571,7 @@ bool TodoModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
}
const auto parentItem = this->data(parent, Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
KCalendarCore::Todo::Ptr destTodo = CalendarSupport::todo(parentItem);
KCalendarCore::Todo::Ptr destTodo = Akonadi::CalendarUtils::todo(parentItem);
if (data->hasText()) {
QString text = data->text();
......@@ -618,7 +619,7 @@ Qt::ItemFlags TodoModel::flags(const QModelIndex &index) const
ret |= Qt::ItemIsDragEnabled;
const KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(item);
const KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(item);
if (d->m_calendar->hasRight(item, Akonadi::Collection::CanChangeItem)) {
// the following columns are editable:
......
......@@ -20,6 +20,7 @@
#include "todoviewsortfilterproxymodel.h"
#include "todoviewview.h"
#include <Akonadi/CalendarUtils>
#include <Akonadi/EntityMimeTypeFilterModel>
#include <Akonadi/TagFetchJob>
......@@ -27,8 +28,6 @@
#include <Akonadi/IncidenceTreeModel>
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
#include <CalendarSupport/KDatePickerPopup>
#include <KCalendarCore/CalFormat>
......@@ -621,7 +620,7 @@ void TodoView::addTodo(const QString &summary, const Akonadi::Item &parentItem,
return;
}
KCalendarCore::Todo::Ptr parent = CalendarSupport::todo(parentItem);
KCalendarCore::Todo::Ptr parent = Akonadi::CalendarUtils::todo(parentItem);
KCalendarCore::Todo::Ptr todo(new KCalendarCore::Todo);
todo->setSummary(summaryTrimmed);
......@@ -680,7 +679,7 @@ void TodoView::contextMenu(QPoint pos)
enable = false;
} else {
Akonadi::Item item = incidences.first();
incidencePtr = CalendarSupport::incidence(item);
incidencePtr = Akonadi::CalendarUtils::incidence(item);
// Action isn't RO, it can change the incidence, "Edit" for example.
const bool actionIsRw = mItemPopupMenuReadWriteEntries.contains(entry);
......@@ -817,7 +816,7 @@ void TodoView::copyTodoToDate(QDate date)
const auto origItem = sModels->todoModel->data(origIndex, Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
const KCalendarCore::Todo::Ptr orig = CalendarSupport::todo(origItem);
const KCalendarCore::Todo::Ptr orig = Akonadi::CalendarUtils::todo(origItem);
if (!orig) {
return;
}
......@@ -861,7 +860,7 @@ QMenu *TodoView::createCategoryPopupMenu()
}
const auto todoItem = selection[0].data(TodoModel::TodoRole).value<Akonadi::Item>();
KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(todoItem);
KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(todoItem);
Q_ASSERT(todo);
const QStringList checkedCategories = todo->categories();
......@@ -907,7 +906,7 @@ void TodoView::setNewDate(QDate date)
}
const auto todoItem = selection[0].data(TodoModel::TodoRole).value<Akonadi::Item>();
KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(todoItem);
KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(todoItem);
Q_ASSERT(todo);
if (calendar()->hasRight(todoItem, Akonadi::Collection::CanChangeItem)) {
......@@ -934,7 +933,7 @@ void TodoView::setNewPercentage(QAction *action)
}
const auto todoItem = selection[0].data(TodoModel::TodoRole).value<Akonadi::Item>();
KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(todoItem);
KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(todoItem);
Q_ASSERT(todo);
if (calendar()->hasRight(todoItem, Akonadi::Collection::CanChangeItem)) {
......@@ -960,7 +959,7 @@ void TodoView::setNewPriority(QAction *action)
return;
}
const auto todoItem = selection[0].data(TodoModel::TodoRole).value<Akonadi::Item>();
KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(todoItem);
KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(todoItem);
if (calendar()->hasRight(todoItem, Akonadi::Collection::CanChangeItem)) {
KCalendarCore::Todo::Ptr oldTodo(todo->clone());
todo->setPriority(mPriority[action]);
......@@ -977,7 +976,7 @@ void TodoView::changedCategories(QAction *action)
}
const auto todoItem = selection[0].data(TodoModel::TodoRole).value<Akonadi::Item>();
KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(todoItem);
KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(todoItem);
Q_ASSERT(todo);
if (calendar()->hasRight(todoItem, Akonadi::Collection::CanChangeItem)) {
KCalendarCore::Todo::Ptr oldTodo(todo->clone());
......
......@@ -8,6 +8,7 @@
#include "whatsnextview.h"
#include <Akonadi/CalendarUtils>
#include <Akonadi/ETMCalendar>
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
......@@ -286,7 +287,7 @@ void WhatsNextView::appendTodo(const KCalendarCore::Incidence::Ptr &incidence)
mText += incidence->summary();
mText += QLatin1String("</a>");
if (const KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(aitem)) {
if (const KCalendarCore::Todo::Ptr todo = Akonadi::CalendarUtils::todo(aitem)) {
if (todo->hasDueDate()) {
mText += i18nc("to-do due date", " (Due: %1)", KCalUtils::IncidenceFormatter::dateTimeToString(todo->dtDue(), todo->allDay()));
}
......
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