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