summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
Unidiff
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index a312ba5..6bca12c 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -265,257 +265,262 @@ void Incidence::recreate()
265} 265}
266 266
267void Incidence::setReadOnly( bool readOnly ) 267void Incidence::setReadOnly( bool readOnly )
268{ 268{
269 IncidenceBase::setReadOnly( readOnly ); 269 IncidenceBase::setReadOnly( readOnly );
270 recurrence()->setRecurReadOnly( readOnly); 270 recurrence()->setRecurReadOnly( readOnly);
271} 271}
272 272
273void Incidence::setCreated(QDateTime created) 273void Incidence::setCreated(QDateTime created)
274{ 274{
275 if (mReadOnly) return; 275 if (mReadOnly) return;
276 mCreated = getEvenTime(created); 276 mCreated = getEvenTime(created);
277} 277}
278 278
279QDateTime Incidence::created() const 279QDateTime Incidence::created() const
280{ 280{
281 return mCreated; 281 return mCreated;
282} 282}
283 283
284void Incidence::setRevision(int rev) 284void Incidence::setRevision(int rev)
285{ 285{
286 if (mReadOnly) return; 286 if (mReadOnly) return;
287 mRevision = rev; 287 mRevision = rev;
288 288
289 updated(); 289 updated();
290} 290}
291 291
292int Incidence::revision() const 292int Incidence::revision() const
293{ 293{
294 return mRevision; 294 return mRevision;
295} 295}
296 296
297void Incidence::setDtStart(const QDateTime &dtStart) 297void Incidence::setDtStart(const QDateTime &dtStart)
298{ 298{
299 299
300 QDateTime dt = getEvenTime(dtStart); 300 QDateTime dt = getEvenTime(dtStart);
301 recurrence()->setRecurStart( dt); 301 recurrence()->setRecurStart( dt);
302 IncidenceBase::setDtStart( dt ); 302 IncidenceBase::setDtStart( dt );
303} 303}
304 304
305void Incidence::setDescription(const QString &description) 305void Incidence::setDescription(const QString &description)
306{ 306{
307 if (mReadOnly) return; 307 if (mReadOnly) return;
308 mDescription = description; 308 mDescription = description;
309 updated(); 309 updated();
310} 310}
311 311
312QString Incidence::description() const 312QString Incidence::description() const
313{ 313{
314 return mDescription; 314 return mDescription;
315} 315}
316 316
317 317
318void Incidence::setSummary(const QString &summary) 318void Incidence::setSummary(const QString &summary)
319{ 319{
320 if (mReadOnly) return; 320 if (mReadOnly) return;
321 mSummary = summary; 321 mSummary = summary;
322 updated(); 322 updated();
323} 323}
324 324
325QString Incidence::summary() const 325QString Incidence::summary() const
326{ 326{
327 return mSummary; 327 return mSummary;
328} 328}
329void Incidence::checkCategories() 329void Incidence::checkCategories()
330{ 330{
331 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 331 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
332 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 332 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
333 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 333 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
334} 334}
335 335
336void Incidence::setCategories(const QStringList &categories) 336void Incidence::setCategories(const QStringList &categories)
337{ 337{
338 if (mReadOnly) return; 338 if (mReadOnly) return;
339 mCategories = categories; 339 mCategories = categories;
340 checkCategories(); 340 checkCategories();
341 updated(); 341 updated();
342} 342}
343 343
344// TODO: remove setCategories(QString) function 344// TODO: remove setCategories(QString) function
345void Incidence::setCategories(const QString &catStr) 345void Incidence::setCategories(const QString &catStr)
346{ 346{
347 if (mReadOnly) return; 347 if (mReadOnly) return;
348 mCategories.clear(); 348 mCategories.clear();
349 349
350 if (catStr.isEmpty()) return; 350 if (catStr.isEmpty()) return;
351 351
352 mCategories = QStringList::split(",",catStr); 352 mCategories = QStringList::split(",",catStr);
353 353
354 QStringList::Iterator it; 354 QStringList::Iterator it;
355 for(it = mCategories.begin();it != mCategories.end(); ++it) { 355 for(it = mCategories.begin();it != mCategories.end(); ++it) {
356 *it = (*it).stripWhiteSpace(); 356 *it = (*it).stripWhiteSpace();
357 } 357 }
358 checkCategories(); 358 checkCategories();
359 updated(); 359 updated();
360} 360}
361 361
362QStringList Incidence::categories() const 362QStringList Incidence::categories() const
363{ 363{
364 return mCategories; 364 return mCategories;
365} 365}
366 366
367QString Incidence::categoriesStr() 367QString Incidence::categoriesStr()
368{ 368{
369 return mCategories.join(","); 369 return mCategories.join(",");
370} 370}
371 371
372void Incidence::setRelatedToUid(const QString &relatedToUid) 372void Incidence::setRelatedToUid(const QString &relatedToUid)
373{ 373{
374 if (mReadOnly) return; 374 if (mReadOnly) return;
375 mRelatedToUid = relatedToUid; 375 mRelatedToUid = relatedToUid;
376} 376}
377 377
378QString Incidence::relatedToUid() const 378QString Incidence::relatedToUid() const
379{ 379{
380 return mRelatedToUid; 380 return mRelatedToUid;
381} 381}
382 382
383void Incidence::setRelatedTo(Incidence *relatedTo) 383void Incidence::setRelatedTo(Incidence *relatedTo)
384{ 384{
385 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 385 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
386 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 386 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
387 if (mReadOnly || mRelatedTo == relatedTo) return; 387 if (mReadOnly || mRelatedTo == relatedTo) return;
388 if(mRelatedTo) { 388 if(mRelatedTo) {
389 // updated(); 389 // updated();
390 mRelatedTo->removeRelation(this); 390 mRelatedTo->removeRelation(this);
391 } 391 }
392 mRelatedTo = relatedTo; 392 mRelatedTo = relatedTo;
393 if (mRelatedTo) mRelatedTo->addRelation(this); 393 if (mRelatedTo) {
394 mRelatedTo->addRelation(this);
395 mRelatedToUid = mRelatedTo->uid();
396 } else {
397 mRelatedToUid = "";
398 }
394} 399}
395 400
396Incidence *Incidence::relatedTo() const 401Incidence *Incidence::relatedTo() const
397{ 402{
398 return mRelatedTo; 403 return mRelatedTo;
399} 404}
400 405
401QPtrList<Incidence> Incidence::relations() const 406QPtrList<Incidence> Incidence::relations() const
402{ 407{
403 return mRelations; 408 return mRelations;
404} 409}
405 410
406void Incidence::addRelation(Incidence *event) 411void Incidence::addRelation(Incidence *event)
407{ 412{
408 if( mRelations.findRef( event ) == -1 ) { 413 if( mRelations.findRef( event ) == -1 ) {
409 mRelations.append(event); 414 mRelations.append(event);
410 //updated(); 415 //updated();
411 } 416 }
412} 417}
413 418
414void Incidence::removeRelation(Incidence *event) 419void Incidence::removeRelation(Incidence *event)
415{ 420{
416 421
417 mRelations.removeRef(event); 422 mRelations.removeRef(event);
418 423
419// if (event->getRelatedTo() == this) event->setRelatedTo(0); 424// if (event->getRelatedTo() == this) event->setRelatedTo(0);
420} 425}
421 426
422bool Incidence::recursOn(const QDate &qd) const 427bool Incidence::recursOn(const QDate &qd) const
423{ 428{
424 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; 429 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true;
425 else return false; 430 else return false;
426} 431}
427 432
428void Incidence::setExDates(const DateList &exDates) 433void Incidence::setExDates(const DateList &exDates)
429{ 434{
430 if (mReadOnly) return; 435 if (mReadOnly) return;
431 mExDates = exDates; 436 mExDates = exDates;
432 437
433 recurrence()->setRecurExDatesCount(mExDates.count()); 438 recurrence()->setRecurExDatesCount(mExDates.count());
434 439
435 updated(); 440 updated();
436} 441}
437 442
438void Incidence::addExDate(const QDate &date) 443void Incidence::addExDate(const QDate &date)
439{ 444{
440 if (mReadOnly) return; 445 if (mReadOnly) return;
441 mExDates.append(date); 446 mExDates.append(date);
442 447
443 recurrence()->setRecurExDatesCount(mExDates.count()); 448 recurrence()->setRecurExDatesCount(mExDates.count());
444 449
445 updated(); 450 updated();
446} 451}
447 452
448DateList Incidence::exDates() const 453DateList Incidence::exDates() const
449{ 454{
450 return mExDates; 455 return mExDates;
451} 456}
452 457
453bool Incidence::isException(const QDate &date) const 458bool Incidence::isException(const QDate &date) const
454{ 459{
455 DateList::ConstIterator it; 460 DateList::ConstIterator it;
456 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 461 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
457 if ( (*it) == date ) { 462 if ( (*it) == date ) {
458 return true; 463 return true;
459 } 464 }
460 } 465 }
461 466
462 return false; 467 return false;
463} 468}
464 469
465void Incidence::addAttachment(Attachment *attachment) 470void Incidence::addAttachment(Attachment *attachment)
466{ 471{
467 if (mReadOnly || !attachment) return; 472 if (mReadOnly || !attachment) return;
468 mAttachments.append(attachment); 473 mAttachments.append(attachment);
469 updated(); 474 updated();
470} 475}
471 476
472void Incidence::deleteAttachment(Attachment *attachment) 477void Incidence::deleteAttachment(Attachment *attachment)
473{ 478{
474 mAttachments.removeRef(attachment); 479 mAttachments.removeRef(attachment);
475} 480}
476 481
477void Incidence::deleteAttachments(const QString& mime) 482void Incidence::deleteAttachments(const QString& mime)
478{ 483{
479 Attachment *at = mAttachments.first(); 484 Attachment *at = mAttachments.first();
480 while (at) { 485 while (at) {
481 if (at->mimeType() == mime) 486 if (at->mimeType() == mime)
482 mAttachments.remove(); 487 mAttachments.remove();
483 else 488 else
484 at = mAttachments.next(); 489 at = mAttachments.next();
485 } 490 }
486} 491}
487 492
488QPtrList<Attachment> Incidence::attachments() const 493QPtrList<Attachment> Incidence::attachments() const
489{ 494{
490 return mAttachments; 495 return mAttachments;
491} 496}
492 497
493QPtrList<Attachment> Incidence::attachments(const QString& mime) const 498QPtrList<Attachment> Incidence::attachments(const QString& mime) const
494{ 499{
495 QPtrList<Attachment> attachments; 500 QPtrList<Attachment> attachments;
496 QPtrListIterator<Attachment> it( mAttachments ); 501 QPtrListIterator<Attachment> it( mAttachments );
497 Attachment *at; 502 Attachment *at;
498 while ( (at = it.current()) ) { 503 while ( (at = it.current()) ) {
499 if (at->mimeType() == mime) 504 if (at->mimeType() == mime)
500 attachments.append(at); 505 attachments.append(at);
501 ++it; 506 ++it;
502 } 507 }
503 508
504 return attachments; 509 return attachments;
505} 510}
506 511
507void Incidence::setResources(const QStringList &resources) 512void Incidence::setResources(const QStringList &resources)
508{ 513{
509 if (mReadOnly) return; 514 if (mReadOnly) return;
510 mResources = resources; 515 mResources = resources;
511 updated(); 516 updated();
512} 517}
513 518
514QStringList Incidence::resources() const 519QStringList Incidence::resources() const
515{ 520{
516 return mResources; 521 return mResources;
517} 522}
518 523
519 524
520void Incidence::setPriority(int priority) 525void Incidence::setPriority(int priority)
521{ 526{