43 #include <ksystemtimezone.h>
45 #include <QtCore/QList>
54 class KCal::IncidenceBase::Private
58 : mUpdateGroupLevel( 0 ),
59 mUpdatedPending( false ),
62 { mAttendees.setAutoDelete(
true ); }
64 Private(
const Private &other )
65 : mUpdateGroupLevel( 0 ),
66 mUpdatedPending( false ),
70 mAttendees.setAutoDelete(
true );
74 void init(
const Private &other );
76 KDateTime mLastModified;
81 int mUpdateGroupLevel;
87 QStringList mComments;
88 QList<IncidenceObserver*> mObservers;
91 void IncidenceBase::Private::init(
const Private &other )
93 mLastModified = other.mLastModified;
94 mDtStart = other.mDtStart;
95 mOrganizer = other.mOrganizer;
97 mDuration = other.mDuration;
98 mAllDay = other.mAllDay;
99 mHasDuration = other.mHasDuration;
100 mComments = other.mComments;
103 Attendee::List::ConstIterator it;
104 for ( it = other.mAttendees.constBegin(); it != other.mAttendees.constEnd(); ++it ) {
105 mAttendees.append(
new Attendee( *(*it) ) );
133 if ( &other ==
this ) {
151 Attendee::List::ConstIterator a1 = al1.constBegin();
152 Attendee::List::ConstIterator a2 = al2.constBegin();
155 for ( ; a1 != al1.constEnd() && a2 != al2.constEnd(); ++a1, ++a2 ) {
156 if ( !( **a1 == **a2 ) ) {
161 if ( !CustomProperties::operator == (i2) ) {
194 KDateTime current = lm.toUtc();
195 QTime t = current.time();
196 t.setHMS( t.hour(), t.minute(), t.second(), 0 );
197 current.setTime( t );
199 d->mLastModified = current;
204 return d->mLastModified;
220 if ( mail.startsWith( QLatin1String(
"MAILTO:" ), Qt::CaseInsensitive ) ) {
221 mail = mail.remove( 0, 7 );
231 return d->mOrganizer;
243 d->mAllDay = dtStart.isDateOnly();
254 if ( spec.isValid() ) {
257 if ( spec.timeZone() != KSystemTimeZones::local() ) {
258 timeZone =
' ' + spec.timeZone().name();
261 return KGlobal::locale()->formatTime(
262 dtStart().toTimeSpec( spec ).time(), !shortfmt ) + timeZone;
264 return KGlobal::locale()->formatTime(
dtStart().time(), !shortfmt );
270 if ( spec.isValid() ) {
273 if ( spec.timeZone() != KSystemTimeZones::local() ) {
274 timeZone =
' ' + spec.timeZone().name();
277 return KGlobal::locale()->formatDate(
278 dtStart().toTimeSpec( spec ).date(),
279 ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) ) + timeZone;
281 return KGlobal::locale()->formatDate(
282 dtStart().date(), ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) );
292 if ( spec.isValid() ) {
295 if ( spec.timeZone() != KSystemTimeZones::local() ) {
296 timeZone =
' ' + spec.timeZone().name();
299 return KGlobal::locale()->formatDateTime(
300 dtStart().toTimeSpec( spec ).dateTime(),
301 ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) ) + timeZone;
303 return KGlobal::locale()->formatDateTime(
305 ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) );
324 const KDateTime::Spec &newSpec )
326 d->mDtStart = d->mDtStart.toTimeSpec( oldSpec );
327 d->mDtStart.setTimeSpec( newSpec );
333 d->mComments += comment;
339 QStringList::Iterator i;
341 for ( i = d->mComments.begin(); !found && i != d->mComments.end(); ++i ) {
342 if ( (*i) == comment ) {
344 d->mComments.erase( i );
353 d->mComments.clear();
367 if ( a->
name().left(7).toUpper() ==
"MAILTO:" ) {
371 d->mAttendees.append( a );
379 return d->mAttendees;
384 return d->mAttendees.count();
392 qDeleteAll( d->mAttendees );
393 d->mAttendees.clear();
398 Attendee::List::ConstIterator it;
399 for ( it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it ) {
400 if ( (*it)->email() == email ) {
409 const QString &email )
const
411 QStringList mails = emails;
412 if ( !email.isEmpty() ) {
413 mails.append( email );
416 Attendee::List::ConstIterator itA;
417 for ( itA = d->mAttendees.constBegin(); itA != d->mAttendees.constEnd(); ++itA ) {
418 for ( QStringList::const_iterator it = mails.constBegin(); it != mails.constEnd(); ++it ) {
419 if ( (*itA)->email() == (*it) ) {
430 Attendee::List::ConstIterator it;
431 for ( it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it ) {
432 if ( (*it)->uid() ==
uid ) {
459 return d->mHasDuration;
464 if ( !d->mObservers.contains( observer ) ) {
465 d->mObservers.append( observer );
471 d->mObservers.removeAll( observer );
476 if ( d->mUpdateGroupLevel ) {
477 d->mUpdatedPending =
true;
489 ++d->mUpdateGroupLevel;
494 if ( d->mUpdateGroupLevel > 0 ) {
495 if ( --d->mUpdateGroupLevel == 0 && d->mUpdatedPending ) {
496 d->mUpdatedPending =
false;
509 return KUrl( QString(
"urn:x-ical:" ) +
uid() );
532 Q_UNUSED( freebusy );