Kgapi

calendar.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 "calendar.h"
10 #include "reminder.h"
11 #include "../debug.h"
12 
13 using namespace KGAPI2;
14 
15 class Q_DECL_HIDDEN Calendar::Private
16 {
17  public:
18  Private() = default;
19  Private(const Private &other) = default;
20 
21  QString uid;
22  QString title;
23  QString details;
24  QString timezone;
26  bool editable = false;
27  QColor backgroundColor;
28  QColor foregroundColor;
29 
30  RemindersList reminders;
31 };
32 
34  Object(),
35  d(new Private)
36 {
37 }
38 
40  Object(other),
41  d(new Private(*(other.d.get())))
42 {
43 }
44 
45 Calendar::~Calendar() = default;
46 
47 bool Calendar::operator==(const Calendar &other) const
48 {
49  if (d->uid != other.d->uid) {
50  qCDebug(KGAPIDebug) << "UIDs don't match";
51  return false;
52  }
53  if (d->title != other.d->title) {
54  qCDebug(KGAPIDebug) << "Titles don't match";
55  return false;
56  }
57  if (d->details != other.d->details) {
58  qCDebug(KGAPIDebug) << "Details don't match";
59  return false;
60  }
61  if (d->timezone != other.d->timezone) {
62  qCDebug(KGAPIDebug) << "Timezones don't match";
63  return false;
64  }
65  if (d->location != other.d->location) {
66  qCDebug(KGAPIDebug) << "Locations don't match";
67  return false;
68  }
69  if (d->editable != other.d->editable) {
70  qCDebug(KGAPIDebug) << "Editable doesn't match";
71  return false;
72  }
73  if (d->backgroundColor != other.d->backgroundColor) {
74  qCDebug(KGAPIDebug) << "BackgroundColors don't match";
75  return false;
76  }
77  if (d->foregroundColor != other.d->foregroundColor) {
78  qCDebug(KGAPIDebug) << "ForegroundColors don't match";
79  return false;
80  }
81 
82  for (const auto &reminder : std::as_const(d->reminders)) {
83  if (std::find_if(other.d->reminders.cbegin(), other.d->reminders.cend(),
84  [reminder](const ReminderPtr &otherReminder) {
85  return *reminder == *otherReminder;
86  }) == other.d->reminders.cend()) {
87  qCDebug(KGAPIDebug) << "Reminders don't match";
88  return false;
89  }
90  }
91 
92  return true;
93 }
94 
95 
97 {
98  d->uid = uid;
99 }
100 
102 {
103  return d->uid;
104 }
105 
107 {
108  return d->title;
109 }
110 
112 {
113  d->title = title;
114 }
115 
117 {
118  return d->details;
119 }
120 
122 {
123  d->details = details;
124 }
125 
127 {
128  return d->location;
129 }
130 
132 {
133  d->location = location;
134 }
135 
137 {
138  return d->timezone;
139 }
140 
142 {
143  d->timezone = timezone;
144 }
145 
146 bool Calendar::editable() const
147 {
148  return d->editable;
149 }
150 
152 {
153  d->editable = editable;
154 }
155 
157 {
158  d->reminders = reminders;
159 }
160 
162 {
163  d->reminders.append(reminder);
164 }
165 
167 {
168  return d->reminders;
169 }
170 
172 {
173  return d->backgroundColor;
174 }
175 
177 {
178  d->backgroundColor = color;
179 }
180 
182 {
183  return d->foregroundColor;
184 }
185 
187 {
188  d->foregroundColor = color;
189 }
void setDefaultReminders(const RemindersList &reminders)
Sets default reminders for all new events in the calendar.
Definition: calendar.cpp:156
Base class for all objects.
Definition: object.h:30
QString title() const
Returns calendar title (name).
Definition: calendar.cpp:106
QString uid() const
Returns uID of the calendar.
Definition: calendar.cpp:101
void setLocation(const QString &location)
Sets geographic location of the calendar.
Definition: calendar.cpp:131
QVariant location(const QVariant &res)
~Calendar() override
Destructor.
QColor backgroundColor() const
Returns calendar background color.
Definition: calendar.cpp:171
RemindersList defaultReminders() const
Returns default reminders for all events in the calendar.
Definition: calendar.cpp:166
Calendar()
Constructor.
Definition: calendar.cpp:33
QString details() const
Returns detailed description of the calendar.
Definition: calendar.cpp:116
void setDetails(const QString &details)
Sets detailed description of a calendar.
Definition: calendar.cpp:121
bool editable() const
Returns whether calendar is editable or read-only.
Definition: calendar.cpp:146
QString location() const
Returns geographic location of the calendar.
Definition: calendar.cpp:126
A job to fetch a single map tile described by a StaticMapUrl.
Definition: blog.h:15
void setEditable(const bool editable)
Sets calendar to read-only or editable.
Definition: calendar.cpp:151
QColor foregroundColor() const
Returns calendar foreground color.
Definition: calendar.cpp:181
void setUid(const QString &uid)
Sets UID of the calendar.
Definition: calendar.cpp:96
void setTimezone(const QString &timezone)
Sets timezone of the calendar.
Definition: calendar.cpp:141
void setBackgroundColor(const QColor &color)
Sets calendar background color.
Definition: calendar.cpp:176
void setForegroundColor(const QColor &color)
Sets calendar foreground color.
Definition: calendar.cpp:186
void setTitle(const QString &title)
Sets a calendar title (name).
Definition: calendar.cpp:111
void addDefaultReminer(const ReminderPtr &reminder)
Adds a default reminder for all events in the calendar.
Definition: calendar.cpp:161
An object that represents a Google calendar.
Definition: calendar.h:27
QString timezone() const
Returns timezone of the calendar.
Definition: calendar.cpp:136
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Oct 24 2021 23:11:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.