diff --git a/ChangeLog b/ChangeLog index bbbb7564d..9eb69ccc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-08-21 Wolfgang Sourdeau + * UI/Scheduler/UIxCalAptListView.m ([UIxCalAptListView -startDate]) + ([UIxCalAptListView -endDate]): return the required dates needed + depending on the value given to the "filterpopup" url parameter. + * UI/Common/UIxToolbar.m ([UIxToolbar -buttonLabel]): reduced the code by invoking UIxComponent's labelForKey:. diff --git a/UI/Scheduler/UIxCalAptListView.h b/UI/Scheduler/UIxCalAptListView.h index 949ed3469..b2205239f 100644 --- a/UI/Scheduler/UIxCalAptListView.h +++ b/UI/Scheduler/UIxCalAptListView.h @@ -29,6 +29,9 @@ @interface UIxCalAptListView : UIxCalView { + NSCalendarDate *startDate; + NSCalendarDate *endDate; + NSDictionary *currentAppointment; } diff --git a/UI/Scheduler/UIxCalAptListView.m b/UI/Scheduler/UIxCalAptListView.m index 365933652..58a09a23b 100644 --- a/UI/Scheduler/UIxCalAptListView.m +++ b/UI/Scheduler/UIxCalAptListView.m @@ -24,6 +24,7 @@ #import #import +#import #import #import @@ -32,15 +33,16 @@ @implementation UIxCalAptListView -// - (id) init -// { -// if ((self = [super init])) -// { -// allAppointments = nil; -// } +- (id) init +{ + if ((self = [super init])) + { + startDate = nil; + endDate = nil; + } -// return self; -// } + return self; +} - (void) setCurrentAppointment: (NSDictionary *) apt { @@ -52,14 +54,81 @@ return currentAppointment; } +// @"view_all", nil, +// @"view_today", @"flags = 'seen' AND NOT (flags = 'deleted')", +// @"view_next7", @"flags = 'unseen' AND NOT (flags = 'deleted')", +// @"view_next14", @"flags = 'deleted'", +// @"view_next31", @"flags = 'flagged'", +// @"view_thismonth", @"flags = 'flagged'", +// @"view_future", @"flags = 'flagged'", +// @"view_selectedday", @"flags = 'flagged'", + +// - (NSCalendarDate *)firstDayOfMonth; +// - (NSCalendarDate *)lastDayOfMonth; + - (NSCalendarDate *) startDate { - return [NSCalendarDate dateWithTimeIntervalSince1970: 0]; + NSString *filterPopup; + + if (!startDate) + { + filterPopup = [self queryParameterForKey: @"filterpopup"]; + if (filterPopup + && [filterPopup length] > 0 + && ![filterPopup isEqualToString: @"view_all"]) + { + if ([filterPopup isEqualToString: @"view_thismonth"]) + startDate = [[NSCalendarDate date] firstDayOfMonth]; + else if ([filterPopup isEqualToString: @"view_selectedday"]) + startDate = [self selectedDate]; + else + startDate = [NSCalendarDate date]; + startDate = [startDate beginOfDay]; + } + else + startDate = [NSCalendarDate dateWithTimeIntervalSince1970: 0]; + } + + return startDate; } - (NSCalendarDate *) endDate { - return [NSCalendarDate dateWithTimeIntervalSince1970: 0x7fffffff]; + NSCalendarDate *today; + NSString *filterPopup; + + if (!endDate) + { + filterPopup = [self queryParameterForKey: @"filterpopup"]; + if (filterPopup + && [filterPopup length] > 0 + && ![filterPopup isEqualToString: @"view_all"] + && ![filterPopup isEqualToString: @"view_future"]) + { + if ([filterPopup isEqualToString: @"view_thismonth"]) + endDate = [[NSCalendarDate date] lastDayOfMonth]; + else if ([filterPopup isEqualToString: @"view_selectedday"]) + endDate = [self selectedDate]; + else + { + today = [NSCalendarDate date]; + if ([filterPopup isEqualToString: @"view_today"]) + endDate = today; + else if ([filterPopup isEqualToString: @"view_next7"]) + endDate = [today dateByAddingYears: 0 months: 0 days: 7]; + else if ([filterPopup isEqualToString: @"view_next14"]) + endDate = [today dateByAddingYears: 0 months: 0 days: 14]; + else if ([filterPopup isEqualToString: @"view_next31"]) + endDate = [today dateByAddingYears: 0 months: 1 days: 0]; + } + + endDate = [endDate endOfDay]; + } + else + endDate = [NSCalendarDate dateWithTimeIntervalSince1970: 0x7fffffff]; + } + + return endDate; } - (SOGoDateFormatter *) itemDateFormatter @@ -73,6 +142,21 @@ return fmt; } +- (NSString *) currentTitle +{ + NSString *fullTitle, *title; + + fullTitle = [currentAppointment objectForKey: @"title"]; + if ([fullTitle length] > 49) + title = [NSString stringWithFormat: @"%@...", + [[currentAppointment objectForKey: @"title"] + substringToIndex: 50]]; + else + title = fullTitle; + + return title; +} + - (NSString *) currentStartTime { NSCalendarDate *date;