-rw-r--r-- | libkcal/incidence.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 4382416..11f7ecc 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -303,192 +303,197 @@ void Incidence::setRevision(int rev) | |||
303 | 303 | ||
304 | int Incidence::revision() const | 304 | int Incidence::revision() const |
305 | { | 305 | { |
306 | return mRevision; | 306 | return mRevision; |
307 | } | 307 | } |
308 | 308 | ||
309 | void Incidence::setDtStart(const QDateTime &dtStart) | 309 | void 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 | ||
317 | void Incidence::setDescription(const QString &description) | 317 | void 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 | ||
324 | QString Incidence::description() const | 324 | QString Incidence::description() const |
325 | { | 325 | { |
326 | return mDescription; | 326 | return mDescription; |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | void Incidence::setSummary(const QString &summary) | 330 | void 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 | ||
337 | QString Incidence::summary() const | 337 | QString Incidence::summary() const |
338 | { | 338 | { |
339 | return mSummary; | 339 | return mSummary; |
340 | } | 340 | } |
341 | void Incidence::checkCategories() | 341 | void 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 | ||
348 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false | 348 | void 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 | ||
367 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false | 367 | void 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 |
383 | void Incidence::setCategories(const QString &catStr) | 383 | void 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 | // using this makes filtering 3 times faster | ||
400 | QStringList* Incidence::categoriesP() | ||
401 | { | ||
402 | return &mCategories; | ||
403 | } | ||
399 | 404 | ||
400 | QStringList Incidence::categories() const | 405 | QStringList Incidence::categories() const |
401 | { | 406 | { |
402 | return mCategories; | 407 | return mCategories; |
403 | } | 408 | } |
404 | 409 | ||
405 | QString Incidence::categoriesStr() | 410 | QString Incidence::categoriesStr() |
406 | { | 411 | { |
407 | return mCategories.join(","); | 412 | return mCategories.join(","); |
408 | } | 413 | } |
409 | QString Incidence::categoriesStrWithSpace() | 414 | QString Incidence::categoriesStrWithSpace() |
410 | { | 415 | { |
411 | return mCategories.join(", "); | 416 | return mCategories.join(", "); |
412 | } | 417 | } |
413 | 418 | ||
414 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 419 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
415 | { | 420 | { |
416 | if (mReadOnly) return; | 421 | if (mReadOnly) return; |
417 | mRelatedToUid = relatedToUid; | 422 | mRelatedToUid = relatedToUid; |
418 | } | 423 | } |
419 | 424 | ||
420 | QString Incidence::relatedToUid() const | 425 | QString Incidence::relatedToUid() const |
421 | { | 426 | { |
422 | return mRelatedToUid; | 427 | return mRelatedToUid; |
423 | } | 428 | } |
424 | 429 | ||
425 | void Incidence::setRelatedTo(Incidence *relatedTo) | 430 | void Incidence::setRelatedTo(Incidence *relatedTo) |
426 | { | 431 | { |
427 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 432 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
428 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 433 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
429 | if (mReadOnly || mRelatedTo == relatedTo) return; | 434 | if (mReadOnly || mRelatedTo == relatedTo) return; |
430 | if(mRelatedTo) { | 435 | if(mRelatedTo) { |
431 | // updated(); | 436 | // updated(); |
432 | mRelatedTo->removeRelation(this); | 437 | mRelatedTo->removeRelation(this); |
433 | } | 438 | } |
434 | mRelatedTo = relatedTo; | 439 | mRelatedTo = relatedTo; |
435 | if (mRelatedTo) { | 440 | if (mRelatedTo) { |
436 | mRelatedTo->addRelation(this); | 441 | mRelatedTo->addRelation(this); |
437 | mRelatedToUid = mRelatedTo->uid(); | 442 | mRelatedToUid = mRelatedTo->uid(); |
438 | } else { | 443 | } else { |
439 | mRelatedToUid = ""; | 444 | mRelatedToUid = ""; |
440 | } | 445 | } |
441 | } | 446 | } |
442 | 447 | ||
443 | Incidence *Incidence::relatedTo() const | 448 | Incidence *Incidence::relatedTo() const |
444 | { | 449 | { |
445 | return mRelatedTo; | 450 | return mRelatedTo; |
446 | } | 451 | } |
447 | 452 | ||
448 | QPtrList<Incidence> Incidence::relations() const | 453 | QPtrList<Incidence> Incidence::relations() const |
449 | { | 454 | { |
450 | return mRelations; | 455 | return mRelations; |
451 | } | 456 | } |
452 | 457 | ||
453 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) | 458 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) |
454 | { | 459 | { |
455 | Incidence* inc; | 460 | Incidence* inc; |
456 | QPtrList<Incidence> Relations = relations(); | 461 | QPtrList<Incidence> Relations = relations(); |
457 | for (inc=Relations.first();inc;inc=Relations.next()) { | 462 | for (inc=Relations.first();inc;inc=Relations.next()) { |
458 | inc->addRelationsToList( rel ); | 463 | inc->addRelationsToList( rel ); |
459 | } | 464 | } |
460 | if ( rel->findRef( this ) == -1 ) | 465 | if ( rel->findRef( this ) == -1 ) |
461 | rel->append( this ); | 466 | rel->append( this ); |
462 | } | 467 | } |
463 | 468 | ||
464 | void Incidence::addRelation(Incidence *event) | 469 | void Incidence::addRelation(Incidence *event) |
465 | { | 470 | { |
466 | if( mRelations.findRef( event ) == -1 ) { | 471 | if( mRelations.findRef( event ) == -1 ) { |
467 | mRelations.append(event); | 472 | mRelations.append(event); |
468 | //updated(); | 473 | //updated(); |
469 | } | 474 | } |
470 | } | 475 | } |
471 | 476 | ||
472 | void Incidence::removeRelation(Incidence *event) | 477 | void Incidence::removeRelation(Incidence *event) |
473 | { | 478 | { |
474 | 479 | ||
475 | mRelations.removeRef(event); | 480 | mRelations.removeRef(event); |
476 | 481 | ||
477 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 482 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
478 | } | 483 | } |
479 | 484 | ||
480 | bool Incidence::recursOn(const QDate &qd) const | 485 | bool Incidence::recursOn(const QDate &qd) const |
481 | { | 486 | { |
482 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 487 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
483 | else return false; | 488 | else return false; |
484 | } | 489 | } |
485 | 490 | ||
486 | void Incidence::setExDates(const DateList &exDates) | 491 | void Incidence::setExDates(const DateList &exDates) |
487 | { | 492 | { |
488 | if (mReadOnly) return; | 493 | if (mReadOnly) return; |
489 | mExDates = exDates; | 494 | mExDates = exDates; |
490 | 495 | ||
491 | recurrence()->setRecurExDatesCount(mExDates.count()); | 496 | recurrence()->setRecurExDatesCount(mExDates.count()); |
492 | 497 | ||
493 | updated(); | 498 | updated(); |
494 | } | 499 | } |