summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
authorzautrix <zautrix>2005-06-08 12:35:38 (UTC)
committer zautrix <zautrix>2005-06-08 12:35:38 (UTC)
commitd9e240cf1a88f4213c9169e9168d01b669613312 (patch) (unidiff)
treeed22cb872cc0f38625afe0f01036a48eb9b3edfa /libkcal/incidence.cpp
parent2448916479b456ca7c880427a80e8e32e95b2fba (diff)
downloadkdepimpi-d9e240cf1a88f4213c9169e9168d01b669613312.zip
kdepimpi-d9e240cf1a88f4213c9169e9168d01b669613312.tar.gz
kdepimpi-d9e240cf1a88f4213c9169e9168d01b669613312.tar.bz2
better export
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index f446197..4382416 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -261,384 +261,395 @@ void Incidence::recreate()
261 261
262 setRevision(0); 262 setRevision(0);
263 setIDStr( ":" ); 263 setIDStr( ":" );
264 setLastModified(QDateTime::currentDateTime()); 264 setLastModified(QDateTime::currentDateTime());
265} 265}
266void Incidence::cloneRelations( Incidence * newInc ) 266void Incidence::cloneRelations( Incidence * newInc )
267{ 267{
268 // newInc is already a clone of this incidence 268 // newInc is already a clone of this incidence
269 Incidence * inc; 269 Incidence * inc;
270 Incidence * cloneInc; 270 Incidence * cloneInc;
271 QPtrList<Incidence> Relations = relations(); 271 QPtrList<Incidence> Relations = relations();
272 for (inc=Relations.first();inc;inc=Relations.next()) { 272 for (inc=Relations.first();inc;inc=Relations.next()) {
273 cloneInc = inc->clone(); 273 cloneInc = inc->clone();
274 cloneInc->recreate(); 274 cloneInc->recreate();
275 cloneInc->setRelatedTo( newInc ); 275 cloneInc->setRelatedTo( newInc );
276 inc->cloneRelations( cloneInc ); 276 inc->cloneRelations( cloneInc );
277 } 277 }
278} 278}
279void Incidence::setReadOnly( bool readOnly ) 279void Incidence::setReadOnly( bool readOnly )
280{ 280{
281 IncidenceBase::setReadOnly( readOnly ); 281 IncidenceBase::setReadOnly( readOnly );
282 recurrence()->setRecurReadOnly( readOnly); 282 recurrence()->setRecurReadOnly( readOnly);
283} 283}
284 284
285void Incidence::setCreated(QDateTime created) 285void Incidence::setCreated(QDateTime created)
286{ 286{
287 if (mReadOnly) return; 287 if (mReadOnly) return;
288 mCreated = getEvenTime(created); 288 mCreated = getEvenTime(created);
289} 289}
290 290
291QDateTime Incidence::created() const 291QDateTime Incidence::created() const
292{ 292{
293 return mCreated; 293 return mCreated;
294} 294}
295 295
296void Incidence::setRevision(int rev) 296void Incidence::setRevision(int rev)
297{ 297{
298 if (mReadOnly) return; 298 if (mReadOnly) return;
299 mRevision = rev; 299 mRevision = rev;
300 300
301 updated(); 301 updated();
302} 302}
303 303
304int Incidence::revision() const 304int Incidence::revision() const
305{ 305{
306 return mRevision; 306 return mRevision;
307} 307}
308 308
309void Incidence::setDtStart(const QDateTime &dtStart) 309void Incidence::setDtStart(const QDateTime &dtStart)
310{ 310{
311 311
312 QDateTime dt = getEvenTime(dtStart); 312 QDateTime dt = getEvenTime(dtStart);
313 recurrence()->setRecurStart( dt); 313 recurrence()->setRecurStart( dt);
314 IncidenceBase::setDtStart( dt ); 314 IncidenceBase::setDtStart( dt );
315} 315}
316 316
317void Incidence::setDescription(const QString &description) 317void Incidence::setDescription(const QString &description)
318{ 318{
319 if (mReadOnly) return; 319 if (mReadOnly) return;
320 mDescription = description; 320 mDescription = description;
321 updated(); 321 updated();
322} 322}
323 323
324QString Incidence::description() const 324QString Incidence::description() const
325{ 325{
326 return mDescription; 326 return mDescription;
327} 327}
328 328
329 329
330void Incidence::setSummary(const QString &summary) 330void Incidence::setSummary(const QString &summary)
331{ 331{
332 if (mReadOnly) return; 332 if (mReadOnly) return;
333 mSummary = summary; 333 mSummary = summary;
334 updated(); 334 updated();
335} 335}
336 336
337QString Incidence::summary() const 337QString Incidence::summary() const
338{ 338{
339 return mSummary; 339 return mSummary;
340} 340}
341void Incidence::checkCategories() 341void Incidence::checkCategories()
342{ 342{
343 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 343 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
344 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 344 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
345 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 345 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
346} 346}
347 347
348void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 348void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
349{ 349{
350 if (mReadOnly) return; 350 if (mReadOnly) return;
351 int i; 351 int i;
352 for( i = 0; i < categories.count(); ++i ) { 352 for( i = 0; i < categories.count(); ++i ) {
353 if ( !mCategories.contains (categories[i])) 353 if ( !mCategories.contains (categories[i]))
354 mCategories.append( categories[i] ); 354 mCategories.append( categories[i] );
355 } 355 }
356 checkCategories(); 356 checkCategories();
357 updated(); 357 updated();
358 if ( addToRelations ) { 358 if ( addToRelations ) {
359 Incidence * inc; 359 Incidence * inc;
360 QPtrList<Incidence> Relations = relations(); 360 QPtrList<Incidence> Relations = relations();
361 for (inc=Relations.first();inc;inc=Relations.next()) { 361 for (inc=Relations.first();inc;inc=Relations.next()) {
362 inc->addCategories( categories, true ); 362 inc->addCategories( categories, true );
363 } 363 }
364 } 364 }
365} 365}
366 366
367void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 367void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
368{ 368{
369 if (mReadOnly) return; 369 if (mReadOnly) return;
370 mCategories = categories; 370 mCategories = categories;
371 checkCategories(); 371 checkCategories();
372 updated(); 372 updated();
373 if ( setForRelations ) { 373 if ( setForRelations ) {
374 Incidence * inc; 374 Incidence * inc;
375 QPtrList<Incidence> Relations = relations(); 375 QPtrList<Incidence> Relations = relations();
376 for (inc=Relations.first();inc;inc=Relations.next()) { 376 for (inc=Relations.first();inc;inc=Relations.next()) {
377 inc->setCategories( categories, true ); 377 inc->setCategories( categories, true );
378 } 378 }
379 } 379 }
380} 380}
381 381
382// TODO: remove setCategories(QString) function 382// TODO: remove setCategories(QString) function
383void Incidence::setCategories(const QString &catStr) 383void Incidence::setCategories(const QString &catStr)
384{ 384{
385 if (mReadOnly) return; 385 if (mReadOnly) return;
386 mCategories.clear(); 386 mCategories.clear();
387 387
388 if (catStr.isEmpty()) return; 388 if (catStr.isEmpty()) return;
389 389
390 mCategories = QStringList::split(",",catStr); 390 mCategories = QStringList::split(",",catStr);
391 391
392 QStringList::Iterator it; 392 QStringList::Iterator it;
393 for(it = mCategories.begin();it != mCategories.end(); ++it) { 393 for(it = mCategories.begin();it != mCategories.end(); ++it) {
394 *it = (*it).stripWhiteSpace(); 394 *it = (*it).stripWhiteSpace();
395 } 395 }
396 checkCategories(); 396 checkCategories();
397 updated(); 397 updated();
398} 398}
399 399
400QStringList Incidence::categories() const 400QStringList Incidence::categories() const
401{ 401{
402 return mCategories; 402 return mCategories;
403} 403}
404 404
405QString Incidence::categoriesStr() 405QString Incidence::categoriesStr()
406{ 406{
407 return mCategories.join(","); 407 return mCategories.join(",");
408} 408}
409QString Incidence::categoriesStrWithSpace() 409QString Incidence::categoriesStrWithSpace()
410{ 410{
411 return mCategories.join(", "); 411 return mCategories.join(", ");
412} 412}
413 413
414void Incidence::setRelatedToUid(const QString &relatedToUid) 414void Incidence::setRelatedToUid(const QString &relatedToUid)
415{ 415{
416 if (mReadOnly) return; 416 if (mReadOnly) return;
417 mRelatedToUid = relatedToUid; 417 mRelatedToUid = relatedToUid;
418} 418}
419 419
420QString Incidence::relatedToUid() const 420QString Incidence::relatedToUid() const
421{ 421{
422 return mRelatedToUid; 422 return mRelatedToUid;
423} 423}
424 424
425void Incidence::setRelatedTo(Incidence *relatedTo) 425void Incidence::setRelatedTo(Incidence *relatedTo)
426{ 426{
427 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 427 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
428 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 428 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
429 if (mReadOnly || mRelatedTo == relatedTo) return; 429 if (mReadOnly || mRelatedTo == relatedTo) return;
430 if(mRelatedTo) { 430 if(mRelatedTo) {
431 // updated(); 431 // updated();
432 mRelatedTo->removeRelation(this); 432 mRelatedTo->removeRelation(this);
433 } 433 }
434 mRelatedTo = relatedTo; 434 mRelatedTo = relatedTo;
435 if (mRelatedTo) { 435 if (mRelatedTo) {
436 mRelatedTo->addRelation(this); 436 mRelatedTo->addRelation(this);
437 mRelatedToUid = mRelatedTo->uid(); 437 mRelatedToUid = mRelatedTo->uid();
438 } else { 438 } else {
439 mRelatedToUid = ""; 439 mRelatedToUid = "";
440 } 440 }
441} 441}
442 442
443Incidence *Incidence::relatedTo() const 443Incidence *Incidence::relatedTo() const
444{ 444{
445 return mRelatedTo; 445 return mRelatedTo;
446} 446}
447 447
448QPtrList<Incidence> Incidence::relations() const 448QPtrList<Incidence> Incidence::relations() const
449{ 449{
450 return mRelations; 450 return mRelations;
451} 451}
452 452
453void Incidence::addRelationsToList(QPtrList<Incidence> *rel)
454{
455 Incidence* inc;
456 QPtrList<Incidence> Relations = relations();
457 for (inc=Relations.first();inc;inc=Relations.next()) {
458 inc->addRelationsToList( rel );
459 }
460 if ( rel->findRef( this ) == -1 )
461 rel->append( this );
462}
463
453void Incidence::addRelation(Incidence *event) 464void Incidence::addRelation(Incidence *event)
454{ 465{
455 if( mRelations.findRef( event ) == -1 ) { 466 if( mRelations.findRef( event ) == -1 ) {
456 mRelations.append(event); 467 mRelations.append(event);
457 //updated(); 468 //updated();
458 } 469 }
459} 470}
460 471
461void Incidence::removeRelation(Incidence *event) 472void Incidence::removeRelation(Incidence *event)
462{ 473{
463 474
464 mRelations.removeRef(event); 475 mRelations.removeRef(event);
465 476
466// if (event->getRelatedTo() == this) event->setRelatedTo(0); 477// if (event->getRelatedTo() == this) event->setRelatedTo(0);
467} 478}
468 479
469bool Incidence::recursOn(const QDate &qd) const 480bool Incidence::recursOn(const QDate &qd) const
470{ 481{
471 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; 482 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true;
472 else return false; 483 else return false;
473} 484}
474 485
475void Incidence::setExDates(const DateList &exDates) 486void Incidence::setExDates(const DateList &exDates)
476{ 487{
477 if (mReadOnly) return; 488 if (mReadOnly) return;
478 mExDates = exDates; 489 mExDates = exDates;
479 490
480 recurrence()->setRecurExDatesCount(mExDates.count()); 491 recurrence()->setRecurExDatesCount(mExDates.count());
481 492
482 updated(); 493 updated();
483} 494}
484 495
485void Incidence::addExDate(const QDate &date) 496void Incidence::addExDate(const QDate &date)
486{ 497{
487 if (mReadOnly) return; 498 if (mReadOnly) return;
488 mExDates.append(date); 499 mExDates.append(date);
489 500
490 recurrence()->setRecurExDatesCount(mExDates.count()); 501 recurrence()->setRecurExDatesCount(mExDates.count());
491 502
492 updated(); 503 updated();
493} 504}
494 505
495DateList Incidence::exDates() const 506DateList Incidence::exDates() const
496{ 507{
497 return mExDates; 508 return mExDates;
498} 509}
499 510
500bool Incidence::isException(const QDate &date) const 511bool Incidence::isException(const QDate &date) const
501{ 512{
502 DateList::ConstIterator it; 513 DateList::ConstIterator it;
503 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 514 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
504 if ( (*it) == date ) { 515 if ( (*it) == date ) {
505 return true; 516 return true;
506 } 517 }
507 } 518 }
508 519
509 return false; 520 return false;
510} 521}
511 522
512void Incidence::addAttachment(Attachment *attachment) 523void Incidence::addAttachment(Attachment *attachment)
513{ 524{
514 if (mReadOnly || !attachment) return; 525 if (mReadOnly || !attachment) return;
515 mAttachments.append(attachment); 526 mAttachments.append(attachment);
516 updated(); 527 updated();
517} 528}
518 529
519void Incidence::deleteAttachment(Attachment *attachment) 530void Incidence::deleteAttachment(Attachment *attachment)
520{ 531{
521 mAttachments.removeRef(attachment); 532 mAttachments.removeRef(attachment);
522} 533}
523 534
524void Incidence::deleteAttachments(const QString& mime) 535void Incidence::deleteAttachments(const QString& mime)
525{ 536{
526 Attachment *at = mAttachments.first(); 537 Attachment *at = mAttachments.first();
527 while (at) { 538 while (at) {
528 if (at->mimeType() == mime) 539 if (at->mimeType() == mime)
529 mAttachments.remove(); 540 mAttachments.remove();
530 else 541 else
531 at = mAttachments.next(); 542 at = mAttachments.next();
532 } 543 }
533} 544}
534 545
535QPtrList<Attachment> Incidence::attachments() const 546QPtrList<Attachment> Incidence::attachments() const
536{ 547{
537 return mAttachments; 548 return mAttachments;
538} 549}
539 550
540QPtrList<Attachment> Incidence::attachments(const QString& mime) const 551QPtrList<Attachment> Incidence::attachments(const QString& mime) const
541{ 552{
542 QPtrList<Attachment> attachments; 553 QPtrList<Attachment> attachments;
543 QPtrListIterator<Attachment> it( mAttachments ); 554 QPtrListIterator<Attachment> it( mAttachments );
544 Attachment *at; 555 Attachment *at;
545 while ( (at = it.current()) ) { 556 while ( (at = it.current()) ) {
546 if (at->mimeType() == mime) 557 if (at->mimeType() == mime)
547 attachments.append(at); 558 attachments.append(at);
548 ++it; 559 ++it;
549 } 560 }
550 561
551 return attachments; 562 return attachments;
552} 563}
553 564
554void Incidence::setResources(const QStringList &resources) 565void Incidence::setResources(const QStringList &resources)
555{ 566{
556 if (mReadOnly) return; 567 if (mReadOnly) return;
557 mResources = resources; 568 mResources = resources;
558 updated(); 569 updated();
559} 570}
560 571
561QStringList Incidence::resources() const 572QStringList Incidence::resources() const
562{ 573{
563 return mResources; 574 return mResources;
564} 575}
565 576
566 577
567void Incidence::setPriority(int priority) 578void Incidence::setPriority(int priority)
568{ 579{
569 if (mReadOnly) return; 580 if (mReadOnly) return;
570 mPriority = priority; 581 mPriority = priority;
571 updated(); 582 updated();
572} 583}
573 584
574int Incidence::priority() const 585int Incidence::priority() const
575{ 586{
576 return mPriority; 587 return mPriority;
577} 588}
578 589
579void Incidence::setSecrecy(int sec) 590void Incidence::setSecrecy(int sec)
580{ 591{
581 if (mReadOnly) return; 592 if (mReadOnly) return;
582 mSecrecy = sec; 593 mSecrecy = sec;
583 updated(); 594 updated();
584} 595}
585 596
586int Incidence::secrecy() const 597int Incidence::secrecy() const
587{ 598{
588 return mSecrecy; 599 return mSecrecy;
589} 600}
590 601
591QString Incidence::secrecyStr() const 602QString Incidence::secrecyStr() const
592{ 603{
593 return secrecyName(mSecrecy); 604 return secrecyName(mSecrecy);
594} 605}
595 606
596QString Incidence::secrecyName(int secrecy) 607QString Incidence::secrecyName(int secrecy)
597{ 608{
598 switch (secrecy) { 609 switch (secrecy) {
599 case SecrecyPublic: 610 case SecrecyPublic:
600 return i18n("Public"); 611 return i18n("Public");
601 break; 612 break;
602 case SecrecyPrivate: 613 case SecrecyPrivate:
603 return i18n("Private"); 614 return i18n("Private");
604 break; 615 break;
605 case SecrecyConfidential: 616 case SecrecyConfidential:
606 return i18n("Confidential"); 617 return i18n("Confidential");
607 break; 618 break;
608 default: 619 default:
609 return i18n("Undefined"); 620 return i18n("Undefined");
610 break; 621 break;
611 } 622 }
612} 623}
613 624
614QStringList Incidence::secrecyList() 625QStringList Incidence::secrecyList()
615{ 626{
616 QStringList list; 627 QStringList list;
617 list << secrecyName(SecrecyPublic); 628 list << secrecyName(SecrecyPublic);
618 list << secrecyName(SecrecyPrivate); 629 list << secrecyName(SecrecyPrivate);
619 list << secrecyName(SecrecyConfidential); 630 list << secrecyName(SecrecyConfidential);
620 631
621 return list; 632 return list;
622} 633}
623 634
624 635
625QPtrList<Alarm> Incidence::alarms() const 636QPtrList<Alarm> Incidence::alarms() const
626{ 637{
627 return mAlarms; 638 return mAlarms;
628} 639}
629 640
630Alarm* Incidence::newAlarm() 641Alarm* Incidence::newAlarm()
631{ 642{
632 Alarm* alarm = new Alarm(this); 643 Alarm* alarm = new Alarm(this);
633 mAlarms.append(alarm); 644 mAlarms.append(alarm);
634// updated(); 645// updated();
635 return alarm; 646 return alarm;
636} 647}
637 648
638void Incidence::addAlarm(Alarm *alarm) 649void Incidence::addAlarm(Alarm *alarm)
639{ 650{
640 mAlarms.append(alarm); 651 mAlarms.append(alarm);
641 updated(); 652 updated();
642} 653}
643 654
644void Incidence::removeAlarm(Alarm *alarm) 655void Incidence::removeAlarm(Alarm *alarm)