23 #include <tdeglobal.h>
24 #include <tdelocale.h>
27 #include "calformat.h"
29 #include "incidencebase.h"
33 IncidenceBase::IncidenceBase()
34 : mReadOnly( false ), mFloats( true ), mDuration( 0 ), mHasDuration( false ),
35 mPilotId( 0 ), mSyncStatus( SYNCMOD )
39 mAttendees.setAutoDelete(
true );
45 mReadOnly = i.mReadOnly;
46 mDtStart = i.mDtStart;
47 mDuration = i.mDuration;
48 mHasDuration = i.mHasDuration;
49 mOrganizer = i.mOrganizer;
52 Attendee::List::ConstIterator it;
53 for( it = attendees.begin(); it != attendees.end(); ++it ) {
54 mAttendees.append(
new Attendee( *(*it) ) );
57 mLastModified = i.mLastModified;
58 mPilotId = i.mPilotId;
59 mSyncStatus = i.mSyncStatus;
60 mComments = i.mComments;
66 mAttendees.setAutoDelete(
true );
69 IncidenceBase::~IncidenceBase()
75 CustomProperties::operator=( i );
76 mReadOnly = i.mReadOnly;
77 mDtStart = i.mDtStart;
78 mDuration = i.mDuration;
79 mHasDuration = i.mHasDuration;
80 mOrganizer = i.mOrganizer;
84 Attendee::List::ConstIterator it;
85 for( it = attendees.begin(); it != attendees.end(); ++it ) {
86 mAttendees.append(
new Attendee( *(*it) ) );
89 mLastModified = i.mLastModified;
90 mPilotId = i.mPilotId;
91 mSyncStatus = i.mSyncStatus;
92 mComments = i.mComments;
97 bool IncidenceBase::operator==(
const IncidenceBase& i2 )
const
105 Attendee::List::ConstIterator a1 = al1.begin();
106 Attendee::List::ConstIterator a2 = al2.begin();
107 for( ; a1 != al1.end() && a2 != al2.end(); ++a1, ++a2 ) {
115 if ( !CustomProperties::operator==(i2) )
119 organizer() == i2.organizer() &&
124 duration() == i2.duration() &&
125 hasDuration() == i2.hasDuration() &&
151 TQDateTime current = lm;
152 TQTime t = current.time();
153 t.setHMS( t.hour(), t.minute(), t.second(), 0 );
154 current.setTime( t );
156 mLastModified = current;
161 return mLastModified;
177 if ( mail.startsWith(
"MAILTO:",
false) )
178 mail = mail.remove( 0, 7 );
184 Person IncidenceBase::organizer()
const
191 mReadOnly = readOnly;
208 return TDEGlobal::locale()->formatTime(
dtStart().time());
213 return TDEGlobal::locale()->formatDate(
dtStart().date(),shortfmt);
218 return TDEGlobal::locale()->formatDateTime(
dtStart());
229 if (mReadOnly)
return;
237 mComments += comment;
243 TQStringList::Iterator i;
245 for ( i = mComments.begin(); !found && i != mComments.end(); ++i ) {
246 if ( (*i) == comment ) {
269 if (mReadOnly)
return;
271 if (a->name().left(7).upper() ==
"MAILTO:")
272 a->setName(a->name().remove(0,7));
274 mAttendees.append(a);
279 void IncidenceBase::removeAttendee(
Attendee *a)
281 if (mReadOnly)
return;
282 mAttendees.removeRef(a);
286 void IncidenceBase::removeAttendee(
const char *n)
290 if (mReadOnly)
return;
291 for (a = mAttendees.first(); a; a = mAttendees.next())
292 if (a->getName() == n) {
301 if (mReadOnly)
return;
307 Attendee::List::ConstIterator it;
308 for( it = mAttendees.begin(); it != mAttendees.end(); ++it ) {
309 if ( (*it)->email() == email )
return *it;
316 const TQString &email)
const
318 TQStringList mails = emails;
319 if ( !email.isEmpty() ) mails.append( email );
321 Attendee::List::ConstIterator itA;
322 for( itA = mAttendees.begin(); itA != mAttendees.end(); ++itA ) {
323 for ( TQStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
324 if ( (*itA)->email() == (*it) )
return *itA;
333 Attendee::List::ConstIterator it;
334 for( it = mAttendees.begin(); it != mAttendees.end(); ++it ) {
335 if ( (*it)->uid() ==
uid )
return *it;
342 void IncidenceBase::setDuration(
int seconds)
345 setHasDuration(
true);
349 int IncidenceBase::duration()
const
354 void IncidenceBase::setHasDuration(
bool hasDuration)
356 mHasDuration = hasDuration;
359 bool IncidenceBase::hasDuration()
const
366 if (mReadOnly)
return;
367 if ( mSyncStatus == stat )
return;
371 void IncidenceBase::setSyncStatusSilent(
int stat)
373 if (mReadOnly)
return;
384 if (mReadOnly)
return;
385 if ( mPilotId ==
id)
return;
397 if( !mObservers.contains( observer ) ) mObservers.append( observer );
402 mObservers.remove( observer );
407 TQPtrListIterator<Observer> it(mObservers);
408 while( it.current() ) {
409 Observer *o = it.current();
412 o->incidenceUpdated(
this );
422 void IncidenceBase::updatedSilent()
424 TQPtrListIterator<Observer> it(mObservers);
425 while( it.current() ) {
426 Observer *o = it.current();
428 o->incidenceUpdatedSilent(
this );