bool CalFilter::filterIncidence( Incidence::Ptr incidence ) const { if ( !d->mEnabled ) { return true; } Todo::Ptr todo = incidence.dynamicCast<Todo>(); if ( todo ) { if ( ( d->mCriteria & HideCompletedTodos ) && todo->isCompleted() ) { // Check if completion date is suffently long ago: if ( todo->completed().addDays( d->mCompletedTimeSpan ) < KDateTime::currentUtcDateTime() ) { return false; } } if ( ( d->mCriteria & HideInactiveTodos ) && ( ( todo->hasStartDate() && KDateTime::currentUtcDateTime() < todo->dtStart() ) || todo->isCompleted() ) ) { return false; } if ( d->mCriteria & HideNoMatchingAttendeeTodos ) { bool iAmOneOfTheAttendees = false; const Attendee::List &attendees = todo->attendees(); if ( !todo->attendees().isEmpty() ) { Attendee::List::ConstIterator it; for ( it = attendees.begin(); it != attendees.end(); ++it ) { if ( d->mEmailList.contains( ( *it )->email() ) ) { iAmOneOfTheAttendees = true; break; } } } else { // no attendees, must be me only iAmOneOfTheAttendees = true; } if ( !iAmOneOfTheAttendees ) { return false; } } } if ( d->mCriteria & HideRecurring ) { if ( incidence->recurs() ) { return false; } } if ( d->mCriteria & ShowCategories ) { for ( QStringList::ConstIterator it = d->mCategoryList.constBegin(); it != d->mCategoryList.constEnd(); ++it ) { QStringList incidenceCategories = incidence->categories(); for ( QStringList::ConstIterator it2 = incidenceCategories.constBegin(); it2 != incidenceCategories.constEnd(); ++it2 ) { if ( ( *it ) == ( *it2 ) ) { return true; } } } return false; } else { for ( QStringList::ConstIterator it = d->mCategoryList.constBegin(); it != d->mCategoryList.constEnd(); ++it ) { QStringList incidenceCategories = incidence->categories(); for ( QStringList::ConstIterator it2 = incidenceCategories.constBegin(); it2 != incidenceCategories.constEnd(); ++it2 ) { if ( ( *it ) == ( *it2 ) ) { return false; } } } return true; } return true; }
void HtmlExport::createTodo(QTextStream *ts, const Todo::Ptr &todo) { qCDebug(KCALUTILS_LOG); const bool completed = todo->isCompleted(); Incidence::List relations = d->mCalendar->relations(todo->uid()); *ts << "<tr>" << endl; *ts << " <td class=\"sum"; if (completed) { *ts << "done"; } *ts << "\">" << endl; *ts << " <a name=\"" << todo->uid() << "\"></a>" << endl; *ts << " <b>" << cleanChars(todo->summary()) << "</b>" << endl; if (!todo->description().isEmpty()) { *ts << " <p>" << breakString(cleanChars(todo->description())) << "</p>" << endl; } if (relations.count()) { *ts << " <div align=\"right\"><a href=\"#sub" << todo->uid() << "\">" << i18nc("@title:column sub-to-dos of the parent to-do", "Sub-To-dos") << "</a></div>" << endl; } *ts << " </td>" << endl; *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; *ts << " " << todo->priority() << endl; *ts << " </td>" << endl; *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; *ts << " " << i18nc("@info to-do percent complete", "%1 %", todo->percentComplete()) << endl; *ts << " </td>" << endl; if (d->mSettings->taskDueDate()) { *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; if (todo->hasDueDate()) { *ts << " " << Stringify::formatDate(todo->dtDue(true)) << endl; } else { *ts << " " << endl; } *ts << " </td>" << endl; } if (d->mSettings->taskLocation()) { *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; formatLocation(ts, todo); *ts << " </td>" << endl; } if (d->mSettings->taskCategories()) { *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; formatCategories(ts, todo); *ts << " </td>" << endl; } if (d->mSettings->taskAttendees()) { *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; formatAttendees(ts, todo); *ts << " </td>" << endl; } *ts << "</tr>" << endl; }