Kgapi

calendar/event.cpp
1 /*
2  * This file is part of LibKGAPI library
3  *
4  * SPDX-FileCopyrightText: 2013 Daniel Vr├ítil <[email protected]>
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 "debug.h"
11 
12 using namespace KGAPI2;
13 
14 namespace
15 {
16 static constexpr const char *EventIdProperty = "EventId";
17 static constexpr const char *EventHangoutLinkProperty = "EventHangoutLink";
18 }
19 
20 class Q_DECL_HIDDEN Event::Private
21 {
22 public:
23  QString id;
24  bool deleted = false;
25  bool useDefaultReminders = false;
26 };
27 
29  : Object()
30  , KCalendarCore::Event()
31  , d(new Private)
32 {
33 }
34 
35 Event::Event(const Event &other)
36  : Object(other)
37  , KCalendarCore::Event(other)
38  , d(new Private(*(other.d)))
39 {
40 }
41 
43  : Object()
44  , KCalendarCore::Event(other)
45  , d(new Private)
46 {
47 }
48 
49 Event::~Event() = default;
50 
51 bool Event::operator==(const Event &other) const
52 {
53  if (!Object::operator==(other)) {
54  return false;
55  }
56  if (!KCalendarCore::Event::operator==(other)) {
57  return false;
58  }
59  if (d->deleted != other.d->deleted) {
60  qCDebug(KGAPIDebug) << "Deleted does not match";
61  return false;
62  }
63  if (d->useDefaultReminders != other.d->useDefaultReminders) {
64  qCDebug(KGAPIDebug) << "UseDefaultReminders does not match";
65  return false;
66  }
67 
68  return true;
69 }
70 
71 bool Event::deleted() const
72 {
73  return d->deleted;
74 }
75 
77 {
78  return d->useDefaultReminders;
79 }
80 
81 void Event::setDeleted(bool deleted)
82 {
83  d->deleted = deleted;
84 }
85 
86 void Event::setUseDefaultReminders(bool useDefault)
87 {
88  d->useDefaultReminders = useDefault;
89 }
90 
92 {
93  const QString val = customProperty("LIBKGAPI", EventIdProperty);
94  if (val.isEmpty()) {
95  // Backwards compatibility: prior to introducing "id", UID was used for
96  // remote identification: use it
98  }
99  return val;
100 }
101 
102 void Event::setId(const QString &id)
103 {
104  setCustomProperty("LIBKGAPI", EventIdProperty, id);
105 }
106 
108 {
109  return customProperty("LIBKGAPI", EventHangoutLinkProperty);
110 }
111 
112 void Event::setHangoutLink(const QString &hangoutLink)
113 {
114  setCustomProperty("LIBKGAPI", EventHangoutLinkProperty, hangoutLink);
115 }
QString id() const
Returns ID used by Google to identify the event in calendar.
bool deleted() const
Returns whether the event was removed.
void setId(const QString &id)
Sets event ID used by Google to identify the event in calendar.
Represents a single event from Google Calendar.
Event()
Constructor.
void setCustomProperty(const QByteArray &app, const QByteArray &key, const QString &value)
Base class for all objects.
Definition: object.h:30
void setDeleted(bool deleted)
Marks the event as deleted.
bool isEmpty() const const
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.
bool useDefaultReminders() const
Returns whether the event should use calendar's default reminders.
A job to fetch a single map tile described by a StaticMapUrl.
Definition: blog.h:15
QString hangoutLink() const
Returns the hangout link for Google Meet.
QString customProperty(const QByteArray &app, const QByteArray &key) const
~Event() override
Destructor.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 04:01:04 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.