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

View File

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

View File

@@ -197,7 +197,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
}
- (NSArray<KPKNode *> *)currentTargetNodes {
NSArray *groups = [self currentTargetGroups];
NSArray *groups = self.currentTargetGroups;
if(groups.count > 0) {
return groups;
}
@@ -221,7 +221,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
return; // Nothing we need to worry about
}
MPDocument *document = self.windowController.document;
document.selectedGroups = [self currentTargetGroups];
document.selectedGroups = self.currentTargetGroups;
}
- (void)_outlineDidScroll:(NSNotification *)notification {
@@ -233,7 +233,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
CGPoint point = CGPointMake(clipView.bounds.origin.x, clipView.bounds.origin.y + 11);
NSInteger topRow = [self.outlineView rowAtPoint:point];
id item = [[self.outlineView itemAtRow:topRow] representedObject];
if([item isKindOfClass:[KPKGroup class]]) {
if([item isKindOfClass:KPKGroup.class]) {
KPKGroup *group = item;
MPDocument *document = self.windowController.document;
document.tree.metaData.lastTopVisibleGroup = group.uuid;
@@ -309,14 +309,14 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
- (void)outlineViewSelectionDidChange:(NSNotification *)notification {
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 */
if(_bindingEstablished) {
NSUUID *oldValue = document.tree.metaData.lastSelectedGroup;
document.tree.metaData.lastSelectedGroup = (groups.count == 1 ? groups.firstObject.uuid : [NSUUID kpk_nullUUID]);
NSUUID *newVlaue = document.tree.metaData.lastSelectedGroup;
if(![oldValue isEqual:newVlaue]) {
[document updateChangeCount:NSChangeDone|NSChangeDiscardable];
[document updateChangeCount:NSChangeDone|NSChangeDiscardable];
}
}
document.selectedGroups = groups;
@@ -359,7 +359,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
if(![document validateUserInterfaceItem:menuItem]) {
return NO;
}
KPKGroup *group = [self currentTargetNodes].firstObject.asGroup;
KPKGroup *group = self.currentTargetNodes.firstObject.asGroup;
return group.isTrash && group.isTrashed;
}

View File

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