41 #include <klocalizedstring.h>
44 #include <ksystemtimezone.h>
46 #include <QtCore/QList>
55 class KCal::IncidenceBase::Private
59 : mUpdateGroupLevel( 0 ),
60 mUpdatedPending( false ),
63 { mAttendees.setAutoDelete(
true ); }
65 Private(
const Private &other )
66 : mUpdateGroupLevel( 0 ),
67 mUpdatedPending( false ),
71 mAttendees.setAutoDelete(
true );
75 void init(
const Private &other );
77 KDateTime mLastModified;
82 int mUpdateGroupLevel;
88 QStringList mComments;
89 QList<IncidenceObserver*> mObservers;
92 void IncidenceBase::Private::init(
const Private &other )
94 mLastModified = other.mLastModified;
95 mDtStart = other.mDtStart;
96 mOrganizer = other.mOrganizer;
98 mDuration = other.mDuration;
99 mAllDay = other.mAllDay;
100 mHasDuration = other.mHasDuration;
101 mComments = other.mComments;
104 Attendee::List::ConstIterator it;
105 for ( it = other.mAttendees.constBegin(); it != other.mAttendees.constEnd(); ++it ) {
106 mAttendees.append(
new Attendee( *(*it) ) );
134 if ( &other ==
this ) {
152 Attendee::List::ConstIterator a1 = al1.constBegin();
153 Attendee::List::ConstIterator a2 = al2.constBegin();
156 for ( ; a1 != al1.constEnd() && a2 != al2.constEnd(); ++a1, ++a2 ) {
157 if ( !( **a1 == **a2 ) ) {
162 if ( !CustomProperties::operator == (i2) ) {
195 KDateTime current = lm.toUtc();
196 QTime t = current.time();
197 t.setHMS( t.hour(), t.minute(), t.second(), 0 );
198 current.setTime( t );
200 d->mLastModified = current;
205 return d->mLastModified;
221 if ( mail.startsWith( QLatin1String(
"MAILTO:" ), Qt::CaseInsensitive ) ) {
222 mail = mail.remove( 0, 7 );
232 return d->mOrganizer;
244 d->mAllDay = dtStart.isDateOnly();
255 if ( spec.isValid() ) {
258 if ( spec.timeZone() != KSystemTimeZones::local() ) {
259 timeZone =
' ' + spec.timeZone().name();
262 return KGlobal::locale()->formatTime(
263 dtStart().toTimeSpec( spec ).time(), !shortfmt ) + timeZone;
265 return KGlobal::locale()->formatTime(
dtStart().time(), !shortfmt );
271 if ( spec.isValid() ) {
274 if ( spec.timeZone() != KSystemTimeZones::local() ) {
275 timeZone =
' ' + spec.timeZone().name();
278 return KGlobal::locale()->formatDate(
279 dtStart().toTimeSpec( spec ).date(),
280 ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) ) + timeZone;
282 return KGlobal::locale()->formatDate(
283 dtStart().date(), ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) );
293 if ( spec.isValid() ) {
296 if ( spec.timeZone() != KSystemTimeZones::local() ) {
297 timeZone =
' ' + spec.timeZone().name();
300 return KGlobal::locale()->formatDateTime(
301 dtStart().toTimeSpec( spec ).dateTime(),
302 ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) ) + timeZone;
304 return KGlobal::locale()->formatDateTime(
306 ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) );
325 const KDateTime::Spec &newSpec )
327 d->mDtStart = d->mDtStart.toTimeSpec( oldSpec );
328 d->mDtStart.setTimeSpec( newSpec );
334 d->mComments += comment;
340 QStringList::Iterator i;
342 for ( i = d->mComments.begin(); !found && i != d->mComments.end(); ++i ) {
343 if ( (*i) == comment ) {
345 d->mComments.erase( i );
354 d->mComments.clear();
368 if ( a->
name().left(7).toUpper() ==
"MAILTO:" ) {
372 d->mAttendees.append( a );
380 return d->mAttendees;
385 return d->mAttendees.count();
393 qDeleteAll( d->mAttendees );
394 d->mAttendees.clear();
399 Attendee::List::ConstIterator it;
400 for ( it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it ) {
401 if ( (*it)->email() == email ) {
410 const QString &email )
const
412 QStringList mails = emails;
413 if ( !email.isEmpty() ) {
414 mails.append( email );
417 Attendee::List::ConstIterator itA;
418 for ( itA = d->mAttendees.constBegin(); itA != d->mAttendees.constEnd(); ++itA ) {
419 for ( QStringList::const_iterator it = mails.constBegin(); it != mails.constEnd(); ++it ) {
420 if ( (*itA)->email() == (*it) ) {
431 Attendee::List::ConstIterator it;
432 for ( it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it ) {
433 if ( (*it)->uid() ==
uid ) {
460 return d->mHasDuration;
465 if ( !d->mObservers.contains( observer ) ) {
466 d->mObservers.append( observer );
472 d->mObservers.removeAll( observer );
477 if ( d->mUpdateGroupLevel ) {
478 d->mUpdatedPending =
true;
490 ++d->mUpdateGroupLevel;
495 if ( d->mUpdateGroupLevel > 0 ) {
496 if ( --d->mUpdateGroupLevel == 0 && d->mUpdatedPending ) {
497 d->mUpdatedPending =
false;
510 return KUrl( QString(
"urn:x-ical:" ) +
uid() );
533 Q_UNUSED( freebusy );