2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
#import "UIxMailTreeBlock.h"
|
|
|
|
#import "common.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
@implementation UIxMailTreeBlock
|
|
|
|
|
|
|
|
id UIxMailTreeHasChildrenMarker = nil;
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
// TODO: needs to be an array because the WETreeView requires a
|
|
|
|
// children array
|
|
|
|
UIxMailTreeHasChildrenMarker =
|
|
|
|
[[NSArray alloc] initWithObjects:@"FAKE", nil];
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
+ (id) blockWithName: (NSString *) _name
|
|
|
|
title: (NSString *) _title
|
|
|
|
iconName: (NSString *) _icon
|
|
|
|
link: (NSString *) _link
|
|
|
|
isPathNode: (BOOL) _isPath
|
|
|
|
isActiveNode: (BOOL) _isActive
|
|
|
|
childBlocks: (NSArray *) _blocks
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
UIxMailTreeBlock *block;
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
block = [[self alloc] initWithName:_name
|
|
|
|
title:_title
|
|
|
|
iconName:_icon
|
2006-06-15 21:34:10 +02:00
|
|
|
link:_link
|
2006-07-29 00:59:11 +02:00
|
|
|
isPathNode:_isPath
|
|
|
|
isActiveNode:_isActive
|
2006-06-15 21:34:10 +02:00
|
|
|
childBlocks:_blocks];
|
|
|
|
return [block autorelease];
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (id) initWithName: (NSString *) _name
|
|
|
|
title: (NSString *) _title
|
|
|
|
iconName: (NSString *) _icon
|
|
|
|
link: (NSString *) _link
|
|
|
|
isPathNode: (BOOL) _isPath
|
|
|
|
isActiveNode: (BOOL) _isActive
|
|
|
|
childBlocks: (NSArray *) _blocks
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
2006-07-29 00:59:11 +02:00
|
|
|
if ((self = [self init]))
|
|
|
|
{
|
|
|
|
self->name = [_name copy];
|
|
|
|
self->title = [_title copy];
|
|
|
|
self->iconName = [_icon copy];
|
|
|
|
self->link = [_link copy];
|
|
|
|
self->blocks = [_blocks retain];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
self->flags.isPath = _isPath ? 1 : 0;
|
|
|
|
self->flags.isActive = _isActive ? 1 : 0;
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
[self->iconName release];
|
|
|
|
[self->blocks release];
|
|
|
|
[self->name release];
|
|
|
|
[self->title release];
|
|
|
|
[self->link release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* accessors */
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (NSString *) name
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self->name;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
- (void) setName: (NSString *) newName
|
|
|
|
{
|
|
|
|
if (name)
|
|
|
|
[name release];
|
|
|
|
name = [newName copy];
|
|
|
|
if (name)
|
|
|
|
[name retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) title
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self->title;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
- (NSString *) link
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self->link;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
- (NSString *) iconName
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self->iconName;
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (BOOL) hasChildren
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
if (self->blocks == UIxMailTreeHasChildrenMarker)
|
|
|
|
return YES;
|
|
|
|
return [self->blocks count] > 0 ? YES : NO;
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (BOOL) areChildrenLoaded
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self->blocks != UIxMailTreeHasChildrenMarker ? YES : NO;
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (NSArray *) children
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
if (self->blocks == UIxMailTreeHasChildrenMarker)
|
|
|
|
// TODO: print a warning
|
|
|
|
return self->blocks;
|
|
|
|
|
|
|
|
return self->blocks;
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (BOOL) isPathNode
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self->flags.isPath ? YES : NO;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
- (BOOL) isActiveNode
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self->flags.isActive ? YES : NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* description */
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (void) appendAttributesToDescription: (NSMutableString *) _ms
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
if (self->name != nil) [_ms appendFormat:@" name='%@'", self->name];
|
|
|
|
if (self->title != nil) [_ms appendFormat:@" title='%@'", self->title];
|
|
|
|
|
|
|
|
if ([self isPathNode]) [_ms appendString:@" path"];
|
|
|
|
if ([self isActiveNode]) [_ms appendString:@" active"];
|
|
|
|
|
|
|
|
if (self->blocks == UIxMailTreeHasChildrenMarker)
|
|
|
|
[_ms appendString:@" has-children"];
|
|
|
|
else if ([self->blocks count] > 0)
|
|
|
|
[_ms appendFormat:@" children=%@", self->blocks];
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (NSString *) description
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
NSMutableString *ms;
|
|
|
|
|
|
|
|
ms = [NSMutableString stringWithCapacity:64];
|
|
|
|
[ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
|
|
|
|
[self appendAttributesToDescription:ms];
|
|
|
|
[ms appendString:@">"];
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
- (void) setSerial: (int) newSerial
|
|
|
|
{
|
|
|
|
serial = newSerial;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) serial
|
|
|
|
{
|
|
|
|
return serial;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) serialAsString
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%d", serial];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setParent: (int) newParent
|
|
|
|
{
|
|
|
|
parent = newParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) parent
|
|
|
|
{
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setFolderType: (NSString *) newFolderType
|
|
|
|
{
|
|
|
|
folderType = newFolderType;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) folderType
|
|
|
|
{
|
|
|
|
return folderType;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) parentAsString
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%d", parent];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) folderMenuId
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"__wox_submenu_%d-%d", parent, serial];
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@end /* UIxMailTreeBlock */
|