1 | /* |
2 | This file is part of the kcal 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 KCAL_EVENT_H |
29 | #define KCAL_EVENT_H |
30 | |
31 | #include "incidence.h" |
32 | #include <kpimutils/supertrait.h> |
33 | #include <QtCore/QByteArray> |
34 | |
35 | namespace KCal { |
36 | |
37 | /** |
38 | @brief |
39 | This class provides an Event in the sense of RFC2445. |
40 | */ |
41 | class KCAL_DEPRECATED_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 | List of events. |
54 | */ |
55 | typedef ListBase<Event> List; |
56 | |
57 | /** |
58 | A shared pointer to an Event object. |
59 | */ |
60 | typedef boost::shared_ptr<Event> Ptr; |
61 | |
62 | /** |
63 | A shared pointer to a non-mutable Event. |
64 | */ |
65 | typedef boost::shared_ptr<const Event> ConstPtr; |
66 | |
67 | /** |
68 | Constructs an event. |
69 | */ |
70 | Event(); |
71 | |
72 | /** |
73 | Copy constructor. |
74 | @param other is the event to copy. |
75 | */ |
76 | Event( const Event &other ); |
77 | |
78 | /** |
79 | Destroys the event. |
80 | */ |
81 | ~Event(); |
82 | |
83 | /** |
84 | Assignment operator. |
85 | @param other is the event to assign. |
86 | */ |
87 | Event &operator=( const Event &other ); |
88 | |
89 | /** |
90 | Compares two events for equality. |
91 | @param event is the event to compare. |
92 | */ |
93 | bool operator==( const Event &event ) const; |
94 | |
95 | /** |
96 | @copydoc |
97 | IncidenceBase::type() |
98 | */ |
99 | QByteArray type() const; |
100 | |
101 | /** |
102 | @copydoc |
103 | IncidenceBase::typeStr() |
104 | */ |
105 | //KDE5: QString typeStr() const; |
106 | |
107 | /** |
108 | Returns an exact copy of this Event. The caller owns the returned object. |
109 | */ |
110 | Event *clone(); |
111 | |
112 | /** |
113 | Sets the event end date and time. |
114 | @param dtEnd is a KDateTime specifying when the event ends. |
115 | @see dtEnd(), dateEnd(). |
116 | */ |
117 | void setDtEnd( const KDateTime &dtEnd ); |
118 | |
119 | /** |
120 | Returns the event end date and time. |
121 | @see setDtEnd(). |
122 | */ |
123 | virtual KDateTime dtEnd() const; |
124 | |
125 | /** |
126 | Returns the date when the event ends. This might be different from |
127 | dtEnd().date, since the end date/time is non-inclusive. So timed events |
128 | ending at 0:00 have their end date on the day before. |
129 | */ |
130 | QDate dateEnd() const; |
131 | |
132 | /** |
133 | Returns the event end time as a string formatted according to the |
134 | user's locale settings. |
135 | |
136 | @param shortfmt If set, use short date format; else use long format. |
137 | @param spec If set, return the time in the given spec, else use the |
138 | event's current spec. |
139 | |
140 | @deprecated use IncidenceFormatter::timeToString() |
141 | */ |
142 | KCAL_DEPRECATED QString dtEndTimeStr( |
143 | bool shortfmt = true, const KDateTime::Spec &spec = KDateTime::Spec() ) const; |
144 | |
145 | /** |
146 | Returns the event end date as a string formatted according to the |
147 | user's locale settings. |
148 | |
149 | @param shortfmt If set, use short date format; else use long format. |
150 | @param spec If set, return the date in the given spec, else use the |
151 | event's current spec. |
152 | |
153 | @deprecated use IncidenceFormatter::dateToString() |
154 | */ |
155 | KCAL_DEPRECATED QString dtEndDateStr( |
156 | bool shortfmt = true, const KDateTime::Spec &spec = KDateTime::Spec() ) const; |
157 | |
158 | /** |
159 | Returns the event end date/time as string formatted according to the |
160 | user's locale settings. |
161 | |
162 | @param shortfmt If set, use short date format; else use long format. |
163 | @param spec If set, return the date/time in the given spec, else use |
164 | the event's current spec. |
165 | |
166 | @deprecated use IncidenceFormatter::dateTimeToString() |
167 | */ |
168 | KCAL_DEPRECATED QString dtEndStr( |
169 | bool shortfmt = true, const KDateTime::Spec &spec = KDateTime::Spec() ) const; |
170 | |
171 | /** |
172 | Sets whether the event has an end date/time. |
173 | @param b If set, indicates the event has an end date. |
174 | */ |
175 | void setHasEndDate( bool b ); |
176 | |
177 | /** |
178 | Returns whether the event has an end date/time. |
179 | */ |
180 | bool hasEndDate() const; |
181 | |
182 | /** |
183 | Returns true if the event spans multiple days, otherwise return false. |
184 | |
185 | @param spec If set, looks if the event is multiday for the given spec. |
186 | If not set, looks if event this multiday for its spec. |
187 | */ |
188 | bool isMultiDay( const KDateTime::Spec &spec = KDateTime::Spec() ) const; |
189 | |
190 | /** |
191 | @copydoc |
192 | IncidenceBase::shiftTimes() |
193 | */ |
194 | virtual void shiftTimes( const KDateTime::Spec &oldSpec, |
195 | const KDateTime::Spec &newSpec ); |
196 | |
197 | /** |
198 | Sets the event's time transparency level. |
199 | @param transparency is the event Transparency level. |
200 | */ |
201 | void setTransparency( Transparency transparency ); |
202 | |
203 | /** |
204 | Returns the event's time transparency level. |
205 | */ |
206 | Transparency transparency() const; |
207 | |
208 | /** |
209 | Sets the duration of this event. |
210 | @param duration is the event Duration. |
211 | */ |
212 | void setDuration( const Duration &duration ); |
213 | |
214 | protected: |
215 | /** |
216 | Returns the end date/time of the base incidence. |
217 | */ |
218 | virtual KDateTime endDateRecurrenceBase() const; |
219 | |
220 | private: |
221 | /** |
222 | @copydoc |
223 | IncidenceBase::accept() |
224 | */ |
225 | bool accept( Visitor &v ) { return v.visit( this ); } |
226 | |
227 | //@cond PRIVATE |
228 | class Private; |
229 | Private *const d; |
230 | //@endcond |
231 | }; |
232 | |
233 | } |
234 | |
235 | //@cond PRIVATE |
236 | // super class trait specialization |
237 | namespace KPIMUtils { |
238 | template <> struct SuperClass<KCal::Event> : public SuperClassTrait<KCal::Incidence>{}; |
239 | } |
240 | //@endcond |
241 | |
242 | #endif |
243 | |