void HtmlExport::createEvent(QTextStream *ts, const Event::Ptr &event, QDate date, bool withDescription) { qCDebug(KCALUTILS_LOG) << event->summary(); *ts << " <tr>" << endl; if (!event->allDay()) { if (event->isMultiDay(d->mCalendar->timeSpec()) && (event->dtStart().date() != date)) { *ts << " <td> </td>" << endl; } else { *ts << " <td valign=\"top\">" << Stringify::formatTime(event->dtStart(), true, d->mCalendar->timeSpec()) << "</td>" << endl; } if (event->isMultiDay(d->mCalendar->timeSpec()) && (event->dtEnd().date() != date)) { *ts << " <td> </td>" << endl; } else { *ts << " <td valign=\"top\">" << Stringify::formatTime(event->dtEnd(), true, d->mCalendar->timeSpec()) << "</td>" << endl; } } else { *ts << " <td> </td><td> </td>" << endl; } *ts << " <td class=\"sum\">" << endl; *ts << " <b>" << cleanChars(event->summary()) << "</b>" << endl; if (withDescription && !event->description().isEmpty()) { *ts << " <p>" << breakString(cleanChars(event->description())) << "</p>" << endl; } *ts << " </td>" << endl; if (d->mSettings->eventLocation()) { *ts << " <td>" << endl; formatLocation(ts, event); *ts << " </td>" << endl; } if (d->mSettings->eventCategories()) { *ts << " <td>" << endl; formatCategories(ts, event); *ts << " </td>" << endl; } if (d->mSettings->eventAttendees()) { *ts << " <td>" << endl; formatAttendees(ts, event); *ts << " </td>" << endl; } *ts << " </tr>" << endl; }
//@cond PRIVATE void FreeBusy::Private::init( const Event::List &eventList, const KDateTime &start, const KDateTime &end ) { int extraDays, i, x, duration; duration = start.daysTo( end ); QDate day; KDateTime tmpStart; KDateTime tmpEnd; // Loops through every event in the calendar Event::List::ConstIterator it; for ( it = eventList.constBegin(); it != eventList.constEnd(); ++it ) { Event::Ptr event = *it; // If this event is transparent it shouldn't be in the freebusy list. if ( event->transparency() == Event::Transparent ) { continue; } // The code below can not handle all-day events. Fixing this resulted // in a lot of duplicated code. Instead, make a copy of the event and // set the period to the full day(s). This trick works for recurring, // multiday, and single day all-day events. Event::Ptr allDayEvent; if ( event->allDay() ) { // addDay event. Do the hack kDebug() << "All-day event"; allDayEvent = Event::Ptr( new Event( *event ) ); // Set the start and end times to be on midnight KDateTime st = allDayEvent->dtStart(); st.setTime( QTime( 0, 0 ) ); KDateTime nd = allDayEvent->dtEnd(); nd.setTime( QTime( 23, 59, 59, 999 ) ); allDayEvent->setAllDay( false ); allDayEvent->setDtStart( st ); allDayEvent->setDtEnd( nd ); kDebug() << "Use:" << st.toString() << "to" << nd.toString(); // Finally, use this event for the setting below event = allDayEvent; } // This whole for loop is for recurring events, it loops through // each of the days of the freebusy request for ( i = 0; i <= duration; ++i ) { day = start.addDays( i ).date(); tmpStart.setDate( day ); tmpEnd.setDate( day ); if ( event->recurs() ) { if ( event->isMultiDay() ) { // FIXME: This doesn't work for sub-daily recurrences or recurrences with // a different time than the original event. extraDays = event->dtStart().daysTo( event->dtEnd() ); for ( x = 0; x <= extraDays; ++x ) { if ( event->recursOn( day.addDays( -x ), start.timeSpec() ) ) { tmpStart.setDate( day.addDays( -x ) ); tmpStart.setTime( event->dtStart().time() ); tmpEnd = event->duration().end( tmpStart ); addLocalPeriod( q, tmpStart, tmpEnd ); break; } } } else { if ( event->recursOn( day, start.timeSpec() ) ) { tmpStart.setTime( event->dtStart().time() ); tmpEnd.setTime( event->dtEnd().time() ); addLocalPeriod ( q, tmpStart, tmpEnd ); } } } } // Non-recurring events addLocalPeriod( q, event->dtStart(), event->dtEnd() ); } q->sortList(); }