From 1897eb9ab10eddc44d80be1fe087951b3da4a505 Mon Sep 17 00:00:00 2001 From: znek Date: Thu, 29 Jul 2004 16:23:51 +0000 Subject: [PATCH] refactoring git-svn-id: http://svn.opengroupware.org/SOGo/trunk@161 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/README | 8 +++ SOGo/UI/Scheduler/ChangeLog | 18 +++++ SOGo/UI/Scheduler/UIxCalDayOverview.m | 45 +----------- SOGo/UI/Scheduler/UIxCalDayOverview.wox | 22 ++++++ SOGo/UI/Scheduler/UIxCalDayView.h | 3 +- SOGo/UI/Scheduler/UIxCalDayView.m | 96 ++++++++++++++++++++++++- SOGo/UI/Scheduler/UIxCalMonthView.m | 8 +-- SOGo/UI/Scheduler/UIxCalView.h | 23 +++--- SOGo/UI/Scheduler/UIxCalView.m | 48 +++++++++++-- SOGo/UI/Scheduler/UIxCalWeekView.m | 5 +- 10 files changed, 202 insertions(+), 74 deletions(-) diff --git a/SOGo/README b/SOGo/README index ee66be99..83fb015c 100644 --- a/SOGo/README +++ b/SOGo/README @@ -14,3 +14,11 @@ Main contains the main server binary (.woa) and application wide objects like authenticators. UI contains the actual UI which is bound to the SoObjects as SOPE methods + + +NOTES +===== + +mapping email <-> logins +usermanager -> part of SOGoLogic + diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index 7a5247c2..fb18d88f 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,3 +1,21 @@ +2004-07-29 Marcus Mueller + + * v0.9.10 + + * UIxCalDayView.m, UIxCalWeekView.m, UIxCalMonthView.m: reversed + previous changes to -startDate/-endDate as these were wrong. + Views have to deal on their own if appointments break the + "usual" time range. Nevertheless we should never drop any + appointments! + + * UIxCalDayOverview.[wox|m]: refactored dateRanges (moved to + UIxCalDayView) and completed display of all appropriate attributes + (all day appointments, holiday info). + + * UIxCalDayView.[hm]: fixed dateRanges. + + * UIxCalView.[hm]: implemented -allDayApts and refactored some code. + 2004-07-28 Marcus Mueller * v0.9.9 diff --git a/SOGo/UI/Scheduler/UIxCalDayOverview.m b/SOGo/UI/Scheduler/UIxCalDayOverview.m index fae83bef..df44ec52 100644 --- a/SOGo/UI/Scheduler/UIxCalDayOverview.m +++ b/SOGo/UI/Scheduler/UIxCalDayOverview.m @@ -55,23 +55,6 @@ return self->currentApts; } -- (NSArray *)dateRange { - NSMutableArray *dateRange; - unsigned i, count, offset; - - offset = [self dayStartHour]; - count = [self dayEndHour] - offset; - dateRange = [[NSMutableArray alloc] initWithCapacity:count]; - for(i = 0; i < count; i++) { - NSCalendarDate *date; - - date = [[self startDate] hour:offset + i minute:0]; - [dateRange addObject:date]; - } - return [dateRange autorelease]; -} - - - (NSArray *)aptsForCurrentDate { NSArray *apts; NSMutableArray *filtered; @@ -111,30 +94,11 @@ return [filtered autorelease]; } -- (NSString *)shortTextForApt { - NSCalendarDate *startDate, *endDate; - NSString *ms; - - startDate = [[self appointment] valueForKey:@"startDate"]; - [startDate setTimeZone:[self viewTimeZone]]; - endDate = [[self appointment] valueForKey:@"endDate"]; - [endDate setTimeZone:[self viewTimeZone]]; - - ms = [NSString stringWithFormat:@"%02i:%02i %@", - [startDate hourOfDay], - [startDate minuteOfHour], - [[self appointment] valueForKey:@"title"]]; - return ms; -} - - -/* URLs */ - - (NSDictionary *)currentDateQueryParameters { NSMutableDictionary *qp; NSString *hmString; NSCalendarDate *date; - + date = [self currentDate]; hmString = [NSString stringWithFormat:@"%02d%02d", [date hourOfDay], [date minuteOfHour]]; @@ -144,11 +108,4 @@ return [qp autorelease]; } - -/* appointments */ - -- (NSArray *)appointments { - return [self fetchCoreInfos]; -} - @end diff --git a/SOGo/UI/Scheduler/UIxCalDayOverview.wox b/SOGo/UI/Scheduler/UIxCalDayOverview.wox index 1724763f..cc244e84 100644 --- a/SOGo/UI/Scheduler/UIxCalDayOverview.wox +++ b/SOGo/UI/Scheduler/UIxCalDayOverview.wox @@ -146,6 +146,28 @@ + + + + + + + + + + +
+ +
+ + + + +
+
+
diff --git a/SOGo/UI/Scheduler/UIxCalDayView.h b/SOGo/UI/Scheduler/UIxCalDayView.h index ac7d700a..8b428bea 100644 --- a/SOGo/UI/Scheduler/UIxCalDayView.h +++ b/SOGo/UI/Scheduler/UIxCalDayView.h @@ -29,9 +29,10 @@ @interface UIxCalDayView : UIxCalView { - } +- (NSArray *)dateRange; + @end #endif /* __UIxCalDayView_H_ */ diff --git a/SOGo/UI/Scheduler/UIxCalDayView.m b/SOGo/UI/Scheduler/UIxCalDayView.m index 8bf4101d..b072fafe 100644 --- a/SOGo/UI/Scheduler/UIxCalDayView.m +++ b/SOGo/UI/Scheduler/UIxCalDayView.m @@ -22,11 +22,94 @@ #import "UIxCalDayView.h" -#include +#include +#include "common.h" +@interface UIxCalDayView (PrivateAPI) +- (NSArray *)_getDatesFrom:(NSCalendarDate *)_from to:(NSCalendarDate *)_to; +@end @implementation UIxCalDayView + +- (NSArray *)dateRange { + /* default range is from dayStartHour to dayEndHour. Any values before + or after are also fine */ + + NSCalendarDate *min, *max; + NSArray *aptDateRanges; + + min = [[self startDate] hour:[self dayStartHour] minute:0]; + max = [[self startDate] hour:[self dayEndHour] minute:0]; + + aptDateRanges = [[self appointments] valueForKey:@"startDate"]; + if([aptDateRanges count] != 0) { + NSCalendarDate *d; + + aptDateRanges = [aptDateRanges sortedArrayUsingSelector:@selector(compareAscending:)]; + d = [aptDateRanges objectAtIndex:0]; + min = (NSCalendarDate *)[d earlierDate:min]; + d = [aptDateRanges objectAtIndex:[aptDateRanges count] - 1]; + max = (NSCalendarDate *)[d laterDate:max]; + } + + return [self _getDatesFrom:min to:max]; +} + +- (NSArray *)_getDatesFrom:(NSCalendarDate *)_from to:(NSCalendarDate *)_to { + NSMutableArray *dates; + unsigned i, count, offset; + + offset = [_from hourOfDay]; + count = ([_to hourOfDay] + 1) - offset; + dates = [[NSMutableArray alloc] initWithCapacity:count]; + for(i = 0; i < count; i++) { + NSCalendarDate *date; + + date = [_from hour:offset + i minute:0]; + [dates addObject:date]; + } + return [dates autorelease]; +} + + +- (NSString *)shortTextForApt { + NSCalendarDate *startDate, *endDate; + NSMutableString *aptDescr; + NSString *s; + BOOL spansRange; + id apt; + + apt = [self appointment]; + spansRange = NO; + startDate = [apt valueForKey:@"startDate"]; + [startDate setTimeZone:[self viewTimeZone]]; + endDate = [apt valueForKey:@"endDate"]; + if(endDate != nil) { + [endDate setTimeZone:[self viewTimeZone]]; + spansRange = ![endDate isEqualToDate:startDate]; + } + aptDescr = [[NSMutableString alloc] init]; + [aptDescr appendFormat:@"%02i:%02i", + [startDate hourOfDay], + [startDate minuteOfHour]]; + if(spansRange) { + [aptDescr appendFormat:@"- %02i:%02i", + [endDate hourOfDay], + [endDate minuteOfHour]]; + } + s = [apt valueForKey:@"title"]; + if(s) { + [aptDescr appendFormat:@"; %@", s]; + } + s = [apt valueForKey:@"location"]; + if(s) { + [aptDescr appendFormat:@"; %@", s]; + } + return [aptDescr autorelease]; +} + + /* URLs */ - (NSDictionary *)prevDayQueryParameters { @@ -49,10 +132,17 @@ /* fetching */ - (NSCalendarDate *)startDate { - return [[self selectedDate] hour:[self dayStartHour] minute:0]; + return [[self selectedDate] beginOfDay]; } - (NSCalendarDate *)endDate { - return [[self startDate] hour:[self dayEndHour] minute:0]; + return [[self startDate] endOfDay]; +} + + +/* appointments */ + +- (NSArray *)appointments { + return [self fetchCoreInfos]; } @end diff --git a/SOGo/UI/Scheduler/UIxCalMonthView.m b/SOGo/UI/Scheduler/UIxCalMonthView.m index d2e1f73f..352a8c23 100644 --- a/SOGo/UI/Scheduler/UIxCalMonthView.m +++ b/SOGo/UI/Scheduler/UIxCalMonthView.m @@ -8,15 +8,11 @@ @implementation UIxCalMonthView - (NSCalendarDate *)startDate { - return [[[super startDate] firstDayOfMonth] - hour:[self dayStartHour] - minute:0]; + return [[[super startDate] firstDayOfMonth] beginOfDay]; } - (NSCalendarDate *)endDate { - NSCalendarDate *startDate = [[self startDate] - hour:[self dayEndHour] - minute:0]; + NSCalendarDate *startDate = [[self startDate] endOfDay]; return [startDate dateByAddingYears:0 months:0 days:[startDate numberOfDaysInMonth] diff --git a/SOGo/UI/Scheduler/UIxCalView.h b/SOGo/UI/Scheduler/UIxCalView.h index e861a074..65a17f7c 100644 --- a/SOGo/UI/Scheduler/UIxCalView.h +++ b/SOGo/UI/Scheduler/UIxCalView.h @@ -10,6 +10,7 @@ @interface UIxCalView : UIxComponent { NSArray *appointments; + NSArray *allDayApts; id appointment; NSCalendarDate *currentDay; } @@ -17,23 +18,29 @@ /* accessors */ - (NSArray *)appointments; +- (NSArray *)allDayApts; - (id)appointment; +- (BOOL)hasDayInfo; +- (BOOL)hasHoldidayInfo; +- (BOOL)hasAllDayApts; + - (NSDictionary *)aptTypeDict; - (NSString *)aptTypeLabel; - (NSString *)aptTypeIcon; - (NSString *)shortTextForApt; - (NSString *)shortTitleForApt; +- (NSString *)appointmentViewURL; + +- (id)holidayInfo; + /* related to current day */ - (void)setCurrentDay:(NSCalendarDate *)_day; - (NSCalendarDate *)currentDay; -- (NSString *)currentDayName; -- (NSArray *)allDayApts; -- (BOOL)hasDayInfo; -- (BOOL)hasHoldidayInfo; +- (NSString *)currentDayName; /* localized */ - +/* defaults */ - (BOOL)showFullNames; - (BOOL)showAMPMDates; - (unsigned)dayStartHour; @@ -45,12 +52,6 @@ - (NSCalendarDate *)thisMonth; - (NSCalendarDate *)nextMonth; -/* URLs */ - -- (NSString *)appointmentViewURL; - -/* backend */ - /* fetching */ - (NSCalendarDate *)startDate; diff --git a/SOGo/UI/Scheduler/UIxCalView.m b/SOGo/UI/Scheduler/UIxCalView.m index 6be1a80f..0fe828b4 100644 --- a/SOGo/UI/Scheduler/UIxCalView.m +++ b/SOGo/UI/Scheduler/UIxCalView.m @@ -9,8 +9,9 @@ @implementation UIxCalView - (void)dealloc { - [self->appointment release]; [self->appointments release]; + [self->allDayApts release]; + [self->appointment release]; [self->currentDay release]; [super dealloc]; } @@ -95,16 +96,51 @@ return [self localizedNameForDayOfWeek:[self->currentDay dayOfWeek]]; } +- (id)holidayInfo { + return nil; +} + +- (NSArray *)allDayApts { + NSArray *apts; + NSMutableArray *filtered; + unsigned i, count; + + if(self->allDayApts) + return self->allDayApts; + + apts = [self appointments]; + count = [apts count]; + filtered = [[NSMutableArray alloc] initWithCapacity:3]; + for(i = 0; i < count; i++) { + id apt; + NSNumber *bv; + + apt = [apts objectAtIndex:i]; +#warning !! check if isAllDay is correct + bv = [apt valueForKey:@"isAllDay"]; + if([bv boolValue]) { + [filtered addObject:apt]; + } + } + + ASSIGN(self->allDayApts, filtered); + [filtered release]; + return self->allDayApts; +} + + +/* special appointments */ + - (BOOL)hasDayInfo { - return [self hasHoldidayInfo] || ([[self allDayApts] count] != 0); + return [self hasHoldidayInfo] || [self hasAllDayApts]; } - (BOOL)hasHoldidayInfo { - return NO; + return [self holidayInfo] != nil; } -- (NSArray *)allDayApts { - return [NSArray array]; +- (BOOL)hasAllDayApts { + return [[self allDayApts] count] != 0; } @@ -124,7 +160,7 @@ } - (unsigned)dayEndHour { - return 19; + return 18; } - (BOOL)shouldDisplayWeekend { diff --git a/SOGo/UI/Scheduler/UIxCalWeekView.m b/SOGo/UI/Scheduler/UIxCalWeekView.m index 8d224074..43303b09 100644 --- a/SOGo/UI/Scheduler/UIxCalWeekView.m +++ b/SOGo/UI/Scheduler/UIxCalWeekView.m @@ -7,14 +7,13 @@ @implementation UIxCalWeekView - (NSCalendarDate *)startDate { - return [[[super startDate] mondayOfWeek] hour:[self dayStartHour] - minute:0]; + return [[[super startDate] mondayOfWeek] beginOfDay]; } - (NSCalendarDate *)endDate { return [[[self startDate] dateByAddingYears:0 months:0 days:7 hours:0 minutes:0 seconds:0] - hour:[self dayEndHour] minute:0]; + endOfDay]; } /* URLs */ -- 2.39.5