Index: src/CMakeLists.txt =================================================================== --- src/CMakeLists.txt +++ src/CMakeLists.txt @@ -6,6 +6,8 @@ attachment.cpp attendee.cpp calendar.cpp + calendarentry.cpp + calendarplugin.cpp calfilter.cpp calformat.cpp calstorage.cpp @@ -78,6 +80,8 @@ CalFormat CalStorage Calendar + CalendarEntry + CalendarPlugin CustomProperties Duration Event Index: src/calendarentry.h =================================================================== --- /dev/null +++ src/calendarentry.h @@ -0,0 +1,66 @@ +/* + 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 + +class CalendarEntryPrivate; + +class Q_DECL_EXPORT CalendarEntry : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString id READ id CONSTANT) + Q_PROPERTY(QString description READ description CONSTANT) + Q_PROPERTY(QString icon READ icon CONSTANT) + Q_PROPERTY(CalendarType type READ type CONSTANT) + Q_PROPERTY(KCalendarCore::Calendar::Ptr calendar READ calendar CONSTANT) +public: + + enum CalendarType + { + ReadOnly, + ReadWrite + }; + Q_ENUM(CalendarType) + + typedef QSharedPointer Ptr; + + CalendarEntry(const QString &id, const QString &description, const QString &icon, CalendarType type, KCalendarCore::Calendar::Ptr calendar); + ~CalendarEntry(); + + KCalendarCore::Calendar::Ptr calendar() const; + QString description() const; + CalendarType type() const; + QString icon() const; + QString id() const; + +public Q_SLOTS: + void sync(); + +Q_SIGNALS: + void syncRequested(); + +private: + CalendarEntryPrivate *d; +}; + +Q_DECLARE_METATYPE(CalendarEntry::Ptr) Index: src/calendarentry.cpp =================================================================== --- /dev/null +++ src/calendarentry.cpp @@ -0,0 +1,67 @@ +/* + 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" + +CalendarEntry::CalendarEntry(const QString &id, const QString &description, const QString &icon, CalendarType type, KCalendarCore::Calendar::Ptr calendar) + : d(new CalendarEntryPrivate) +{ + d->m_id = id; + d->m_description = description; + d->m_icon = icon; + d->m_type = type; + d->m_calendar = calendar; +} + +CalendarEntry::~CalendarEntry() +{ +} + +QString CalendarEntry::description() const +{ + return d->m_description; +} + +KCalendarCore::Calendar::Ptr CalendarEntry::calendar() const +{ + return d->m_calendar; +} + +void CalendarEntry::sync() +{ + Q_EMIT syncRequested(); +} + +CalendarEntry::CalendarType CalendarEntry::type() const +{ + return ReadWrite; +} + +QString CalendarEntry::icon() const +{ + return d->m_icon; +} + +QString CalendarEntry::id() const +{ + return d->m_id; +} Index: src/calendarentry_p.h =================================================================== --- /dev/null +++ src/calendarentry_p.h @@ -0,0 +1,34 @@ +/* + 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" + +class CalendarEntryPrivate +{ +public: + QString m_id; + QString m_description; + QString m_icon; + CalendarEntry::CalendarType m_type; + KCalendarCore::Calendar::Ptr m_calendar; +}; Index: src/calendarplugin.h =================================================================== --- /dev/null +++ src/calendarplugin.h @@ -0,0 +1,40 @@ +/* + 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" + +class Q_DECL_EXPORT CalendarPlugin : public QObject +{ + Q_OBJECT +public: + CalendarPlugin(QObject *parent, const QVariantList args); + + virtual std::vector calendars() const; + +Q_SIGNALS: + void calendarsChanged(); + +private: + void *d; +}; Index: src/calendarplugin.cpp =================================================================== --- /dev/null +++ src/calendarplugin.cpp @@ -0,0 +1,33 @@ +/* + 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" + +CalendarPlugin::CalendarPlugin(QObject *parent, const QVariantList args) + : QObject(parent) +{ + Q_UNUSED(args) +} + +std::vector CalendarPlugin::calendars() const +{ + return {}; +}