Multiple selections are now handled correctly

This commit is contained in:
michael starke
2016-02-26 14:26:09 +01:00
parent c4eb499cf6
commit cbb98ff50f
8 changed files with 125 additions and 140 deletions

View File

@@ -334,25 +334,31 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
}
- (void)createGroup:(id)sender {
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroup)];
KPKGroup *group = [target currentTargetGroup];
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroups)];
NSArray *groups = [target currentTargetGroups];
MPDocument *document = self.document;
if(!group) {
group = document.root;
if(groups.count == 1) {
[document createGroup:groups.firstObject];
}
else {
[document createGroup:document.root];
}
[document createGroup:group];
}
- (void)createEntry:(id)sender {
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroup)];
KPKGroup *group = [target currentTargetGroup];
[(MPDocument *)self.document createEntry:group];
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroups)];
NSArray *groups = [target currentTargetGroups];
if(groups.count == 1) {
[(MPDocument *)self.document createEntry:groups.firstObject];
}
}
- (void)delete:(id)sender {
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetNode)];
KPKNode *node = [target currentTargetNode];
[self.document deleteNode:node];
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetNodes)];
NSArray *nodes = [target currentTargetNodes];
for(KPKNode *node in nodes) {
[self.document deleteNode:node];
}
}
- (void)pickExpiryDate:(id)sender {
@@ -377,9 +383,11 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
}
- (void)performAutotypeForEntry:(id)sender {
id<MPTargetNodeResolving> entryResolver = [NSApp targetForAction:@selector(currentTargetEntry)];
KPKEntry *targetEntry = [entryResolver currentTargetEntry];
[[MPAutotypeDaemon defaultDaemon] performAutotypeForEntry:targetEntry];
id<MPTargetNodeResolving> entryResolver = [NSApp targetForAction:@selector(currentTargetEntries)];
NSArray *entries = [entryResolver currentTargetEntries];
if(entries.count == 1) {
[[MPAutotypeDaemon defaultDaemon] performAutotypeForEntry:entries.firstObject];
}
}
- (void)showInspector:(id)sender {