Kgapi

calendar/event.cpp
1/*
2 * This file is part of LibKGAPI library
3 *
4 * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "event.h"
10#include "calendarservice.h"
11#include "debug.h"
12
13using namespace KGAPI2;
14
15namespace
16{
17static constexpr const char *EventIdProperty = "EventId";
18static constexpr const char *EventHangoutLinkProperty = "EventHangoutLink";
19static constexpr const char *EventTypeProperty = "EventType";
20}
21
22class Q_DECL_HIDDEN Event::Private
23{
24public:
25 bool deleted = false;
26 bool useDefaultReminders = false;
27};
28
30 : Object()
32 , d(new Private)
33{
34}
35
36Event::Event(const Event &other)
37 : Object(other)
38 , KCalendarCore::Event(other)
39 , d(new Private(*(other.d)))
40{
41}
42
44 : Object()
45 , KCalendarCore::Event(other)
46 , d(new Private)
47{
48}
49
50Event::~Event() = default;
51
52bool Event::operator==(const Event &other) const
53{
54 if (!Object::operator==(other)) {
55 return false;
56 }
57 if (!KCalendarCore::Event::operator==(other)) {
58 return false;
59 }
60 if (d->deleted != other.d->deleted) {
61 qCDebug(KGAPIDebug) << "Deleted does not match";
62 return false;
63 }
64 if (d->useDefaultReminders != other.d->useDefaultReminders) {
65 qCDebug(KGAPIDebug) << "UseDefaultReminders does not match";
66 return false;
67 }
68
69 return true;
70}
71
72bool Event::deleted() const
73{
74 return d->deleted;
75}
76
78{
79 return d->useDefaultReminders;
80}
81
82void Event::setDeleted(bool deleted)
83{
84 d->deleted = deleted;
85}
86
87void Event::setUseDefaultReminders(bool useDefault)
88{
89 d->useDefaultReminders = useDefault;
90}
91
93{
94 const QString val = customProperty("LIBKGAPI", EventIdProperty);
95 if (val.isEmpty()) {
96 // Backwards compatibility: prior to introducing "id", UID was used for
97 // remote identification: use it
99 }
100 return val;
101}
102
103void Event::setId(const QString &id)
104{
105 setCustomProperty("LIBKGAPI", EventIdProperty, id);
106}
107
109{
110 return customProperty("LIBKGAPI", EventHangoutLinkProperty);
111}
112
113void Event::setHangoutLink(const QString &hangoutLink)
114{
115 setCustomProperty("LIBKGAPI", EventHangoutLinkProperty, hangoutLink);
116}
117
118Event::EventType Event::eventType() const
119{
120 return CalendarService::eventTypeFromString(customProperty("LIBKGAPI", EventTypeProperty));
121}
122
123void Event::setEventType(EventType type)
124{
125 setCustomProperty("LIBKGAPI", EventTypeProperty, CalendarService::eventTypeToString(type));
126}
void setCustomProperty(const QByteArray &app, const QByteArray &key, const QString &value)
QString customProperty(const QByteArray &app, const QByteArray &key) const
IncidenceType type() const override
Represents a single event from Google Calendar.
void setId(const QString &id)
Sets event ID used by Google to identify the event in calendar.
void setDeleted(bool deleted)
Marks the event as deleted.
Event()
Constructor.
bool useDefaultReminders() const
Returns whether the event should use calendar's default reminders.
bool deleted() const
Returns whether the event was removed.
QString hangoutLink() const
Returns the hangout link for Google Meet.
void setEventType(EventType eventType)
Sets the type of the event.
EventType eventType() const
Returns the type of the event.
void setUseDefaultReminders(bool useDefault)
Sets whether the event should use calendar's default reminders.
void setHangoutLink(const QString &id)
Sets the hangout link for Google Meet.
QString id() const
Returns ID used by Google to identify the event in calendar.
~Event() override
Destructor.
Base class for all objects.
Definition object.h:31
QString eventTypeToString(Event::EventType eventType)
Converts event type enum value to string.
Event::EventType eventTypeFromString(const QString &eventType)
Converts event type string to enum value.
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:59:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.