return link;
}
-- (NSString *)titleForObject:(id)_object {
+- (void)getTitle:(NSString **)_t andIcon:(NSString **)_icon
+ forObject:(id)_object
+{
// TODO: need to refactor for reuse!
NSString *ftype;
unsigned len;
ftype = [_object valueForKey:@"outlookFolderClass"];
len = [ftype length];
-
+
switch (len) {
case 8:
- if ([ftype isEqualToString:@"IPF.Sent"])
- return [self labelForKey:@"SentFolderName"];
+ if ([ftype isEqualToString:@"IPF.Sent"]) {
+ *_t = [self labelForKey:@"SentFolderName"];
+ *_icon = @"tbtv_sent_17x17.gif";
+ return;
+ }
break;
case 9:
- if ([ftype isEqualToString:@"IPF.Inbox"])
- return [self labelForKey:@"InboxFolderName"];
- if ([ftype isEqualToString:@"IPF.Trash"])
- return [self labelForKey:@"TrashFolderName"];
+ if ([ftype isEqualToString:@"IPF.Inbox"]) {
+ *_t = [self labelForKey:@"InboxFolderName"];
+ *_icon = @"tbtv_inbox_17x17.gif";
+ return;
+ }
+ if ([ftype isEqualToString:@"IPF.Trash"]) {
+ *_t = [self labelForKey:@"TrashFolderName"];
+ *_icon = @"tbtv_trash_17x17.gif";
+ return;
+ }
break;
case 10:
- if ([ftype isEqualToString:@"IPF.Drafts"])
- return [self labelForKey:@"DraftsFolderName"];
- if ([ftype isEqualToString:@"IPF.Filter"])
- return [self labelForKey:@"SieveFolderName"];
+ if ([ftype isEqualToString:@"IPF.Drafts"]) {
+ *_t = [self labelForKey:@"DraftsFolderName"];
+ *_icon = @"tbtv_drafts_17x17.gif";
+ return;
+ }
+ if ([ftype isEqualToString:@"IPF.Filter"]) {
+ *_t = [self labelForKey:@"SieveFolderName"];
+ *_icon = nil;
+ return;
+ }
+ break;
}
- return [_object davDisplayName];
+ *_t = [_object davDisplayName];
+ *_icon = nil;
+ return;
}
- (UIxMailTreeBlock *)treeNavigationBlockForLeafNode:(id)_o atDepth:(int)_d {
UIxMailTreeBlock *md;
+ NSString *n, *i;
id blocks;
/*
blocks = [[_o toManyRelationshipKeys] count] > 0
? [[NSArray alloc] initWithObjects:@"FAKE", nil]
: nil;
+
+ [self getTitle:&n andIcon:&i forObject:_o];
md = [UIxMailTreeBlock blockWithName:nil
- title:[self titleForObject:_o]
+ title:n iconName:i
link:[self treeNavigationLinkForObject:_o atDepth:_d]
isPathNode:NO isActiveNode:NO
childBlocks:blocks];
UIxMailTreeBlock *md;
NSMutableArray *blocks;
NSArray *folders;
+ NSString *title, *icon;
unsigned i, count;
/* process child folders */
/* build block */
+ [self getTitle:&title andIcon:&icon forObject:_object];
md = [UIxMailTreeBlock blockWithName:[_object nameInContainer]
- title:[self titleForObject:_object]
+ title:title iconName:icon
link:[@"../" stringByAppendingString:
[_object nameInContainer]]
isPathNode:YES isActiveNode:YES
UIxMailTreeBlock *md;
NSMutableArray *blocks;
NSArray *folders;
+ NSString *title, *icon;
unsigned i, count;
// TODO: maybe we can join the two implementations, this might not be
/* build block */
+ [self getTitle:&title andIcon:&icon forObject:_object];
md = [UIxMailTreeBlock blockWithName:[_object nameInContainer]
- title:[self titleForObject:_object]
+ title:title iconName:icon
link:@"."
isPathNode:YES isActiveNode:YES
childBlocks:blocks];
NSMutableArray *blocks;
NSString *activeName;
NSArray *folders;
+ NSString *title, *icon;
unsigned i, count;
if ([self isRootObject:_object]) /* we are at the top */
/* build block */
+ [self getTitle:&title andIcon:&icon forObject:_object];
md = [UIxMailTreeBlock blockWithName:[_object nameInContainer]
- title:[self titleForObject:_object]
+ title:title iconName:icon
link:[self treeNavigationLinkForObject:_object
atDepth:(_depth + 1)]
isPathNode:YES isActiveNode:NO
@implementation UIxMailTreeBlock
+ (id)blockWithName:(NSString *)_name title:(NSString *)_title
+ iconName:(NSString *)_icon
link:(NSString *)_link isPathNode:(BOOL)_isPath isActiveNode:(BOOL)_isActive
childBlocks:(NSArray *)_blocks
{
UIxMailTreeBlock *block;
- block = [[self alloc] initWithName:_name title:_title link:_link
+ block = [[self alloc] initWithName:_name title:_title iconName:_icon
+ link:_link
isPathNode:_isPath isActiveNode:_isActive
childBlocks:_blocks];
return [block autorelease];
}
- (id)initWithName:(NSString *)_name title:(NSString *)_title
+ iconName:(NSString *)_icon
link:(NSString *)_link isPathNode:(BOOL)_isPath isActiveNode:(BOOL)_isActive
childBlocks:(NSArray *)_blocks
{
if ((self = [self init])) {
- self->name = [_name copy];
- self->title = [_title copy];
- self->link = [_link copy];
- self->blocks = [_blocks retain];
+ self->name = [_name copy];
+ self->title = [_title copy];
+ self->iconName = [_icon copy];
+ self->link = [_link copy];
+ self->blocks = [_blocks retain];
self->flags.isPath = _isPath ? 1 : 0;
self->flags.isActive = _isActive ? 1 : 0;
}
- (void)dealloc {
- [self->blocks release];
- [self->name release];
- [self->title release];
- [self->link release];
+ [self->iconName release];
+ [self->blocks release];
+ [self->name release];
+ [self->title release];
+ [self->link release];
[super dealloc];
}
- (NSString *)link {
return self->link;
}
+- (NSString *)iconName {
+ return self->iconName;
+}
- (NSArray *)children {
return self->blocks;