Fixed the state for the playlists menu item to show the currently playing playlist.
[MenuTunes.git] / PlaylistNode.m
1 /*
2  *      MenuTunes
3  *  PlaylistNode
4  *    Helper class for keeping track of sources, playlists and folders
5  *
6  *  Original Author : Kent Sutherland <ksuther@ithinksw.com>
7  *   Responsibility : Kent Sutherland <ksuther@ithinksw.com>
8  *
9  *  Copyright (c) 2005 iThink Software.
10  *  All Rights Reserved
11  *
12  */
13
14 #import "PlaylistNode.h"
15
16
17 @implementation PlaylistNode
18
19 + (PlaylistNode *)playlistNodeWithName:(NSString *)n type:(ITMTNodeType)t index:(int)i
20 {
21         return [[[PlaylistNode alloc] initWithName:n type:t index:i] autorelease];
22 }
23
24 - (id)initWithName:(NSString *)n type:(ITMTNodeType)t index:(int)i
25 {
26         if ( (self = [super init]) ) {
27                 _name = [n retain];
28                 _type = t;
29                 _index = i;
30                 _children = [[NSMutableArray alloc] init];
31                 _parent = nil;
32         }
33         return self;
34 }
35
36 - (void)dealloc
37 {
38         [_name release];
39         [_children release];
40         [_parent release];
41         [super dealloc];
42 }
43
44 - (NSString *)description
45 {
46         return [NSString stringWithFormat:@"{%@, index: %i, type: %i, parent: %@, children: %@}", _name, _index, _type, [_parent name], _children];
47 }
48
49 - (NSString *)name
50 {
51         return _name;
52 }
53
54 - (NSMutableArray *)children
55 {
56         return _children;
57 }
58
59 - (int)index
60 {
61         return _index;
62 }
63
64 - (void)setType:(ITMTNodeType)t
65 {
66         _type = t;
67 }
68
69 - (ITMTNodeType)type
70 {
71         return _type;
72 }
73
74 - (PlaylistNode *)parent
75 {
76         return _parent;
77 }
78
79 - (void)setParent:(PlaylistNode *)p
80 {
81         [_parent release];
82         _parent = [p retain];
83 }
84
85 - (ITMTRemotePlayerSource)sourceType
86 {
87         return _sourceType;
88 }
89
90 - (void)setSourceType:(ITMTRemotePlayerSource)t
91 {
92         _sourceType = t;
93 }
94
95 @end