mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 01:12:31 +00:00
broke commit
This commit is contained in:
@@ -10,8 +10,9 @@
|
||||
|
||||
@class MPDocument;
|
||||
|
||||
FOUNDATION_EXTERN NSString *const MPSearchServiceSearchDidChangeNotification;
|
||||
FOUNDATION_EXTERN NSString *const MPSearchServiceSearchWasClearedNotification;
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentSearchServiceDidChangeSearchNotification;
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentSearchServiceDidClearSearchNotification;
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentSearchServiceDidExitSearchNotification;
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, MPEntrySearchFlags) {
|
||||
MPEntrySearchNone = 0,
|
||||
@@ -27,11 +28,14 @@ typedef NS_OPTIONS(NSUInteger, MPEntrySearchFlags) {
|
||||
|
||||
@property (nonatomic, assign) MPEntrySearchFlags activeFlags;
|
||||
@property (nonatomic, copy) NSString *searchString;
|
||||
@property (nonatomic, weak) NSSearchField *searchField;
|
||||
|
||||
+ (instancetype)sharedService;
|
||||
- (NSArray *)entriesInDocument:(MPDocument *)document matching:(NSString *)string usingSearchMode:(MPEntrySearchFlags)mode;
|
||||
- (NSArray *)optionsEnabledInMode:(MPEntrySearchFlags)mode;
|
||||
|
||||
/* Should be called by the NSSearchTextField to update the search string */
|
||||
- (IBAction)updateSearch:(id)sender;
|
||||
/* Clears the search string, but doesn't exit searching */
|
||||
- (IBAction)clearSearch:(id)sender;
|
||||
/* exits searching mode */
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
#import "KPKEntry.h"
|
||||
#import "MPFlagsHelper.h"
|
||||
|
||||
NSString *const MPDocumentSearchServiceDidChangeSearchNotification = @"com.hicknhack.macpass.MPDocumentSearchServiceDidChangeSearchNotification";
|
||||
NSString *const MPDocumentSearchServiceDidClearSearchNotification = @"com.hicknhack.macpass.MPDocumentSearchServiceDidClearSearchNotification";
|
||||
NSString *const MPDocumentSearchServiceDidExitSearchNotification = @"com.hicknhack.macpass.MPDocumentSearchServiceDidExitSearchNotification";
|
||||
|
||||
@implementation MPDocumentSearchService
|
||||
|
||||
static MPDocumentSearchService *_kMPSearchServiceInstance;
|
||||
@@ -33,6 +37,30 @@ static MPDocumentSearchService *_kMPSearchServiceInstance;
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark Actions
|
||||
- (void)updateSearch:(id)sender {
|
||||
if(sender != self.searchField) {
|
||||
return; // Wrong sender
|
||||
}
|
||||
self.searchString = [self.searchField stringValue];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentSearchServiceDidChangeSearchNotification object:self];
|
||||
}
|
||||
|
||||
- (void)clearSearch:(id)sender {
|
||||
if(sender != self.searchField) {
|
||||
return; // Wrong sender
|
||||
}
|
||||
[self.searchField setStringValue:@""];
|
||||
self.searchString = nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentSearchServiceDidClearSearchNotification object:self];
|
||||
}
|
||||
|
||||
- (void)exitSearch:(id)sender {
|
||||
[self.searchField setStringValue:@""];
|
||||
self.searchString = nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentSearchServiceDidExitSearchNotification object:self];
|
||||
}
|
||||
|
||||
- (NSArray *)entriesInDocument:(MPDocument *)document matching:(NSString *)string usingSearchMode:(MPEntrySearchFlags)mode {
|
||||
/* Filter double passwords */
|
||||
if(MPTestFlagInOptions(MPEntrySearchDoublePasswords, mode)) {
|
||||
|
||||
@@ -26,6 +26,4 @@
|
||||
|
||||
@interface MPToolbarDelegate : NSObject <NSToolbarDelegate>
|
||||
|
||||
@property (weak, readonly) NSSearchField *searchField;
|
||||
|
||||
@end
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#import "MPIconHelper.h"
|
||||
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPDocumentSearchService.h"
|
||||
|
||||
NSString *const MPToolbarItemLock = @"TOOLBAR_LOCK";
|
||||
NSString *const MPToolbarItemAddGroup = @"TOOLBAR_ADD_GROUP";
|
||||
@@ -137,7 +138,6 @@ NSString *const MPToolbarItemSearch = @"TOOLBAR_SEARCH";
|
||||
NSSearchFieldCell *cell = [searchField cell];
|
||||
[[cell cancelButtonCell] setAction:@selector(cancelSearch:)];
|
||||
[[cell cancelButtonCell] setTarget:nil];
|
||||
self.searchField = searchField;
|
||||
[item setView:searchField];
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user