summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.h
authorzautrix <zautrix>2005-11-28 01:23:02 (UTC)
committer zautrix <zautrix>2005-11-28 01:23:02 (UTC)
commite08811c2246f63b2b63f9db6b65701344460f3d7 (patch) (unidiff)
treed450f486a9472d80eb86f605237b828a0e7ffae6 /libkcal/incidence.h
parent854d4a0c686962cd73ac7418b5fbf4b2d73adab7 (diff)
downloadkdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.zip
kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.gz
kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.bz2
ync
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 dc49640..f89942f 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -1,326 +1,327 @@
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 void addRelationsToList(QPtrList<Incidence> *rel); 116 void addRelationsToList(QPtrList<Incidence> *rel);
117 void clearRelations(); 117 void clearRelations();
118 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; 118 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0;
119 void setReadOnly( bool ); 119 void setReadOnly( bool );
120 120
121 /** 121 /**
122 Recreate event. The event is made a new unique event, but already stored 122 Recreate event. The event is made a new unique event, but already stored
123 event information is preserved. Sets uniquie id, creation date, last 123 event information is preserved. Sets uniquie id, creation date, last
124 modification date and revision number. 124 modification date and revision number.
125 */ 125 */
126 void recreate(); 126 void recreate();
127 Incidence* recreateCloneException(QDate); 127 Incidence* recreateCloneException(QDate);
128 128
129 /** set creation date */ 129 /** set creation date */
130 void setCreated(QDateTime); 130 void setCreated(QDateTime);
131 /** return time and date of creation. */ 131 /** return time and date of creation. */
132 QDateTime created() const; 132 QDateTime created() const;
133 133
134 /** set the number of revisions this event has seen */ 134 /** set the number of revisions this event has seen */
135 void setRevision(int rev); 135 void setRevision(int rev);
136 /** return the number of revisions this event has seen */ 136 /** return the number of revisions this event has seen */
137 int revision() const; 137 int revision() const;
138 138
139 /** Set starting date/time. */ 139 /** Set starting date/time. */
140 virtual void setDtStart(const QDateTime &dtStart); 140 virtual void setDtStart(const QDateTime &dtStart);
141 /** Return the incidence's ending date/time as a QDateTime. */ 141 /** Return the incidence's ending date/time as a QDateTime. */
142 virtual QDateTime dtEnd() const { return QDateTime(); } 142 virtual QDateTime dtEnd() const { return QDateTime(); }
143 143
144 /** sets the event's lengthy description. */ 144 /** sets the event's lengthy description. */
145 void setDescription(const QString &description); 145 void setDescription(const QString &description);
146 /** returns a reference to the event's description. */ 146 /** returns a reference to the event's description. */
147 QString description() const; 147 QString description() const;
148 148
149 /** sets the event's short summary. */ 149 /** sets the event's short summary. */
150 void setSummary(const QString &summary); 150 void setSummary(const QString &summary);
151 /** returns a reference to the event's summary. */ 151 /** returns a reference to the event's summary. */
152 QString summary() const; 152 QString summary() const;
153 153
154 /** set event's applicable categories */ 154 /** set event's applicable categories */
155 void setCategories(const QStringList &categories, bool setForRelations = false); 155 void setCategories(const QStringList &categories, bool setForRelations = false);
156 void addCategories(const QStringList &categories, bool addToRelations = false); 156 void addCategories(const QStringList &categories, bool addToRelations = false);
157 /** set event's categories based on a comma delimited string */ 157 /** set event's categories based on a comma delimited string */
158 void setCategories(const QString &catStr); 158 void setCategories(const QString &catStr);
159 /** return categories in a list */ 159 /** return categories in a list */
160 QStringList categories() const; 160 QStringList categories() const;
161 QStringList* categoriesP(); 161 QStringList* categoriesP();
162 /** return categories as a comma separated string */ 162 /** return categories as a comma separated string */
163 QString categoriesStr(); 163 QString categoriesStr();
164 QString categoriesStrWithSpace(); 164 QString categoriesStrWithSpace();
165 165
166 /** point at some other event to which the event relates. This function should 166 /** 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 167 * only be used when constructing a calendar before the related Event
168 * exists. */ 168 * exists. */
169 void setRelatedToUid(const QString &); 169 void setRelatedToUid(const QString &);
170 /** what event does this one relate to? This function should 170 /** what event does this one relate to? This function should
171 * only be used when constructing a calendar before the related Event 171 * only be used when constructing a calendar before the related Event
172 * exists. */ 172 * exists. */
173 QString relatedToUid() const; 173 QString relatedToUid() const;
174 /** point at some other event to which the event relates */ 174 /** point at some other event to which the event relates */
175 void setRelatedTo(Incidence *relatedTo); 175 void setRelatedTo(Incidence *relatedTo);
176 void resetRelatedTo();
176 /** what event does this one relate to? */ 177 /** what event does this one relate to? */
177 Incidence *relatedTo() const; 178 Incidence *relatedTo() const;
178 /** All events that are related to this event */ 179 /** All events that are related to this event */
179 QPtrList<Incidence> relations() const; 180 QPtrList<Incidence> relations() const;
180 /** Add an event which is related to this event */ 181 /** Add an event which is related to this event */
181 void addRelation(Incidence *); 182 void addRelation(Incidence *);
182 /** Remove event that is related to this event */ 183 /** Remove event that is related to this event */
183 void removeRelation(Incidence *); 184 void removeRelation(Incidence *);
184 185
185 /** returns the list of dates which are exceptions to the recurrence rule */ 186 /** returns the list of dates which are exceptions to the recurrence rule */
186 DateList exDates() const; 187 DateList exDates() const;
187 /** sets the list of dates which are exceptions to the recurrence rule */ 188 /** sets the list of dates which are exceptions to the recurrence rule */
188 void setExDates(const DateList &_exDates); 189 void setExDates(const DateList &_exDates);
189 void setExDates(const char *dates); 190 void setExDates(const char *dates);
190 /** Add a date to the list of exceptions of the recurrence rule. */ 191 /** Add a date to the list of exceptions of the recurrence rule. */
191 void addExDate(const QDate &date); 192 void addExDate(const QDate &date);
192 193
193 /** returns true if there is an exception for this date in the recurrence 194 /** returns true if there is an exception for this date in the recurrence
194 rule set, or false otherwise. */ 195 rule set, or false otherwise. */
195 bool isException(const QDate &qd) const; 196 bool isException(const QDate &qd) const;
196 197
197 /** add attachment to this event */ 198 /** add attachment to this event */
198 void addAttachment(Attachment *attachment); 199 void addAttachment(Attachment *attachment);
199 /** remove and delete a specific attachment */ 200 /** remove and delete a specific attachment */
200 void deleteAttachment(Attachment *attachment); 201 void deleteAttachment(Attachment *attachment);
201 /** remove and delete all attachments with this mime type */ 202 /** remove and delete all attachments with this mime type */
202 void deleteAttachments(const QString& mime); 203 void deleteAttachments(const QString& mime);
203 /** return list of all associated attachments */ 204 /** return list of all associated attachments */
204 QPtrList<Attachment> attachments() const; 205 QPtrList<Attachment> attachments() const;
205 /** find a list of attachments with this mime type */ 206 /** find a list of attachments with this mime type */
206 QPtrList<Attachment> attachments(const QString& mime) const; 207 QPtrList<Attachment> attachments(const QString& mime) const;
207 208
208 /** sets the event's status the value specified. See the enumeration 209 /** sets the event's status the value specified. See the enumeration
209 * above for possible values. */ 210 * above for possible values. */
210 void setSecrecy(int); 211 void setSecrecy(int);
211 /** return the event's secrecy. */ 212 /** return the event's secrecy. */
212 int secrecy() const; 213 int secrecy() const;
213 /** return the event's secrecy in string format. */ 214 /** return the event's secrecy in string format. */
214 QString secrecyStr() const; 215 QString secrecyStr() const;
215 /** return list of all availbale secrecy classes */ 216 /** return list of all availbale secrecy classes */
216 static QStringList secrecyList(); 217 static QStringList secrecyList();
217 /** return human-readable name of secrecy class */ 218 /** return human-readable name of secrecy class */
218 static QString secrecyName(int); 219 static QString secrecyName(int);
219 220
220 /** returns TRUE if the date specified is one on which the event will 221 /** returns TRUE if the date specified is one on which the event will
221 * recur. */ 222 * recur. */
222 bool recursOn(const QDate &qd) const; 223 bool recursOn(const QDate &qd) const;
223 224
224 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 225 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
225 226
226 /** set resources used, such as Office, Car, etc. */ 227 /** set resources used, such as Office, Car, etc. */
227 void setResources(const QStringList &resources); 228 void setResources(const QStringList &resources);
228 /** return list of current resources */ 229 /** return list of current resources */
229 QStringList resources() const; 230 QStringList resources() const;
230 231
231 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 232 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
232 void setPriority(int priority); 233 void setPriority(int priority);
233 /** get the event's priority */ 234 /** get the event's priority */
234 int priority() const; 235 int priority() const;
235 236
236 /** All alarms that are associated with this incidence */ 237 /** All alarms that are associated with this incidence */
237 QPtrList<Alarm> alarms() const; 238 QPtrList<Alarm> alarms() const;
238 /** Create a new alarm which is associated with this incidence */ 239 /** Create a new alarm which is associated with this incidence */
239 Alarm* newAlarm(); 240 Alarm* newAlarm();
240 /** Add an alarm which is associated with this incidence */ 241 /** Add an alarm which is associated with this incidence */
241 void addAlarm(Alarm*); 242 void addAlarm(Alarm*);
242 /** Remove an alarm that is associated with this incidence */ 243 /** Remove an alarm that is associated with this incidence */
243 void removeAlarm(Alarm*); 244 void removeAlarm(Alarm*);
244 /** Remove all alarms that are associated with this incidence */ 245 /** Remove all alarms that are associated with this incidence */
245 void clearAlarms(); 246 void clearAlarms();
246 /** return whether any alarm associated with this incidence is enabled */ 247 /** return whether any alarm associated with this incidence is enabled */
247 bool isAlarmEnabled() const; 248 bool isAlarmEnabled() const;
248 249
249 /** 250 /**
250 Return the recurrence rule associated with this incidence. If there is 251 Return the recurrence rule associated with this incidence. If there is
251 none, returns an appropriate (non-0) object. 252 none, returns an appropriate (non-0) object.
252 */ 253 */
253 Recurrence *recurrence(); 254 Recurrence *recurrence();
254 void setRecurrence(Recurrence * r); 255 void setRecurrence(Recurrence * r);
255 /** 256 /**
256 Forward to Recurrence::doesRecur(). 257 Forward to Recurrence::doesRecur().
257 */ 258 */
258 ushort doesRecur() const; 259 ushort doesRecur() const;
259 260
260 /** set the event's/todo's location. Do _not_ use it with journal */ 261 /** set the event's/todo's location. Do _not_ use it with journal */
261 void setLocation(const QString &location); 262 void setLocation(const QString &location);
262 /** return the event's/todo's location. Do _not_ use it with journal */ 263 /** return the event's/todo's location. Do _not_ use it with journal */
263 QString location() const; 264 QString location() const;
264 /** returns TRUE or FALSE depending on whether the todo has a start date */ 265 /** returns TRUE or FALSE depending on whether the todo has a start date */
265 bool hasStartDate() const; 266 bool hasStartDate() const;
266 /** sets the event's hasStartDate value. */ 267 /** sets the event's hasStartDate value. */
267 void setHasStartDate(bool f); 268 void setHasStartDate(bool f);
268 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 269 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
269 bool cancelled() const; 270 bool cancelled() const;
270 void setCancelled( bool b ); 271 void setCancelled( bool b );
271 272
272 bool hasRecurrenceID() const; 273 bool hasRecurrenceID() const;
273 void setHasRecurrenceID( bool b ); 274 void setHasRecurrenceID( bool b );
274 275
275 void setRecurrenceID(QDateTime); 276 void setRecurrenceID(QDateTime);
276 QDateTime recurrenceID () const; 277 QDateTime recurrenceID () const;
277 QDateTime dtStart() const; 278 QDateTime dtStart() const;
278 bool isHoliday() const; 279 bool isHoliday() const;
279 bool isBirthday() const; 280 bool isBirthday() const;
280 bool isAnniversary() const; 281 bool isAnniversary() const;
281 QDateTime lastModifiedSub(); 282 QDateTime lastModifiedSub();
282 QString lastModifiedSubSortKey() const; 283 QString lastModifiedSubSortKey() const;
283 QString recurrenceText() const; 284 QString recurrenceText() const;
284 void setLastModifiedSubInvalid(); 285 void setLastModifiedSubInvalid();
285 286
286 virtual QString durationText(); 287 virtual QString durationText();
287 QString durationText4Time( int secs ); 288 QString durationText4Time( int secs );
288 Recurrence *mRecurrence; 289 Recurrence *mRecurrence;
289protected: 290protected:
290 QPtrList<Alarm> mAlarms; 291 QPtrList<Alarm> mAlarms;
291 QPtrList<Incidence> mRelations; 292 QPtrList<Incidence> mRelations;
292 QDateTime mRecurrenceID; 293 QDateTime mRecurrenceID;
293 bool mHasRecurrenceID; 294 bool mHasRecurrenceID;
294 private: 295 private:
295 void checkCategories(); 296 void checkCategories();
296 QString mLastModifiedSubSortKey; 297 QString mLastModifiedSubSortKey;
297 bool mHoliday, mBirthday, mAnniversary; 298 bool mHoliday, mBirthday, mAnniversary;
298 int mRevision; 299 int mRevision;
299 bool mCancelled; 300 bool mCancelled;
300 301
301 // base components of jounal, event and todo 302 // base components of jounal, event and todo
302 QDateTime mCreated; 303 QDateTime mCreated;
303 QDateTime mLastModifiedSub; 304 QDateTime mLastModifiedSub;
304 QString mDescription; 305 QString mDescription;
305 QString mSummary; 306 QString mSummary;
306 QStringList mCategories; 307 QStringList mCategories;
307 Incidence *mRelatedTo; 308 Incidence *mRelatedTo;
308 QString mRelatedToUid; 309 QString mRelatedToUid;
309 DateList mExDates; 310 DateList mExDates;
310 QPtrList<Attachment> mAttachments; 311 QPtrList<Attachment> mAttachments;
311 QStringList mResources; 312 QStringList mResources;
312 bool mHasStartDate; // if todo has associated start date 313 bool mHasStartDate; // if todo has associated start date
313 314
314 int mSecrecy; 315 int mSecrecy;
315 int mPriority; // 1 = highest, 2 = less, etc. 316 int mPriority; // 1 = highest, 2 = less, etc.
316 317
317 //QPtrList<Alarm> mAlarms; 318 //QPtrList<Alarm> mAlarms;
318 319
319 QString mLocation; 320 QString mLocation;
320}; 321};
321 322
322bool operator==( const Incidence&, const Incidence& ); 323bool operator==( const Incidence&, const Incidence& );
323 324
324} 325}
325 326
326#endif 327#endif