summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.h
Unidiff
Diffstat (limited to 'libkcal/incidence.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 60070a2..327e7dd 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -1,315 +1,316 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef INCIDENCE_H 20#ifndef INCIDENCE_H
21#define INCIDENCE_H 21#define INCIDENCE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29 29
30#include "recurrence.h" 30#include "recurrence.h"
31#include "alarm.h" 31#include "alarm.h"
32#include "attachment.h" 32#include "attachment.h"
33#include "listbase.h" 33#include "listbase.h"
34#include "incidencebase.h" 34#include "incidencebase.h"
35 35
36namespace KCal { 36namespace KCal {
37 37
38class Event; 38class Event;
39class Todo; 39class Todo;
40class Journal; 40class Journal;
41 41
42/** 42/**
43 This class provides the base class common to all calendar components. 43 This class provides the base class common to all calendar components.
44*/ 44*/
45class Incidence : public IncidenceBase 45class Incidence : public IncidenceBase
46{ 46{
47 public: 47 public:
48 /** 48 /**
49 This class provides the interface for a visitor of calendar components. It 49 This class provides the interface for a visitor of calendar components. It
50 serves as base class for concrete visitors, which implement certain actions on 50 serves as base class for concrete visitors, which implement certain actions on
51 calendar components. It allows to add functions, which operate on the concrete 51 calendar components. It allows to add functions, which operate on the concrete
52 types of calendar components, without changing the calendar component classes. 52 types of calendar components, without changing the calendar component classes.
53 */ 53 */
54 class Visitor 54 class Visitor
55 { 55 {
56 public: 56 public:
57 /** Destruct Incidence::Visitor */ 57 /** Destruct Incidence::Visitor */
58 virtual ~Visitor() {} 58 virtual ~Visitor() {}
59 59
60 /** 60 /**
61 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 61 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
62 on an Event object. 62 on an Event object.
63 */ 63 */
64 virtual bool visit(Event *) { return false; } 64 virtual bool visit(Event *) { return false; }
65 /** 65 /**
66 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 66 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
67 on an Todo object. 67 on an Todo object.
68 */ 68 */
69 virtual bool visit(Todo *) { return false; } 69 virtual bool visit(Todo *) { return false; }
70 /** 70 /**
71 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 71 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
72 on an Journal object. 72 on an Journal object.
73 */ 73 */
74 virtual bool visit(Journal *) { return false; } 74 virtual bool visit(Journal *) { return false; }
75 75
76 protected: 76 protected:
77 /** Constructor is protected to prevent direct creation of visitor base class. */ 77 /** Constructor is protected to prevent direct creation of visitor base class. */
78 Visitor() {} 78 Visitor() {}
79 }; 79 };
80 80
81 /** 81 /**
82 This class implements a visitor for adding an Incidence to a resource 82 This class implements a visitor for adding an Incidence to a resource
83 supporting addEvent(), addTodo() and addJournal() calls. 83 supporting addEvent(), addTodo() and addJournal() calls.
84 */ 84 */
85 template<class T> 85 template<class T>
86 class AddVisitor : public Visitor 86 class AddVisitor : public Visitor
87 { 87 {
88 public: 88 public:
89 AddVisitor( T *r ) : mResource( r ) {} 89 AddVisitor( T *r ) : mResource( r ) {}
90 bool visit( Event *e ) { return mResource->addEvent( e ); } 90 bool visit( Event *e ) { return mResource->addEvent( e ); }
91 bool visit( Todo *t ) { return mResource->addTodo( t ); } 91 bool visit( Todo *t ) { return mResource->addTodo( t ); }
92 bool visit( Journal *j ) { return mResource->addJournal( j ); } 92 bool visit( Journal *j ) { return mResource->addJournal( j ); }
93 93
94 private: 94 private:
95 T *mResource; 95 T *mResource;
96 }; 96 };
97 97
98 /** enumeration for describing an event's secrecy. */ 98 /** enumeration for describing an event's secrecy. */
99 enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; 99 enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 };
100 typedef ListBase<Incidence> List; 100 typedef ListBase<Incidence> List;
101 Incidence(); 101 Incidence();
102 Incidence(const Incidence &); 102 Incidence(const Incidence &);
103 ~Incidence(); 103 ~Incidence();
104 104
105 /** 105 /**
106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to 106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to
107 provide this implementation: 107 provide this implementation:
108 <pre> 108 <pre>
109 bool accept(Visitor &v) { return v.visit(this); } 109 bool accept(Visitor &v) { return v.visit(this); }
110 </pre> 110 </pre>
111 */ 111 */
112 virtual bool accept(Visitor &) { return false; } 112 virtual bool accept(Visitor &) { return false; }
113 113
114 virtual Incidence *clone() = 0; 114 virtual Incidence *clone() = 0;
115 virtual void cloneRelations( Incidence * ); 115 virtual void cloneRelations( Incidence * );
116 116
117 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; 117 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0;
118 void setReadOnly( bool ); 118 void setReadOnly( bool );
119 119
120 /** 120 /**
121 Recreate event. The event is made a new unique event, but already stored 121 Recreate event. The event is made a new unique event, but already stored
122 event information is preserved. Sets uniquie id, creation date, last 122 event information is preserved. Sets uniquie id, creation date, last
123 modification date and revision number. 123 modification date and revision number.
124 */ 124 */
125 void recreate(); 125 void recreate();
126 Incidence* recreateCloneException(QDate); 126 Incidence* recreateCloneException(QDate);
127 127
128 /** set creation date */ 128 /** set creation date */
129 void setCreated(QDateTime); 129 void setCreated(QDateTime);
130 /** return time and date of creation. */ 130 /** return time and date of creation. */
131 QDateTime created() const; 131 QDateTime created() const;
132 132
133 /** set the number of revisions this event has seen */ 133 /** set the number of revisions this event has seen */
134 void setRevision(int rev); 134 void setRevision(int rev);
135 /** return the number of revisions this event has seen */ 135 /** return the number of revisions this event has seen */
136 int revision() const; 136 int revision() const;
137 137
138 /** Set starting date/time. */ 138 /** Set starting date/time. */
139 virtual void setDtStart(const QDateTime &dtStart); 139 virtual void setDtStart(const QDateTime &dtStart);
140 /** Return the incidence's ending date/time as a QDateTime. */ 140 /** Return the incidence's ending date/time as a QDateTime. */
141 virtual QDateTime dtEnd() const { return QDateTime(); } 141 virtual QDateTime dtEnd() const { return QDateTime(); }
142 142
143 /** sets the event's lengthy description. */ 143 /** sets the event's lengthy description. */
144 void setDescription(const QString &description); 144 void setDescription(const QString &description);
145 /** returns a reference to the event's description. */ 145 /** returns a reference to the event's description. */
146 QString description() const; 146 QString description() const;
147 147
148 /** sets the event's short summary. */ 148 /** sets the event's short summary. */
149 void setSummary(const QString &summary); 149 void setSummary(const QString &summary);
150 /** returns a reference to the event's summary. */ 150 /** returns a reference to the event's summary. */
151 QString summary() const; 151 QString summary() const;
152 152
153 /** set event's applicable categories */ 153 /** set event's applicable categories */
154 void setCategories(const QStringList &categories); 154 void setCategories(const QStringList &categories);
155 /** set event's categories based on a comma delimited string */ 155 /** set event's categories based on a comma delimited string */
156 void setCategories(const QString &catStr); 156 void setCategories(const QString &catStr);
157 /** return categories in a list */ 157 /** return categories in a list */
158 QStringList categories() const; 158 QStringList categories() const;
159 /** return categories as a comma separated string */ 159 /** return categories as a comma separated string */
160 QString categoriesStr(); 160 QString categoriesStr();
161 QString categoriesStrWithSpace();
161 162
162 /** point at some other event to which the event relates. This function should 163 /** point at some other event to which the event relates. This function should
163 * only be used when constructing a calendar before the related Event 164 * only be used when constructing a calendar before the related Event
164 * exists. */ 165 * exists. */
165 void setRelatedToUid(const QString &); 166 void setRelatedToUid(const QString &);
166 /** what event does this one relate to? This function should 167 /** what event does this one relate to? This function should
167 * only be used when constructing a calendar before the related Event 168 * only be used when constructing a calendar before the related Event
168 * exists. */ 169 * exists. */
169 QString relatedToUid() const; 170 QString relatedToUid() const;
170 /** point at some other event to which the event relates */ 171 /** point at some other event to which the event relates */
171 void setRelatedTo(Incidence *relatedTo); 172 void setRelatedTo(Incidence *relatedTo);
172 /** what event does this one relate to? */ 173 /** what event does this one relate to? */
173 Incidence *relatedTo() const; 174 Incidence *relatedTo() const;
174 /** All events that are related to this event */ 175 /** All events that are related to this event */
175 QPtrList<Incidence> relations() const; 176 QPtrList<Incidence> relations() const;
176 /** Add an event which is related to this event */ 177 /** Add an event which is related to this event */
177 void addRelation(Incidence *); 178 void addRelation(Incidence *);
178 /** Remove event that is related to this event */ 179 /** Remove event that is related to this event */
179 void removeRelation(Incidence *); 180 void removeRelation(Incidence *);
180 181
181 /** returns the list of dates which are exceptions to the recurrence rule */ 182 /** returns the list of dates which are exceptions to the recurrence rule */
182 DateList exDates() const; 183 DateList exDates() const;
183 /** sets the list of dates which are exceptions to the recurrence rule */ 184 /** sets the list of dates which are exceptions to the recurrence rule */
184 void setExDates(const DateList &_exDates); 185 void setExDates(const DateList &_exDates);
185 void setExDates(const char *dates); 186 void setExDates(const char *dates);
186 /** Add a date to the list of exceptions of the recurrence rule. */ 187 /** Add a date to the list of exceptions of the recurrence rule. */
187 void addExDate(const QDate &date); 188 void addExDate(const QDate &date);
188 189
189 /** returns true if there is an exception for this date in the recurrence 190 /** returns true if there is an exception for this date in the recurrence
190 rule set, or false otherwise. */ 191 rule set, or false otherwise. */
191 bool isException(const QDate &qd) const; 192 bool isException(const QDate &qd) const;
192 193
193 /** add attachment to this event */ 194 /** add attachment to this event */
194 void addAttachment(Attachment *attachment); 195 void addAttachment(Attachment *attachment);
195 /** remove and delete a specific attachment */ 196 /** remove and delete a specific attachment */
196 void deleteAttachment(Attachment *attachment); 197 void deleteAttachment(Attachment *attachment);
197 /** remove and delete all attachments with this mime type */ 198 /** remove and delete all attachments with this mime type */
198 void deleteAttachments(const QString& mime); 199 void deleteAttachments(const QString& mime);
199 /** return list of all associated attachments */ 200 /** return list of all associated attachments */
200 QPtrList<Attachment> attachments() const; 201 QPtrList<Attachment> attachments() const;
201 /** find a list of attachments with this mime type */ 202 /** find a list of attachments with this mime type */
202 QPtrList<Attachment> attachments(const QString& mime) const; 203 QPtrList<Attachment> attachments(const QString& mime) const;
203 204
204 /** sets the event's status the value specified. See the enumeration 205 /** sets the event's status the value specified. See the enumeration
205 * above for possible values. */ 206 * above for possible values. */
206 void setSecrecy(int); 207 void setSecrecy(int);
207 /** return the event's secrecy. */ 208 /** return the event's secrecy. */
208 int secrecy() const; 209 int secrecy() const;
209 /** return the event's secrecy in string format. */ 210 /** return the event's secrecy in string format. */
210 QString secrecyStr() const; 211 QString secrecyStr() const;
211 /** return list of all availbale secrecy classes */ 212 /** return list of all availbale secrecy classes */
212 static QStringList secrecyList(); 213 static QStringList secrecyList();
213 /** return human-readable name of secrecy class */ 214 /** return human-readable name of secrecy class */
214 static QString secrecyName(int); 215 static QString secrecyName(int);
215 216
216 /** returns TRUE if the date specified is one on which the event will 217 /** returns TRUE if the date specified is one on which the event will
217 * recur. */ 218 * recur. */
218 bool recursOn(const QDate &qd) const; 219 bool recursOn(const QDate &qd) const;
219 220
220 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 221 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
221 222
222 /** set resources used, such as Office, Car, etc. */ 223 /** set resources used, such as Office, Car, etc. */
223 void setResources(const QStringList &resources); 224 void setResources(const QStringList &resources);
224 /** return list of current resources */ 225 /** return list of current resources */
225 QStringList resources() const; 226 QStringList resources() const;
226 227
227 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 228 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
228 void setPriority(int priority); 229 void setPriority(int priority);
229 /** get the event's priority */ 230 /** get the event's priority */
230 int priority() const; 231 int priority() const;
231 232
232 /** All alarms that are associated with this incidence */ 233 /** All alarms that are associated with this incidence */
233 QPtrList<Alarm> alarms() const; 234 QPtrList<Alarm> alarms() const;
234 /** Create a new alarm which is associated with this incidence */ 235 /** Create a new alarm which is associated with this incidence */
235 Alarm* newAlarm(); 236 Alarm* newAlarm();
236 /** Add an alarm which is associated with this incidence */ 237 /** Add an alarm which is associated with this incidence */
237 void addAlarm(Alarm*); 238 void addAlarm(Alarm*);
238 /** Remove an alarm that is associated with this incidence */ 239 /** Remove an alarm that is associated with this incidence */
239 void removeAlarm(Alarm*); 240 void removeAlarm(Alarm*);
240 /** Remove all alarms that are associated with this incidence */ 241 /** Remove all alarms that are associated with this incidence */
241 void clearAlarms(); 242 void clearAlarms();
242 /** return whether any alarm associated with this incidence is enabled */ 243 /** return whether any alarm associated with this incidence is enabled */
243 bool isAlarmEnabled() const; 244 bool isAlarmEnabled() const;
244 245
245 /** 246 /**
246 Return the recurrence rule associated with this incidence. If there is 247 Return the recurrence rule associated with this incidence. If there is
247 none, returns an appropriate (non-0) object. 248 none, returns an appropriate (non-0) object.
248 */ 249 */
249 Recurrence *recurrence() const; 250 Recurrence *recurrence() const;
250 void setRecurrence(Recurrence * r); 251 void setRecurrence(Recurrence * r);
251 /** 252 /**
252 Forward to Recurrence::doesRecur(). 253 Forward to Recurrence::doesRecur().
253 */ 254 */
254 ushort doesRecur() const; 255 ushort doesRecur() const;
255 256
256 /** set the event's/todo's location. Do _not_ use it with journal */ 257 /** set the event's/todo's location. Do _not_ use it with journal */
257 void setLocation(const QString &location); 258 void setLocation(const QString &location);
258 /** return the event's/todo's location. Do _not_ use it with journal */ 259 /** return the event's/todo's location. Do _not_ use it with journal */
259 QString location() const; 260 QString location() const;
260 /** returns TRUE or FALSE depending on whether the todo has a start date */ 261 /** returns TRUE or FALSE depending on whether the todo has a start date */
261 bool hasStartDate() const; 262 bool hasStartDate() const;
262 /** sets the event's hasStartDate value. */ 263 /** sets the event's hasStartDate value. */
263 void setHasStartDate(bool f); 264 void setHasStartDate(bool f);
264 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 265 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
265 bool cancelled() const; 266 bool cancelled() const;
266 void setCancelled( bool b ); 267 void setCancelled( bool b );
267 268
268 bool hasRecurrenceID() const; 269 bool hasRecurrenceID() const;
269 void setHasRecurrenceID( bool b ); 270 void setHasRecurrenceID( bool b );
270 271
271 void setRecurrenceID(QDateTime); 272 void setRecurrenceID(QDateTime);
272 QDateTime recurrenceID () const; 273 QDateTime recurrenceID () const;
273 QDateTime dtStart() const; 274 QDateTime dtStart() const;
274 bool isHoliday() const; 275 bool isHoliday() const;
275 bool isBirthday() const; 276 bool isBirthday() const;
276 bool isAnniversary() const; 277 bool isAnniversary() const;
277 278
278 279
279protected: 280protected:
280 QPtrList<Alarm> mAlarms; 281 QPtrList<Alarm> mAlarms;
281 QPtrList<Incidence> mRelations; 282 QPtrList<Incidence> mRelations;
282 QDateTime mRecurrenceID; 283 QDateTime mRecurrenceID;
283 bool mHasRecurrenceID; 284 bool mHasRecurrenceID;
284 private: 285 private:
285 void checkCategories(); 286 void checkCategories();
286 bool mHoliday, mBirthday, mAnniversary; 287 bool mHoliday, mBirthday, mAnniversary;
287 int mRevision; 288 int mRevision;
288 bool mCancelled; 289 bool mCancelled;
289 290
290 // base components of jounal, event and todo 291 // base components of jounal, event and todo
291 QDateTime mCreated; 292 QDateTime mCreated;
292 QString mDescription; 293 QString mDescription;
293 QString mSummary; 294 QString mSummary;
294 QStringList mCategories; 295 QStringList mCategories;
295 Incidence *mRelatedTo; 296 Incidence *mRelatedTo;
296 QString mRelatedToUid; 297 QString mRelatedToUid;
297 DateList mExDates; 298 DateList mExDates;
298 QPtrList<Attachment> mAttachments; 299 QPtrList<Attachment> mAttachments;
299 QStringList mResources; 300 QStringList mResources;
300 bool mHasStartDate; // if todo has associated start date 301 bool mHasStartDate; // if todo has associated start date
301 302
302 int mSecrecy; 303 int mSecrecy;
303 int mPriority; // 1 = highest, 2 = less, etc. 304 int mPriority; // 1 = highest, 2 = less, etc.
304 305
305 //QPtrList<Alarm> mAlarms; 306 //QPtrList<Alarm> mAlarms;
306 Recurrence *mRecurrence; 307 Recurrence *mRecurrence;
307 308
308 QString mLocation; 309 QString mLocation;
309}; 310};
310 311
311bool operator==( const Incidence&, const Incidence& ); 312bool operator==( const Incidence&, const Incidence& );
312 313
313} 314}
314 315
315#endif 316#endif