mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +00:00
Removed unnecessary object controller, moving bindings to xib
This commit is contained in:
@@ -50,7 +50,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
|||||||
@property (nonatomic, assign) BOOL showPassword;
|
@property (nonatomic, assign) BOOL showPassword;
|
||||||
@property (nonatomic, assign) MPEntryTab activeTab;
|
@property (nonatomic, assign) MPEntryTab activeTab;
|
||||||
@property (strong) NSPopover *activePopover;
|
@property (strong) NSPopover *activePopover;
|
||||||
@property (strong) NSObjectController *entryController;
|
@property (nonatomic, readonly) KPKEntry *representedEntry;
|
||||||
|
|
||||||
|
|
||||||
//@property (nonatomic, weak) KPKEntry *entry;
|
//@property (nonatomic, weak) KPKEntry *entry;
|
||||||
@@ -83,15 +83,13 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
|||||||
_attachmentTableDelegate.viewController = self;
|
_attachmentTableDelegate.viewController = self;
|
||||||
_customFieldTableDelegate.viewController = self;
|
_customFieldTableDelegate.viewController = self;
|
||||||
_activeTab = MPEntryTabGeneral;
|
_activeTab = MPEntryTabGeneral;
|
||||||
_entryController = [[NSObjectController alloc] init];
|
|
||||||
_entryController.objectClass = [KPKEntry class];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (KPKEntry *)contentEntry {
|
- (KPKEntry *)representedEntry {
|
||||||
if([self.entryController.content isKindOfClass:[KPKEntry class]]) {
|
if([self.representedObject isKindOfClass:[KPKEntry class]]) {
|
||||||
return self.entryController.content;
|
return self.representedObject;
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
@@ -129,7 +127,7 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setupBindings:(MPDocument *)document {
|
- (void)setupBindings:(MPDocument *)document {
|
||||||
[self.entryController bind:NSContentObjectBinding toObject:self withKeyPath:NSStringFromSelector(@selector(representedObject)) options:nil];
|
//[self.entryController bind:NSContentObjectBinding toObject:self withKeyPath:NSStringFromSelector(@selector(representedObject)) options:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerNotificationsForDocument:(MPDocument *)document {
|
- (void)registerNotificationsForDocument:(MPDocument *)document {
|
||||||
@@ -147,13 +145,12 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
|||||||
#pragma mark Actions
|
#pragma mark Actions
|
||||||
|
|
||||||
- (void)addCustomField:(id)sender {
|
- (void)addCustomField:(id)sender {
|
||||||
MPDocument *document = [[self windowController] document];
|
[self.windowController.document createCustomAttribute:self.representedObject];
|
||||||
[document createCustomAttribute:self.entryController.content];
|
|
||||||
}
|
}
|
||||||
- (void)removeCustomField:(id)sender {
|
- (void)removeCustomField:(id)sender {
|
||||||
NSUInteger index = [sender tag];
|
NSUInteger index = [sender tag];
|
||||||
KPKAttribute *attribute = self.contentEntry.customAttributes[index];
|
KPKAttribute *attribute = self.representedEntry.customAttributes[index];
|
||||||
[self.contentEntry removeCustomAttribute:attribute];
|
[self.representedEntry removeCustomAttribute:attribute];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)saveAttachment:(id)sender {
|
- (void)saveAttachment:(id)sender {
|
||||||
@@ -161,7 +158,7 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
|||||||
if(row < 0) {
|
if(row < 0) {
|
||||||
return; // No selection
|
return; // No selection
|
||||||
}
|
}
|
||||||
KPKBinary *binary = self.contentEntry.binaries[row];
|
KPKBinary *binary = self.representedEntry.binaries[row];
|
||||||
NSSavePanel *savePanel = [NSSavePanel savePanel];
|
NSSavePanel *savePanel = [NSSavePanel savePanel];
|
||||||
savePanel.canCreateDirectories = YES;
|
savePanel.canCreateDirectories = YES;
|
||||||
savePanel.nameFieldStringValue = binary.name;
|
savePanel.nameFieldStringValue = binary.name;
|
||||||
@@ -186,7 +183,7 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
|||||||
if(result == NSFileHandlingPanelOKButton) {
|
if(result == NSFileHandlingPanelOKButton) {
|
||||||
for (NSURL *attachmentURL in openPanel.URLs) {
|
for (NSURL *attachmentURL in openPanel.URLs) {
|
||||||
KPKBinary *binary = [[KPKBinary alloc] initWithContentsOfURL:attachmentURL];
|
KPKBinary *binary = [[KPKBinary alloc] initWithContentsOfURL:attachmentURL];
|
||||||
[self.contentEntry addBinary:binary];
|
[self.representedEntry addBinary:binary];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
@@ -198,18 +195,18 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
|||||||
return; // no selection
|
return; // no selection
|
||||||
}
|
}
|
||||||
KPKBinary *binary = self.contentEntry.binaries[row];
|
KPKBinary *binary = self.contentEntry.binaries[row];
|
||||||
[self.contentEntry removeBinary:binary];
|
[self.representedEntry removeBinary:binary];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addWindowAssociation:(id)sender {
|
- (void)addWindowAssociation:(id)sender {
|
||||||
KPKWindowAssociation *associtation = [[KPKWindowAssociation alloc] initWithWindowTitle:NSLocalizedString(@"DEFAULT_WINDOW_TITLE", "") keystrokeSequence:nil];
|
KPKWindowAssociation *associtation = [[KPKWindowAssociation alloc] initWithWindowTitle:NSLocalizedString(@"DEFAULT_WINDOW_TITLE", "") keystrokeSequence:nil];
|
||||||
[self.contentEntry.autotype addAssociation:associtation];
|
[self.representedEntry.autotype addAssociation:associtation];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeWindowAssociation:(id)sender {
|
- (void)removeWindowAssociation:(id)sender {
|
||||||
NSInteger row = self.windowAssociationsTableView.selectedRow;
|
NSInteger row = self.windowAssociationsTableView.selectedRow;
|
||||||
if(row > - 1 && row < [self.contentEntry.autotype.associations count]) {
|
if(row > - 1 && row < [self.contentEntry.autotype.associations count]) {
|
||||||
[self.contentEntry.autotype removeAssociation:self.contentEntry.autotype.associations[row]];
|
[self.representedEntry.autotype removeAssociation:self.contentEntry.autotype.associations[row]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +259,7 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
|||||||
- (void)_updatePreviewItemForPanel:(QLPreviewPanel *)panel {
|
- (void)_updatePreviewItemForPanel:(QLPreviewPanel *)panel {
|
||||||
NSInteger row = [self.attachmentTableView selectedRow];
|
NSInteger row = [self.attachmentTableView selectedRow];
|
||||||
NSAssert(row > -1, @"Row needs to be selected");
|
NSAssert(row > -1, @"Row needs to be selected");
|
||||||
KPKBinary *binary = self.contentEntry.binaries[row];
|
KPKBinary *binary = self.representedEntry.binaries[row];
|
||||||
MPTemporaryFileStorage *oldStorage = (MPTemporaryFileStorage *)panel.dataSource;
|
MPTemporaryFileStorage *oldStorage = (MPTemporaryFileStorage *)panel.dataSource;
|
||||||
[[MPTemporaryFileStorageCenter defaultCenter] unregisterStorage:oldStorage];
|
[[MPTemporaryFileStorageCenter defaultCenter] unregisterStorage:oldStorage];
|
||||||
panel.dataSource = [[MPTemporaryFileStorageCenter defaultCenter] storageForBinary:binary];
|
panel.dataSource = [[MPTemporaryFileStorageCenter defaultCenter] storageForBinary:binary];
|
||||||
@@ -275,7 +272,7 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
|||||||
[self.generatePasswordButton setEnabled:NO];
|
[self.generatePasswordButton setEnabled:NO];
|
||||||
MPPasswordCreatorViewController *viewController = [[MPPasswordCreatorViewController alloc] init];
|
MPPasswordCreatorViewController *viewController = [[MPPasswordCreatorViewController alloc] init];
|
||||||
viewController.allowsEntryDefaults = YES;
|
viewController.allowsEntryDefaults = YES;
|
||||||
viewController.entry = self.contentEntry;
|
viewController.representedObject = self.representedObject;
|
||||||
[self _showPopopver:viewController atView:self.passwordTextField onEdge:NSMinYEdge];
|
[self _showPopopver:viewController atView:self.passwordTextField onEdge:NSMinYEdge];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
BOOL _didUnlock;
|
BOOL _didUnlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@property (strong) NSArrayController *entryArrayController;
|
|
||||||
@property (strong) MPContextBarViewController *contextBarViewController;
|
@property (strong) MPContextBarViewController *contextBarViewController;
|
||||||
@property (strong) NSArray *filteredEntries;
|
@property (strong) NSArray *filteredEntries;
|
||||||
|
|
||||||
@@ -107,8 +106,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)didLoadView {
|
- (void)didLoadView {
|
||||||
|
self.view.wantsLayer = YES;
|
||||||
[self.view setWantsLayer:YES];
|
|
||||||
|
|
||||||
self.entryTable.delegate = self;
|
self.entryTable.delegate = self;
|
||||||
self.entryTable.doubleAction = @selector(_columnDoubleClick:);
|
self.entryTable.doubleAction = @selector(_columnDoubleClick:);
|
||||||
@@ -155,14 +153,14 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
parentColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:parentTitleKeyPath ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
parentColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:parentTitleKeyPath ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||||
modifiedColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:timeInfoModificationTimeKeyPath ascending:YES selector:@selector(compare:)];
|
modifiedColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:timeInfoModificationTimeKeyPath ascending:YES selector:@selector(compare:)];
|
||||||
|
|
||||||
[parentColumn.headerCell setStringValue:NSLocalizedString(@"GROUP", "")];
|
parentColumn.headerCell.stringValue = NSLocalizedString(@"GROUP", "");
|
||||||
[titleColumn.headerCell setStringValue:NSLocalizedString(@"TITLE", "")];
|
titleColumn.headerCell.stringValue = NSLocalizedString(@"TITLE", "");
|
||||||
[userNameColumn.headerCell setStringValue:NSLocalizedString(@"USERNAME", "")];
|
userNameColumn.headerCell.stringValue = NSLocalizedString(@"USERNAME", "");
|
||||||
[passwordColumn.headerCell setStringValue:NSLocalizedString(@"PASSWORD", "")];
|
passwordColumn.headerCell.stringValue = NSLocalizedString(@"PASSWORD", "");
|
||||||
[urlColumn.headerCell setStringValue:NSLocalizedString(@"URL", "")];
|
urlColumn.headerCell.stringValue = NSLocalizedString(@"URL", "");
|
||||||
[notesColumn.headerCell setStringValue:NSLocalizedString(@"NOTES", "")];
|
notesColumn.headerCell.stringValue = NSLocalizedString(@"NOTES", "");
|
||||||
[attachmentsColumn.headerCell setStringValue:NSLocalizedString(@"ATTACHMENTS", "")];
|
attachmentsColumn.headerCell.stringValue = NSLocalizedString(@"ATTACHMENTS", "");
|
||||||
[modifiedColumn.headerCell setStringValue:NSLocalizedString(@"MODIFIED", "")];
|
modifiedColumn.headerCell.stringValue = NSLocalizedString(@"MODIFIED", "");
|
||||||
|
|
||||||
[self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:NSStringFromSelector(@selector(arrangedObjects)) options:nil];
|
[self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:NSStringFromSelector(@selector(arrangedObjects)) options:nil];
|
||||||
[self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:NSStringFromSelector(@selector(sortDescriptors)) options:nil];
|
[self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:NSStringFromSelector(@selector(sortDescriptors)) options:nil];
|
||||||
@@ -252,7 +250,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
[view.imageView bind:NSValueBinding toObject:view withKeyPath:iconImageKeyPath options:nil];
|
[view.imageView bind:NSValueBinding toObject:view withKeyPath:iconImageKeyPath options:nil];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
KPKEntry *entry = [self.entryArrayController arrangedObjects][row];
|
KPKEntry *entry = self.entryArrayController.arrangedObjects[row];
|
||||||
NSAssert(entry.parent != nil, @"Entry needs to have a parent");
|
NSAssert(entry.parent != nil, @"Entry needs to have a parent");
|
||||||
|
|
||||||
NSString *parentTitleKeyPath = [NSString stringWithFormat:@"%@.%@.%@",
|
NSString *parentTitleKeyPath = [NSString stringWithFormat:@"%@.%@.%@",
|
||||||
@@ -288,8 +286,8 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
formatter = [[NSDateFormatter alloc] init];
|
formatter = [[NSDateFormatter alloc] init];
|
||||||
[formatter setDateStyle:NSDateFormatterMediumStyle];
|
formatter.dateStyle = NSDateFormatterMediumStyle;
|
||||||
[formatter setTimeStyle:NSDateFormatterMediumStyle];
|
formatter.timeStyle = NSDateFormatterMediumStyle;
|
||||||
});
|
});
|
||||||
view.textField.formatter = formatter;
|
view.textField.formatter = formatter;
|
||||||
}
|
}
|
||||||
@@ -368,7 +366,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
|
|
||||||
#pragma mark MPDocument Notifications
|
#pragma mark MPDocument Notifications
|
||||||
- (void)_didChangeCurrentItem:(NSNotification *)notification {
|
- (void)_didChangeCurrentItem:(NSNotification *)notification {
|
||||||
MPDocument *document = [notification object];
|
MPDocument *document = notification.object;
|
||||||
|
|
||||||
if(document.selectedGroups.count != 1 && !document.hasSearch) {
|
if(document.selectedGroups.count != 1 && !document.hasSearch) {
|
||||||
/* no group selection out of search is wrong */
|
/* no group selection out of search is wrong */
|
||||||
@@ -423,7 +421,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
|
|
||||||
- (void)_didUpdateSearchResults:(NSNotification *)notification {
|
- (void)_didUpdateSearchResults:(NSNotification *)notification {
|
||||||
[self _showContextBar];
|
[self _showContextBar];
|
||||||
NSArray *result = [notification userInfo][kMPDocumentSearchResultsKey];
|
NSArray *result = notification.userInfo[kMPDocumentSearchResultsKey];
|
||||||
NSAssert(result != nil, @"Resutls should never be nil");
|
NSAssert(result != nil, @"Resutls should never be nil");
|
||||||
self.filteredEntries = result;
|
self.filteredEntries = result;
|
||||||
[self.entryArrayController unbind:NSContentArrayBinding];
|
[self.entryArrayController unbind:NSContentArrayBinding];
|
||||||
@@ -482,11 +480,11 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_isDisplayingContextBar = YES;
|
_isDisplayingContextBar = YES;
|
||||||
if(![[self.contextBarViewController view] superview]) {
|
if(!self.contextBarViewController.view.superview) {
|
||||||
[[self view] addSubview:[self.contextBarViewController view]];
|
[self.view addSubview:[self.contextBarViewController view]];
|
||||||
[self.contextBarViewController updateResponderChain];
|
[self.contextBarViewController updateResponderChain];
|
||||||
NSView *contextBar = [self.contextBarViewController view];
|
NSView *contextBar = self.contextBarViewController.view;
|
||||||
NSView *scrollView = [_entryTable enclosingScrollView];
|
NSView *scrollView = self.entryTable.enclosingScrollView;
|
||||||
NSDictionary *views = NSDictionaryOfVariableBindings(scrollView, contextBar);
|
NSDictionary *views = NSDictionaryOfVariableBindings(scrollView, contextBar);
|
||||||
|
|
||||||
/* Pin to the left */
|
/* Pin to the left */
|
||||||
@@ -497,15 +495,15 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
self.contextBarTopConstraint = [NSLayoutConstraint constraintWithItem:contextBar
|
self.contextBarTopConstraint = [NSLayoutConstraint constraintWithItem:contextBar
|
||||||
attribute:NSLayoutAttributeTop
|
attribute:NSLayoutAttributeTop
|
||||||
relatedBy:NSLayoutRelationEqual
|
relatedBy:NSLayoutRelationEqual
|
||||||
toItem:[self view]
|
toItem:self.view
|
||||||
attribute:NSLayoutAttributeTop
|
attribute:NSLayoutAttributeTop
|
||||||
multiplier:1
|
multiplier:1
|
||||||
constant:-31];
|
constant:-31];
|
||||||
}
|
}
|
||||||
/* Add the view for the first time */
|
/* Add the view for the first time */
|
||||||
[[self view] removeConstraint:self.tableToTopConstraint];
|
[self.view removeConstraint:self.tableToTopConstraint];
|
||||||
[[self view] addConstraint:self.contextBarTopConstraint];
|
[self.view addConstraint:self.contextBarTopConstraint];
|
||||||
[[self view] layout];
|
[self.view layout];
|
||||||
self.contextBarTopConstraint.constant = 0;
|
self.contextBarTopConstraint.constant = 0;
|
||||||
|
|
||||||
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
|
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
|
||||||
@@ -520,7 +518,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
return; // nothing to do;
|
return; // nothing to do;
|
||||||
}
|
}
|
||||||
self.contextBarTopConstraint.constant = -31;
|
self.contextBarTopConstraint.constant = -31;
|
||||||
[[self view] addConstraint:self.tableToTopConstraint];
|
[self.view addConstraint:self.tableToTopConstraint];
|
||||||
|
|
||||||
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
|
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
|
||||||
context.duration = STATUS_BAR_ANIMATION_TIME;
|
context.duration = STATUS_BAR_ANIMATION_TIME;
|
||||||
@@ -565,8 +563,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
#pragma mark Validation
|
#pragma mark Validation
|
||||||
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
|
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
|
||||||
/* Validation is solely handled in the document */
|
/* Validation is solely handled in the document */
|
||||||
MPDocument *document = [[self windowController] document];
|
return [self.windowController.document validateMenuItem:menuItem];
|
||||||
return [document validateMenuItem:menuItem];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark ContextMenu
|
#pragma mark ContextMenu
|
||||||
@@ -577,8 +574,8 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
for(NSMenuItem *item in items) {
|
for(NSMenuItem *item in items) {
|
||||||
[menu addItem:item];
|
[menu addItem:item];
|
||||||
}
|
}
|
||||||
[menu setDelegate:_menuDelegate];
|
menu.delegate = _menuDelegate;
|
||||||
[self.entryTable setMenu:menu];
|
self.entryTable.menu = menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_setupHeaderMenu {
|
- (void)_setupHeaderMenu {
|
||||||
@@ -601,7 +598,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
MPEntryTableModfiedColumnIdentifier ];
|
MPEntryTableModfiedColumnIdentifier ];
|
||||||
|
|
||||||
NSDictionary *options = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName };
|
NSDictionary *options = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName };
|
||||||
for(NSMenuItem *item in [headerMenu itemArray]) {
|
for(NSMenuItem *item in headerMenu.itemArray) {
|
||||||
NSUInteger index = [headerMenu indexOfItem:item];
|
NSUInteger index = [headerMenu indexOfItem:item];
|
||||||
NSTableColumn *column= [self.entryTable tableColumnWithIdentifier:identifier[index]];
|
NSTableColumn *column= [self.entryTable tableColumnWithIdentifier:identifier[index]];
|
||||||
[item bind:NSValueBinding toObject:column withKeyPath:NSHiddenBinding options:options];
|
[item bind:NSValueBinding toObject:column withKeyPath:NSHiddenBinding options:options];
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
@property (weak) IBOutlet NSSplitView *splitView;
|
@property (weak) IBOutlet NSSplitView *splitView;
|
||||||
@property (unsafe_unretained) IBOutlet NSTextView *notesTextView;
|
@property (unsafe_unretained) IBOutlet NSTextView *notesTextView;
|
||||||
|
|
||||||
@property (strong) NSObjectController *nodeController;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation MPInspectorViewController
|
@implementation MPInspectorViewController
|
||||||
@@ -63,7 +61,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
self.activeTab = MPEmptyTab;
|
self.activeTab = MPEmptyTab;
|
||||||
self.entryViewController = [[MPEntryInspectorViewController alloc] init];
|
self.entryViewController = [[MPEntryInspectorViewController alloc] init];
|
||||||
self.groupViewController = [[MPGroupInspectorViewController alloc] init];
|
self.groupViewController = [[MPGroupInspectorViewController alloc] init];
|
||||||
self.nodeController = [[NSObjectController alloc] init];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -105,8 +102,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
[self.view layout];
|
[self.view layout];
|
||||||
|
|
||||||
self.cancelEditButton.hidden = YES;
|
self.cancelEditButton.hidden = YES;
|
||||||
|
|
||||||
[self _establishBindings];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerNotificationsForDocument:(MPDocument *)document {
|
- (void)registerNotificationsForDocument:(MPDocument *)document {
|
||||||
@@ -219,13 +214,13 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
BOOL useDefault = (iconId == -1);
|
BOOL useDefault = (iconId == -1);
|
||||||
switch (self.activeTab) {
|
switch (self.activeTab) {
|
||||||
case MPGroupTab: {
|
case MPGroupTab: {
|
||||||
KPKGroup *group = self.nodeController.content;
|
KPKGroup *group = self.representedObject;
|
||||||
group.iconId = useDefault ? [KPKGroup defaultIcon] : iconId;
|
group.iconId = useDefault ? [KPKGroup defaultIcon] : iconId;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MPEntryTab: {
|
case MPEntryTab: {
|
||||||
KPKEntry *entry = self.nodeController.content;
|
KPKEntry *entry = self.representedObject;
|
||||||
entry.iconId = useDefault ? [KPKEntry defaultIcon]: iconId;
|
entry.iconId = useDefault ? [KPKEntry defaultIcon]: iconId;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -244,18 +239,18 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
#pragma mark Bindings
|
#pragma mark Bindings
|
||||||
- (void)_establishBindings {
|
- (void)_establishBindings {
|
||||||
|
|
||||||
[self.itemImageView bind:NSValueBinding
|
// [self.itemImageView bind:NSValueBinding
|
||||||
toObject:self.nodeController
|
// toObject:self
|
||||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(content)), NSStringFromSelector(@selector(iconImage))]
|
// withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(iconImage))]
|
||||||
options:nil];
|
// options:nil];
|
||||||
[self.notesTextView bind:NSValueBinding
|
// [self.notesTextView bind:NSValueBinding
|
||||||
toObject:self.nodeController
|
// toObject:self
|
||||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(content)), NSStringFromSelector(@selector(notes))]
|
// withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(notes))]
|
||||||
options:@{ NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "")}];
|
// options:@{ NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "")}];
|
||||||
[self.itemNameTextField bind:NSValueBinding
|
// [self.itemNameTextField bind:NSValueBinding
|
||||||
toObject:self.nodeController
|
// toObject:self
|
||||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(content)), NSStringFromSelector(@selector(title))]
|
// withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(title))]
|
||||||
options:@{NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "")}];
|
// options:@{NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "")}];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@@ -281,7 +276,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
else {
|
else {
|
||||||
self.activeTab = MPEmptyTab;
|
self.activeTab = MPEmptyTab;
|
||||||
}
|
}
|
||||||
self.nodeController.content = node;
|
self.representedObject = node;
|
||||||
self.entryViewController.representedObject = node.asEntry;
|
self.entryViewController.representedObject = node.asEntry;
|
||||||
self.groupViewController.representedObject = node.asGroup;
|
self.groupViewController.representedObject = node.asGroup;
|
||||||
[self _toggleEditors:(nil != node.asGroup)];
|
[self _toggleEditors:(nil != node.asGroup)];
|
||||||
|
|||||||
Reference in New Issue
Block a user