summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
Unidiff
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index f9e1e9e..dbc159c 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -1,556 +1,589 @@
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} 43}
43 44
44Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) 45Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
45{ 46{
46// TODO: reenable attributes currently commented out. 47// TODO: reenable attributes currently commented out.
47 mRevision = i.mRevision; 48 mRevision = i.mRevision;
48 mCreated = i.mCreated; 49 mCreated = i.mCreated;
49 mDescription = i.mDescription; 50 mDescription = i.mDescription;
50 mSummary = i.mSummary; 51 mSummary = i.mSummary;
51 mCategories = i.mCategories; 52 mCategories = i.mCategories;
52// Incidence *mRelatedTo; Incidence *mRelatedTo; 53// Incidence *mRelatedTo; Incidence *mRelatedTo;
53 mRelatedTo = 0; 54 mRelatedTo = 0;
54 mRelatedToUid = i.mRelatedToUid; 55 mRelatedToUid = i.mRelatedToUid;
55// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 56// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
56 mExDates = i.mExDates; 57 mExDates = i.mExDates;
57 mAttachments = i.mAttachments; 58 mAttachments = i.mAttachments;
58 mResources = i.mResources; 59 mResources = i.mResources;
59 mSecrecy = i.mSecrecy; 60 mSecrecy = i.mSecrecy;
60 mPriority = i.mPriority; 61 mPriority = i.mPriority;
61 mLocation = i.mLocation; 62 mLocation = i.mLocation;
62 mCancelled = i.mCancelled; 63 mCancelled = i.mCancelled;
63 mHasStartDate = i.mHasStartDate; 64 mHasStartDate = i.mHasStartDate;
64 QPtrListIterator<Alarm> it( i.mAlarms ); 65 QPtrListIterator<Alarm> it( i.mAlarms );
65 const Alarm *a; 66 const Alarm *a;
66 while( (a = it.current()) ) { 67 while( (a = it.current()) ) {
67 Alarm *b = new Alarm( *a ); 68 Alarm *b = new Alarm( *a );
68 b->setParent( this ); 69 b->setParent( this );
69 mAlarms.append( b ); 70 mAlarms.append( b );
70 71
71 ++it; 72 ++it;
72 } 73 }
73 mAlarms.setAutoDelete(true); 74 mAlarms.setAutoDelete(true);
74 75 mHasRecurrenceID = i.mHasRecurrenceID;
76 mRecurrenceID = i.mRecurrenceID;
75 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 77 mRecurrence = new Recurrence( *(i.mRecurrence), this );
76} 78}
77 79
78Incidence::~Incidence() 80Incidence::~Incidence()
79{ 81{
80 82
81 Incidence *ev; 83 Incidence *ev;
82 QPtrList<Incidence> Relations = relations(); 84 QPtrList<Incidence> Relations = relations();
83 for (ev=Relations.first();ev;ev=Relations.next()) { 85 for (ev=Relations.first();ev;ev=Relations.next()) {
84 if (ev->relatedTo() == this) ev->setRelatedTo(0); 86 if (ev->relatedTo() == this) ev->setRelatedTo(0);
85 } 87 }
86 if (relatedTo()) relatedTo()->removeRelation(this); 88 if (relatedTo()) relatedTo()->removeRelation(this);
87 delete mRecurrence; 89 delete mRecurrence;
88 90
89} 91}
92bool Incidence::hasRecurrenceID() const
93{
94 return mHasRecurrenceID;
95}
96
97void Incidence::setHasRecurrenceID( bool b )
98{
99 mHasRecurrenceID = b;
100}
101
102void Incidence::setRecurrenceID(QDateTime d)
103{
104 mRecurrenceID = d;
105 mHasRecurrenceID = true;
106 updated();
107}
108QDateTime Incidence::recurrenceID () const
109{
110 return mRecurrenceID;
111}
90 112
91bool Incidence::cancelled() const 113bool Incidence::cancelled() const
92{ 114{
93 return mCancelled; 115 return mCancelled;
94} 116}
95void Incidence::setCancelled( bool b ) 117void Incidence::setCancelled( bool b )
96{ 118{
97 mCancelled = b; 119 mCancelled = b;
98 updated(); 120 updated();
99} 121}
100bool Incidence::hasStartDate() const 122bool Incidence::hasStartDate() const
101{ 123{
102 return mHasStartDate; 124 return mHasStartDate;
103} 125}
104 126
105void Incidence::setHasStartDate(bool f) 127void Incidence::setHasStartDate(bool f)
106{ 128{
107 if (mReadOnly) return; 129 if (mReadOnly) return;
108 mHasStartDate = f; 130 mHasStartDate = f;
109 updated(); 131 updated();
110} 132}
111 133
112// A string comparison that considers that null and empty are the same 134// A string comparison that considers that null and empty are the same
113static bool stringCompare( const QString& s1, const QString& s2 ) 135static bool stringCompare( const QString& s1, const QString& s2 )
114{ 136{
115 if ( s1.isEmpty() && s2.isEmpty() ) 137 if ( s1.isEmpty() && s2.isEmpty() )
116 return true; 138 return true;
117 return s1 == s2; 139 return s1 == s2;
118} 140}
119 141
120bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 142bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
121{ 143{
122 144
123 if( i1.alarms().count() != i2.alarms().count() ) { 145 if( i1.alarms().count() != i2.alarms().count() ) {
124 return false; // no need to check further 146 return false; // no need to check further
125 } 147 }
126 if ( i1.alarms().count() > 0 ) { 148 if ( i1.alarms().count() > 0 ) {
127 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 149 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
128 { 150 {
129 qDebug("alarm not equal "); 151 qDebug("alarm not equal ");
130 return false; 152 return false;
131 } 153 }
132 } 154 }
133#if 0 155#if 0
134 QPtrListIterator<Alarm> a1( i1.alarms() ); 156 QPtrListIterator<Alarm> a1( i1.alarms() );
135 QPtrListIterator<Alarm> a2( i2.alarms() ); 157 QPtrListIterator<Alarm> a2( i2.alarms() );
136 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 158 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
137 if( *a1.current() == *a2.current() ) { 159 if( *a1.current() == *a2.current() ) {
138 continue; 160 continue;
139 } 161 }
140 else { 162 else {
141 return false; 163 return false;
142 } 164 }
143 } 165 }
144#endif 166#endif
145 167
168 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
169 if ( i1.hasRecurrenceID() ) {
170 if ( i1.recurrenceID() != i2.recurrenceID() )
171 return false;
172 }
173
174 } else {
175 return false;
176 }
177
146 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 178 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
147 return false; 179 return false;
148 if ( i1.hasStartDate() == i2.hasStartDate() ) { 180 if ( i1.hasStartDate() == i2.hasStartDate() ) {
149 if ( i1.hasStartDate() ) { 181 if ( i1.hasStartDate() ) {
150 if ( i1.dtStart() != i2.dtStart() ) 182 if ( i1.dtStart() != i2.dtStart() )
151 return false; 183 return false;
152 } 184 }
153 } else { 185 } else {
154 return false; 186 return false;
155 } 187 }
156 if (!( *i1.recurrence() == *i2.recurrence()) ) { 188 if (!( *i1.recurrence() == *i2.recurrence()) ) {
157 qDebug("recurrence is NOT equal "); 189 qDebug("recurrence is NOT equal ");
158 return false; 190 return false;
159 } 191 }
160 return 192 return
161 // i1.created() == i2.created() && 193 // i1.created() == i2.created() &&
162 stringCompare( i1.description(), i2.description() ) && 194 stringCompare( i1.description(), i2.description() ) &&
163 stringCompare( i1.summary(), i2.summary() ) && 195 stringCompare( i1.summary(), i2.summary() ) &&
164 i1.categories() == i2.categories() && 196 i1.categories() == i2.categories() &&
165 // no need to compare mRelatedTo 197 // no need to compare mRelatedTo
166 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 198 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
167 // i1.relations() == i2.relations() && 199 // i1.relations() == i2.relations() &&
168 i1.exDates() == i2.exDates() && 200 i1.exDates() == i2.exDates() &&
169 i1.attachments() == i2.attachments() && 201 i1.attachments() == i2.attachments() &&
170 i1.resources() == i2.resources() && 202 i1.resources() == i2.resources() &&
171 i1.secrecy() == i2.secrecy() && 203 i1.secrecy() == i2.secrecy() &&
172 i1.priority() == i2.priority() && 204 i1.priority() == i2.priority() &&
205 i1.cancelled() == i2.cancelled() &&
173 stringCompare( i1.location(), i2.location() ); 206 stringCompare( i1.location(), i2.location() );
174} 207}
175 208
176Incidence* Incidence::recreateCloneException( QDate d ) 209Incidence* Incidence::recreateCloneException( QDate d )
177{ 210{
178 Incidence* newInc = clone(); 211 Incidence* newInc = clone();
179 newInc->recreate(); 212 newInc->recreate();
180 if ( doesRecur() ) { 213 if ( doesRecur() ) {
181 addExDate( d ); 214 addExDate( d );
182 newInc->recurrence()->unsetRecurs(); 215 newInc->recurrence()->unsetRecurs();
183 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 216 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
184 QTime tim = dtStart().time(); 217 QTime tim = dtStart().time();
185 newInc->setDtStart( QDateTime(d, tim) ); 218 newInc->setDtStart( QDateTime(d, tim) );
186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 219 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
187 } 220 }
188 return newInc; 221 return newInc;
189} 222}
190 223
191void Incidence::recreate() 224void Incidence::recreate()
192{ 225{
193 setCreated(QDateTime::currentDateTime()); 226 setCreated(QDateTime::currentDateTime());
194 227
195 setUid(CalFormat::createUniqueId()); 228 setUid(CalFormat::createUniqueId());
196 229
197 setRevision(0); 230 setRevision(0);
198 setIDStr( ":" ); 231 setIDStr( ":" );
199 setLastModified(QDateTime::currentDateTime()); 232 setLastModified(QDateTime::currentDateTime());
200} 233}
201 234
202void Incidence::setReadOnly( bool readOnly ) 235void Incidence::setReadOnly( bool readOnly )
203{ 236{
204 IncidenceBase::setReadOnly( readOnly ); 237 IncidenceBase::setReadOnly( readOnly );
205 recurrence()->setRecurReadOnly( readOnly); 238 recurrence()->setRecurReadOnly( readOnly);
206} 239}
207 240
208void Incidence::setCreated(QDateTime created) 241void Incidence::setCreated(QDateTime created)
209{ 242{
210 if (mReadOnly) return; 243 if (mReadOnly) return;
211 mCreated = getEvenTime(created); 244 mCreated = getEvenTime(created);
212} 245}
213 246
214QDateTime Incidence::created() const 247QDateTime Incidence::created() const
215{ 248{
216 return mCreated; 249 return mCreated;
217} 250}
218 251
219void Incidence::setRevision(int rev) 252void Incidence::setRevision(int rev)
220{ 253{
221 if (mReadOnly) return; 254 if (mReadOnly) return;
222 mRevision = rev; 255 mRevision = rev;
223 256
224 updated(); 257 updated();
225} 258}
226 259
227int Incidence::revision() const 260int Incidence::revision() const
228{ 261{
229 return mRevision; 262 return mRevision;
230} 263}
231 264
232void Incidence::setDtStart(const QDateTime &dtStart) 265void Incidence::setDtStart(const QDateTime &dtStart)
233{ 266{
234 267
235 QDateTime dt = getEvenTime(dtStart); 268 QDateTime dt = getEvenTime(dtStart);
236 recurrence()->setRecurStart( dt); 269 recurrence()->setRecurStart( dt);
237 IncidenceBase::setDtStart( dt ); 270 IncidenceBase::setDtStart( dt );
238} 271}
239 272
240void Incidence::setDescription(const QString &description) 273void Incidence::setDescription(const QString &description)
241{ 274{
242 if (mReadOnly) return; 275 if (mReadOnly) return;
243 mDescription = description; 276 mDescription = description;
244 updated(); 277 updated();
245} 278}
246 279
247QString Incidence::description() const 280QString Incidence::description() const
248{ 281{
249 return mDescription; 282 return mDescription;
250} 283}
251 284
252 285
253void Incidence::setSummary(const QString &summary) 286void Incidence::setSummary(const QString &summary)
254{ 287{
255 if (mReadOnly) return; 288 if (mReadOnly) return;
256 mSummary = summary; 289 mSummary = summary;
257 updated(); 290 updated();
258} 291}
259 292
260QString Incidence::summary() const 293QString Incidence::summary() const
261{ 294{
262 return mSummary; 295 return mSummary;
263} 296}
264 297
265void Incidence::setCategories(const QStringList &categories) 298void Incidence::setCategories(const QStringList &categories)
266{ 299{
267 if (mReadOnly) return; 300 if (mReadOnly) return;
268 mCategories = categories; 301 mCategories = categories;
269 updated(); 302 updated();
270} 303}
271 304
272// TODO: remove setCategories(QString) function 305// TODO: remove setCategories(QString) function
273void Incidence::setCategories(const QString &catStr) 306void Incidence::setCategories(const QString &catStr)
274{ 307{
275 if (mReadOnly) return; 308 if (mReadOnly) return;
276 mCategories.clear(); 309 mCategories.clear();
277 310
278 if (catStr.isEmpty()) return; 311 if (catStr.isEmpty()) return;
279 312
280 mCategories = QStringList::split(",",catStr); 313 mCategories = QStringList::split(",",catStr);
281 314
282 QStringList::Iterator it; 315 QStringList::Iterator it;
283 for(it = mCategories.begin();it != mCategories.end(); ++it) { 316 for(it = mCategories.begin();it != mCategories.end(); ++it) {
284 *it = (*it).stripWhiteSpace(); 317 *it = (*it).stripWhiteSpace();
285 } 318 }
286 319
287 updated(); 320 updated();
288} 321}
289 322
290QStringList Incidence::categories() const 323QStringList Incidence::categories() const
291{ 324{
292 return mCategories; 325 return mCategories;
293} 326}
294 327
295QString Incidence::categoriesStr() 328QString Incidence::categoriesStr()
296{ 329{
297 return mCategories.join(","); 330 return mCategories.join(",");
298} 331}
299 332
300void Incidence::setRelatedToUid(const QString &relatedToUid) 333void Incidence::setRelatedToUid(const QString &relatedToUid)
301{ 334{
302 if (mReadOnly) return; 335 if (mReadOnly) return;
303 mRelatedToUid = relatedToUid; 336 mRelatedToUid = relatedToUid;
304} 337}
305 338
306QString Incidence::relatedToUid() const 339QString Incidence::relatedToUid() const
307{ 340{
308 return mRelatedToUid; 341 return mRelatedToUid;
309} 342}
310 343
311void Incidence::setRelatedTo(Incidence *relatedTo) 344void Incidence::setRelatedTo(Incidence *relatedTo)
312{ 345{
313 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 346 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
314 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 347 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
315 if (mReadOnly || mRelatedTo == relatedTo) return; 348 if (mReadOnly || mRelatedTo == relatedTo) return;
316 if(mRelatedTo) { 349 if(mRelatedTo) {
317 // updated(); 350 // updated();
318 mRelatedTo->removeRelation(this); 351 mRelatedTo->removeRelation(this);
319 } 352 }
320 mRelatedTo = relatedTo; 353 mRelatedTo = relatedTo;
321 if (mRelatedTo) mRelatedTo->addRelation(this); 354 if (mRelatedTo) mRelatedTo->addRelation(this);
322} 355}
323 356
324Incidence *Incidence::relatedTo() const 357Incidence *Incidence::relatedTo() const
325{ 358{
326 return mRelatedTo; 359 return mRelatedTo;
327} 360}
328 361
329QPtrList<Incidence> Incidence::relations() const 362QPtrList<Incidence> Incidence::relations() const
330{ 363{
331 return mRelations; 364 return mRelations;
332} 365}
333 366
334void Incidence::addRelation(Incidence *event) 367void Incidence::addRelation(Incidence *event)
335{ 368{
336 if( mRelations.findRef( event ) == -1 ) { 369 if( mRelations.findRef( event ) == -1 ) {
337 mRelations.append(event); 370 mRelations.append(event);
338 //updated(); 371 //updated();
339 } 372 }
340} 373}
341 374
342void Incidence::removeRelation(Incidence *event) 375void Incidence::removeRelation(Incidence *event)
343{ 376{
344 377
345 mRelations.removeRef(event); 378 mRelations.removeRef(event);
346 379
347// if (event->getRelatedTo() == this) event->setRelatedTo(0); 380// if (event->getRelatedTo() == this) event->setRelatedTo(0);
348} 381}
349 382
350bool Incidence::recursOn(const QDate &qd) const 383bool Incidence::recursOn(const QDate &qd) const
351{ 384{
352 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; 385 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true;
353 else return false; 386 else return false;
354} 387}
355 388
356void Incidence::setExDates(const DateList &exDates) 389void Incidence::setExDates(const DateList &exDates)
357{ 390{
358 if (mReadOnly) return; 391 if (mReadOnly) return;
359 mExDates = exDates; 392 mExDates = exDates;
360 393
361 recurrence()->setRecurExDatesCount(mExDates.count()); 394 recurrence()->setRecurExDatesCount(mExDates.count());
362 395
363 updated(); 396 updated();
364} 397}
365 398
366void Incidence::addExDate(const QDate &date) 399void Incidence::addExDate(const QDate &date)
367{ 400{
368 if (mReadOnly) return; 401 if (mReadOnly) return;
369 mExDates.append(date); 402 mExDates.append(date);
370 403
371 recurrence()->setRecurExDatesCount(mExDates.count()); 404 recurrence()->setRecurExDatesCount(mExDates.count());
372 405
373 updated(); 406 updated();
374} 407}
375 408
376DateList Incidence::exDates() const 409DateList Incidence::exDates() const
377{ 410{
378 return mExDates; 411 return mExDates;
379} 412}
380 413
381bool Incidence::isException(const QDate &date) const 414bool Incidence::isException(const QDate &date) const
382{ 415{
383 DateList::ConstIterator it; 416 DateList::ConstIterator it;
384 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 417 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
385 if ( (*it) == date ) { 418 if ( (*it) == date ) {
386 return true; 419 return true;
387 } 420 }
388 } 421 }
389 422
390 return false; 423 return false;
391} 424}
392 425
393void Incidence::addAttachment(Attachment *attachment) 426void Incidence::addAttachment(Attachment *attachment)
394{ 427{
395 if (mReadOnly || !attachment) return; 428 if (mReadOnly || !attachment) return;
396 mAttachments.append(attachment); 429 mAttachments.append(attachment);
397 updated(); 430 updated();
398} 431}
399 432
400void Incidence::deleteAttachment(Attachment *attachment) 433void Incidence::deleteAttachment(Attachment *attachment)
401{ 434{
402 mAttachments.removeRef(attachment); 435 mAttachments.removeRef(attachment);
403} 436}
404 437
405void Incidence::deleteAttachments(const QString& mime) 438void Incidence::deleteAttachments(const QString& mime)
406{ 439{
407 Attachment *at = mAttachments.first(); 440 Attachment *at = mAttachments.first();
408 while (at) { 441 while (at) {
409 if (at->mimeType() == mime) 442 if (at->mimeType() == mime)
410 mAttachments.remove(); 443 mAttachments.remove();
411 else 444 else
412 at = mAttachments.next(); 445 at = mAttachments.next();
413 } 446 }
414} 447}
415 448
416QPtrList<Attachment> Incidence::attachments() const 449QPtrList<Attachment> Incidence::attachments() const
417{ 450{
418 return mAttachments; 451 return mAttachments;
419} 452}
420 453
421QPtrList<Attachment> Incidence::attachments(const QString& mime) const 454QPtrList<Attachment> Incidence::attachments(const QString& mime) const
422{ 455{
423 QPtrList<Attachment> attachments; 456 QPtrList<Attachment> attachments;
424 QPtrListIterator<Attachment> it( mAttachments ); 457 QPtrListIterator<Attachment> it( mAttachments );
425 Attachment *at; 458 Attachment *at;
426 while ( (at = it.current()) ) { 459 while ( (at = it.current()) ) {
427 if (at->mimeType() == mime) 460 if (at->mimeType() == mime)
428 attachments.append(at); 461 attachments.append(at);
429 ++it; 462 ++it;
430 } 463 }
431 464
432 return attachments; 465 return attachments;
433} 466}
434 467
435void Incidence::setResources(const QStringList &resources) 468void Incidence::setResources(const QStringList &resources)
436{ 469{
437 if (mReadOnly) return; 470 if (mReadOnly) return;
438 mResources = resources; 471 mResources = resources;
439 updated(); 472 updated();
440} 473}
441 474
442QStringList Incidence::resources() const 475QStringList Incidence::resources() const
443{ 476{
444 return mResources; 477 return mResources;
445} 478}
446 479
447 480
448void Incidence::setPriority(int priority) 481void Incidence::setPriority(int priority)
449{ 482{
450 if (mReadOnly) return; 483 if (mReadOnly) return;
451 mPriority = priority; 484 mPriority = priority;
452 updated(); 485 updated();
453} 486}
454 487
455int Incidence::priority() const 488int Incidence::priority() const
456{ 489{
457 return mPriority; 490 return mPriority;
458} 491}
459 492
460void Incidence::setSecrecy(int sec) 493void Incidence::setSecrecy(int sec)
461{ 494{
462 if (mReadOnly) return; 495 if (mReadOnly) return;
463 mSecrecy = sec; 496 mSecrecy = sec;
464 updated(); 497 updated();
465} 498}
466 499
467int Incidence::secrecy() const 500int Incidence::secrecy() const
468{ 501{
469 return mSecrecy; 502 return mSecrecy;
470} 503}
471 504
472QString Incidence::secrecyStr() const 505QString Incidence::secrecyStr() const
473{ 506{
474 return secrecyName(mSecrecy); 507 return secrecyName(mSecrecy);
475} 508}
476 509
477QString Incidence::secrecyName(int secrecy) 510QString Incidence::secrecyName(int secrecy)
478{ 511{
479 switch (secrecy) { 512 switch (secrecy) {
480 case SecrecyPublic: 513 case SecrecyPublic:
481 return i18n("Public"); 514 return i18n("Public");
482 break; 515 break;
483 case SecrecyPrivate: 516 case SecrecyPrivate:
484 return i18n("Private"); 517 return i18n("Private");
485 break; 518 break;
486 case SecrecyConfidential: 519 case SecrecyConfidential:
487 return i18n("Confidential"); 520 return i18n("Confidential");
488 break; 521 break;
489 default: 522 default:
490 return i18n("Undefined"); 523 return i18n("Undefined");
491 break; 524 break;
492 } 525 }
493} 526}
494 527
495QStringList Incidence::secrecyList() 528QStringList Incidence::secrecyList()
496{ 529{
497 QStringList list; 530 QStringList list;
498 list << secrecyName(SecrecyPublic); 531 list << secrecyName(SecrecyPublic);
499 list << secrecyName(SecrecyPrivate); 532 list << secrecyName(SecrecyPrivate);
500 list << secrecyName(SecrecyConfidential); 533 list << secrecyName(SecrecyConfidential);
501 534
502 return list; 535 return list;
503} 536}
504 537
505 538
506QPtrList<Alarm> Incidence::alarms() const 539QPtrList<Alarm> Incidence::alarms() const
507{ 540{
508 return mAlarms; 541 return mAlarms;
509} 542}
510 543
511Alarm* Incidence::newAlarm() 544Alarm* Incidence::newAlarm()
512{ 545{
513 Alarm* alarm = new Alarm(this); 546 Alarm* alarm = new Alarm(this);
514 mAlarms.append(alarm); 547 mAlarms.append(alarm);
515// updated(); 548// updated();
516 return alarm; 549 return alarm;
517} 550}
518 551
519void Incidence::addAlarm(Alarm *alarm) 552void Incidence::addAlarm(Alarm *alarm)
520{ 553{
521 mAlarms.append(alarm); 554 mAlarms.append(alarm);
522 updated(); 555 updated();
523} 556}
524 557
525void Incidence::removeAlarm(Alarm *alarm) 558void Incidence::removeAlarm(Alarm *alarm)
526{ 559{
527 mAlarms.removeRef(alarm); 560 mAlarms.removeRef(alarm);
528 updated(); 561 updated();
529} 562}
530 563
531void Incidence::clearAlarms() 564void Incidence::clearAlarms()
532{ 565{
533 mAlarms.clear(); 566 mAlarms.clear();
534 updated(); 567 updated();
535} 568}
536 569
537bool Incidence::isAlarmEnabled() const 570bool Incidence::isAlarmEnabled() const
538{ 571{
539 Alarm* alarm; 572 Alarm* alarm;
540 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 573 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
541 if (alarm->enabled()) 574 if (alarm->enabled())
542 return true; 575 return true;
543 } 576 }
544 return false; 577 return false;
545} 578}
546 579
547Recurrence *Incidence::recurrence() const 580Recurrence *Incidence::recurrence() const
548{ 581{
549 return mRecurrence; 582 return mRecurrence;
550} 583}
551void Incidence::setRecurrence( Recurrence * r) 584void Incidence::setRecurrence( Recurrence * r)
552{ 585{
553 delete mRecurrence; 586 delete mRecurrence;
554 mRecurrence = r; 587 mRecurrence = r;
555} 588}
556 589