Moved StringToURLTransformer to its own file.
This commit is contained in:
parent
facdea9b7e
commit
7bb24f5179
4 changed files with 42 additions and 22 deletions
|
@ -9,9 +9,6 @@
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
@class SpotlightWindowController;
|
@class SpotlightWindowController;
|
||||||
|
|
||||||
@interface StringToURLTransformer: NSValueTransformer {}
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface PausingQueryTransformer: NSValueTransformer {
|
@interface PausingQueryTransformer: NSValueTransformer {
|
||||||
NSArray *oldResults;
|
NSArray *oldResults;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,25 +9,6 @@
|
||||||
#import "SpotlightTransformers.h"
|
#import "SpotlightTransformers.h"
|
||||||
#import "SpotlightWindowController.h"
|
#import "SpotlightWindowController.h"
|
||||||
|
|
||||||
@implementation StringToURLTransformer
|
|
||||||
+ (Class)transformedValueClass { return [NSURL class]; }
|
|
||||||
+ (BOOL)allowsReverseTransformation { return YES; }
|
|
||||||
|
|
||||||
// Convert from string to NSURL
|
|
||||||
- (id)transformedValue:(id)value {
|
|
||||||
if (value == nil) return nil;
|
|
||||||
|
|
||||||
return [NSURL URLWithString:value];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert from NSURL to string
|
|
||||||
- (id)reverseTransformedValue:(id)value {
|
|
||||||
if (value == nil) return nil;
|
|
||||||
|
|
||||||
return [value absoluteString];
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
// This is what we use instead of an outlet for PausingQueryTransformer
|
// This is what we use instead of an outlet for PausingQueryTransformer
|
||||||
static SpotlightWindowController * searchController;
|
static SpotlightWindowController * searchController;
|
||||||
|
|
||||||
|
|
14
Utils/StringToURLTransformer.h
Normal file
14
Utils/StringToURLTransformer.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
//
|
||||||
|
// StringToURLTransformer.h
|
||||||
|
// Cog
|
||||||
|
//
|
||||||
|
// Created by Vincent Spader on 2/17/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
|
||||||
|
@interface StringToURLTransformer: NSValueTransformer {}
|
||||||
|
@end
|
||||||
|
|
28
Utils/StringToURLTransformer.m
Normal file
28
Utils/StringToURLTransformer.m
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
//
|
||||||
|
// StringToURLTransformer.m
|
||||||
|
// Cog
|
||||||
|
//
|
||||||
|
// Created by Vincent Spader on 2/17/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "StringToURLTransformer.h"
|
||||||
|
|
||||||
|
@implementation StringToURLTransformer
|
||||||
|
+ (Class)transformedValueClass { return [NSURL class]; }
|
||||||
|
+ (BOOL)allowsReverseTransformation { return YES; }
|
||||||
|
|
||||||
|
// Convert from string to NSURL
|
||||||
|
- (id)transformedValue:(id)value {
|
||||||
|
if (value == nil) return nil;
|
||||||
|
|
||||||
|
return [NSURL URLWithString:value];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert from NSURL to string
|
||||||
|
- (id)reverseTransformedValue:(id)value {
|
||||||
|
if (value == nil) return nil;
|
||||||
|
|
||||||
|
return [value absoluteString];
|
||||||
|
}
|
||||||
|
@end
|
Loading…
Reference in a new issue