/
calendarevent.h
191 lines (174 loc) · 6.77 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
/*
* 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>
class CalendarManager;
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 uniqueId READ uniqueId NOTIFY uniqueIdChanged)
Q_PROPERTY(QString recurrenceId READ recurrenceIdString CONSTANT)
Q_PROPERTY(QString color READ color NOTIFY colorChanged)
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::SyncFailure syncFailure READ syncFailure NOTIFY syncFailureChanged)
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,
UploadFailure,
UpdateFailure,
DeleteFailure
};
Q_ENUM(SyncFailure)
CalendarEvent(CalendarManager *manager, const QString &uid, const QDateTime &recurrenceId);
~CalendarEvent();
QString displayLabel() const;
QString description() const;
QDateTime startTime() const;
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 uniqueId() const;
QString color() const;
bool readOnly() const;
QString calendarUid() const;
QString location() const;
QDateTime recurrenceId() const;
QString recurrenceIdString() const;
Secrecy secrecy() const;
SyncFailure syncFailure() const;
Response ownerStatus() const;
bool rsvp() const;
bool externalInvitation() const;
Q_INVOKABLE bool sendResponse(int response);
Q_INVOKABLE QString iCalendar(const QString &prodId = QString()) const;
Q_INVOKABLE void deleteEvent();
private slots:
void notebookColorChanged(QString notebookUid);
void eventUidChanged(QString oldUid, QString newUid);
signals:
void displayLabelChanged();
void descriptionChanged();
void startTimeChanged();
void endTimeChanged();
void allDayChanged();
void recurChanged();
void reminderChanged();
void reminderDateTimeChanged();
void uniqueIdChanged();
void colorChanged();
void calendarUidChanged();
void locationChanged();
void recurEndDateChanged();
void hasRecurEndDateChanged();
void recurWeeklyDaysChanged();
void secrecyChanged();
void syncFailureChanged();
void ownerStatusChanged();
void rsvpChanged();
void externalInvitationChanged();
private:
CalendarManager *mManager;
QString mUniqueId;
QDateTime mRecurrenceId;
};
#endif // CALENDAREVENT_H