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
23 #include "UIxCalWeekView.h"
25 @interface UIxCalWeekListview : UIxCalWeekView
37 #include <NGExtensions/NGCalendarDateRange.h>
38 #include <SOGo/AgenorUserManager.h>
39 #include <SOGoUI/SOGoAptFormatter.h>
40 #include "SoObjects/Appointments/SOGoAppointmentFolder.h"
42 @implementation UIxCalWeekListview
46 [self->currentUid release];
52 /* NOTE: this fetches coreInfos instead of overviewInfos
53 * as is done in the superclass!
55 - (NSArray *)fetchCoreInfos {
56 if (!self->appointments) {
58 NSCalendarDate *sd, *ed;
60 folder = [self clientObject];
61 sd = [self startDate];
63 [self setAppointments:[folder fetchCoreInfosFrom:sd to:ed]];
65 return self->appointments;
72 self->uids = [[[[self clientObject] calendarUIDs]
73 sortedArrayUsingSelector:@selector(compareAscending:)]
79 - (void)setCurrentUid:(id)_currentUid {
80 ASSIGN(self->currentUid, _currentUid);
83 return self->currentUid;
86 /* column corresponds to the current day/hour */
87 - (void)setColumn:(int)_column {
88 unsigned dayOfWeek, hour;
91 dayOfWeek = _column / [self columnsPerDay];
92 hour = _column % [self columnsPerDay];
94 date = [[self startDate] dateByAddingYears:0 months:0 days:dayOfWeek];
95 date = [date hour:hour minute:0];
96 /* let's reuse currentDay, although this isn't named too accurately */
97 [self setCurrentDay:date];
98 self->column = _column;
106 - (int)columnsPerDay {
110 - (NSArray *)columns {
111 static NSMutableArray *columns = nil;
116 if([self shouldDisplayWeekend])
117 count = [self columnsPerDay] * 7;
119 count = [self columnsPerDay] * 5;
121 columns = [[NSMutableArray alloc] initWithCapacity:count];
122 for(i = 0; i < count; i++) {
123 [columns addObject:[NSNumber numberWithInt:i]];
131 /* row is active, if currentUid is participant of apt */
132 - (BOOL)isRowActive {
133 AgenorUserManager *um;
135 NSString *currentMail;
137 um = [AgenorUserManager sharedUserManager];
138 currentMail = [um getEmailForUID:self->currentUid];
139 mailChunk = [self->appointment valueForKey:@"partmails"];
140 if([mailChunk rangeOfString:currentMail].length > 0)
145 /* item is active, if apt's dateRange intersects the range
146 of the current column (currentDay is set to be this date) */
147 - (BOOL)isItemActive {
148 NSCalendarDate *dateStart, *dateEnd, *aptStart, *aptEnd;
149 NGCalendarDateRange *dateRange, *aptRange;
151 dateStart = [self currentDay];
152 dateEnd = [dateStart dateByAddingYears:0 months:0 days:0
153 hours:1 minutes:0 seconds:0];
154 dateRange = [NGCalendarDateRange calendarDateRangeWithStartDate:dateStart
156 aptStart = [self->appointment valueForKey:@"startDate"];
157 aptEnd = [self->appointment valueForKey:@"endDate"];
158 aptRange = [NGCalendarDateRange calendarDateRangeWithStartDate:aptStart
160 return [dateRange doesIntersectWithDateRange:aptRange];
165 - (void)configureFormatters {
166 [super configureFormatters];
167 [self->aptFormatter setTitleOnly];
168 [self->privateAptFormatter setPrivateTitleOnly];
171 - (NSString *)cnForCurrentUid {
172 return [[AgenorUserManager sharedUserManager] getCNForUID:self->currentUid];
177 - (NSString *)titleStyle {
178 if([self->currentDay isToday])
179 return @"weekoverview_title_hilite";
180 return @"weekoverview_title";
183 @end /* UIxCalWeekListview */