diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 6f0efab6..f074d6d6 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -752,11 +752,11 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; if(0 == [self.entryArrayController.arrangedObjects count]) { return; // No data available } - NSInteger columnIndex = [self.entryTable clickedColumn]; + NSInteger columnIndex = self.entryTable.clickedColumn; if(columnIndex < 0 || columnIndex >= self.entryTable.tableColumns.count) { return; // No Column to use } - NSTableColumn *column = self.entryTable.tableColumns[self.entryTable.clickedColumn]; + NSTableColumn *column = self.entryTable.tableColumns[columnIndex]; NSString *identifier = column.identifier; if([identifier isEqualToString:MPEntryTableTitleColumnIdentifier]) { [self _executeTitleColumnDoubleClick]; @@ -770,9 +770,21 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; else if([identifier isEqualToString:MPEntryTableURLColumnIdentifier]) { [self _executeURLColumnDoubleClick]; } + else if([identifier isEqualToString:MPEntryTableParentColumnIdentifier]) { + [self _executeGroupColumnDoubleClick]; + } // TODO: Add more actions for new columns } +- (void)_executeGroupColumnDoubleClick { + NSUInteger clickedRow = self.entryTable.clickedRow; + if(clickedRow < 0 || clickedRow > [self.entryArrayController.arrangedObjects count]) { + return; + } + KPKEntry *entry = self.entryArrayController.arrangedObjects[clickedRow]; + [((MPDocumentWindowController *)self.windowController).outlineViewController selectGroup:entry.parent]; +} + - (void)_executeTitleColumnDoubleClick { MPDoubleClickTitleAction action = [NSUserDefaults.standardUserDefaults integerForKey:kMPSettingsKeyDoubleClickTitleAction]; switch(action) { diff --git a/MacPass/MPOutlineViewController.h b/MacPass/MPOutlineViewController.h index bd64098b..7fd8492c 100644 --- a/MacPass/MPOutlineViewController.h +++ b/MacPass/MPOutlineViewController.h @@ -26,12 +26,14 @@ APPKIT_EXTERN NSString *const MPOutlineViewDidChangeGroupSelection; @class MPDocument; +@class KPKGroup; @interface MPOutlineViewController : MPViewController - (void)clearSelection; - (void)showOutline; - (void)registerNotificationsForDocument:(MPDocument *)document; +- (void)selectGroup:(KPKGroup *)group; /** * Retrieves the current item for the current mouse location diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 0c651275..3d492ca1 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -143,6 +143,22 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; } } +- (void)selectGroup:(KPKGroup *)group { + NSMutableArray *parents = [[NSMutableArray alloc] init]; + NSUUID *groupUUID = group.uuid; + while(group.parent) { + [parents insertObject:group.parent atIndex:0]; + group = group.parent; + } + NSTreeNode *node = [self.outlineView itemAtRow:0]; + for(KPKGroup *group in parents) { + NSUInteger row = [self _rowForUUID:group.uuid node:node]; + [self.outlineView expandItem:[self.outlineView itemAtRow:row]]; + } + NSUInteger rowToSelect = [self _rowForUUID:groupUUID node:node]; + [self.outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:rowToSelect] byExtendingSelection:NO]; +} + - (void)_expandItems:(NSTreeNode *)node { id nodeItem = node.representedObject; if([nodeItem isKindOfClass:KPKTree.class]) {