-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathPasswordsViewController.mm
74 lines (58 loc) · 2.26 KB
/
PasswordsViewController.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (C) 2012 Brian A. Mattern <[email protected]>.
* All Rights Reserved.
* This file is licensed under the GPLv2+.
* Please see COPYING for more information
*/
#import <UIKit/UIKit.h>
#import "PasswordsViewController.h"
#import "PassDataController.h"
#import "PassEntry.h"
#import "PassEntryViewController.h"
#import <dirent.h>
@implementation PasswordsViewController
@synthesize entries;
- (void)viewDidLoad {
[super viewDidLoad];
if (self.title == nil)
self.title = NSLocalizedString(@"Passwords", @"Password title");
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.entries numEntries];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"EntryCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
PassEntry *entry = [self.entries entryAtIndex:indexPath.row];
cell.textLabel.text = entry.name;
if (entry.is_dir)
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
else
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
PassEntry *entry = [self.entries entryAtIndex:indexPath.row];
if (entry.is_dir) {
// push subdir view onto stack
PasswordsViewController *subviewController = [[PasswordsViewController alloc] init];
subviewController.entries = [[PassDataController alloc] initWithPath:entry.path];
subviewController.title = entry.name;
[[self navigationController] pushViewController:subviewController animated:YES];
[subviewController release];
} else {
PassEntryViewController *detailController = [[PassEntryViewController alloc] init];
detailController.entry = entry;
[[self navigationController] pushViewController:detailController animated:YES];
[detailController release];
}
}
@end