Kgapi

calendar.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 "calendar.h"
10#include "debug.h"
11#include "reminder.h"
12
13using namespace KGAPI2;
14
15class Q_DECL_HIDDEN Calendar::Private
16{
17public:
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
45Calendar::~Calendar() = default;
46
47bool 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(),
84 other.d->reminders.cend(),
85 [reminder](const ReminderPtr &otherReminder) {
86 return *reminder == *otherReminder;
87 })
88 == other.d->reminders.cend()) {
89 qCDebug(KGAPIDebug) << "Reminders don't match";
90 return false;
91 }
92 }
93
94 return true;
95}
96
97void Calendar::setUid(const QString &uid)
98{
99 d->uid = uid;
100}
101
103{
104 return d->uid;
105}
106
108{
109 return d->title;
110}
111
112void Calendar::setTitle(const QString &title)
113{
114 d->title = title;
115}
116
118{
119 return d->details;
120}
121
122void Calendar::setDetails(const QString &details)
123{
124 d->details = details;
125}
126
128{
129 return d->location;
130}
131
132void Calendar::setLocation(const QString &location)
133{
134 d->location = location;
135}
136
138{
139 return d->timezone;
140}
141
142void Calendar::setTimezone(const QString &timezone)
143{
144 d->timezone = timezone;
145}
146
148{
149 return d->editable;
150}
151
152void Calendar::setEditable(const bool editable)
153{
154 d->editable = editable;
155}
156
158{
159 d->reminders = reminders;
160}
161
163{
164 d->reminders.append(reminder);
165}
166
168{
169 return d->reminders;
170}
171
173{
174 return d->backgroundColor;
175}
176
178{
179 d->backgroundColor = color;
180}
181
183{
184 return d->foregroundColor;
185}
186
188{
189 d->foregroundColor = color;
190}
An object that represents a Google calendar.
Definition calendar.h:28
QString location() const
Returns geographic location of the calendar.
Definition calendar.cpp:127
void setBackgroundColor(const QColor &color)
Sets calendar background color.
Definition calendar.cpp:177
QColor foregroundColor() const
Returns calendar foreground color.
Definition calendar.cpp:182
QString timezone() const
Returns timezone of the calendar.
Definition calendar.cpp:137
void setForegroundColor(const QColor &color)
Sets calendar foreground color.
Definition calendar.cpp:187
void setEditable(const bool editable)
Sets calendar to read-only or editable.
Definition calendar.cpp:152
void setDetails(const QString &details)
Sets detailed description of a calendar.
Definition calendar.cpp:122
Calendar()
Constructor.
Definition calendar.cpp:33
RemindersList defaultReminders() const
Returns default reminders for all events in the calendar.
Definition calendar.cpp:167
bool editable() const
Returns whether calendar is editable or read-only.
Definition calendar.cpp:147
QString title() const
Returns calendar title (name).
Definition calendar.cpp:107
void setDefaultReminders(const RemindersList &reminders)
Sets default reminders for all new events in the calendar.
Definition calendar.cpp:157
void setTimezone(const QString &timezone)
Sets timezone of the calendar.
Definition calendar.cpp:142
void setLocation(const QString &location)
Sets geographic location of the calendar.
Definition calendar.cpp:132
QString details() const
Returns detailed description of the calendar.
Definition calendar.cpp:117
~Calendar() override
Destructor.
void addDefaultReminer(const ReminderPtr &reminder)
Adds a default reminder for all events in the calendar.
Definition calendar.cpp:162
QString uid() const
Returns uID of the calendar.
Definition calendar.cpp:102
void setUid(const QString &uid)
Sets UID of the calendar.
Definition calendar.cpp:97
QColor backgroundColor() const
Returns calendar background color.
Definition calendar.cpp:172
void setTitle(const QString &title)
Sets a calendar title (name).
Definition calendar.cpp:112
Base class for all objects.
Definition object.h:31
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
QVariant location(const QVariant &res)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:51 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.