Search structurally works again. Filtering is not polished.

This commit is contained in:
michael starke
2014-02-27 21:54:59 +01:00
parent 4273e41142
commit 90d5bc9ef2
3 changed files with 9 additions and 9 deletions

View File

@@ -99,7 +99,7 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
- (void)_didChangeCurrentItem:(NSNotification *)notification { - (void)_didChangeCurrentItem:(NSNotification *)notification {
MPDocument *document = [notification object]; MPDocument *document = [notification object];
BOOL showTrash = document.useTrash && (document.selectedGroup == document.trash || [document isItemTrashed:document.selectedItem]); BOOL showTrash = document.useTrash && (document.selectedGroup == document.trash || [document isItemTrashed:document.selectedItem]);
if(showTrash) { if(showTrash && ! document.hasSearch) {
self.activeTab = MPContextTabTrash; self.activeTab = MPContextTabTrash;
[self _updateBindings]; [self _updateBindings];
} }

View File

@@ -31,6 +31,7 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
- (void)performFindPanelAction:(id)sender { - (void)performFindPanelAction:(id)sender {
self.hasSearch = YES; self.hasSearch = YES;
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidEnterSearchNotification object:self]; [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidEnterSearchNotification object:self];
[self updateSearch:self];
} }
- (void)updateSearch:(id)sender { - (void)updateSearch:(id)sender {

View File

@@ -199,7 +199,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
selector:@selector(_didEnterSearch:) selector:@selector(_didEnterSearch:)
name:MPDocumentDidEnterSearchNotification name:MPDocumentDidEnterSearchNotification
object:document]; object:document];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didExitSearch:) selector:@selector(_didExitSearch:)
name:MPDocumentDidExitSearchNotification name:MPDocumentDidExitSearchNotification
@@ -300,7 +300,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
} }
} }
#pragma mark Notifications #pragma mark MPDocument Notifications
- (void)_didChangeCurrentItem:(NSNotification *)notification { - (void)_didChangeCurrentItem:(NSNotification *)notification {
MPDocument *document = [notification object]; MPDocument *document = [notification object];
@@ -312,9 +312,9 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
If a group is the current item, see if we already show that group If a group is the current item, see if we already show that group
*/ */
if(document.selectedItem == document.selectedGroup) { if(document.selectedItem == document.selectedGroup) {
/* If we change to a group selection, we should clear the filter */ if(document.hasSearch) {
if(_isDisplayingContextBar) { /* If search was active, stop it and exit */
// nothing? [document exitSearch:self];
} }
else if([[self.entryArrayController content] count] > 0) { else if([[self.entryArrayController content] count] > 0) {
KPKEntry *entry = [[self.entryArrayController content] lastObject]; KPKEntry *entry = [[self.entryArrayController content] lastObject];
@@ -336,9 +336,8 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
document.selectedEntry = nil; document.selectedEntry = nil;
} }
} }
#pragma mark MPDocumentSearchServiceNotifications
- (void)_didUpdateSearchResults:(NSNotification *)notification { - (void)_didUpdateSearchResults:(NSNotification *)notification {
BOOL main = [NSThread isMainThread];
[self _showContextBar]; [self _showContextBar];
NSArray *result = [notification userInfo][kMPDocumentSearchResultsKey]; NSArray *result = [notification userInfo][kMPDocumentSearchResultsKey];
NSAssert(result != nil, @"Resutls should never be nil"); NSAssert(result != nil, @"Resutls should never be nil");
@@ -348,7 +347,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:NO]; [[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:NO];
} }
#pragma mark NSDocument+Search Notifications
- (void)_didExitSearch:(NSNotification *)notification { - (void)_didExitSearch:(NSNotification *)notification {
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES]; [[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES];
MPDocument *document = [[self windowController] document]; MPDocument *document = [[self windowController] document];