1 | /* |
2 | This file is part of the kcalcore library. |
3 | |
4 | Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org> |
5 | |
6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | /** |
22 | @file |
23 | This file is part of the API for handling calendar data and |
24 | defines the Event class. |
25 | |
26 | @author Cornelius Schumacher \<schumacher@kde.org\> |
27 | */ |
28 | #ifndef KCALCORE_EVENT_H |
29 | #define KCALCORE_EVENT_H |
30 | |
31 | #include "kcalcore_export.h" |
32 | #include "incidence.h" |
33 | #include "supertrait.h" |
34 | |
35 | namespace KCalCore { |
36 | |
37 | /** |
38 | @brief |
39 | This class provides an Event in the sense of RFC2445. |
40 | */ |
41 | class KCALCORE_EXPORT Event : public Incidence |
42 | { |
43 | public: |
44 | /** |
45 | The different Event transparency types. |
46 | */ |
47 | enum Transparency { |
48 | Opaque, /**< Event appears in free/busy time */ |
49 | Transparent /**< Event does @b not appear in free/busy time */ |
50 | }; |
51 | |
52 | /** |
53 | A shared pointer to an Event object. |
54 | */ |
55 | typedef QSharedPointer<Event> Ptr; |
56 | |
57 | /** |
58 | List of events. |
59 | */ |
60 | typedef QVector<Ptr> List; |
61 | |
62 | /** |
63 | Constructs an event. |
64 | */ |
65 | Event(); |
66 | |
67 | /** |
68 | Copy constructor. |
69 | @param other is the event to copy. |
70 | */ |
71 | Event(const Event &other); |
72 | |
73 | /** |
74 | Destroys the event. |
75 | */ |
76 | ~Event(); |
77 | |
78 | /** |
79 | @copydoc |
80 | IncidenceBase::type() |
81 | */ |
82 | IncidenceType type() const; |
83 | |
84 | /** |
85 | @copydoc |
86 | IncidenceBase::typeStr() |
87 | */ |
88 | QByteArray typeStr() const; |
89 | |
90 | /** |
91 | Returns an exact copy of this Event. The caller owns the returned object. |
92 | */ |
93 | Event *clone() const; |
94 | |
95 | /** |
96 | Sets the incidence starting date/time. |
97 | |
98 | @param dt is the starting date/time. |
99 | @see IncidenceBase::dtStart(). |
100 | */ |
101 | virtual void setDtStart(const KDateTime &dt); |
102 | |
103 | /** |
104 | Sets the event end date and time. |
105 | Important note for all day events: the end date is inclusive, |
106 | the event will still occur during dtEnd(). When serializing to iCalendar |
107 | DTEND will be dtEnd()+1, because the RFC states that DTEND is exclusive. |
108 | @param dtEnd is a KDateTime specifying when the event ends. |
109 | @see dtEnd(), dateEnd(). |
110 | */ |
111 | void setDtEnd(const KDateTime &dtEnd); |
112 | |
113 | /** |
114 | Returns the event end date and time. |
115 | Important note for all day events: the returned end date is inclusive, |
116 | the event will still occur during dtEnd(). When serializing to iCalendar |
117 | DTEND will be dtEnd()+1, because the RFC states that DTEND is exclusive. |
118 | @see setDtEnd(). |
119 | */ |
120 | virtual KDateTime dtEnd() const; |
121 | |
122 | /** |
123 | Returns the date when the event ends. This might be different from |
124 | dtEnd().date, since the end date/time is non-inclusive. So timed events |
125 | ending at 0:00 have their end date on the day before. |
126 | */ |
127 | QDate dateEnd() const; |
128 | |
129 | /** |
130 | Sets whether the event has an end date/time. |
131 | @param b If set, indicates the event has an end date. |
132 | @deprecated Use setDtEnd( KDateTime() ) instead of setHasEndDate( false ) |
133 | */ |
134 | KCALCORE_DEPRECATED void setHasEndDate(bool b); |
135 | |
136 | /** |
137 | Returns whether the event has an end date/time. |
138 | */ |
139 | bool hasEndDate() const; |
140 | |
141 | /** |
142 | Returns true if the event spans multiple days, otherwise return false. |
143 | |
144 | For recurring events, it returns true if the first occurrence spans multiple days, |
145 | otherwise returns false. Other occurrences might have a different span due to day light |
146 | savings changes. |
147 | |
148 | @param spec If set, looks if the event is multiday for the given spec. |
149 | If not set, looks if event this multiday for its spec. |
150 | */ |
151 | bool isMultiDay(const KDateTime::Spec &spec = KDateTime::Spec()) const; |
152 | |
153 | /** |
154 | @copydoc |
155 | IncidenceBase::shiftTimes() |
156 | */ |
157 | virtual void shiftTimes(const KDateTime::Spec &oldSpec, |
158 | const KDateTime::Spec &newSpec); |
159 | |
160 | /** |
161 | Sets the event's time transparency level. |
162 | @param transparency is the event Transparency level. |
163 | */ |
164 | void setTransparency(Transparency transparency); |
165 | |
166 | /** |
167 | Returns the event's time transparency level. |
168 | */ |
169 | Transparency transparency() const; |
170 | |
171 | /** |
172 | Sets the duration of this event. |
173 | @param duration is the event Duration. |
174 | */ |
175 | void setDuration(const Duration &duration); |
176 | |
177 | /** |
178 | @copydoc |
179 | IncidenceBase::setAllDay(). |
180 | */ |
181 | void setAllDay(bool allDay); |
182 | |
183 | /** |
184 | @copydoc |
185 | IncidenceBase::dateTime() |
186 | */ |
187 | KDateTime dateTime(DateTimeRole role) const; |
188 | |
189 | /** |
190 | @copydoc |
191 | IncidenceBase::setDateTime() |
192 | */ |
193 | void setDateTime(const KDateTime &dateTime, DateTimeRole role); |
194 | |
195 | /** |
196 | @copydoc |
197 | IncidenceBase::mimeType() |
198 | */ |
199 | QLatin1String mimeType() const; |
200 | |
201 | /** |
202 | @copydoc |
203 | Incidence::iconName() |
204 | */ |
205 | QLatin1String iconName(const KDateTime &recurrenceId = KDateTime()) const; |
206 | |
207 | /** |
208 | Returns the Akonadi specific sub MIME type of a KCalCore::Event. |
209 | */ |
210 | static QLatin1String eventMimeType(); |
211 | |
212 | protected: |
213 | /** |
214 | Compares two events for equality. |
215 | @param event is the event to compare. |
216 | */ |
217 | virtual bool equals(const IncidenceBase &event) const; |
218 | |
219 | /** |
220 | @copydoc |
221 | IncidenceBase::assign() |
222 | */ |
223 | virtual IncidenceBase &assign(const IncidenceBase &other); |
224 | |
225 | /** |
226 | @copydoc |
227 | IncidenceBase::virtual_hook() |
228 | */ |
229 | virtual void virtual_hook(int id, void *data); |
230 | |
231 | private: |
232 | /** |
233 | @copydoc |
234 | IncidenceBase::accept() |
235 | */ |
236 | bool accept(Visitor &v, IncidenceBase::Ptr incidence); |
237 | |
238 | /** |
239 | Disabled, otherwise could be dangerous if you subclass Event. |
240 | Use IncidenceBase::operator= which is safe because it calls |
241 | virtual function assign(). |
242 | @param other is another Event object to assign to this one. |
243 | */ |
244 | Event &operator=(const Event &other); |
245 | |
246 | // For polymorfic serialization |
247 | void serialize(QDataStream &out); |
248 | void deserialize(QDataStream &in); |
249 | |
250 | //@cond PRIVATE |
251 | class Private; |
252 | Private *const d; |
253 | //@endcond |
254 | }; |
255 | |
256 | } // namespace KCalCore |
257 | |
258 | //@cond PRIVATE |
259 | Q_DECLARE_TYPEINFO(KCalCore::Event::Ptr, Q_MOVABLE_TYPE); |
260 | Q_DECLARE_METATYPE(KCalCore::Event::Ptr) |
261 | //@endcond |
262 | |
263 | //@cond PRIVATE |
264 | namespace KPIMUtils { |
265 | // super class trait specialization |
266 | template <> struct SuperClass<KCalCore::Event> : public SuperClassTrait<KCalCore::Incidence> {}; |
267 | } |
268 | //@endcond |
269 | |
270 | #endif |
271 | |