Commit 8b351124 authored by Sergio Martins's avatar Sergio Martins
Browse files

Don't filter out journals.

OccurrenceIterator is also used for non-recurring incidences, which
technically have 1 occurrence.

So journals, although not being recurring were being filtered out here
and not appearing in month view.

BUG: 324971
parent 910b39f8
......@@ -188,8 +188,22 @@ OccurrenceIterator::OccurrenceIterator( const Calendar &calendar,
calendar.filter()->apply( &todos );
}
Journal::List journals;
const Journal::List allJournals = calendar.rawJournals();
foreach ( const KCalCore::Journal::Ptr &journal, allJournals ) {
const QDate journalStart = journal->dtStart().toTimeSpec( start.timeSpec() ).date();
if ( journal->dtStart().isValid() &&
journalStart >= start.date() &&
journalStart <= end.date() )
journals << journal;
}
if ( calendar.filter() ) {
calendar.filter()->apply( &journals );
}
const Incidence::List incidences =
KCalCore::Calendar::mergeIncidenceList( events, todos, Journal::List() );
KCalCore::Calendar::mergeIncidenceList( events, todos, journals );
d->setupIterator( calendar, incidences );
}
......
......@@ -253,3 +253,26 @@ void TestOccurrenceIterator::testSubDailyRecurrences()
QCOMPARE(expectedEventOccurrences.size(), 0);
}
void TestOccurrenceIterator::testJournals()
{
KCalCore::MemoryCalendar calendar( KDateTime::UTC );
const KDateTime today = KDateTime::currentDateTime( KDateTime::UTC );
const KDateTime yesterday = today.addDays( -1 );
const KDateTime tomorrow = today.addDays( 1 );
KCalCore::Journal::Ptr journal( new KCalCore::Journal() );
journal->setUid( "journal" );
journal->setDtStart( today );
calendar.addJournal( journal );
KCalCore::OccurrenceIterator rIt( calendar, yesterday, tomorrow );
QVERIFY( rIt.hasNext() );
rIt.next();
QCOMPARE( rIt.occurrenceStartDate(), today);
QVERIFY( !rIt.hasNext() );
KCalCore::OccurrenceIterator rIt2( calendar, tomorrow, tomorrow.addDays( 1 ) );
QVERIFY( !rIt2.hasNext() );
}
......@@ -29,6 +29,7 @@ class TestOccurrenceIterator: public QObject
void testAllDayEvents();
void testWithExceptionThisAndFuture();
void testSubDailyRecurrences();
void testJournals();
};
#endif // TESTOCCURRENCEITERATOR_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment