34Incidence::Incidence() :
36 mRelatedTo(0), mStatus(StatusNone), mSecrecy(SecrecyPublic),
37 mPriority(0), mRecurrence(0),
38 mHasRecurrenceID( false ), mChildRecurrenceEvents()
42 mAlarms.setAutoDelete(
true);
43 mAttachments.setAutoDelete(
true);
49 mRevision = i.mRevision;
50 mCreated = i.mCreated;
51 mDescription = i.mDescription;
52 mSummary = i.mSummary;
53 mCategories = i.mCategories;
56 mRelatedToUid = i.mRelatedToUid;
58 mResources = i.mResources;
59 mStatusString = i.mStatusString;
61 mSecrecy = i.mSecrecy;
62 mPriority = i.mPriority;
63 mLocation = i.mLocation;
64 mRecurrenceID = i.mRecurrenceID;
65 mHasRecurrenceID = i.mHasRecurrenceID;
66 mChildRecurrenceEvents = i.mChildRecurrenceEvents;
71 Alarm::List::ConstIterator it;
72 for( it = i.mAlarms.begin(); it != i.mAlarms.end(); ++it ) {
77 mAlarms.setAutoDelete(
true);
79 Attachment::List::ConstIterator it1;
80 for ( it1 = i.mAttachments.begin(); it1 != i.mAttachments.end(); ++it1 ) {
82 mAttachments.append( a );
84 mAttachments.setAutoDelete(
true );
87 mRecurrence =
new Recurrence( *(i.mRecurrence) );
88 mRecurrence->addObserver(
this );
92 mSchedulingID = i.mSchedulingID;
95Incidence::~Incidence()
98 List::ConstIterator it;
99 for ( it = Relations.begin(); it != Relations.end(); ++it ) {
100 if ( (*it)->relatedTo() == this ) (*it)->mRelatedTo = 0;
108static bool stringCompare(
const TQString& s1,
const TQString& s2 )
110 return ( s1.isEmpty() && s2.isEmpty() ) || (s1 == s2);
117 IncidenceBase::operator=( i );
118 mRevision = i.mRevision;
119 mCreated = i.mCreated;
120 mDescription = i.mDescription;
121 mSummary = i.mSummary;
122 mCategories = i.mCategories;
124 mRelatedToUid = i.mRelatedToUid;
126 mResources = i.mResources;
127 mStatusString = i.mStatusString;
129 mSecrecy = i.mSecrecy;
130 mPriority = i.mPriority;
131 mLocation = i.mLocation;
132 mRecurrenceID = i.mRecurrenceID;
133 mHasRecurrenceID = i.mHasRecurrenceID;
134 mChildRecurrenceEvents = i.mChildRecurrenceEvents;
137 Alarm::List::ConstIterator it;
138 for( it = i.mAlarms.begin(); it != i.mAlarms.end(); ++it ) {
144 mAttachments.clearAll();
145 Attachment::List::ConstIterator it1;
146 for ( it1 = i.mAttachments.begin(); it1 != i.mAttachments.end(); ++it1 ) {
148 mAttachments.append( a );
153 mRecurrence =
new Recurrence( *(i.mRecurrence) );
158 mSchedulingID = i.mSchedulingID;
162bool Incidence::operator==(
const Incidence& i2 )
const
168 Alarm::List::ConstIterator a1 =
alarms().begin();
169 Alarm::List::ConstIterator a2 = i2.
alarms().begin();
170 for( ; a1 !=
alarms().end() && a2 != i2.
alarms().end(); ++a1, ++a2 )
177 if ( !IncidenceBase::operator==(i2) )
180 bool recurrenceEqual = ( mRecurrence == 0 && i2.mRecurrence == 0 );
181 if ( !recurrenceEqual )
183 recurrenceEqual = mRecurrence != 0 &&
184 i2.mRecurrence != 0 &&
185 *mRecurrence == *i2.mRecurrence;
199 mStatus == i2.mStatus &&
200 ( mStatus == StatusNone || stringCompare( mStatusString, i2.mStatusString ) ) &&
231 if (mReadOnly)
return;
239 if (mReadOnly)
return;
253 if (mReadOnly)
return;
275 if (mReadOnly)
return;
288 if (mReadOnly)
return;
300 if (mReadOnly)
return;
308 if (mReadOnly)
return;
311 if (catStr.isEmpty())
return;
313 mCategories = TQStringList::split(
",",catStr);
315 TQStringList::Iterator it;
316 for(it = mCategories.begin();it != mCategories.end(); ++it) {
317 *it = (*it).stripWhiteSpace();
330 return mCategories.join(
",");
335 if ( mReadOnly || mRelatedToUid ==
relatedToUid )
return;
342 return mRelatedToUid;
347 if (mReadOnly || mRelatedTo ==
relatedTo)
return;
353 if ( mRelatedTo->
uid() != mRelatedToUid )
372 if ( mRelations.find( event ) == mRelations.end() ) {
373 mRelations.append( event );
381 mRelations.removeRef(event);
383 mRelatedToUid=TQString();
410uint Incidence::recurrenceType()
const
413 else return Recurrence::rNone;
418 if ( mRecurrence )
return mRecurrence->
doesRecur();
446 IncidenceListIterator it;
447 for ( it = il.begin(); it != il.end(); ++it ) {
449 modifiedDt.setTime(TQTime());
450 if (TQDateTime(qd) == modifiedDt) {
467 IncidenceListIterator it;
468 for ( it = il.begin(); it != il.end(); ++it ) {
492 TQValueList<TQDateTime> result;
495 if ( !start.isValid() && ! end.isValid() ) {
501 if ( !(start.date() > date || end.date() < date ) ) {
507 int days = start.daysTo( end );
509 TQDate tmpday( date.addDays( -days - 1 ) );
511 while ( tmpday <= date ) {
514 for ( TQValueList<TQTime>::ConstIterator it = times.begin(); it != times.end(); ++it ) {
515 tmp = TQDateTime( tmpday, *it );
520 tmpday = tmpday.addDays( 1 );
539 TQValueList<TQDateTime> result;
542 if ( !start.isValid() && ! end.isValid() ) {
548 if ( !(start > datetime || end < datetime ) ) {
554 int days = start.daysTo( end );
556 TQDate tmpday( datetime.date().addDays( -days - 1 ) );
558 while ( tmpday <= datetime.date() ) {
561 for ( TQValueList<TQTime>::ConstIterator it = times.begin(); it != times.end(); ++it ) {
562 tmp = TQDateTime( tmpday, *it );
567 tmpday = tmpday.addDays( 1 );
577 if ( !end.isValid() )
return start;
578 if ( !start.isValid() )
return end;
580 return startDt.addSecs( start.secsTo( end ) );
676 if (mReadOnly || !attachment)
return;
677 mAttachments.append(attachment);
683 mAttachments.removeRef(attachment);
688 Attachment::List::Iterator it = mAttachments.begin();
689 while( it != mAttachments.end() ) {
690 if ( (*it)->mimeType() == mime ) mAttachments.remove( it );
703 Attachment::List::ConstIterator it;
704 for( it = mAttachments.begin(); it != mAttachments.end(); ++it ) {
705 if ( (*it)->mimeType() == mime )
attachments.append( *it );
713 mAttachments.clearAll();
718 if (mReadOnly)
return;
731 if (mReadOnly)
return;
743 if (mReadOnly ||
status == StatusX)
return;
745 mStatusString = TQString();
751 if (mReadOnly)
return;
752 mStatus =
status.isEmpty() ? StatusNone : StatusX;
764 if (mStatus == StatusX)
765 return mStatusString;
772 case StatusTentative:
return i18n(
"incidence status",
"Tentative");
773 case StatusConfirmed:
return i18n(
"Confirmed");
774 case StatusCompleted:
return i18n(
"Completed");
775 case StatusNeedsAction:
return i18n(
"Needs-Action");
776 case StatusCanceled:
return i18n(
"Canceled");
777 case StatusInProcess:
return i18n(
"In-Process");
778 case StatusDraft:
return i18n(
"Draft");
779 case StatusFinal:
return i18n(
"Final");
782 default:
return TQString();
788 if (mReadOnly)
return;
807 return i18n(
"Public");
809 return i18n(
"Private");
810 case SecrecyConfidential:
811 return i18n(
"Confidential");
813 return i18n(
"Undefined");
836 mAlarms.append(alarm);
843 mAlarms.append(alarm);
849 mAlarms.removeRef(alarm);
861 Alarm::List::ConstIterator it;
862 for( it = mAlarms.begin(); it != mAlarms.end(); ++it ) {
863 if ( (*it)->enabled() )
return true;
870 if (mReadOnly)
return;
887 if ( mSchedulingID.isNull() )
890 return mSchedulingID;
895 return mHasRecurrenceID;
910 return mRecurrenceID;
926 mChildRecurrenceEvents.append(childIncidence);
931 mChildRecurrenceEvents.remove(childIncidence);
936 return mChildRecurrenceEvents;
Provides the main "calendar" object class.
This class represents an alarm notification.
void setParent(Incidence *)
Set the alarm's parent incidence.
This class represents information related to an attachment.
This is the main "calendar" object class.
Incidence * incidence(const TQString &uid)
Returns the Incidence associated with the given unique identifier.
This class provides the base class common to all calendar components.
void updated()
Call this to notify the observers after the IncidenceBas object has changed.
void setFloats(bool f)
Set whether the incidence floats, i.e.
void setPilotId(unsigned long id)
Set Pilot Id.
bool doesFloat() const
Return true or false depending on whether the incidence "floats," i.e.
TQString uid() const
Return the unique id for the event.
void setUid(const TQString &)
Set the unique id for the event.
virtual void setReadOnly(bool)
Set readonly status.
virtual TQDateTime dtStart() const
returns an event's starting date/time as a TQDateTime.
virtual void setDtStart(const TQDateTime &dtStart)
for setting the event's starting date/time with a TQDateTime.
void setSyncStatus(int status)
Set synchronisation satus.
void setLastModified(const TQDateTime &lm)
Sets the time the incidence was last modified.
This class provides the base class common to all calendar components.
TQString statusStr() const
Return the event's status string.
TQString secrecyStr() const
Return secrecy as translated string.
void setReadOnly(bool readonly)
Set readonly state of incidence.
void addAttachment(Attachment *attachment)
Add attachment.
TQString relatedToUid() const
What event does this one relate to? This function should only be used when constructing a calendar be...
void setLocation(const TQString &location)
Set the event's/todo's location.
void deleteAttachment(Attachment *attachment)
Remove and delete a specific attachment.
bool recursAt(const TQDateTime &qdt) const
Returns true if the date/time specified is one on which the incidence will recur.
const Alarm::List & alarms() const
All alarms that are associated with this incidence.
void setSummary(const TQString &summary)
Set short summary.
void recreate()
Recreate event.
void setCustomStatus(const TQString &status)
Sets the incidence status to a non-standard status value.
void clearAlarms()
Remove all alarms that are associated with this incidence.
virtual void recurrenceUpdated(Recurrence *)
Observer interface for the recurrence class.
void clearAttachments()
Remove and delete all attachments.
void setSchedulingID(const TQString &sid)
Set the event's/todo's scheduling ID.
Alarm * newAlarm()
Create a new alarm which is associated with this incidence.
void setRelatedTo(Incidence *relatedTo)
Point at some other event to which the event relates.
TQDateTime created() const
Return time and date of creation.
int revision() const
Return the number of revisions this event has seen.
void setPriority(int priority)
Set the incidences priority.
virtual TQValueList< TQDateTime > startDateTimesForDateTime(const TQDateTime &datetime) const
Calculates the start date/time for all recurrences that happen at the given time.
void setSecrecy(int)
Sets secrecy status.
int secrecy() const
Return the event's secrecy.
IncidenceList childIncidences() const
Returns an EventList of all child incidences.
static TQString secrecyName(int)
Return human-readable translated name of secrecy class.
TQString description() const
Return long description.
Incidence * relatedTo() const
What event does this one relate to?
Status
Enumeration for describing an event's status.
static TQString statusName(Status)
Return human-readable translated name of status value.
TQStringList categories() const
Return categories as a list of strings.
void setStatus(Status status)
Sets the incidence status to a standard status value.
void removeRelation(Incidence *)
Remove event that is related to this event.
void setDescription(const TQString &description)
Set the long description.
int priority() const
Return priority.
Status status() const
Return the event's status.
void setFloats(bool f)
Set whether the incidence floats, i.e.
void setRelatedToUid(const TQString &)
Point at some other event to which the event relates.
bool doesRecur() const
Forward to Recurrence::doesRecur().
bool isAlarmEnabled() const
Return whether any alarm associated with this incidence is enabled.
virtual void setDtStart(const TQDateTime &dtStart)
Set starting date/time.
TQString schedulingID() const
Return the event's/todo's scheduling ID.
bool hasRecurrenceID() const
Returns true if the incidence has recurrenceID, otherwise return false.
TQDateTime recurrenceID() const
Returns the incidence recurrenceID.
void setCategories(const TQStringList &categories)
Set categories.
static TQStringList secrecyList()
Return list of all available secrecy states as list of translated strings.
void deleteAttachments(const TQString &mime)
Remove and delete all attachments with this mime type.
void setResources(const TQStringList &resources)
Set resources used, such as Office, Car, etc.
Incidence::List relations() const
All events that are related to this event.
TQString location() const
Return the event's/todo's location.
virtual TQValueList< TQDateTime > startDateTimesForDate(const TQDate &date) const
Calculates the start date/time for all recurrences that happen at some time on the given date (might ...
void addAlarm(Alarm *)
Add an alarm which is associated with this incidence.
virtual TQDateTime endDateRecurrenceBase() const
Return the end date/time of the base incidence (e.g.
void removeAlarm(Alarm *)
Remove an alarm that is associated with this incidence.
void clearRecurrence()
Removes all recurrence and exception rules and dates.
Attachment::List attachments() const
Return list of all associated attachments.
TQString categoriesStr() const
Return categories as a comma separated string.
TQString summary() const
Return short summary.
Recurrence * recurrence() const
Return the recurrence rule associated with this incidence.
void setRevision(int rev)
Set the number of revisions this event has seen.
void addChildIncidence(TQString childIncidence)
Attach a child incidence to a parent incidence.
TQStringList resources() const
Return list of current resources.
void deleteChildIncidence(TQString childIncidence)
Detach a child incidence from its parent incidence.
void setCreated(const TQDateTime &)
Set creation date.
virtual bool recursOn(const TQDate &qd) const
Returns true if the date specified is one on which the incidence will recur.
void addRelation(Incidence *)
Add an event which is related to this event.
void setHasRecurrenceID(bool hasRecurrenceID)
Sets if the incidence has recurrenceID.
virtual TQDateTime endDateForStart(const TQDateTime &startDt) const
Return the end time of the occurrence if it starts at the given date/time.
void setRecurrenceID(const TQDateTime &recurrenceID)
Set the incidences recurrenceID.
This class represents a recurrence rule for a calendar incidence.
ushort recurrenceType() const
Returns the event's recurrence status.
void setFloats(bool floats)
Sets whether the dtstart is a floating time (i.e.
void setStartDateTime(const TQDateTime &start)
Set start of recurrence, as a date and time.
void setRecurReadOnly(bool readOnly)
Set if recurrence is read-only or can be changed.
void addObserver(Observer *observer)
Installs an observer.
TQValueList< TQTime > recurTimesOn(const TQDate &date) const
Returns a list of the times on the specified date at which the recurrence will occur.
bool doesRecur() const
Returns whether the event recurs at all.
bool recursAt(const TQDateTime &) const
Returns true if the date/time specified is one at which the event will recur.
bool recursOn(const TQDate &qd) const
Returns true if the date specified is one on which the event will recur.
Namespace KCal is for global classes, objects and/or functions in libkcal.