mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 09:22:33 +00:00
Simple Display of relevant Data now working
This commit is contained in:
@@ -7,10 +7,18 @@
|
||||
//
|
||||
|
||||
#import "MPEntryViewController.h"
|
||||
#import "MPOutlineViewDelegate.h"
|
||||
|
||||
NSString *const _MPUserNameColumnIdentifier = @"MPUserNameColumnIdentifier";
|
||||
NSString *const _MPTitleColumnIdentifier = @"MPTitleColumnIdentifier";
|
||||
NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
|
||||
|
||||
@interface MPEntryViewController ()
|
||||
|
||||
@property (retain) NSArrayController *entryArrayController;
|
||||
@property (assign) IBOutlet NSTableView *entryTable;
|
||||
|
||||
- (void)didChangeGroupSelectionInOutlineView:(NSNotification *)notification;
|
||||
|
||||
@end
|
||||
|
||||
@@ -23,9 +31,42 @@
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if(self) {
|
||||
self.entryArrayController = [[[NSArrayController alloc] init] autorelease];
|
||||
_entryArrayController = [[NSArrayController alloc] init];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didChangeGroupSelectionInOutlineView:)
|
||||
name:MPOutlineViewDidChangeGroupSelection
|
||||
object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)didLoadView {
|
||||
NSTableColumn *nameColumn = [self.entryTable tableColumns][0];
|
||||
NSTableColumn *userNameColumn = [self.entryTable tableColumns][1];
|
||||
NSTableColumn *passwordColumn = [self.entryTable tableColumns][2];
|
||||
|
||||
[nameColumn setIdentifier:_MPTitleColumnIdentifier];
|
||||
[userNameColumn setIdentifier:_MPUserNameColumnIdentifier];
|
||||
[passwordColumn setIdentifier:_MPPasswordColumnIdentifier];
|
||||
|
||||
[[nameColumn headerCell] setStringValue:@"Title"];
|
||||
[[userNameColumn headerCell] setStringValue:@"Username"];
|
||||
[[passwordColumn headerCell] setStringValue:@"Password"];
|
||||
|
||||
[nameColumn bind:NSValueBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects.title" options:nil];
|
||||
[userNameColumn bind:NSValueBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects.username" options:nil];
|
||||
[passwordColumn bind:NSValueBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects.password" options:nil];
|
||||
}
|
||||
|
||||
- (void)didChangeGroupSelectionInOutlineView:(NSNotification *)notification {
|
||||
MPOutlineViewDelegate *delegate = [notification object];
|
||||
KdbGroup *group = delegate.selectedGroup;
|
||||
if(group) {
|
||||
[self.entryArrayController bind:NSContentArrayBinding toObject:group withKeyPath:@"entries" options:nil];
|
||||
}
|
||||
else {
|
||||
[self.entryArrayController setContent:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user