BathyScapheのthreadファイルをSpotlightを用いて検索する
Revisão | ce173f62094fb727c99037025dce44f09166ef71 (tree) |
---|---|
Hora | 2009-04-18 23:17:18 |
Autor | masakih <masakih@user...> |
Commiter | masakih |
NSPredicateの条件を見直し。
git-svn-id: svn+ssh://macmini/usr/local/svnrepos/BSSpotlighter/BSSpotlighter@6 349e1e32-f012-47ec-a20f-05ec029f004b
@@ -23,4 +23,6 @@ | ||
23 | 23 | |
24 | 24 | - (void)openThread:(id)path; |
25 | 25 | |
26 | +- (id) metadataQuery; | |
27 | +- (void) setMatadataQuery: (id) newValue; | |
26 | 28 | @end |
@@ -17,7 +17,7 @@ enum { | ||
17 | 17 | }; |
18 | 18 | |
19 | 19 | @interface BSSpotlighter(HMPrivate) |
20 | -- (NSMetadataQuery *)createQuery; | |
20 | +-(NSArray *)bsDocumentDirectory; | |
21 | 21 | - (NSPredicate *)createPredicate; |
22 | 22 | |
23 | 23 | - (void)setCurrentPredicateForMenuItem:(id)item; |
@@ -88,6 +88,27 @@ static NSString *CustomTableViewStateKey = @"CustomTableViewState"; | ||
88 | 88 | } |
89 | 89 | |
90 | 90 | #pragma mark## Key Value Coding ## |
91 | +- (id) metadataQuery | |
92 | +{ | |
93 | + if(mQuery) return mQuery; | |
94 | + | |
95 | +// [self willChangeValueForKey:@"mQuery"]; | |
96 | + | |
97 | + mQuery = [[NSMetadataQuery alloc] init]; | |
98 | + if(!mQuery) return nil; | |
99 | + | |
100 | + [mQuery setSearchScopes:[self bsDocumentDirectory]]; | |
101 | + | |
102 | +// [self didChangeValueForKey:@"mQuery"]; | |
103 | + | |
104 | + return mQuery; | |
105 | +} | |
106 | + | |
107 | +- (void) setMatadataQuery: (id) newValue | |
108 | +{ | |
109 | + [mQuery autorelease]; | |
110 | + mQuery = [newValue retain]; | |
111 | +} | |
91 | 112 | - (NSArray *)currentKeys |
92 | 113 | { |
93 | 114 | return mCurrentKeys; |
@@ -363,21 +384,6 @@ static NSString *CustomTableViewStateKey = @"CustomTableViewState"; | ||
363 | 384 | } |
364 | 385 | |
365 | 386 | #pragma mark - |
366 | -- (NSMetadataQuery *)createQuery | |
367 | -{ | |
368 | - if(mQuery) return mQuery; | |
369 | - | |
370 | - [self willChangeValueForKey:@"mQuery"]; | |
371 | - | |
372 | - mQuery = [[NSMetadataQuery alloc] init]; | |
373 | - if(!mQuery) return nil; | |
374 | - | |
375 | - [mQuery setSearchScopes:[self bsDocumentDirectory]]; | |
376 | - | |
377 | - [self didChangeValueForKey:@"mQuery"]; | |
378 | - | |
379 | - return mQuery; | |
380 | -} | |
381 | 387 | - (NSPredicate *)createPredicate |
382 | 388 | { |
383 | 389 | NSPredicate *predicate; |
@@ -412,16 +418,13 @@ static NSString *CustomTableViewStateKey = @"CustomTableViewState"; | ||
412 | 418 | predicate02 = [array componentsJoinedByString:@" || "]; |
413 | 419 | } |
414 | 420 | |
415 | - predicate02 = [NSString stringWithFormat:@"kMDItemContentType == \"jp.tsawada2.bathyscaphe.thread\" && (%@)", predicate02]; | |
421 | + predicate02 = [NSString stringWithFormat:@"kMDItemContentType = \"jp.tsawada2.bathyscaphe.thread\" && (%@)", predicate02]; | |
416 | 422 | predicate = [NSPredicate predicateWithFormat:predicate02]; |
417 | 423 | BSSLog(@"Tokens -> %@", predicate); |
418 | 424 | |
419 | - if(!mQuery) { | |
420 | - [self createQuery]; | |
421 | - } | |
422 | - [mQuery setPredicate:predicate]; | |
423 | - if(![mQuery isStarted]) { | |
424 | - [mQuery startQuery]; | |
425 | + [[self metadataQuery] setPredicate:predicate]; | |
426 | + if(![[self metadataQuery] isStarted]) { | |
427 | + [[self metadataQuery] startQuery]; | |
425 | 428 | } |
426 | 429 | |
427 | 430 | return predicate; |