-rw-r--r-- | libkcal/incidence.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 11f7ecc..e4bcc5e 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -188,390 +188,410 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | |||
188 | } | 188 | } |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
192 | if ( i1.hasRecurrenceID() ) { | 192 | if ( i1.hasRecurrenceID() ) { |
193 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 193 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
194 | return false; | 194 | return false; |
195 | } | 195 | } |
196 | 196 | ||
197 | } else { | 197 | } else { |
198 | return false; | 198 | return false; |
199 | } | 199 | } |
200 | 200 | ||
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 | ||
232 | Incidence* Incidence::recreateCloneException( QDate d ) | 232 | Incidence* 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 ( typeID() == eventID ) { | 239 | if ( typeID() == eventID ) { |
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 | ||
256 | void Incidence::recreate() | 256 | void 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 | void Incidence::cloneRelations( Incidence * newInc ) | 266 | void 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 | } |
279 | void Incidence::setReadOnly( bool readOnly ) | 279 | void 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 | void Incidence::setLastModifiedSubInvalid() | |
285 | { | ||
286 | mLastModifiedSub = QDateTime(); | ||
287 | if ( mRelatedTo ) | ||
288 | mRelatedTo->setLastModifiedSubInvalid(); | ||
289 | } | ||
290 | QDateTime Incidence::lastModifiedSub() | ||
291 | { | ||
292 | if ( !mRelations.count() ) | ||
293 | return lastModified(); | ||
294 | if ( mLastModifiedSub.isValid() ) | ||
295 | return mLastModifiedSub; | ||
296 | mLastModifiedSub = lastModified(); | ||
297 | Incidence * inc; | ||
298 | QPtrList<Incidence> Relations = relations(); | ||
299 | for (inc=Relations.first();inc;inc=Relations.next()) { | ||
300 | if ( inc->lastModifiedSub() > mLastModifiedSub ) | ||
301 | mLastModifiedSub = inc->lastModifiedSub(); | ||
302 | } | ||
303 | return mLastModifiedSub; | ||
304 | } | ||
285 | void Incidence::setCreated(QDateTime created) | 305 | void Incidence::setCreated(QDateTime created) |
286 | { | 306 | { |
287 | if (mReadOnly) return; | 307 | if (mReadOnly) return; |
288 | mCreated = getEvenTime(created); | 308 | mCreated = getEvenTime(created); |
289 | } | 309 | } |
290 | 310 | ||
291 | QDateTime Incidence::created() const | 311 | QDateTime Incidence::created() const |
292 | { | 312 | { |
293 | return mCreated; | 313 | return mCreated; |
294 | } | 314 | } |
295 | 315 | ||
296 | void Incidence::setRevision(int rev) | 316 | void Incidence::setRevision(int rev) |
297 | { | 317 | { |
298 | if (mReadOnly) return; | 318 | if (mReadOnly) return; |
299 | mRevision = rev; | 319 | mRevision = rev; |
300 | 320 | ||
301 | updated(); | 321 | updated(); |
302 | } | 322 | } |
303 | 323 | ||
304 | int Incidence::revision() const | 324 | int Incidence::revision() const |
305 | { | 325 | { |
306 | return mRevision; | 326 | return mRevision; |
307 | } | 327 | } |
308 | 328 | ||
309 | void Incidence::setDtStart(const QDateTime &dtStart) | 329 | void Incidence::setDtStart(const QDateTime &dtStart) |
310 | { | 330 | { |
311 | 331 | ||
312 | QDateTime dt = getEvenTime(dtStart); | 332 | QDateTime dt = getEvenTime(dtStart); |
313 | recurrence()->setRecurStart( dt); | 333 | recurrence()->setRecurStart( dt); |
314 | IncidenceBase::setDtStart( dt ); | 334 | IncidenceBase::setDtStart( dt ); |
315 | } | 335 | } |
316 | 336 | ||
317 | void Incidence::setDescription(const QString &description) | 337 | void Incidence::setDescription(const QString &description) |
318 | { | 338 | { |
319 | if (mReadOnly) return; | 339 | if (mReadOnly) return; |
320 | mDescription = description; | 340 | mDescription = description; |
321 | updated(); | 341 | updated(); |
322 | } | 342 | } |
323 | 343 | ||
324 | QString Incidence::description() const | 344 | QString Incidence::description() const |
325 | { | 345 | { |
326 | return mDescription; | 346 | return mDescription; |
327 | } | 347 | } |
328 | 348 | ||
329 | 349 | ||
330 | void Incidence::setSummary(const QString &summary) | 350 | void Incidence::setSummary(const QString &summary) |
331 | { | 351 | { |
332 | if (mReadOnly) return; | 352 | if (mReadOnly) return; |
333 | mSummary = summary; | 353 | mSummary = summary; |
334 | updated(); | 354 | updated(); |
335 | } | 355 | } |
336 | 356 | ||
337 | QString Incidence::summary() const | 357 | QString Incidence::summary() const |
338 | { | 358 | { |
339 | return mSummary; | 359 | return mSummary; |
340 | } | 360 | } |
341 | void Incidence::checkCategories() | 361 | void Incidence::checkCategories() |
342 | { | 362 | { |
343 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 363 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
344 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 364 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
345 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 365 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
346 | } | 366 | } |
347 | 367 | ||
348 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false | 368 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false |
349 | { | 369 | { |
350 | if (mReadOnly) return; | 370 | if (mReadOnly) return; |
351 | int i; | 371 | int i; |
352 | for( i = 0; i < categories.count(); ++i ) { | 372 | for( i = 0; i < categories.count(); ++i ) { |
353 | if ( !mCategories.contains (categories[i])) | 373 | if ( !mCategories.contains (categories[i])) |
354 | mCategories.append( categories[i] ); | 374 | mCategories.append( categories[i] ); |
355 | } | 375 | } |
356 | checkCategories(); | 376 | checkCategories(); |
357 | updated(); | 377 | updated(); |
358 | if ( addToRelations ) { | 378 | if ( addToRelations ) { |
359 | Incidence * inc; | 379 | Incidence * inc; |
360 | QPtrList<Incidence> Relations = relations(); | 380 | QPtrList<Incidence> Relations = relations(); |
361 | for (inc=Relations.first();inc;inc=Relations.next()) { | 381 | for (inc=Relations.first();inc;inc=Relations.next()) { |
362 | inc->addCategories( categories, true ); | 382 | inc->addCategories( categories, true ); |
363 | } | 383 | } |
364 | } | 384 | } |
365 | } | 385 | } |
366 | 386 | ||
367 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false | 387 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false |
368 | { | 388 | { |
369 | if (mReadOnly) return; | 389 | if (mReadOnly) return; |
370 | mCategories = categories; | 390 | mCategories = categories; |
371 | checkCategories(); | 391 | checkCategories(); |
372 | updated(); | 392 | updated(); |
373 | if ( setForRelations ) { | 393 | if ( setForRelations ) { |
374 | Incidence * inc; | 394 | Incidence * inc; |
375 | QPtrList<Incidence> Relations = relations(); | 395 | QPtrList<Incidence> Relations = relations(); |
376 | for (inc=Relations.first();inc;inc=Relations.next()) { | 396 | for (inc=Relations.first();inc;inc=Relations.next()) { |
377 | inc->setCategories( categories, true ); | 397 | inc->setCategories( categories, true ); |
378 | } | 398 | } |
379 | } | 399 | } |
380 | } | 400 | } |
381 | 401 | ||
382 | // TODO: remove setCategories(QString) function | 402 | // TODO: remove setCategories(QString) function |
383 | void Incidence::setCategories(const QString &catStr) | 403 | void Incidence::setCategories(const QString &catStr) |
384 | { | 404 | { |
385 | if (mReadOnly) return; | 405 | if (mReadOnly) return; |
386 | mCategories.clear(); | 406 | mCategories.clear(); |
387 | 407 | ||
388 | if (catStr.isEmpty()) return; | 408 | if (catStr.isEmpty()) return; |
389 | 409 | ||
390 | mCategories = QStringList::split(",",catStr); | 410 | mCategories = QStringList::split(",",catStr); |
391 | 411 | ||
392 | QStringList::Iterator it; | 412 | QStringList::Iterator it; |
393 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 413 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
394 | *it = (*it).stripWhiteSpace(); | 414 | *it = (*it).stripWhiteSpace(); |
395 | } | 415 | } |
396 | checkCategories(); | 416 | checkCategories(); |
397 | updated(); | 417 | updated(); |
398 | } | 418 | } |
399 | // using this makes filtering 3 times faster | 419 | // using this makes filtering 3 times faster |
400 | QStringList* Incidence::categoriesP() | 420 | QStringList* Incidence::categoriesP() |
401 | { | 421 | { |
402 | return &mCategories; | 422 | return &mCategories; |
403 | } | 423 | } |
404 | 424 | ||
405 | QStringList Incidence::categories() const | 425 | QStringList Incidence::categories() const |
406 | { | 426 | { |
407 | return mCategories; | 427 | return mCategories; |
408 | } | 428 | } |
409 | 429 | ||
410 | QString Incidence::categoriesStr() | 430 | QString Incidence::categoriesStr() |
411 | { | 431 | { |
412 | return mCategories.join(","); | 432 | return mCategories.join(","); |
413 | } | 433 | } |
414 | QString Incidence::categoriesStrWithSpace() | 434 | QString Incidence::categoriesStrWithSpace() |
415 | { | 435 | { |
416 | return mCategories.join(", "); | 436 | return mCategories.join(", "); |
417 | } | 437 | } |
418 | 438 | ||
419 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 439 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
420 | { | 440 | { |
421 | if (mReadOnly) return; | 441 | if (mReadOnly) return; |
422 | mRelatedToUid = relatedToUid; | 442 | mRelatedToUid = relatedToUid; |
423 | } | 443 | } |
424 | 444 | ||
425 | QString Incidence::relatedToUid() const | 445 | QString Incidence::relatedToUid() const |
426 | { | 446 | { |
427 | return mRelatedToUid; | 447 | return mRelatedToUid; |
428 | } | 448 | } |
429 | 449 | ||
430 | void Incidence::setRelatedTo(Incidence *relatedTo) | 450 | void Incidence::setRelatedTo(Incidence *relatedTo) |
431 | { | 451 | { |
432 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 452 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
433 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 453 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
434 | if (mReadOnly || mRelatedTo == relatedTo) return; | 454 | if (mReadOnly || mRelatedTo == relatedTo) return; |
435 | if(mRelatedTo) { | 455 | if(mRelatedTo) { |
436 | // updated(); | 456 | // updated(); |
437 | mRelatedTo->removeRelation(this); | 457 | mRelatedTo->removeRelation(this); |
438 | } | 458 | } |
439 | mRelatedTo = relatedTo; | 459 | mRelatedTo = relatedTo; |
440 | if (mRelatedTo) { | 460 | if (mRelatedTo) { |
441 | mRelatedTo->addRelation(this); | 461 | mRelatedTo->addRelation(this); |
442 | mRelatedToUid = mRelatedTo->uid(); | 462 | mRelatedToUid = mRelatedTo->uid(); |
443 | } else { | 463 | } else { |
444 | mRelatedToUid = ""; | 464 | mRelatedToUid = ""; |
445 | } | 465 | } |
446 | } | 466 | } |
447 | 467 | ||
448 | Incidence *Incidence::relatedTo() const | 468 | Incidence *Incidence::relatedTo() const |
449 | { | 469 | { |
450 | return mRelatedTo; | 470 | return mRelatedTo; |
451 | } | 471 | } |
452 | 472 | ||
453 | QPtrList<Incidence> Incidence::relations() const | 473 | QPtrList<Incidence> Incidence::relations() const |
454 | { | 474 | { |
455 | return mRelations; | 475 | return mRelations; |
456 | } | 476 | } |
457 | 477 | ||
458 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) | 478 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) |
459 | { | 479 | { |
460 | Incidence* inc; | 480 | Incidence* inc; |
461 | QPtrList<Incidence> Relations = relations(); | 481 | QPtrList<Incidence> Relations = relations(); |
462 | for (inc=Relations.first();inc;inc=Relations.next()) { | 482 | for (inc=Relations.first();inc;inc=Relations.next()) { |
463 | inc->addRelationsToList( rel ); | 483 | inc->addRelationsToList( rel ); |
464 | } | 484 | } |
465 | if ( rel->findRef( this ) == -1 ) | 485 | if ( rel->findRef( this ) == -1 ) |
466 | rel->append( this ); | 486 | rel->append( this ); |
467 | } | 487 | } |
468 | 488 | ||
469 | void Incidence::addRelation(Incidence *event) | 489 | void Incidence::addRelation(Incidence *event) |
470 | { | 490 | { |
491 | setLastModifiedSubInvalid(); | ||
471 | if( mRelations.findRef( event ) == -1 ) { | 492 | if( mRelations.findRef( event ) == -1 ) { |
472 | mRelations.append(event); | 493 | mRelations.append(event); |
473 | //updated(); | 494 | //updated(); |
474 | } | 495 | } |
475 | } | 496 | } |
476 | 497 | ||
477 | void Incidence::removeRelation(Incidence *event) | 498 | void Incidence::removeRelation(Incidence *event) |
478 | { | 499 | { |
479 | 500 | setLastModifiedSubInvalid(); | |
480 | mRelations.removeRef(event); | 501 | mRelations.removeRef(event); |
481 | |||
482 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 502 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
483 | } | 503 | } |
484 | 504 | ||
485 | bool Incidence::recursOn(const QDate &qd) const | 505 | bool Incidence::recursOn(const QDate &qd) const |
486 | { | 506 | { |
487 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 507 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
488 | else return false; | 508 | else return false; |
489 | } | 509 | } |
490 | 510 | ||
491 | void Incidence::setExDates(const DateList &exDates) | 511 | void Incidence::setExDates(const DateList &exDates) |
492 | { | 512 | { |
493 | if (mReadOnly) return; | 513 | if (mReadOnly) return; |
494 | mExDates = exDates; | 514 | mExDates = exDates; |
495 | 515 | ||
496 | recurrence()->setRecurExDatesCount(mExDates.count()); | 516 | recurrence()->setRecurExDatesCount(mExDates.count()); |
497 | 517 | ||
498 | updated(); | 518 | updated(); |
499 | } | 519 | } |
500 | 520 | ||
501 | void Incidence::addExDate(const QDate &date) | 521 | void Incidence::addExDate(const QDate &date) |
502 | { | 522 | { |
503 | if (mReadOnly) return; | 523 | if (mReadOnly) return; |
504 | mExDates.append(date); | 524 | mExDates.append(date); |
505 | 525 | ||
506 | recurrence()->setRecurExDatesCount(mExDates.count()); | 526 | recurrence()->setRecurExDatesCount(mExDates.count()); |
507 | 527 | ||
508 | updated(); | 528 | updated(); |
509 | } | 529 | } |
510 | 530 | ||
511 | DateList Incidence::exDates() const | 531 | DateList Incidence::exDates() const |
512 | { | 532 | { |
513 | return mExDates; | 533 | return mExDates; |
514 | } | 534 | } |
515 | 535 | ||
516 | bool Incidence::isException(const QDate &date) const | 536 | bool Incidence::isException(const QDate &date) const |
517 | { | 537 | { |
518 | DateList::ConstIterator it; | 538 | DateList::ConstIterator it; |
519 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 539 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
520 | if ( (*it) == date ) { | 540 | if ( (*it) == date ) { |
521 | return true; | 541 | return true; |
522 | } | 542 | } |
523 | } | 543 | } |
524 | 544 | ||
525 | return false; | 545 | return false; |
526 | } | 546 | } |
527 | 547 | ||
528 | void Incidence::addAttachment(Attachment *attachment) | 548 | void Incidence::addAttachment(Attachment *attachment) |
529 | { | 549 | { |
530 | if (mReadOnly || !attachment) return; | 550 | if (mReadOnly || !attachment) return; |
531 | mAttachments.append(attachment); | 551 | mAttachments.append(attachment); |
532 | updated(); | 552 | updated(); |
533 | } | 553 | } |
534 | 554 | ||
535 | void Incidence::deleteAttachment(Attachment *attachment) | 555 | void Incidence::deleteAttachment(Attachment *attachment) |
536 | { | 556 | { |
537 | mAttachments.removeRef(attachment); | 557 | mAttachments.removeRef(attachment); |
538 | } | 558 | } |
539 | 559 | ||
540 | void Incidence::deleteAttachments(const QString& mime) | 560 | void Incidence::deleteAttachments(const QString& mime) |
541 | { | 561 | { |
542 | Attachment *at = mAttachments.first(); | 562 | Attachment *at = mAttachments.first(); |
543 | while (at) { | 563 | while (at) { |
544 | if (at->mimeType() == mime) | 564 | if (at->mimeType() == mime) |
545 | mAttachments.remove(); | 565 | mAttachments.remove(); |
546 | else | 566 | else |
547 | at = mAttachments.next(); | 567 | at = mAttachments.next(); |
548 | } | 568 | } |
549 | } | 569 | } |
550 | 570 | ||
551 | QPtrList<Attachment> Incidence::attachments() const | 571 | QPtrList<Attachment> Incidence::attachments() const |
552 | { | 572 | { |
553 | return mAttachments; | 573 | return mAttachments; |
554 | } | 574 | } |
555 | 575 | ||
556 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 576 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
557 | { | 577 | { |
558 | QPtrList<Attachment> attachments; | 578 | QPtrList<Attachment> attachments; |
559 | QPtrListIterator<Attachment> it( mAttachments ); | 579 | QPtrListIterator<Attachment> it( mAttachments ); |
560 | Attachment *at; | 580 | Attachment *at; |
561 | while ( (at = it.current()) ) { | 581 | while ( (at = it.current()) ) { |
562 | if (at->mimeType() == mime) | 582 | if (at->mimeType() == mime) |
563 | attachments.append(at); | 583 | attachments.append(at); |
564 | ++it; | 584 | ++it; |
565 | } | 585 | } |
566 | 586 | ||
567 | return attachments; | 587 | return attachments; |
568 | } | 588 | } |
569 | 589 | ||
570 | void Incidence::setResources(const QStringList &resources) | 590 | void Incidence::setResources(const QStringList &resources) |
571 | { | 591 | { |
572 | if (mReadOnly) return; | 592 | if (mReadOnly) return; |
573 | mResources = resources; | 593 | mResources = resources; |
574 | updated(); | 594 | updated(); |
575 | } | 595 | } |
576 | 596 | ||
577 | QStringList Incidence::resources() const | 597 | QStringList Incidence::resources() const |