]> err.no Git - scalable-opengroupware.org/blob - SOPE/NGCards/iCalToDo.m
e5e2c0a1fa48341c3ee554614d4c60c6b525903f
[scalable-opengroupware.org] / SOPE / NGCards / iCalToDo.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE 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
9   later version.
10
11   SOPE 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.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #import <Foundation/NSString.h>
23
24 #import "NSCalendarDate+NGCards.h"
25 #import "CardGroup+iCal.h"
26
27 #import "iCalDateTime.h"
28 #import "iCalToDo.h"
29
30 @implementation iCalToDo
31
32 - (Class) classForTag: (NSString *) classTag
33 {
34   Class tagClass;
35
36   if ([classTag isEqualToString: @"DUE"]
37       || [classTag isEqualToString: @"COMPLETED"])
38     tagClass = [iCalDateTime class];
39   else if ([classTag isEqualToString: @"PERCENT-COMPLETE"])
40     tagClass = [CardElement class];
41   else
42     tagClass = [super classForTag: classTag];
43
44   return tagClass;
45 }
46
47 /* accessors */
48
49 - (void) setPercentComplete: (NSString *) _value
50 {
51   [[self uniqueChildWithTag: @"percent-complete"] setValue: 0
52                                                   to: _value];
53 }
54
55 - (NSString *) percentComplete
56 {
57   return [[self uniqueChildWithTag: @"percent-complete"] value: 0];
58 }
59
60 - (void) setDue: (NSCalendarDate *) _date
61 {
62   [self setDate: _date
63         forDateTimeValue: @"due"];
64 }
65
66 - (NSCalendarDate *) due
67 {
68   return [self dateForDateTimeValue: @"due"];
69 //   return [[self uniqueChildWithTag: @"percent-complete"] asCalendarDate];
70 }
71
72 - (void) setCompleted: (NSCalendarDate *) _date
73 {
74   [self setStatus: @"COMPLETED"];
75   [self setDate: _date forDateTimeValue: @"completed"];
76 }
77
78 - (NSCalendarDate *) completed
79 {
80   return [self dateForDateTimeValue: @"completed"];
81 }
82
83 /* ical typing */
84
85 - (NSString *) entityName
86 {
87   return @"vtodo";
88 }
89
90 // /* descriptions */
91
92 // - (NSString *)description {
93 //   NSMutableString *ms;
94
95 //   ms = [NSMutableString stringWithCapacity:128];
96 //   [ms appendFormat:@"<0x%p[%@]:", self, NSStringFromClass([self class])];
97
98 //   if (uid)       [ms appendFormat:@" uid=%@", uid];
99 //   if (startDate) [ms appendFormat:@" start=%@", startDate];
100 //   if (due)       [ms appendFormat:@" due=%@", due];
101 //   if (priority)  [ms appendFormat:@" pri=%@", priority];
102
103 //   if (completed) 
104 //     [ms appendFormat:@" completed=%@", completed];
105 //   if (percentComplete) 
106 //     [ms appendFormat:@" complete=%@", percentComplete];
107 //   if (accessClass) 
108 //     [ms appendFormat:@" class=%@", accessClass];
109   
110 //   if (summary)
111 //     [ms appendFormat:@" summary=%@", summary];
112
113 //   [ms appendString:@">"];
114 //   return ms;
115 // }
116
117 @end /* iCalToDo */