QString Stringify::todoCompletedDateTime( const Todo::Ptr &todo, bool shortfmt ) { return KGlobal::locale()->formatDateTime( todo->completed().dateTime(), ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) ); }
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; }