Extracted search into own class

This commit is contained in:
michael starke
2014-08-27 12:13:24 +02:00
parent 554da9dfc7
commit 0286ed4e5c
10 changed files with 135 additions and 36 deletions

View File

@@ -30,13 +30,17 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
- (void)performFindPanelAction:(id)sender {
self.hasSearch = YES;
/* the search context is loaded via defaults */
self.searchContext = [[MPEntrySearchContext alloc] init];
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidEnterSearchNotification object:self];
[self updateSearch:self];
}
- (void)updateSearch:(id)sender {
MPDocumentWindowController *windowController = [self windowControllers][0];
self.searchString = [windowController.searchField stringValue];
NSString *searchString = [windowController.searchField stringValue];
/* Update the search string */
self.searchContext = [[MPEntrySearchContext alloc] initWithString:searchString flags:self.searchContext.searchFlags];
if(NO == self.hasSearch) {
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidEnterSearchNotification object:self];
}
@@ -53,8 +57,10 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
}
- (void)exitSearch:(id)sender {
self.searchString = nil;
self.searchContext = nil;
/*self.searchString = nil;
self.hasSearch = NO;
*/
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidExitSearchNotification object:self];
}
@@ -97,6 +103,10 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
}
}
- (NSArray *)entriesMatchingSearch:(MPEntrySearchContext *)search {
return nil;
}
#pragma mark Search
- (NSArray *)_findEntriesMatchingCurrentSearch {
/* Filter double passwords */