Remove infinite repeating events from future/all events list

Monotone-Parent: f4de398f76f75d98075e7f82ecc7fb9fcd5758d9
Monotone-Revision: fc8a386bb7a8ed33f9aa40e7912eb09eeba0e6cb

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2008-11-07T18:56:03
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle 2008-11-07 18:56:03 +00:00
parent b0cc837b01
commit 0d880248ba
2 changed files with 31 additions and 24 deletions

View file

@ -515,7 +515,7 @@ static Class sogoAppointmentFolderKlass = Nil;
/* prepare mandatory fields */ /* prepare mandatory fields */
sql = [[NSString stringWithFormat: @"%@%@%@%@", sql = [[NSString stringWithFormat: @"%@ %@ %@ %@",
dateSqlString, titleSqlString, componentSqlString, dateSqlString, titleSqlString, componentSqlString,
filterSqlString] substringFromIndex: 4]; filterSqlString] substringFromIndex: 4];
@ -887,6 +887,7 @@ static Class sogoAppointmentFolderKlass = Nil;
NSArray *records; NSArray *records;
NSString *sql, *dateSqlString, *titleSqlString, *componentSqlString, NSString *sql, *dateSqlString, *titleSqlString, *componentSqlString,
*privacySqlString, *currentLogin, *filterSqlString; *privacySqlString, *currentLogin, *filterSqlString;
NSCalendarDate *endDate;
NGCalendarDateRange *r; NGCalendarDateRange *r;
BOOL rememberRecords; BOOL rememberRecords;
@ -902,11 +903,15 @@ static Class sogoAppointmentFolderKlass = Nil;
return nil; return nil;
} }
if (_startDate && _endDate) if (_startDate)
{ {
if (_endDate)
endDate = _endDate;
else
endDate = [NSCalendarDate distantFuture];
r = [NGCalendarDateRange calendarDateRangeWithStartDate: _startDate r = [NGCalendarDateRange calendarDateRangeWithStartDate: _startDate
endDate: _endDate]; endDate: endDate];
dateSqlString = [self _sqlStringRangeFrom: _startDate to: _endDate]; dateSqlString = [self _sqlStringRangeFrom: _startDate to: endDate];
} }
else else
{ {
@ -937,9 +942,9 @@ static Class sogoAppointmentFolderKlass = Nil;
[fields addObjectUniquely: @"c_isallday"]; [fields addObjectUniquely: @"c_isallday"];
if (logger) if (logger)
[self debugWithFormat:@"should fetch (%@=>%@) ...", _startDate, _endDate]; [self debugWithFormat:@"should fetch (%@=>%@) ...", _startDate, endDate];
sql = [NSString stringWithFormat: @"(c_iscycle = 0)%@%@%@%@%@", sql = [NSString stringWithFormat: @"(c_iscycle = 0) %@ %@ %@ %@ %@",
dateSqlString, titleSqlString, componentSqlString, dateSqlString, titleSqlString, componentSqlString,
privacySqlString, filterSqlString]; privacySqlString, filterSqlString];
@ -957,25 +962,26 @@ static Class sogoAppointmentFolderKlass = Nil;
ma = [NSMutableArray arrayWithArray: records]; ma = [NSMutableArray arrayWithArray: records];
} }
/* fetch recurrent apts now. we do NOT consider the date range when doing that /* fetch recurrent apts now. we do NOT consider events with no cycle end. */
as the c_startdate/c_enddate of a recurring event is always set to the first if (_endDate)
recurrence - others are generated on the fly */
sql = [NSString stringWithFormat: @"(c_iscycle = 1)%@%@%@%@", titleSqlString,
componentSqlString, privacySqlString, filterSqlString];
qualifier = [EOQualifier qualifierWithQualifierFormat: sql];
records = [folder fetchFields: fields matchingQualifier: qualifier];
if (records)
{ {
if (r) sql = [NSString stringWithFormat: @"(c_iscycle = 1) %@ %@ %@ %@", titleSqlString,
records = [self fixupCyclicRecords: records fetchRange: r]; componentSqlString, privacySqlString, filterSqlString];
if (ma)
[ma addObjectsFromArray: records]; qualifier = [EOQualifier qualifierWithQualifierFormat: sql];
else
ma = [NSMutableArray arrayWithArray: records]; records = [folder fetchFields: fields matchingQualifier: qualifier];
if (records)
{
if (r)
records = [self fixupCyclicRecords: records fetchRange: r];
if (ma)
[ma addObjectsFromArray: records];
else
ma = [NSMutableArray arrayWithArray: records];
}
} }
else if (!ma) if (!ma)
{ {
[self errorWithFormat: @"(%s): fetch failed!", __PRETTY_FUNCTION__]; [self errorWithFormat: @"(%s): fetch failed!", __PRETTY_FUNCTION__];
return nil; return nil;

View file

@ -159,7 +159,7 @@ static NSArray *tasksFields = nil;
newDate = [NSCalendarDate calendarDate]; newDate = [NSCalendarDate calendarDate];
[newDate setTimeZone: userTZ]; [newDate setTimeZone: userTZ];
startDate = [newDate beginOfDay]; startDate = [newDate beginOfDay];
endDate = [NSCalendarDate distantFuture]; endDate = nil;
} }
else if ([popupValue isEqualToString: @"view_selectedday"]) else if ([popupValue isEqualToString: @"view_selectedday"])
{ {
@ -313,6 +313,7 @@ static NSArray *tasksFields = nil;
NSString *formattedDate; NSString *formattedDate;
date = [NSCalendarDate dateWithTimeIntervalSince1970: seconds]; date = [NSCalendarDate dateWithTimeIntervalSince1970: seconds];
// Adjust for daylight saving time? (wrt to startDate)
[date setTimeZone: userTimeZone]; [date setTimeZone: userTimeZone];
if (forAllDay) if (forAllDay)
formattedDate = [dateFormatter formattedDate: date]; formattedDate = [dateFormatter formattedDate: date];