/
calendarevent.h
234 lines (211 loc) · 8.02 KB
2
3
* Copyright (c) 2013 - 2019 Jolla Ltd.
* Copyright (c) 2020 - 2021 Open Mobile Platform LLC.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef CALENDAREVENT_H
#define CALENDAREVENT_H
#include <QObject>
#include <QDateTime>
39
40
41
namespace CalendarData {
struct Event;
}
43
class CalendarEvent : public QObject
44
45
{
Q_OBJECT
46
Q_ENUMS(Reminder)
47
48
Q_ENUMS(Secrecy)
Q_ENUMS(Response)
50
51
Q_PROPERTY(QString displayLabel READ displayLabel NOTIFY displayLabelChanged)
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
52
53
Q_PROPERTY(QDateTime startTime READ startTime NOTIFY startTimeChanged)
Q_PROPERTY(QDateTime endTime READ endTime NOTIFY endTimeChanged)
54
55
Q_PROPERTY(Qt::TimeSpec startTimeSpec READ startTimeSpec NOTIFY startTimeChanged)
Q_PROPERTY(Qt::TimeSpec endTimeSpec READ endTimeSpec NOTIFY endTimeChanged)
56
57
Q_PROPERTY(QString startTimeZone READ startTimeZone NOTIFY startTimeChanged)
Q_PROPERTY(QString endTimeZone READ endTimeZone NOTIFY endTimeChanged)
58
Q_PROPERTY(bool allDay READ allDay NOTIFY allDayChanged)
59
Q_PROPERTY(CalendarEvent::Recur recur READ recur NOTIFY recurChanged)
60
61
Q_PROPERTY(QDateTime recurEndDate READ recurEndDate NOTIFY recurEndDateChanged)
Q_PROPERTY(bool hasRecurEndDate READ hasRecurEndDate NOTIFY hasRecurEndDateChanged)
62
Q_PROPERTY(CalendarEvent::Days recurWeeklyDays READ recurWeeklyDays NOTIFY recurWeeklyDaysChanged)
63
Q_PROPERTY(int reminder READ reminder NOTIFY reminderChanged)
64
Q_PROPERTY(QDateTime reminderDateTime READ reminderDateTime NOTIFY reminderDateTimeChanged)
65
Q_PROPERTY(QString instanceId READ instanceId NOTIFY instanceIdChanged)
66
Q_PROPERTY(bool isException READ isException CONSTANT)
67
Q_PROPERTY(bool readOnly READ readOnly CONSTANT)
68
Q_PROPERTY(QString calendarUid READ calendarUid NOTIFY calendarUidChanged)
69
Q_PROPERTY(QString location READ location NOTIFY locationChanged)
70
Q_PROPERTY(CalendarEvent::Secrecy secrecy READ secrecy NOTIFY secrecyChanged)
71
Q_PROPERTY(CalendarEvent::Status status READ status NOTIFY statusChanged)
72
Q_PROPERTY(CalendarEvent::SyncFailure syncFailure READ syncFailure NOTIFY syncFailureChanged)
73
Q_PROPERTY(CalendarEvent::SyncFailureResolution syncFailureResolution READ syncFailureResolution NOTIFY syncFailureResolutionChanged)
74
Q_PROPERTY(CalendarEvent::Response ownerStatus READ ownerStatus NOTIFY ownerStatusChanged)
75
Q_PROPERTY(bool rsvp READ rsvp NOTIFY rsvpChanged)
76
Q_PROPERTY(bool externalInvitation READ externalInvitation NOTIFY externalInvitationChanged)
79
80
81
82
83
enum Recur {
RecurOnce,
RecurDaily,
RecurWeekly,
RecurBiweekly,
84
RecurWeeklyByDays,
85
RecurMonthly,
86
RecurMonthlyByDayOfWeek,
87
RecurMonthlyByLastDayOfWeek,
88
89
90
RecurYearly,
RecurCustom
};
93
94
95
96
97
98
99
100
101
102
103
104
105
enum Day {
NoDays = 0x00,
Monday = 0x01,
Tuesday = 0x02,
Wednesday = 0x04,
Thursday = 0x08,
Friday = 0x10,
Saturday = 0x20,
Sunday = 0x40
};
Q_DECLARE_FLAGS(Days, Day)
Q_FLAG(Days)
106
107
108
109
110
111
112
113
114
115
116
117
118
enum Secrecy {
SecrecyPublic,
SecrecyPrivate,
SecrecyConfidential
};
enum Response {
ResponseUnspecified,
ResponseAccept,
ResponseTentative,
ResponseDecline
};
119
120
enum SyncFailure {
NoSyncFailure,
121
CreationFailure,
122
123
124
125
126
127
UploadFailure,
UpdateFailure,
DeleteFailure
};
Q_ENUM(SyncFailure)
128
129
130
131
132
133
134
135
enum SyncFailureResolution {
RetrySync,
KeepOutOfSync,
PushDeviceData,
PullServerData
};
Q_ENUM(SyncFailureResolution)
136
137
138
139
140
141
142
143
enum Status {
StatusNone,
StatusTentative,
StatusConfirmed,
StatusCancelled
};
Q_ENUM(Status)
144
145
CalendarEvent(const CalendarData::Event *data, QObject *parent);
CalendarEvent(const CalendarEvent *other, QObject *parent);
146
~CalendarEvent();
147
148
149
QString displayLabel() const;
QString description() const;
150
151
virtual QDateTime startTime() const;
virtual QDateTime endTime() const;
152
153
Qt::TimeSpec startTimeSpec() const;
Qt::TimeSpec endTimeSpec() const;
154
155
QString startTimeZone() const;
QString endTimeZone() const;
156
bool allDay() const;
157
Recur recur() const;
158
159
QDateTime recurEndDate() const;
bool hasRecurEndDate() const;
160
Days recurWeeklyDays() const;
161
int reminder() const;
162
QDateTime reminderDateTime() const;
163
QString instanceId() const;
164
bool isException() const;
165
virtual bool readOnly() const;
166
QString calendarUid() const;
167
QString location() const;
168
Secrecy secrecy() const;
169
Status status() const;
170
SyncFailure syncFailure() const;
171
SyncFailureResolution syncFailureResolution() const;
172
173
virtual Response ownerStatus() const;
virtual bool rsvp() const;
174
bool externalInvitation() const;
176
177
178
179
180
signals:
void displayLabelChanged();
void descriptionChanged();
void startTimeChanged();
void endTimeChanged();
181
void allDayChanged();
182
void recurChanged();
183
void reminderChanged();
184
void reminderDateTimeChanged();
185
void instanceIdChanged();
186
void calendarUidChanged();
187
void locationChanged();
188
189
void recurEndDateChanged();
void hasRecurEndDateChanged();
190
void recurWeeklyDaysChanged();
191
void secrecyChanged();
192
void statusChanged();
193
void syncFailureChanged();
194
void syncFailureResolutionChanged();
195
196
void ownerStatusChanged();
void rsvpChanged();
197
void externalInvitationChanged();
199
200
201
202
203
protected:
CalendarData::Event *mData;
};
class CalendarManager;
204
class CalendarEventOccurrence;
205
206
207
208
class CalendarStoredEvent : public CalendarEvent
{
Q_OBJECT
Q_PROPERTY(QString color READ color NOTIFY colorChanged)
209
Q_PROPERTY(CalendarStoredEvent *recurringParent READ parent CONSTANT)
210
211
212
213
public:
CalendarStoredEvent(CalendarManager *manager, const CalendarData::Event *data);
~CalendarStoredEvent();
214
CalendarData::Event dissociateSingleOccurrence(const CalendarEventOccurrence *occurrence) const;
215
void setEvent(const CalendarData::Event *event);
216
CalendarStoredEvent* parent() const;
217
218
219
220
221
222
223
224
225
226
227
QString color() const;
Q_INVOKABLE bool sendResponse(int response);
Q_INVOKABLE QString iCalendar(const QString &prodId = QString()) const;
Q_INVOKABLE void deleteEvent();
signals:
void colorChanged();
private slots:
void notebookColorChanged(QString notebookUid);
228
void instanceIdNotified(QString oldId, QString newId, QString notebookUid);
230
private:
231
CalendarManager *mManager;
232
233
234
};
#endif // CALENDAREVENT_H