mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 08:52:20 +00:00
Added double click action to select the group of the currently selected entry.
This feature is mainly aimed to ease navigation when browsing search results
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -26,12 +26,14 @@
|
||||
APPKIT_EXTERN NSString *const MPOutlineViewDidChangeGroupSelection;
|
||||
|
||||
@class MPDocument;
|
||||
@class KPKGroup;
|
||||
|
||||
@interface MPOutlineViewController : MPViewController <MPTargetNodeResolving, NSOutlineViewDelegate, NSMenuDelegate>
|
||||
|
||||
- (void)clearSelection;
|
||||
- (void)showOutline;
|
||||
- (void)registerNotificationsForDocument:(MPDocument *)document;
|
||||
- (void)selectGroup:(KPKGroup *)group;
|
||||
|
||||
/**
|
||||
* Retrieves the current item for the current mouse location
|
||||
|
||||
@@ -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]) {
|
||||
|
||||
Reference in New Issue
Block a user