summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp28
-rw-r--r--libkcal/incidence.h3
-rw-r--r--libkcal/incidencebase.cpp4
-rw-r--r--libkcal/incidencebase.h1
4 files changed, 32 insertions, 4 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 11f7ecc..e4bcc5e 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -1,760 +1,780 @@
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 ( typeID() == eventID ) { 239 if ( typeID() == eventID ) {
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 284void Incidence::setLastModifiedSubInvalid()
285{
286 mLastModifiedSub = QDateTime();
287 if ( mRelatedTo )
288 mRelatedTo->setLastModifiedSubInvalid();
289}
290QDateTime Incidence::lastModifiedSub()
291{
292 if ( !mRelations.count() )
293 return lastModified();
294 if ( mLastModifiedSub.isValid() )
295 return mLastModifiedSub;
296 mLastModifiedSub = lastModified();
297 Incidence * inc;
298 QPtrList<Incidence> Relations = relations();
299 for (inc=Relations.first();inc;inc=Relations.next()) {
300 if ( inc->lastModifiedSub() > mLastModifiedSub )
301 mLastModifiedSub = inc->lastModifiedSub();
302 }
303 return mLastModifiedSub;
304}
285void Incidence::setCreated(QDateTime created) 305void Incidence::setCreated(QDateTime created)
286{ 306{
287 if (mReadOnly) return; 307 if (mReadOnly) return;
288 mCreated = getEvenTime(created); 308 mCreated = getEvenTime(created);
289} 309}
290 310
291QDateTime Incidence::created() const 311QDateTime Incidence::created() const
292{ 312{
293 return mCreated; 313 return mCreated;
294} 314}
295 315
296void Incidence::setRevision(int rev) 316void Incidence::setRevision(int rev)
297{ 317{
298 if (mReadOnly) return; 318 if (mReadOnly) return;
299 mRevision = rev; 319 mRevision = rev;
300 320
301 updated(); 321 updated();
302} 322}
303 323
304int Incidence::revision() const 324int Incidence::revision() const
305{ 325{
306 return mRevision; 326 return mRevision;
307} 327}
308 328
309void Incidence::setDtStart(const QDateTime &dtStart) 329void Incidence::setDtStart(const QDateTime &dtStart)
310{ 330{
311 331
312 QDateTime dt = getEvenTime(dtStart); 332 QDateTime dt = getEvenTime(dtStart);
313 recurrence()->setRecurStart( dt); 333 recurrence()->setRecurStart( dt);
314 IncidenceBase::setDtStart( dt ); 334 IncidenceBase::setDtStart( dt );
315} 335}
316 336
317void Incidence::setDescription(const QString &description) 337void Incidence::setDescription(const QString &description)
318{ 338{
319 if (mReadOnly) return; 339 if (mReadOnly) return;
320 mDescription = description; 340 mDescription = description;
321 updated(); 341 updated();
322} 342}
323 343
324QString Incidence::description() const 344QString Incidence::description() const
325{ 345{
326 return mDescription; 346 return mDescription;
327} 347}
328 348
329 349
330void Incidence::setSummary(const QString &summary) 350void Incidence::setSummary(const QString &summary)
331{ 351{
332 if (mReadOnly) return; 352 if (mReadOnly) return;
333 mSummary = summary; 353 mSummary = summary;
334 updated(); 354 updated();
335} 355}
336 356
337QString Incidence::summary() const 357QString Incidence::summary() const
338{ 358{
339 return mSummary; 359 return mSummary;
340} 360}
341void Incidence::checkCategories() 361void Incidence::checkCategories()
342{ 362{
343 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 363 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
344 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 364 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
345 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 365 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
346} 366}
347 367
348void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 368void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
349{ 369{
350 if (mReadOnly) return; 370 if (mReadOnly) return;
351 int i; 371 int i;
352 for( i = 0; i < categories.count(); ++i ) { 372 for( i = 0; i < categories.count(); ++i ) {
353 if ( !mCategories.contains (categories[i])) 373 if ( !mCategories.contains (categories[i]))
354 mCategories.append( categories[i] ); 374 mCategories.append( categories[i] );
355 } 375 }
356 checkCategories(); 376 checkCategories();
357 updated(); 377 updated();
358 if ( addToRelations ) { 378 if ( addToRelations ) {
359 Incidence * inc; 379 Incidence * inc;
360 QPtrList<Incidence> Relations = relations(); 380 QPtrList<Incidence> Relations = relations();
361 for (inc=Relations.first();inc;inc=Relations.next()) { 381 for (inc=Relations.first();inc;inc=Relations.next()) {
362 inc->addCategories( categories, true ); 382 inc->addCategories( categories, true );
363 } 383 }
364 } 384 }
365} 385}
366 386
367void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 387void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
368{ 388{
369 if (mReadOnly) return; 389 if (mReadOnly) return;
370 mCategories = categories; 390 mCategories = categories;
371 checkCategories(); 391 checkCategories();
372 updated(); 392 updated();
373 if ( setForRelations ) { 393 if ( setForRelations ) {
374 Incidence * inc; 394 Incidence * inc;
375 QPtrList<Incidence> Relations = relations(); 395 QPtrList<Incidence> Relations = relations();
376 for (inc=Relations.first();inc;inc=Relations.next()) { 396 for (inc=Relations.first();inc;inc=Relations.next()) {
377 inc->setCategories( categories, true ); 397 inc->setCategories( categories, true );
378 } 398 }
379 } 399 }
380} 400}
381 401
382// TODO: remove setCategories(QString) function 402// TODO: remove setCategories(QString) function
383void Incidence::setCategories(const QString &catStr) 403void Incidence::setCategories(const QString &catStr)
384{ 404{
385 if (mReadOnly) return; 405 if (mReadOnly) return;
386 mCategories.clear(); 406 mCategories.clear();
387 407
388 if (catStr.isEmpty()) return; 408 if (catStr.isEmpty()) return;
389 409
390 mCategories = QStringList::split(",",catStr); 410 mCategories = QStringList::split(",",catStr);
391 411
392 QStringList::Iterator it; 412 QStringList::Iterator it;
393 for(it = mCategories.begin();it != mCategories.end(); ++it) { 413 for(it = mCategories.begin();it != mCategories.end(); ++it) {
394 *it = (*it).stripWhiteSpace(); 414 *it = (*it).stripWhiteSpace();
395 } 415 }
396 checkCategories(); 416 checkCategories();
397 updated(); 417 updated();
398} 418}
399// using this makes filtering 3 times faster 419// using this makes filtering 3 times faster
400QStringList* Incidence::categoriesP() 420QStringList* Incidence::categoriesP()
401{ 421{
402 return &mCategories; 422 return &mCategories;
403} 423}
404 424
405QStringList Incidence::categories() const 425QStringList Incidence::categories() const
406{ 426{
407 return mCategories; 427 return mCategories;
408} 428}
409 429
410QString Incidence::categoriesStr() 430QString Incidence::categoriesStr()
411{ 431{
412 return mCategories.join(","); 432 return mCategories.join(",");
413} 433}
414QString Incidence::categoriesStrWithSpace() 434QString Incidence::categoriesStrWithSpace()
415{ 435{
416 return mCategories.join(", "); 436 return mCategories.join(", ");
417} 437}
418 438
419void Incidence::setRelatedToUid(const QString &relatedToUid) 439void Incidence::setRelatedToUid(const QString &relatedToUid)
420{ 440{
421 if (mReadOnly) return; 441 if (mReadOnly) return;
422 mRelatedToUid = relatedToUid; 442 mRelatedToUid = relatedToUid;
423} 443}
424 444
425QString Incidence::relatedToUid() const 445QString Incidence::relatedToUid() const
426{ 446{
427 return mRelatedToUid; 447 return mRelatedToUid;
428} 448}
429 449
430void Incidence::setRelatedTo(Incidence *relatedTo) 450void Incidence::setRelatedTo(Incidence *relatedTo)
431{ 451{
432 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 452 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
433 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 453 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
434 if (mReadOnly || mRelatedTo == relatedTo) return; 454 if (mReadOnly || mRelatedTo == relatedTo) return;
435 if(mRelatedTo) { 455 if(mRelatedTo) {
436 // updated(); 456 // updated();
437 mRelatedTo->removeRelation(this); 457 mRelatedTo->removeRelation(this);
438 } 458 }
439 mRelatedTo = relatedTo; 459 mRelatedTo = relatedTo;
440 if (mRelatedTo) { 460 if (mRelatedTo) {
441 mRelatedTo->addRelation(this); 461 mRelatedTo->addRelation(this);
442 mRelatedToUid = mRelatedTo->uid(); 462 mRelatedToUid = mRelatedTo->uid();
443 } else { 463 } else {
444 mRelatedToUid = ""; 464 mRelatedToUid = "";
445 } 465 }
446} 466}
447 467
448Incidence *Incidence::relatedTo() const 468Incidence *Incidence::relatedTo() const
449{ 469{
450 return mRelatedTo; 470 return mRelatedTo;
451} 471}
452 472
453QPtrList<Incidence> Incidence::relations() const 473QPtrList<Incidence> Incidence::relations() const
454{ 474{
455 return mRelations; 475 return mRelations;
456} 476}
457 477
458void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 478void Incidence::addRelationsToList(QPtrList<Incidence> *rel)
459{ 479{
460 Incidence* inc; 480 Incidence* inc;
461 QPtrList<Incidence> Relations = relations(); 481 QPtrList<Incidence> Relations = relations();
462 for (inc=Relations.first();inc;inc=Relations.next()) { 482 for (inc=Relations.first();inc;inc=Relations.next()) {
463 inc->addRelationsToList( rel ); 483 inc->addRelationsToList( rel );
464 } 484 }
465 if ( rel->findRef( this ) == -1 ) 485 if ( rel->findRef( this ) == -1 )
466 rel->append( this ); 486 rel->append( this );
467} 487}
468 488
469void Incidence::addRelation(Incidence *event) 489void Incidence::addRelation(Incidence *event)
470{ 490{
491 setLastModifiedSubInvalid();
471 if( mRelations.findRef( event ) == -1 ) { 492 if( mRelations.findRef( event ) == -1 ) {
472 mRelations.append(event); 493 mRelations.append(event);
473 //updated(); 494 //updated();
474 } 495 }
475} 496}
476 497
477void Incidence::removeRelation(Incidence *event) 498void Incidence::removeRelation(Incidence *event)
478{ 499{
479 500 setLastModifiedSubInvalid();
480 mRelations.removeRef(event); 501 mRelations.removeRef(event);
481
482// if (event->getRelatedTo() == this) event->setRelatedTo(0); 502// if (event->getRelatedTo() == this) event->setRelatedTo(0);
483} 503}
484 504
485bool Incidence::recursOn(const QDate &qd) const 505bool Incidence::recursOn(const QDate &qd) const
486{ 506{
487 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; 507 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true;
488 else return false; 508 else return false;
489} 509}
490 510
491void Incidence::setExDates(const DateList &exDates) 511void Incidence::setExDates(const DateList &exDates)
492{ 512{
493 if (mReadOnly) return; 513 if (mReadOnly) return;
494 mExDates = exDates; 514 mExDates = exDates;
495 515
496 recurrence()->setRecurExDatesCount(mExDates.count()); 516 recurrence()->setRecurExDatesCount(mExDates.count());
497 517
498 updated(); 518 updated();
499} 519}
500 520
501void Incidence::addExDate(const QDate &date) 521void Incidence::addExDate(const QDate &date)
502{ 522{
503 if (mReadOnly) return; 523 if (mReadOnly) return;
504 mExDates.append(date); 524 mExDates.append(date);
505 525
506 recurrence()->setRecurExDatesCount(mExDates.count()); 526 recurrence()->setRecurExDatesCount(mExDates.count());
507 527
508 updated(); 528 updated();
509} 529}
510 530
511DateList Incidence::exDates() const 531DateList Incidence::exDates() const
512{ 532{
513 return mExDates; 533 return mExDates;
514} 534}
515 535
516bool Incidence::isException(const QDate &date) const 536bool Incidence::isException(const QDate &date) const
517{ 537{
518 DateList::ConstIterator it; 538 DateList::ConstIterator it;
519 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 539 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
520 if ( (*it) == date ) { 540 if ( (*it) == date ) {
521 return true; 541 return true;
522 } 542 }
523 } 543 }
524 544
525 return false; 545 return false;
526} 546}
527 547
528void Incidence::addAttachment(Attachment *attachment) 548void Incidence::addAttachment(Attachment *attachment)
529{ 549{
530 if (mReadOnly || !attachment) return; 550 if (mReadOnly || !attachment) return;
531 mAttachments.append(attachment); 551 mAttachments.append(attachment);
532 updated(); 552 updated();
533} 553}
534 554
535void Incidence::deleteAttachment(Attachment *attachment) 555void Incidence::deleteAttachment(Attachment *attachment)
536{ 556{
537 mAttachments.removeRef(attachment); 557 mAttachments.removeRef(attachment);
538} 558}
539 559
540void Incidence::deleteAttachments(const QString& mime) 560void Incidence::deleteAttachments(const QString& mime)
541{ 561{
542 Attachment *at = mAttachments.first(); 562 Attachment *at = mAttachments.first();
543 while (at) { 563 while (at) {
544 if (at->mimeType() == mime) 564 if (at->mimeType() == mime)
545 mAttachments.remove(); 565 mAttachments.remove();
546 else 566 else
547 at = mAttachments.next(); 567 at = mAttachments.next();
548 } 568 }
549} 569}
550 570
551QPtrList<Attachment> Incidence::attachments() const 571QPtrList<Attachment> Incidence::attachments() const
552{ 572{
553 return mAttachments; 573 return mAttachments;
554} 574}
555 575
556QPtrList<Attachment> Incidence::attachments(const QString& mime) const 576QPtrList<Attachment> Incidence::attachments(const QString& mime) const
557{ 577{
558 QPtrList<Attachment> attachments; 578 QPtrList<Attachment> attachments;
559 QPtrListIterator<Attachment> it( mAttachments ); 579 QPtrListIterator<Attachment> it( mAttachments );
560 Attachment *at; 580 Attachment *at;
561 while ( (at = it.current()) ) { 581 while ( (at = it.current()) ) {
562 if (at->mimeType() == mime) 582 if (at->mimeType() == mime)
563 attachments.append(at); 583 attachments.append(at);
564 ++it; 584 ++it;
565 } 585 }
566 586
567 return attachments; 587 return attachments;
568} 588}
569 589
570void Incidence::setResources(const QStringList &resources) 590void Incidence::setResources(const QStringList &resources)
571{ 591{
572 if (mReadOnly) return; 592 if (mReadOnly) return;
573 mResources = resources; 593 mResources = resources;
574 updated(); 594 updated();
575} 595}
576 596
577QStringList Incidence::resources() const 597QStringList Incidence::resources() const
578{ 598{
579 return mResources; 599 return mResources;
580} 600}
581 601
582 602
583void Incidence::setPriority(int priority) 603void Incidence::setPriority(int priority)
584{ 604{
585 if (mReadOnly) return; 605 if (mReadOnly) return;
586 mPriority = priority; 606 mPriority = priority;
587 updated(); 607 updated();
588} 608}
589 609
590int Incidence::priority() const 610int Incidence::priority() const
591{ 611{
592 return mPriority; 612 return mPriority;
593} 613}
594 614
595void Incidence::setSecrecy(int sec) 615void Incidence::setSecrecy(int sec)
596{ 616{
597 if (mReadOnly) return; 617 if (mReadOnly) return;
598 mSecrecy = sec; 618 mSecrecy = sec;
599 updated(); 619 updated();
600} 620}
601 621
602int Incidence::secrecy() const 622int Incidence::secrecy() const
603{ 623{
604 return mSecrecy; 624 return mSecrecy;
605} 625}
606 626
607QString Incidence::secrecyStr() const 627QString Incidence::secrecyStr() const
608{ 628{
609 return secrecyName(mSecrecy); 629 return secrecyName(mSecrecy);
610} 630}
611 631
612QString Incidence::secrecyName(int secrecy) 632QString Incidence::secrecyName(int secrecy)
613{ 633{
614 switch (secrecy) { 634 switch (secrecy) {
615 case SecrecyPublic: 635 case SecrecyPublic:
616 return i18n("Public"); 636 return i18n("Public");
617 break; 637 break;
618 case SecrecyPrivate: 638 case SecrecyPrivate:
619 return i18n("Private"); 639 return i18n("Private");
620 break; 640 break;
621 case SecrecyConfidential: 641 case SecrecyConfidential:
622 return i18n("Confidential"); 642 return i18n("Confidential");
623 break; 643 break;
624 default: 644 default:
625 return i18n("Undefined"); 645 return i18n("Undefined");
626 break; 646 break;
627 } 647 }
628} 648}
629 649
630QStringList Incidence::secrecyList() 650QStringList Incidence::secrecyList()
631{ 651{
632 QStringList list; 652 QStringList list;
633 list << secrecyName(SecrecyPublic); 653 list << secrecyName(SecrecyPublic);
634 list << secrecyName(SecrecyPrivate); 654 list << secrecyName(SecrecyPrivate);
635 list << secrecyName(SecrecyConfidential); 655 list << secrecyName(SecrecyConfidential);
636 656
637 return list; 657 return list;
638} 658}
639 659
640 660
641QPtrList<Alarm> Incidence::alarms() const 661QPtrList<Alarm> Incidence::alarms() const
642{ 662{
643 return mAlarms; 663 return mAlarms;
644} 664}
645 665
646Alarm* Incidence::newAlarm() 666Alarm* Incidence::newAlarm()
647{ 667{
648 Alarm* alarm = new Alarm(this); 668 Alarm* alarm = new Alarm(this);
649 mAlarms.append(alarm); 669 mAlarms.append(alarm);
650// updated(); 670// updated();
651 return alarm; 671 return alarm;
652} 672}
653 673
654void Incidence::addAlarm(Alarm *alarm) 674void Incidence::addAlarm(Alarm *alarm)
655{ 675{
656 mAlarms.append(alarm); 676 mAlarms.append(alarm);
657 updated(); 677 updated();
658} 678}
659 679
660void Incidence::removeAlarm(Alarm *alarm) 680void Incidence::removeAlarm(Alarm *alarm)
661{ 681{
662 mAlarms.removeRef(alarm); 682 mAlarms.removeRef(alarm);
663 updated(); 683 updated();
664} 684}
665 685
666void Incidence::clearAlarms() 686void Incidence::clearAlarms()
667{ 687{
668 mAlarms.clear(); 688 mAlarms.clear();
669 updated(); 689 updated();
670} 690}
671 691
672bool Incidence::isAlarmEnabled() const 692bool Incidence::isAlarmEnabled() const
673{ 693{
674 Alarm* alarm; 694 Alarm* alarm;
675 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 695 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
676 if (alarm->enabled()) 696 if (alarm->enabled())
677 return true; 697 return true;
678 } 698 }
679 return false; 699 return false;
680} 700}
681 701
682Recurrence *Incidence::recurrence() const 702Recurrence *Incidence::recurrence() const
683{ 703{
684 return mRecurrence; 704 return mRecurrence;
685} 705}
686void Incidence::setRecurrence( Recurrence * r) 706void Incidence::setRecurrence( Recurrence * r)
687{ 707{
688 delete mRecurrence; 708 delete mRecurrence;
689 mRecurrence = r; 709 mRecurrence = r;
690} 710}
691 711
692void Incidence::setLocation(const QString &location) 712void Incidence::setLocation(const QString &location)
693{ 713{
694 if (mReadOnly) return; 714 if (mReadOnly) return;
695 mLocation = location; 715 mLocation = location;
696 updated(); 716 updated();
697} 717}
698 718
699QString Incidence::location() const 719QString Incidence::location() const
700{ 720{
701 return mLocation; 721 return mLocation;
702} 722}
703 723
704ushort Incidence::doesRecur() const 724ushort Incidence::doesRecur() const
705{ 725{
706 if ( mRecurrence ) return mRecurrence->doesRecur(); 726 if ( mRecurrence ) return mRecurrence->doesRecur();
707 else return Recurrence::rNone; 727 else return Recurrence::rNone;
708} 728}
709 729
710QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 730QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
711{ 731{
712 QDateTime incidenceStart = dt; 732 QDateTime incidenceStart = dt;
713 *ok = false; 733 *ok = false;
714 if ( doesRecur() ) { 734 if ( doesRecur() ) {
715 bool last; 735 bool last;
716 recurrence()->getPreviousDateTime( incidenceStart , &last ); 736 recurrence()->getPreviousDateTime( incidenceStart , &last );
717 int count = 0; 737 int count = 0;
718 if ( !last ) { 738 if ( !last ) {
719 while ( !last ) { 739 while ( !last ) {
720 ++count; 740 ++count;
721 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); 741 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last );
722 if ( recursOn( incidenceStart.date() ) ) { 742 if ( recursOn( incidenceStart.date() ) ) {
723 last = true; // exit while llop 743 last = true; // exit while llop
724 } else { 744 } else {
725 if ( last ) { // no alarm on last recurrence 745 if ( last ) { // no alarm on last recurrence
726 return QDateTime (); 746 return QDateTime ();
727 } 747 }
728 int year = incidenceStart.date().year(); 748 int year = incidenceStart.date().year();
729 // workaround for bug in recurrence 749 // workaround for bug in recurrence
730 if ( count == 100 || year < 1000 || year > 5000 ) { 750 if ( count == 100 || year < 1000 || year > 5000 ) {
731 return QDateTime (); 751 return QDateTime ();
732 } 752 }
733 incidenceStart = incidenceStart.addSecs( 1 ); 753 incidenceStart = incidenceStart.addSecs( 1 );
734 } 754 }
735 } 755 }
736 } else { 756 } else {
737 return QDateTime (); 757 return QDateTime ();
738 } 758 }
739 } else { 759 } else {
740 if ( hasStartDate () ) { 760 if ( hasStartDate () ) {
741 incidenceStart = dtStart(); 761 incidenceStart = dtStart();
742 } 762 }
743 if ( typeID() == todoID ) { 763 if ( typeID() == todoID ) {
744 if ( ((Todo*)this)->hasDueDate() ) 764 if ( ((Todo*)this)->hasDueDate() )
745 incidenceStart = ((Todo*)this)->dtDue(); 765 incidenceStart = ((Todo*)this)->dtDue();
746 } 766 }
747 } 767 }
748 if ( incidenceStart > dt ) 768 if ( incidenceStart > dt )
749 *ok = true; 769 *ok = true;
750 return incidenceStart; 770 return incidenceStart;
751} 771}
752QDateTime Incidence::dtStart() const 772QDateTime Incidence::dtStart() const
753{ 773{
754 if ( doesRecur() ) { 774 if ( doesRecur() ) {
755 if ( typeID() == todoID ) { 775 if ( typeID() == todoID ) {
756 ((Todo*)this)->checkSetCompletedFalse(); 776 ((Todo*)this)->checkSetCompletedFalse();
757 } 777 }
758 } 778 }
759 return mDtStart; 779 return mDtStart;
760} 780}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index c88ba2f..d4af9f0 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -1,318 +1,321 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef INCIDENCE_H 20#ifndef INCIDENCE_H
21#define INCIDENCE_H 21#define INCIDENCE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29 29
30#include "recurrence.h" 30#include "recurrence.h"
31#include "alarm.h" 31#include "alarm.h"
32#include "attachment.h" 32#include "attachment.h"
33#include "listbase.h" 33#include "listbase.h"
34#include "incidencebase.h" 34#include "incidencebase.h"
35 35
36namespace KCal { 36namespace KCal {
37 37
38class Event; 38class Event;
39class Todo; 39class Todo;
40class Journal; 40class Journal;
41 41
42/** 42/**
43 This class provides the base class common to all calendar components. 43 This class provides the base class common to all calendar components.
44*/ 44*/
45class Incidence : public IncidenceBase 45class Incidence : public IncidenceBase
46{ 46{
47 public: 47 public:
48 /** 48 /**
49 This class provides the interface for a visitor of calendar components. It 49 This class provides the interface for a visitor of calendar components. It
50 serves as base class for concrete visitors, which implement certain actions on 50 serves as base class for concrete visitors, which implement certain actions on
51 calendar components. It allows to add functions, which operate on the concrete 51 calendar components. It allows to add functions, which operate on the concrete
52 types of calendar components, without changing the calendar component classes. 52 types of calendar components, without changing the calendar component classes.
53 */ 53 */
54 class Visitor 54 class Visitor
55 { 55 {
56 public: 56 public:
57 /** Destruct Incidence::Visitor */ 57 /** Destruct Incidence::Visitor */
58 virtual ~Visitor() {} 58 virtual ~Visitor() {}
59 59
60 /** 60 /**
61 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 61 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
62 on an Event object. 62 on an Event object.
63 */ 63 */
64 virtual bool visit(Event *) { return false; } 64 virtual bool visit(Event *) { return false; }
65 /** 65 /**
66 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 66 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
67 on an Todo object. 67 on an Todo object.
68 */ 68 */
69 virtual bool visit(Todo *) { return false; } 69 virtual bool visit(Todo *) { return false; }
70 /** 70 /**
71 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 71 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
72 on an Journal object. 72 on an Journal object.
73 */ 73 */
74 virtual bool visit(Journal *) { return false; } 74 virtual bool visit(Journal *) { return false; }
75 75
76 protected: 76 protected:
77 /** Constructor is protected to prevent direct creation of visitor base class. */ 77 /** Constructor is protected to prevent direct creation of visitor base class. */
78 Visitor() {} 78 Visitor() {}
79 }; 79 };
80 80
81 /** 81 /**
82 This class implements a visitor for adding an Incidence to a resource 82 This class implements a visitor for adding an Incidence to a resource
83 supporting addEvent(), addTodo() and addJournal() calls. 83 supporting addEvent(), addTodo() and addJournal() calls.
84 */ 84 */
85 template<class T> 85 template<class T>
86 class AddVisitor : public Visitor 86 class AddVisitor : public Visitor
87 { 87 {
88 public: 88 public:
89 AddVisitor( T *r ) : mResource( r ) {} 89 AddVisitor( T *r ) : mResource( r ) {}
90 bool visit( Event *e ) { return mResource->addEvent( e ); } 90 bool visit( Event *e ) { return mResource->addEvent( e ); }
91 bool visit( Todo *t ) { return mResource->addTodo( t ); } 91 bool visit( Todo *t ) { return mResource->addTodo( t ); }
92 bool visit( Journal *j ) { return mResource->addJournal( j ); } 92 bool visit( Journal *j ) { return mResource->addJournal( j ); }
93 93
94 private: 94 private:
95 T *mResource; 95 T *mResource;
96 }; 96 };
97 97
98 /** enumeration for describing an event's secrecy. */ 98 /** enumeration for describing an event's secrecy. */
99 enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; 99 enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 };
100 typedef ListBase<Incidence> List; 100 typedef ListBase<Incidence> List;
101 Incidence(); 101 Incidence();
102 Incidence(const Incidence &); 102 Incidence(const Incidence &);
103 ~Incidence(); 103 ~Incidence();
104 104
105 /** 105 /**
106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to 106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to
107 provide this implementation: 107 provide this implementation:
108 <pre> 108 <pre>
109 bool accept(Visitor &v) { return v.visit(this); } 109 bool accept(Visitor &v) { return v.visit(this); }
110 </pre> 110 </pre>
111 */ 111 */
112 virtual bool accept(Visitor &) { return false; } 112 virtual bool accept(Visitor &) { return false; }
113 113
114 virtual Incidence *clone() = 0; 114 virtual Incidence *clone() = 0;
115 virtual void cloneRelations( Incidence * ); 115 virtual void cloneRelations( Incidence * );
116 void addRelationsToList(QPtrList<Incidence> *rel); 116 void addRelationsToList(QPtrList<Incidence> *rel);
117 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; 117 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) 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, bool setForRelations = false); 154 void setCategories(const QStringList &categories, bool setForRelations = false);
155 void addCategories(const QStringList &categories, bool addToRelations = false); 155 void addCategories(const QStringList &categories, bool addToRelations = false);
156 /** set event's categories based on a comma delimited string */ 156 /** set event's categories based on a comma delimited string */
157 void setCategories(const QString &catStr); 157 void setCategories(const QString &catStr);
158 /** return categories in a list */ 158 /** return categories in a list */
159 QStringList categories() const; 159 QStringList categories() const;
160 QStringList* categoriesP(); 160 QStringList* categoriesP();
161 /** return categories as a comma separated string */ 161 /** return categories as a comma separated string */
162 QString categoriesStr(); 162 QString categoriesStr();
163 QString categoriesStrWithSpace(); 163 QString categoriesStrWithSpace();
164 164
165 /** point at some other event to which the event relates. This function should 165 /** point at some other event to which the event relates. 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 void setRelatedToUid(const QString &); 168 void setRelatedToUid(const QString &);
169 /** what event does this one relate to? This function should 169 /** what event does this one relate to? This function should
170 * only be used when constructing a calendar before the related Event 170 * only be used when constructing a calendar before the related Event
171 * exists. */ 171 * exists. */
172 QString relatedToUid() const; 172 QString relatedToUid() const;
173 /** point at some other event to which the event relates */ 173 /** point at some other event to which the event relates */
174 void setRelatedTo(Incidence *relatedTo); 174 void setRelatedTo(Incidence *relatedTo);
175 /** what event does this one relate to? */ 175 /** what event does this one relate to? */
176 Incidence *relatedTo() const; 176 Incidence *relatedTo() const;
177 /** All events that are related to this event */ 177 /** All events that are related to this event */
178 QPtrList<Incidence> relations() const; 178 QPtrList<Incidence> relations() const;
179 /** Add an event which is related to this event */ 179 /** Add an event which is related to this event */
180 void addRelation(Incidence *); 180 void addRelation(Incidence *);
181 /** Remove event that is related to this event */ 181 /** Remove event that is related to this event */
182 void removeRelation(Incidence *); 182 void removeRelation(Incidence *);
183 183
184 /** returns the list of dates which are exceptions to the recurrence rule */ 184 /** returns the list of dates which are exceptions to the recurrence rule */
185 DateList exDates() const; 185 DateList exDates() const;
186 /** sets the list of dates which are exceptions to the recurrence rule */ 186 /** sets the list of dates which are exceptions to the recurrence rule */
187 void setExDates(const DateList &_exDates); 187 void setExDates(const DateList &_exDates);
188 void setExDates(const char *dates); 188 void setExDates(const char *dates);
189 /** Add a date to the list of exceptions of the recurrence rule. */ 189 /** Add a date to the list of exceptions of the recurrence rule. */
190 void addExDate(const QDate &date); 190 void addExDate(const QDate &date);
191 191
192 /** returns true if there is an exception for this date in the recurrence 192 /** returns true if there is an exception for this date in the recurrence
193 rule set, or false otherwise. */ 193 rule set, or false otherwise. */
194 bool isException(const QDate &qd) const; 194 bool isException(const QDate &qd) const;
195 195
196 /** add attachment to this event */ 196 /** add attachment to this event */
197 void addAttachment(Attachment *attachment); 197 void addAttachment(Attachment *attachment);
198 /** remove and delete a specific attachment */ 198 /** remove and delete a specific attachment */
199 void deleteAttachment(Attachment *attachment); 199 void deleteAttachment(Attachment *attachment);
200 /** remove and delete all attachments with this mime type */ 200 /** remove and delete all attachments with this mime type */
201 void deleteAttachments(const QString& mime); 201 void deleteAttachments(const QString& mime);
202 /** return list of all associated attachments */ 202 /** return list of all associated attachments */
203 QPtrList<Attachment> attachments() const; 203 QPtrList<Attachment> attachments() const;
204 /** find a list of attachments with this mime type */ 204 /** find a list of attachments with this mime type */
205 QPtrList<Attachment> attachments(const QString& mime) const; 205 QPtrList<Attachment> attachments(const QString& mime) const;
206 206
207 /** sets the event's status the value specified. See the enumeration 207 /** sets the event's status the value specified. See the enumeration
208 * above for possible values. */ 208 * above for possible values. */
209 void setSecrecy(int); 209 void setSecrecy(int);
210 /** return the event's secrecy. */ 210 /** return the event's secrecy. */
211 int secrecy() const; 211 int secrecy() const;
212 /** return the event's secrecy in string format. */ 212 /** return the event's secrecy in string format. */
213 QString secrecyStr() const; 213 QString secrecyStr() const;
214 /** return list of all availbale secrecy classes */ 214 /** return list of all availbale secrecy classes */
215 static QStringList secrecyList(); 215 static QStringList secrecyList();
216 /** return human-readable name of secrecy class */ 216 /** return human-readable name of secrecy class */
217 static QString secrecyName(int); 217 static QString secrecyName(int);
218 218
219 /** returns TRUE if the date specified is one on which the event will 219 /** returns TRUE if the date specified is one on which the event will
220 * recur. */ 220 * recur. */
221 bool recursOn(const QDate &qd) const; 221 bool recursOn(const QDate &qd) const;
222 222
223 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 223 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
224 224
225 /** set resources used, such as Office, Car, etc. */ 225 /** set resources used, such as Office, Car, etc. */
226 void setResources(const QStringList &resources); 226 void setResources(const QStringList &resources);
227 /** return list of current resources */ 227 /** return list of current resources */
228 QStringList resources() const; 228 QStringList resources() const;
229 229
230 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 230 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
231 void setPriority(int priority); 231 void setPriority(int priority);
232 /** get the event's priority */ 232 /** get the event's priority */
233 int priority() const; 233 int priority() const;
234 234
235 /** All alarms that are associated with this incidence */ 235 /** All alarms that are associated with this incidence */
236 QPtrList<Alarm> alarms() const; 236 QPtrList<Alarm> alarms() const;
237 /** Create a new alarm which is associated with this incidence */ 237 /** Create a new alarm which is associated with this incidence */
238 Alarm* newAlarm(); 238 Alarm* newAlarm();
239 /** Add an alarm which is associated with this incidence */ 239 /** Add an alarm which is associated with this incidence */
240 void addAlarm(Alarm*); 240 void addAlarm(Alarm*);
241 /** Remove an alarm that is associated with this incidence */ 241 /** Remove an alarm that is associated with this incidence */
242 void removeAlarm(Alarm*); 242 void removeAlarm(Alarm*);
243 /** Remove all alarms that are associated with this incidence */ 243 /** Remove all alarms that are associated with this incidence */
244 void clearAlarms(); 244 void clearAlarms();
245 /** return whether any alarm associated with this incidence is enabled */ 245 /** return whether any alarm associated with this incidence is enabled */
246 bool isAlarmEnabled() const; 246 bool isAlarmEnabled() const;
247 247
248 /** 248 /**
249 Return the recurrence rule associated with this incidence. If there is 249 Return the recurrence rule associated with this incidence. If there is
250 none, returns an appropriate (non-0) object. 250 none, returns an appropriate (non-0) object.
251 */ 251 */
252 Recurrence *recurrence() const; 252 Recurrence *recurrence() const;
253 void setRecurrence(Recurrence * r); 253 void setRecurrence(Recurrence * r);
254 /** 254 /**
255 Forward to Recurrence::doesRecur(). 255 Forward to Recurrence::doesRecur().
256 */ 256 */
257 ushort doesRecur() const; 257 ushort doesRecur() const;
258 258
259 /** set the event's/todo's location. Do _not_ use it with journal */ 259 /** set the event's/todo's location. Do _not_ use it with journal */
260 void setLocation(const QString &location); 260 void setLocation(const QString &location);
261 /** return the event's/todo's location. Do _not_ use it with journal */ 261 /** return the event's/todo's location. Do _not_ use it with journal */
262 QString location() const; 262 QString location() const;
263 /** returns TRUE or FALSE depending on whether the todo has a start date */ 263 /** returns TRUE or FALSE depending on whether the todo has a start date */
264 bool hasStartDate() const; 264 bool hasStartDate() const;
265 /** sets the event's hasStartDate value. */ 265 /** sets the event's hasStartDate value. */
266 void setHasStartDate(bool f); 266 void setHasStartDate(bool f);
267 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 267 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
268 bool cancelled() const; 268 bool cancelled() const;
269 void setCancelled( bool b ); 269 void setCancelled( bool b );
270 270
271 bool hasRecurrenceID() const; 271 bool hasRecurrenceID() const;
272 void setHasRecurrenceID( bool b ); 272 void setHasRecurrenceID( bool b );
273 273
274 void setRecurrenceID(QDateTime); 274 void setRecurrenceID(QDateTime);
275 QDateTime recurrenceID () const; 275 QDateTime recurrenceID () const;
276 QDateTime dtStart() const; 276 QDateTime dtStart() const;
277 bool isHoliday() const; 277 bool isHoliday() const;
278 bool isBirthday() const; 278 bool isBirthday() const;
279 bool isAnniversary() const; 279 bool isAnniversary() const;
280 QDateTime lastModifiedSub();
281 void setLastModifiedSubInvalid();
280 282
281 283
282protected: 284protected:
283 QPtrList<Alarm> mAlarms; 285 QPtrList<Alarm> mAlarms;
284 QPtrList<Incidence> mRelations; 286 QPtrList<Incidence> mRelations;
285 QDateTime mRecurrenceID; 287 QDateTime mRecurrenceID;
286 bool mHasRecurrenceID; 288 bool mHasRecurrenceID;
287 private: 289 private:
288 void checkCategories(); 290 void checkCategories();
289 bool mHoliday, mBirthday, mAnniversary; 291 bool mHoliday, mBirthday, mAnniversary;
290 int mRevision; 292 int mRevision;
291 bool mCancelled; 293 bool mCancelled;
292 294
293 // base components of jounal, event and todo 295 // base components of jounal, event and todo
294 QDateTime mCreated; 296 QDateTime mCreated;
297 QDateTime mLastModifiedSub;
295 QString mDescription; 298 QString mDescription;
296 QString mSummary; 299 QString mSummary;
297 QStringList mCategories; 300 QStringList mCategories;
298 Incidence *mRelatedTo; 301 Incidence *mRelatedTo;
299 QString mRelatedToUid; 302 QString mRelatedToUid;
300 DateList mExDates; 303 DateList mExDates;
301 QPtrList<Attachment> mAttachments; 304 QPtrList<Attachment> mAttachments;
302 QStringList mResources; 305 QStringList mResources;
303 bool mHasStartDate; // if todo has associated start date 306 bool mHasStartDate; // if todo has associated start date
304 307
305 int mSecrecy; 308 int mSecrecy;
306 int mPriority; // 1 = highest, 2 = less, etc. 309 int mPriority; // 1 = highest, 2 = less, etc.
307 310
308 //QPtrList<Alarm> mAlarms; 311 //QPtrList<Alarm> mAlarms;
309 Recurrence *mRecurrence; 312 Recurrence *mRecurrence;
310 313
311 QString mLocation; 314 QString mLocation;
312}; 315};
313 316
314bool operator==( const Incidence&, const Incidence& ); 317bool operator==( const Incidence&, const Incidence& );
315 318
316} 319}
317 320
318#endif 321#endif
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 1a19f3e..022dead 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -1,478 +1,482 @@
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#include <kidmanager.h> 24#include <kidmanager.h>
25 25
26#include "calformat.h" 26#include "calformat.h"
27#include "syncdefines.h" 27#include "syncdefines.h"
28 28
29#include "incidencebase.h" 29#include "incidencebase.h"
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33IncidenceBase::IncidenceBase() : 33IncidenceBase::IncidenceBase() :
34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
35 mPilotId(0), mSyncStatus(SYNCMOD) 35 mPilotId(0), mSyncStatus(SYNCMOD)
36{ 36{
37 blockLastModified = false; 37 blockLastModified = false;
38 setUid(CalFormat::createUniqueId()); 38 setUid(CalFormat::createUniqueId());
39 mOrganizer = ""; 39 mOrganizer = "";
40 mFloats = false; 40 mFloats = false;
41 mDuration = 0; 41 mDuration = 0;
42 mHasDuration = false; 42 mHasDuration = false;
43 mPilotId = 0; 43 mPilotId = 0;
44 mExternalId = ":"; 44 mExternalId = ":";
45 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 45 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
46 mSyncStatus = 0; 46 mSyncStatus = 0;
47 mAttendees.setAutoDelete( true ); 47 mAttendees.setAutoDelete( true );
48 mCalEnabled = true; 48 mCalEnabled = true;
49 mAlarmEnabled = true; 49 mAlarmEnabled = true;
50 mCalID = 0; 50 mCalID = 0;
51} 51}
52 52
53IncidenceBase::IncidenceBase(const IncidenceBase &i) : 53IncidenceBase::IncidenceBase(const IncidenceBase &i) :
54 CustomProperties( i ) 54 CustomProperties( i )
55{ 55{
56 56
57 blockLastModified = false; 57 blockLastModified = false;
58 mReadOnly = i.mReadOnly; 58 mReadOnly = i.mReadOnly;
59 mDtStart = i.mDtStart; 59 mDtStart = i.mDtStart;
60 mDuration = i.mDuration; 60 mDuration = i.mDuration;
61 mHasDuration = i.mHasDuration; 61 mHasDuration = i.mHasDuration;
62 mOrganizer = i.mOrganizer; 62 mOrganizer = i.mOrganizer;
63 mUid = i.mUid; 63 mUid = i.mUid;
64 mCalEnabled = i.mCalEnabled; 64 mCalEnabled = i.mCalEnabled;
65 mAlarmEnabled = i.mAlarmEnabled; 65 mAlarmEnabled = i.mAlarmEnabled;
66 mCalID = i.mCalID; 66 mCalID = i.mCalID;
67 QPtrList<Attendee> attendees = i.attendees(); 67 QPtrList<Attendee> attendees = i.attendees();
68 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 68 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
69 mAttendees.append( new Attendee( *a ) ); 69 mAttendees.append( new Attendee( *a ) );
70 } 70 }
71 mFloats = i.mFloats; 71 mFloats = i.mFloats;
72 mLastModified = i.mLastModified; 72 mLastModified = i.mLastModified;
73 mPilotId = i.mPilotId; 73 mPilotId = i.mPilotId;
74 mTempSyncStat = i.mTempSyncStat; 74 mTempSyncStat = i.mTempSyncStat;
75 mSyncStatus = i.mSyncStatus; 75 mSyncStatus = i.mSyncStatus;
76 mExternalId = i.mExternalId; 76 mExternalId = i.mExternalId;
77 // The copied object is a new one, so it isn't observed by the observer 77 // The copied object is a new one, so it isn't observed by the observer
78 // of the original object. 78 // of the original object.
79 mObservers.clear(); 79 mObservers.clear();
80 80
81 mAttendees.setAutoDelete( true ); 81 mAttendees.setAutoDelete( true );
82} 82}
83 83
84IncidenceBase::~IncidenceBase() 84IncidenceBase::~IncidenceBase()
85{ 85{
86} 86}
87 87
88 88
89bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 89bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
90{ 90{
91 // do not compare mSyncStatus and mExternalId 91 // do not compare mSyncStatus and mExternalId
92 if( i1.attendees().count() != i2.attendees().count() ) { 92 if( i1.attendees().count() != i2.attendees().count() ) {
93 return false; // no need to check further 93 return false; // no need to check further
94 } 94 }
95 if ( i1.attendees().count() > 0 ) { 95 if ( i1.attendees().count() > 0 ) {
96 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 96 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
97 while ( a1 ) { 97 while ( a1 ) {
98 if ( !( (*a1) == (*a2)) ) 98 if ( !( (*a1) == (*a2)) )
99 { 99 {
100 //qDebug("Attendee not equal "); 100 //qDebug("Attendee not equal ");
101 return false; 101 return false;
102 } 102 }
103 a1 = i1.attendees().next(); 103 a1 = i1.attendees().next();
104 a2 = i2.attendees().next(); 104 a2 = i2.attendees().next();
105 } 105 }
106 } 106 }
107 //if ( i1.dtStart() != i2.dtStart() ) 107 //if ( i1.dtStart() != i2.dtStart() )
108 // return false; 108 // return false;
109#if 0 109#if 0
110 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 110 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
111 qDebug("1 %d ",i1.duration() == i2.duration() ); 111 qDebug("1 %d ",i1.duration() == i2.duration() );
112 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 112 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
113 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 113 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
114 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 114 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
115 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 115 qDebug("6 %d ",i1.organizer() == i2.organizer() );
116 116
117#endif 117#endif
118 if ( i1.hasDuration() == i2.hasDuration() ) { 118 if ( i1.hasDuration() == i2.hasDuration() ) {
119 if ( i1.hasDuration() ) { 119 if ( i1.hasDuration() ) {
120 if ( i1.duration() != i2.duration() ) 120 if ( i1.duration() != i2.duration() )
121 return false; 121 return false;
122 } 122 }
123 } else { 123 } else {
124 return false; 124 return false;
125 } 125 }
126 126
127 return ( i1.organizer() == i2.organizer() && 127 return ( i1.organizer() == i2.organizer() &&
128 // i1.uid() == i2.uid() && 128 // i1.uid() == i2.uid() &&
129 // Don't compare lastModified, otherwise the operator is not 129 // Don't compare lastModified, otherwise the operator is not
130 // of much use. We are not comparing for identity, after all. 130 // of much use. We are not comparing for identity, after all.
131 i1.doesFloat() == i2.doesFloat() && 131 i1.doesFloat() == i2.doesFloat() &&
132 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 132 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
133 // no need to compare mObserver 133 // no need to compare mObserver
134} 134}
135 135
136 136
137QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 137QDateTime IncidenceBase::getEvenTime( QDateTime dt )
138{ 138{
139 QTime t = dt.time(); 139 QTime t = dt.time();
140 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 140 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
141 return dt; 141 return dt;
142} 142}
143 143
144bool IncidenceBase::isTagged() const 144bool IncidenceBase::isTagged() const
145{ 145{
146 return mIsTagged; 146 return mIsTagged;
147} 147}
148void IncidenceBase::setTagged( bool b) 148void IncidenceBase::setTagged( bool b)
149{ 149{
150 mIsTagged = b; 150 mIsTagged = b;
151} 151}
152void IncidenceBase::setCalID( int id ) 152void IncidenceBase::setCalID( int id )
153{ 153{
154 if ( mCalID > 0 ) { 154 if ( mCalID > 0 ) {
155 blockLastModified = true; 155 blockLastModified = true;
156 updated(); 156 updated();
157 blockLastModified = false; 157 blockLastModified = false;
158 } 158 }
159 mCalID = id; 159 mCalID = id;
160} 160}
161int IncidenceBase::calID() const 161int IncidenceBase::calID() const
162{ 162{
163 return mCalID; 163 return mCalID;
164} 164}
165void IncidenceBase::setCalEnabled( bool b ) 165void IncidenceBase::setCalEnabled( bool b )
166{ 166{
167 mCalEnabled = b; 167 mCalEnabled = b;
168} 168}
169bool IncidenceBase::calEnabled() const 169bool IncidenceBase::calEnabled() const
170{ 170{
171 return mCalEnabled; 171 return mCalEnabled;
172} 172}
173 173
174void IncidenceBase::setAlarmEnabled( bool b ) 174void IncidenceBase::setAlarmEnabled( bool b )
175{ 175{
176 mAlarmEnabled = b; 176 mAlarmEnabled = b;
177} 177}
178bool IncidenceBase::alarmEnabled() const 178bool IncidenceBase::alarmEnabled() const
179{ 179{
180 return mAlarmEnabled; 180 return mAlarmEnabled;
181} 181}
182 182
183 183
184void IncidenceBase::setUid(const QString &uid) 184void IncidenceBase::setUid(const QString &uid)
185{ 185{
186 mUid = uid; 186 mUid = uid;
187 updated(); 187 updated();
188} 188}
189 189
190QString IncidenceBase::uid() const 190QString IncidenceBase::uid() const
191{ 191{
192 return mUid; 192 return mUid;
193} 193}
194void IncidenceBase::setLastModifiedSubInvalid()
195{
194 196
197}
195void IncidenceBase::setLastModified(const QDateTime &lm) 198void IncidenceBase::setLastModified(const QDateTime &lm)
196{ 199{
197 if ( blockLastModified ) return; 200 if ( blockLastModified ) return;
198 // DON'T! updated() because we call this from 201 // DON'T! updated() because we call this from
199 // Calendar::updateEvent(). 202 // Calendar::updateEvent().
200 mLastModified = getEvenTime(lm); 203 mLastModified = getEvenTime(lm);
204 setLastModifiedSubInvalid();
201 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 205 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
202} 206}
203 207
204QDateTime IncidenceBase::lastModified() const 208QDateTime IncidenceBase::lastModified() const
205{ 209{
206 return mLastModified; 210 return mLastModified;
207} 211}
208 212
209void IncidenceBase::setOrganizer(const QString &o) 213void IncidenceBase::setOrganizer(const QString &o)
210{ 214{
211 // we don't check for readonly here, because it is 215 // we don't check for readonly here, because it is
212 // possible that by setting the organizer we are changing 216 // possible that by setting the organizer we are changing
213 // the event's readonly status... 217 // the event's readonly status...
214 mOrganizer = o; 218 mOrganizer = o;
215 if (mOrganizer.left(7).upper() == "MAILTO:") 219 if (mOrganizer.left(7).upper() == "MAILTO:")
216 mOrganizer = mOrganizer.remove(0,7); 220 mOrganizer = mOrganizer.remove(0,7);
217 221
218 updated(); 222 updated();
219} 223}
220 224
221QString IncidenceBase::organizer() const 225QString IncidenceBase::organizer() const
222{ 226{
223 return mOrganizer; 227 return mOrganizer;
224} 228}
225 229
226void IncidenceBase::setReadOnly( bool readOnly ) 230void IncidenceBase::setReadOnly( bool readOnly )
227{ 231{
228 mReadOnly = readOnly; 232 mReadOnly = readOnly;
229} 233}
230 234
231void IncidenceBase::setDtStart(const QDateTime &dtStart) 235void IncidenceBase::setDtStart(const QDateTime &dtStart)
232{ 236{
233// if (mReadOnly) return; 237// if (mReadOnly) return;
234 mDtStart = getEvenTime(dtStart); 238 mDtStart = getEvenTime(dtStart);
235 updated(); 239 updated();
236} 240}
237 241
238 242
239QDateTime IncidenceBase::dtStart() const 243QDateTime IncidenceBase::dtStart() const
240{ 244{
241 return mDtStart; 245 return mDtStart;
242} 246}
243 247
244QString IncidenceBase::dtStartTimeStr() const 248QString IncidenceBase::dtStartTimeStr() const
245{ 249{
246 return KGlobal::locale()->formatTime(dtStart().time()); 250 return KGlobal::locale()->formatTime(dtStart().time());
247} 251}
248 252
249QString IncidenceBase::dtStartDateStr(bool shortfmt) const 253QString IncidenceBase::dtStartDateStr(bool shortfmt) const
250{ 254{
251 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 255 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
252} 256}
253 257
254QString IncidenceBase::dtStartStr(bool shortfmt) const 258QString IncidenceBase::dtStartStr(bool shortfmt) const
255{ 259{
256 if ( doesFloat() ) 260 if ( doesFloat() )
257 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 261 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
258 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 262 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
259} 263}
260 264
261 265
262bool IncidenceBase::doesFloat() const 266bool IncidenceBase::doesFloat() const
263{ 267{
264 return mFloats; 268 return mFloats;
265} 269}
266 270
267void IncidenceBase::setFloats(bool f) 271void IncidenceBase::setFloats(bool f)
268{ 272{
269 if (mReadOnly) return; 273 if (mReadOnly) return;
270 mFloats = f; 274 mFloats = f;
271 updated(); 275 updated();
272} 276}
273 277
274 278
275bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) 279bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
276{ 280{
277 if (mReadOnly) return false; 281 if (mReadOnly) return false;
278 if (a->name().left(7).upper() == "MAILTO:") 282 if (a->name().left(7).upper() == "MAILTO:")
279 a->setName(a->name().remove(0,7)); 283 a->setName(a->name().remove(0,7));
280 284
281 QPtrListIterator<Attendee> qli(mAttendees); 285 QPtrListIterator<Attendee> qli(mAttendees);
282 286
283 qli.toFirst(); 287 qli.toFirst();
284 while (qli) { 288 while (qli) {
285 if (*qli.current() == *a) 289 if (*qli.current() == *a)
286 return false; 290 return false;
287 ++qli; 291 ++qli;
288 } 292 }
289 mAttendees.append(a); 293 mAttendees.append(a);
290 if (doupdate) updated(); 294 if (doupdate) updated();
291 return true; 295 return true;
292} 296}
293 297
294#if 0 298#if 0
295void IncidenceBase::removeAttendee(Attendee *a) 299void IncidenceBase::removeAttendee(Attendee *a)
296{ 300{
297 if (mReadOnly) return; 301 if (mReadOnly) return;
298 mAttendees.removeRef(a); 302 mAttendees.removeRef(a);
299 updated(); 303 updated();
300} 304}
301 305
302void IncidenceBase::removeAttendee(const char *n) 306void IncidenceBase::removeAttendee(const char *n)
303{ 307{
304 Attendee *a; 308 Attendee *a;
305 309
306 if (mReadOnly) return; 310 if (mReadOnly) return;
307 for (a = mAttendees.first(); a; a = mAttendees.next()) 311 for (a = mAttendees.first(); a; a = mAttendees.next())
308 if (a->getName() == n) { 312 if (a->getName() == n) {
309 mAttendees.remove(); 313 mAttendees.remove();
310 break; 314 break;
311 } 315 }
312} 316}
313#endif 317#endif
314 318
315void IncidenceBase::clearAttendees() 319void IncidenceBase::clearAttendees()
316{ 320{
317 if (mReadOnly) return; 321 if (mReadOnly) return;
318 mAttendees.clear(); 322 mAttendees.clear();
319} 323}
320 324
321#if 0 325#if 0
322Attendee *IncidenceBase::getAttendee(const char *n) const 326Attendee *IncidenceBase::getAttendee(const char *n) const
323{ 327{
324 QPtrListIterator<Attendee> qli(mAttendees); 328 QPtrListIterator<Attendee> qli(mAttendees);
325 329
326 qli.toFirst(); 330 qli.toFirst();
327 while (qli) { 331 while (qli) {
328 if (qli.current()->getName() == n) 332 if (qli.current()->getName() == n)
329 return qli.current(); 333 return qli.current();
330 ++qli; 334 ++qli;
331 } 335 }
332 return 0L; 336 return 0L;
333} 337}
334#endif 338#endif
335 339
336Attendee *IncidenceBase::attendeeByMail(const QString &email) 340Attendee *IncidenceBase::attendeeByMail(const QString &email)
337{ 341{
338 QPtrListIterator<Attendee> qli(mAttendees); 342 QPtrListIterator<Attendee> qli(mAttendees);
339 343
340 qli.toFirst(); 344 qli.toFirst();
341 while (qli) { 345 while (qli) {
342 if (qli.current()->email().lower() == email.lower()) 346 if (qli.current()->email().lower() == email.lower())
343 return qli.current(); 347 return qli.current();
344 ++qli; 348 ++qli;
345 } 349 }
346 return 0L; 350 return 0L;
347} 351}
348 352
349Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 353Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
350{ 354{
351 QPtrListIterator<Attendee> qli(mAttendees); 355 QPtrListIterator<Attendee> qli(mAttendees);
352 356
353 QStringList mails = emails; 357 QStringList mails = emails;
354 if (!email.isEmpty()) { 358 if (!email.isEmpty()) {
355 mails.append(email); 359 mails.append(email);
356 } 360 }
357 qli.toFirst(); 361 qli.toFirst();
358 while (qli) { 362 while (qli) {
359 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 363 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
360 if (qli.current()->email().lower() == (*it).lower()) 364 if (qli.current()->email().lower() == (*it).lower())
361 return qli.current(); 365 return qli.current();
362 } 366 }
363 367
364 ++qli; 368 ++qli;
365 } 369 }
366 return 0L; 370 return 0L;
367} 371}
368 372
369void IncidenceBase::setDuration(int seconds) 373void IncidenceBase::setDuration(int seconds)
370{ 374{
371 mDuration = seconds; 375 mDuration = seconds;
372 setHasDuration(true); 376 setHasDuration(true);
373} 377}
374 378
375int IncidenceBase::duration() const 379int IncidenceBase::duration() const
376{ 380{
377 return mDuration; 381 return mDuration;
378} 382}
379 383
380void IncidenceBase::setHasDuration(bool b) 384void IncidenceBase::setHasDuration(bool b)
381{ 385{
382 mHasDuration = b; 386 mHasDuration = b;
383} 387}
384 388
385bool IncidenceBase::hasDuration() const 389bool IncidenceBase::hasDuration() const
386{ 390{
387 return mHasDuration; 391 return mHasDuration;
388} 392}
389 393
390void IncidenceBase::setSyncStatus(int stat) 394void IncidenceBase::setSyncStatus(int stat)
391{ 395{
392 if (mReadOnly) return; 396 if (mReadOnly) return;
393 mSyncStatus = stat; 397 mSyncStatus = stat;
394} 398}
395 399
396int IncidenceBase::syncStatus() const 400int IncidenceBase::syncStatus() const
397{ 401{
398 return mSyncStatus; 402 return mSyncStatus;
399} 403}
400 404
401void IncidenceBase::setPilotId( int id ) 405void IncidenceBase::setPilotId( int id )
402{ 406{
403 if (mReadOnly) return; 407 if (mReadOnly) return;
404 mPilotId = id; 408 mPilotId = id;
405} 409}
406 410
407int IncidenceBase::pilotId() const 411int IncidenceBase::pilotId() const
408{ 412{
409 return mPilotId; 413 return mPilotId;
410} 414}
411 415
412int IncidenceBase::tempSyncStat() const 416int IncidenceBase::tempSyncStat() const
413{ 417{
414 return mTempSyncStat; 418 return mTempSyncStat;
415} 419}
416void IncidenceBase::setTempSyncStat( int id ) 420void IncidenceBase::setTempSyncStat( int id )
417{ 421{
418 if (mReadOnly) return; 422 if (mReadOnly) return;
419 mTempSyncStat = id; 423 mTempSyncStat = id;
420} 424}
421 425
422void IncidenceBase::removeID(const QString &prof) 426void IncidenceBase::removeID(const QString &prof)
423{ 427{
424 if ( prof.isEmpty() ) 428 if ( prof.isEmpty() )
425 mExternalId = ":"; 429 mExternalId = ":";
426 else 430 else
427 mExternalId = KIdManager::removeId ( mExternalId, prof); 431 mExternalId = KIdManager::removeId ( mExternalId, prof);
428 432
429} 433}
430void IncidenceBase::setID( const QString & prof , const QString & id ) 434void IncidenceBase::setID( const QString & prof , const QString & id )
431{ 435{
432 mExternalId = KIdManager::setId ( mExternalId, prof, id ); 436 mExternalId = KIdManager::setId ( mExternalId, prof, id );
433} 437}
434QString IncidenceBase::getID( const QString & prof) 438QString IncidenceBase::getID( const QString & prof)
435{ 439{
436 return KIdManager::getId ( mExternalId, prof ); 440 return KIdManager::getId ( mExternalId, prof );
437} 441}
438 442
439// example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: 443// example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0:
440// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 444// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0
441void IncidenceBase::setCsum( const QString & prof , const QString & id ) 445void IncidenceBase::setCsum( const QString & prof , const QString & id )
442{ 446{
443 mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); 447 mExternalId = KIdManager::setCsum ( mExternalId, prof, id );
444} 448}
445QString IncidenceBase::getCsum( const QString & prof) 449QString IncidenceBase::getCsum( const QString & prof)
446{ 450{
447 return KIdManager::getCsum ( mExternalId, prof ); 451 return KIdManager::getCsum ( mExternalId, prof );
448} 452}
449 453
450void IncidenceBase::setIDStr( const QString & s ) 454void IncidenceBase::setIDStr( const QString & s )
451{ 455{
452 if (mReadOnly) return; 456 if (mReadOnly) return;
453 mExternalId = s; 457 mExternalId = s;
454} 458}
455 459
456QString IncidenceBase::IDStr() const 460QString IncidenceBase::IDStr() const
457{ 461{
458 return mExternalId ; 462 return mExternalId ;
459} 463}
460void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 464void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
461{ 465{
462 if( !mObservers.contains(observer) ) mObservers.append( observer ); 466 if( !mObservers.contains(observer) ) mObservers.append( observer );
463} 467}
464 468
465void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 469void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
466{ 470{
467 mObservers.remove( observer ); 471 mObservers.remove( observer );
468} 472}
469 473
470void IncidenceBase::updated() 474void IncidenceBase::updated()
471{ 475{
472 QPtrListIterator<Observer> it(mObservers); 476 QPtrListIterator<Observer> it(mObservers);
473 while( it.current() ) { 477 while( it.current() ) {
474 Observer *o = it.current(); 478 Observer *o = it.current();
475 ++it; 479 ++it;
476 o->incidenceUpdated( this ); 480 o->incidenceUpdated( this );
477 } 481 }
478} 482}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index bed73db..665c1f6 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -1,186 +1,187 @@
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 KCAL_INCIDENCEBASE_H 20#ifndef KCAL_INCIDENCEBASE_H
21#define KCAL_INCIDENCEBASE_H 21#define KCAL_INCIDENCEBASE_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#include <qptrlist.h> 29#include <qptrlist.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "attendee.h" 32#include "attendee.h"
33 33
34namespace KCal { 34namespace KCal {
35 35
36typedef QValueList<QDate> DateList; 36typedef QValueList<QDate> DateList;
37 enum IncTypeID { eventID,todoID,journalID,freebusyID }; 37 enum IncTypeID { eventID,todoID,journalID,freebusyID };
38 38
39/** 39/**
40 This class provides the base class common to all calendar components. 40 This class provides the base class common to all calendar components.
41*/ 41*/
42class IncidenceBase : public CustomProperties 42class IncidenceBase : public CustomProperties
43{ 43{
44 public: 44 public:
45 class Observer { 45 class Observer {
46 public: 46 public:
47 virtual void incidenceUpdated( IncidenceBase * ) = 0; 47 virtual void incidenceUpdated( IncidenceBase * ) = 0;
48 }; 48 };
49 49
50 IncidenceBase(); 50 IncidenceBase();
51 IncidenceBase(const IncidenceBase &); 51 IncidenceBase(const IncidenceBase &);
52 virtual ~IncidenceBase(); 52 virtual ~IncidenceBase();
53 53
54 virtual QCString type() const = 0; 54 virtual QCString type() const = 0;
55 virtual IncTypeID typeID() const = 0; 55 virtual IncTypeID typeID() const = 0;
56 56
57 /** Set the unique id for the event */ 57 /** Set the unique id for the event */
58 void setUid(const QString &); 58 void setUid(const QString &);
59 /** Return the unique id for the event */ 59 /** Return the unique id for the event */
60 QString uid() const; 60 QString uid() const;
61 61
62 /** Sets the time the incidence was last modified. */ 62 /** Sets the time the incidence was last modified. */
63 void setLastModified(const QDateTime &lm); 63 void setLastModified(const QDateTime &lm);
64 /** Return the time the incidence was last modified. */ 64 /** Return the time the incidence was last modified. */
65 QDateTime lastModified() const; 65 QDateTime lastModified() const;
66 66
67 /** sets the organizer for the event */ 67 /** sets the organizer for the event */
68 void setOrganizer(const QString &o); 68 void setOrganizer(const QString &o);
69 QString organizer() const; 69 QString organizer() const;
70 70
71 /** Set readonly status. */ 71 /** Set readonly status. */
72 virtual void setReadOnly( bool ); 72 virtual void setReadOnly( bool );
73 /** Return if the object is read-only. */ 73 /** Return if the object is read-only. */
74 bool isReadOnly() const { return mReadOnly; } 74 bool isReadOnly() const { return mReadOnly; }
75 75
76 /** for setting the event's starting date/time with a QDateTime. */ 76 /** for setting the event's starting date/time with a QDateTime. */
77 virtual void setDtStart(const QDateTime &dtStart); 77 virtual void setDtStart(const QDateTime &dtStart);
78 /** returns an event's starting date/time as a QDateTime. */ 78 /** returns an event's starting date/time as a QDateTime. */
79 virtual QDateTime dtStart() const; 79 virtual QDateTime dtStart() const;
80 /** returns an event's starting time as a string formatted according to the 80 /** returns an event's starting time as a string formatted according to the
81 users locale settings */ 81 users locale settings */
82 QString dtStartTimeStr() const; 82 QString dtStartTimeStr() const;
83 /** returns an event's starting date as a string formatted according to the 83 /** returns an event's starting date as a string formatted according to the
84 users locale settings */ 84 users locale settings */
85 QString dtStartDateStr(bool shortfmt=true) const; 85 QString dtStartDateStr(bool shortfmt=true) const;
86 /** returns an event's starting date and time as a string formatted according 86 /** returns an event's starting date and time as a string formatted according
87 to the users locale settings */ 87 to the users locale settings */
88 QString dtStartStr(bool shortfmt=true) const; 88 QString dtStartStr(bool shortfmt=true) const;
89 89
90 virtual void setDuration(int seconds); 90 virtual void setDuration(int seconds);
91 int duration() const; 91 int duration() const;
92 void setHasDuration(bool); 92 void setHasDuration(bool);
93 bool hasDuration() const; 93 bool hasDuration() const;
94 94
95 /** Return true or false depending on whether the incidence "floats," 95 /** Return true or false depending on whether the incidence "floats,"
96 * i.e. has a date but no time attached to it. */ 96 * i.e. has a date but no time attached to it. */
97 bool doesFloat() const; 97 bool doesFloat() const;
98 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ 98 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */
99 void setFloats(bool f); 99 void setFloats(bool f);
100 100
101 /** 101 /**
102 Add Attendee to this incidence. IncidenceBase takes ownership of the 102 Add Attendee to this incidence. IncidenceBase takes ownership of the
103 Attendee object. 103 Attendee object.
104 */ 104 */
105 bool addAttendee(Attendee *a, bool doupdate=true ); 105 bool addAttendee(Attendee *a, bool doupdate=true );
106// void removeAttendee(Attendee *a); 106// void removeAttendee(Attendee *a);
107// void removeAttendee(const char *n); 107// void removeAttendee(const char *n);
108 /** Remove all Attendees. */ 108 /** Remove all Attendees. */
109 void clearAttendees(); 109 void clearAttendees();
110 /** Return list of attendees. */ 110 /** Return list of attendees. */
111 QPtrList<Attendee> attendees() const { return mAttendees; }; 111 QPtrList<Attendee> attendees() const { return mAttendees; };
112 /** Return number of attendees. */ 112 /** Return number of attendees. */
113 int attendeeCount() const { return mAttendees.count(); }; 113 int attendeeCount() const { return mAttendees.count(); };
114 /** Return the Attendee with this email */ 114 /** Return the Attendee with this email */
115 Attendee* attendeeByMail(const QString &); 115 Attendee* attendeeByMail(const QString &);
116 /** Return first Attendee with one of this emails */ 116 /** Return first Attendee with one of this emails */
117 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); 117 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
118 118
119 /** pilot syncronization states */ 119 /** pilot syncronization states */
120 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 120 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
121 /** Set synchronisation satus. */ 121 /** Set synchronisation satus. */
122 void setSyncStatus(int stat); 122 void setSyncStatus(int stat);
123 /** Return synchronisation status. */ 123 /** Return synchronisation status. */
124 int syncStatus() const; 124 int syncStatus() const;
125 125
126 /** Set Pilot Id. */ 126 /** Set Pilot Id. */
127 void setPilotId(int id); 127 void setPilotId(int id);
128 /** Return Pilot Id. */ 128 /** Return Pilot Id. */
129 int pilotId() const; 129 int pilotId() const;
130 130
131 void setTempSyncStat(int id); 131 void setTempSyncStat(int id);
132 int tempSyncStat() const; 132 int tempSyncStat() const;
133 void setIDStr( const QString & ); 133 void setIDStr( const QString & );
134 QString IDStr() const; 134 QString IDStr() const;
135 void setID( const QString &, const QString & ); 135 void setID( const QString &, const QString & );
136 QString getID( const QString & ); 136 QString getID( const QString & );
137 void setCsum( const QString &, const QString & ); 137 void setCsum( const QString &, const QString & );
138 QString getCsum( const QString & ); 138 QString getCsum( const QString & );
139 void removeID(const QString &); 139 void removeID(const QString &);
140 140
141 void registerObserver( Observer * ); 141 void registerObserver( Observer * );
142 void unRegisterObserver( Observer * ); 142 void unRegisterObserver( Observer * );
143 void updated(); 143 void updated();
144 void setCalID( int id ); 144 void setCalID( int id );
145 int calID() const; 145 int calID() const;
146 void setCalEnabled( bool ); 146 void setCalEnabled( bool );
147 bool calEnabled() const; 147 bool calEnabled() const;
148 void setAlarmEnabled( bool ); 148 void setAlarmEnabled( bool );
149 bool alarmEnabled() const; 149 bool alarmEnabled() const;
150 bool isTagged() const; 150 bool isTagged() const;
151 void setTagged( bool ); 151 void setTagged( bool );
152 virtual void setLastModifiedSubInvalid();
152 protected: 153 protected:
153 bool blockLastModified; 154 bool blockLastModified;
154 bool mIsTagged; 155 bool mIsTagged;
155 QDateTime mDtStart; 156 QDateTime mDtStart;
156 bool mReadOnly; 157 bool mReadOnly;
157 QDateTime getEvenTime( QDateTime ); 158 QDateTime getEvenTime( QDateTime );
158 159
159 private: 160 private:
160 // base components 161 // base components
161 QString mOrganizer; 162 QString mOrganizer;
162 QString mUid; 163 QString mUid;
163 int mCalID; 164 int mCalID;
164 bool mCalEnabled; 165 bool mCalEnabled;
165 bool mAlarmEnabled; 166 bool mAlarmEnabled;
166 QDateTime mLastModified; 167 QDateTime mLastModified;
167 QPtrList<Attendee> mAttendees; 168 QPtrList<Attendee> mAttendees;
168 169
169 bool mFloats; 170 bool mFloats;
170 171
171 int mDuration; 172 int mDuration;
172 bool mHasDuration; 173 bool mHasDuration;
173 QString mExternalId; 174 QString mExternalId;
174 int mTempSyncStat; 175 int mTempSyncStat;
175 176
176 // PILOT SYNCHRONIZATION STUFF 177 // PILOT SYNCHRONIZATION STUFF
177 int mPilotId; // unique id for pilot sync 178 int mPilotId; // unique id for pilot sync
178 int mSyncStatus; // status (for sync) 179 int mSyncStatus; // status (for sync)
179 180
180 QPtrList<Observer> mObservers; 181 QPtrList<Observer> mObservers;
181}; 182};
182 183
183bool operator==( const IncidenceBase&, const IncidenceBase& ); 184bool operator==( const IncidenceBase&, const IncidenceBase& );
184} 185}
185 186
186#endif 187#endif