diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,6 +6,8 @@ attachment.cpp attendee.cpp calendar.cpp + calendarentry.cpp + calendarplugin.cpp calfilter.cpp calformat.cpp calstorage.cpp @@ -85,6 +87,8 @@ CalFormat CalStorage Calendar + CalendarEntry + CalendarPlugin CustomProperties Duration Event diff --git a/src/calendarentry.h b/src/calendarentry.h new file mode 100644 --- /dev/null +++ b/src/calendarentry.h @@ -0,0 +1,113 @@ +/* + This file is part of the kcalcore library. + + Copyright (c) 2019 Nicolas Fella + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#pragma once + +#include + +#include + +namespace KCalendarCore +{ + +class CalendarEntryPrivate; + +/** + * Wraps a Calendar::Ptr with some associated metadata. + */ +class Q_DECL_EXPORT CalendarEntry : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString id READ id CONSTANT) + Q_PROPERTY(QString name READ name CONSTANT) + Q_PROPERTY(QString icon READ icon CONSTANT) + Q_PROPERTY(CalendarType type READ type CONSTANT) +public: + + /** + * Type of calendar, i.e. whether it can be written to or is read only. + */ + enum CalendarType + { + ReadOnly, + ReadWrite + }; + Q_ENUM(CalendarType) + + typedef QSharedPointer Ptr; + + /** + * Creates a new CalendarEntry. + * + * The backing calendar needs to be set using setCalendar(). + * + * @param id A per-plugin unique id for this entry. + * @param name A user-visible name for this entry; + * @param icon The name of an icon for this entry. + * @param type This entry's type. + */ + CalendarEntry(const QString &id, const QString &name, const QString &icon, CalendarType type); + + virtual ~CalendarEntry(); + + /** + * The calendar this entry wraps + */ + KCalendarCore::Calendar::Ptr calendar() const; + + /** + * Set the calendar this entry wraps. + */ + void setCalendar(const KCalendarCore::Calendar::Ptr calendar); + + /** + * The user-visible name of this entry. + */ + QString name() const; + + /** + * This entry's type, i.e. whether it can be written to or is read only. + */ + CalendarType type() const; + + /** + * This entry's icon. + */ + QString icon() const; + + /** + * A per-plugin unique id for this entry. + */ + QString id() const; + + /** + * Synchronize the calendar with it's datasource. + * The behavior is implementation-specific. + * Typical behavior would be e.g. synchronization + * with a remote server. + */ + virtual void synchronize(); + +private: + CalendarEntryPrivate *d; +}; + +} diff --git a/src/calendarentry.cpp b/src/calendarentry.cpp new file mode 100644 --- /dev/null +++ b/src/calendarentry.cpp @@ -0,0 +1,74 @@ +/* + This file is part of the kcalcore library. + + Copyright (c) 2019 Nicolas Fella + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "calendarentry.h" +#include "calendarentry_p.h" + +using namespace KCalendarCore; + +CalendarEntry::CalendarEntry(const QString &id, const QString &name, const QString &icon, CalendarType type) + : d(new CalendarEntryPrivate) +{ + d->m_id = id; + d->m_name = name; + d->m_icon = icon; + d->m_type = type; +} + +CalendarEntry::~CalendarEntry() +{ + delete d; +} + + +QString CalendarEntry::name() const +{ + return d->m_name; +} + +KCalendarCore::Calendar::Ptr CalendarEntry::calendar() const +{ + return d->m_calendar; +} + +void CalendarEntry::setCalendar(const KCalendarCore::Calendar::Ptr calendar) +{ + d->m_calendar = calendar; +} + +CalendarEntry::CalendarType CalendarEntry::type() const +{ + return ReadWrite; +} + +QString CalendarEntry::icon() const +{ + return d->m_icon; +} + +QString CalendarEntry::id() const +{ + return d->m_id; +} + +void CalendarEntry::synchronize() +{ +} diff --git a/src/calendarentry_p.h b/src/calendarentry_p.h new file mode 100644 --- /dev/null +++ b/src/calendarentry_p.h @@ -0,0 +1,39 @@ +/* + This file is part of the kcalcore library. + + Copyright (c) 2019 Nicolas Fella + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#pragma once + +#include "calendarentry.h" + +namespace KCalendarCore +{ + +class CalendarEntryPrivate +{ +public: + QString m_id; + QString m_name; + QString m_icon; + CalendarEntry::CalendarType m_type; + KCalendarCore::Calendar::Ptr m_calendar; +}; + +} diff --git a/src/calendarplugin.h b/src/calendarplugin.h new file mode 100644 --- /dev/null +++ b/src/calendarplugin.h @@ -0,0 +1,59 @@ +/* + This file is part of the kcalcore library. + + Copyright (c) 2019 Nicolas Fella + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#pragma once + +#include +#include "calendarentry.h" + +namespace KCalendarCore +{ +/** + @brief + A plugin that provides calendar data. + + It allows calendar applications to consume data provided by multiple + sources, e.g. local ical files or remote calendars. +*/ +class Q_DECL_EXPORT CalendarPlugin : public QObject +{ + Q_OBJECT +public: + CalendarPlugin(QObject *parent, const QVariantList &args); + + /** + * The set of calendars defined by this plugin. + * + * @return QVector of calendarEntrys. + */ + virtual QVector calendars() const = 0; + +Q_SIGNALS: + /** + * Emitted when the set of calendars changed. + */ + void calendarsChanged(); + +private: + void *d; +}; + +} diff --git a/src/calendarplugin.cpp b/src/calendarplugin.cpp new file mode 100644 --- /dev/null +++ b/src/calendarplugin.cpp @@ -0,0 +1,30 @@ +/* + This file is part of the kcalcore library. + + Copyright (c) 2019 Nicolas Fella + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "calendarplugin.h" + +using namespace KCalendarCore; + +CalendarPlugin::CalendarPlugin(QObject *parent, const QVariantList &args) + : QObject(parent) +{ + Q_UNUSED(args) +}