summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp32
-rw-r--r--libkcal/incidence.h5
2 files changed, 36 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 708ee6b..9a36939 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -1,666 +1,696 @@
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 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#include "incidence.h" 27#include "incidence.h"
28#include "todo.h" 28#include "todo.h"
29 29
30using namespace KCal; 30using namespace KCal;
31 31
32Incidence::Incidence() : 32Incidence::Incidence() :
33 IncidenceBase(), 33 IncidenceBase(),
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 35{
36 mRecurrence = new Recurrence(this); 36 mRecurrence = new Recurrence(this);
37 mCancelled = false; 37 mCancelled = false;
38 recreate(); 38 recreate();
39 mHasStartDate = true; 39 mHasStartDate = true;
40 mAlarms.setAutoDelete(true); 40 mAlarms.setAutoDelete(true);
41 mAttachments.setAutoDelete(true); 41 mAttachments.setAutoDelete(true);
42 mHasRecurrenceID = false; 42 mHasRecurrenceID = false;
43 mHoliday = false;
44 mBirthday = false;
45 mAnniversary = false;
46
43} 47}
44 48
45Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) 49Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
46{ 50{
47// TODO: reenable attributes currently commented out. 51// TODO: reenable attributes currently commented out.
48 mRevision = i.mRevision; 52 mRevision = i.mRevision;
49 mCreated = i.mCreated; 53 mCreated = i.mCreated;
50 mDescription = i.mDescription; 54 mDescription = i.mDescription;
51 mSummary = i.mSummary; 55 mSummary = i.mSummary;
52 mCategories = i.mCategories; 56 mCategories = i.mCategories;
53// Incidence *mRelatedTo; Incidence *mRelatedTo; 57// Incidence *mRelatedTo; Incidence *mRelatedTo;
54 mRelatedTo = 0; 58 mRelatedTo = 0;
55 mRelatedToUid = i.mRelatedToUid; 59 mRelatedToUid = i.mRelatedToUid;
56// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
57 mExDates = i.mExDates; 61 mExDates = i.mExDates;
58 mAttachments = i.mAttachments; 62 mAttachments = i.mAttachments;
59 mResources = i.mResources; 63 mResources = i.mResources;
60 mSecrecy = i.mSecrecy; 64 mSecrecy = i.mSecrecy;
61 mPriority = i.mPriority; 65 mPriority = i.mPriority;
62 mLocation = i.mLocation; 66 mLocation = i.mLocation;
63 mCancelled = i.mCancelled; 67 mCancelled = i.mCancelled;
64 mHasStartDate = i.mHasStartDate; 68 mHasStartDate = i.mHasStartDate;
65 QPtrListIterator<Alarm> it( i.mAlarms ); 69 QPtrListIterator<Alarm> it( i.mAlarms );
66 const Alarm *a; 70 const Alarm *a;
67 while( (a = it.current()) ) { 71 while( (a = it.current()) ) {
68 Alarm *b = new Alarm( *a ); 72 Alarm *b = new Alarm( *a );
69 b->setParent( this ); 73 b->setParent( this );
70 mAlarms.append( b ); 74 mAlarms.append( b );
71 75
72 ++it; 76 ++it;
73 } 77 }
74 mAlarms.setAutoDelete(true); 78 mAlarms.setAutoDelete(true);
75 mHasRecurrenceID = i.mHasRecurrenceID; 79 mHasRecurrenceID = i.mHasRecurrenceID;
76 mRecurrenceID = i.mRecurrenceID; 80 mRecurrenceID = i.mRecurrenceID;
77 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 81 mRecurrence = new Recurrence( *(i.mRecurrence), this );
82 mHoliday = i.mHoliday ;
83 mBirthday = i.mBirthday;
84 mAnniversary = i.mAnniversary;
78} 85}
79 86
80Incidence::~Incidence() 87Incidence::~Incidence()
81{ 88{
82 89
83 Incidence *ev; 90 Incidence *ev;
84 QPtrList<Incidence> Relations = relations(); 91 QPtrList<Incidence> Relations = relations();
85 for (ev=Relations.first();ev;ev=Relations.next()) { 92 for (ev=Relations.first();ev;ev=Relations.next()) {
86 if (ev->relatedTo() == this) ev->setRelatedTo(0); 93 if (ev->relatedTo() == this) ev->setRelatedTo(0);
87 } 94 }
88 if (relatedTo()) relatedTo()->removeRelation(this); 95 if (relatedTo()) relatedTo()->removeRelation(this);
89 delete mRecurrence; 96 delete mRecurrence;
90 97
91} 98}
99
100bool Incidence::isHoliday() const
101{
102 return mHoliday;
103}
104bool Incidence::isBirthday() const
105{
106
107 return mBirthday ;
108}
109bool Incidence::isAnniversary() const
110{
111 return mAnniversary ;
112
113}
114
92bool Incidence::hasRecurrenceID() const 115bool Incidence::hasRecurrenceID() const
93{ 116{
94 return mHasRecurrenceID; 117 return mHasRecurrenceID;
95} 118}
96 119
97void Incidence::setHasRecurrenceID( bool b ) 120void Incidence::setHasRecurrenceID( bool b )
98{ 121{
99 mHasRecurrenceID = b; 122 mHasRecurrenceID = b;
100} 123}
101 124
102void Incidence::setRecurrenceID(QDateTime d) 125void Incidence::setRecurrenceID(QDateTime d)
103{ 126{
104 mRecurrenceID = d; 127 mRecurrenceID = d;
105 mHasRecurrenceID = true; 128 mHasRecurrenceID = true;
106 updated(); 129 updated();
107} 130}
108QDateTime Incidence::recurrenceID () const 131QDateTime Incidence::recurrenceID () const
109{ 132{
110 return mRecurrenceID; 133 return mRecurrenceID;
111} 134}
112 135
113bool Incidence::cancelled() const 136bool Incidence::cancelled() const
114{ 137{
115 return mCancelled; 138 return mCancelled;
116} 139}
117void Incidence::setCancelled( bool b ) 140void Incidence::setCancelled( bool b )
118{ 141{
119 mCancelled = b; 142 mCancelled = b;
120 updated(); 143 updated();
121} 144}
122bool Incidence::hasStartDate() const 145bool Incidence::hasStartDate() const
123{ 146{
124 return mHasStartDate; 147 return mHasStartDate;
125} 148}
126 149
127void Incidence::setHasStartDate(bool f) 150void Incidence::setHasStartDate(bool f)
128{ 151{
129 if (mReadOnly) return; 152 if (mReadOnly) return;
130 mHasStartDate = f; 153 mHasStartDate = f;
131 updated(); 154 updated();
132} 155}
133 156
134// A string comparison that considers that null and empty are the same 157// A string comparison that considers that null and empty are the same
135static bool stringCompare( const QString& s1, const QString& s2 ) 158static bool stringCompare( const QString& s1, const QString& s2 )
136{ 159{
137 if ( s1.isEmpty() && s2.isEmpty() ) 160 if ( s1.isEmpty() && s2.isEmpty() )
138 return true; 161 return true;
139 return s1 == s2; 162 return s1 == s2;
140} 163}
141 164
142bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 165bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
143{ 166{
144 167
145 if( i1.alarms().count() != i2.alarms().count() ) { 168 if( i1.alarms().count() != i2.alarms().count() ) {
146 return false; // no need to check further 169 return false; // no need to check further
147 } 170 }
148 if ( i1.alarms().count() > 0 ) { 171 if ( i1.alarms().count() > 0 ) {
149 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 172 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
150 { 173 {
151 qDebug("alarm not equal "); 174 qDebug("alarm not equal ");
152 return false; 175 return false;
153 } 176 }
154 } 177 }
155#if 0 178#if 0
156 QPtrListIterator<Alarm> a1( i1.alarms() ); 179 QPtrListIterator<Alarm> a1( i1.alarms() );
157 QPtrListIterator<Alarm> a2( i2.alarms() ); 180 QPtrListIterator<Alarm> a2( i2.alarms() );
158 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 181 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
159 if( *a1.current() == *a2.current() ) { 182 if( *a1.current() == *a2.current() ) {
160 continue; 183 continue;
161 } 184 }
162 else { 185 else {
163 return false; 186 return false;
164 } 187 }
165 } 188 }
166#endif 189#endif
167 190
168 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { 191 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
169 if ( i1.hasRecurrenceID() ) { 192 if ( i1.hasRecurrenceID() ) {
170 if ( i1.recurrenceID() != i2.recurrenceID() ) 193 if ( i1.recurrenceID() != i2.recurrenceID() )
171 return false; 194 return false;
172 } 195 }
173 196
174 } else { 197 } else {
175 return false; 198 return false;
176 } 199 }
177 200
178 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 201 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
179 return false; 202 return false;
180 if ( i1.hasStartDate() == i2.hasStartDate() ) { 203 if ( i1.hasStartDate() == i2.hasStartDate() ) {
181 if ( i1.hasStartDate() ) { 204 if ( i1.hasStartDate() ) {
182 if ( i1.dtStart() != i2.dtStart() ) 205 if ( i1.dtStart() != i2.dtStart() )
183 return false; 206 return false;
184 } 207 }
185 } else { 208 } else {
186 return false; 209 return false;
187 } 210 }
188 if (!( *i1.recurrence() == *i2.recurrence()) ) { 211 if (!( *i1.recurrence() == *i2.recurrence()) ) {
189 qDebug("recurrence is NOT equal "); 212 qDebug("recurrence is NOT equal ");
190 return false; 213 return false;
191 } 214 }
192 return 215 return
193 // i1.created() == i2.created() && 216 // i1.created() == i2.created() &&
194 stringCompare( i1.description(), i2.description() ) && 217 stringCompare( i1.description(), i2.description() ) &&
195 stringCompare( i1.summary(), i2.summary() ) && 218 stringCompare( i1.summary(), i2.summary() ) &&
196 i1.categories() == i2.categories() && 219 i1.categories() == i2.categories() &&
197 // no need to compare mRelatedTo 220 // no need to compare mRelatedTo
198 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 221 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
199 // i1.relations() == i2.relations() && 222 // i1.relations() == i2.relations() &&
200 i1.exDates() == i2.exDates() && 223 i1.exDates() == i2.exDates() &&
201 i1.attachments() == i2.attachments() && 224 i1.attachments() == i2.attachments() &&
202 i1.resources() == i2.resources() && 225 i1.resources() == i2.resources() &&
203 i1.secrecy() == i2.secrecy() && 226 i1.secrecy() == i2.secrecy() &&
204 i1.priority() == i2.priority() && 227 i1.priority() == i2.priority() &&
205 i1.cancelled() == i2.cancelled() && 228 i1.cancelled() == i2.cancelled() &&
206 stringCompare( i1.location(), i2.location() ); 229 stringCompare( i1.location(), i2.location() );
207} 230}
208 231
209Incidence* Incidence::recreateCloneException( QDate d ) 232Incidence* Incidence::recreateCloneException( QDate d )
210{ 233{
211 Incidence* newInc = clone(); 234 Incidence* newInc = clone();
212 newInc->recreate(); 235 newInc->recreate();
213 if ( doesRecur() ) { 236 if ( doesRecur() ) {
214 addExDate( d ); 237 addExDate( d );
215 newInc->recurrence()->unsetRecurs(); 238 newInc->recurrence()->unsetRecurs();
216 if ( type() == "Event") { 239 if ( type() == "Event") {
217 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 240 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
218 QTime tim = dtStart().time(); 241 QTime tim = dtStart().time();
219 newInc->setDtStart( QDateTime(d, tim) ); 242 newInc->setDtStart( QDateTime(d, tim) );
220 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 243 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
221 } else { 244 } else {
222 int len = dtStart().secsTo( ((Todo*)this)->dtDue()); 245 int len = dtStart().secsTo( ((Todo*)this)->dtDue());
223 QTime tim = ((Todo*)this)->dtDue().time(); 246 QTime tim = ((Todo*)this)->dtDue().time();
224 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); 247 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
225 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); 248 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
226 ((Todo*)this)->setRecurDates(); 249 ((Todo*)this)->setRecurDates();
227 } 250 }
228 } 251 }
229 return newInc; 252 return newInc;
230} 253}
231 254
232void Incidence::recreate() 255void Incidence::recreate()
233{ 256{
234 setCreated(QDateTime::currentDateTime()); 257 setCreated(QDateTime::currentDateTime());
235 258
236 setUid(CalFormat::createUniqueId()); 259 setUid(CalFormat::createUniqueId());
237 260
238 setRevision(0); 261 setRevision(0);
239 setIDStr( ":" ); 262 setIDStr( ":" );
240 setLastModified(QDateTime::currentDateTime()); 263 setLastModified(QDateTime::currentDateTime());
241} 264}
242 265
243void Incidence::setReadOnly( bool readOnly ) 266void Incidence::setReadOnly( bool readOnly )
244{ 267{
245 IncidenceBase::setReadOnly( readOnly ); 268 IncidenceBase::setReadOnly( readOnly );
246 recurrence()->setRecurReadOnly( readOnly); 269 recurrence()->setRecurReadOnly( readOnly);
247} 270}
248 271
249void Incidence::setCreated(QDateTime created) 272void Incidence::setCreated(QDateTime created)
250{ 273{
251 if (mReadOnly) return; 274 if (mReadOnly) return;
252 mCreated = getEvenTime(created); 275 mCreated = getEvenTime(created);
253} 276}
254 277
255QDateTime Incidence::created() const 278QDateTime Incidence::created() const
256{ 279{
257 return mCreated; 280 return mCreated;
258} 281}
259 282
260void Incidence::setRevision(int rev) 283void Incidence::setRevision(int rev)
261{ 284{
262 if (mReadOnly) return; 285 if (mReadOnly) return;
263 mRevision = rev; 286 mRevision = rev;
264 287
265 updated(); 288 updated();
266} 289}
267 290
268int Incidence::revision() const 291int Incidence::revision() const
269{ 292{
270 return mRevision; 293 return mRevision;
271} 294}
272 295
273void Incidence::setDtStart(const QDateTime &dtStart) 296void Incidence::setDtStart(const QDateTime &dtStart)
274{ 297{
275 298
276 QDateTime dt = getEvenTime(dtStart); 299 QDateTime dt = getEvenTime(dtStart);
277 recurrence()->setRecurStart( dt); 300 recurrence()->setRecurStart( dt);
278 IncidenceBase::setDtStart( dt ); 301 IncidenceBase::setDtStart( dt );
279} 302}
280 303
281void Incidence::setDescription(const QString &description) 304void Incidence::setDescription(const QString &description)
282{ 305{
283 if (mReadOnly) return; 306 if (mReadOnly) return;
284 mDescription = description; 307 mDescription = description;
285 updated(); 308 updated();
286} 309}
287 310
288QString Incidence::description() const 311QString Incidence::description() const
289{ 312{
290 return mDescription; 313 return mDescription;
291} 314}
292 315
293 316
294void Incidence::setSummary(const QString &summary) 317void Incidence::setSummary(const QString &summary)
295{ 318{
296 if (mReadOnly) return; 319 if (mReadOnly) return;
297 mSummary = summary; 320 mSummary = summary;
298 updated(); 321 updated();
299} 322}
300 323
301QString Incidence::summary() const 324QString Incidence::summary() const
302{ 325{
303 return mSummary; 326 return mSummary;
304} 327}
328void Incidence::checkCategories()
329{
330 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
331 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
332 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
333}
305 334
306void Incidence::setCategories(const QStringList &categories) 335void Incidence::setCategories(const QStringList &categories)
307{ 336{
308 if (mReadOnly) return; 337 if (mReadOnly) return;
309 mCategories = categories; 338 mCategories = categories;
339 checkCategories();
310 updated(); 340 updated();
311} 341}
312 342
313// TODO: remove setCategories(QString) function 343// TODO: remove setCategories(QString) function
314void Incidence::setCategories(const QString &catStr) 344void Incidence::setCategories(const QString &catStr)
315{ 345{
316 if (mReadOnly) return; 346 if (mReadOnly) return;
317 mCategories.clear(); 347 mCategories.clear();
318 348
319 if (catStr.isEmpty()) return; 349 if (catStr.isEmpty()) return;
320 350
321 mCategories = QStringList::split(",",catStr); 351 mCategories = QStringList::split(",",catStr);
322 352
323 QStringList::Iterator it; 353 QStringList::Iterator it;
324 for(it = mCategories.begin();it != mCategories.end(); ++it) { 354 for(it = mCategories.begin();it != mCategories.end(); ++it) {
325 *it = (*it).stripWhiteSpace(); 355 *it = (*it).stripWhiteSpace();
326 } 356 }
327 357 checkCategories();
328 updated(); 358 updated();
329} 359}
330 360
331QStringList Incidence::categories() const 361QStringList Incidence::categories() const
332{ 362{
333 return mCategories; 363 return mCategories;
334} 364}
335 365
336QString Incidence::categoriesStr() 366QString Incidence::categoriesStr()
337{ 367{
338 return mCategories.join(","); 368 return mCategories.join(",");
339} 369}
340 370
341void Incidence::setRelatedToUid(const QString &relatedToUid) 371void Incidence::setRelatedToUid(const QString &relatedToUid)
342{ 372{
343 if (mReadOnly) return; 373 if (mReadOnly) return;
344 mRelatedToUid = relatedToUid; 374 mRelatedToUid = relatedToUid;
345} 375}
346 376
347QString Incidence::relatedToUid() const 377QString Incidence::relatedToUid() const
348{ 378{
349 return mRelatedToUid; 379 return mRelatedToUid;
350} 380}
351 381
352void Incidence::setRelatedTo(Incidence *relatedTo) 382void Incidence::setRelatedTo(Incidence *relatedTo)
353{ 383{
354 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 384 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
355 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 385 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
356 if (mReadOnly || mRelatedTo == relatedTo) return; 386 if (mReadOnly || mRelatedTo == relatedTo) return;
357 if(mRelatedTo) { 387 if(mRelatedTo) {
358 // updated(); 388 // updated();
359 mRelatedTo->removeRelation(this); 389 mRelatedTo->removeRelation(this);
360 } 390 }
361 mRelatedTo = relatedTo; 391 mRelatedTo = relatedTo;
362 if (mRelatedTo) mRelatedTo->addRelation(this); 392 if (mRelatedTo) mRelatedTo->addRelation(this);
363} 393}
364 394
365Incidence *Incidence::relatedTo() const 395Incidence *Incidence::relatedTo() const
366{ 396{
367 return mRelatedTo; 397 return mRelatedTo;
368} 398}
369 399
370QPtrList<Incidence> Incidence::relations() const 400QPtrList<Incidence> Incidence::relations() const
371{ 401{
372 return mRelations; 402 return mRelations;
373} 403}
374 404
375void Incidence::addRelation(Incidence *event) 405void Incidence::addRelation(Incidence *event)
376{ 406{
377 if( mRelations.findRef( event ) == -1 ) { 407 if( mRelations.findRef( event ) == -1 ) {
378 mRelations.append(event); 408 mRelations.append(event);
379 //updated(); 409 //updated();
380 } 410 }
381} 411}
382 412
383void Incidence::removeRelation(Incidence *event) 413void Incidence::removeRelation(Incidence *event)
384{ 414{
385 415
386 mRelations.removeRef(event); 416 mRelations.removeRef(event);
387 417
388// if (event->getRelatedTo() == this) event->setRelatedTo(0); 418// if (event->getRelatedTo() == this) event->setRelatedTo(0);
389} 419}
390 420
391bool Incidence::recursOn(const QDate &qd) const 421bool Incidence::recursOn(const QDate &qd) const
392{ 422{
393 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; 423 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true;
394 else return false; 424 else return false;
395} 425}
396 426
397void Incidence::setExDates(const DateList &exDates) 427void Incidence::setExDates(const DateList &exDates)
398{ 428{
399 if (mReadOnly) return; 429 if (mReadOnly) return;
400 mExDates = exDates; 430 mExDates = exDates;
401 431
402 recurrence()->setRecurExDatesCount(mExDates.count()); 432 recurrence()->setRecurExDatesCount(mExDates.count());
403 433
404 updated(); 434 updated();
405} 435}
406 436
407void Incidence::addExDate(const QDate &date) 437void Incidence::addExDate(const QDate &date)
408{ 438{
409 if (mReadOnly) return; 439 if (mReadOnly) return;
410 mExDates.append(date); 440 mExDates.append(date);
411 441
412 recurrence()->setRecurExDatesCount(mExDates.count()); 442 recurrence()->setRecurExDatesCount(mExDates.count());
413 443
414 updated(); 444 updated();
415} 445}
416 446
417DateList Incidence::exDates() const 447DateList Incidence::exDates() const
418{ 448{
419 return mExDates; 449 return mExDates;
420} 450}
421 451
422bool Incidence::isException(const QDate &date) const 452bool Incidence::isException(const QDate &date) const
423{ 453{
424 DateList::ConstIterator it; 454 DateList::ConstIterator it;
425 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 455 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
426 if ( (*it) == date ) { 456 if ( (*it) == date ) {
427 return true; 457 return true;
428 } 458 }
429 } 459 }
430 460
431 return false; 461 return false;
432} 462}
433 463
434void Incidence::addAttachment(Attachment *attachment) 464void Incidence::addAttachment(Attachment *attachment)
435{ 465{
436 if (mReadOnly || !attachment) return; 466 if (mReadOnly || !attachment) return;
437 mAttachments.append(attachment); 467 mAttachments.append(attachment);
438 updated(); 468 updated();
439} 469}
440 470
441void Incidence::deleteAttachment(Attachment *attachment) 471void Incidence::deleteAttachment(Attachment *attachment)
442{ 472{
443 mAttachments.removeRef(attachment); 473 mAttachments.removeRef(attachment);
444} 474}
445 475
446void Incidence::deleteAttachments(const QString& mime) 476void Incidence::deleteAttachments(const QString& mime)
447{ 477{
448 Attachment *at = mAttachments.first(); 478 Attachment *at = mAttachments.first();
449 while (at) { 479 while (at) {
450 if (at->mimeType() == mime) 480 if (at->mimeType() == mime)
451 mAttachments.remove(); 481 mAttachments.remove();
452 else 482 else
453 at = mAttachments.next(); 483 at = mAttachments.next();
454 } 484 }
455} 485}
456 486
457QPtrList<Attachment> Incidence::attachments() const 487QPtrList<Attachment> Incidence::attachments() const
458{ 488{
459 return mAttachments; 489 return mAttachments;
460} 490}
461 491
462QPtrList<Attachment> Incidence::attachments(const QString& mime) const 492QPtrList<Attachment> Incidence::attachments(const QString& mime) const
463{ 493{
464 QPtrList<Attachment> attachments; 494 QPtrList<Attachment> attachments;
465 QPtrListIterator<Attachment> it( mAttachments ); 495 QPtrListIterator<Attachment> it( mAttachments );
466 Attachment *at; 496 Attachment *at;
467 while ( (at = it.current()) ) { 497 while ( (at = it.current()) ) {
468 if (at->mimeType() == mime) 498 if (at->mimeType() == mime)
469 attachments.append(at); 499 attachments.append(at);
470 ++it; 500 ++it;
471 } 501 }
472 502
473 return attachments; 503 return attachments;
474} 504}
475 505
476void Incidence::setResources(const QStringList &resources) 506void Incidence::setResources(const QStringList &resources)
477{ 507{
478 if (mReadOnly) return; 508 if (mReadOnly) return;
479 mResources = resources; 509 mResources = resources;
480 updated(); 510 updated();
481} 511}
482 512
483QStringList Incidence::resources() const 513QStringList Incidence::resources() const
484{ 514{
485 return mResources; 515 return mResources;
486} 516}
487 517
488 518
489void Incidence::setPriority(int priority) 519void Incidence::setPriority(int priority)
490{ 520{
491 if (mReadOnly) return; 521 if (mReadOnly) return;
492 mPriority = priority; 522 mPriority = priority;
493 updated(); 523 updated();
494} 524}
495 525
496int Incidence::priority() const 526int Incidence::priority() const
497{ 527{
498 return mPriority; 528 return mPriority;
499} 529}
500 530
501void Incidence::setSecrecy(int sec) 531void Incidence::setSecrecy(int sec)
502{ 532{
503 if (mReadOnly) return; 533 if (mReadOnly) return;
504 mSecrecy = sec; 534 mSecrecy = sec;
505 updated(); 535 updated();
506} 536}
507 537
508int Incidence::secrecy() const 538int Incidence::secrecy() const
509{ 539{
510 return mSecrecy; 540 return mSecrecy;
511} 541}
512 542
513QString Incidence::secrecyStr() const 543QString Incidence::secrecyStr() const
514{ 544{
515 return secrecyName(mSecrecy); 545 return secrecyName(mSecrecy);
516} 546}
517 547
518QString Incidence::secrecyName(int secrecy) 548QString Incidence::secrecyName(int secrecy)
519{ 549{
520 switch (secrecy) { 550 switch (secrecy) {
521 case SecrecyPublic: 551 case SecrecyPublic:
522 return i18n("Public"); 552 return i18n("Public");
523 break; 553 break;
524 case SecrecyPrivate: 554 case SecrecyPrivate:
525 return i18n("Private"); 555 return i18n("Private");
526 break; 556 break;
527 case SecrecyConfidential: 557 case SecrecyConfidential:
528 return i18n("Confidential"); 558 return i18n("Confidential");
529 break; 559 break;
530 default: 560 default:
531 return i18n("Undefined"); 561 return i18n("Undefined");
532 break; 562 break;
533 } 563 }
534} 564}
535 565
536QStringList Incidence::secrecyList() 566QStringList Incidence::secrecyList()
537{ 567{
538 QStringList list; 568 QStringList list;
539 list << secrecyName(SecrecyPublic); 569 list << secrecyName(SecrecyPublic);
540 list << secrecyName(SecrecyPrivate); 570 list << secrecyName(SecrecyPrivate);
541 list << secrecyName(SecrecyConfidential); 571 list << secrecyName(SecrecyConfidential);
542 572
543 return list; 573 return list;
544} 574}
545 575
546 576
547QPtrList<Alarm> Incidence::alarms() const 577QPtrList<Alarm> Incidence::alarms() const
548{ 578{
549 return mAlarms; 579 return mAlarms;
550} 580}
551 581
552Alarm* Incidence::newAlarm() 582Alarm* Incidence::newAlarm()
553{ 583{
554 Alarm* alarm = new Alarm(this); 584 Alarm* alarm = new Alarm(this);
555 mAlarms.append(alarm); 585 mAlarms.append(alarm);
556// updated(); 586// updated();
557 return alarm; 587 return alarm;
558} 588}
559 589
560void Incidence::addAlarm(Alarm *alarm) 590void Incidence::addAlarm(Alarm *alarm)
561{ 591{
562 mAlarms.append(alarm); 592 mAlarms.append(alarm);
563 updated(); 593 updated();
564} 594}
565 595
566void Incidence::removeAlarm(Alarm *alarm) 596void Incidence::removeAlarm(Alarm *alarm)
567{ 597{
568 mAlarms.removeRef(alarm); 598 mAlarms.removeRef(alarm);
569 updated(); 599 updated();
570} 600}
571 601
572void Incidence::clearAlarms() 602void Incidence::clearAlarms()
573{ 603{
574 mAlarms.clear(); 604 mAlarms.clear();
575 updated(); 605 updated();
576} 606}
577 607
578bool Incidence::isAlarmEnabled() const 608bool Incidence::isAlarmEnabled() const
579{ 609{
580 Alarm* alarm; 610 Alarm* alarm;
581 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 611 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
582 if (alarm->enabled()) 612 if (alarm->enabled())
583 return true; 613 return true;
584 } 614 }
585 return false; 615 return false;
586} 616}
587 617
588Recurrence *Incidence::recurrence() const 618Recurrence *Incidence::recurrence() const
589{ 619{
590 return mRecurrence; 620 return mRecurrence;
591} 621}
592void Incidence::setRecurrence( Recurrence * r) 622void Incidence::setRecurrence( Recurrence * r)
593{ 623{
594 delete mRecurrence; 624 delete mRecurrence;
595 mRecurrence = r; 625 mRecurrence = r;
596} 626}
597 627
598void Incidence::setLocation(const QString &location) 628void Incidence::setLocation(const QString &location)
599{ 629{
600 if (mReadOnly) return; 630 if (mReadOnly) return;
601 mLocation = location; 631 mLocation = location;
602 updated(); 632 updated();
603} 633}
604 634
605QString Incidence::location() const 635QString Incidence::location() const
606{ 636{
607 return mLocation; 637 return mLocation;
608} 638}
609 639
610ushort Incidence::doesRecur() const 640ushort Incidence::doesRecur() const
611{ 641{
612 if ( mRecurrence ) return mRecurrence->doesRecur(); 642 if ( mRecurrence ) return mRecurrence->doesRecur();
613 else return Recurrence::rNone; 643 else return Recurrence::rNone;
614} 644}
615 645
616QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 646QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
617{ 647{
618 QDateTime incidenceStart = dt; 648 QDateTime incidenceStart = dt;
619 *ok = false; 649 *ok = false;
620 if ( doesRecur() ) { 650 if ( doesRecur() ) {
621 bool last; 651 bool last;
622 recurrence()->getPreviousDateTime( incidenceStart , &last ); 652 recurrence()->getPreviousDateTime( incidenceStart , &last );
623 int count = 0; 653 int count = 0;
624 if ( !last ) { 654 if ( !last ) {
625 while ( !last ) { 655 while ( !last ) {
626 ++count; 656 ++count;
627 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); 657 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last );
628 if ( recursOn( incidenceStart.date() ) ) { 658 if ( recursOn( incidenceStart.date() ) ) {
629 last = true; // exit while llop 659 last = true; // exit while llop
630 } else { 660 } else {
631 if ( last ) { // no alarm on last recurrence 661 if ( last ) { // no alarm on last recurrence
632 return QDateTime (); 662 return QDateTime ();
633 } 663 }
634 int year = incidenceStart.date().year(); 664 int year = incidenceStart.date().year();
635 // workaround for bug in recurrence 665 // workaround for bug in recurrence
636 if ( count == 100 || year < 1000 || year > 5000 ) { 666 if ( count == 100 || year < 1000 || year > 5000 ) {
637 return QDateTime (); 667 return QDateTime ();
638 } 668 }
639 incidenceStart = incidenceStart.addSecs( 1 ); 669 incidenceStart = incidenceStart.addSecs( 1 );
640 } 670 }
641 } 671 }
642 } else { 672 } else {
643 return QDateTime (); 673 return QDateTime ();
644 } 674 }
645 } else { 675 } else {
646 if ( hasStartDate () ) { 676 if ( hasStartDate () ) {
647 incidenceStart = dtStart(); 677 incidenceStart = dtStart();
648 } 678 }
649 if ( type() =="Todo" ) { 679 if ( type() =="Todo" ) {
650 if ( ((Todo*)this)->hasDueDate() ) 680 if ( ((Todo*)this)->hasDueDate() )
651 incidenceStart = ((Todo*)this)->dtDue(); 681 incidenceStart = ((Todo*)this)->dtDue();
652 } 682 }
653 } 683 }
654 if ( incidenceStart > dt ) 684 if ( incidenceStart > dt )
655 *ok = true; 685 *ok = true;
656 return incidenceStart; 686 return incidenceStart;
657} 687}
658QDateTime Incidence::dtStart() const 688QDateTime Incidence::dtStart() const
659{ 689{
660 if ( doesRecur() ) { 690 if ( doesRecur() ) {
661 if ( type() == "Todo" ) { 691 if ( type() == "Todo" ) {
662 ((Todo*)this)->checkSetCompletedFalse(); 692 ((Todo*)this)->checkSetCompletedFalse();
663 } 693 }
664 } 694 }
665 return mDtStart; 695 return mDtStart;
666} 696}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 0ae9656..f8da342 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -1,309 +1,314 @@
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 115
116 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; 116 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0;
117 void setReadOnly( bool ); 117 void setReadOnly( bool );
118 118
119 /** 119 /**
120 Recreate event. The event is made a new unique event, but already stored 120 Recreate event. The event is made a new unique event, but already stored
121 event information is preserved. Sets uniquie id, creation date, last 121 event information is preserved. Sets uniquie id, creation date, last
122 modification date and revision number. 122 modification date and revision number.
123 */ 123 */
124 void recreate(); 124 void recreate();
125 Incidence* recreateCloneException(QDate); 125 Incidence* recreateCloneException(QDate);
126 126
127 /** set creation date */ 127 /** set creation date */
128 void setCreated(QDateTime); 128 void setCreated(QDateTime);
129 /** return time and date of creation. */ 129 /** return time and date of creation. */
130 QDateTime created() const; 130 QDateTime created() const;
131 131
132 /** set the number of revisions this event has seen */ 132 /** set the number of revisions this event has seen */
133 void setRevision(int rev); 133 void setRevision(int rev);
134 /** return the number of revisions this event has seen */ 134 /** return the number of revisions this event has seen */
135 int revision() const; 135 int revision() const;
136 136
137 /** Set starting date/time. */ 137 /** Set starting date/time. */
138 virtual void setDtStart(const QDateTime &dtStart); 138 virtual void setDtStart(const QDateTime &dtStart);
139 /** Return the incidence's ending date/time as a QDateTime. */ 139 /** Return the incidence's ending date/time as a QDateTime. */
140 virtual QDateTime dtEnd() const { return QDateTime(); } 140 virtual QDateTime dtEnd() const { return QDateTime(); }
141 141
142 /** sets the event's lengthy description. */ 142 /** sets the event's lengthy description. */
143 void setDescription(const QString &description); 143 void setDescription(const QString &description);
144 /** returns a reference to the event's description. */ 144 /** returns a reference to the event's description. */
145 QString description() const; 145 QString description() const;
146 146
147 /** sets the event's short summary. */ 147 /** sets the event's short summary. */
148 void setSummary(const QString &summary); 148 void setSummary(const QString &summary);
149 /** returns a reference to the event's summary. */ 149 /** returns a reference to the event's summary. */
150 QString summary() const; 150 QString summary() const;
151 151
152 /** set event's applicable categories */ 152 /** set event's applicable categories */
153 void setCategories(const QStringList &categories); 153 void setCategories(const QStringList &categories);
154 /** set event's categories based on a comma delimited string */ 154 /** set event's categories based on a comma delimited string */
155 void setCategories(const QString &catStr); 155 void setCategories(const QString &catStr);
156 /** return categories in a list */ 156 /** return categories in a list */
157 QStringList categories() const; 157 QStringList categories() const;
158 /** return categories as a comma separated string */ 158 /** return categories as a comma separated string */
159 QString categoriesStr(); 159 QString categoriesStr();
160 160
161 /** point at some other event to which the event relates. This function should 161 /** point at some other event to which the event relates. This function should
162 * only be used when constructing a calendar before the related Event 162 * only be used when constructing a calendar before the related Event
163 * exists. */ 163 * exists. */
164 void setRelatedToUid(const QString &); 164 void setRelatedToUid(const QString &);
165 /** what event does this one relate to? This function should 165 /** what event does this one relate to? This function should
166 * only be used when constructing a calendar before the related Event 166 * only be used when constructing a calendar before the related Event
167 * exists. */ 167 * exists. */
168 QString relatedToUid() const; 168 QString relatedToUid() const;
169 /** point at some other event to which the event relates */ 169 /** point at some other event to which the event relates */
170 void setRelatedTo(Incidence *relatedTo); 170 void setRelatedTo(Incidence *relatedTo);
171 /** what event does this one relate to? */ 171 /** what event does this one relate to? */
172 Incidence *relatedTo() const; 172 Incidence *relatedTo() const;
173 /** All events that are related to this event */ 173 /** All events that are related to this event */
174 QPtrList<Incidence> relations() const; 174 QPtrList<Incidence> relations() const;
175 /** Add an event which is related to this event */ 175 /** Add an event which is related to this event */
176 void addRelation(Incidence *); 176 void addRelation(Incidence *);
177 /** Remove event that is related to this event */ 177 /** Remove event that is related to this event */
178 void removeRelation(Incidence *); 178 void removeRelation(Incidence *);
179 179
180 /** returns the list of dates which are exceptions to the recurrence rule */ 180 /** returns the list of dates which are exceptions to the recurrence rule */
181 DateList exDates() const; 181 DateList exDates() const;
182 /** sets the list of dates which are exceptions to the recurrence rule */ 182 /** sets the list of dates which are exceptions to the recurrence rule */
183 void setExDates(const DateList &_exDates); 183 void setExDates(const DateList &_exDates);
184 void setExDates(const char *dates); 184 void setExDates(const char *dates);
185 /** Add a date to the list of exceptions of the recurrence rule. */ 185 /** Add a date to the list of exceptions of the recurrence rule. */
186 void addExDate(const QDate &date); 186 void addExDate(const QDate &date);
187 187
188 /** returns true if there is an exception for this date in the recurrence 188 /** returns true if there is an exception for this date in the recurrence
189 rule set, or false otherwise. */ 189 rule set, or false otherwise. */
190 bool isException(const QDate &qd) const; 190 bool isException(const QDate &qd) const;
191 191
192 /** add attachment to this event */ 192 /** add attachment to this event */
193 void addAttachment(Attachment *attachment); 193 void addAttachment(Attachment *attachment);
194 /** remove and delete a specific attachment */ 194 /** remove and delete a specific attachment */
195 void deleteAttachment(Attachment *attachment); 195 void deleteAttachment(Attachment *attachment);
196 /** remove and delete all attachments with this mime type */ 196 /** remove and delete all attachments with this mime type */
197 void deleteAttachments(const QString& mime); 197 void deleteAttachments(const QString& mime);
198 /** return list of all associated attachments */ 198 /** return list of all associated attachments */
199 QPtrList<Attachment> attachments() const; 199 QPtrList<Attachment> attachments() const;
200 /** find a list of attachments with this mime type */ 200 /** find a list of attachments with this mime type */
201 QPtrList<Attachment> attachments(const QString& mime) const; 201 QPtrList<Attachment> attachments(const QString& mime) const;
202 202
203 /** sets the event's status the value specified. See the enumeration 203 /** sets the event's status the value specified. See the enumeration
204 * above for possible values. */ 204 * above for possible values. */
205 void setSecrecy(int); 205 void setSecrecy(int);
206 /** return the event's secrecy. */ 206 /** return the event's secrecy. */
207 int secrecy() const; 207 int secrecy() const;
208 /** return the event's secrecy in string format. */ 208 /** return the event's secrecy in string format. */
209 QString secrecyStr() const; 209 QString secrecyStr() const;
210 /** return list of all availbale secrecy classes */ 210 /** return list of all availbale secrecy classes */
211 static QStringList secrecyList(); 211 static QStringList secrecyList();
212 /** return human-readable name of secrecy class */ 212 /** return human-readable name of secrecy class */
213 static QString secrecyName(int); 213 static QString secrecyName(int);
214 214
215 /** returns TRUE if the date specified is one on which the event will 215 /** returns TRUE if the date specified is one on which the event will
216 * recur. */ 216 * recur. */
217 bool recursOn(const QDate &qd) const; 217 bool recursOn(const QDate &qd) const;
218 218
219 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 219 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
220 220
221 /** set resources used, such as Office, Car, etc. */ 221 /** set resources used, such as Office, Car, etc. */
222 void setResources(const QStringList &resources); 222 void setResources(const QStringList &resources);
223 /** return list of current resources */ 223 /** return list of current resources */
224 QStringList resources() const; 224 QStringList resources() const;
225 225
226 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 226 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
227 void setPriority(int priority); 227 void setPriority(int priority);
228 /** get the event's priority */ 228 /** get the event's priority */
229 int priority() const; 229 int priority() const;
230 230
231 /** All alarms that are associated with this incidence */ 231 /** All alarms that are associated with this incidence */
232 QPtrList<Alarm> alarms() const; 232 QPtrList<Alarm> alarms() const;
233 /** Create a new alarm which is associated with this incidence */ 233 /** Create a new alarm which is associated with this incidence */
234 Alarm* newAlarm(); 234 Alarm* newAlarm();
235 /** Add an alarm which is associated with this incidence */ 235 /** Add an alarm which is associated with this incidence */
236 void addAlarm(Alarm*); 236 void addAlarm(Alarm*);
237 /** Remove an alarm that is associated with this incidence */ 237 /** Remove an alarm that is associated with this incidence */
238 void removeAlarm(Alarm*); 238 void removeAlarm(Alarm*);
239 /** Remove all alarms that are associated with this incidence */ 239 /** Remove all alarms that are associated with this incidence */
240 void clearAlarms(); 240 void clearAlarms();
241 /** return whether any alarm associated with this incidence is enabled */ 241 /** return whether any alarm associated with this incidence is enabled */
242 bool isAlarmEnabled() const; 242 bool isAlarmEnabled() const;
243 243
244 /** 244 /**
245 Return the recurrence rule associated with this incidence. If there is 245 Return the recurrence rule associated with this incidence. If there is
246 none, returns an appropriate (non-0) object. 246 none, returns an appropriate (non-0) object.
247 */ 247 */
248 Recurrence *recurrence() const; 248 Recurrence *recurrence() const;
249 void setRecurrence(Recurrence * r); 249 void setRecurrence(Recurrence * r);
250 /** 250 /**
251 Forward to Recurrence::doesRecur(). 251 Forward to Recurrence::doesRecur().
252 */ 252 */
253 ushort doesRecur() const; 253 ushort doesRecur() const;
254 254
255 /** set the event's/todo's location. Do _not_ use it with journal */ 255 /** set the event's/todo's location. Do _not_ use it with journal */
256 void setLocation(const QString &location); 256 void setLocation(const QString &location);
257 /** return the event's/todo's location. Do _not_ use it with journal */ 257 /** return the event's/todo's location. Do _not_ use it with journal */
258 QString location() const; 258 QString location() const;
259 /** returns TRUE or FALSE depending on whether the todo has a start date */ 259 /** returns TRUE or FALSE depending on whether the todo has a start date */
260 bool hasStartDate() const; 260 bool hasStartDate() const;
261 /** sets the event's hasStartDate value. */ 261 /** sets the event's hasStartDate value. */
262 void setHasStartDate(bool f); 262 void setHasStartDate(bool f);
263 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 263 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
264 bool cancelled() const; 264 bool cancelled() const;
265 void setCancelled( bool b ); 265 void setCancelled( bool b );
266 266
267 bool hasRecurrenceID() const; 267 bool hasRecurrenceID() const;
268 void setHasRecurrenceID( bool b ); 268 void setHasRecurrenceID( bool b );
269 269
270 void setRecurrenceID(QDateTime); 270 void setRecurrenceID(QDateTime);
271 QDateTime recurrenceID () const; 271 QDateTime recurrenceID () const;
272 QDateTime dtStart() const; 272 QDateTime dtStart() const;
273 bool isHoliday() const;
274 bool isBirthday() const;
275 bool isAnniversary() const;
273 276
274 277
275protected: 278protected:
276 QPtrList<Alarm> mAlarms; 279 QPtrList<Alarm> mAlarms;
277 QPtrList<Incidence> mRelations; 280 QPtrList<Incidence> mRelations;
278 QDateTime mRecurrenceID; 281 QDateTime mRecurrenceID;
279 bool mHasRecurrenceID; 282 bool mHasRecurrenceID;
280 private: 283 private:
284 void checkCategories();
285 bool mHoliday, mBirthday, mAnniversary;
281 int mRevision; 286 int mRevision;
282 bool mCancelled; 287 bool mCancelled;
283 288
284 // base components of jounal, event and todo 289 // base components of jounal, event and todo
285 QDateTime mCreated; 290 QDateTime mCreated;
286 QString mDescription; 291 QString mDescription;
287 QString mSummary; 292 QString mSummary;
288 QStringList mCategories; 293 QStringList mCategories;
289 Incidence *mRelatedTo; 294 Incidence *mRelatedTo;
290 QString mRelatedToUid; 295 QString mRelatedToUid;
291 DateList mExDates; 296 DateList mExDates;
292 QPtrList<Attachment> mAttachments; 297 QPtrList<Attachment> mAttachments;
293 QStringList mResources; 298 QStringList mResources;
294 bool mHasStartDate; // if todo has associated start date 299 bool mHasStartDate; // if todo has associated start date
295 300
296 int mSecrecy; 301 int mSecrecy;
297 int mPriority; // 1 = highest, 2 = less, etc. 302 int mPriority; // 1 = highest, 2 = less, etc.
298 303
299 //QPtrList<Alarm> mAlarms; 304 //QPtrList<Alarm> mAlarms;
300 Recurrence *mRecurrence; 305 Recurrence *mRecurrence;
301 306
302 QString mLocation; 307 QString mLocation;
303}; 308};
304 309
305bool operator==( const Incidence&, const Incidence& ); 310bool operator==( const Incidence&, const Incidence& );
306 311
307} 312}
308 313
309#endif 314#endif