2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo 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
11 OGo 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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "UIxMailTreeBlock.h"
25 @implementation UIxMailTreeBlock
27 id UIxMailTreeHasChildrenMarker = nil;
30 // TODO: needs to be an array because the WETreeView requires a
32 UIxMailTreeHasChildrenMarker =
33 [[NSArray alloc] initWithObjects:@"FAKE", nil];
36 + (id)blockWithName:(NSString *)_name title:(NSString *)_title
37 iconName:(NSString *)_icon
38 link:(NSString *)_link isPathNode:(BOOL)_isPath isActiveNode:(BOOL)_isActive
39 childBlocks:(NSArray *)_blocks
41 UIxMailTreeBlock *block;
43 block = [[self alloc] initWithName:_name title:_title iconName:_icon
45 isPathNode:_isPath isActiveNode:_isActive
47 return [block autorelease];
50 - (id)initWithName:(NSString *)_name title:(NSString *)_title
51 iconName:(NSString *)_icon
52 link:(NSString *)_link isPathNode:(BOOL)_isPath isActiveNode:(BOOL)_isActive
53 childBlocks:(NSArray *)_blocks
55 if ((self = [self init])) {
56 self->name = [_name copy];
57 self->title = [_title copy];
58 self->iconName = [_icon copy];
59 self->link = [_link copy];
60 self->blocks = [_blocks retain];
62 self->flags.isPath = _isPath ? 1 : 0;
63 self->flags.isActive = _isActive ? 1 : 0;
69 [self->iconName release];
70 [self->blocks release];
72 [self->title release];
88 - (NSString *)iconName {
89 return self->iconName;
93 if (self->blocks == UIxMailTreeHasChildrenMarker)
95 return [self->blocks count] > 0 ? YES : NO;
98 - (BOOL)areChildrenLoaded {
99 return self->blocks != UIxMailTreeHasChildrenMarker ? YES : NO;
102 - (NSArray *)children {
103 if (self->blocks == UIxMailTreeHasChildrenMarker)
104 // TODO: print a warning
111 return self->flags.isPath ? YES : NO;
113 - (BOOL)isActiveNode {
114 return self->flags.isActive ? YES : NO;
119 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
120 if (self->name != nil) [_ms appendFormat:@" name='%@'", self->name];
121 if (self->title != nil) [_ms appendFormat:@" title='%@'", self->title];
123 if ([self isPathNode]) [_ms appendString:@" path"];
124 if ([self isActiveNode]) [_ms appendString:@" active"];
126 if (self->blocks == UIxMailTreeHasChildrenMarker)
127 [_ms appendString:@" has-children"];
128 else if ([self->blocks count] > 0)
129 [_ms appendFormat:@" children=%@", self->blocks];
132 - (NSString *)description {
135 ms = [NSMutableString stringWithCapacity:64];
136 [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
137 [self appendAttributesToDescription:ms];
138 [ms appendString:@">"];
142 @end /* UIxMailTreeBlock */