2006-08-19 00:35:44 +02:00
|
|
|
/* UIxCalAptListView.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/NSDate.h>
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
2006-08-22 00:29:35 +02:00
|
|
|
#import <NGExtensions/NSCalendarDate+misc.h>
|
2006-08-19 00:35:44 +02:00
|
|
|
#import <Appointments/SOGoAppointmentFolder.h>
|
|
|
|
|
|
|
|
#import <SOGoUI/SOGoDateFormatter.h>
|
|
|
|
|
|
|
|
#import "UIxCalAptListView.h"
|
|
|
|
|
|
|
|
@implementation UIxCalAptListView
|
|
|
|
|
2006-08-22 00:29:35 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
startDate = nil;
|
|
|
|
endDate = nil;
|
|
|
|
}
|
2006-08-19 00:35:44 +02:00
|
|
|
|
2006-08-22 00:29:35 +02:00
|
|
|
return self;
|
|
|
|
}
|
2006-08-19 00:35:44 +02:00
|
|
|
|
|
|
|
- (void) setCurrentAppointment: (NSDictionary *) apt
|
|
|
|
{
|
|
|
|
currentAppointment = apt;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *) currentAppointment
|
|
|
|
{
|
|
|
|
return currentAppointment;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) startDate
|
|
|
|
{
|
2006-08-22 21:20:42 +02:00
|
|
|
NSCalendarDate *today;
|
2006-08-22 00:29:35 +02:00
|
|
|
NSString *filterPopup;
|
|
|
|
|
|
|
|
if (!startDate)
|
|
|
|
{
|
|
|
|
filterPopup = [self queryParameterForKey: @"filterpopup"];
|
2006-08-22 21:20:42 +02:00
|
|
|
today = [[NSCalendarDate date] beginOfDay];
|
|
|
|
if (!filterPopup || ![filterPopup length])
|
|
|
|
startDate = today;
|
|
|
|
else if ([filterPopup isEqualToString: @"view_selectedday"])
|
|
|
|
startDate = [[self selectedDate] beginOfDay];
|
|
|
|
else if ([filterPopup isEqualToString: @"view_thismonth"])
|
|
|
|
startDate = [today firstDayOfMonth];
|
|
|
|
else if ([filterPopup isEqualToString: @"view_all"])
|
2006-08-22 00:29:35 +02:00
|
|
|
startDate = [NSCalendarDate dateWithTimeIntervalSince1970: 0];
|
2006-08-22 21:20:42 +02:00
|
|
|
else
|
|
|
|
startDate = today;
|
2006-08-22 00:29:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return startDate;
|
2006-08-19 00:35:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) endDate
|
|
|
|
{
|
2006-08-22 00:29:35 +02:00
|
|
|
NSCalendarDate *today;
|
|
|
|
NSString *filterPopup;
|
|
|
|
|
|
|
|
if (!endDate)
|
|
|
|
{
|
|
|
|
filterPopup = [self queryParameterForKey: @"filterpopup"];
|
2006-08-22 21:20:42 +02:00
|
|
|
|
|
|
|
today = [[NSCalendarDate date] endOfDay];
|
|
|
|
if (!filterPopup || ![filterPopup length]
|
|
|
|
|| [filterPopup isEqualToString: @"view_today"])
|
|
|
|
endDate = today;
|
|
|
|
else if ([filterPopup isEqualToString: @"view_all"]
|
|
|
|
|| [filterPopup isEqualToString: @"view_future"])
|
2006-08-22 00:29:35 +02:00
|
|
|
endDate = [NSCalendarDate dateWithTimeIntervalSince1970: 0x7fffffff];
|
2006-08-22 21:20:42 +02:00
|
|
|
else if ([filterPopup isEqualToString: @"view_thismonth"])
|
|
|
|
endDate = [today lastDayOfMonth];
|
|
|
|
else if ([filterPopup isEqualToString: @"view_selectedday"])
|
|
|
|
endDate = [[self selectedDate] endOfDay];
|
|
|
|
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];
|
|
|
|
else
|
|
|
|
endDate = today;
|
2006-08-22 00:29:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return endDate;
|
2006-08-19 00:35:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (SOGoDateFormatter *) itemDateFormatter
|
|
|
|
{
|
|
|
|
SOGoDateFormatter *fmt;
|
|
|
|
|
|
|
|
fmt = [[SOGoDateFormatter alloc] initWithLocale: [self locale]];
|
|
|
|
[fmt autorelease];
|
|
|
|
[fmt setFullWeekdayNameAndDetails];
|
|
|
|
|
|
|
|
return fmt;
|
|
|
|
}
|
|
|
|
|
2006-08-22 00:29:35 +02:00
|
|
|
- (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;
|
|
|
|
}
|
|
|
|
|
2006-08-19 00:35:44 +02:00
|
|
|
- (NSString *) currentStartTime
|
|
|
|
{
|
|
|
|
NSCalendarDate *date;
|
|
|
|
|
|
|
|
date = [NSCalendarDate dateWithTimeIntervalSince1970:
|
|
|
|
[[currentAppointment objectForKey: @"startdate"]
|
|
|
|
intValue]];
|
2006-09-05 16:54:53 +02:00
|
|
|
[date setTimeZone: [self viewTimeZone]];
|
2006-08-19 00:35:44 +02:00
|
|
|
|
|
|
|
return [[self itemDateFormatter] stringForObjectValue: date];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) currentEndTime
|
|
|
|
{
|
|
|
|
NSCalendarDate *date;
|
|
|
|
|
|
|
|
date = [NSCalendarDate dateWithTimeIntervalSince1970:
|
|
|
|
[[currentAppointment objectForKey: @"enddate"]
|
|
|
|
intValue]];
|
2006-09-05 16:54:53 +02:00
|
|
|
[date setTimeZone: [self viewTimeZone]];
|
2006-08-19 00:35:44 +02:00
|
|
|
|
|
|
|
return [[self itemDateFormatter] stringForObjectValue: date];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) currentLocation
|
|
|
|
{
|
|
|
|
return [currentAppointment objectForKey: @"location"];
|
|
|
|
}
|
|
|
|
|
2006-08-22 21:20:42 +02:00
|
|
|
- (NSString *) currentSerialDay
|
|
|
|
{
|
|
|
|
NSCalendarDate *date;
|
|
|
|
int intDate;
|
|
|
|
|
|
|
|
intDate = [[currentAppointment objectForKey: @"startdate"] intValue];
|
|
|
|
date = [NSCalendarDate dateWithTimeIntervalSince1970: intDate];
|
|
|
|
|
|
|
|
return [NSString stringWithFormat: @"%d%.2d%.2d",
|
|
|
|
[date yearOfCommonEra],
|
|
|
|
[date monthOfYear],
|
|
|
|
[date dayOfMonth]];
|
|
|
|
}
|
|
|
|
|
2006-08-19 00:35:44 +02:00
|
|
|
@end
|