using property declaration in MPNodeResolver instead of simple getter.

This commit is contained in:
Michael Starke
2018-11-14 11:02:51 +01:00
parent b9de0fb2dd
commit 23e7ebc4a0
5 changed files with 23 additions and 23 deletions

View File

@@ -843,9 +843,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
id<MPTargetNodeResolving> nodeResolver = [NSApp targetForAction:@selector(currentTargetNodes)]; id<MPTargetNodeResolving> nodeResolver = [NSApp targetForAction:@selector(currentTargetNodes)];
NSArray *targetNodes = [nodeResolver currentTargetNodes]; NSArray *targetNodes = nodeResolver.currentTargetNodes;
NSArray *targetGroups = [groupResolver currentTargetGroups]; NSArray *targetGroups = groupResolver.currentTargetGroups;
NSArray *targetEntries = [entryResolver currentTargetEntries]; NSArray *targetEntries = entryResolver.currentTargetEntries;
KPKEntry *targetEntry = targetEntries.count == 1 ? targetEntries.firstObject : nil; KPKEntry *targetEntry = targetEntries.count == 1 ? targetEntries.firstObject : nil;
KPKGroup *targetGroup = targetGroups.count == 1 ? targetGroups.firstObject : nil; KPKGroup *targetGroup = targetGroups.count == 1 ? targetGroups.firstObject : nil;

View File

@@ -388,7 +388,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
- (void)createGroup:(id)sender { - (void)createGroup:(id)sender {
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroups)]; id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroups)];
NSArray *groups = [target currentTargetGroups]; NSArray *groups = target.currentTargetGroups;
MPDocument *document = self.document; MPDocument *document = self.document;
if(groups.count == 1) { if(groups.count == 1) {
[document createGroup:groups.firstObject]; [document createGroup:groups.firstObject];
@@ -400,7 +400,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
- (void)createEntry:(id)sender { - (void)createEntry:(id)sender {
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroups)]; id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroups)];
NSArray *groups = [target currentTargetGroups]; NSArray *groups = target.currentTargetGroups;
if(groups.count == 1) { if(groups.count == 1) {
[(MPDocument *)self.document createEntry:groups.firstObject]; [(MPDocument *)self.document createEntry:groups.firstObject];
} }
@@ -408,7 +408,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
- (void)delete:(id)sender { - (void)delete:(id)sender {
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetNodes)]; id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetNodes)];
NSArray *nodes = [target currentTargetNodes]; NSArray *nodes = target.currentTargetNodes;
for(KPKNode *node in nodes) { for(KPKNode *node in nodes) {
[self.document deleteNode:node]; [self.document deleteNode:node];
} }
@@ -460,7 +460,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
- (void)performAutotypeForEntry:(id)sender { - (void)performAutotypeForEntry:(id)sender {
id<MPTargetNodeResolving> entryResolver = [NSApp targetForAction:@selector(currentTargetEntries)]; id<MPTargetNodeResolving> entryResolver = [NSApp targetForAction:@selector(currentTargetEntries)];
NSArray *entries = [entryResolver currentTargetEntries]; NSArray *entries = entryResolver.currentTargetEntries;
if(entries.count == 1) { if(entries.count == 1) {
[[MPAutotypeDaemon defaultDaemon] performAutotypeForEntry:entries.firstObject]; [[MPAutotypeDaemon defaultDaemon] performAutotypeForEntry:entries.firstObject];
} }

View File

@@ -409,7 +409,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
} }
- (NSArray<KPKNode *> *)currentTargetNodes { - (NSArray<KPKNode *> *)currentTargetNodes {
NSArray *entries = [self currentTargetEntries]; NSArray *entries = self.currentTargetEntries;
if(entries.count > 0) { if(entries.count > 0) {
return entries; return entries;
} }
@@ -641,7 +641,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
#pragma mark Actions #pragma mark Actions
- (void)copyPassword:(id)sender { - (void)copyPassword:(id)sender {
NSArray *nodes = [self currentTargetNodes]; NSArray *nodes = self.currentTargetNodes;
KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil;
NSString *value = [selectedEntry.password kpk_finalValueForEntry:selectedEntry]; NSString *value = [selectedEntry.password kpk_finalValueForEntry:selectedEntry];
if(value) { if(value) {
@@ -650,7 +650,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
} }
- (void)copyUsername:(id)sender { - (void)copyUsername:(id)sender {
NSArray *nodes = [self currentTargetNodes]; NSArray *nodes = self.currentTargetNodes;
KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil;
NSString *value = [selectedEntry.username kpk_finalValueForEntry:selectedEntry]; NSString *value = [selectedEntry.username kpk_finalValueForEntry:selectedEntry];
if(value) { if(value) {
@@ -659,7 +659,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
} }
- (void)copyCustomAttribute:(id)sender { - (void)copyCustomAttribute:(id)sender {
NSArray *nodes = [self currentTargetNodes]; NSArray *nodes = self.currentTargetNodes;
KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil;
if(selectedEntry && [selectedEntry isKindOfClass:[KPKEntry class]]) { if(selectedEntry && [selectedEntry isKindOfClass:[KPKEntry class]]) {
NSUInteger index = [sender tag]; NSUInteger index = [sender tag];
@@ -673,7 +673,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
} }
- (void)copyURL:(id)sender { - (void)copyURL:(id)sender {
NSArray *nodes = [self currentTargetNodes]; NSArray *nodes = self.currentTargetNodes;
KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil;
NSString *value = [selectedEntry.url kpk_finalValueForEntry:selectedEntry]; NSString *value = [selectedEntry.url kpk_finalValueForEntry:selectedEntry];
if(value) { if(value) {
@@ -711,7 +711,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
} }
- (void)delete:(id)sender { - (void)delete:(id)sender {
NSArray *entries = [self currentTargetEntries]; NSArray *entries = self.currentTargetEntries;
MPDocument *document = self.windowController.document; MPDocument *document = self.windowController.document;
for(KPKEntry *entry in entries) { for(KPKEntry *entry in entries) {
[document deleteNode:entry]; [document deleteNode:entry];
@@ -720,7 +720,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
- (void)revertToHistoryEntry:(id)sender { - (void)revertToHistoryEntry:(id)sender {
MPDocument *document = self.windowController.document; MPDocument *document = self.windowController.document;
NSArray<KPKEntry *> *historyEntries = [self currentTargetEntries]; NSArray<KPKEntry *> *historyEntries = self.currentTargetEntries;
if(historyEntries.count != 1) { if(historyEntries.count != 1) {
return; return;
} }

View File

@@ -197,7 +197,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
} }
- (NSArray<KPKNode *> *)currentTargetNodes { - (NSArray<KPKNode *> *)currentTargetNodes {
NSArray *groups = [self currentTargetGroups]; NSArray *groups = self.currentTargetGroups;
if(groups.count > 0) { if(groups.count > 0) {
return groups; return groups;
} }
@@ -221,7 +221,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
return; // Nothing we need to worry about return; // Nothing we need to worry about
} }
MPDocument *document = self.windowController.document; MPDocument *document = self.windowController.document;
document.selectedGroups = [self currentTargetGroups]; document.selectedGroups = self.currentTargetGroups;
} }
- (void)_outlineDidScroll:(NSNotification *)notification { - (void)_outlineDidScroll:(NSNotification *)notification {
@@ -233,7 +233,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
CGPoint point = CGPointMake(clipView.bounds.origin.x, clipView.bounds.origin.y + 11); CGPoint point = CGPointMake(clipView.bounds.origin.x, clipView.bounds.origin.y + 11);
NSInteger topRow = [self.outlineView rowAtPoint:point]; NSInteger topRow = [self.outlineView rowAtPoint:point];
id item = [[self.outlineView itemAtRow:topRow] representedObject]; id item = [[self.outlineView itemAtRow:topRow] representedObject];
if([item isKindOfClass:[KPKGroup class]]) { if([item isKindOfClass:KPKGroup.class]) {
KPKGroup *group = item; KPKGroup *group = item;
MPDocument *document = self.windowController.document; MPDocument *document = self.windowController.document;
document.tree.metaData.lastTopVisibleGroup = group.uuid; document.tree.metaData.lastTopVisibleGroup = group.uuid;
@@ -309,7 +309,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
- (void)outlineViewSelectionDidChange:(NSNotification *)notification { - (void)outlineViewSelectionDidChange:(NSNotification *)notification {
MPDocument *document = self.windowController.document; MPDocument *document = self.windowController.document;
NSArray<KPKGroup *> *groups = [self currentTargetGroups]; NSArray<KPKGroup *> *groups = self.currentTargetGroups;
/* only update state if binding is set up to prevent resetting on first show */ /* only update state if binding is set up to prevent resetting on first show */
if(_bindingEstablished) { if(_bindingEstablished) {
NSUUID *oldValue = document.tree.metaData.lastSelectedGroup; NSUUID *oldValue = document.tree.metaData.lastSelectedGroup;
@@ -359,7 +359,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
if(![document validateUserInterfaceItem:menuItem]) { if(![document validateUserInterfaceItem:menuItem]) {
return NO; return NO;
} }
KPKGroup *group = [self currentTargetNodes].firstObject.asGroup; KPKGroup *group = self.currentTargetNodes.firstObject.asGroup;
return group.isTrash && group.isTrashed; return group.isTrash && group.isTrashed;
} }

View File

@@ -28,8 +28,8 @@
@protocol MPTargetNodeResolving <NSObject> @protocol MPTargetNodeResolving <NSObject>
@optional @optional
- (NSArray<KPKNode *> *)currentTargetNodes; @property (nonatomic, readonly, copy) NSArray<KPKNode *> *currentTargetNodes;
- (NSArray<KPKGroup *> *)currentTargetGroups; @property (nonatomic, readonly, copy) NSArray<KPKGroup *> *currentTargetGroups;
- (NSArray<KPKEntry *> *)currentTargetEntries; @property (nonatomic, readonly, copy) NSArray<KPKEntry *> *currentTargetEntries;
@end @end