mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-06 22:08:51 +00:00
Monotone-Parent: b8fd5dfd59140030da4818862fa172e77f0d50fb
Monotone-Revision: ed6bb8dbb9400c9327fb86fd4e43cbc306ad95d5 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-08-24T18:56:24 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2006-08-24 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/Scheduler/UIxCalDayTable.[hm]: new class module/component
|
||||
used by UIxCalDayView and UIxCalWeekView to display the events
|
||||
occuring in one or more days.
|
||||
|
||||
2006-08-22 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/Scheduler/UIxCalMainView.m: extended class to populate the
|
||||
|
||||
65
UI/Scheduler/UIxCalDayTable.h
Normal file
65
UI/Scheduler/UIxCalDayTable.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* UIxCalDayTable.h - this file is part of $PROJECT_NAME_HERE$
|
||||
*
|
||||
* Copyright (C) 2006 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef UIXCALDAYTABLE_H
|
||||
#define UIXCALDAYTABLE_H
|
||||
|
||||
#import "UIxCalView.h"
|
||||
|
||||
@class NSArray;
|
||||
@class NSCalendarDay;
|
||||
@class NSString;
|
||||
@class SOGoDateFormatter;
|
||||
|
||||
@interface UIxCalDayTable : UIxCalView
|
||||
{
|
||||
int numberOfDays;
|
||||
NSCalendarDate *startDate;
|
||||
NSCalendarDate *currentTableDay;
|
||||
NSString *currentTableHour;
|
||||
NSArray *daysToDisplay;
|
||||
NSMutableArray *hoursToDisplay;
|
||||
SOGoDateFormatter *dateFormatter;
|
||||
|
||||
NSString *cssClass;
|
||||
NSString *cssId;
|
||||
}
|
||||
|
||||
- (void) setCSSClass: (NSString *) aCssClass;
|
||||
- (NSString *) cssClass;
|
||||
|
||||
- (void) setCSSId: (NSString *) aCssId;
|
||||
- (NSString *) cssId;
|
||||
|
||||
- (void) setNumberOfDays: (NSString *) aNumber;
|
||||
|
||||
- (void) setStartDate: (NSCalendarDate *) aStartDate;
|
||||
- (NSCalendarDate *) startDate;
|
||||
- (NSCalendarDate *) endDate;
|
||||
|
||||
- (NSArray *) daysToDisplay;
|
||||
- (void) setCurrentTableDay: (NSCalendarDate *) aTableDay;
|
||||
- (NSCalendarDate *) currentTableDay;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* UIXCALDAYTABLE_H */
|
||||
211
UI/Scheduler/UIxCalDayTable.m
Normal file
211
UI/Scheduler/UIxCalDayTable.m
Normal file
@@ -0,0 +1,211 @@
|
||||
/* UIxCalDayTable.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2006 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSKeyValueCoding.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <EOControl/EOQualifier.h>
|
||||
|
||||
#import <NGExtensions/NSCalendarDate+misc.h>
|
||||
#import <SOGoUI/SOGoDateFormatter.h>
|
||||
|
||||
#import "UIxCalDayTable.h"
|
||||
|
||||
@class SOGoAppointment;
|
||||
|
||||
@implementation UIxCalDayTable
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
daysToDisplay = nil;
|
||||
hoursToDisplay = nil;
|
||||
numberOfDays = 1;
|
||||
startDate = nil;
|
||||
currentTableDay = nil;
|
||||
currentTableHour = nil;
|
||||
dateFormatter = [[SOGoDateFormatter alloc]
|
||||
initWithLocale: [self locale]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[dateFormatter release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setCSSClass: (NSString *) aCssClass
|
||||
{
|
||||
cssClass = aCssClass;
|
||||
}
|
||||
|
||||
- (NSString *) cssClass
|
||||
{
|
||||
return cssClass;
|
||||
}
|
||||
|
||||
- (void) setCSSId: (NSString *) aCssId
|
||||
{
|
||||
cssId = aCssId;
|
||||
}
|
||||
|
||||
- (NSString *) cssId
|
||||
{
|
||||
return cssId;
|
||||
}
|
||||
|
||||
- (void) setNumberOfDays: (NSString *) aNumber
|
||||
{
|
||||
numberOfDays = [aNumber intValue];
|
||||
}
|
||||
|
||||
- (void) setStartDate: (NSCalendarDate *) aStartDate
|
||||
{
|
||||
startDate = aStartDate;
|
||||
}
|
||||
|
||||
- (NSCalendarDate *) startDate
|
||||
{
|
||||
if (!startDate)
|
||||
startDate = [super startDate];
|
||||
|
||||
return [startDate beginOfDay];
|
||||
}
|
||||
|
||||
- (NSCalendarDate *) endDate
|
||||
{
|
||||
NSCalendarDate *endDate;
|
||||
|
||||
endDate = [[self startDate] dateByAddingYears: 0
|
||||
months: 0
|
||||
days: numberOfDays - 1];
|
||||
|
||||
return [endDate endOfDay];
|
||||
}
|
||||
|
||||
- (NSArray *) hoursToDisplay
|
||||
{
|
||||
unsigned int currentHour, lastHour;
|
||||
|
||||
if (!hoursToDisplay)
|
||||
{
|
||||
currentHour = [self dayStartHour];
|
||||
lastHour = [self dayEndHour];
|
||||
hoursToDisplay
|
||||
= [NSMutableArray arrayWithCapacity: (lastHour - currentHour)];
|
||||
|
||||
while (currentHour < lastHour)
|
||||
{
|
||||
[hoursToDisplay
|
||||
addObject: [NSString stringWithFormat: @"%d", currentHour]];
|
||||
currentHour++;
|
||||
}
|
||||
}
|
||||
|
||||
return hoursToDisplay;
|
||||
}
|
||||
|
||||
- (NSArray *) daysToDisplay
|
||||
{
|
||||
NSMutableArray *days;
|
||||
NSCalendarDate *currentDate;
|
||||
int count;
|
||||
|
||||
days = [NSMutableArray arrayWithCapacity: numberOfDays];
|
||||
currentDate = [[self startDate] hour: [currentTableHour intValue]
|
||||
minute: 0];
|
||||
[days addObject: currentDate];
|
||||
for (count = 1; count < numberOfDays; count++)
|
||||
{
|
||||
currentDate = [currentDate dateByAddingYears: 0
|
||||
months: 0
|
||||
days: 1];
|
||||
[days addObject: currentDate];
|
||||
}
|
||||
|
||||
return days;
|
||||
}
|
||||
|
||||
- (void) setCurrentTableDay: (NSCalendarDate *) aTableDay
|
||||
{
|
||||
currentTableDay = aTableDay;
|
||||
}
|
||||
|
||||
- (NSCalendarDate *) currentTableDay
|
||||
{
|
||||
return currentTableDay;
|
||||
}
|
||||
|
||||
- (void) setCurrentTableHour: (NSString *) aTableHour
|
||||
{
|
||||
currentTableHour = aTableHour;
|
||||
}
|
||||
|
||||
- (NSString *) currentTableHour
|
||||
{
|
||||
return currentTableHour;
|
||||
}
|
||||
|
||||
- (NSString *) labelForDay
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@ %@",
|
||||
[dateFormatter shortDayOfWeek: [currentTableDay dayOfWeek]],
|
||||
[dateFormatter stringForObjectValue: currentTableDay]];
|
||||
}
|
||||
|
||||
- (NSArray *) aptsForCurrentDate
|
||||
{
|
||||
NSArray *apts;
|
||||
NSMutableArray *filtered;
|
||||
unsigned i, count;
|
||||
NSCalendarDate *start, *end;
|
||||
SOGoAppointment *apt;
|
||||
NSCalendarDate *aptStartDate;
|
||||
|
||||
start = currentTableDay;
|
||||
end = [start dateByAddingYears: 0 months: 0 days: 0
|
||||
hours: 0 minutes: 59 seconds: 59];
|
||||
|
||||
apts = [self fetchCoreInfos];
|
||||
filtered = [NSMutableArray new];
|
||||
[filtered autorelease];
|
||||
|
||||
count = [apts count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
apt = [apts objectAtIndex:i];
|
||||
aptStartDate = [apt valueForKey:@"startDate"];
|
||||
if([aptStartDate isGreaterThanOrEqualTo: start]
|
||||
&& [aptStartDate isLessThan: end])
|
||||
[filtered addObject:apt];
|
||||
}
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user