]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Mailer/UIxMailTree.m
implement folder tree navigation
[scalable-opengroupware.org] / SOGo / UI / Mailer / UIxMailTree.m
1 /*
2   Copyright (C) 2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id: UIxMailTree.m 278 2004-08-26 23:29:09Z helge $
22
23 #include <SOGoUI/UIxComponent.h>
24
25 @interface UIxMailTree : UIxComponent
26 {
27   id item;
28 }
29 @end
30
31 #include <SOGo/SoObjects/Mailer/SOGoMailBaseObject.h>
32 #include "common.h"
33 #include <NGObjWeb/SoComponent.h>
34
35 @implementation UIxMailTree
36
37 - (void)dealloc {
38   [self->item        release];
39   [super dealloc];
40 }
41
42 /* accessors */
43
44 - (void)setItem:(id)_item {
45   ASSIGN(self->item, _item);
46 }
47 - (id)item {
48   return self->item;
49 }
50
51 /* tree */
52
53 - (NSArray *)rootNodes {
54   return [NSArray arrayWithObject:[[self clientObject] treeNavigationNodes]];
55 }
56
57 - (NSArray *)itemChildNodes {
58   NSMutableArray *folders;
59   NSArray  *names;
60   unsigned i, count;
61   
62   names   = [[self item] toManyRelationshipKeys];
63   count   = [names count];
64   folders = [NSMutableArray arrayWithCapacity:count];
65
66   for (i = 0; i < count; i++) {
67     id folder;
68
69     folder = [[self item] lookupName:[names objectAtIndex:i]
70                           inContext:[self context]
71                           acquire:NO];
72     if (folder)
73       [folders addObject:folder];
74   }
75   
76   return folders;
77 }
78
79 - (BOOL)isItemExpanded {
80   return YES;
81 }
82
83 /* notifications */
84
85 - (void)sleep {
86   [self->item release]; self->item = nil;
87   [super sleep];
88 }
89
90 @end /* UIxMailTree */