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
@@ -201,385 +201,390 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
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 ( type() == "Event") { 239 if ( type() == "Event") {
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}
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{
522 if (mReadOnly) return; 527 if (mReadOnly) return;
523 mPriority = priority; 528 mPriority = priority;
524 updated(); 529 updated();
525} 530}
526 531
527int Incidence::priority() const 532int Incidence::priority() const
528{ 533{
529 return mPriority; 534 return mPriority;
530} 535}
531 536
532void Incidence::setSecrecy(int sec) 537void Incidence::setSecrecy(int sec)
533{ 538{
534 if (mReadOnly) return; 539 if (mReadOnly) return;
535 mSecrecy = sec; 540 mSecrecy = sec;
536 updated(); 541 updated();
537} 542}
538 543
539int Incidence::secrecy() const 544int Incidence::secrecy() const
540{ 545{
541 return mSecrecy; 546 return mSecrecy;
542} 547}
543 548
544QString Incidence::secrecyStr() const 549QString Incidence::secrecyStr() const
545{ 550{
546 return secrecyName(mSecrecy); 551 return secrecyName(mSecrecy);
547} 552}
548 553
549QString Incidence::secrecyName(int secrecy) 554QString Incidence::secrecyName(int secrecy)
550{ 555{
551 switch (secrecy) { 556 switch (secrecy) {
552 case SecrecyPublic: 557 case SecrecyPublic:
553 return i18n("Public"); 558 return i18n("Public");
554 break; 559 break;
555 case SecrecyPrivate: 560 case SecrecyPrivate:
556 return i18n("Private"); 561 return i18n("Private");
557 break; 562 break;
558 case SecrecyConfidential: 563 case SecrecyConfidential:
559 return i18n("Confidential"); 564 return i18n("Confidential");
560 break; 565 break;
561 default: 566 default:
562 return i18n("Undefined"); 567 return i18n("Undefined");
563 break; 568 break;
564 } 569 }
565} 570}
566 571
567QStringList Incidence::secrecyList() 572QStringList Incidence::secrecyList()
568{ 573{
569 QStringList list; 574 QStringList list;
570 list << secrecyName(SecrecyPublic); 575 list << secrecyName(SecrecyPublic);
571 list << secrecyName(SecrecyPrivate); 576 list << secrecyName(SecrecyPrivate);
572 list << secrecyName(SecrecyConfidential); 577 list << secrecyName(SecrecyConfidential);
573 578
574 return list; 579 return list;
575} 580}
576 581
577 582
578QPtrList<Alarm> Incidence::alarms() const 583QPtrList<Alarm> Incidence::alarms() const
579{ 584{
580 return mAlarms; 585 return mAlarms;
581} 586}
582 587
583Alarm* Incidence::newAlarm() 588Alarm* Incidence::newAlarm()
584{ 589{
585 Alarm* alarm = new Alarm(this); 590 Alarm* alarm = new Alarm(this);