/
calendarevent.h
234 lines (211 loc) · 8.02 KB
/
calendarevent.h
1
2
3
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
* Copyright (c) 2013 - 2019 Jolla Ltd.
* Copyright (c) 2020 - 2021 Open Mobile Platform LLC.
*
* 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>
namespace CalendarData {
struct Event;
}
class CalendarEvent : public QObject
{
Q_OBJECT
Q_ENUMS(Reminder)
Q_ENUMS(Secrecy)
Q_ENUMS(Response)
Q_PROPERTY(QString displayLabel READ displayLabel NOTIFY displayLabelChanged)
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
Q_PROPERTY(QDateTime startTime READ startTime NOTIFY startTimeChanged)
Q_PROPERTY(QDateTime endTime READ endTime NOTIFY endTimeChanged)
Q_PROPERTY(Qt::TimeSpec startTimeSpec READ startTimeSpec NOTIFY startTimeChanged)
Q_PROPERTY(Qt::TimeSpec endTimeSpec READ endTimeSpec NOTIFY endTimeChanged)
Q_PROPERTY(QString startTimeZone READ startTimeZone NOTIFY startTimeChanged)
Q_PROPERTY(QString endTimeZone READ endTimeZone NOTIFY endTimeChanged)
Q_PROPERTY(bool allDay READ allDay NOTIFY allDayChanged)
Q_PROPERTY(CalendarEvent::Recur recur READ recur NOTIFY recurChanged)
Q_PROPERTY(QDateTime recurEndDate READ recurEndDate NOTIFY recurEndDateChanged)
Q_PROPERTY(bool hasRecurEndDate READ hasRecurEndDate NOTIFY hasRecurEndDateChanged)
Q_PROPERTY(CalendarEvent::Days recurWeeklyDays READ recurWeeklyDays NOTIFY recurWeeklyDaysChanged)
Q_PROPERTY(int reminder READ reminder NOTIFY reminderChanged)
Q_PROPERTY(QDateTime reminderDateTime READ reminderDateTime NOTIFY reminderDateTimeChanged)
Q_PROPERTY(QString instanceId READ instanceId NOTIFY instanceIdChanged)
Q_PROPERTY(bool isException READ isException CONSTANT)
Q_PROPERTY(bool readOnly READ readOnly CONSTANT)
Q_PROPERTY(QString calendarUid READ calendarUid NOTIFY calendarUidChanged)
Q_PROPERTY(QString location READ location NOTIFY locationChanged)
Q_PROPERTY(CalendarEvent::Secrecy secrecy READ secrecy NOTIFY secrecyChanged)
Q_PROPERTY(CalendarEvent::Status status READ status NOTIFY statusChanged)
Q_PROPERTY(CalendarEvent::SyncFailure syncFailure READ syncFailure NOTIFY syncFailureChanged)
Q_PROPERTY(CalendarEvent::SyncFailureResolution syncFailureResolution READ syncFailureResolution NOTIFY syncFailureResolutionChanged)
Q_PROPERTY(CalendarEvent::Response ownerStatus READ ownerStatus NOTIFY ownerStatusChanged)
Q_PROPERTY(bool rsvp READ rsvp NOTIFY rsvpChanged)
Q_PROPERTY(bool externalInvitation READ externalInvitation NOTIFY externalInvitationChanged)
public:
enum Recur {
RecurOnce,
RecurDaily,
RecurWeekly,
RecurBiweekly,
RecurWeeklyByDays,
RecurMonthly,
RecurMonthlyByDayOfWeek,
RecurMonthlyByLastDayOfWeek,
RecurYearly,
RecurCustom
};
Q_ENUM(Recur)
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)
enum Secrecy {
SecrecyPublic,
SecrecyPrivate,
SecrecyConfidential
};
enum Response {
ResponseUnspecified,
ResponseAccept,
ResponseTentative,
ResponseDecline
};
enum SyncFailure {
NoSyncFailure,
CreationFailure,
UploadFailure,
UpdateFailure,
DeleteFailure
};
Q_ENUM(SyncFailure)
enum SyncFailureResolution {
RetrySync,
KeepOutOfSync,
PushDeviceData,
PullServerData
};
Q_ENUM(SyncFailureResolution)
enum Status {
StatusNone,
StatusTentative,
StatusConfirmed,
StatusCancelled
};
Q_ENUM(Status)
CalendarEvent(const CalendarData::Event *data, QObject *parent);
CalendarEvent(const CalendarEvent *other, QObject *parent);
~CalendarEvent();
QString displayLabel() const;
QString description() const;
virtual QDateTime startTime() const;
virtual QDateTime endTime() const;
Qt::TimeSpec startTimeSpec() const;
Qt::TimeSpec endTimeSpec() const;
QString startTimeZone() const;
QString endTimeZone() const;
bool allDay() const;
Recur recur() const;
QDateTime recurEndDate() const;
bool hasRecurEndDate() const;
Days recurWeeklyDays() const;
int reminder() const;
QDateTime reminderDateTime() const;
QString instanceId() const;
bool isException() const;
virtual bool readOnly() const;
QString calendarUid() const;
QString location() const;
Secrecy secrecy() const;
Status status() const;
SyncFailure syncFailure() const;
SyncFailureResolution syncFailureResolution() const;
virtual Response ownerStatus() const;
virtual bool rsvp() const;
bool externalInvitation() const;
signals:
void displayLabelChanged();
void descriptionChanged();
void startTimeChanged();
void endTimeChanged();
void allDayChanged();
void recurChanged();
void reminderChanged();
void reminderDateTimeChanged();
void instanceIdChanged();
void calendarUidChanged();
void locationChanged();
void recurEndDateChanged();
void hasRecurEndDateChanged();
void recurWeeklyDaysChanged();
void secrecyChanged();
void statusChanged();
void syncFailureChanged();
void syncFailureResolutionChanged();
void ownerStatusChanged();
void rsvpChanged();
void externalInvitationChanged();
protected:
CalendarData::Event *mData;
};
class CalendarManager;
class CalendarEventOccurrence;
class CalendarStoredEvent : public CalendarEvent
{
Q_OBJECT
Q_PROPERTY(QString color READ color NOTIFY colorChanged)
Q_PROPERTY(CalendarStoredEvent *recurringParent READ parent CONSTANT)
public:
CalendarStoredEvent(CalendarManager *manager, const CalendarData::Event *data);
~CalendarStoredEvent();
CalendarData::Event dissociateSingleOccurrence(const CalendarEventOccurrence *occurrence) const;
void setEvent(const CalendarData::Event *event);
CalendarStoredEvent* parent() const;
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);
void instanceIdNotified(QString oldId, QString newId, QString notebookUid);
private:
CalendarManager *mManager;
};
#endif // CALENDAREVENT_H