Kgapi

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 static constexpr const char *EventIdProperty = "EventId";
16 }
17 
18 class Q_DECL_HIDDEN Event::Private
19 {
20  public:
21  QString id;
22  bool deleted = false;
23  bool useDefaultReminders = false;
24 };
25 
27  Object(),
29  d(new Private)
30 {
31 }
32 
33 Event::Event(const Event &other):
34  Object(other),
35  KCalendarCore::Event(other),
36  d(new Private(*(other.d)))
37 {
38 }
39 
41  Object(),
42  KCalendarCore::Event(other),
43  d(new Private)
44 {
45 }
46 
47 Event::~Event()= default;
48 
49 bool Event::operator==(const Event &other) const
50 {
51  if (!Object::operator==(other)) {
52  return false;
53  }
54  if (!KCalendarCore::Event::operator==(other)) {
55  return false;
56  }
57  if (d->deleted != other.d->deleted) {
58  qCDebug(KGAPIDebug) << "Deleted does not match";
59  return false;
60  }
61  if (d->useDefaultReminders != other.d->useDefaultReminders) {
62  qCDebug(KGAPIDebug) << "UseDefaultReminders does not match";
63  return false;
64  }
65 
66  return true;
67 }
68 
69 
70 bool Event::deleted() const
71 {
72  return d->deleted;
73 }
74 
76 {
77  return d->useDefaultReminders;
78 }
79 
81 {
82  d->deleted = deleted;
83 }
84 
85 void Event::setUseDefaultReminders(bool useDefault)
86 {
87  d->useDefaultReminders = useDefault;
88 }
89 
91 {
92  const QString val = customProperty("LIBKGAPI", EventIdProperty);
93  if (val.isEmpty()) {
94  // Backwards compatibility: prior to introducing "id", UID was used for
95  // remote identification: use it
97  }
98  return val;
99 }
100 
101 void Event::setId(const QString &id)
102 {
103  setCustomProperty("LIBKGAPI", EventIdProperty, id);
104 }
Base class for all objects.
Definition: object.h:31
void setUseDefaultReminders(bool useDefault)
Sets whether the event should use calendar&#39;s default reminders.
Definition: event.cpp:85
void setDeleted(bool deleted)
Marks the event as deleted.
Definition: event.cpp:80
~Event()
Destructor.
bool isEmpty() const const
A job to fetch a single map tile described by a StaticMapUrl.
Definition: blog.h:16
Represents a single event from Google Calendar.
Definition: event.h:29
QString customProperty(const QByteArray &app, const QByteArray &key) const
void setId(const QString &id)
Sets event ID used by Google to identify the event in calendar.
Definition: event.cpp:101
bool deleted() const
Returns whether the event was removed.
Definition: event.cpp:70
bool useDefaultReminders() const
Returns whether the event should use calendar&#39;s default reminders.
Definition: event.cpp:75
Event()
Constructor.
Definition: event.cpp:26
QString id() const
Returns ID used by Google to identify the event in calendar.
Definition: event.cpp:90
void setCustomProperty(const QByteArray &app, const QByteArray &key, const QString &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 02:56:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.