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
maint-2.0.2
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 */
sql = [[NSString stringWithFormat: @"%@%@%@%@",
sql = [[NSString stringWithFormat: @"%@ %@ %@ %@",
dateSqlString, titleSqlString, componentSqlString,
filterSqlString] substringFromIndex: 4];
@ -887,6 +887,7 @@ static Class sogoAppointmentFolderKlass = Nil;
NSArray *records;
NSString *sql, *dateSqlString, *titleSqlString, *componentSqlString,
*privacySqlString, *currentLogin, *filterSqlString;
NSCalendarDate *endDate;
NGCalendarDateRange *r;
BOOL rememberRecords;
@ -902,11 +903,15 @@ static Class sogoAppointmentFolderKlass = Nil;
return nil;
}
if (_startDate && _endDate)
if (_startDate)
{
if (_endDate)
endDate = _endDate;
else
endDate = [NSCalendarDate distantFuture];
r = [NGCalendarDateRange calendarDateRangeWithStartDate: _startDate
endDate: _endDate];
dateSqlString = [self _sqlStringRangeFrom: _startDate to: _endDate];
endDate: endDate];
dateSqlString = [self _sqlStringRangeFrom: _startDate to: endDate];
}
else
{
@ -937,9 +942,9 @@ static Class sogoAppointmentFolderKlass = Nil;
[fields addObjectUniquely: @"c_isallday"];
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,
privacySqlString, filterSqlString];
@ -957,25 +962,26 @@ static Class sogoAppointmentFolderKlass = Nil;
ma = [NSMutableArray arrayWithArray: records];
}
/* fetch recurrent apts now. we do NOT consider the date range when doing that
as the c_startdate/c_enddate of a recurring event is always set to the first
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)
/* fetch recurrent apts now. we do NOT consider events with no cycle end. */
if (_endDate)
{
if (r)
records = [self fixupCyclicRecords: records fetchRange: r];
if (ma)
[ma addObjectsFromArray: records];
else
ma = [NSMutableArray arrayWithArray: records];
sql = [NSString stringWithFormat: @"(c_iscycle = 1) %@ %@ %@ %@", titleSqlString,
componentSqlString, privacySqlString, filterSqlString];
qualifier = [EOQualifier qualifierWithQualifierFormat: sql];
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__];
return nil;

View File

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