1 /* UIxCalTasksListView.m - this file is part of SOGo
3 * Copyright (C) 2006 Inverse groupe conseil
5 * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
7 * This file is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This file is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #import <Foundation/NSDate.h>
24 #import <Foundation/NSDictionary.h>
25 #import <Foundation/NSString.h>
26 #import <Foundation/NSValue.h>
28 #import <NGExtensions/NSCalendarDate+misc.h>
29 #import <Appointments/SOGoAppointmentFolder.h>
30 #import <SOGoUI/SOGoDateFormatter.h>
32 #import "UIxCalTasksListView.h"
34 @implementation UIxCalTasksListView
38 if ((self = [super init]))
49 - (void) setCurrentTask: (NSDictionary *) task
54 - (NSDictionary *) currentTask
59 - (NSCalendarDate *) startDate
64 - (NSCalendarDate *) endDate
69 - (NSString *) currentStatusClass
71 NSCalendarDate *taskDate, *now;
72 NSString *statusClass, *allClasses;
73 NSNumber *taskDueStamp;
75 if ([[currentTask objectForKey: @"status"] intValue] == 1)
76 statusClass = @"completed";
79 taskDueStamp = [currentTask objectForKey: @"enddate"];
80 if ([taskDueStamp intValue])
82 now = [NSCalendarDate calendarDate];
83 taskDate = [NSCalendarDate dateWithTimeIntervalSince1970:
84 [taskDueStamp intValue]];
85 if ([taskDate earlierDate: now] == taskDate)
86 statusClass = @"overdue";
89 if ([taskDate isToday])
90 statusClass = @"duetoday";
92 statusClass = @"duelater";
96 statusClass = @"duelater";
99 allClasses = [NSString stringWithFormat: @"%@ ownerIs%@",
101 [currentTask objectForKey: @"owner"]];
106 - (BOOL) shouldDisplayCurrentTask
111 = [[self queryParameterForKey: @"show-completed"] intValue];
115 return ([[currentTask objectForKey: @"status"] intValue] != 1
119 - (BOOL) shouldShowCompletedTasks
124 = [[self queryParameterForKey: @"show-completed"] intValue];
128 return showCompleted;
131 - (BOOL) isCurrentTaskCompleted
133 return ([[currentTask objectForKey: @"status"] intValue] == 1);