File indexing completed on 2025-01-05 04:54:59

0001 /*
0002  *  Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
0003  *  Copyright (C) 2018 Christian Mollekopf, <mollekopf@kolabsys.com>
0004  *
0005  *  This program is free software; you can redistribute it and/or modify
0006  *  it under the terms of the GNU General Public License as published by
0007  *  the Free Software Foundation; either version 2 of the License, or
0008  *  (at your option) any later version.
0009  *
0010  *  This program is distributed in the hope that it will be useful,
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0013  *  GNU General Public License for more details.
0014  *
0015  *  You should have received a copy of the GNU General Public License along
0016  *  with this program; if not, write to the Free Software Foundation, Inc.,
0017  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 
0021 #pragma once
0022 #include "kube_export.h"
0023 
0024 #include <QString>
0025 #include <QDateTime>
0026 
0027 #include <sink/applicationdomaintype.h>
0028 
0029 #include "controller.h"
0030 #include "completer.h"
0031 #include "selector.h"
0032 
0033 namespace KCalendarCore {
0034     class Event;
0035 };
0036 
0037 class KUBE_EXPORT EventController : public Kube::Controller
0038 {
0039     Q_OBJECT
0040 
0041     // Input properties
0042     KUBE_CONTROLLER_PROPERTY(QVariant, EventOccurrence, eventOccurrence)
0043 
0044     //Interface properties
0045     KUBE_CONTROLLER_PROPERTY(QByteArray, AccountId, accountId)
0046     KUBE_CONTROLLER_PROPERTY(QString, Summary, summary)
0047     KUBE_CONTROLLER_PROPERTY(QString, Description, description)
0048     KUBE_CONTROLLER_PROPERTY(QString, Location, location)
0049     KUBE_CONTROLLER_PROPERTY(QDateTime, Start, start)
0050     KUBE_CONTROLLER_PROPERTY(QDateTime, End, end)
0051     KUBE_CONTROLLER_PROPERTY(QString, RecurrenceString, recurrenceString)
0052     KUBE_CONTROLLER_PROPERTY(bool, AllDay, allDay)
0053     KUBE_CONTROLLER_PROPERTY(bool, Recurring, recurring)
0054     KUBE_CONTROLLER_PROPERTY(bool, OurEvent, ourEvent)
0055     KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::ApplicationDomainType::Ptr, Calendar, calendar)
0056 
0057     KUBE_CONTROLLER_PROPERTY(QString, Organizer, organizer)
0058     KUBE_CONTROLLER_LISTCONTROLLER(attendees)
0059 
0060     Q_PROPERTY (Completer* attendeeCompleter READ attendeeCompleter CONSTANT)
0061     Q_PROPERTY (Selector* identitySelector READ identitySelector CONSTANT)
0062 
0063     KUBE_CONTROLLER_ACTION(save)
0064 
0065 public:
0066     enum ParticipantStatus {
0067         Unknown,
0068         Accepted,
0069         Declined,
0070         Cancelled, //This is not part of the usual partstat in ical, but for our purposes where it belongs
0071         NoMatch
0072     };
0073     Q_ENUM(ParticipantStatus);
0074 
0075     explicit EventController();
0076 
0077     void init() override;
0078     Q_INVOKABLE void remove();
0079     Q_INVOKABLE void reload();
0080 
0081     Completer *attendeeCompleter() const;
0082     Selector *identitySelector() const;
0083 
0084     static QString eventToBody(const KCalendarCore::Event &event);
0085 
0086 protected:
0087     void populateFromEvent(const KCalendarCore::Event &event);
0088     void saveToEvent(KCalendarCore::Event &event);
0089 
0090 private slots:
0091     void updateSaveAction();
0092 
0093 private:
0094     QScopedPointer<Completer> mAttendeeCompleter;
0095     QScopedPointer<Selector> mIdentitySelector;
0096 };