From 019e64a9266924f2e99cd7aca6d095e099a1c2fb Mon Sep 17 00:00:00 2001 From: michael starke Date: Mon, 18 Aug 2014 12:23:11 +0200 Subject: [PATCH] Fixed exit Search issues Exiting search now clears matching entries when no group was preselected (use case is opening a DB and then search without selecting a group) Deleting a group now correctly deselects the group. Previously the inspector still showed the group, but the outline view did not show any selection. --- MacPass/MPEntryViewController.m | 10 ++++++++-- MacPass/MPOutlineViewController.m | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 6f841bd4..c6c057f1 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -328,8 +328,10 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; - (void)_didChangeCurrentItem:(NSNotification *)notification { MPDocument *document = [notification object]; - if(!document.selectedGroup) { - /* TODO: handle deleted item */ + if(!document.selectedGroup && !document.hasSearch) { + /* no group selection out of search is wrong */ + [self.entryArrayController unbind:NSContentArrayBinding]; + [self.entryArrayController setContent:nil]; return; } /* @@ -384,6 +386,10 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; [[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES]; MPDocument *document = [[self windowController] document]; document.selectedItem = document.selectedGroup; + if( nil == document.selectedItem && nil == document.selectedGroup ) { + [self.entryArrayController unbind:NSContentArrayBinding]; + [self.entryArrayController setContent:nil]; + } [self _updateContextBar]; } diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index ee537209..66ac9714 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -247,7 +247,6 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; id representedObject = [item representedObject]; if([representedObject isKindOfClass:[KPKGroup class]]) { KPKGroup *group = (KPKGroup *)representedObject; - NSLog(@"IndexPath for %@: %@ vs. %@", group.name, [item indexPath], [group indexPath]); group.isExpanded = YES; } } @@ -261,6 +260,13 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; } } +- (void)outlineView:(NSOutlineView *)outlineView didRemoveRowView:(NSTableRowView *)rowView forRow:(NSInteger)row { + /* Deletion of an item */ + if(row == -1) { + [self outlineViewSelectionDidChange:nil]; + } +} + #pragma mark Validation - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { MPDocument *document = [[self windowController] document];