Develop and Download Open Source Software

Browse CVS Repository

Annotation of /undmail/guiproto/AddressBookController.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (hide annotations) (download)
Fri Jan 31 17:49:12 2003 UTC (21 years, 2 months ago) by footashida
Branch: MAIN
Changes since 1.2: +4 -0 lines
*** empty log message ***

1 footashida 1.1 #import "AddressBookController.h"
2     #import <AddressBook/AddressBook.h>
3    
4     @implementation AddressBookController
5     - (id)init{
6     self = [super initWithWindowNibName:@"AddressBook"];
7     return self;
8     }
9 footashida 1.2 -(void)dealloc{
10     [nameTable release];
11     [group release];
12     [currentGroup release];
13     [super dealloc];
14     }
15 footashida 1.3 -(NSView *)addressBookView{
16     return addressBookView;
17     }
18 footashida 1.1 - (void)windowDidLoad
19     {
20 footashida 1.3 [[self window] setContentView:addressBookView];
21 footashida 1.1 [self updateGroup];
22     }/* windowDidLoad */
23    
24     - (NSMutableArray *)listGroup
25     {
26     NSArray *everygroup = [[[NSArray alloc] init] autorelease];
27     NSMutableArray *aGroup = [[[NSMutableArray alloc] init] autorelease];
28    
29     [aGroup addObject:@"All"];
30    
31     ABAddressBook *ab = [ABAddressBook sharedAddressBook];
32    
33     everygroup = [ab groups];
34    
35     id obj;
36     NSEnumerator *enumerator = [everygroup objectEnumerator];
37     while ((obj = [enumerator nextObject]) != nil){
38     ABGroup *someGroup = obj;
39     [aGroup addObject:[someGroup valueForProperty:kABGroupNameProperty]];
40     }
41    
42     return aGroup;
43     }/* listGroup*/
44    
45     - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
46     {
47     ABAddressBook *ab = [ABAddressBook sharedAddressBook];
48     //NSLog(@"aNotification");
49     //NSLog(@"%d",[[aNotification object] selectedRow]);
50     //NSLog(@"%@",[[[aNotification object] dataSource] group]);
51     if ([[aNotification object] selectedRow] == -1){
52     [self setCurrentGroup:nil];
53     [self updateUI];
54     } else if (![[aNotification object] selectedRow]){
55    
56     ABGroup *all =[[[ABGroup alloc] init] autorelease];
57     NSEnumerator *enumerator = [[ab people] objectEnumerator];
58     id obj;
59    
60     while ((obj = [enumerator nextObject]) != nil){
61     [all addMember:obj];
62     }
63    
64     [self setCurrentGroup:all];
65     [self updateUI];
66     } else {
67     NSArray *everygroup = [[[NSArray alloc] init] autorelease];
68     everygroup = [ab groups];
69     ABGroup *someGroup = [everygroup objectAtIndex:[[aNotification object] selectedRow]-1];
70     [self setCurrentGroup:someGroup];
71     [self updateUI];
72     }
73     }/* tableViewSelectionDidChange */
74    
75     -(void) updateUI
76     {
77     [nameTable reloadData];
78     }/* updateUI */
79    
80     - (void) updateGroup
81     {
82     group = [[NSMutableArray alloc] init];
83     [self setGroup:[self listGroup]];
84     }/* updateGroup */
85    
86     // ----------------------------------------------------------------------------------------
87     // NSTableDataSource
88     // ----------------------------------------------------------------------------------------
89    
90     - (int)numberOfRowsInTableView:(NSTableView *)aTableView
91     {
92     return [[currentGroup members] count];
93     }/* numberOfRowsInTableView */
94    
95     - (id)tableView:(NSTableView *)aTableView
96     objectValueForTableColumn:(NSTableColumn *)aTableColumn
97     row:(int)rowIndex
98     {
99     //NSDictionary *dictionary = [array objectAtIndex:rowIndex];
100     //return [dictionary objectForKey:[aTableColumn identifier]];
101    
102     ABPerson *theRecord;
103     id theValue;
104     ABPropertyType type = [ABPerson typeOfProperty:[aTableColumn identifier]];
105     theRecord = [[currentGroup members] objectAtIndex:rowIndex];
106    
107     //First,Last,Email,Phone
108    
109     if ( type & kABMultiValueMask ) {
110     ABMultiValue *mValue = [theRecord valueForProperty:[aTableColumn identifier]];
111     int index = [mValue indexForIdentifier:[mValue primaryIdentifier]];
112     theValue = [mValue valueAtIndex:index];
113     } else {
114     theValue = [theRecord valueForProperty:[aTableColumn identifier]];
115     }
116    
117     return theValue;
118     }/* tableView */
119    
120    
121    
122     // ----------------------------------------------------------------------------------------
123     // �A�N�Z�b�T���\�b�h
124     // ----------------------------------------------------------------------------------------
125    
126    
127     - (void) setGroup:(NSMutableArray *)aGroup
128     {
129     [aGroup retain];
130     [group release];
131     group = aGroup;
132     }/* setGroup */
133    
134     - (NSMutableArray *)group
135     {
136     return group;
137     }/* group */
138    
139     - (void) setCurrentGroup:(ABGroup *)cGroup
140     {
141     [cGroup retain];
142     [currentGroup release];
143     currentGroup = cGroup;
144     }/* setCurrentGroup */
145     - (ABGroup *)currentGroup
146     {
147     return currentGroup;
148     }/* currentGroup */
149     @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26