Commit ac8e6637 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Use Calendar instead of MemoryCalendar in interfaces

We don't need any of the MemoryCalendar API.

By using Calendar in the interfaces the API gets more flexible and we can use it for non-MemoryCalendar-based calendars
parent 23a77592
Pipeline #77426 passed with stage
in 5 minutes and 38 seconds
......@@ -16,6 +16,7 @@
#include <KCalendarCore/FreeBusy>
#include <KCalendarCore/ICalFormat>
#include <KCalendarCore/Journal>
#include <KCalendarCore/MemoryCalendar>
#include <KCalendarCore/Todo>
#include <KLocalizedString>
......
......@@ -10,7 +10,7 @@
#include <QObject>
#include <KCalendarCore/MemoryCalendar>
#include <KCalendarCore/Calendar>
class IncidenceFormatterTest : public QObject
{
......
......@@ -26,6 +26,7 @@
#include "vcaldrag.h"
#include "kcalutils_debug.h"
#include <KCalendarCore/MemoryCalendar>
#include <KIconLoader>
#include <KUrlMimeData>
#include <QUrl>
......@@ -51,7 +52,7 @@ using namespace KCalUtils;
class KCalUtils::DndFactoryPrivate
{
public:
DndFactoryPrivate(const MemoryCalendar::Ptr &calendar)
DndFactoryPrivate(const Calendar::Ptr &calendar)
: mCalendar(calendar)
{
}
......@@ -116,11 +117,11 @@ public:
return inc;
}
MemoryCalendar::Ptr mCalendar;
Calendar::Ptr mCalendar;
};
//@endcond
DndFactory::DndFactory(const MemoryCalendar::Ptr &calendar)
DndFactory::DndFactory(const Calendar::Ptr &calendar)
: d(new KCalUtils::DndFactoryPrivate(calendar))
{
}
......@@ -149,7 +150,7 @@ QDrag *DndFactory::createDrag(QWidget *owner)
QMimeData *DndFactory::createMimeData(const Incidence::Ptr &incidence)
{
MemoryCalendar::Ptr cal(new MemoryCalendar(d->mCalendar->timeZone()));
Calendar::Ptr cal(new MemoryCalendar(d->mCalendar->timeZone()));
Incidence::Ptr i(incidence->clone());
// strip recurrence id's, We don't want to drag the exception but the occurrence.
i->setRecurrenceId({});
......@@ -179,22 +180,22 @@ QDrag *DndFactory::createDrag(const Incidence::Ptr &incidence, QWidget *owner)
return drag;
}
MemoryCalendar::Ptr DndFactory::createDropCalendar(const QMimeData *mimeData)
Calendar::Ptr DndFactory::createDropCalendar(const QMimeData *mimeData)
{
if (mimeData) {
MemoryCalendar::Ptr calendar(new MemoryCalendar(QTimeZone::systemTimeZone()));
Calendar::Ptr calendar(new MemoryCalendar(QTimeZone::systemTimeZone()));
if (ICalDrag::fromMimeData(mimeData, calendar) || VCalDrag::fromMimeData(mimeData, calendar)) {
return calendar;
}
}
return MemoryCalendar::Ptr();
return Calendar::Ptr();
}
MemoryCalendar::Ptr DndFactory::createDropCalendar(QDropEvent *dropEvent)
Calendar::Ptr DndFactory::createDropCalendar(QDropEvent *dropEvent)
{
MemoryCalendar::Ptr calendar(createDropCalendar(dropEvent->mimeData()));
Calendar::Ptr calendar(createDropCalendar(dropEvent->mimeData()));
if (calendar) {
dropEvent->accept();
return calendar;
......@@ -206,7 +207,7 @@ Event::Ptr DndFactory::createDropEvent(const QMimeData *mimeData)
{
// qCDebug(KCALUTILS_LOG);
Event::Ptr event;
MemoryCalendar::Ptr calendar(createDropCalendar(mimeData));
Calendar::Ptr calendar(createDropCalendar(mimeData));
if (calendar) {
Event::List events = calendar->events();
......@@ -232,7 +233,7 @@ Todo::Ptr DndFactory::createDropTodo(const QMimeData *mimeData)
{
// qCDebug(KCALUTILS_LOG);
Todo::Ptr todo;
MemoryCalendar::Ptr calendar(createDropCalendar(mimeData));
Calendar::Ptr calendar(createDropCalendar(mimeData));
if (calendar) {
Todo::List todos = calendar->todos();
......@@ -280,7 +281,7 @@ bool DndFactory::copyIncidences(const Incidence::List &incidences)
{
QClipboard *clipboard = QApplication::clipboard();
Q_ASSERT(clipboard);
MemoryCalendar::Ptr calendar(new MemoryCalendar(d->mCalendar->timeZone()));
Calendar::Ptr calendar(new MemoryCalendar(d->mCalendar->timeZone()));
Incidence::List::ConstIterator it;
const Incidence::List::ConstIterator end(incidences.constEnd());
......@@ -313,7 +314,7 @@ Incidence::List DndFactory::pasteIncidences(const QDateTime &newDateTime, PasteF
{
QClipboard *clipboard = QApplication::clipboard();
Q_ASSERT(clipboard);
MemoryCalendar::Ptr calendar(createDropCalendar(clipboard->mimeData()));
Calendar::Ptr calendar(createDropCalendar(clipboard->mimeData()));
Incidence::List list;
if (!calendar) {
......@@ -355,7 +356,7 @@ Incidence::List DndFactory::pasteIncidences(const QDateTime &newDateTime, PasteF
Incidence::Ptr DndFactory::pasteIncidence(const QDateTime &newDateTime, PasteFlags pasteOptions)
{
QClipboard *clipboard = QApplication::clipboard();
MemoryCalendar::Ptr calendar(createDropCalendar(clipboard->mimeData()));
Calendar::Ptr calendar(createDropCalendar(clipboard->mimeData()));
if (!calendar) {
qCDebug(KCALUTILS_LOG) << "Can't parse clipboard";
......
......@@ -21,9 +21,9 @@
#include "kcalutils_export.h"
#include <KCalendarCore/Calendar>
#include <KCalendarCore/Event>
#include <KCalendarCore/Journal>
#include <KCalendarCore/MemoryCalendar>
#include <KCalendarCore/Todo>
#include <QDateTime>
......@@ -55,19 +55,19 @@ public:
Q_DECLARE_FLAGS(PasteFlags, PasteFlag)
explicit DndFactory(const KCalendarCore::MemoryCalendar::Ptr &cal);
explicit DndFactory(const KCalendarCore::Calendar::Ptr &cal);
~DndFactory();
/**
Create the calendar that is contained in the drop event's data.
*/
KCalendarCore::MemoryCalendar::Ptr createDropCalendar(QDropEvent *de);
KCalendarCore::Calendar::Ptr createDropCalendar(QDropEvent *de);
/**
Create the calendar that is contained in the mime data.
*/
static KCalendarCore::MemoryCalendar::Ptr createDropCalendar(const QMimeData *md);
static KCalendarCore::Calendar::Ptr createDropCalendar(const QMimeData *md);
/**
Create the mime data for the whole calendar.
......
......@@ -11,7 +11,7 @@
#include "incidenceformatter.h"
#include "stringify.h"
#include <KCalendarCore/MemoryCalendar>
#include <KCalendarCore/Calendar>
using namespace KCalendarCore;
#include "kcalutils_debug.h"
......@@ -38,19 +38,19 @@ auto returnEndLine()
class KCalUtils::HtmlExportPrivate
{
public:
HtmlExportPrivate(MemoryCalendar *calendar, HTMLExportSettings *settings)
HtmlExportPrivate(Calendar *calendar, HTMLExportSettings *settings)
: mCalendar(calendar)
, mSettings(settings)
{
}
MemoryCalendar *const mCalendar;
Calendar *const mCalendar;
HTMLExportSettings *const mSettings;
QMap<QDate, QString> mHolidayMap;
};
//@endcond
HtmlExport::HtmlExport(MemoryCalendar *calendar, HTMLExportSettings *settings)
HtmlExport::HtmlExport(Calendar *calendar, HTMLExportSettings *settings)
: d(new HtmlExportPrivate(calendar, settings))
{
}
......
......@@ -18,7 +18,7 @@
namespace KCalendarCore
{
class MemoryCalendar;
class Calendar;
}
class QTextStream;
......@@ -36,7 +36,7 @@ public:
/**
Create new HTML exporter for calendar.
*/
HtmlExport(KCalendarCore::MemoryCalendar *calendar, HTMLExportSettings *settings);
HtmlExport(KCalendarCore::Calendar *calendar, HTMLExportSettings *settings);
virtual ~HtmlExport();
/**
......
......@@ -22,7 +22,7 @@ QString ICalDrag::mimeType()
return QStringLiteral("text/calendar");
}
bool ICalDrag::populateMimeData(QMimeData *me, const MemoryCalendar::Ptr &cal)
bool ICalDrag::populateMimeData(QMimeData *me, const Calendar::Ptr &cal)
{
ICalFormat icf;
QString scal = icf.toString(cal, QString(), false);
......@@ -42,7 +42,7 @@ bool ICalDrag::canDecode(const QMimeData *me)
}
}
bool ICalDrag::fromMimeData(const QMimeData *de, const MemoryCalendar::Ptr &cal)
bool ICalDrag::fromMimeData(const QMimeData *de, const Calendar::Ptr &cal)
{
if (!canDecode(de)) {
return false;
......
......@@ -10,7 +10,7 @@
#include "kcalutils_export.h"
#include <KCalendarCore/MemoryCalendar>
#include <KCalendarCore/Calendar>
class QMimeData;
......@@ -29,7 +29,7 @@ Q_REQUIRED_RESULT KCALUTILS_EXPORT QString mimeType();
/**
Sets the iCalendar representation as data of the drag object
*/
Q_REQUIRED_RESULT KCALUTILS_EXPORT bool populateMimeData(QMimeData *e, const KCalendarCore::MemoryCalendar::Ptr &cal);
Q_REQUIRED_RESULT KCALUTILS_EXPORT bool populateMimeData(QMimeData *e, const KCalendarCore::Calendar::Ptr &cal);
/**
Return, if drag&drop object can be decode to iCalendar.
......@@ -39,7 +39,7 @@ Q_REQUIRED_RESULT KCALUTILS_EXPORT bool canDecode(const QMimeData *);
/**
Decode drag&drop object to iCalendar component \a cal.
*/
Q_REQUIRED_RESULT KCALUTILS_EXPORT bool fromMimeData(const QMimeData *e, const KCalendarCore::MemoryCalendar::Ptr &cal);
Q_REQUIRED_RESULT KCALUTILS_EXPORT bool fromMimeData(const QMimeData *e, const KCalendarCore::Calendar::Ptr &cal);
}
}
......@@ -2034,11 +2034,8 @@ Calendar::Ptr InvitationFormatterHelper::calendar() const
return Calendar::Ptr();
}
static QString formatICalInvitationHelper(const QString &invitation,
const MemoryCalendar::Ptr &mCalendar,
InvitationFormatterHelper *helper,
bool noHtmlMode,
const QString &sender)
static QString
formatICalInvitationHelper(const QString &invitation, const Calendar::Ptr &mCalendar, InvitationFormatterHelper *helper, bool noHtmlMode, const QString &sender)
{
if (invitation.isEmpty()) {
return QString();
......@@ -2311,13 +2308,13 @@ static QString formatICalInvitationHelper(const QString &invitation,
//@endcond
QString IncidenceFormatter::formatICalInvitation(const QString &invitation, const MemoryCalendar::Ptr &calendar, InvitationFormatterHelper *helper)
QString IncidenceFormatter::formatICalInvitation(const QString &invitation, const Calendar::Ptr &calendar, InvitationFormatterHelper *helper)
{
return formatICalInvitationHelper(invitation, calendar, helper, false, QString());
}
QString IncidenceFormatter::formatICalInvitationNoHtml(const QString &invitation,
const MemoryCalendar::Ptr &calendar,
const Calendar::Ptr &calendar,
InvitationFormatterHelper *helper,
const QString &sender)
{
......@@ -2337,7 +2334,7 @@ public:
{
}
bool act(const MemoryCalendar::Ptr &calendar, const IncidenceBase::Ptr &incidence, QDate date = QDate(), bool richText = true)
bool act(const Calendar::Ptr &calendar, const IncidenceBase::Ptr &incidence, QDate date = QDate(), bool richText = true)
{
mCalendar = calendar;
mLocation.clear();
......@@ -2375,7 +2372,7 @@ protected:
QString generateToolTip(const Incidence::Ptr &incidence, const QString &dtRangeText);
protected:
MemoryCalendar::Ptr mCalendar;
Calendar::Ptr mCalendar;
QString mLocation;
QDate mDate;
bool mRichText;
......
......@@ -20,8 +20,8 @@
#include "kcalutils_export.h"
#include <KCalendarCore/Calendar>
#include <KCalendarCore/Incidence>
#include <KCalendarCore/MemoryCalendar>
#include <QDate>
class InvitationFormatterHelperPrivate;
......@@ -114,7 +114,7 @@ KCALUTILS_EXPORT QString mailBodyStr(const KCalendarCore::IncidenceBase::Ptr &in
@since 5.23.0
*/
KCALUTILS_EXPORT QString formatICalInvitation(const QString &invitation, const KCalendarCore::MemoryCalendar::Ptr &calendar, InvitationFormatterHelper *helper);
KCALUTILS_EXPORT QString formatICalInvitation(const QString &invitation, const KCalendarCore::Calendar::Ptr &calendar, InvitationFormatterHelper *helper);
/**
Deliver an HTML formatted string displaying an invitation.
......@@ -131,7 +131,7 @@ KCALUTILS_EXPORT QString formatICalInvitation(const QString &invitation, const K
@since 5.23.0
*/
KCALUTILS_EXPORT QString formatICalInvitationNoHtml(const QString &invitation,
const KCalendarCore::MemoryCalendar::Ptr &calendar,
const KCalendarCore::Calendar::Ptr &calendar,
InvitationFormatterHelper *helper,
const QString &sender);
......
......@@ -31,7 +31,7 @@ bool VCalDrag::canDecode(const QMimeData *me)
}
}
bool VCalDrag::fromMimeData(const QMimeData *de, const MemoryCalendar::Ptr &cal)
bool VCalDrag::fromMimeData(const QMimeData *de, const Calendar::Ptr &cal)
{
if (!canDecode(de)) {
return false;
......
......@@ -9,7 +9,7 @@
#pragma once
#include "kcalutils_export.h"
#include <KCalendarCore/MemoryCalendar>
#include <KCalendarCore/Calendar>
class QMimeData;
......@@ -33,7 +33,7 @@ Q_REQUIRED_RESULT KCALUTILS_EXPORT bool canDecode(const QMimeData *);
/**
Decode drag&drop object to vCalendar component \a vcal.
*/
Q_REQUIRED_RESULT KCALUTILS_EXPORT bool fromMimeData(const QMimeData *e, const KCalendarCore::MemoryCalendar::Ptr &cal);
Q_REQUIRED_RESULT KCALUTILS_EXPORT bool fromMimeData(const QMimeData *e, const KCalendarCore::Calendar::Ptr &cal);
}
}
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