Changeset 4983

Show
Ignore:
Timestamp:
10/20/07 02:43:50 (9 months ago)
Author:
morris
Message:

Fix Spotlight search

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Footagehead/trunk/FHSpotlightHandler.m

    r4726 r4983  
    3030#import "FHSpotlightHandler.h" 
    3131 
     32@interface FHSpotlightHandler(Private) 
     33 
     34- (void)_addFilesFromQuery; 
     35 
     36@end 
     37 
     38 
     39@implementation FHSpotlightHandler(Private) 
     40 
     41- (void)_addFilesFromQuery { 
     42        NSMetadataItem  *item; 
     43        NSString                *path; 
     44        NSUInteger              count; 
     45         
     46        count = [_query resultCount]; 
     47         
     48        for(; _index < count; _index++) { 
     49                item = [_query resultAtIndex:_index]; 
     50                path = [item valueForAttribute:@"kMDItemPath"]; 
     51                 
     52                if(path) { 
     53                        [_files addObject:[FHFile fileWithURL:[WIURL fileURLWithPath:path] isDirectory:NO]]; 
     54                         
     55                        _numberOfFiles++; 
     56                        _numberOfImages++; 
     57                         
     58                        [_delegate handlerDidAddFiles:self]; 
     59                } 
     60        } 
     61} 
     62 
     63@end 
     64 
     65 
     66 
    3267@implementation FHSpotlightHandler 
    3368 
     
    4580        _query = [[NSMetadataQuery alloc] init]; 
    4681        [_query setPredicate:[NSPredicate predicateWithFormat: 
    47                 @"(kMDItemFSName LIKE[cd] %@) && (kMDItemContentTypeTree == \"public.image\")", 
    48                 [[url path] substringFromIndex:1]]]; 
    49  
     82                [NSSWF:@"(kMDItemDisplayName LIKE[cd] '*%@*') && (kMDItemContentTypeTree == \"public.image\")", 
     83                       [[url path] substringFromIndex:1]]]]; 
     84         
    5085        [[NSNotificationCenter defaultCenter] 
    5186                addObserver:self 
    5287                   selector:@selector(metadataQueryGatheringProgress:) 
    5388                           name:NSMetadataQueryGatheringProgressNotification]; 
     89         
     90        [[NSNotificationCenter defaultCenter] 
     91                addObserver:self 
     92                   selector:@selector(metadataQueryDidUpdate:) 
     93                           name:NSMetadataQueryDidUpdateNotification]; 
    5494         
    5595        [[NSNotificationCenter defaultCenter] 
     
    76116 
    77117- (void)metadataQueryGatheringProgress:(NSNotification *)notification { 
    78         NSMetadataItem  *item; 
    79         NSString                *path; 
    80         NSUInteger              count; 
    81          
    82         count = [_query resultCount]; 
    83          
    84         for(; _index < count; _index++) { 
    85                 item = [_query resultAtIndex:_index]; 
    86                 path = [item valueForAttribute:@"kMDItemPath"]; 
    87                  
    88                 if(path) { 
    89                         [_files addObject:[FHFile fileWithURL:[WIURL fileURLWithPath:path] isDirectory:NO]]; 
    90                          
    91                         _numberOfFiles++; 
    92                         _numberOfImages++; 
    93                          
    94                         [_delegate handlerDidAddFiles:self]; 
    95                 } 
    96         } 
     118        [self _addFilesFromQuery]; 
    97119} 
    98120 
     121 
     122 
     123- (void)metadataQueryDidUpdate:(NSNotification *)notification { 
     124        [self _addFilesFromQuery]; 
     125} 
     126         
    99127 
    100128 
  • Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj

    r4981 r4983  
    178178                        containerPortal = 77396B390857A18300058AF5 /* WiredAdditions.xcodeproj */; 
    179179                        proxyType = 2; 
    180                         remoteGlobalIDString = 774897900CC8A63200E95A83 /* WiredNetworking.framework */
     180                        remoteGlobalIDString = 774897900CC8A63200E95A83
    181181                        remoteInfo = "Wired Networking"; 
    182182                };