You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
Matlab
53 lines
1.2 KiB
Matlab
8 years ago
|
#import "RequestHistory.h"
|
||
8 years ago
|
#import "RequestHistoryItem.h"
|
||
8 years ago
|
|
||
|
@interface RequestHistory ()
|
||
|
@property (strong) NSMutableArray *items;
|
||
|
@end
|
||
|
|
||
|
@implementation RequestHistory
|
||
|
|
||
|
- (instancetype) init {
|
||
|
self = [super init];
|
||
|
if (self) {
|
||
|
[self setItems:[[NSMutableArray alloc] initWithCapacity:1000]];
|
||
|
}
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (NSInteger) numberOfRowsInTableView:(NSTableView *)view {
|
||
|
return [[self items] count];
|
||
|
}
|
||
|
|
||
|
- (id) tableView:(NSTableView *)view objectValueForTableColumn:(NSTableColumn *)column row:(NSInteger) row {
|
||
8 years ago
|
RequestHistoryItem *item = [[self items] objectAtIndex:row];
|
||
|
if (!item) {
|
||
8 years ago
|
return nil;
|
||
|
}
|
||
|
|
||
|
if ([[column identifier] isEqualToString:@"id"]) {
|
||
8 years ago
|
return [NSNumber numberWithInt:[item seq]];
|
||
8 years ago
|
} else if ([[column identifier] isEqualToString:@"status"]) {
|
||
8 years ago
|
if ([item status] == 0) {
|
||
|
return @"???";
|
||
|
} else {
|
||
|
return [NSNumber numberWithInt:[item status]];
|
||
|
}
|
||
8 years ago
|
} else if ([[column identifier] isEqualToString:@"path"]) {
|
||
8 years ago
|
return [item path];
|
||
8 years ago
|
} else {
|
||
|
return @"fuck";
|
||
|
}
|
||
8 years ago
|
}
|
||
|
|
||
|
- (void) addRequestItem:(RequestMeta *)meta {
|
||
8 years ago
|
[[self items] addObject:[RequestHistoryItem itemWithRequestMeta:meta]];
|
||
8 years ago
|
}
|
||
|
|
||
|
- (void) addResponseItem:(ResponseMeta *)meta {
|
||
8 years ago
|
id item = [[self items] objectAtIndex:meta->seq-1];
|
||
|
[item updateWithResponseMeta:meta];
|
||
8 years ago
|
}
|
||
|
|
||
|
@end
|