diff --git a/SOPE/NGCards/CardGroup.h b/SOPE/NGCards/CardGroup.h index 1dfb6c7ef..2ef4adc46 100644 --- a/SOPE/NGCards/CardGroup.h +++ b/SOPE/NGCards/CardGroup.h @@ -49,7 +49,7 @@ - (void) addChild: (CardElement *) aChild; - (void) addChildren: (NSArray *) someChildren; -- (NSArray *) children; +- (NSMutableArray *) children; - (CardElement *) firstChildWithTag: (NSString *) aTag; - (NSArray *) childrenWithTag: (NSString *) aTag; - (NSArray *) childrenWithAttribute: (NSString *) anAttribute diff --git a/SOPE/NGCards/CardGroup.m b/SOPE/NGCards/CardGroup.m index d1c8c2482..a608c47be 100644 --- a/SOPE/NGCards/CardGroup.m +++ b/SOPE/NGCards/CardGroup.m @@ -260,7 +260,7 @@ static NGCardsSaxHandler *sax = nil; [self addChild: currentChild]; } -- (NSArray *) children +- (NSMutableArray *) children { return children; } @@ -398,9 +398,20 @@ static NGCardsSaxHandler *sax = nil; - (id) copyWithZone: (NSZone *) aZone { CardGroup *new; + CardElement *newChild; + NSMutableArray *newChildren; + unsigned int count, max; new = [super copyWithZone: aZone]; - [new setChildrenAsCopy: [children copyWithZone: aZone]]; + newChildren = [NSMutableArray new]; + max = [children count]; + for (count = 0; count < max; count++) + { + newChild = [[children objectAtIndex: count] copyWithZone: aZone]; + [newChildren addObject: newChild]; + } + [new setChildrenAsCopy: newChildren]; + [newChildren release]; return new; } @@ -410,9 +421,21 @@ static NGCardsSaxHandler *sax = nil; - (id) mutableCopyWithZone: (NSZone *) aZone { CardGroup *new; + CardElement *newChild; + NSMutableArray *newChildren; + unsigned int count, max; new = [super mutableCopyWithZone: aZone]; - [new setChildrenAsCopy: [children mutableCopyWithZone: aZone]]; + newChildren = [NSMutableArray new]; + max = [children count]; + for (count = 0; count < max; count++) + { + newChild + = [[children objectAtIndex: count] mutableCopyWithZone: aZone]; + [newChildren addObject: newChild]; + } + [new setChildrenAsCopy: newChildren]; + [newChildren release]; return new; } diff --git a/SOPE/NGCards/ChangeLog b/SOPE/NGCards/ChangeLog index 23000a161..7e6a37822 100644 --- a/SOPE/NGCards/ChangeLog +++ b/SOPE/NGCards/ChangeLog @@ -1,3 +1,17 @@ +2008-07-17 Wolfgang Sourdeau + + * iCalRepeatableEntityObject.m ([iCalRepeatableEntityObject + -addToExceptionDates:_rdate]): the iCalDateTime argument was + replaced with NSCalendarDate. + + * iCalEntityObject.m ([iCalEntityObject + -setOrganizer:_organizer]): now accepts a nil argument. + + * CardGroup.m ([CardGroup -children]): now returns an NSMutableArray. + ([CardGroup -copyWithZone:aZone]) + ([CardGroup -mutableCopyWithZone:aZone]): the children were not + properlty cloned, we thus clone them explicitly. + 2008-07-16 Wolfgang Sourdeau * iCalDateTime.m ([iCalDateTime -setDate:dateTime]): don't set diff --git a/SOPE/NGCards/iCalEntityObject.m b/SOPE/NGCards/iCalEntityObject.m index 146f2b538..5f6ff9775 100644 --- a/SOPE/NGCards/iCalEntityObject.m +++ b/SOPE/NGCards/iCalEntityObject.m @@ -277,8 +277,13 @@ - (void) setOrganizer: (iCalPerson *) _organizer { - [_organizer setTag: @"organizer"]; - [self setUniqueChild: _organizer]; + if (_organizer) + { + [_organizer setTag: @"organizer"]; + [self setUniqueChild: _organizer]; + } + else + [children removeObjectsInArray: [self childrenWithTag: @"organizer"]]; } - (iCalPerson *) organizer diff --git a/SOPE/NGCards/iCalRecurrenceCalculator.m b/SOPE/NGCards/iCalRecurrenceCalculator.m index 66a06ec65..a30be6c74 100644 --- a/SOPE/NGCards/iCalRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalRecurrenceCalculator.m @@ -188,17 +188,19 @@ static Class yearlyCalcClass = Nil; NSEnumerator *dates; NSCalendarDate *currentDate; NGCalendarDateRange *currentRange; - int count, maxRanges; + unsigned int count, maxRanges; - maxRanges = [ranges count]; dates = [[self _dates: exdates withinRange: limits] objectEnumerator]; while ((currentDate = [dates nextObject])) - for (count = (maxRanges - 1); count > -1; count--) - { - currentRange = [ranges objectAtIndex: count]; - if ([currentRange containsDate: currentDate]) - [ranges removeObjectAtIndex: count]; - } + { + maxRanges = [ranges count]; + for (count = maxRanges; count > 0; count--) + { + currentRange = [ranges objectAtIndex: count - 1]; + if ([currentRange containsDate: currentDate]) + [ranges removeObjectAtIndex: count - 1]; + } + } } + (NSArray *) diff --git a/SOPE/NGCards/iCalRepeatableEntityObject.h b/SOPE/NGCards/iCalRepeatableEntityObject.h index fa475a01c..d89cd03ed 100644 --- a/SOPE/NGCards/iCalRepeatableEntityObject.h +++ b/SOPE/NGCards/iCalRepeatableEntityObject.h @@ -32,7 +32,7 @@ are VEVENT, VTODO and VJOURNAL. */ -@class NSMutableArray, NGCalendarDateRange; +@class NSCalendarDate, NSMutableArray, NGCalendarDateRange; @interface iCalRepeatableEntityObject : iCalEntityObject // { @@ -53,7 +53,7 @@ - (NSArray *)exceptionRules; - (void)removeAllExceptionDates; -- (void)addToExceptionDates:(id)_date; +- (void)addToExceptionDates:(NSCalendarDate *)_date; - (BOOL)hasExceptionDates; - (NSArray *)exceptionDates; diff --git a/SOPE/NGCards/iCalRepeatableEntityObject.m b/SOPE/NGCards/iCalRepeatableEntityObject.m index dc52aa950..26214f5a6 100644 --- a/SOPE/NGCards/iCalRepeatableEntityObject.m +++ b/SOPE/NGCards/iCalRepeatableEntityObject.m @@ -107,9 +107,15 @@ [children removeObjectsInArray: [self childrenWithTag: @"exdate"]]; } -- (void) addToExceptionDates: (id) _rdate +- (void) addToExceptionDates: (NSCalendarDate *) _rdate { - [self addChild: _rdate]; + iCalDateTime *dateTime; + + dateTime = [iCalDateTime new]; + [dateTime setTag: @"exdate"]; + [dateTime setDateTime: _rdate]; + [self addChild: dateTime]; + [dateTime release]; } - (void) setExceptionDates: (NSArray *) _rdates