1 #import "DownloadsViewController.h"
4 @implementation DownloadsViewController
6 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
8 NSString *columnId = [aTableColumn identifier];
9 DownloadingFile *i = [m_fileset objectAtIndex:rowIndex];
10 // if ( [columnId compare:@"filename"] == NSOrderedSame ) {
11 // value = @"val-for-filename";
12 // } else if ( [columnId compare:@"progress"] == NSOrderedSame ) {
13 // value = @"val-for-progress";
14 // } else if ( [columnId compare:@"size"] == NSOrderedSame ) {
15 // value = @"val-for-name";
16 // } else if ( [columnId compare:@"xferred"] == NSOrderedSame ) {
17 // value = @"val-for-size";
18 // } else if ( [columnId compare:@"completed"] == NSOrderedSame ) {
19 // value = @"val-for-completed";
20 // } else if ( [columnId compare:@"speed"] == NSOrderedSame ) {
21 // value = @"val-for-speed";
22 // } else if ( [columnId compare:@"prio"] == NSOrderedSame ) {
23 // value = @"val-for-prio";
24 // } else if ( [columnId compare:@"timerem"] == NSOrderedSame ) {
25 // value = @"val-for-timerem";
26 // } else if ( [columnId compare:@"lastcomp"] == NSOrderedSame ) {
27 // value = @"val-for-lastcomp";
28 // } else if ( [columnId compare:@"lastrx"] == NSOrderedSame ) {
29 // value = @"val-for-lastrx";
31 // value = @"ERROR: bad column id";
33 if ( [columnId compare:@"filename"] == NSOrderedSame ) {
35 } else if ( [columnId compare:@"progress"] == NSOrderedSame ) {
36 value = @"progress-colored-bar";
37 } else if ( [columnId compare:@"size"] == NSOrderedSame ) {
38 value = [i convertWithPrefix: i.size];
39 } else if ( [columnId compare:@"xferred"] == NSOrderedSame ) {
40 value = [i convertWithPrefix: i.size_xfer];
41 } else if ( [columnId compare:@"completed"] == NSOrderedSame ) {
42 value = [i convertWithPrefix: i.size_done];
43 } else if ( [columnId compare:@"speed"] == NSOrderedSame ) {
45 [[i convertWithPrefix: i.speed] stringByAppendingString: @"/sec"] : @"";
46 } else if ( [columnId compare:@"prio"] == NSOrderedSame ) {
48 } else if ( [columnId compare:@"timerem"] == NSOrderedSame ) {
49 value = @"val-for-timerem";
50 } else if ( [columnId compare:@"lastcomp"] == NSOrderedSame ) {
51 value = @"val-for-lastcomp";
52 } else if ( [columnId compare:@"lastrx"] == NSOrderedSame ) {
53 value = @"val-for-lastrx";
55 value = @"ERROR: bad column id";
60 - (int)numberOfRowsInTableView:(NSTableView *)aTableView {
62 return [m_fileset count];
65 - (void)linkAmuleData:(amuleData *)amuledata {
66 m_amuledata = amuledata;
67 m_fileset = m_amuledata.downloads;
68 [amuledata.downloads setGuiController:self];
72 [m_tableview reloadData];
75 - (void)awakeFromNib {
76 [m_tableview setDelegate:self];
77 [m_tableview setDataSource:self];
82 for (NSTableColumn *c in [m_tableview tableColumns]) {
83 NSString *columnId = [c identifier];
84 NSString *keyWidth = [NSString stringWithFormat:@"DownloadView.Column_%@_Width", columnId];
85 int width = [[NSUserDefaults standardUserDefaults] integerForKey:keyWidth];
87 NSLog(@"Column %@ setting width %d\n", columnId, width);
90 NSString *keyHide = [NSString stringWithFormat:@"DownloadView.Column_%@_Hide", columnId];
91 int hide = [[NSUserDefaults standardUserDefaults] integerForKey:keyHide];
97 for (NSTableColumn *c in [m_tableview tableColumns]) {
98 NSString *columnId = [c identifier];
100 NSString *keyWidth = [NSString stringWithFormat:@"DownloadView.Column_%@_Width", columnId];
101 [[NSUserDefaults standardUserDefaults] setInteger:c.width forKey:keyWidth];
103 NSString *keyHide = [NSString stringWithFormat:@"DownloadView.Column_%@_Hide", columnId];
104 [[NSUserDefaults standardUserDefaults] setInteger:[c isHidden] forKey:keyHide];