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 );
void setUid(const TQString &)
Set the unique id for the event.
void addComment(const TQString &comment)
Add a comment to this incidence.
bool doesFloat() const
Return true or false depending on whether the incidence "floats," i.e.
This class represents custom calendar properties.
Attendee * attendeeByMails(const TQStringList &, const TQString &email=TQString()) const
Return first Attendee with one of the given email addresses.
This class provides the base class common to all calendar components.
void setLastModified(const TQDateTime &lm)
Sets the time the incidence was last modified.
void updated()
Call this to notify the observers after the IncidenceBas object has changed.
virtual void setReadOnly(bool)
Set readonly status.
This class represents information related to an attendee of an event.
virtual KDE_DEPRECATED TQString dtStartStr() const
returns an event's starting date and time as a string formatted according to the users locale setting...
virtual TQDateTime dtStart() const
returns an event's starting date/time as a TQDateTime.
TQDateTime lastModified() const
Return the time the incidence was last modified.
void setOrganizer(const Person &o)
sets the organizer for the event
void clearComments()
Delete all comments associated with this incidence.
int syncStatus() const
Return synchronisation status.
This class represents a person.
virtual KDE_DEPRECATED TQString dtStartTimeStr() const
returns an event's starting time as a string formatted according to the users locale settings...
TQString uid() const
Return the unique id for the event.
virtual void customPropertyUpdated()
Attendee * attendeeByMail(const TQString &) const
Return the Attendee with this email address.
virtual void setDtStart(const TQDateTime &dtStart)
for setting the event's starting date/time with a TQDateTime.
Namespace KCal is for global classes, objects and/or functions in libkcal.
void addAttendee(Attendee *attendee, bool doUpdate=true)
Add Attendee to this incidence.
void unRegisterObserver(Observer *)
Unregister observer.
const Attendee::List & attendees() const
Return list of attendees.
virtual KDE_DEPRECATED TQString dtStartDateStr(bool shortfmt=true) const
returns an event's starting date as a string formatted according to the users locale settings ...
TQStringList comments() const
Return all comments associated with this incidence.
bool removeComment(const TQString &comment)
Remove a comment from the event.
void setSyncStatus(int status)
Set synchronisation satus.
Attendee * attendeeByUid(const TQString &uid) const
Return attendee with given uid.
void setPilotId(unsigned long id)
Set Pilot Id.
void registerObserver(Observer *)
Register observer.
void setFloats(bool f)
Set whether the incidence floats, i.e.
void clearAttendees()
Remove all Attendees.
unsigned long pilotId() const
Return Pilot Id.