33 FreeBusy::FreeBusy(
const TQDateTime &start,
const TQDateTime &end)
39 FreeBusy::FreeBusy(
Calendar *calendar,
const TQDateTime &start,
const TQDateTime &end )
41 kdDebug(5800) <<
"FreeBusy::FreeBusy" << endl;
50 int extraDays, i, x, duration;
51 duration = start.daysTo(end);
56 Event::List::ConstIterator it;
57 for( it = eventList.begin(); it != eventList.end(); ++it ) {
64 Event *floatingEvent = 0;
65 if ( event->doesFloat() ) {
67 kdDebug(5800) <<
"Floating event\n";
68 floatingEvent =
new Event( *event );
71 TQDateTime start( floatingEvent->
dtStart().date(), TQTime( 0, 0 ) );
72 TQDateTime end( floatingEvent->
dtEnd().date(), TQTime( 23, 59, 59, 999 ) );
77 kdDebug(5800) <<
"Use: " << start.toString() <<
" to " << end.toString()
80 event = floatingEvent;
88 if ( event->transparency() == Event::Transparent )
92 for( i = 0; i <= duration; ++i ) {
93 day=(start.addDays(i).date());
94 tmpStart.setDate(day);
97 if( event->doesRecur() ) {
98 if ( event->isMultiDay() ) {
101 extraDays =
event->
dtStart().date().daysTo(event->dtEnd().date());
102 for ( x = 0; x <= extraDays; ++x ) {
103 if ( event->recursOn(day.addDays(-x))) {
104 tmpStart.setDate(day.addDays(-x));
105 tmpStart.setTime(event->dtStart().time());
106 tmpEnd=tmpStart.addSecs( (event->duration()) );
108 addLocalPeriod( tmpStart, tmpEnd );
113 if (event->recursOn(day)) {
114 tmpStart.setTime(event->dtStart().time());
115 tmpEnd.setTime(event->dtEnd().time());
117 addLocalPeriod (tmpStart, tmpEnd);
124 addLocalPeriod(event->dtStart(),
event->dtEnd());
127 delete floatingEvent;
133 FreeBusy::~FreeBusy()
137 bool FreeBusy::setDtEnd(
const TQDateTime &end )
143 TQDateTime FreeBusy::dtEnd()
const 148 PeriodList FreeBusy::busyPeriods()
const 153 bool FreeBusy::addLocalPeriod(
const TQDateTime &eventStart,
const TQDateTime &eventEnd ) {
159 if ( !( ( (
dtStart().secsTo(eventStart) >= 0 ) &&
160 ( eventStart.secsTo(dtEnd()) >= 0 ) )
161 || ( (
dtStart().secsTo(eventEnd) >= 0 ) &&
162 ( eventEnd.secsTo(dtEnd()) >= 0 ) ) ) )
165 if ( eventStart.secsTo(
dtStart() ) >= 0 ) {
168 tmpStart = eventStart;
171 if ( eventEnd.secsTo( dtEnd() ) <= 0 ) {
177 Period p(tmpStart, tmpEnd);
178 mBusyPeriods.append( p );
183 FreeBusy::FreeBusy( PeriodList busyPeriods)
185 mBusyPeriods = busyPeriods;
188 void FreeBusy::sortList()
190 qHeapSort( mBusyPeriods );
196 mBusyPeriods += list;
202 mBusyPeriods.append(
Period(start, end) );
208 mBusyPeriods.append(
Period(start, dur) );
212 void FreeBusy::merge(
FreeBusy *freeBusy )
217 if ( freeBusy->dtEnd() > dtEnd() )
218 setDtEnd( freeBusy->dtEnd() );
220 TQValueList<Period> periods = freeBusy->busyPeriods();
221 TQValueList<Period>::ConstIterator it;
222 for ( it = periods.begin(); it != periods.end(); ++it )
230 dtEnd() == freebusy.dtEnd() &&
231 mCalendar == freebusy.mCalendar &&
232 mBusyPeriods == freebusy.mBusyPeriods;
void setFloats(bool f)
Set whether the incidence floats, i.e.
void setDtEnd(const TQDateTime &dtEnd)
Set end date and time.
void addPeriod(const TQDateTime &start, const TQDateTime &end)
Adds a period to the freebusy list and sorts the list.
This is the main "calendar" object class.
This class provides the base class common to all calendar components.
This class provides an Event in the sense of RFC2445.
virtual Event::List rawEvents(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return a sorted, unfiltered list of all Events for this Calendar.
virtual TQDateTime dtEnd() const
Return end date and time.
virtual TQDateTime dtStart() const
returns an event's starting date/time as a TQDateTime.
This class represents a period of time.
bool operator==(const FreeBusy &freebusy) const
Compare this with freebusy for equality.
virtual void setDtStart(const TQDateTime &dtStart)
for setting the event's starting date/time with a TQDateTime.
void addPeriods(const PeriodList &)
Adds a list of periods to the freebusy object and then sorts that list.
Namespace KCal is for global classes, objects and/or functions in libkcal.
This class represents a duration.
This class provides information about free/busy time of a calendar user.
virtual void setDtStart(const TQDateTime &dtStart)
Set starting date/time.