45 #include <QtCore/QStringList>
47 using namespace KCalCore;
54 class KCalCore::IncidenceBase::Private
58 : mOrganizer( new
Person() ),
59 mUpdateGroupLevel( 0 ),
60 mUpdatedPending( false ),
65 Private(
const Private &other )
66 : mUpdateGroupLevel( 0 ),
67 mUpdatedPending( false ),
78 void init(
const Private &other );
80 KDateTime mLastModified;
85 int mUpdateGroupLevel;
90 QStringList mComments;
91 QStringList mContacts;
92 QList<IncidenceObserver*> mObservers;
93 QSet<Field> mDirtyFields;
97 void IncidenceBase::Private::init(
const Private &other )
99 mLastModified = other.mLastModified;
100 mDtStart = other.mDtStart;
101 mOrganizer = other.mOrganizer;
103 mDuration = other.mDuration;
104 mAllDay = other.mAllDay;
105 mHasDuration = other.mHasDuration;
107 mComments = other.mComments;
108 mContacts = other.mContacts;
111 Attendee::List::ConstIterator it;
112 for ( it = other.mAttendees.constBegin(); it != other.mAttendees.constEnd(); ++it ) {
154 d->mDirtyFields.clear();
182 Attendee::List::ConstIterator a1 = al1.constBegin();
183 Attendee::List::ConstIterator a2 = al2.constBegin();
186 for ( ; a1 != al1.constEnd() && a2 != al2.constEnd(); ++a1, ++a2 ) {
187 if ( !( **a1 == **a2 ) ) {
192 if ( !CustomProperties::operator==( i2 ) ) {
212 Q_UNUSED( incidence );
237 KDateTime current = lm.toUtc();
238 QTime t = current.time();
239 t.setHMS( t.hour(), t.minute(), t.second(), 0 );
240 current.setTime( t );
242 d->mLastModified = current;
247 return d->mLastModified;
266 if ( mail.startsWith( QLatin1String(
"MAILTO:" ), Qt::CaseInsensitive ) ) {
267 mail = mail.remove( 0, 7 );
277 return d->mOrganizer;
295 d->mAllDay = dtStart.isDateOnly();
296 d->mDirtyFields.insert( FieldDtStart );
317 if ( d->mDtStart.isValid() ) {
318 d->mDirtyFields.insert( FieldDtStart );
324 const KDateTime::Spec &newSpec )
327 d->mDtStart = d->mDtStart.toTimeSpec( oldSpec );
328 d->mDtStart.setTimeSpec( newSpec );
329 d->mDirtyFields.insert( FieldDtStart );
336 d->mComments += comment;
342 QStringList::Iterator i;
344 for ( i = d->mComments.begin(); !found && i != d->mComments.end(); ++i ) {
345 if ( ( *i ) == comment ) {
347 d->mComments.erase( i );
361 d->mComments.clear();
371 if ( !contact.isEmpty() ) {
372 d->mContacts += contact;
380 QStringList::Iterator i;
382 for ( i = d->mContacts.begin(); !found && i != d->mContacts.end(); ++i ) {
383 if ( ( *i ) == contact ) {
385 d->mContacts.erase( i );
399 d->mContacts.clear();
413 Q_ASSERT( !d->mAttendees.contains( a ) );
418 if ( a->name().left( 7 ).toUpper() ==
"MAILTO:" ) {
419 a->setName( a->name().remove( 0, 7 ) );
430 if ( a->uid().isEmpty() ) {
431 a->setUid( QString::number( (qlonglong)a.data() ) );
434 d->mAttendees.append( a );
447 int index = d->mAttendees.indexOf( a );
453 d->mAttendees.remove( index );
464 return d->mAttendees;
469 return d->mAttendees.count();
478 d->mAttendees.clear();
483 Attendee::List::ConstIterator it;
484 for ( it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it ) {
485 if ( ( *it )->email() == email ) {
494 const QString &email )
const
496 QStringList mails = emails;
497 if ( !email.isEmpty() ) {
498 mails.append( email );
501 Attendee::List::ConstIterator itA;
502 for ( itA = d->mAttendees.constBegin(); itA != d->mAttendees.constEnd(); ++itA ) {
503 for ( QStringList::const_iterator it = mails.constBegin(); it != mails.constEnd(); ++it ) {
504 if ( ( *itA )->email() == ( *it ) ) {
515 Attendee::List::ConstIterator it;
516 for ( it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it ) {
517 if ( ( *it )->uid() ==
uid ) {
546 return d->mHasDuration;
551 if ( observer && !d->mObservers.contains( observer ) ) {
552 d->mObservers.append( observer );
558 d->mObservers.removeAll( observer );
563 if ( !d->mUpdateGroupLevel ) {
564 d->mUpdatedPending =
true;
574 if ( d->mUpdateGroupLevel ) {
575 d->mUpdatedPending =
true;
587 ++d->mUpdateGroupLevel;
592 if ( d->mUpdateGroupLevel > 0 ) {
593 if ( --d->mUpdateGroupLevel == 0 && d->mUpdatedPending ) {
594 d->mUpdatedPending =
false;
617 d->mDirtyFields.clear();
622 return d->mDirtyFields;
627 d->mDirtyFields.insert( field );
632 return KUrl( QString(
"urn:x-ical:" ) +
uid() );