2 Copyright (C) 2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include "UIxCalDayOverview.h"
26 #include <SOGoUI/SOGoAptFormatter.h>
28 @implementation UIxCalDayOverview
31 [self->currentApts release];
35 - (void)setCurrentApts:(NSArray *)_apts {
36 ASSIGN(self->currentApts, _apts);
38 - (NSArray *)currentApts {
39 return self->currentApts;
42 - (int)minRequiredRowSpan {
43 unsigned count = [[self aptsForCurrentDate] count];
44 return count == 0 ? 1 : count;
49 - (void)configureFormatters {
50 [super configureFormatters];
52 [self->aptFormatter setSingleLineFullDetails];
53 [self->aptTooltipFormatter setTooltip];
56 - (NSArray *)aptsForCurrentDate {
58 NSMutableArray *filtered;
60 NSCalendarDate *start, *end;
62 start = self->currentDate;
63 end = [start dateByAddingYears:0
70 apts = [self appointments];
71 filtered = [[NSMutableArray alloc] initWithCapacity:1];
73 for (i = 0; i < count; i++) {
75 NSCalendarDate *aptStartDate;
77 apt = [apts objectAtIndex:i];
78 aptStartDate = [apt valueForKey:@"startDate"];
79 if([aptStartDate isGreaterThanOrEqualTo:start] &&
80 [aptStartDate isLessThan:end])
82 [filtered addObject:apt];
86 return [filtered autorelease];
89 - (NSArray *)allDayApts {
90 NSCalendarDate *start;
92 NSMutableArray *filtered;
96 return self->allDayApts;
98 start = [self startDate];
99 apts = [self appointments];
100 filtered = [[NSMutableArray alloc] initWithCapacity:1];
101 count = [apts count];
102 for (i = 0; i < count; i++) {
106 apt = [apts objectAtIndex:i];
107 bv = [apt valueForKey:@"isallday"];
108 if ([bv boolValue]) {
109 [filtered addObject:apt];
112 NSCalendarDate *aptStartDate;
114 aptStartDate = [apt valueForKey:@"startDate"];
115 if([aptStartDate isLessThan:start]) {
116 [filtered addObject:apt];
121 ASSIGN(self->allDayApts, filtered);
123 return self->allDayApts;