Develop and Download Open Source Software

Browse CVS Repository

Contents of /undmail/guiproto/AddressBookController.m

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


Revision 1.1 - (show annotations) (download)
Sun Jan 26 16:30:09 2003 UTC (21 years, 2 months ago) by footashida
Branch: MAIN
*** empty log message ***

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

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