summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
Unidiff
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 7dd9bd2..8fcdc69 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -5,121 +5,123 @@
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//Added by qt3to4:
30#include <Q3PtrList>
29 31
30using namespace KCal; 32using namespace KCal;
31 33
32Incidence::Incidence() : 34Incidence::Incidence() :
33 IncidenceBase(), 35 IncidenceBase(),
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 36 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 37{
36 mRecurrence = 0;//new Recurrence(this); 38 mRecurrence = 0;//new Recurrence(this);
37 mCancelled = false; 39 mCancelled = false;
38 recreate(); 40 recreate();
39 mHasStartDate = true; 41 mHasStartDate = true;
40 mAlarms.setAutoDelete(true); 42 mAlarms.setAutoDelete(true);
41 mAttachments.setAutoDelete(true); 43 mAttachments.setAutoDelete(true);
42 mHasRecurrenceID = false; 44 mHasRecurrenceID = false;
43 mHoliday = false; 45 mHoliday = false;
44 mBirthday = false; 46 mBirthday = false;
45 mAnniversary = false; 47 mAnniversary = false;
46 48
47} 49}
48 50
49Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) 51Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
50{ 52{
51// TODO: reenable attributes currently commented out. 53// TODO: reenable attributes currently commented out.
52 mRevision = i.mRevision; 54 mRevision = i.mRevision;
53 mCreated = i.mCreated; 55 mCreated = i.mCreated;
54 mDescription = i.mDescription; 56 mDescription = i.mDescription;
55 mSummary = i.mSummary; 57 mSummary = i.mSummary;
56 mCategories = i.mCategories; 58 mCategories = i.mCategories;
57// Incidence *mRelatedTo; Incidence *mRelatedTo; 59// Incidence *mRelatedTo; Incidence *mRelatedTo;
58 mRelatedTo = 0; 60 mRelatedTo = 0;
59 mRelatedToUid = i.mRelatedToUid; 61 mRelatedToUid = i.mRelatedToUid;
60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 62// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
61 mExDates = i.mExDates; 63 mExDates = i.mExDates;
62 QPtrListIterator<Attachment> itat( i.mAttachments ); 64 Q3PtrListIterator<Attachment> itat( i.mAttachments );
63 Attachment *at; 65 Attachment *at;
64 while( (at = itat.current()) ) { 66 while( (at = itat.current()) ) {
65 Attachment *a = new Attachment( *at ); 67 Attachment *a = new Attachment( *at );
66 mAttachments.append( a ); 68 mAttachments.append( a );
67 ++itat; 69 ++itat;
68 } 70 }
69 mAttachments.setAutoDelete( true ); 71 mAttachments.setAutoDelete( true );
70 mResources = i.mResources; 72 mResources = i.mResources;
71 mSecrecy = i.mSecrecy; 73 mSecrecy = i.mSecrecy;
72 mPriority = i.mPriority; 74 mPriority = i.mPriority;
73 mLocation = i.mLocation; 75 mLocation = i.mLocation;
74 mCancelled = i.mCancelled; 76 mCancelled = i.mCancelled;
75 mHasStartDate = i.mHasStartDate; 77 mHasStartDate = i.mHasStartDate;
76 QPtrListIterator<Alarm> it( i.mAlarms ); 78 Q3PtrListIterator<Alarm> it( i.mAlarms );
77 const Alarm *a; 79 const Alarm *a;
78 while( (a = it.current()) ) { 80 while( (a = it.current()) ) {
79 Alarm *b = new Alarm( *a ); 81 Alarm *b = new Alarm( *a );
80 b->setParent( this ); 82 b->setParent( this );
81 mAlarms.append( b ); 83 mAlarms.append( b );
82 84
83 ++it; 85 ++it;
84 } 86 }
85 mAlarms.setAutoDelete(true); 87 mAlarms.setAutoDelete(true);
86 mHasRecurrenceID = i.mHasRecurrenceID; 88 mHasRecurrenceID = i.mHasRecurrenceID;
87 mRecurrenceID = i.mRecurrenceID; 89 mRecurrenceID = i.mRecurrenceID;
88 if ( i.mRecurrence ) 90 if ( i.mRecurrence )
89 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 91 mRecurrence = new Recurrence( *(i.mRecurrence), this );
90 else 92 else
91 mRecurrence = 0; 93 mRecurrence = 0;
92 mHoliday = i.mHoliday ; 94 mHoliday = i.mHoliday ;
93 mBirthday = i.mBirthday; 95 mBirthday = i.mBirthday;
94 mAnniversary = i.mAnniversary; 96 mAnniversary = i.mAnniversary;
95} 97}
96 98
97Incidence::~Incidence() 99Incidence::~Incidence()
98{ 100{
99 101
100 Incidence *ev; 102 Incidence *ev;
101 QPtrList<Incidence> Relations = relations(); 103 Q3PtrList<Incidence> Relations = relations();
102 for (ev=Relations.first();ev;ev=Relations.next()) { 104 for (ev=Relations.first();ev;ev=Relations.next()) {
103 if (ev->relatedTo() == this) ev->setRelatedTo(0); 105 if (ev->relatedTo() == this) ev->setRelatedTo(0);
104 } 106 }
105 if (relatedTo()) relatedTo()->removeRelation(this); 107 if (relatedTo()) relatedTo()->removeRelation(this);
106 if ( mRecurrence ) 108 if ( mRecurrence )
107 delete mRecurrence; 109 delete mRecurrence;
108 110
109} 111}
110QString Incidence::durationText() 112QString Incidence::durationText()
111{ 113{
112 return "---"; 114 return "---";
113} 115}
114QString Incidence::durationText4Time( int offset ) 116QString Incidence::durationText4Time( int offset )
115{ 117{
116 int min = offset/60; 118 int min = offset/60;
117 int hours = min /60; 119 int hours = min /60;
118 min = min % 60; 120 min = min % 60;
119 int days = hours /24; 121 int days = hours /24;
120 hours = hours % 24; 122 hours = hours % 24;
121 123
122 if ( doesFloat() || ( min == 0 && hours == 0 ) ) { 124 if ( doesFloat() || ( min == 0 && hours == 0 ) ) {
123 if ( days == 1 ) 125 if ( days == 1 )
124 return "1" + i18n(" day"); 126 return "1" + i18n(" day");
125 else 127 else
@@ -195,50 +197,50 @@ void Incidence::setHasStartDate(bool f)
195} 197}
196 198
197// A string comparison that considers that null and empty are the same 199// A string comparison that considers that null and empty are the same
198static bool stringCompare( const QString& s1, const QString& s2 ) 200static bool stringCompare( const QString& s1, const QString& s2 )
199{ 201{
200 if ( s1.isEmpty() && s2.isEmpty() ) 202 if ( s1.isEmpty() && s2.isEmpty() )
201 return true; 203 return true;
202 return s1 == s2; 204 return s1 == s2;
203} 205}
204 206
205bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 207bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
206{ 208{
207 209
208 if( i1.alarms().count() != i2.alarms().count() ) { 210 if( i1.alarms().count() != i2.alarms().count() ) {
209 return false; // no need to check further 211 return false; // no need to check further
210 } 212 }
211 if ( i1.alarms().count() > 0 ) { 213 if ( i1.alarms().count() > 0 ) {
212 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 214 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
213 { 215 {
214 qDebug("alarm not equal "); 216 qDebug("alarm not equal ");
215 return false; 217 return false;
216 } 218 }
217 } 219 }
218#if 0 220#if 0
219 QPtrListIterator<Alarm> a1( i1.alarms() ); 221 Q3PtrListIterator<Alarm> a1( i1.alarms() );
220 QPtrListIterator<Alarm> a2( i2.alarms() ); 222 Q3PtrListIterator<Alarm> a2( i2.alarms() );
221 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 223 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
222 if( *a1.current() == *a2.current() ) { 224 if( *a1.current() == *a2.current() ) {
223 continue; 225 continue;
224 } 226 }
225 else { 227 else {
226 return false; 228 return false;
227 } 229 }
228 } 230 }
229#endif 231#endif
230 232
231 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { 233 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
232 if ( i1.hasRecurrenceID() ) { 234 if ( i1.hasRecurrenceID() ) {
233 if ( i1.recurrenceID() != i2.recurrenceID() ) 235 if ( i1.recurrenceID() != i2.recurrenceID() )
234 return false; 236 return false;
235 } 237 }
236 238
237 } else { 239 } else {
238 return false; 240 return false;
239 } 241 }
240 242
241 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 243 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
242 return false; 244 return false;
243 if ( i1.hasStartDate() == i2.hasStartDate() ) { 245 if ( i1.hasStartDate() == i2.hasStartDate() ) {
244 if ( i1.hasStartDate() ) { 246 if ( i1.hasStartDate() ) {
@@ -301,83 +303,83 @@ Incidence* Incidence::recreateCloneException( QDate d )
301 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); 303 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
302 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); 304 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
303 ((Todo*)this)->setRecurDates(); 305 ((Todo*)this)->setRecurDates();
304 } 306 }
305 newInc->setExDates( DateList () ); 307 newInc->setExDates( DateList () );
306 } 308 }
307 return newInc; 309 return newInc;
308} 310}
309 311
310void Incidence::recreate() 312void Incidence::recreate()
311{ 313{
312 setCreated(QDateTime::currentDateTime()); 314 setCreated(QDateTime::currentDateTime());
313 315
314 setUid(CalFormat::createUniqueId()); 316 setUid(CalFormat::createUniqueId());
315 317
316 setRevision(0); 318 setRevision(0);
317 setIDStr( ":" ); 319 setIDStr( ":" );
318 setLastModified(QDateTime::currentDateTime()); 320 setLastModified(QDateTime::currentDateTime());
319} 321}
320void Incidence::cloneRelations( Incidence * newInc ) 322void Incidence::cloneRelations( Incidence * newInc )
321{ 323{
322 // newInc is already a clone of this incidence 324 // newInc is already a clone of this incidence
323 Incidence * inc; 325 Incidence * inc;
324 Incidence * cloneInc; 326 Incidence * cloneInc;
325 QPtrList<Incidence> Relations = relations(); 327 Q3PtrList<Incidence> Relations = relations();
326 for (inc=Relations.first();inc;inc=Relations.next()) { 328 for (inc=Relations.first();inc;inc=Relations.next()) {
327 cloneInc = inc->clone(); 329 cloneInc = inc->clone();
328 cloneInc->recreate(); 330 cloneInc->recreate();
329 cloneInc->setRelatedTo( newInc ); 331 cloneInc->setRelatedTo( newInc );
330 inc->cloneRelations( cloneInc ); 332 inc->cloneRelations( cloneInc );
331 } 333 }
332} 334}
333void Incidence::setReadOnly( bool readOnly ) 335void Incidence::setReadOnly( bool readOnly )
334{ 336{
335 IncidenceBase::setReadOnly( readOnly ); 337 IncidenceBase::setReadOnly( readOnly );
336 if ( mRecurrence ) 338 if ( mRecurrence )
337 mRecurrence->setRecurReadOnly( readOnly); 339 mRecurrence->setRecurReadOnly( readOnly);
338} 340}
339void Incidence::setLastModifiedSubInvalid() 341void Incidence::setLastModifiedSubInvalid()
340{ 342{
341 mLastModifiedSub = QDateTime(); 343 mLastModifiedSub = QDateTime();
342 if ( mRelatedTo ) 344 if ( mRelatedTo )
343 mRelatedTo->setLastModifiedSubInvalid(); 345 mRelatedTo->setLastModifiedSubInvalid();
344} 346}
345QString Incidence::lastModifiedSubSortKey() const 347QString Incidence::lastModifiedSubSortKey() const
346{ 348{
347 if ( mLastModifiedSubSortKey.isEmpty() ) 349 if ( mLastModifiedSubSortKey.isEmpty() )
348 return lastModifiedSortKey(); 350 return lastModifiedSortKey();
349 return mLastModifiedSubSortKey; 351 return mLastModifiedSubSortKey;
350} 352}
351QDateTime Incidence::lastModifiedSub() 353QDateTime Incidence::lastModifiedSub()
352{ 354{
353 if ( !mRelations.count() ) 355 if ( !mRelations.count() )
354 return lastModified(); 356 return lastModified();
355 if ( mLastModifiedSub.isValid() ) 357 if ( mLastModifiedSub.isValid() )
356 return mLastModifiedSub; 358 return mLastModifiedSub;
357 mLastModifiedSub = lastModified(); 359 mLastModifiedSub = lastModified();
358 Incidence * inc; 360 Incidence * inc;
359 QPtrList<Incidence> Relations = relations(); 361 Q3PtrList<Incidence> Relations = relations();
360 for (inc=Relations.first();inc;inc=Relations.next()) { 362 for (inc=Relations.first();inc;inc=Relations.next()) {
361 if ( inc->lastModifiedSub() > mLastModifiedSub ) 363 if ( inc->lastModifiedSub() > mLastModifiedSub )
362 mLastModifiedSub = inc->lastModifiedSub(); 364 mLastModifiedSub = inc->lastModifiedSub();
363 } 365 }
364 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d", 366 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d",
365 mLastModifiedSub.date().year(), 367 mLastModifiedSub.date().year(),
366 mLastModifiedSub.date().month(), 368 mLastModifiedSub.date().month(),
367 mLastModifiedSub.date().day(), 369 mLastModifiedSub.date().day(),
368 mLastModifiedSub.time().hour(), 370 mLastModifiedSub.time().hour(),
369 mLastModifiedSub.time().minute(), 371 mLastModifiedSub.time().minute(),
370 mLastModifiedSub.time().second() ); 372 mLastModifiedSub.time().second() );
371 return mLastModifiedSub; 373 return mLastModifiedSub;
372} 374}
373void Incidence::setCreated(QDateTime created) 375void Incidence::setCreated(QDateTime created)
374{ 376{
375 if (mReadOnly) return; 377 if (mReadOnly) return;
376 mCreated = getEvenTime(created); 378 mCreated = getEvenTime(created);
377} 379}
378 380
379QDateTime Incidence::created() const 381QDateTime Incidence::created() const
380{ 382{
381 return mCreated; 383 return mCreated;
382} 384}
383 385
@@ -426,64 +428,64 @@ void Incidence::setSummary(const QString &summary)
426 428
427QString Incidence::summary() const 429QString Incidence::summary() const
428{ 430{
429 return mSummary; 431 return mSummary;
430} 432}
431void Incidence::checkCategories() 433void Incidence::checkCategories()
432{ 434{
433 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 435 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
434 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 436 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
435 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 437 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
436} 438}
437 439
438void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 440void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
439{ 441{
440 if (mReadOnly) return; 442 if (mReadOnly) return;
441 int i; 443 int i;
442 for( i = 0; i < categories.count(); ++i ) { 444 for( i = 0; i < categories.count(); ++i ) {
443 if ( !mCategories.contains (categories[i])) 445 if ( !mCategories.contains (categories[i]))
444 mCategories.append( categories[i] ); 446 mCategories.append( categories[i] );
445 } 447 }
446 checkCategories(); 448 checkCategories();
447 updated(); 449 updated();
448 if ( addToRelations ) { 450 if ( addToRelations ) {
449 Incidence * inc; 451 Incidence * inc;
450 QPtrList<Incidence> Relations = relations(); 452 Q3PtrList<Incidence> Relations = relations();
451 for (inc=Relations.first();inc;inc=Relations.next()) { 453 for (inc=Relations.first();inc;inc=Relations.next()) {
452 inc->addCategories( categories, true ); 454 inc->addCategories( categories, true );
453 } 455 }
454 } 456 }
455} 457}
456 458
457void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 459void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
458{ 460{
459 if (mReadOnly) return; 461 if (mReadOnly) return;
460 mCategories = categories; 462 mCategories = categories;
461 checkCategories(); 463 checkCategories();
462 updated(); 464 updated();
463 if ( setForRelations ) { 465 if ( setForRelations ) {
464 Incidence * inc; 466 Incidence * inc;
465 QPtrList<Incidence> Relations = relations(); 467 Q3PtrList<Incidence> Relations = relations();
466 for (inc=Relations.first();inc;inc=Relations.next()) { 468 for (inc=Relations.first();inc;inc=Relations.next()) {
467 inc->setCategories( categories, true ); 469 inc->setCategories( categories, true );
468 } 470 }
469 } 471 }
470} 472}
471 473
472// TODO: remove setCategories(QString) function 474// TODO: remove setCategories(QString) function
473void Incidence::setCategories(const QString &catStr) 475void Incidence::setCategories(const QString &catStr)
474{ 476{
475 if (mReadOnly) return; 477 if (mReadOnly) return;
476 mCategories.clear(); 478 mCategories.clear();
477 479
478 if (catStr.isEmpty()) return; 480 if (catStr.isEmpty()) return;
479 481
480 mCategories = QStringList::split(",",catStr); 482 mCategories = QStringList::split(",",catStr);
481 483
482 QStringList::Iterator it; 484 QStringList::Iterator it;
483 for(it = mCategories.begin();it != mCategories.end(); ++it) { 485 for(it = mCategories.begin();it != mCategories.end(); ++it) {
484 *it = (*it).stripWhiteSpace(); 486 *it = (*it).stripWhiteSpace();
485 } 487 }
486 checkCategories(); 488 checkCategories();
487 updated(); 489 updated();
488} 490}
489// using this makes filtering 3 times faster 491// using this makes filtering 3 times faster
@@ -529,57 +531,57 @@ void Incidence::resetRelatedTo()
529 531
530void Incidence::setRelatedTo(Incidence *relatedTo) 532void Incidence::setRelatedTo(Incidence *relatedTo)
531{ 533{
532 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 534 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
533 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 535 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
534 if (mReadOnly || mRelatedTo == relatedTo) return; 536 if (mReadOnly || mRelatedTo == relatedTo) return;
535 if(mRelatedTo) { 537 if(mRelatedTo) {
536 // updated(); 538 // updated();
537 mRelatedTo->removeRelation(this); 539 mRelatedTo->removeRelation(this);
538 } 540 }
539 mRelatedTo = relatedTo; 541 mRelatedTo = relatedTo;
540 if (mRelatedTo) { 542 if (mRelatedTo) {
541 mRelatedTo->addRelation(this); 543 mRelatedTo->addRelation(this);
542 mRelatedToUid = mRelatedTo->uid(); 544 mRelatedToUid = mRelatedTo->uid();
543 } else { 545 } else {
544 mRelatedToUid = ""; 546 mRelatedToUid = "";
545 } 547 }
546} 548}
547 549
548Incidence *Incidence::relatedTo() const 550Incidence *Incidence::relatedTo() const
549{ 551{
550 return mRelatedTo; 552 return mRelatedTo;
551} 553}
552 554
553QPtrList<Incidence> Incidence::relations() const 555Q3PtrList<Incidence> Incidence::relations() const
554{ 556{
555 return mRelations; 557 return mRelations;
556} 558}
557 559
558void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 560void Incidence::addRelationsToList(Q3PtrList<Incidence> *rel)
559{ 561{
560 Incidence* inc; 562 Incidence* inc;
561 QPtrList<Incidence> Relations = relations(); 563 Q3PtrList<Incidence> Relations = relations();
562 for (inc=Relations.first();inc;inc=Relations.next()) { 564 for (inc=Relations.first();inc;inc=Relations.next()) {
563 inc->addRelationsToList( rel ); 565 inc->addRelationsToList( rel );
564 } 566 }
565 if ( rel->findRef( this ) == -1 ) 567 if ( rel->findRef( this ) == -1 )
566 rel->append( this ); 568 rel->append( this );
567} 569}
568 570
569void Incidence::addRelation(Incidence *event) 571void Incidence::addRelation(Incidence *event)
570{ 572{
571 setLastModifiedSubInvalid(); 573 setLastModifiedSubInvalid();
572 if( mRelations.findRef( event ) == -1 ) { 574 if( mRelations.findRef( event ) == -1 ) {
573 mRelations.append(event); 575 mRelations.append(event);
574 //updated(); 576 //updated();
575 } 577 }
576} 578}
577 579
578void Incidence::removeRelation(Incidence *event) 580void Incidence::removeRelation(Incidence *event)
579{ 581{
580 setLastModifiedSubInvalid(); 582 setLastModifiedSubInvalid();
581 mRelations.removeRef(event); 583 mRelations.removeRef(event);
582// if (event->getRelatedTo() == this) event->setRelatedTo(0); 584// if (event->getRelatedTo() == this) event->setRelatedTo(0);
583} 585}
584 586
585bool Incidence::recursOn(const QDate &qd) const 587bool Incidence::recursOn(const QDate &qd) const
@@ -626,57 +628,57 @@ bool Incidence::isException(const QDate &date) const
626 628
627void Incidence::addAttachment(Attachment *attachment) 629void Incidence::addAttachment(Attachment *attachment)
628{ 630{
629 if (mReadOnly || !attachment) return; 631 if (mReadOnly || !attachment) return;
630 mAttachments.append(attachment); 632 mAttachments.append(attachment);
631 updated(); 633 updated();
632} 634}
633 635
634void Incidence::deleteAttachment(Attachment *attachment) 636void Incidence::deleteAttachment(Attachment *attachment)
635{ 637{
636 mAttachments.removeRef(attachment); 638 mAttachments.removeRef(attachment);
637} 639}
638 640
639void Incidence::deleteAttachments(const QString& mime) 641void Incidence::deleteAttachments(const QString& mime)
640{ 642{
641 Attachment *at = mAttachments.first(); 643 Attachment *at = mAttachments.first();
642 while (at) { 644 while (at) {
643 if (at->mimeType() == mime) 645 if (at->mimeType() == mime)
644 mAttachments.remove(); 646 mAttachments.remove();
645 else 647 else
646 at = mAttachments.next(); 648 at = mAttachments.next();
647 } 649 }
648} 650}
649 651
650QPtrList<Attachment> Incidence::attachments() const 652Q3PtrList<Attachment> Incidence::attachments() const
651{ 653{
652 return mAttachments; 654 return mAttachments;
653} 655}
654 656
655QPtrList<Attachment> Incidence::attachments(const QString& mime) const 657Q3PtrList<Attachment> Incidence::attachments(const QString& mime) const
656{ 658{
657 QPtrList<Attachment> attachments; 659 Q3PtrList<Attachment> attachments;
658 QPtrListIterator<Attachment> it( mAttachments ); 660 Q3PtrListIterator<Attachment> it( mAttachments );
659 Attachment *at; 661 Attachment *at;
660 while ( (at = it.current()) ) { 662 while ( (at = it.current()) ) {
661 if (at->mimeType() == mime) 663 if (at->mimeType() == mime)
662 attachments.append(at); 664 attachments.append(at);
663 ++it; 665 ++it;
664 } 666 }
665 667
666 return attachments; 668 return attachments;
667} 669}
668 670
669void Incidence::setResources(const QStringList &resources) 671void Incidence::setResources(const QStringList &resources)
670{ 672{
671 if (mReadOnly) return; 673 if (mReadOnly) return;
672 mResources = resources; 674 mResources = resources;
673 updated(); 675 updated();
674} 676}
675 677
676QStringList Incidence::resources() const 678QStringList Incidence::resources() const
677{ 679{
678 return mResources; 680 return mResources;
679} 681}
680 682
681 683
682void Incidence::setPriority(int priority) 684void Incidence::setPriority(int priority)
@@ -716,83 +718,83 @@ QString Incidence::secrecyName(int secrecy)
716 break; 718 break;
717 case SecrecyPrivate: 719 case SecrecyPrivate:
718 return i18n("Private"); 720 return i18n("Private");
719 break; 721 break;
720 case SecrecyConfidential: 722 case SecrecyConfidential:
721 return i18n("Confidential"); 723 return i18n("Confidential");
722 break; 724 break;
723 default: 725 default:
724 return i18n("Undefined"); 726 return i18n("Undefined");
725 break; 727 break;
726 } 728 }
727} 729}
728 730
729QStringList Incidence::secrecyList() 731QStringList Incidence::secrecyList()
730{ 732{
731 QStringList list; 733 QStringList list;
732 list << secrecyName(SecrecyPublic); 734 list << secrecyName(SecrecyPublic);
733 list << secrecyName(SecrecyPrivate); 735 list << secrecyName(SecrecyPrivate);
734 list << secrecyName(SecrecyConfidential); 736 list << secrecyName(SecrecyConfidential);
735 737
736 return list; 738 return list;
737} 739}
738 740
739 741
740QPtrList<Alarm> Incidence::alarms() const 742Q3PtrList<Alarm> Incidence::alarms() const
741{ 743{
742 return mAlarms; 744 return mAlarms;
743} 745}
744 746
745Alarm* Incidence::newAlarm() 747Alarm* Incidence::newAlarm()
746{ 748{
747 Alarm* alarm = new Alarm(this); 749 Alarm* alarm = new Alarm(this);
748 mAlarms.append(alarm); 750 mAlarms.append(alarm);
749// updated(); 751// updated();
750 return alarm; 752 return alarm;
751} 753}
752 754
753void Incidence::addAlarm(Alarm *alarm) 755void Incidence::addAlarm(Alarm *alarm)
754{ 756{
755 mAlarms.append(alarm); 757 mAlarms.append(alarm);
756 updated(); 758 updated();
757} 759}
758 760
759void Incidence::removeAlarm(Alarm *alarm) 761void Incidence::removeAlarm(Alarm *alarm)
760{ 762{
761 mAlarms.removeRef(alarm); 763 mAlarms.removeRef(alarm);
762 updated(); 764 updated();
763} 765}
764 766
765void Incidence::clearAlarms() 767void Incidence::clearAlarms()
766{ 768{
767 mAlarms.clear(); 769 mAlarms.clear();
768 updated(); 770 updated();
769} 771}
770 772
771bool Incidence::isAlarmEnabled() const 773bool Incidence::isAlarmEnabled() const
772{ 774{
773 Alarm* alarm; 775 Alarm* alarm;
774 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 776 for (Q3PtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
775 if (alarm->enabled()) 777 if (alarm->enabled())
776 return true; 778 return true;
777 } 779 }
778 return false; 780 return false;
779} 781}
780#include <stdlib.h> 782#include <stdlib.h>
781Recurrence *Incidence::recurrence() 783Recurrence *Incidence::recurrence()
782{ 784{
783 if ( ! mRecurrence ) { 785 if ( ! mRecurrence ) {
784 mRecurrence = new Recurrence(this); 786 mRecurrence = new Recurrence(this);
785 mRecurrence->setRecurStart( dtStart() ); 787 mRecurrence->setRecurStart( dtStart() );
786 mRecurrence->setRecurReadOnly( isReadOnly()); 788 mRecurrence->setRecurReadOnly( isReadOnly());
787 //qDebug("creating new recurence "); 789 //qDebug("creating new recurence ");
788 //abort(); 790 //abort();
789 } 791 }
790 return mRecurrence; 792 return mRecurrence;
791} 793}
792void Incidence::setRecurrence( Recurrence * r) 794void Incidence::setRecurrence( Recurrence * r)
793{ 795{
794 if ( mRecurrence ) 796 if ( mRecurrence )
795 delete mRecurrence; 797 delete mRecurrence;
796 mRecurrence = r; 798 mRecurrence = r;
797} 799}
798 800