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