PageRenderTime 80ms CodeModel.GetById 65ms app.highlight 12ms RepoModel.GetById 0ms app.codeStats 0ms

/Sidebar/SidebarNode.m

http://github.com/bububa/MongoHub-Mac
Objective C | 91 lines | 62 code | 22 blank | 7 comment | 3 complexity | 9a03facb890c2307ebd79c68942a54ca MD5 | raw file
 1//
 2//  SidebarNode.m
 3//  Sidebar
 4//
 5//  Created by Matteo Bertozzi on 3/8/09.
 6//  Copyright 2009 Matteo Bertozzi. All rights reserved.
 7//
 8
 9#import "SidebarNode.h"
10
11@implementation SidebarNode
12
13@synthesize actionTarget;
14@synthesize action;
15
16@synthesize badgeValue;
17@synthesize hasBadge;
18
19@synthesize parentKey;
20@synthesize nodeType;
21@synthesize nodeKey;
22@synthesize caption;
23@synthesize icon;
24@synthesize data;
25
26- (id)init {
27	if ((self = [super init])) {
28		children = [[NSMutableArray alloc] init];
29		hasBadge = NO;
30	}
31
32	return self;
33}
34
35- (void)dealloc {
36	[children release];
37
38	[caption release];
39	[icon release];
40	[data release];
41
42	[super dealloc];
43}
44
45- (void)setAction:(SEL)aSelector target:(id)target {
46	actionTarget = target;
47	action = aSelector;
48}
49
50- (BOOL)hasAction {
51	return(action != NULL);
52}
53
54- (void)setBadgeValue:(NSInteger)value {
55	hasBadge = YES;
56	badgeValue = value;
57}
58
59- (void)unsetBadgeValue {
60	hasBadge = NO;
61}
62
63- (void)addChild:(SidebarNode *)node {
64	[children addObject:node];
65}
66
67- (void)insertChild:(SidebarNode *)node atIndex:(NSUInteger)index {
68	[children insertObject:node atIndex:index];
69}
70
71- (void)removeChild:(SidebarNode *)node {
72	[children removeObject:node];
73}
74
75- (NSInteger)indexOfChild:(SidebarNode *)node {
76	return [children indexOfObject:node];
77}
78
79- (SidebarNode *)childAtIndex:(int)index {
80	return([children objectAtIndex:index]);
81}
82
83- (NSUInteger)numberOfChildren {
84	return([children count]);
85}
86
87- (BOOL)isDraggable {
88	return(nodeType != kSidebarNodeTypeSection);
89}
90
91@end